Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef GNASH_INPUTDEVICE_H
00019 #define GNASH_INPUTDEVICE_H
00020
00021 #ifdef HAVE_CONFIG_H
00022 #include "gnashconfig.h"
00023 #endif
00024
00025 #include <boost/scoped_array.hpp>
00026 #include <boost/shared_array.hpp>
00027 #include <boost/scoped_ptr.hpp>
00028 #include <boost/shared_ptr.hpp>
00029 #include <boost/cstdint.hpp>
00030
00031 #include "gui.h"
00032
00033 #include <linux/input.h>
00034
00035 namespace gnash {
00036
00037
00038
00039
00040
00041
00042
00043 class Gui;
00044
00045
00046
00047 static const int DEFAULT_BUFFER_SIZE = 256;
00048
00049
00050
00051 class InputDevice
00052 {
00053 public:
00054 typedef enum {
00055 UNKNOWN,
00056 KEYBOARD,
00057 MOUSE,
00058 TOUCHSCREEN,
00059 TOUCHMOUSE,
00060 POWERBUTTON,
00061 SLEEPBUTTON,
00062 SERIALUSB,
00063 INFRARED
00064 } devicetype_e;
00065 InputDevice();
00066 InputDevice(Gui *gui);
00067 virtual ~InputDevice();
00068
00069 virtual bool init();
00070 bool init(devicetype_e type);
00071 bool init(devicetype_e type, size_t size);
00072 bool init(devicetype_e type, const std::string &filespec);
00073 bool init(devicetype_e type, const std::string &filespec, size_t size);
00074 virtual bool init(const std::string &filespec, size_t size) = 0;
00075 virtual bool check() = 0;
00076
00077 static std::vector<boost::shared_ptr<InputDevice> > scanForDevices(Gui *gui);
00078
00079 InputDevice::devicetype_e getType() { return _type; };
00080
00081
00082 boost::shared_array<boost::uint8_t> readData(size_t size);
00083
00084 void dump();
00085
00086 protected:
00087 devicetype_e _type;
00088 std::string _filespec;
00089 int _fd;
00090 int _x;
00091 int _y;
00092
00093 int _button;
00094 size_t _position;
00095 boost::scoped_array<boost::uint8_t> _buffer;
00096
00097
00098 Gui *_gui;
00099 };
00100
00101 class MouseDevice : public InputDevice
00102 {
00103 public:
00104 MouseDevice();
00105 MouseDevice(Gui *gui);
00106 virtual bool init();
00107 virtual bool init(const std::string &filespec, size_t size);
00108 virtual bool check();
00109
00110 static std::vector<boost::shared_ptr<InputDevice> > scanForDevices(Gui *gui);
00111
00113 bool command(unsigned char cmd, unsigned char *buf, int count);
00114 };
00115
00116 class TouchDevice : public InputDevice
00117 {
00118 public:
00119 TouchDevice();
00120 TouchDevice(Gui *gui);
00121 virtual ~TouchDevice();
00122 virtual bool init();
00123 virtual bool init(const std::string &filespec, size_t size);
00124 virtual bool check();
00125
00126 void apply_ts_calibration(float* cx, float* cy, int rawx, int rawy);
00127
00128 static std::vector<boost::shared_ptr<InputDevice> > scanForDevices(Gui *gui);
00129 private:
00130
00131
00132 struct tsdev *_tsDev;
00133 };
00134
00135 class EventDevice : public InputDevice
00136 {
00137 public:
00138 EventDevice();
00139 EventDevice(Gui *gui);
00140 virtual bool init();
00141 virtual bool init(const std::string &filespec, size_t size);
00142 virtual bool check();
00143
00144 gnash::key::code scancode_to_gnash_key(int code, bool shift);
00145
00146
00147 static std::vector<boost::shared_ptr<InputDevice> > scanForDevices(Gui *gui);
00148
00149 private:
00150
00151 bool keyb_lshift, keyb_rshift, keyb_lctrl, keyb_rctrl, keyb_lalt, keyb_ralt;
00152 struct input_id _device_info;
00153 };
00154
00155 }
00156
00157
00158 #endif
00159
00160
00161
00162
00163