00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PAPYRUSEVENT_H
00021 #define PAPYRUSEVENT_H
00022
00023 namespace Papyrus {
00024
00025 namespace Event {
00026
00027 typedef enum Type {
00028 BUTTON_PRESS,
00029 BUTTON_RELEASE,
00030 BUTTON_DOUBLE_PRESS,
00031 BUTTON_TRIPLE_PRESS,
00032 SCROLL,
00033 MOTION,
00034 KEY_PRESS,
00035 KEY_RELEASE,
00036 } Type;
00037
00038 typedef enum ScrollDirection {
00039 SCROLL_UP,
00040 SCROLL_DOWN,
00041 SCROLL_LEFT,
00042 SCROLL_RIGHT,
00043 } ScrollDirection;
00044
00045 typedef enum ButtonID {
00046 BUTTON_NONE = 0x00,
00047 BUTTON_1 = 0x01 << 0,
00048 BUTTON_2 = 0x01 << 1,
00049 BUTTON_3 = 0x01 << 2,
00050 BUTTON_4 = 0x01 << 3,
00051 BUTTON_5 = 0x01 << 4,
00052 BUTTON_6 = 0x01 << 5,
00053 BUTTON_7 = 0x01 << 6,
00054 BUTTON_8 = 0x01 << 7,
00055 BUTTON_9 = 0x01 << 8,
00056 BUTTON_10 = 0x01 << 9,
00057 BUTTON_11 = 0x01 << 10,
00058 BUTTON_12 = 0x01 << 11,
00059 BUTTONS_1_3 = 0x01 << 12,
00060 BUTTONS_4_5 = 0x01 << 13,
00061 BUTTONS_6_7 = 0x01 << 14,
00062 BUTTONS_8_9 = 0x01 << 15,
00063 BUTTONS_11_12 = 0x01 << 16,
00064 BUTTONS_1_3_INV = 0x01 << 17,
00065 BUTTONS_4_5_INV = 0x01 << 18,
00066 BUTTONS_6_7_INV = 0x01 << 19,
00067 BUTTONS_8_9_INV = 0x01 << 20,
00068 BUTTONS_11_12_INV = 0x01 << 21,
00069 } ButtonID;
00070
00071
00072 typedef enum ModifierType
00073 {
00074 SHIFT_MASK = 1 << 0,
00075 LOCK_MASK = 1 << 1,
00076 CONTROL_MASK = 1 << 2,
00077 MOD1_MASK = 1 << 3,
00078 MOD2_MASK = 1 << 4,
00079 MOD3_MASK = 1 << 5,
00080 MOD4_MASK = 1 << 6,
00081 MOD5_MASK = 1 << 7,
00082 BUTTON1_MASK = 1 << 8,
00083 BUTTON2_MASK = 1 << 9,
00084 BUTTON3_MASK = 1 << 10,
00085 BUTTON4_MASK = 1 << 11,
00086 BUTTON5_MASK = 1 << 12,
00087
00088
00089
00090
00091
00092 SUPER_MASK = 1 << 26,
00093 HYPER_MASK = 1 << 27,
00094 META_MASK = 1 << 28,
00095
00096 RELEASE_MASK = 1 << 30,
00097
00098 MODIFIER_MASK = 0x5c001fff
00099 } ModifierType;
00100
00101 struct Event {
00102 Event( uint32_t t=0, unsigned s=0 ): time(t), state(s) { }
00103 virtual ~Event() { }
00104
00105 uint32_t time;
00106 unsigned state;
00107
00108 virtual Type type() const = 0;
00109 };
00110
00111 struct InterruptMarshaller {
00112 typedef bool result_type;
00113
00114 template <typename T_iterator>
00115 result_type operator()(T_iterator first, T_iterator last) const
00116 {
00117 while ( first != last )
00118 {
00119 if ( *first ) return true;
00120 ++first;
00121 }
00122 return false;
00123 }
00124 };
00125
00126 typedef sigc::signal1<bool, const Event&, InterruptMarshaller> signal;
00127
00128 struct Button: public Event {
00129 Button( uint32_t t=0, unsigned s=0, unsigned b=0, double nx=0.0, double ny=0.0 ):
00130 Event( t, s ), button(b), x(nx), y(ny) { }
00131 virtual ~Button() { }
00132
00133 unsigned button;
00134 double x;
00135 double y;
00136 };
00137
00138 struct ButtonPress: public Button {
00139 ButtonPress( uint32_t t=0, unsigned s=0, unsigned b=0, double nx=0.0, double ny=0.0 ):
00140 Button( t, s, b, nx, ny) { }
00141 virtual ~ButtonPress() { }
00142
00143 virtual Type type() const { return BUTTON_PRESS; }
00144 };
00145
00146 struct ButtonRelease: public Button {
00147 ButtonRelease( uint32_t t=0, unsigned s=0, unsigned b=0, double nx=0.0, double ny=0.0 ):
00148 Button( t, s, b, nx, ny) { }
00149 virtual ~ButtonRelease() { }
00150
00151 virtual Type type() const { return BUTTON_RELEASE; }
00152 };
00153
00154 struct ButtonDoublePress: public Button {
00155 ButtonDoublePress( uint32_t t=0, unsigned s=0, unsigned b=0, double nx=0.0, double ny=0.0 ):
00156 Button( t, s, b, nx, ny) { }
00157
00158 virtual ~ButtonDoublePress() { }
00159
00160 virtual Type type() const { return BUTTON_DOUBLE_PRESS; }
00161 };
00162
00163 struct ButtonTriplePress: public Button {
00164 ButtonTriplePress( uint32_t t=0, unsigned s=0, unsigned b=0, double nx=0.0, double ny=0.0 ):
00165 Button( t, s, b, nx, ny) { }
00166
00167 virtual ~ButtonTriplePress() { }
00168
00169 virtual Type type() const { return BUTTON_TRIPLE_PRESS; }
00170 };
00171
00172 struct Scroll: public Event {
00173 Scroll( uint32_t t=0, unsigned s=0, ScrollDirection d=SCROLL_UP, double nx=0, double ny=0 ):
00174 Event(t, s), direction(d), x(nx), y(ny) { }
00175
00176 virtual ~Scroll() { }
00177
00178 ScrollDirection direction;
00179 double x;
00180 double y;
00181
00182 virtual Type type() const { return SCROLL; }
00183 };
00184
00185 struct Motion: public Event {
00186 Motion( uint32_t t=0, unsigned s=0, double nx=0.0, double ny=0.0 ):
00187 Event(t, s), x(nx), y(ny) { }
00188
00189 virtual ~Motion() { }
00190
00191 double x;
00192 double y;
00193
00194 virtual Type type() const { return MOTION; }
00195 };
00196
00197 struct Key: public Event {
00198 Key( uint32_t t=0, unsigned s=0, unsigned k=0, uint16_t hc=0, uint8_t kg=0 ):
00199 Event(t, s), key(k), hardware_code(hc), keyboard_group(kg) { }
00200
00201 virtual ~Key() { }
00202
00203 unsigned key;
00204 uint16_t hardware_code;
00205 uint8_t keyboard_group;
00206 };
00207
00208 struct KeyPress: public Key {
00209 KeyPress( uint32_t t=0, unsigned s=0, unsigned k=0, uint16_t hc=0, uint8_t kg=0 ):
00210 Key( t, s, k, hc, kg) { }
00211
00212 virtual ~KeyPress() { }
00213
00214 virtual Type type() const { return KEY_PRESS; }
00215 };
00216
00217 struct KeyRelease: public Key {
00218 KeyRelease( uint32_t t=0, unsigned s=0, unsigned k=0, uint16_t hc=0, uint8_t kg=0 ):
00219 Key( t, s, k, hc, kg) { }
00220
00221 virtual ~KeyRelease() { }
00222
00223 virtual Type type() const { return KEY_RELEASE; }
00224 };
00225
00226 }
00227
00228 }
00229
00230 #endif