]> git.tdb.fi Git - libs/gui.git/blob - source/inputdevice.h
Initial revision
[libs/gui.git] / source / inputdevice.h
1 /* $Id$
2
3 This file is part of libmspgbase
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GBASE_INPUTDEVICE_H_
9 #define MSP_GBASE_INPUTDEVICE_H_
10
11 #include <vector>
12 #include <sigc++/signal.h>
13
14 namespace Msp {
15 namespace Input {
16
17 /**
18 Base class for input devices.  Input devices have two types of controls:
19 buttons and axes.  Buttons are either on or off.  Axes have a floating-point
20 value, with range depending on the device.
21 */
22 class Device
23 {
24 public:
25         sigc::signal<void, unsigned> signal_button_press;
26         sigc::signal<void, unsigned> signal_button_release;
27         sigc::signal<void, unsigned, float, float> signal_axis_motion;
28
29 protected:
30         std::vector<char>  buttons;
31         std::vector<float> axes;
32
33 public:
34         virtual ~Device() { }
35         bool  get_button_state(unsigned);
36         float get_axis_value(unsigned);
37 protected:
38         void set_button_state(unsigned, bool, bool);
39         void set_axis_value(unsigned, float, bool);
40 };
41
42 } // namespace Input
43 } // namespace Msp
44
45 #endif