EnglishРусский  

   ..

   SRC

   defines.g

   Desktop.g

   Font.g

   Image.g

   InputDevice.g

   Screen.g

   Sound.g

   Sprites.g

Данный проект закрыт! Создан новый скриптовый язык с тем же именем. Всё доступно на GitHub.
Также попробуйте нашу open source кроссплатформенную программу для создания и управления скриптами.

Реклама

Инсталлятор CreateInstall
Бесплатные и коммерческие инсталляторы

source\dev\directx\lib\InputDevice.g
  1 import "Graphics.dll" {
  2   //Joystick
  3   int Joystick_Init()
  4   int Joystick_Examine()
  5   int Joystick_GetAxisX()
  6   int Joystick_GetAxisY()
  7   int Joystick_GetButtonState(int)
  8   //Keyboard
  9   int Keyboard_Init()
 10   Keyboard_Examine()
 11   int Keyboard_GetLastChar()
 12   Keyboard_SetMode(int)
 13   int Keyboard_IsPushed(int)
 14   int Keyboard_IsReleased(int)
 15   //Mouse
 16   int Mouse_Init()
 17   int Mouse_Examine()
 18   int Mouse_IsLeftClick()
 19   int Mouse_IsRightClick()
 20   int Mouse_IsMiddleClick()
 21   int Mouse_GetDX()
 22   int Mouse_GetDY()
 23   int Mouse_GetX()
 24   int Mouse_GetY()
 25   int Mouse_SetPos(int,int)
 26   int Mouse_SetX(int)
 27   int Mouse_SetY(int)
 28   int Mouse_Wheel()
 29   int Mouse_Release(int)
 30 }
 31 
 32 include {
 33   "defines.g"
 34 }
 35 
 36 define <export>{
 37   //Joystick
 38   ARROW_L  = 1 //left
 39   ARROW_LU = 2 //left & up
 40   ARROW_UL = 2
 41   ARROW_U  = 3 //up
 42   ARROW_UR = 4 //up & right
 43   ARROW_RU = 4
 44   ARROW_R  = 5 //right
 45   ARROW_RD = 6 //right & down
 46   ARROW_DR = 6
 47   ARROW_D  = 7 //down
 48   ARROW_DL = 8 //down & left
 49   ARROW_LD = 8 //left & down
 50 
 51   //Keyboard
 52   BTN_ALL = -1
 53 
 54   BTN_1            = 2
 55   BTN_2            = 3
 56   BTN_3            = 4
 57   BTN_4            = 5
 58   BTN_5            = 6
 59   BTN_6            = 7
 60   BTN_7            = 8
 61   BTN_8            = 9
 62   BTN_9            = 10
 63   BTN_0            = 11
 64 
 65   BTN_A            = 30
 66   BTN_B            = 48
 67   BTN_C            = 46
 68   BTN_D            = 32
 69   BTN_E            = 18
 70   BTN_F            = 33
 71   BTN_G            = 34
 72   BTN_H            = 35
 73   BTN_I            = 23
 74   BTN_J            = 36
 75   BTN_K            = 37
 76   BTN_L            = 38
 77   BTN_M            = 50
 78   BTN_N            = 49
 79   BTN_O            = 24
 80   BTN_P            = 25
 81   BTN_Q            = 16
 82   BTN_R            = 19
 83   BTN_S            = 31
 84   BTN_T            = 20
 85   BTN_U            = 22
 86   BTN_V            = 47
 87   BTN_W            = 17
 88   BTN_X            = 45
 89   BTN_Y            = 21
 90   BTN_Z            = 44
 91   BTN_ESCAPE       = 1
 92   BTN_MINUS        = 12
 93   BTN_EQUALS       = 13
 94   BTN_BACK         = 14
 95   BTN_TAB          = 15
 96   BTN_LEFTBRACKET  = 26
 97   BTN_RIGHTBRACKET = 27
 98   BTN_RETURN       = 28
 99   BTN_LCONTROL     = 29
100   BTN_SEMICOLON    = 39
101   BTN_APOSTROPHE   = 40
102   BTN_GRAVE        = 41
103   BTN_LSHIFT       = 42
104   BTN_BACKSLASH    = 43
105   BTN_COMMA        = 51
106   BTN_PERIOD       = 52
107   BTN_SLASH        = 53
108   BTN_RSHIFT       = 54
109   BTN_MULTIPLY     = 55
110   BTN_LALT         = 56
111   BTN_SPACE        = 57
112   BTN_CAPITAL      = 58
113   BTN_F1           = 59
114   BTN_F2           = 60
115   BTN_F3           = 61
116   BTN_F4           = 62
117   BTN_F5           = 63
118   BTN_F6           = 64
119   BTN_F7           = 65
120   BTN_F8           = 66
121   BTN_F9           = 67
122   BTN_F10          = 68
123   BTN_F11          = 87
124   BTN_F12          = 88
125   BTN_NUMLOCK      = 69
126   BTN_SCROLL       = 70
127   BTN_PAD0         = 82
128   BTN_PAD1         = 79
129   BTN_PAD2         = 80
130   BTN_PAD3         = 81
131   BTN_PAD4         = 75
132   BTN_PAD5         = 76
133   BTN_PAD6         = 77
134   BTN_PAD7         = 71
135   BTN_PAD8         = 72
136   BTN_PAD9         = 73
137   BTN_ADD          = 78
138   BTN_SUBSTRACT    = 74
139   BTN_DECIMAL      = 83
140   BTN_PADENTER     = 156
141   BTN_RCONTROL     = 157
142   BTN_PADCOMMA     = 179
143   BTN_DIVIDE       = 181
144   BTN_RALT         = 184
145   BTN_PAUSE        = 197
146   BTN_HOME         = 199
147   BTN_UP           = 200
148   BTN_DOWN         = 208
149   BTN_LEFT         = 203
150   BTN_RIGHT        = 205
151   BTN_END          = 207
152   BTN_PAGEUP       = 201
153   BTN_PAGEDOWN     = 209
154   BTN_INSERT       = 210
155   BTN_DELETE       = 211
156 
157   //Keyboard
158   KEYBOARD_QWERTY          = 0
159   KEYBOARD_INTERNATIONAL   = 1
160   KEYBOARD_ALLOWSYSTEMKEYS = 2
161 }
162 
163 type TInputDevice <inherit = GAPI_Object>:
164 type TJoystick    <inherit = TInputDevice>:
165 type TKeyboard    <inherit = TInputDevice>:
166 type TMouse       <inherit = TInputDevice>:
167 
168 global {
169   TInputDevice InputDevice
170 
171   //Joystick
172   TJoystick Joystick
173 
174   //Keyboard
175   TKeyboard Keyboard
176   arr BTN_KEYS of int = %{$BTN_1, $BTN_2, $BTN_3, $BTN_4, $BTN_5, $BTN_6, $BTN_7, $BTN_8, $BTN_9, $BTN_0, $BTN_A, $BTN_B, $BTN_C, $BTN_D, $BTN_E, $BTN_F, $BTN_G, $BTN_H,
177                           $BTN_I, $BTN_J, $BTN_K, $BTN_L, $BTN_M, $BTN_N, $BTN_O, $BTN_P, $BTN_Q, $BTN_R, $BTN_S, $BTN_T, $BTN_U, $BTN_V, $BTN_W, $BTN_X, $BTN_Y, $BTN_Z,
178                           $BTN_ESCAPE, $BTN_MINUS, $BTN_EQUALS, $BTN_BACK, $BTN_TAB, $BTN_LEFTBRACKET, $BTN_RIGHTBRACKET, $BTN_RETURN, $BTN_LCONTROL, $BTN_SEMICOLON,
179                           $BTN_APOSTROPHE, $BTN_GRAVE, $BTN_LSHIFT, $BTN_BACKSLASH, $BTN_COMMA, $BTN_PERIOD, $BTN_SLASH, $BTN_RSHIFT, $BTN_MULTIPLY, $BTN_LALT,
180                           $BTN_SPACE, $BTN_CAPITAL, $BTN_F1, $BTN_F2, $BTN_F3, $BTN_F4, $BTN_F5, $BTN_F6, $BTN_F7, $BTN_F8, $BTN_F9, $BTN_F10, $BTN_F11, $BTN_F12,
181                           $BTN_NUMLOCK, $BTN_SCROLL, $BTN_PAD0, $BTN_PAD1, $BTN_PAD2, $BTN_PAD3, $BTN_PAD4, $BTN_PAD5, $BTN_PAD6, $BTN_PAD7, $BTN_PAD8, $BTN_PAD9,
182                           $BTN_ADD, $BTN_SUBSTRACT, $BTN_DECIMAL, $BTN_PADENTER, $BTN_RCONTROL, $BTN_PADCOMMA, $BTN_DIVIDE, $BTN_RALT, $BTN_PAUSE, $BTN_HOME, $BTN_UP,
183                           $BTN_DOWN, $BTN_LEFT, $BTN_RIGHT, $BTN_END, $BTN_PAGEUP, $BTN_PAGEDOWN, $BTN_INSERT, $BTN_DELETE
184                          }
185   arr BTN_PUSHED   of int
186   arr BTN_RELEASED of int
187   int GE_KeyboardMode = $KEYBOARD_QWERTY
188   
189   //Mouse
190   TMouse Mouse
191   int GE_MouseLock = $false
192 }
193 
194 method int TInputDevice.UseJoystick(){
195   return Joystick_Init()
196 }
197 method int TInputDevice.UseKeyboard(){
198   return Keyboard_Init()
199 }
200 method int TInputDevice.UseMouse(){
201   return Mouse_Init()
202 }
203 
204 //Joystick
205 method int TJoystick.Examine(){ //опросить джостик
206   return Joystick_Examine()
207 }
208 method int TJoystick.getAxisX(){   //-1:LEFT 1:RIGHT 0:--
209   return Joystick_GetAxisX()
210 }
211 method int TJoystick.getAxisY(){   //-1:UP   1:DOWN  0:--
212   return Joystick_GetAxisY()
213 }
214 method int TJoystick.getArrows(){   //получить положение крестовины джостика (ARROW_*)
215   int x = Joystick_GetAxisX()
216   int y = Joystick_GetAxisY()
217   if   y == -1 {
218     if   x == -1 : return $ARROW_LU :
219     elif x ==  0 : return $ARROW_U  :
220     elif x ==  1 : return $ARROW_RU :
221   }
222   elif y == 1  {
223     if   x == -1 : return $ARROW_LD :
224     elif x ==  0 : return $ARROW_D  :
225     elif x ==  1 : return $ARROW_RD :
226   }
227   return $null
228 }
229 method int TJoystick.isLeft(){
230   return ?(Joystick_GetAxisX()==-1,$true,$false)
231 }
232 method int TJoystick.isRight(){
233   return ?(Joystick_GetAxisX()==1,$true,$false)
234 }
235 method int TJoystick.isUp(){
236   return ?(Joystick_GetAxisY()==-1,$true,$false)
237 }
238 method int TJoystick.isDown(){
239   return ?(Joystick_GetAxisY()==1,$true,$false)
240 }
241 method int TJoystick.IsButton(int N){
242   return Joystick_GetButtonState(N)
243 }
244 
245 //Keyboard
246 method TKeyboard.Examine(){
247   Keyboard_Examine()
248 }
249 method str TKeyboard.getChar(){
250   str s
251   return s.copy(Keyboard_GetLastChar())
252 }
253 method int TKeyboard.isPushed(int KeyID){
254   return Keyboard_IsPushed(KeyID)
255 }
256 method int TKeyboard.isReleased(int KeyID){
257   return Keyboard_IsReleased(KeyID)
258 }
259 method TKeyboard.getPushedKeys(){
260   int i = 0
261   uint j KeyID
262   BTN_PUSHED.clear()
263   fornum j,*BTN_KEYS{
264     KeyID = BTN_KEYS[j]
265     if Keyboard_IsPushed(KeyID){
266       BTN_PUSHED.expand(1)
267       BTN_PUSHED[i]=KeyID
268       i++
269     }
270   }
271 }
272 method TKeyboard.getReleasedKeys(){
273   int i = 0
274   uint j KeyID
275   BTN_RELEASED.clear()
276   fornum j,*BTN_KEYS{
277     KeyID = BTN_KEYS[j]
278     if Keyboard_IsReleased(KeyID){
279       BTN_RELEASED.expand(1)
280       BTN_RELEASED[i]=KeyID
281       i++
282     }
283   }
284 }
285 property TKeyboard.Mode(int mode){
286   GE_KeyboardMode = mode
287   Keyboard_SetMode(mode)
288 }
289 property int TKeyboard.Mode{
290   return GE_KeyboardMode
291 }
292 
293 //Mouse
294 method int TMouse.Examine(){
295   return Mouse_Examine()
296 }
297 method int TMouse.isLClick(){
298   return Mouse_IsLeftClick()
299 }
300 method int TMouse.isRClick(){
301   return Mouse_IsRightClick()
302 }
303 method int TMouse.isMClick(){
304   return Mouse_IsMiddleClick()
305 }
306 method int TMouse.getDeltaX(){
307   return Mouse_GetDX()
308 }
309 method int TMouse.getDeltaY(){
310   return Mouse_GetDY()
311 }
312 property int TMouse.X{
313   return Mouse_GetX()
314 }
315 property TMouse.X(int a){
316   Mouse_SetX(a)
317 }
318 property int TMouse.Y{
319   return Mouse_GetY()
320 }
321 property TMouse.Y(int a){
322   Mouse_SetY(a)
323 }
324 method TMouse.setXY(int a b){
325   Mouse_SetPos(a,b)
326 }
327 method TMouse.setPos(int a b){
328   Mouse_SetPos(a,b)
329 }
330 method int TMouse.getWheel(){
331   return Mouse_Wheel()
332 }
333 method int TMouse.getWheelTicks(){
334   return abs(Mouse_Wheel())
335 }
336 method int TMouse.isWheelUp(){
337   int ticks = Mouse_Wheel()
338   return ?(ticks > 0,ticks,$false)
339 }
340 method int TMouse.isWheelDown(){
341   int ticks = Mouse_Wheel()
342   return ?(ticks < 0,abs(ticks),$false)
343 }
344 method int TMouse.Lock(){
345   if Mouse_Release($true){
346     GE_MouseLock = $true
347     return $true
348   }
349   return $false
350 }
351 method int TMouse.Release{
352   if (Mouse_Release($false)){
353     GE_MouseLock = $false
354     return $true
355   }
356   return $false
357 }
358 property int TMouse.Locked{
359   return GE_MouseLock
360 }
361 property TMouse.Locked(int state){
362   if (state > 0){
363     this.Lock()
364   }
365   this.Release()
366 }
367 
Редактировать