2 * psychlops_io_keyboard.h
3 * Psychlops Standard Library (Universal)
5 * Last Modified 2006/01/04 by Kenchi HOSOKAWA
6 * (C) 2006 Kenchi HOSOKAWA, Kazushi MARUYA and Takao SATO
9 #ifndef HEADER_PSYCHLOPS_INPUT_HID
10 #define HEADER_PSYCHLOPS_INPUT_HID
12 #include "../graphic/psychlops_g_fundamental.h"
19 class HumanInterfaceDevice;
20 class APIHIDProperties;
21 typedef HumanInterfaceDevice Input;
26 friend class HumanInterfaceDevice;
27 friend class APIHIDProperties;
31 pressed=0, pushed=1, released=2, hadpressed=3
38 bool released() const;
39 bool get(KeyState state) const;
43 one,two,three,four,five,six,seven,eight,nine,zero,
44 a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,
46 pad0,pad1,pad2,pad3,pad4,pad5,pad6,pad7,pad8,pad9,
47 rtn,spc,esc,tab,up,down,left,right,
49 shift, shift_r, ctrl, alt,
51 hyphen,equal,backslash,caret,
52 underscore,semicolon,colon,leftbracket,rightbracket,at, // because these keys laid on different location in differnt keyboard-lacalization.
53 padcomma,padperiod,padenter,padplus,padminus,padasterisk,padslash,padequal,padclear, // because these keys are OS-specific.
54 nfer,xfer // because these keys exist only on Japanese keyboard
59 static void refresh();
61 static bool get(Key key, KeyState state = pushed);
64 static bool getKey(Key key, KeyState state = pushed);
65 static void wait(Key key, bool needrelease=true);
66 static void allReleased();
69 static void refresh_internal();
74 friend class HumanInterfaceDevice;
75 friend class APIHIDProperties;
76 static ::Psychlops::Point pointerPos, wheelDelta, lastPoint;
80 pressed=0, pushed=1, released=2, hadpressed=3
84 Button(const int code_);
87 bool released() const;
88 bool get(ButtonState state) const;
90 static const Button left, right, middle, any;
94 friend class POSITION;
96 friend class APIHIDProperties;
103 int operator =(int val);
105 static POSITIONVAL uniX, uniY;
106 struct POSITION { public: operator Psychlops::Point(); Psychlops::Point operator =(Point val); };
107 static POSITION uniPosition;
109 struct DEFPOSITIONVALX { operator int(); int operator =(int val); };
110 static DEFPOSITIONVALX x;
111 struct DEFPOSITIONVALY { operator int(); int operator =(int val); };
112 static DEFPOSITIONVALY y;
113 struct DEFPOSITION { operator ::Psychlops::Point(); ::Psychlops::Point operator =(::Psychlops::Point val); };
114 static DEFPOSITION position;
116 static bool show_local_pointer_;
117 static bool showLocalPointer();
119 static void initialize();
121 static void update();
122 static void refresh();
124 static bool get(Button code, ButtonState state = pushed);
125 static ::Psychlops::Point getWheelDelta();
129 static void drawPointer(Point p, Drawable &target);
130 static void setPointer(int size);
131 static void setPointer(Figure &fig);
132 static Figure* pointer_figure;
135 static void refresh_internal();
138 class APIMouseProperties;
139 class HumanInterfaceDevice {
140 friend class Keyboard;
142 friend class APIHIDProperties;
143 friend class APIMouseProperties;
147 pressed=0, pushed=1, released=2, hadpressed=3
149 struct ButtonStateHolder {
151 Mouse::Button *target;
152 bool pressed_, pushed_, released_, hadpressed_;
155 ButtonStateHolder(const Mouse::Button &);
161 static bool runningHIDListner;
167 static States state[3];
170 static int pushRepeatFrames, pushRepeatInterval;
172 static void initialize();
173 static void finalize();
175 static void startListener();
176 static void stopListener();
178 static void refresh();
180 static bool get(Keyboard::Key code, Keyboard::KeyState state = Keyboard::pushed);
181 static bool get(Mouse::Button code, Mouse::ButtonState state = Mouse::pushed);
182 static void wait(Keyboard::Key code, Keyboard::KeyState state = Keyboard::pushed);
188 } /* <- namespace Psycholops */