|
Revision 13172, 2.2 kB
(checked in by robert, 10 hours ago)
|
|
Refactored the support for stereo and keystone RTT setup so that it can be applied to an existing Camera.
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | #ifndef SDLINTEGRATION |
|---|
| 14 | #define SDLINTEGRATION |
|---|
| 15 | |
|---|
| 16 | #include <osgGA/Device> |
|---|
| 17 | |
|---|
| 18 | #include <SDL.h> |
|---|
| 19 | #include <SDL_events.h> |
|---|
| 20 | #include <SDL_joystick.h> |
|---|
| 21 | |
|---|
| 22 | #include <vector> |
|---|
| 23 | #include <map> |
|---|
| 24 | |
|---|
| 25 | class JoystickDevice : public osgGA::Device |
|---|
| 26 | { |
|---|
| 27 | public: |
|---|
| 28 | |
|---|
| 29 | JoystickDevice(); |
|---|
| 30 | |
|---|
| 31 | typedef std::vector<int> ValueList; |
|---|
| 32 | typedef std::map<int, int> ButtonMap; |
|---|
| 33 | |
|---|
| 34 | virtual void checkEvents(); |
|---|
| 35 | |
|---|
| 36 | void addMouseButtonMapping(int joystickButton, int mouseButton) |
|---|
| 37 | { |
|---|
| 38 | _mouseButtonMap[joystickButton] = mouseButton; |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | int getMouseButtonMapping(int joystickButton) |
|---|
| 42 | { |
|---|
| 43 | ButtonMap::const_iterator itr = _mouseButtonMap.find(joystickButton); |
|---|
| 44 | if (itr != _mouseButtonMap.end()) return itr->second; |
|---|
| 45 | else return -1; |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | void addKeyMapping(int joystickButton, int key) |
|---|
| 49 | { |
|---|
| 50 | _keyMap[joystickButton] = key; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | int getKeyMapping(int joystickButton) |
|---|
| 54 | { |
|---|
| 55 | ButtonMap::const_iterator itr = _keyMap.find(joystickButton); |
|---|
| 56 | if (itr != _keyMap.end()) return itr->second; |
|---|
| 57 | else return -1; |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | protected: |
|---|
| 61 | |
|---|
| 62 | virtual ~JoystickDevice(); |
|---|
| 63 | |
|---|
| 64 | void capture(ValueList& axisValues, ValueList& buttonValues) const; |
|---|
| 65 | |
|---|
| 66 | SDL_Joystick* _joystick; |
|---|
| 67 | int _numAxes; |
|---|
| 68 | int _numBalls; |
|---|
| 69 | int _numHats; |
|---|
| 70 | int _numButtons; |
|---|
| 71 | bool _verbose; |
|---|
| 72 | |
|---|
| 73 | ValueList _axisValues; |
|---|
| 74 | ValueList _buttonValues; |
|---|
| 75 | ButtonMap _mouseButtonMap; |
|---|
| 76 | ButtonMap _keyMap; |
|---|
| 77 | }; |
|---|
| 78 | |
|---|
| 79 | #endif |
|---|