root/OpenSceneGraph/trunk/src/osgPlugins/sdl/JoystickDevice.h @ 13429

Revision 13429, 2.2 kB (checked in by robert, 18 hours ago)

Added VolumeSettings::Filename property.

Line 
1/* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield
2 *
3 * This software is open source and may be redistributed and/or modified under 
4 * the terms of the GNU General Public License (GPL) version 2.0.
5 * The full license is in LICENSE.txt file included with this distribution,.
6 *
7 * This software is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 * include LICENSE.txt for more details.
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
25class 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 bool 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
Note: See TracBrowser for help on using the browser.