dxrubynd 1.4.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2522 @@
1
+ /* �A�i���O�p�b�h���͂̃R�[�h�� @iMAKOPi�����蒸���܂����B2012/07/06 */
2
+ #define WINVER 0x0500 /* �o�[�W������` Windows2000�ȏ� */
3
+ #define _WIN32_WINNT WINVER
4
+ #undef DIRECTINPUT_VERSION
5
+ #define DIRECTINPUT_VERSION (0x0800) /* DirectInput�o�[�W������` */
6
+
7
+ #include "ruby.h"
8
+ #ifndef RUBY_ST_H
9
+ #include "st.h"
10
+ #endif
11
+ #include <dinput.h>
12
+
13
+ #define DXRUBY_EXTERN 1
14
+ #include "dxruby.h"
15
+ #include "input.h"
16
+ #ifdef DXRUBY15
17
+ #include "font.h"
18
+ #endif
19
+
20
+ #ifdef DXRUBY15
21
+ #ifdef DXRUBY_USE_TYPEDDATA
22
+ extern rb_data_type_t Font_data_type;
23
+ #endif
24
+ #endif
25
+
26
+ #ifndef DIK_PREVTRACK
27
+ #define DIK_PREVTRACK DIK_CIRCUMFLEX
28
+ #endif
29
+
30
+ #define PADMAX 2
31
+
32
+ /* �Ǘ�����{�^���̌� */
33
+ #define PADBUTTON_MAX 28
34
+
35
+ #define P_LEFT 0
36
+ #define P_RIGHT 1
37
+ #define P_UP 2
38
+ #define P_DOWN 3
39
+ #define P_BUTTON0 4
40
+ #define P_BUTTON1 5
41
+ #define P_BUTTON2 6
42
+ #define P_BUTTON3 7
43
+ #define P_BUTTON4 8
44
+ #define P_BUTTON5 9
45
+ #define P_BUTTON6 10
46
+ #define P_BUTTON7 11
47
+ #define P_BUTTON8 12
48
+ #define P_BUTTON9 13
49
+ #define P_BUTTON10 14
50
+ #define P_BUTTON11 15
51
+ #define P_BUTTON12 16
52
+ #define P_BUTTON13 17
53
+ #define P_BUTTON14 18
54
+ #define P_BUTTON15 19
55
+
56
+ /* ���A�i���O�X�e�B�b�N */
57
+ #define P_L_LEFT 0
58
+ #define P_L_RIGHT 1
59
+ #define P_L_UP 2
60
+ #define P_L_DOWN 3
61
+
62
+ /* �f�W�^���\���{�^�� */
63
+ #define P_D_LEFT 20
64
+ #define P_D_RIGHT 21
65
+ #define P_D_UP 22
66
+ #define P_D_DOWN 23
67
+
68
+ /* �E�A�i���O�X�e�B�b�N */
69
+ #define P_R_LEFT 24
70
+ #define P_R_RIGHT 25
71
+ #define P_R_UP 26
72
+ #define P_R_DOWN 27
73
+
74
+ #define M_LBUTTON 0
75
+ #define M_RBUTTON 1
76
+ #define M_MBUTTON 2
77
+
78
+ /* POV�̕�������p */
79
+ #define POV_UP 0
80
+ #define POV_UP_RIGHT 4500
81
+ #define POV_RIGHT 9000
82
+ #define POV_DOWN_RIGHT 13500
83
+ #define POV_DOWN 18000
84
+ #define POV_DOWN_LEFT 22500
85
+ #define POV_LEFT 27000
86
+ #define POV_UP_LEFT 31500
87
+
88
+
89
+ static VALUE mInput; /* �C���v�b�g���W���[�� */
90
+ static VALUE mIME; /* IME���W���[�� */
91
+ static LPDIRECTINPUT8 g_pDInput = NULL; /* DirectInput */
92
+ static LPDIRECTINPUTDEVICE8 g_pDIDKeyBoard = NULL; /* DirectInput�̃L�[�{�[�h�f�o�C�X */
93
+ static LPDIRECTINPUTDEVICE8 g_pDIDJoyPad[PADMAX]; /* DirectInput�̃p�b�h�f�o�C�X */
94
+ static BYTE g_diKeyState[256]; /* DirectInput�ł̃L�[�{�[�h���͗p�o�b�t�@ */
95
+ static BYTE g_diKeyStateOld[256]; /* DirectInput�ł̃L�[�{�[�h���͗p�o�b�t�@�P�t���[���O */
96
+ static BYTE g_diKeyCount[256]; /* DirectInput�ł̃L�[�{�[�h���͗p�J�E���^ */
97
+ static BYTE g_diKeyConfig[256]; /* DirectInput�ł̃L�[�{�[�h�E�p�b�h���蓖�� */
98
+ static BYTE g_diKeyWait[256]; /* �I�[�g���s�[�g�E�F�C�g���� */
99
+ static BYTE g_diKeyInterval[256]; /* �I�[�g���s�[�g�Ԋu */
100
+ static int g_JoystickCount = 0;
101
+ static BYTE g_byMouseState_L, g_byMouseStateOld_L;
102
+ static BYTE g_byMouseState_M, g_byMouseStateOld_M;
103
+ static BYTE g_byMouseState_R, g_byMouseStateOld_R;
104
+
105
+ #ifdef DXRUBY15
106
+ extern WCHAR *ime_buf;
107
+ extern int ime_str_length;
108
+ extern int ime_str_length_old;
109
+ extern WCHAR *ime_buf_old;
110
+ extern CRITICAL_SECTION ime_cs;
111
+ extern int ime_compositing;
112
+ extern char *ime_vk_push_buf;
113
+ extern int ime_vk_push_str_length;
114
+ extern char *ime_vk_push_buf_old;
115
+ int ime_vk_push_str_length_old;
116
+ extern char *ime_vk_release_buf;
117
+ extern int ime_vk_release_str_length;
118
+ extern char *ime_vk_release_buf_old;
119
+ int ime_vk_release_str_length_old;
120
+ extern WCHAR *ime_composition_str;
121
+ extern WCHAR *ime_composition_str_old;
122
+ extern char *ime_composition_attr;
123
+ extern char *ime_composition_attr_old;
124
+ extern int ime_composition_attr_size;
125
+ extern LPCANDIDATELIST ime_canlist;
126
+ extern LPCANDIDATELIST ime_canlist_old;
127
+ extern int ime_cursor_pos;
128
+
129
+ static VALUE g_vCompInfoArray = Qnil;;
130
+
131
+ static VALUE cCompInfo; /* �ϊ����N���X */
132
+ #endif
133
+
134
+ //LPDIRECTINPUTEFFECT g_lpDIEffect = NULL;
135
+
136
+ /* Pad��� */
137
+ static struct DXRubyPadInfo {
138
+ /* �e���͈̔� */
139
+ int x_flg;
140
+ int x_min;
141
+ int x_center;
142
+ int x_max;
143
+ int y_flg;
144
+ int y_min;
145
+ int y_center;
146
+ int y_max;
147
+ int z_flg;
148
+ int z_min;
149
+ int z_center;
150
+ int z_max;
151
+ int rx_flg;
152
+ int rx_min;
153
+ int rx_center;
154
+ int rx_max;
155
+ int ry_flg;
156
+ int ry_min;
157
+ int ry_center;
158
+ int ry_max;
159
+ int rz_flg;
160
+ int rz_min;
161
+ int rz_center;
162
+ int rz_max;
163
+
164
+ int x_ff_flg;
165
+ int y_ff_flg;
166
+
167
+ LPDIRECTINPUTDEVICE8 pDIDJoyPad; /* DirectInput�̃p�b�h�f�o�C�X */
168
+ } g_PadInfo[PADMAX];
169
+
170
+ /* Pad��� */
171
+ static struct DXRubyPadState {
172
+ char button[PADBUTTON_MAX];
173
+ int PadConfig[PADBUTTON_MAX];
174
+ int count[PADBUTTON_MAX];
175
+ int wait[PADBUTTON_MAX];
176
+ int interval[PADBUTTON_MAX];
177
+ float x;
178
+ float y;
179
+ float z;
180
+ float rx;
181
+ float ry;
182
+ float rz;
183
+ int pov;
184
+ } g_PadState[PADMAX], g_PadStateOld[PADMAX];
185
+
186
+ int Window_autocall_foreach( VALUE key, VALUE value, VALUE obj );
187
+
188
+ /*********************************************************************
189
+ * Input���W���[��
190
+ *
191
+ * DirectInput���g�p���ăL�[�{�[�h�E�p�b�h�̓��͂��s���B
192
+ *********************************************************************/
193
+
194
+ /*--------------------------------------------------------------------
195
+ Windows���b�Z�[�W�������݂̓��͍X�V
196
+ ---------------------------------------------------------------------*/
197
+ VALUE Input_update( VALUE obj )
198
+ {
199
+ // if( g_WindowInfo.input_updated == 0 )
200
+ // {
201
+ /* ���͏�ԍX�V */
202
+ inputupdate_internal();
203
+ rb_hash_foreach( g_WindowInfo.before_call, Window_autocall_foreach, obj );
204
+ // }
205
+
206
+ if( g_WindowInfo.requestclose == 1 )
207
+ {
208
+ g_WindowInfo.requestclose = 0;
209
+ return Qtrue;
210
+ }
211
+
212
+ return Qfalse;
213
+ }
214
+
215
+
216
+ /*--------------------------------------------------------------------
217
+ �‚����悤�Ƃ������ǂ�����Ԃ�
218
+ ---------------------------------------------------------------------*/
219
+ VALUE Input_requested_close( VALUE obj )
220
+ {
221
+ if( g_WindowInfo.requestclose == 1 )
222
+ {
223
+ g_WindowInfo.requestclose = 0;
224
+ return Qtrue;
225
+ }
226
+
227
+ return Qfalse;
228
+ }
229
+
230
+
231
+ /*--------------------------------------------------------------------
232
+ Input���W���[���̓��͏���
233
+ ---------------------------------------------------------------------*/
234
+ void inputupdate_internal( void )
235
+ {
236
+ int i, j;
237
+ DIJOYSTATE paddata;
238
+ WCHAR *ime_buf_tmp_wchar;
239
+ char *ime_buf_tmp_char;
240
+
241
+ /* �t�H�[�J�X���͂��ꂽ�ꍇ�A�L�[�ƃp�b�h�A�}�E�X�{�^���̓��͂��󂯕t���Ȃ����� */
242
+ if( g_WindowInfo.active == 0 )
243
+ {
244
+ /* �L�[�{�[�h�̃f�[�^���N���A���� */
245
+ ZeroMemory( &g_diKeyState, sizeof(g_diKeyState) );
246
+ ZeroMemory( &g_diKeyStateOld, sizeof(g_diKeyStateOld) );
247
+
248
+ /* �p�b�h�f�[�^���N���A���� */
249
+ for( i = 0; i < g_JoystickCount; i++ )
250
+ {
251
+ for( j = 0; j < PADBUTTON_MAX; j++ )
252
+ {
253
+ g_PadStateOld[i].button[j] = g_PadState[i].button[j];
254
+ g_PadState[i].button[j] = 0;
255
+ }
256
+ }
257
+
258
+ /* �}�E�X�{�^���̃f�[�^���N���A���� */
259
+ g_byMouseStateOld_L = g_byMouseState_L;
260
+ g_byMouseStateOld_M = g_byMouseState_M;
261
+ g_byMouseStateOld_R = g_byMouseState_R;
262
+ g_byMouseState_L = 0;
263
+ g_byMouseState_M = 0;
264
+ g_byMouseState_R = 0;
265
+
266
+ g_WindowInfo.input_updated = 1;
267
+ return;
268
+ }
269
+
270
+ /* �f�o�C�X�A�N�Z�X�����Ď擾���� */
271
+ g_pDIDKeyBoard->lpVtbl->Acquire( g_pDIDKeyBoard );
272
+
273
+ for( i = 0; i < g_JoystickCount; i++ )
274
+ {
275
+ g_pDIDJoyPad[i]->lpVtbl->Poll( g_pDIDJoyPad[i] );
276
+ g_pDIDJoyPad[i]->lpVtbl->Acquire( g_pDIDJoyPad[i] );
277
+ }
278
+
279
+ /* �L�[�{�[�h�̒��ڃf�[�^���擾���� */
280
+ memcpy( g_diKeyStateOld, g_diKeyState, sizeof(g_diKeyState) );
281
+ g_pDIDKeyBoard->lpVtbl->GetDeviceState( g_pDIDKeyBoard, 256, g_diKeyState );
282
+
283
+ for( i = 0; i < PADMAX; i++ )
284
+ {
285
+ for( j = 0; j < PADBUTTON_MAX; j++ )
286
+ {
287
+ g_PadStateOld[i].button[j] = g_PadState[i].button[j];
288
+ g_PadState[i].button[j] = 0;
289
+ g_PadState[i].count[j]++; /* �J�E���g */
290
+ }
291
+ }
292
+
293
+ /* �Q�[���p�b�h�̃f�[�^���擾���� */
294
+ for( i = 0; i < g_JoystickCount; i++ )
295
+ {
296
+ int j;
297
+
298
+ g_pDIDJoyPad[i]->lpVtbl->GetDeviceState( g_pDIDJoyPad[i], sizeof(DIJOYSTATE), &paddata );
299
+
300
+ // //----------------------------------------
301
+ // // typedef struct DIJOYSTATE {
302
+ // // LONG lX;
303
+ // // LONG lY;
304
+ // // LONG lZ;
305
+ // // LONG lRx;
306
+ // // LONG lRy;
307
+ // // LONG lRz;
308
+ // // LONG rglSlider[2];
309
+ // // DWORD rgdwPOV[4];
310
+ // // BYTE rgbButtons[32];
311
+ // // } DIJOYSTATE, *LPDIJOYSTATE;
312
+ // //----------------------------------------
313
+ // {
314
+ // int tmp = 0;
315
+ //
316
+ // tmp = paddata.rgbButtons[ 0] >> 7;
317
+ // tmp |= (paddata.rgbButtons[ 1] >> 7) << 1;
318
+ // tmp |= (paddata.rgbButtons[ 2] >> 7) << 2;
319
+ // tmp |= (paddata.rgbButtons[ 3] >> 7) << 3;
320
+ // tmp |= (paddata.rgbButtons[ 4] >> 7) << 4;
321
+ // tmp |= (paddata.rgbButtons[ 5] >> 7) << 5;
322
+ // tmp |= (paddata.rgbButtons[ 6] >> 7) << 6;
323
+ // tmp |= (paddata.rgbButtons[ 7] >> 7) << 7;
324
+ // tmp |= (paddata.rgbButtons[ 8] >> 7) << 8;
325
+ // tmp |= (paddata.rgbButtons[ 9] >> 7) << 9;
326
+ // tmp |= (paddata.rgbButtons[10] >> 7) << 10;
327
+ // tmp |= (paddata.rgbButtons[11] >> 7) << 11;
328
+ // tmp |= (paddata.rgbButtons[12] >> 7) << 12;
329
+ // tmp |= (paddata.rgbButtons[13] >> 7) << 13;
330
+ // tmp |= (paddata.rgbButtons[14] >> 7) << 14;
331
+ // tmp |= (paddata.rgbButtons[15] >> 7) << 15;
332
+ // tmp |= (paddata.rgbButtons[16] >> 7) << 16;
333
+ // tmp |= (paddata.rgbButtons[17] >> 7) << 17;
334
+ // tmp |= (paddata.rgbButtons[18] >> 7) << 18;
335
+ // tmp |= (paddata.rgbButtons[19] >> 7) << 19;
336
+ // tmp |= (paddata.rgbButtons[20] >> 7) << 20;
337
+ // tmp |= (paddata.rgbButtons[21] >> 7) << 21;
338
+ // tmp |= (paddata.rgbButtons[22] >> 7) << 22;
339
+ // tmp |= (paddata.rgbButtons[23] >> 7) << 23;
340
+ // tmp |= (paddata.rgbButtons[24] >> 7) << 24;
341
+ // tmp |= (paddata.rgbButtons[25] >> 7) << 25;
342
+ // tmp |= (paddata.rgbButtons[26] >> 7) << 26;
343
+ // tmp |= (paddata.rgbButtons[27] >> 7) << 27;
344
+ // tmp |= (paddata.rgbButtons[28] >> 7) << 28;
345
+ // tmp |= (paddata.rgbButtons[29] >> 7) << 29;
346
+ // tmp |= (paddata.rgbButtons[30] >> 7) << 30;
347
+ // tmp |= (paddata.rgbButtons[31] >> 7) << 31;
348
+ //
349
+ //
350
+ // printf("button=%08X lX=%08X lY=%08X lZ=%08X lRx=%08X lRy=%08X lRz=%08X rglSlider[0]=%08X rgdwPOV[0]=%d\n",
351
+ // tmp,
352
+ // paddata.lX, paddata.lY, paddata.lZ,
353
+ // paddata.lRx, paddata.lRy, paddata.lRz,
354
+ // paddata.rglSlider[0], paddata.rgdwPOV[0] );
355
+ //
356
+ // //debug
357
+ // printf("g_PadInfo[%d].right = 0x%08X\n", i, g_PadInfo[i].right);
358
+ // printf("g_PadInfo[%d].left = 0x%08X\n", i, g_PadInfo[i].left);
359
+ // printf("g_PadInfo[%d].up = 0x%08X\n", i, g_PadInfo[i].up);
360
+ // printf("g_PadInfo[%d].down = 0x%08X\n", i, g_PadInfo[i].down);
361
+ // printf("g_PadInfo[%d].forward = 0x%08X\n", i, g_PadInfo[i].forward);
362
+ // printf("g_PadInfo[%d].backward = 0x%08X\n", i, g_PadInfo[i].backward);
363
+ //
364
+ // printf("g_PadInfo[%d].r_right = 0x%08X\n", i, g_PadInfo[i].r_right);
365
+ // printf("g_PadInfo[%d].r_left = 0x%08X\n", i, g_PadInfo[i].r_left);
366
+ // printf("g_PadInfo[%d].r_up = 0x%08X\n", i, g_PadInfo[i].r_up);
367
+ // printf("g_PadInfo[%d].r_down = 0x%08X\n", i, g_PadInfo[i].r_down);
368
+ // printf("g_PadInfo[%d].r_forward = 0x%08X\n", i, g_PadInfo[i].r_forward);
369
+ // printf("g_PadInfo[%d].r_backward = 0x%08X\n", i, g_PadInfo[i].r_backward);
370
+ // }
371
+
372
+ /* �e����0.0�`1.0�̒l�Ɍv�Z */
373
+ g_PadState[i].x = g_PadInfo[i].x_flg ? (float)(paddata.lX - g_PadInfo[i].x_min) / (g_PadInfo[i].x_max - g_PadInfo[i].x_min) : 0;
374
+ g_PadState[i].y = g_PadInfo[i].y_flg ? (float)(paddata.lY - g_PadInfo[i].y_min) / (g_PadInfo[i].y_max - g_PadInfo[i].y_min) : 0;
375
+ g_PadState[i].z = g_PadInfo[i].z_flg ? (float)(paddata.lZ - g_PadInfo[i].z_min) / (g_PadInfo[i].z_max - g_PadInfo[i].z_min) : 0;
376
+ g_PadState[i].rx = g_PadInfo[i].rx_flg ? (float)(paddata.lRx - g_PadInfo[i].rx_min) / (g_PadInfo[i].rx_max - g_PadInfo[i].rx_min) : 0;
377
+ g_PadState[i].ry = g_PadInfo[i].ry_flg ? (float)(paddata.lRy - g_PadInfo[i].ry_min) / (g_PadInfo[i].ry_max - g_PadInfo[i].ry_min) : 0;
378
+ g_PadState[i].rz = g_PadInfo[i].rz_flg ? (float)(paddata.lRz - g_PadInfo[i].rz_min) / (g_PadInfo[i].rz_max - g_PadInfo[i].rz_min) : 0;
379
+
380
+ /* POV�̒l�ۑ� */
381
+ g_PadState[i].pov = paddata.rgdwPOV[0];
382
+
383
+ /* �p�b�h�̏\���{�^��(�f�W�^���̏ꍇ)or���X�e�B�b�N(�A�i���O�̏ꍇ) */
384
+ /* �� */
385
+ if( paddata.lX < (g_PadInfo[i].x_center + g_PadInfo[i].x_min) / 2 )
386
+ {
387
+ g_PadState[i].button[P_LEFT] = 1;
388
+ }
389
+ /* �E */
390
+ else if( paddata.lX > (g_PadInfo[i].x_center + g_PadInfo[i].x_max ) / 2 )
391
+ {
392
+ g_PadState[i].button[P_RIGHT] = 1;
393
+ }
394
+
395
+ /* �� */
396
+ if( paddata.lY < (g_PadInfo[i].y_center + g_PadInfo[i].y_min) / 2 )
397
+ {
398
+ g_PadState[i].button[P_UP] = 1;
399
+ }
400
+ /* �� */
401
+ else if( paddata.lY > (g_PadInfo[i].y_center + g_PadInfo[i].y_max) / 2 )
402
+ {
403
+ g_PadState[i].button[P_DOWN] = 1;
404
+ }
405
+
406
+ /* �{�^����� */
407
+ for( j = 0; j < 16; j++)
408
+ {
409
+ g_PadState[i].button[j + 4] = paddata.rgbButtons[j] >> 7;
410
+ }
411
+
412
+ /* �E�A�i���O:�� */
413
+ if( paddata.lZ < (g_PadInfo[i].z_center + g_PadInfo[i].z_min) / 2 )
414
+ {
415
+ g_PadState[i].button[P_R_LEFT] = 1;
416
+ }
417
+ /* �E�A�i���O:�E */
418
+ else if( paddata.lZ > (g_PadInfo[i].z_center + g_PadInfo[i].z_max ) / 2 )
419
+ {
420
+ g_PadState[i].button[P_R_RIGHT] = 1;
421
+ }
422
+
423
+ /* �E�A�i���O:�� */
424
+ if( paddata.lRz < (g_PadInfo[i].rz_center + g_PadInfo[i].rz_min) / 2 )
425
+ {
426
+ g_PadState[i].button[P_R_UP] = 1;
427
+ }
428
+ /* �E�A�i���O:�� */
429
+ else if( paddata.lRz > (g_PadInfo[i].rz_center + g_PadInfo[i].rz_max ) / 2 )
430
+ {
431
+ g_PadState[i].button[P_R_DOWN] = 1;
432
+ }
433
+
434
+ /* �\���{�^��(POV)�F�� */
435
+ if( paddata.rgdwPOV[0] == POV_UP )
436
+ {
437
+ g_PadState[i].button[P_D_UP] = 1;
438
+ }
439
+ /* �\���{�^��(POV)�F�E�� */
440
+ else if( paddata.rgdwPOV[0] == POV_UP_RIGHT )
441
+ {
442
+ g_PadState[i].button[P_D_UP] = 1;
443
+ g_PadState[i].button[P_D_RIGHT] = 1;
444
+ }
445
+ /* �\���{�^��(POV)�F�E */
446
+ else if( paddata.rgdwPOV[0] == POV_RIGHT )
447
+ {
448
+ g_PadState[i].button[P_D_RIGHT] = 1;
449
+ }
450
+ /* �\���{�^��(POV)�F�E�� */
451
+ else if( paddata.rgdwPOV[0] == POV_DOWN_RIGHT )
452
+ {
453
+ g_PadState[i].button[P_D_DOWN] = 1;
454
+ g_PadState[i].button[P_D_RIGHT] = 1;
455
+ }
456
+ /* �\���{�^��(POV)�F�� */
457
+ else if( paddata.rgdwPOV[0] == POV_DOWN )
458
+ {
459
+ g_PadState[i].button[P_D_DOWN] = 1;
460
+ }
461
+ /* �\���{�^��(POV)�F���� */
462
+ else if( paddata.rgdwPOV[0] == POV_DOWN_LEFT )
463
+ {
464
+ g_PadState[i].button[P_D_DOWN] = 1;
465
+ g_PadState[i].button[P_D_LEFT] = 1;
466
+ }
467
+ /* �\���{�^��(POV)�F�� */
468
+ else if( paddata.rgdwPOV[0] == POV_LEFT )
469
+ {
470
+ g_PadState[i].button[P_D_LEFT] = 1;
471
+ }
472
+ /* �\���{�^��(POV)�F���� */
473
+ else if( paddata.rgdwPOV[0] == POV_UP_LEFT )
474
+ {
475
+ g_PadState[i].button[P_D_UP] = 1;
476
+ g_PadState[i].button[P_D_LEFT] = 1;
477
+ }
478
+ }
479
+
480
+ /* �}�E�X�{�^���̏�� */
481
+ g_byMouseStateOld_L = g_byMouseState_L;
482
+ g_byMouseStateOld_M = g_byMouseState_M;
483
+ g_byMouseStateOld_R = g_byMouseState_R;
484
+ g_byMouseState_L = g_byMouseState_L_buf;
485
+ g_byMouseState_M = g_byMouseState_M_buf;
486
+ g_byMouseState_R = g_byMouseState_R_buf;
487
+
488
+ for( i = 0; i < 256; i++ )
489
+ {
490
+ g_diKeyCount[i]++; /* �J�E���g */
491
+ }
492
+
493
+ #ifdef DXRUBY15
494
+ /* �L�[�o�b�t�@�ۑ� */
495
+ EnterCriticalSection( &ime_cs );
496
+ ime_buf_tmp_wchar = ime_buf_old;
497
+ ime_buf_old = ime_buf;
498
+ ime_str_length_old = ime_str_length;
499
+ ime_buf = ime_buf_tmp_wchar;
500
+ ime_str_length = 0;
501
+ ime_buf[0] = 0;
502
+
503
+ ime_buf_tmp_char = ime_vk_push_buf_old;
504
+ ime_vk_push_buf_old = ime_vk_push_buf;
505
+ ime_vk_push_buf = ime_buf_tmp_char;
506
+ ime_vk_push_str_length_old = ime_vk_push_str_length;
507
+ ime_vk_push_str_length = 0;
508
+ ime_vk_push_buf[0] = 0;
509
+
510
+ ime_buf_tmp_char = ime_vk_release_buf_old;
511
+ ime_vk_release_buf_old = ime_vk_release_buf;
512
+ ime_vk_release_buf = ime_buf_tmp_char;
513
+ ime_vk_release_str_length_old = ime_vk_release_str_length;
514
+ ime_vk_release_str_length = 0;
515
+ ime_vk_release_buf[0] = 0;
516
+
517
+ {
518
+ int i, j, topindex, pagesize;
519
+ VALUE ary[8];
520
+
521
+ if( ime_composition_str != ime_composition_str_old )
522
+ {
523
+ if( ime_composition_str_old )
524
+ {
525
+ free( ime_composition_str_old );
526
+ }
527
+
528
+ if( ime_composition_str )
529
+ {
530
+ ary[0] = rb_str_export_to_enc( rb_enc_associate( rb_str_new( (char*)ime_composition_str, wcslen( ime_composition_str ) * 2 ), g_enc_utf16 ), g_enc_utf8 );
531
+ }
532
+ else
533
+ {
534
+ ary[0] = rb_str_new2("");
535
+ }
536
+ ime_composition_str_old = ime_composition_str;
537
+ }
538
+ else
539
+ {
540
+ ary[0] = rb_ary_entry( g_vCompInfoArray, 0 );
541
+ }
542
+
543
+ if( ime_composition_attr != ime_composition_attr_old )
544
+ {
545
+ VALUE vattr_ary = rb_ary_new();
546
+ if( ime_composition_attr_old )
547
+ {
548
+ free( ime_composition_attr_old );
549
+ }
550
+
551
+ if( ime_composition_attr )
552
+ {
553
+ for( i = 0; i < ime_composition_attr_size; i++ )
554
+ {
555
+ rb_ary_push( vattr_ary, INT2FIX( ime_composition_attr[i] ) );
556
+ }
557
+ }
558
+ ary[1] = vattr_ary;
559
+ ime_composition_attr_old = ime_composition_attr;
560
+ }
561
+ else
562
+ {
563
+ ary[1] = rb_ary_entry( g_vCompInfoArray, 1 );
564
+ }
565
+
566
+ ary[2] = INT2NUM( ime_cursor_pos );
567
+
568
+ if( ime_canlist != ime_canlist_old )
569
+ {
570
+ if( ime_canlist_old )
571
+ {
572
+ free( ime_canlist_old );
573
+ }
574
+
575
+ if( ime_canlist )
576
+ {
577
+ VALUE vcanlist = rb_ary_new();
578
+ pagesize = ime_canlist->dwPageSize;
579
+ topindex = (ime_canlist->dwSelection / pagesize) * pagesize;
580
+ for( i = topindex, j = 0; i < ime_canlist->dwCount && j < pagesize; i++, j++ )
581
+ {
582
+ rb_ary_push( vcanlist, rb_str_export_to_enc( rb_enc_associate( rb_str_new( (char *)ime_canlist + ime_canlist->dwOffset[i], wcslen( (const wchar_t *)((char *)ime_canlist + ime_canlist->dwOffset[i] )) * 2 ), g_enc_utf16 ), g_enc_utf8 ) );
583
+ }
584
+ ary[3] = vcanlist;
585
+ ary[4] = INT2NUM( ime_canlist->dwSelection - topindex );
586
+ ary[5] = INT2NUM( ime_canlist->dwSelection );
587
+ ary[6] = INT2NUM( pagesize );
588
+ ary[7] = INT2NUM( ime_canlist->dwCount );
589
+ }
590
+ else
591
+ {
592
+ ary[3] = rb_ary_new();
593
+ ary[4] = Qnil;
594
+ ary[5] = Qnil;
595
+ ary[6] = Qnil;
596
+ ary[7] = Qnil;
597
+ }
598
+
599
+ ime_canlist_old = ime_canlist;
600
+ }
601
+ else
602
+ {
603
+ ary[3] = rb_ary_entry( g_vCompInfoArray, 3 );
604
+ ary[4] = rb_ary_entry( g_vCompInfoArray, 4 );
605
+ ary[5] = rb_ary_entry( g_vCompInfoArray, 5 );
606
+ ary[6] = rb_ary_entry( g_vCompInfoArray, 6 );
607
+ ary[7] = rb_ary_entry( g_vCompInfoArray, 7 );
608
+ }
609
+
610
+ g_vCompInfoArray = rb_ary_new4( 8, ary );
611
+ }
612
+ LeaveCriticalSection( &ime_cs );
613
+ #endif
614
+
615
+ g_WindowInfo.input_updated = 1;
616
+ return;
617
+ }
618
+
619
+
620
+ /*--------------------------------------------------------------------
621
+ Input���W���[���̃f�[�^�擾
622
+
623
+ �������̓��͂�x�̑����ŕԂ�
624
+ ---------------------------------------------------------------------*/
625
+ static VALUE Input_x( int argc, VALUE *argv, VALUE obj )
626
+ {
627
+ int x = 0;
628
+ VALUE vnumber;
629
+ int number;
630
+
631
+ rb_scan_args( argc, argv, "01", &vnumber);
632
+
633
+ number = (vnumber == Qnil ? 0 : NUM2INT( vnumber ));
634
+
635
+ if( number < 0 || number >= PADMAX )
636
+ {
637
+ rb_raise( eDXRubyError, "invalid value - Input_x" );
638
+ }
639
+
640
+ // printf("PadConfig[P_LEFT] = %02X button[P_LEFT] = %d PadConfig[P_RIGHT] = %02X button[P_RIGHT] = %d\n",
641
+ // g_diKeyState[g_PadState[number].PadConfig[P_LEFT]],
642
+ // g_PadState[number].button[P_LEFT],
643
+ // g_diKeyState[g_PadState[number].PadConfig[P_RIGHT]],
644
+ // g_PadState[number].button[P_RIGHT]
645
+ // );
646
+
647
+
648
+ /* �Ђ��� */
649
+ if( (g_PadState[number].PadConfig[P_LEFT] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_LEFT]] & 0x80) || g_PadState[number].button[P_LEFT] == 1 ||
650
+ (g_PadState[number].PadConfig[P_D_LEFT] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_D_LEFT]] & 0x80) || g_PadState[number].button[P_D_LEFT] == 1 )
651
+ {
652
+ x = x - 1;
653
+ }
654
+
655
+ /* �݂� */
656
+ if( (g_PadState[number].PadConfig[P_RIGHT] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_RIGHT]] & 0x80) || g_PadState[number].button[P_RIGHT] == 1 ||
657
+ (g_PadState[number].PadConfig[P_D_RIGHT] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_D_RIGHT]] & 0x80) || g_PadState[number].button[P_D_RIGHT] == 1 )
658
+ {
659
+ x = x + 1;
660
+ }
661
+
662
+ return INT2FIX( x );
663
+ }
664
+
665
+
666
+ /*--------------------------------------------------------------------
667
+ Input���W���[���̃f�[�^�擾
668
+
669
+ �c�����̓��͂�y�̑����ŕԂ�
670
+ ---------------------------------------------------------------------*/
671
+ static VALUE Input_y( int argc, VALUE *argv, VALUE obj )
672
+ {
673
+ int y = 0;
674
+ VALUE vnumber;
675
+ int number;
676
+
677
+ rb_scan_args( argc, argv, "01", &vnumber);
678
+
679
+ number = (vnumber == Qnil ? 0 : NUM2INT( vnumber ));
680
+
681
+ if( number < 0 || number >= PADMAX )
682
+ {
683
+ rb_raise( eDXRubyError, "invalid value - Input_y" );
684
+ }
685
+
686
+
687
+ /* ���� */
688
+ if( (g_PadState[number].PadConfig[P_UP] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_UP]] & 0x80) || g_PadState[number].button[P_UP] == 1 ||
689
+ (g_PadState[number].PadConfig[P_D_UP] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_D_UP]] & 0x80) || g_PadState[number].button[P_D_UP] == 1 )
690
+ {
691
+ y = y - 1;
692
+ }
693
+
694
+ /* ���� */
695
+ if( (g_PadState[number].PadConfig[P_DOWN] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_DOWN]] & 0x80) || g_PadState[number].button[P_DOWN] == 1 ||
696
+ (g_PadState[number].PadConfig[P_D_DOWN] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_D_DOWN]] & 0x80) || g_PadState[number].button[P_D_DOWN] == 1 )
697
+ {
698
+ y = y + 1;
699
+ }
700
+
701
+ return INT2FIX( y );
702
+ }
703
+
704
+
705
+ /*--------------------------------------------------------------------*/
706
+ /*--------------------------------------------------------------------
707
+ Input���W���[���̃f�[�^�擾(���X�e�B�b�N)
708
+
709
+ ���X�e�B�b�N�̉������̓��͂�x�̑����ŕԂ�
710
+ ---------------------------------------------------------------------*/
711
+ static VALUE Input_lx( int argc, VALUE *argv, VALUE obj )
712
+ {
713
+ int x = 0;
714
+ VALUE vnumber;
715
+ int number;
716
+
717
+ rb_scan_args( argc, argv, "01", &vnumber);
718
+
719
+ number = (vnumber == Qnil ? 0 : NUM2INT( vnumber ));
720
+
721
+ if( number < 0 || number >= PADMAX )
722
+ {
723
+ rb_raise( eDXRubyError, "invalid value - Input_rx" );
724
+ }
725
+
726
+ /* �Ђ��� */
727
+ if( (g_PadState[number].PadConfig[P_LEFT] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_LEFT]] & 0x80) || g_PadState[number].button[P_LEFT] == 1 )
728
+ {
729
+ x = x - 1;
730
+ }
731
+
732
+ /* �݂� */
733
+ if( (g_PadState[number].PadConfig[P_RIGHT] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_RIGHT]] & 0x80) || g_PadState[number].button[P_RIGHT] == 1 )
734
+ {
735
+ x = x + 1;
736
+ }
737
+
738
+ return INT2FIX( x );
739
+ }
740
+
741
+
742
+ /*--------------------------------------------------------------------
743
+ Input���W���[���̃f�[�^�擾(���X�e�B�b�N)
744
+
745
+ ���X�e�B�b�N�̏c�����̓��͂�y�̑����ŕԂ�
746
+ ---------------------------------------------------------------------*/
747
+ static VALUE Input_ly( int argc, VALUE *argv, VALUE obj )
748
+ {
749
+ int y = 0;
750
+ VALUE vnumber;
751
+ int number;
752
+
753
+ rb_scan_args( argc, argv, "01", &vnumber);
754
+
755
+ number = (vnumber == Qnil ? 0 : NUM2INT( vnumber ));
756
+
757
+ if( number < 0 || number >= PADMAX )
758
+ {
759
+ rb_raise( eDXRubyError, "invalid value - Input_ry" );
760
+ }
761
+
762
+
763
+ /* ���� */
764
+ if( (g_PadState[number].PadConfig[P_UP] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_UP]] & 0x80) || g_PadState[number].button[P_UP] == 1 )
765
+ {
766
+ y = y - 1;
767
+ }
768
+
769
+ /* ���� */
770
+ if( (g_PadState[number].PadConfig[P_DOWN] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_DOWN]] & 0x80) || g_PadState[number].button[P_DOWN] == 1 )
771
+ {
772
+ y = y + 1;
773
+ }
774
+
775
+ return INT2FIX( y );
776
+ }
777
+
778
+
779
+ /*--------------------------------------------------------------------
780
+ Input���W���[���̃f�[�^�擾(�E�X�e�B�b�N)
781
+
782
+ �E�X�e�B�b�N�̉������̓��͂�x�̑����ŕԂ�
783
+ ---------------------------------------------------------------------*/
784
+ static VALUE Input_rx( int argc, VALUE *argv, VALUE obj )
785
+ {
786
+ int x = 0;
787
+ VALUE vnumber;
788
+ int number;
789
+
790
+ rb_scan_args( argc, argv, "01", &vnumber);
791
+
792
+ number = (vnumber == Qnil ? 0 : NUM2INT( vnumber ));
793
+
794
+ if( number < 0 || number >= PADMAX )
795
+ {
796
+ rb_raise( eDXRubyError, "invalid value - Input_rx" );
797
+ }
798
+
799
+ /* �Ђ��� */
800
+ if( (g_PadState[number].PadConfig[P_R_LEFT] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_R_LEFT]] & 0x80) || g_PadState[number].button[P_R_LEFT] == 1 )
801
+ {
802
+ x = x - 1;
803
+ }
804
+
805
+ /* �݂� */
806
+ if( (g_PadState[number].PadConfig[P_R_RIGHT] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_R_RIGHT]] & 0x80) || g_PadState[number].button[P_R_RIGHT] == 1 )
807
+ {
808
+ x = x + 1;
809
+ }
810
+
811
+ return INT2FIX( x );
812
+ }
813
+
814
+
815
+ /*--------------------------------------------------------------------
816
+ Input���W���[���̃f�[�^�擾(�E�X�e�B�b�N)
817
+
818
+ �E�X�e�B�b�N�̏c�����̓��͂�y�̑����ŕԂ�
819
+ ---------------------------------------------------------------------*/
820
+ static VALUE Input_ry( int argc, VALUE *argv, VALUE obj )
821
+ {
822
+ int y = 0;
823
+ VALUE vnumber;
824
+ int number;
825
+
826
+ rb_scan_args( argc, argv, "01", &vnumber);
827
+
828
+ number = (vnumber == Qnil ? 0 : NUM2INT( vnumber ));
829
+
830
+ if( number < 0 || number >= PADMAX )
831
+ {
832
+ rb_raise( eDXRubyError, "invalid value - Input_ry" );
833
+ }
834
+
835
+
836
+ /* ���� */
837
+ if( (g_PadState[number].PadConfig[P_R_UP] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_R_UP]] & 0x80) || g_PadState[number].button[P_R_UP] == 1 )
838
+ {
839
+ y = y - 1;
840
+ }
841
+
842
+ /* ���� */
843
+ if( (g_PadState[number].PadConfig[P_R_DOWN] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_R_DOWN]] & 0x80) || g_PadState[number].button[P_R_DOWN] == 1 )
844
+ {
845
+ y = y + 1;
846
+ }
847
+
848
+ return INT2FIX( y );
849
+ }
850
+
851
+
852
+ /*--------------------------------------------------------------------
853
+ Input���W���[���̃f�[�^�擾(�\���{�^��)
854
+
855
+ �\���{�^���̉������̓��͂�x�̑����ŕԂ�
856
+ ---------------------------------------------------------------------*/
857
+ static VALUE Input_dx( int argc, VALUE *argv, VALUE obj )
858
+ {
859
+ int x = 0;
860
+ VALUE vnumber;
861
+ int number;
862
+
863
+ rb_scan_args( argc, argv, "01", &vnumber);
864
+
865
+ number = (vnumber == Qnil ? 0 : NUM2INT( vnumber ));
866
+
867
+ if( number < 0 || number >= PADMAX )
868
+ {
869
+ rb_raise( eDXRubyError, "invalid value - Input_dx" );
870
+ }
871
+
872
+
873
+ /* �Ђ��� */
874
+ if( (g_PadState[number].PadConfig[P_D_LEFT] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_D_LEFT]] & 0x80) || g_PadState[number].button[P_D_LEFT] == 1 )
875
+ {
876
+ x = x - 1;
877
+ }
878
+
879
+ /* �݂� */
880
+ if( (g_PadState[number].PadConfig[P_D_RIGHT] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_D_RIGHT]] & 0x80) || g_PadState[number].button[P_D_RIGHT] == 1 )
881
+ {
882
+ x = x + 1;
883
+ }
884
+
885
+ return INT2FIX( x );
886
+ }
887
+
888
+
889
+ /*--------------------------------------------------------------------
890
+ Input���W���[���̃f�[�^�擾(�\���{�^��)
891
+
892
+ �\���{�^���̏c�����̓��͂�y�̑����ŕԂ�
893
+ ---------------------------------------------------------------------*/
894
+ static VALUE Input_dy( int argc, VALUE *argv, VALUE obj )
895
+ {
896
+ int y = 0;
897
+ VALUE vnumber;
898
+ int number;
899
+
900
+ rb_scan_args( argc, argv, "01", &vnumber);
901
+
902
+ number = (vnumber == Qnil ? 0 : NUM2INT( vnumber ));
903
+
904
+ if( number < 0 || number >= PADMAX )
905
+ {
906
+ rb_raise( eDXRubyError, "invalid value - Input_dy" );
907
+ }
908
+
909
+
910
+ /* ���� */
911
+ if( (g_PadState[number].PadConfig[P_D_UP] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_D_UP]] & 0x80) || g_PadState[number].button[P_D_UP] == 1 )
912
+ {
913
+ y = y - 1;
914
+ }
915
+
916
+ /* ���� */
917
+ if( (g_PadState[number].PadConfig[P_D_DOWN] != -1 && g_diKeyState[g_PadState[number].PadConfig[P_D_DOWN]] & 0x80) || g_PadState[number].button[P_D_DOWN] == 1 )
918
+ {
919
+ y = y + 1;
920
+ }
921
+
922
+ return INT2FIX( y );
923
+ }
924
+
925
+
926
+ /*--------------------------------------------------------------------
927
+ Input���W���[���̃f�[�^�擾
928
+
929
+ ������Ă�����true�ɂȂ�B�����̓L�[�R�[�h�B
930
+ ---------------------------------------------------------------------*/
931
+ static VALUE Input_keyDown( VALUE obj , VALUE vkey )
932
+ {
933
+ int key, padbutton = 0;
934
+
935
+ key = NUM2INT( vkey );
936
+ if( key < 0 || key >= 256 )
937
+ {
938
+ rb_raise( eDXRubyError, "invalid value - Input_keyDown" );
939
+ }
940
+
941
+ // if( g_diKeyConfig[key] != -1 && g_PadState[g_diKeyConfig[key] / 20].button[g_diKeyConfig[key] % 20] == 1 )
942
+ if( g_diKeyConfig[key] != -1 && g_PadState[g_diKeyConfig[key] / PADBUTTON_MAX].button[g_diKeyConfig[key] % PADBUTTON_MAX] == 1 )
943
+ {
944
+ padbutton = 1;
945
+ }
946
+
947
+ if( g_diKeyState[key] & 0x80 || padbutton == 1)
948
+ {
949
+ return Qtrue;
950
+ }
951
+
952
+ return Qfalse;
953
+ }
954
+
955
+
956
+ /*--------------------------------------------------------------------
957
+ Input���W���[���̃f�[�^�擾
958
+
959
+ �������u�Ԃ���true�ɂȂ�B�����̓L�[�R�[�h�B
960
+ ---------------------------------------------------------------------*/
961
+ static VALUE Input_keyPush( VALUE obj , VALUE vkey )
962
+ {
963
+ int key, padbutton = 0, padbuttonold = 0;
964
+
965
+ key = NUM2INT( vkey );
966
+ if( key < 0 || key >= 256 )
967
+ {
968
+ rb_raise( eDXRubyError, "invalid value - Input_keyPush" );
969
+ }
970
+
971
+ if( g_diKeyConfig[key] != -1 )
972
+ {
973
+ //if( g_PadState[g_diKeyConfig[key] / 20].button[g_diKeyConfig[key] % 20] == 1 )
974
+ if( g_PadState[g_diKeyConfig[key] / PADBUTTON_MAX].button[g_diKeyConfig[key] % PADBUTTON_MAX] == 1 )
975
+ {
976
+ padbutton = 1;
977
+ }
978
+ //if( g_PadStateOld[g_diKeyConfig[key] / 20].button[g_diKeyConfig[key] % 20] == 1 )
979
+ if( g_PadStateOld[g_diKeyConfig[key] / PADBUTTON_MAX].button[g_diKeyConfig[key] % PADBUTTON_MAX] == 1 )
980
+ {
981
+ padbuttonold = 1;
982
+ }
983
+ }
984
+
985
+ if( (g_diKeyState[key] & 0x80) || padbutton == 1 ) /* ���͂���Ă��� */
986
+ {
987
+ if( !(g_diKeyStateOld[key] & 0x80) && padbuttonold == 0 ) /* �O��OFF�ł��� */
988
+ {
989
+ g_diKeyCount[key] = 0; /* �J�E���g������ */
990
+ return Qtrue; /* �Ȃɂ͂Ƃ�����True */
991
+ }
992
+ else /* �O��ON������ */
993
+ {
994
+ if( g_diKeyWait[key] <= g_diKeyCount[key] ) /* �E�F�C�g�^�C���𒴂����� */
995
+ {
996
+ if( g_diKeyInterval[key] != 0 &&
997
+ (g_diKeyCount[key] - g_diKeyWait[key]) % g_diKeyInterval[key] == 0 ) /* �C���^�[�o���^�C�����Ƃ� */
998
+ {
999
+ return Qtrue; /* True */
1000
+ }
1001
+ }
1002
+ }
1003
+ }
1004
+
1005
+ return Qfalse;
1006
+ }
1007
+
1008
+
1009
+ /*--------------------------------------------------------------------
1010
+ Input���W���[���̃f�[�^�擾
1011
+
1012
+ �������u�Ԃ���true�ɂȂ�B�����̓L�[�R�[�h�B
1013
+ ---------------------------------------------------------------------*/
1014
+ static VALUE Input_keyRelease( VALUE obj , VALUE vkey )
1015
+ {
1016
+ int key, padbutton = 0, padbuttonold = 0;
1017
+
1018
+ key = NUM2INT( vkey );
1019
+ if( key < 0 || key >= 256 )
1020
+ {
1021
+ rb_raise( eDXRubyError, "invalid value - Input_keyPush" );
1022
+ }
1023
+
1024
+ if( g_diKeyConfig[key] != -1 )
1025
+ {
1026
+ //if( g_PadState[g_diKeyConfig[key] / 20].button[g_diKeyConfig[key] % 20] == 1 )
1027
+ if( g_PadState[g_diKeyConfig[key] / PADBUTTON_MAX].button[g_diKeyConfig[key] % PADBUTTON_MAX] == 1 )
1028
+ {
1029
+ padbutton = 1;
1030
+ }
1031
+ //if( g_PadStateOld[g_diKeyConfig[key] / 20].button[g_diKeyConfig[key] % 20] == 1 )
1032
+ if( g_PadStateOld[g_diKeyConfig[key] / PADBUTTON_MAX].button[g_diKeyConfig[key] % PADBUTTON_MAX] == 1 )
1033
+ {
1034
+ padbuttonold = 1;
1035
+ }
1036
+ }
1037
+
1038
+ if( !(g_diKeyState[key] & 0x80) && padbutton == 0 ) /* ���͂���Ă��Ȃ� */
1039
+ {
1040
+ if( g_diKeyStateOld[key] & 0x80 || padbuttonold == 1 ) /* �O��ON�ł��� */
1041
+ {
1042
+ return Qtrue; /* �Ȃɂ͂Ƃ�����True */
1043
+ }
1044
+ }
1045
+
1046
+ return Qfalse;
1047
+ }
1048
+
1049
+
1050
+ /*--------------------------------------------------------------------
1051
+ Input���W���[���̃f�[�^�擾
1052
+
1053
+ ������Ă�����true�ɂȂ�B�����̓{�^���ԍ��B
1054
+ ---------------------------------------------------------------------*/
1055
+ static VALUE Input_padDown( int argc, VALUE *argv, VALUE obj )
1056
+ {
1057
+ VALUE vnumber, vbutton;
1058
+ int number, button, key = 0;
1059
+
1060
+ rb_scan_args( argc, argv, "11", &vbutton, &vnumber);
1061
+
1062
+ button = NUM2INT( vbutton );
1063
+ number = (vnumber == Qnil ? 0 : NUM2INT( vnumber ));
1064
+
1065
+ if( number < 0 || button < 0 || number >= PADMAX || button >= PADBUTTON_MAX )
1066
+ {
1067
+ rb_raise( eDXRubyError, "invalid value - Input_padDown" );
1068
+ }
1069
+
1070
+ if( g_PadState[number].PadConfig[button] != -1 && g_diKeyState[g_PadState[number].PadConfig[button]] & 0x80 )
1071
+ {
1072
+ key = 1;
1073
+ }
1074
+
1075
+ if( key == 1 || g_PadState[number].button[button] == 1 )
1076
+ {
1077
+ return Qtrue;
1078
+ }
1079
+
1080
+ return Qfalse;
1081
+ }
1082
+
1083
+
1084
+ /*--------------------------------------------------------------------
1085
+ Input���W���[���̃f�[�^�擾
1086
+
1087
+ �������u�Ԃ���true�ɂȂ�B�����̓{�^���ԍ��B
1088
+ ---------------------------------------------------------------------*/
1089
+ static VALUE Input_padPush( int argc, VALUE *argv, VALUE obj )
1090
+ {
1091
+ VALUE vnumber, vbutton;
1092
+ int number, button, key = 0, keyold = 0;
1093
+
1094
+ rb_scan_args( argc, argv, "11", &vbutton, &vnumber);
1095
+
1096
+ button = NUM2INT( vbutton );
1097
+ number = (vnumber == Qnil ? 0 : NUM2INT( vnumber ));
1098
+
1099
+ if( number < 0 || button < 0 || number >= PADMAX || button >= PADBUTTON_MAX )
1100
+ {
1101
+ rb_raise( eDXRubyError, "invalid value - Input_padPush" );
1102
+ }
1103
+
1104
+ if( g_PadState[number].PadConfig[button] != -1 )
1105
+ {
1106
+ if( g_diKeyState[g_PadState[number].PadConfig[button]] & 0x80 )
1107
+ {
1108
+ key = 1;
1109
+ }
1110
+ if( g_diKeyStateOld[g_PadState[number].PadConfig[button]] & 0x80 )
1111
+ {
1112
+ keyold = 1;
1113
+ }
1114
+ }
1115
+
1116
+ if( key == 1 || g_PadState[number].button[button] == 1 ) /* ���͂���Ă��� */
1117
+ {
1118
+ if( keyold == 0 && g_PadStateOld[number].button[button] == 0 ) /* �O��OFF�ł��� */
1119
+ {
1120
+ g_PadState[number].count[button] = 0; /* �J�E���g������ */
1121
+ return Qtrue; /* �Ȃɂ͂Ƃ�����True */
1122
+ }
1123
+ else /* �O��ON������ */
1124
+ {
1125
+ if( g_PadState[number].wait[button] <= g_PadState[number].count[button] ) /* �E�F�C�g�^�C���𒴂����� */
1126
+ {
1127
+ if( g_PadState[number].interval[button] != 0 &&
1128
+ (g_PadState[number].count[button] - g_PadState[number].wait[button])
1129
+ % g_PadState[number].interval[button] == 0 ) /* �C���^�[�o���^�C�����Ƃ� */
1130
+ {
1131
+ return Qtrue; /* True */
1132
+ }
1133
+ }
1134
+ }
1135
+ }
1136
+
1137
+ return Qfalse;
1138
+ }
1139
+
1140
+
1141
+ /*--------------------------------------------------------------------
1142
+ Input���W���[���̃f�[�^�擾
1143
+
1144
+ �������u�Ԃ���true�ɂȂ�B�����̓{�^���ԍ��B
1145
+ ---------------------------------------------------------------------*/
1146
+ static VALUE Input_padRelease( int argc, VALUE *argv, VALUE obj )
1147
+ {
1148
+ VALUE vnumber, vbutton;
1149
+ int number, button, key = 0, keyold = 0;
1150
+
1151
+ rb_scan_args( argc, argv, "11", &vbutton, &vnumber);
1152
+
1153
+ button = NUM2INT( vbutton );
1154
+ number = (vnumber == Qnil ? 0 : NUM2INT( vnumber ));
1155
+
1156
+ if( number < 0 || button < 0 || number >= PADMAX || button >= PADBUTTON_MAX )
1157
+ {
1158
+ rb_raise( eDXRubyError, "invalid value - Input_padPush" );
1159
+ }
1160
+
1161
+ if( g_PadState[number].PadConfig[button] != -1 )
1162
+ {
1163
+ if( g_diKeyState[g_PadState[number].PadConfig[button]] & 0x80 )
1164
+ {
1165
+ key = 1;
1166
+ }
1167
+ if( g_diKeyStateOld[g_PadState[number].PadConfig[button]] & 0x80 )
1168
+ {
1169
+ keyold = 1;
1170
+ }
1171
+ }
1172
+
1173
+ if( key == 0 && g_PadState[number].button[button] == 0 ) /* ���͂���Ă��Ȃ� */
1174
+ {
1175
+ if( keyold == 1 || g_PadStateOld[number].button[button] == 1 ) /* �O��ON�ł��� */
1176
+ {
1177
+ return Qtrue; /* �Ȃɂ͂Ƃ�����True */
1178
+ }
1179
+ }
1180
+
1181
+ return Qfalse;
1182
+ }
1183
+
1184
+
1185
+ /*--------------------------------------------------------------------
1186
+ �p�b�h�ƃL�[�̑Ή���ݒ肷��
1187
+ ---------------------------------------------------------------------*/
1188
+ static void Input_SetConfig( int number, int pad, int key )
1189
+ {
1190
+ int i, j;
1191
+
1192
+ if( pad == -1 ) /* �L�[�ɑ΂���p�b�h���蓖�ĉ������� */
1193
+ {
1194
+ g_diKeyConfig[key] = -1;
1195
+ for( i = 0; i < PADMAX; i++)
1196
+ {
1197
+ for( j = 0; j < PADBUTTON_MAX; j++)
1198
+ {
1199
+ if( g_PadState[i].PadConfig[j] == key )
1200
+ {
1201
+ g_PadState[i].PadConfig[j] = -1;
1202
+ }
1203
+ }
1204
+ }
1205
+ }
1206
+ else if( key == -1 || key == 0 ) /* �p�b�h�ɑ΂���L�[���蓖�ĉ������� */
1207
+ {
1208
+ g_PadState[number].PadConfig[pad] = -1;
1209
+ for( i = 0; i < 256; i++)
1210
+ {
1211
+ if( g_diKeyConfig[i] == pad )
1212
+ {
1213
+ g_diKeyConfig[i] = -1;
1214
+ }
1215
+ }
1216
+ }
1217
+ else /* ���蓖�ď��� */
1218
+ {
1219
+ g_PadState[number].PadConfig[pad] = key;
1220
+ //g_diKeyConfig[key] = number * 20 + pad; //check
1221
+ g_diKeyConfig[key] = number * PADBUTTON_MAX + pad; //check
1222
+ }
1223
+ }
1224
+
1225
+ static VALUE Input_setconfig( int argc, VALUE *argv, VALUE obj )
1226
+ {
1227
+ VALUE vnumber, vpad, vkey;
1228
+ int number, pad, key;
1229
+
1230
+ rb_scan_args( argc, argv, "21", &vpad, &vkey, &vnumber);
1231
+
1232
+ number = (vnumber == Qnil ? 0 : NUM2INT( vnumber ));
1233
+ pad = (vpad == Qnil ? -1 : NUM2INT( vpad ));
1234
+ key = (vkey == Qnil ? -1 : NUM2INT( vkey ));
1235
+
1236
+ if( number < 0 || pad < -1 || key < -1 || number >= PADMAX || pad >= PADBUTTON_MAX || key >= 256 )
1237
+ {
1238
+ rb_raise( eDXRubyError, "invalid value - Input_setconfig" );
1239
+ }
1240
+
1241
+ if( pad != -1 || key != -1 )
1242
+ {
1243
+ Input_SetConfig( number, pad, key );
1244
+ }
1245
+
1246
+ return obj;
1247
+ }
1248
+
1249
+
1250
+ /*--------------------------------------------------------------------
1251
+ �}�E�X�z�C�[���̏�Ԃ�Ԃ�
1252
+ ---------------------------------------------------------------------*/
1253
+ static VALUE Input_getmousewheelpos( VALUE obj )
1254
+ {
1255
+ return INT2FIX(g_WindowInfo.mousewheelpos);
1256
+ }
1257
+
1258
+
1259
+ /*--------------------------------------------------------------------
1260
+ �}�E�X�z�C�[���̏�Ԃ�ݒ肷��
1261
+ ---------------------------------------------------------------------*/
1262
+ static VALUE Input_setmousewheelpos( VALUE obj, VALUE wheelpos )
1263
+ {
1264
+ g_WindowInfo.mousewheelpos = NUM2INT( wheelpos );
1265
+
1266
+ return obj;
1267
+ }
1268
+
1269
+
1270
+ /*--------------------------------------------------------------------
1271
+ �}�E�X�̃{�^����Ԃ�Ԃ�
1272
+ ---------------------------------------------------------------------*/
1273
+ static VALUE Input_mouseDown( VALUE obj, VALUE button )
1274
+ {
1275
+
1276
+ switch( NUM2INT( button ) )
1277
+ {
1278
+ case M_LBUTTON:
1279
+ if( g_byMouseState_L & 0x80 )
1280
+ {
1281
+ return Qtrue;
1282
+ }
1283
+ else
1284
+ {
1285
+ return Qfalse;
1286
+ }
1287
+
1288
+ case M_RBUTTON:
1289
+ if( g_byMouseState_R & 0x80 )
1290
+ {
1291
+ return Qtrue;
1292
+ }
1293
+ else
1294
+ {
1295
+ return Qfalse;
1296
+ }
1297
+
1298
+ case M_MBUTTON:
1299
+ if( g_byMouseState_M & 0x80 )
1300
+ {
1301
+ return Qtrue;
1302
+ }
1303
+ else
1304
+ {
1305
+ return Qfalse;
1306
+ }
1307
+ default:
1308
+ rb_raise( eDXRubyError, "invalid value - Input_mouseDown" );
1309
+ }
1310
+
1311
+ return Qnil;
1312
+ }
1313
+
1314
+
1315
+ /*--------------------------------------------------------------------
1316
+ �}�E�X�̃{�^���������ꂽ�Ƃ���true
1317
+ ---------------------------------------------------------------------*/
1318
+ static VALUE Input_mousePush( VALUE obj, VALUE button )
1319
+ {
1320
+
1321
+ switch( NUM2INT( button ) )
1322
+ {
1323
+ case M_LBUTTON:
1324
+ if( (g_byMouseState_L & 0x80) && !(g_byMouseStateOld_L & 0x80) )
1325
+ {
1326
+ return Qtrue;
1327
+ }
1328
+ else
1329
+ {
1330
+ return Qfalse;
1331
+ }
1332
+
1333
+ case M_RBUTTON:
1334
+ if( g_byMouseState_R & 0x80 && !(g_byMouseStateOld_R & 0x80) )
1335
+ {
1336
+ return Qtrue;
1337
+ }
1338
+ else
1339
+ {
1340
+ return Qfalse;
1341
+ }
1342
+
1343
+ case M_MBUTTON:
1344
+ if( g_byMouseState_M & 0x80 && !(g_byMouseStateOld_M & 0x80) )
1345
+ {
1346
+ return Qtrue;
1347
+ }
1348
+ else
1349
+ {
1350
+ return Qfalse;
1351
+ }
1352
+ default:
1353
+ rb_raise( eDXRubyError, "invalid value - Input_mousePush" );
1354
+ }
1355
+
1356
+ return Qnil;
1357
+ }
1358
+
1359
+
1360
+ /*--------------------------------------------------------------------
1361
+ �}�E�X�̃{�^���������ꂽ�Ƃ���true
1362
+ ---------------------------------------------------------------------*/
1363
+ static VALUE Input_mouseRelease( VALUE obj, VALUE button )
1364
+ {
1365
+
1366
+ switch( NUM2INT( button ) )
1367
+ {
1368
+ case M_LBUTTON:
1369
+ if( !(g_byMouseState_L & 0x80) && (g_byMouseStateOld_L & 0x80) )
1370
+ {
1371
+ return Qtrue;
1372
+ }
1373
+ else
1374
+ {
1375
+ return Qfalse;
1376
+ }
1377
+
1378
+ case M_RBUTTON:
1379
+ if( !(g_byMouseState_R & 0x80) && (g_byMouseStateOld_R & 0x80) )
1380
+ {
1381
+ return Qtrue;
1382
+ }
1383
+ else
1384
+ {
1385
+ return Qfalse;
1386
+ }
1387
+
1388
+ case M_MBUTTON:
1389
+ if( !(g_byMouseState_M & 0x80) && (g_byMouseStateOld_M & 0x80) )
1390
+ {
1391
+ return Qtrue;
1392
+ }
1393
+ else
1394
+ {
1395
+ return Qfalse;
1396
+ }
1397
+ default:
1398
+ rb_raise( eDXRubyError, "invalid value - Input_mouseRelease" );
1399
+ }
1400
+
1401
+ return Qnil;
1402
+ }
1403
+
1404
+
1405
+ /*--------------------------------------------------------------------
1406
+ �}�E�X�J�[�\���̈ʒu��Ԃ�
1407
+ ---------------------------------------------------------------------*/
1408
+ static VALUE Input_getmouseposx( VALUE obj )
1409
+ {
1410
+ POINT cursor;
1411
+
1412
+ GetCursorPos( &cursor );
1413
+ ScreenToClient( g_hWnd, &cursor );
1414
+ return INT2FIX( cursor.x );
1415
+ }
1416
+
1417
+
1418
+ /*--------------------------------------------------------------------
1419
+ �}�E�X�J�[�\���̈ʒu��Ԃ�
1420
+ ---------------------------------------------------------------------*/
1421
+ static VALUE Input_getmouseposy( VALUE obj )
1422
+ {
1423
+ POINT cursor;
1424
+
1425
+ GetCursorPos( &cursor );
1426
+ ScreenToClient( g_hWnd, &cursor );
1427
+
1428
+ return INT2FIX( cursor.y );
1429
+ }
1430
+
1431
+
1432
+ /*--------------------------------------------------------------------
1433
+ �}�E�X�J�[�\���̈ʒu��ݒ肷��
1434
+ ---------------------------------------------------------------------*/
1435
+ static VALUE Input_setmousepos( VALUE klass, VALUE vx, VALUE vy )
1436
+ {
1437
+ POINT cursor;
1438
+
1439
+ cursor.x = NUM2INT( vx );
1440
+ cursor.y = NUM2INT( vy );
1441
+ ClientToScreen( g_hWnd, &cursor );
1442
+ SetCursorPos( cursor.x, cursor.y );
1443
+
1444
+ return Qnil;
1445
+ }
1446
+
1447
+
1448
+ /*--------------------------------------------------------------------
1449
+ �}�E�X�`�悷�邩�ǂ����̐ݒ�
1450
+ ---------------------------------------------------------------------*/
1451
+ static VALUE Input_enablemouse( VALUE obj, VALUE vdrawflag )
1452
+ {
1453
+ if( RTEST(vdrawflag) )
1454
+ {
1455
+ ShowCursorMessage();
1456
+ }
1457
+ else
1458
+ {
1459
+ HideCursorMessage();
1460
+ }
1461
+
1462
+ return vdrawflag;
1463
+ }
1464
+
1465
+
1466
+ /*--------------------------------------------------------------------
1467
+ Input���W���[���̑S�L�[�I�[�g���s�[�g��Ԑݒ�
1468
+ ---------------------------------------------------------------------*/
1469
+ static VALUE Input_setrepeat( VALUE obj , VALUE vwait, VALUE vinterval )
1470
+ {
1471
+ int wait, interval, i, j;
1472
+
1473
+ wait = NUM2INT( vwait );
1474
+ interval = NUM2INT( vinterval );
1475
+
1476
+ for( i = 0; i < 256; i++)
1477
+ {
1478
+ g_diKeyWait[i] = wait;
1479
+ g_diKeyInterval[i] = interval;
1480
+ }
1481
+
1482
+ for( i = 0; i < PADMAX; i++)
1483
+ {
1484
+ for( j = 0; j < PADBUTTON_MAX; j++)
1485
+ {
1486
+ g_PadState[i].wait[j] = wait;
1487
+ g_PadState[i].interval[j] = interval;
1488
+ }
1489
+ }
1490
+
1491
+ return obj;
1492
+ }
1493
+
1494
+
1495
+ /*--------------------------------------------------------------------
1496
+ Input���W���[���̃L�[�I�[�g���s�[�g��Ԑݒ�
1497
+ ---------------------------------------------------------------------*/
1498
+ static VALUE Input_setkeyrepeat( VALUE obj , VALUE vkey, VALUE vwait, VALUE vinterval )
1499
+ {
1500
+ int key, wait, interval;
1501
+
1502
+ key = NUM2INT( vkey );
1503
+ wait = NUM2INT( vwait );
1504
+ interval = NUM2INT( vinterval );
1505
+
1506
+ if( key < 0 || key >= 256 || wait < 0 || interval < 0 )
1507
+ {
1508
+ rb_raise( eDXRubyError, "invalid value - Input_setKeyRepeat" );
1509
+ }
1510
+
1511
+ g_diKeyWait[key] = wait;
1512
+ g_diKeyInterval[key] = interval;
1513
+
1514
+ return obj;
1515
+ }
1516
+
1517
+
1518
+ /*--------------------------------------------------------------------
1519
+ Input���W���[���̃p�b�h�I�[�g���s�[�g��Ԑݒ�
1520
+ ---------------------------------------------------------------------*/
1521
+ static VALUE Input_setpadrepeat( int argc, VALUE *argv, VALUE obj )
1522
+ {
1523
+ VALUE vpad, vwait, vinterval, vnumber;
1524
+ int pad, wait, interval, number;
1525
+
1526
+ rb_scan_args( argc, argv, "31", &vpad, &vwait, &vinterval, &vnumber );
1527
+
1528
+ pad = NUM2INT( vpad );
1529
+ wait = NUM2INT( vwait );
1530
+ interval = NUM2INT( vinterval );
1531
+ number = (vnumber == Qnil ? 0 : NUM2INT( vnumber ));
1532
+
1533
+ if( number < 0 || pad < 0 || number >= PADMAX || pad >= PADBUTTON_MAX ||
1534
+ wait < 0 || interval < 0 )
1535
+ {
1536
+ rb_raise( eDXRubyError, "invalid value - Input_setPadRepeat" );
1537
+ }
1538
+
1539
+ g_PadState[number].wait[pad] = wait;
1540
+ g_PadState[number].interval[pad] = interval;
1541
+
1542
+ return obj;
1543
+ }
1544
+
1545
+
1546
+ /*--------------------------------------------------------------------
1547
+ Input���W���[���̃f�[�^�擾
1548
+
1549
+ ������Ă���L�[�̔z���Ԃ��B
1550
+ ---------------------------------------------------------------------*/
1551
+ static VALUE Input_getKeys( VALUE obj )
1552
+ {
1553
+ int i, j;
1554
+ VALUE buf[256];
1555
+
1556
+ for( i = 0, j = 0; i < 256; i++ )
1557
+ {
1558
+ if( g_diKeyState[i] & 0x80 ) /* ���͂���Ă��� */
1559
+ {
1560
+ buf[j++] = INT2FIX( i );
1561
+ }
1562
+ }
1563
+
1564
+ return rb_ary_new4( j, buf );
1565
+ }
1566
+
1567
+
1568
+ /*--------------------------------------------------------------------
1569
+ Input���W���[���̃f�[�^�擾
1570
+
1571
+ ������Ă���p�b�h�̔z���Ԃ��B
1572
+ ---------------------------------------------------------------------*/
1573
+ static VALUE Input_getPads( int argc, VALUE *argv, VALUE obj )
1574
+ {
1575
+ int i, j, number;
1576
+ VALUE buf[PADBUTTON_MAX];
1577
+ VALUE vnumber;
1578
+
1579
+ rb_scan_args( argc, argv, "01", &vnumber);
1580
+
1581
+ number = vnumber == Qnil ? 0 : NUM2INT( vnumber );
1582
+
1583
+ for( i = 0, j = 0; i < PADBUTTON_MAX; i++ )
1584
+ {
1585
+ if( g_PadState[number].button[i] == 1 )
1586
+ {
1587
+ buf[j++] = INT2FIX( i );
1588
+ }
1589
+ }
1590
+
1591
+ return rb_ary_new4( j, buf );
1592
+ }
1593
+
1594
+
1595
+ /*--------------------------------------------------------------------
1596
+ �p�b�h�̐���Ԃ�
1597
+ ---------------------------------------------------------------------*/
1598
+ static VALUE Input_getPadNum( VALUE obj )
1599
+ {
1600
+ return INT2FIX( g_JoystickCount );
1601
+ }
1602
+
1603
+
1604
+ /*--------------------------------------------------------------------
1605
+ �A�i���O���擾
1606
+ ---------------------------------------------------------------------*/
1607
+ static VALUE Input_getPadAxis( int argc, VALUE *argv, VALUE obj )
1608
+ {
1609
+ VALUE vnumber, vary;
1610
+ int number;
1611
+
1612
+ rb_scan_args( argc, argv, "01", &vnumber );
1613
+
1614
+ number = (vnumber == Qnil ? 0 : NUM2INT( vnumber ));
1615
+
1616
+ if( number < 0 || number >= PADMAX )
1617
+ {
1618
+ rb_raise( eDXRubyError, "invalid value - Input_setPadAxis" );
1619
+ }
1620
+
1621
+ return rb_ary_new3( 6, rb_float_new( g_PadState[number].x )
1622
+ , rb_float_new( g_PadState[number].y )
1623
+ , rb_float_new( g_PadState[number].z )
1624
+ , rb_float_new( g_PadState[number].rx )
1625
+ , rb_float_new( g_PadState[number].ry )
1626
+ , rb_float_new( g_PadState[number].rz )
1627
+ );
1628
+ }
1629
+
1630
+
1631
+ /*--------------------------------------------------------------------
1632
+ ���X�e�B�b�N�擾
1633
+ ---------------------------------------------------------------------*/
1634
+ static VALUE Input_getPadLStick( int argc, VALUE *argv, VALUE obj )
1635
+ {
1636
+ VALUE vnumber, vary;
1637
+ int number;
1638
+
1639
+ rb_scan_args( argc, argv, "01", &vnumber );
1640
+
1641
+ number = (vnumber == Qnil ? 0 : NUM2INT( vnumber ));
1642
+
1643
+ if( number < 0 || number >= PADMAX )
1644
+ {
1645
+ rb_raise( eDXRubyError, "invalid value - Input_setPadAxis" );
1646
+ }
1647
+
1648
+ return rb_ary_new3( 2, rb_float_new( g_PadState[number].x )
1649
+ , rb_float_new( g_PadState[number].y )
1650
+ );
1651
+ }
1652
+
1653
+
1654
+ /*--------------------------------------------------------------------
1655
+ �E�X�e�B�b�N�擾
1656
+ ---------------------------------------------------------------------*/
1657
+ static VALUE Input_getPadRStick( int argc, VALUE *argv, VALUE obj )
1658
+ {
1659
+ VALUE vnumber, vary;
1660
+ int number;
1661
+
1662
+ rb_scan_args( argc, argv, "01", &vnumber );
1663
+
1664
+ number = (vnumber == Qnil ? 0 : NUM2INT( vnumber ));
1665
+
1666
+ if( number < 0 || number >= PADMAX )
1667
+ {
1668
+ rb_raise( eDXRubyError, "invalid value - Input_setPadAxis" );
1669
+ }
1670
+
1671
+ return rb_ary_new3( 2, rb_float_new( g_PadState[number].z )
1672
+ , rb_float_new( g_PadState[number].rz )
1673
+ );
1674
+ }
1675
+
1676
+
1677
+ /*--------------------------------------------------------------------
1678
+ POV�擾
1679
+ ---------------------------------------------------------------------*/
1680
+ static VALUE Input_getPadPov( int argc, VALUE *argv, VALUE obj )
1681
+ {
1682
+ VALUE vnumber, vary;
1683
+ int number;
1684
+
1685
+ rb_scan_args( argc, argv, "01", &vnumber );
1686
+
1687
+ number = (vnumber == Qnil ? 0 : NUM2INT( vnumber ));
1688
+
1689
+ if( number < 0 || number >= PADMAX )
1690
+ {
1691
+ rb_raise( eDXRubyError, "invalid value - Input_setPadAxis" );
1692
+ }
1693
+
1694
+ return INT2FIX( g_PadState[number].pov );
1695
+ }
1696
+
1697
+
1698
+ ///*--------------------------------------------------------------------
1699
+ // �G�t�F�N�g�J�n
1700
+ // ---------------------------------------------------------------------*/
1701
+ //static VALUE Input_ff_start( VALUE obj )
1702
+ //{
1703
+ // g_lpDIEffect->lpVtbl->Start( g_lpDIEffect, 1, 0 );
1704
+ // return Qnil;
1705
+ //}
1706
+ ///*--------------------------------------------------------------------
1707
+ // �G�t�F�N�g��~
1708
+ // ---------------------------------------------------------------------*/
1709
+ //static VALUE Input_ff_stop( VALUE obj )
1710
+ //{
1711
+ // g_lpDIEffect->lpVtbl->Stop( g_lpDIEffect );
1712
+ // return Qnil;
1713
+ //}
1714
+
1715
+
1716
+ /*--------------------------------------------------------------------
1717
+ �J�[�\���`��ύX
1718
+ ---------------------------------------------------------------------*/
1719
+ static VALUE Input_setCursor( VALUE obj , VALUE vcursor )
1720
+ {
1721
+
1722
+ SetCursorMessage( NUM2INT(vcursor) );
1723
+ return vcursor;
1724
+ }
1725
+
1726
+
1727
+ #ifdef DXRUBY15
1728
+ /*--------------------------------------------------------------------
1729
+ IME���������
1730
+ ---------------------------------------------------------------------*/
1731
+ static VALUE Input_IME_getstring( VALUE obj )
1732
+ {
1733
+ return rb_str_export_to_enc( rb_enc_str_new( (char*)ime_buf_old, ime_str_length_old * 2, g_enc_utf16 ), g_enc_utf8 );
1734
+ }
1735
+
1736
+ UINT DI_KeyList[][2] = { {VK_UP,DIK_UP}, {VK_DOWN,DIK_DOWN}, {VK_LEFT,DIK_LEFT}, {VK_RIGHT,DIK_RIGHT},
1737
+ {VK_INSERT,DIK_INSERT}, {VK_HOME,DIK_HOME}, {VK_PRIOR,DIK_PRIOR},
1738
+ {VK_DELETE,DIK_DELETE}, {VK_END,DIK_END}, {VK_NEXT,DIK_NEXT},
1739
+ {VK_LMENU,DIK_LMENU}, {VK_RMENU,DIK_RMENU}, {VK_LCONTROL,DIK_LCONTROL}, {VK_RCONTROL,DIK_RCONTROL},
1740
+ {VK_DIVIDE,DIK_DIVIDE} };
1741
+
1742
+ /*--------------------------------------------------------------------
1743
+ IME�������L�[�ꗗ
1744
+ ---------------------------------------------------------------------*/
1745
+ static VALUE Input_IME_getpushkeys( VALUE obj )
1746
+ {
1747
+ int i, j;
1748
+ VALUE ary;
1749
+
1750
+ if( ime_vk_push_str_length_old == 0 )
1751
+ {
1752
+ return rb_ary_new();
1753
+ }
1754
+
1755
+ ary = rb_ary_new2( ime_vk_push_str_length_old );
1756
+
1757
+ for( i = 0; i < ime_vk_push_str_length_old ; i++ )
1758
+ {
1759
+ for( j = 0; j < sizeof(DI_KeyList)/(sizeof(UINT)*2); j++ )
1760
+ {
1761
+ if( ime_vk_push_buf_old[i] == DI_KeyList[j][0] )
1762
+ {
1763
+ rb_ary_push( ary, INT2FIX( DI_KeyList[j][1] ));
1764
+ break;
1765
+ }
1766
+ }
1767
+
1768
+ if( j == sizeof(DI_KeyList)/(sizeof(UINT)*2) )
1769
+ {
1770
+ rb_ary_push( ary, INT2FIX(MapVirtualKey( ime_vk_push_buf_old[i], 0 )));
1771
+ }
1772
+ }
1773
+
1774
+ return ary;
1775
+ }
1776
+
1777
+
1778
+ /*--------------------------------------------------------------------
1779
+ IME�������L�[�ꗗ
1780
+ ---------------------------------------------------------------------*/
1781
+ static VALUE Input_IME_getreleasekeys( VALUE obj )
1782
+ {
1783
+ int i, j;
1784
+ VALUE ary;
1785
+
1786
+ if( ime_vk_release_str_length_old == 0 )
1787
+ {
1788
+ return rb_ary_new();
1789
+ }
1790
+
1791
+ ary = rb_ary_new2( ime_vk_release_str_length_old );
1792
+
1793
+ for( i = 0; i < ime_vk_release_str_length_old ; i++ )
1794
+ {
1795
+ for( j = 0; j < sizeof(DI_KeyList)/(sizeof(UINT)*2); j++ )
1796
+ {
1797
+ if( ime_vk_release_buf_old[i] == DI_KeyList[j][0] )
1798
+ {
1799
+ rb_ary_push( ary, INT2FIX( DI_KeyList[j][1] ));
1800
+ break;
1801
+ }
1802
+ }
1803
+
1804
+ if( j == sizeof(DI_KeyList)/(sizeof(UINT)*2) )
1805
+ {
1806
+ rb_ary_push( ary, INT2FIX(MapVirtualKey( ime_vk_release_buf_old[i], 0 )));
1807
+ }
1808
+ }
1809
+
1810
+ return ary;
1811
+ }
1812
+
1813
+
1814
+ /*--------------------------------------------------------------------
1815
+ IME��enable
1816
+ ---------------------------------------------------------------------*/
1817
+ static VALUE Input_IME_setenable( VALUE obj, VALUE vflag )
1818
+ {
1819
+ SetImeEnable( RTEST( vflag ) );
1820
+ return vflag;
1821
+ }
1822
+
1823
+
1824
+ /*--------------------------------------------------------------------
1825
+ IME��enable�擾
1826
+ ---------------------------------------------------------------------*/
1827
+ static VALUE Input_IME_getenable( VALUE obj )
1828
+ {
1829
+ return ( GetImeEnable() ? Qtrue : Qfalse );
1830
+ }
1831
+
1832
+
1833
+ /*--------------------------------------------------------------------
1834
+ IME�̏�Ԏ擾
1835
+ ---------------------------------------------------------------------*/
1836
+ static VALUE Input_IME_getcompositing( VALUE obj )
1837
+ {
1838
+ return ( ime_compositing ? Qtrue : Qfalse );
1839
+ }
1840
+
1841
+ /*--------------------------------------------------------------------
1842
+ IME�̕ϊ���������擾
1843
+ ---------------------------------------------------------------------*/
1844
+ static VALUE Input_IME_getcompositioninfo( VALUE obj )
1845
+ {
1846
+ VALUE ary[8];
1847
+ ary[0] = RARRAY_AREF( g_vCompInfoArray, 0 );
1848
+ ary[1] = RARRAY_AREF( g_vCompInfoArray, 1 );
1849
+ ary[2] = RARRAY_AREF( g_vCompInfoArray, 2 );
1850
+ ary[3] = RARRAY_AREF( g_vCompInfoArray, 3 );
1851
+ ary[4] = RARRAY_AREF( g_vCompInfoArray, 4 );
1852
+ ary[5] = RARRAY_AREF( g_vCompInfoArray, 5 );
1853
+ ary[6] = RARRAY_AREF( g_vCompInfoArray, 6 );
1854
+ ary[7] = RARRAY_AREF( g_vCompInfoArray, 7 );
1855
+ return rb_class_new_instance( 8, ary, cCompInfo );
1856
+ }
1857
+ #endif
1858
+
1859
+
1860
+ /* �f�o�C�X�񋓊֐� */
1861
+ BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, void* pContext )
1862
+ {
1863
+ HRESULT hr;
1864
+
1865
+ /* �񋓂��ꂽ�W���C�X�e�B�b�N�ւ̃C���^�[�t�F�C�X���擾���� */
1866
+ hr = g_pDInput->lpVtbl->CreateDevice( g_pDInput,
1867
+ &pdidInstance->guidInstance,
1868
+ &g_pDIDJoyPad[g_JoystickCount],
1869
+ NULL );
1870
+ if( SUCCEEDED( hr ) )
1871
+ {
1872
+ return (++g_JoystickCount == PADMAX)?(DIENUM_STOP):(DIENUM_CONTINUE);
1873
+ }
1874
+
1875
+ return DIENUM_STOP;
1876
+ }
1877
+
1878
+ /* �I�u�W�F�N�g�i���j�񋓊֐� */
1879
+ BOOL CALLBACK EnumAxisCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, void *pContext )
1880
+ {
1881
+ HRESULT hr;
1882
+ DIPROPRANGE diprg = { sizeof(DIPROPRANGE), sizeof(DIPROPHEADER) };
1883
+ struct DXRubyPadInfo *pad;
1884
+
1885
+ pad = (struct DXRubyPadInfo *)pContext;
1886
+
1887
+ diprg.diph.dwHow = DIPH_BYID;
1888
+ diprg.diph.dwObj = pdidoi->dwType;
1889
+
1890
+ /*========================================================*/
1891
+ /* �擾 */
1892
+ hr = pad->pDIDJoyPad->lpVtbl->GetProperty( pad->pDIDJoyPad, DIPROP_RANGE, &diprg.diph );
1893
+
1894
+ if( FAILED( hr ) )
1895
+ {
1896
+ MainThreadError = 17;
1897
+ return DIENUM_STOP;
1898
+ }
1899
+
1900
+ /* x�� */
1901
+ if( memcmp( &pdidoi->guidType, &GUID_XAxis ,sizeof(GUID)) == 0 )
1902
+ {
1903
+ pad->x_flg = 1;
1904
+ pad->x_min = diprg.lMin;
1905
+ pad->x_center = (diprg.lMin + diprg.lMax) / 2;
1906
+ pad->x_max = diprg.lMax;
1907
+ if ( ( pdidoi->dwFlags & DIDOI_FFACTUATOR) != 0 )
1908
+ {
1909
+ pad->x_ff_flg = 1;
1910
+ }
1911
+ }
1912
+
1913
+ /* y�� */
1914
+ if( memcmp( &pdidoi->guidType, &GUID_YAxis ,sizeof(GUID)) == 0 )
1915
+ {
1916
+ pad->y_flg = 1;
1917
+ pad->y_min = diprg.lMin;
1918
+ pad->y_center = (diprg.lMin + diprg.lMax) / 2;
1919
+ pad->y_max = diprg.lMax;
1920
+ if ( ( pdidoi->dwFlags & DIDOI_FFACTUATOR) != 0 )
1921
+ {
1922
+ pad->y_ff_flg = 1;
1923
+ }
1924
+ }
1925
+
1926
+ /* z�� */
1927
+ if( memcmp( &pdidoi->guidType, &GUID_ZAxis ,sizeof(GUID)) == 0 )
1928
+ {
1929
+ pad->z_flg = 1;
1930
+ pad->z_min = diprg.lMin;
1931
+ pad->z_center = (diprg.lMin + diprg.lMax) / 2;
1932
+ pad->z_max = diprg.lMax;
1933
+ }
1934
+
1935
+ /* x����] */
1936
+ if( memcmp( &pdidoi->guidType, &GUID_RxAxis ,sizeof(GUID)) == 0 )
1937
+ {
1938
+ pad->rx_flg = 1;
1939
+ pad->rx_min = diprg.lMin;
1940
+ pad->rx_center = (diprg.lMin + diprg.lMax) / 2;
1941
+ pad->rx_max = diprg.lMax;
1942
+ }
1943
+
1944
+ /* y����] */
1945
+ if( memcmp( &pdidoi->guidType, &GUID_RyAxis ,sizeof(GUID)) == 0 )
1946
+ {
1947
+ pad->ry_flg = 1;
1948
+ pad->ry_min = diprg.lMin;
1949
+ pad->ry_center = (diprg.lMin + diprg.lMax) / 2;
1950
+ pad->ry_max = diprg.lMax;
1951
+ }
1952
+
1953
+ /* z����] */
1954
+ if( memcmp( &pdidoi->guidType, &GUID_RzAxis ,sizeof(GUID)) == 0 )
1955
+ {
1956
+ pad->rz_flg = 1;
1957
+ pad->rz_min = diprg.lMin;
1958
+ pad->rz_center = (diprg.lMin + diprg.lMax) / 2;
1959
+ pad->rz_max = diprg.lMax;
1960
+ }
1961
+
1962
+ return DIENUM_CONTINUE;
1963
+ }
1964
+
1965
+ /*--------------------------------------------------------------------
1966
+ �i�����֐��jDirectInput������
1967
+ ---------------------------------------------------------------------*/
1968
+ int InitDirectInput( void )
1969
+ {
1970
+ HRESULT hr;
1971
+ int i;
1972
+
1973
+ /* DirectInput������ */
1974
+
1975
+ /* DirectInput�I�u�W�F�N�g�̍쐬 */
1976
+ hr = DirectInput8Create( g_hInstance, DIRECTINPUT_VERSION,
1977
+ &IID_IDirectInput8, (void **)&g_pDInput, NULL );
1978
+
1979
+ if( FAILED( hr ) )
1980
+ {
1981
+ MainThreadError = 10;
1982
+ return MainThreadError;
1983
+ }
1984
+
1985
+ /* �L�[�{�[�h */
1986
+
1987
+ /* �f�o�C�X�E�I�u�W�F�N�g���쐬�i�L�[�{�[�h�j */
1988
+ hr = g_pDInput->lpVtbl->CreateDevice( g_pDInput, &GUID_SysKeyboard, &g_pDIDKeyBoard, NULL );
1989
+
1990
+ if( FAILED( hr ) )
1991
+ {
1992
+ MainThreadError = 11;
1993
+ return MainThreadError;
1994
+ }
1995
+
1996
+ /* �f�[�^�`����ݒ�i�L�[�{�[�h�ł���j */
1997
+ hr = g_pDIDKeyBoard->lpVtbl->SetDataFormat( g_pDIDKeyBoard, &c_dfDIKeyboard );
1998
+
1999
+ if( FAILED( hr ) )
2000
+ {
2001
+ MainThreadError = 12;
2002
+ return MainThreadError;
2003
+ }
2004
+
2005
+ /* �L�[�{�[�h�̃��[�h��ݒ�i�t�H�A�O���E���h����r�����[�h�j */
2006
+ hr = g_pDIDKeyBoard->lpVtbl->SetCooperativeLevel( g_pDIDKeyBoard, g_hWnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND );
2007
+
2008
+ if( FAILED( hr ) )
2009
+ {
2010
+ MainThreadError = 13;
2011
+ return MainThreadError;
2012
+ }
2013
+
2014
+ /* ���͐���J�n */
2015
+ g_pDIDKeyBoard->lpVtbl->Acquire( g_pDIDKeyBoard );
2016
+
2017
+
2018
+ /* �Q�[���p�b�h */
2019
+
2020
+ for( i = 0; i < PADMAX; i++)
2021
+ {
2022
+ g_pDIDJoyPad[i] = NULL;
2023
+ }
2024
+ g_JoystickCount = 0;
2025
+
2026
+ /* �Q�[���f�o�C�X�� */
2027
+ hr = g_pDInput->lpVtbl->EnumDevices( g_pDInput, DI8DEVCLASS_GAMECTRL, EnumJoysticksCallback, NULL, DIEDFL_ATTACHEDONLY );
2028
+
2029
+ if( MainThreadError != 0 )
2030
+ {
2031
+ return MainThreadError;
2032
+ }
2033
+
2034
+ if( FAILED( hr ) )
2035
+ {
2036
+ MainThreadError = 14;
2037
+ return MainThreadError;
2038
+ }
2039
+
2040
+ /* �Q�[���f�o�C�X������ */
2041
+ for ( i = 0; i < g_JoystickCount; i++ )
2042
+ {
2043
+ /* �f�[�^�`����ݒ� */
2044
+ hr = g_pDIDJoyPad[i]->lpVtbl->SetDataFormat( g_pDIDJoyPad[i], &c_dfDIJoystick );
2045
+
2046
+ if( FAILED( hr ) )
2047
+ {
2048
+ MainThreadError = 15;
2049
+ return MainThreadError;
2050
+ }
2051
+
2052
+ /* �L�[�{�[�h�̃��[�h��ݒ�i�t�H�A�O���E���h����r�����[�h�j */
2053
+ hr = g_pDIDJoyPad[i]->lpVtbl->SetCooperativeLevel( g_pDIDJoyPad[i], g_hWnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND );
2054
+
2055
+ if( FAILED( hr ) )
2056
+ {
2057
+ MainThreadError = 16;
2058
+ return MainThreadError;
2059
+ }
2060
+
2061
+ /* ���I�u�W�F�N�g�� */
2062
+ g_PadInfo[i].pDIDJoyPad = g_pDIDJoyPad[i];
2063
+ g_PadInfo[i].x_flg = g_PadInfo[i].y_flg = g_PadInfo[i].z_flg =
2064
+ g_PadInfo[i].rx_flg = g_PadInfo[i].ry_flg = g_PadInfo[i].rz_flg =
2065
+ g_PadInfo[i].x_ff_flg = g_PadInfo[i].y_ff_flg = 0;
2066
+ hr = g_pDIDJoyPad[i]->lpVtbl->EnumObjects( g_pDIDJoyPad[i], EnumAxisCallback, &g_PadInfo[i], DIDFT_AXIS );
2067
+
2068
+ if( MainThreadError != 0 )
2069
+ {
2070
+ return MainThreadError;
2071
+ }
2072
+
2073
+ if( FAILED( hr ) )
2074
+ {
2075
+ MainThreadError = 18;
2076
+ return MainThreadError;
2077
+ }
2078
+
2079
+ // /* �t�H�[�X�t�B�[�h�o�b�N���� */
2080
+ // if( g_PadInfo[i].x_ff_flg + g_PadInfo[i].y_ff_flg > 0 )
2081
+ // {
2082
+ //
2083
+ // DWORD rgdwAxes[2] = { DIJOFS_X , DIJOFS_Y };
2084
+ // LONG rglDirection[2] = { 1 , 1 };
2085
+ // DICONSTANTFORCE cf;
2086
+ // DIEFFECT eff;
2087
+ // HRESULT hr;
2088
+ //
2089
+ // ZeroMemory( &eff , sizeof( eff ) );
2090
+ // eff.dwSize = sizeof( DIEFFECT );
2091
+ // eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
2092
+ // eff.dwDuration = INFINITE;
2093
+ // eff.dwSamplePeriod = 0;
2094
+ // eff.dwGain = DI_FFNOMINALMAX;
2095
+ // eff.dwTriggerButton = DIEB_NOTRIGGER;
2096
+ // eff.dwTriggerRepeatInterval = 0;
2097
+ // eff.cAxes = g_PadInfo[i].x_ff_flg + g_PadInfo[i].y_ff_flg;
2098
+ // eff.rgdwAxes = rgdwAxes;
2099
+ // eff.rglDirection = rglDirection;
2100
+ // eff.lpEnvelope = 0;
2101
+ // eff.cbTypeSpecificParams = sizeof( DICONSTANTFORCE );
2102
+ // eff.lpvTypeSpecificParams = &cf;
2103
+ // eff.dwStartDelay = 0;
2104
+ //
2105
+ // hr = g_pDIDJoyPad[i]->lpVtbl->CreateEffect( g_pDIDJoyPad[i], &GUID_ConstantForce, &eff, &g_lpDIEffect, NULL );
2106
+ // if ( FAILED( hr ) ){
2107
+ // rb_raise( eDXRubyError, "DirectInput�̏������Ɏ��s���܂��� - CreateEffect" );
2108
+ // }
2109
+ //
2110
+ // }
2111
+
2112
+ /* ���͐���J�n */
2113
+ g_pDIDJoyPad[i]->lpVtbl->Acquire( g_pDIDJoyPad[i] );
2114
+ }
2115
+
2116
+ return 0;
2117
+ }
2118
+
2119
+
2120
+ void Input_release( void )
2121
+ {
2122
+ int i;
2123
+
2124
+ // g_lpDIEffect->lpVtbl->Unload(g_lpDIEffect);
2125
+ // RELEASE( g_lpDIEffect );
2126
+
2127
+ for( i = 0 ; i < g_JoystickCount; i++ )
2128
+ {
2129
+ /* DirectInputDevice(JoyPad)�I�u�W�F�N�g�̎g�p�I�� */
2130
+ if( g_pDIDJoyPad[i] )
2131
+ {
2132
+ g_pDIDJoyPad[i]->lpVtbl->Unacquire( g_pDIDJoyPad[i] );
2133
+ }
2134
+
2135
+ /* DirectInputDevide(JoyPad)�I�u�W�F�N�g�̔j�� */
2136
+ RELEASE( g_pDIDJoyPad[i] );
2137
+ }
2138
+
2139
+ /* DirectInputDevice(Keyboard)�I�u�W�F�N�g�̎g�p�I�� */
2140
+ if( g_pDIDKeyBoard )
2141
+ {
2142
+ g_pDIDKeyBoard->lpVtbl->Unacquire( g_pDIDKeyBoard );
2143
+ }
2144
+
2145
+ /* DirectInputDevide(Keyboard)�I�u�W�F�N�g�̔j�� */
2146
+ RELEASE( g_pDIDKeyBoard );
2147
+
2148
+ /* DirectInput�I�u�W�F�N�g�̔j�� */
2149
+ RELEASE( g_pDInput );
2150
+ }
2151
+
2152
+ void Init_dxruby_Input( void )
2153
+ {
2154
+ int i, j;
2155
+
2156
+ /* Input���W���[���o�^ */
2157
+ mInput = rb_define_module_under( mDXRuby, "Input" );
2158
+
2159
+ /* Input���W���[���Ƀ��\�b�h�o�^ */
2160
+ rb_define_singleton_method( mInput, "x" , Input_x , -1 );
2161
+ rb_define_singleton_method( mInput, "y" , Input_y , -1 );
2162
+ rb_define_singleton_method( mInput, "set_mouse_pos" , Input_setmousepos , 2 );
2163
+ rb_define_singleton_method( mInput, "setMousePos" , Input_setmousepos , 2 );
2164
+ rb_define_singleton_method( mInput, "mouse_pos_x" , Input_getmouseposx , 0 );
2165
+ rb_define_singleton_method( mInput, "mousePosX" , Input_getmouseposx , 0 );
2166
+ rb_define_singleton_method( mInput, "mouse_pos_y" , Input_getmouseposy , 0 );
2167
+ rb_define_singleton_method( mInput, "mousePosY" , Input_getmouseposy , 0 );
2168
+ rb_define_singleton_method( mInput, "mouse_x" , Input_getmouseposx , 0 );
2169
+ rb_define_singleton_method( mInput, "mouseX" , Input_getmouseposx , 0 );
2170
+ rb_define_singleton_method( mInput, "mouse_y" , Input_getmouseposy , 0 );
2171
+ rb_define_singleton_method( mInput, "mouseY" , Input_getmouseposy , 0 );
2172
+ rb_define_singleton_method( mInput, "key_down?" , Input_keyDown , 1 );
2173
+ rb_define_singleton_method( mInput, "keyDown?" , Input_keyDown , 1 );
2174
+ rb_define_singleton_method( mInput, "key_push?" , Input_keyPush , 1 );
2175
+ rb_define_singleton_method( mInput, "keyPush?" , Input_keyPush , 1 );
2176
+ rb_define_singleton_method( mInput, "key_release?" , Input_keyRelease , 1 );
2177
+ rb_define_singleton_method( mInput, "keyRelease?" , Input_keyRelease , 1 );
2178
+ rb_define_singleton_method( mInput, "pad_down?" , Input_padDown , -1 );
2179
+ rb_define_singleton_method( mInput, "padDown?" , Input_padDown , -1 );
2180
+ rb_define_singleton_method( mInput, "pad_push?" , Input_padPush , -1 );
2181
+ rb_define_singleton_method( mInput, "padPush?" , Input_padPush , -1 );
2182
+ rb_define_singleton_method( mInput, "pad_release?" , Input_padRelease , -1 );
2183
+ rb_define_singleton_method( mInput, "padRelease?" , Input_padRelease , -1 );
2184
+ rb_define_singleton_method( mInput, "mouse_down?" , Input_mouseDown , 1 );
2185
+ rb_define_singleton_method( mInput, "mouseDown?" , Input_mouseDown , 1 );
2186
+ rb_define_singleton_method( mInput, "mouse_push?" , Input_mousePush , 1 );
2187
+ rb_define_singleton_method( mInput, "mousePush?" , Input_mousePush , 1 );
2188
+ rb_define_singleton_method( mInput, "mouse_release?" , Input_mouseRelease , 1 );
2189
+ rb_define_singleton_method( mInput, "mouseRelease?" , Input_mouseRelease , 1 );
2190
+ rb_define_singleton_method( mInput, "mouse_enable=" , Input_enablemouse , 1 );
2191
+ rb_define_singleton_method( mInput, "mouseEnable=" , Input_enablemouse , 1 );
2192
+ rb_define_singleton_method( mInput, "mouse_wheel_pos", Input_getmousewheelpos, 0 );
2193
+ rb_define_singleton_method( mInput, "mouseWheelPos" , Input_getmousewheelpos, 0 );
2194
+ rb_define_singleton_method( mInput, "mouse_wheel_pos=", Input_setmousewheelpos, 1 );
2195
+ rb_define_singleton_method( mInput, "mouseWheelPos=" , Input_setmousewheelpos, 1 );
2196
+ rb_define_singleton_method( mInput, "set_config" , Input_setconfig , -1 );
2197
+ rb_define_singleton_method( mInput, "setConfig" , Input_setconfig , -1 );
2198
+ rb_define_singleton_method( mInput, "set_repeat" , Input_setrepeat , 2 );
2199
+ rb_define_singleton_method( mInput, "setRepeat" , Input_setrepeat , 2 );
2200
+ rb_define_singleton_method( mInput, "update" , Input_update , 0 );
2201
+ rb_define_singleton_method( mInput, "set_key_repeat" , Input_setkeyrepeat , 3 );
2202
+ rb_define_singleton_method( mInput, "setKeyRepeat" , Input_setkeyrepeat , 3 );
2203
+ rb_define_singleton_method( mInput, "set_pad_repeat" , Input_setpadrepeat , -1 );
2204
+ rb_define_singleton_method( mInput, "setPadRepeat" , Input_setpadrepeat , -1 );
2205
+ rb_define_singleton_method( mInput, "keys" , Input_getKeys , 0 );
2206
+ rb_define_singleton_method( mInput, "pads" , Input_getPads , -1 );
2207
+ rb_define_singleton_method( mInput, "pad_num" , Input_getPadNum , 0 );
2208
+ rb_define_singleton_method( mInput, "requested_close?", Input_requested_close, 0 );
2209
+
2210
+ rb_define_singleton_method( mInput, "pad_axis" , Input_getPadAxis , -1 );
2211
+ rb_define_singleton_method( mInput, "pad_lstick" , Input_getPadLStick , -1 );
2212
+ rb_define_singleton_method( mInput, "pad_rstick" , Input_getPadRStick , -1 );
2213
+ rb_define_singleton_method( mInput, "pad_pov" , Input_getPadPov , -1 );
2214
+ // rb_define_singleton_method( mInput, "start" , Input_ff_start , 0 );
2215
+ // rb_define_singleton_method( mInput, "stop" , Input_ff_stop , 0 );
2216
+
2217
+ /* �E�X�e�B�b�N�Ə\���{�^���̃��\�b�h�lj�*/
2218
+ rb_define_singleton_method( mInput, "pad_lx" , Input_lx , -1 );
2219
+ rb_define_singleton_method( mInput, "pad_ly" , Input_ly , -1 );
2220
+ rb_define_singleton_method( mInput, "pad_rx" , Input_rx , -1 );
2221
+ rb_define_singleton_method( mInput, "pad_ry" , Input_ry , -1 );
2222
+ rb_define_singleton_method( mInput, "pad_pov_x" , Input_dx , -1 );
2223
+ rb_define_singleton_method( mInput, "pad_pov_y" , Input_dy , -1 );
2224
+ rb_define_singleton_method( mInput, "set_cursor" , Input_setCursor , 1 );
2225
+
2226
+
2227
+ /* �L�[�{�[�h�̃X�L�����R�[�h�萔�ݒ� */
2228
+ rb_define_const( mDXRuby, "K_ESCAPE" , INT2FIX(DIK_ESCAPE) );
2229
+ rb_define_const( mDXRuby, "K_1" , INT2FIX(DIK_1) );
2230
+ rb_define_const( mDXRuby, "K_2" , INT2FIX(DIK_2) );
2231
+ rb_define_const( mDXRuby, "K_3" , INT2FIX(DIK_3) );
2232
+ rb_define_const( mDXRuby, "K_4" , INT2FIX(DIK_4) );
2233
+ rb_define_const( mDXRuby, "K_5" , INT2FIX(DIK_5) );
2234
+ rb_define_const( mDXRuby, "K_6" , INT2FIX(DIK_6) );
2235
+ rb_define_const( mDXRuby, "K_7" , INT2FIX(DIK_7) );
2236
+ rb_define_const( mDXRuby, "K_8" , INT2FIX(DIK_8) );
2237
+ rb_define_const( mDXRuby, "K_9" , INT2FIX(DIK_9) );
2238
+ rb_define_const( mDXRuby, "K_0" , INT2FIX(DIK_0) );
2239
+ rb_define_const( mDXRuby, "K_MINUS" , INT2FIX(DIK_MINUS) );
2240
+ rb_define_const( mDXRuby, "K_EQUALS" , INT2FIX(DIK_EQUALS) );
2241
+ rb_define_const( mDXRuby, "K_BACK" , INT2FIX(DIK_BACK) );
2242
+ rb_define_const( mDXRuby, "K_TAB" , INT2FIX(DIK_TAB) );
2243
+ rb_define_const( mDXRuby, "K_Q" , INT2FIX(DIK_Q) );
2244
+ rb_define_const( mDXRuby, "K_W" , INT2FIX(DIK_W) );
2245
+ rb_define_const( mDXRuby, "K_E" , INT2FIX(DIK_E) );
2246
+ rb_define_const( mDXRuby, "K_R" , INT2FIX(DIK_R) );
2247
+ rb_define_const( mDXRuby, "K_T" , INT2FIX(DIK_T) );
2248
+ rb_define_const( mDXRuby, "K_Y" , INT2FIX(DIK_Y) );
2249
+ rb_define_const( mDXRuby, "K_U" , INT2FIX(DIK_U) );
2250
+ rb_define_const( mDXRuby, "K_I" , INT2FIX(DIK_I) );
2251
+ rb_define_const( mDXRuby, "K_O" , INT2FIX(DIK_O) );
2252
+ rb_define_const( mDXRuby, "K_P" , INT2FIX(DIK_P) );
2253
+ rb_define_const( mDXRuby, "K_LBRACKET" , INT2FIX(DIK_LBRACKET) );
2254
+ rb_define_const( mDXRuby, "K_RBRACKET" , INT2FIX(DIK_RBRACKET) );
2255
+ rb_define_const( mDXRuby, "K_RETURN" , INT2FIX(DIK_RETURN) );
2256
+ rb_define_const( mDXRuby, "K_LCONTROL" , INT2FIX(DIK_LCONTROL) );
2257
+ rb_define_const( mDXRuby, "K_A" , INT2FIX(DIK_A) );
2258
+ rb_define_const( mDXRuby, "K_S" , INT2FIX(DIK_S) );
2259
+ rb_define_const( mDXRuby, "K_D" , INT2FIX(DIK_D) );
2260
+ rb_define_const( mDXRuby, "K_F" , INT2FIX(DIK_F) );
2261
+ rb_define_const( mDXRuby, "K_G" , INT2FIX(DIK_G) );
2262
+ rb_define_const( mDXRuby, "K_H" , INT2FIX(DIK_H) );
2263
+ rb_define_const( mDXRuby, "K_J" , INT2FIX(DIK_J) );
2264
+ rb_define_const( mDXRuby, "K_K" , INT2FIX(DIK_K) );
2265
+ rb_define_const( mDXRuby, "K_L" , INT2FIX(DIK_L) );
2266
+ rb_define_const( mDXRuby, "K_SEMICOLON" , INT2FIX(DIK_SEMICOLON) );
2267
+ rb_define_const( mDXRuby, "K_APOSTROPHE" , INT2FIX(DIK_APOSTROPHE) );
2268
+ rb_define_const( mDXRuby, "K_GRAVE" , INT2FIX(DIK_GRAVE) );
2269
+ rb_define_const( mDXRuby, "K_LSHIFT" , INT2FIX(DIK_LSHIFT) );
2270
+ rb_define_const( mDXRuby, "K_BACKSLASH" , INT2FIX(DIK_BACKSLASH) );
2271
+ rb_define_const( mDXRuby, "K_Z" , INT2FIX(DIK_Z) );
2272
+ rb_define_const( mDXRuby, "K_X" , INT2FIX(DIK_X) );
2273
+ rb_define_const( mDXRuby, "K_C" , INT2FIX(DIK_C) );
2274
+ rb_define_const( mDXRuby, "K_V" , INT2FIX(DIK_V) );
2275
+ rb_define_const( mDXRuby, "K_B" , INT2FIX(DIK_B) );
2276
+ rb_define_const( mDXRuby, "K_N" , INT2FIX(DIK_N) );
2277
+ rb_define_const( mDXRuby, "K_M" , INT2FIX(DIK_M) );
2278
+ rb_define_const( mDXRuby, "K_COMMA" , INT2FIX(DIK_COMMA) );
2279
+ rb_define_const( mDXRuby, "K_PERIOD" , INT2FIX(DIK_PERIOD) );
2280
+ rb_define_const( mDXRuby, "K_SLASH" , INT2FIX(DIK_SLASH) );
2281
+ rb_define_const( mDXRuby, "K_RSHIFT" , INT2FIX(DIK_RSHIFT) );
2282
+ rb_define_const( mDXRuby, "K_MULTIPLY" , INT2FIX(DIK_MULTIPLY) );
2283
+ rb_define_const( mDXRuby, "K_LMENU" , INT2FIX(DIK_LMENU) );
2284
+ rb_define_const( mDXRuby, "K_SPACE" , INT2FIX(DIK_SPACE) );
2285
+ rb_define_const( mDXRuby, "K_CAPITAL" , INT2FIX(DIK_CAPITAL) );
2286
+ rb_define_const( mDXRuby, "K_F1" , INT2FIX(DIK_F1) );
2287
+ rb_define_const( mDXRuby, "K_F2" , INT2FIX(DIK_F2) );
2288
+ rb_define_const( mDXRuby, "K_F3" , INT2FIX(DIK_F3) );
2289
+ rb_define_const( mDXRuby, "K_F4" , INT2FIX(DIK_F4) );
2290
+ rb_define_const( mDXRuby, "K_F5" , INT2FIX(DIK_F5) );
2291
+ rb_define_const( mDXRuby, "K_F6" , INT2FIX(DIK_F6) );
2292
+ rb_define_const( mDXRuby, "K_F7" , INT2FIX(DIK_F7) );
2293
+ rb_define_const( mDXRuby, "K_F8" , INT2FIX(DIK_F8) );
2294
+ rb_define_const( mDXRuby, "K_F9" , INT2FIX(DIK_F9) );
2295
+ rb_define_const( mDXRuby, "K_F10" , INT2FIX(DIK_F10) );
2296
+ rb_define_const( mDXRuby, "K_NUMLOCK" , INT2FIX(DIK_NUMLOCK) );
2297
+ rb_define_const( mDXRuby, "K_SCROLL" , INT2FIX(DIK_SCROLL) );
2298
+ rb_define_const( mDXRuby, "K_NUMPAD7" , INT2FIX(DIK_NUMPAD7) );
2299
+ rb_define_const( mDXRuby, "K_NUMPAD8" , INT2FIX(DIK_NUMPAD8) );
2300
+ rb_define_const( mDXRuby, "K_NUMPAD9" , INT2FIX(DIK_NUMPAD9) );
2301
+ rb_define_const( mDXRuby, "K_SUBTRACT" , INT2FIX(DIK_SUBTRACT) );
2302
+ rb_define_const( mDXRuby, "K_NUMPAD4" , INT2FIX(DIK_NUMPAD4) );
2303
+ rb_define_const( mDXRuby, "K_NUMPAD5" , INT2FIX(DIK_NUMPAD5) );
2304
+ rb_define_const( mDXRuby, "K_NUMPAD6" , INT2FIX(DIK_NUMPAD6) );
2305
+ rb_define_const( mDXRuby, "K_ADD" , INT2FIX(DIK_ADD) );
2306
+ rb_define_const( mDXRuby, "K_NUMPAD1" , INT2FIX(DIK_NUMPAD1) );
2307
+ rb_define_const( mDXRuby, "K_NUMPAD2" , INT2FIX(DIK_NUMPAD2) );
2308
+ rb_define_const( mDXRuby, "K_NUMPAD3" , INT2FIX(DIK_NUMPAD3) );
2309
+ rb_define_const( mDXRuby, "K_NUMPAD0" , INT2FIX(DIK_NUMPAD0) );
2310
+ rb_define_const( mDXRuby, "K_DECIMAL" , INT2FIX(DIK_DECIMAL) );
2311
+ rb_define_const( mDXRuby, "K_OEM_102" , INT2FIX(DIK_OEM_102) );
2312
+ rb_define_const( mDXRuby, "K_F11" , INT2FIX(DIK_F11) );
2313
+ rb_define_const( mDXRuby, "K_F12" , INT2FIX(DIK_F12) );
2314
+ rb_define_const( mDXRuby, "K_F13" , INT2FIX(DIK_F13) );
2315
+ rb_define_const( mDXRuby, "K_F14" , INT2FIX(DIK_F14) );
2316
+ rb_define_const( mDXRuby, "K_F15" , INT2FIX(DIK_F15) );
2317
+ rb_define_const( mDXRuby, "K_KANA" , INT2FIX(DIK_KANA) );
2318
+ rb_define_const( mDXRuby, "K_ABNT_C1" , INT2FIX(DIK_ABNT_C1) );
2319
+ rb_define_const( mDXRuby, "K_CONVERT" , INT2FIX(DIK_CONVERT) );
2320
+ rb_define_const( mDXRuby, "K_NOCONVERT" , INT2FIX(DIK_NOCONVERT) );
2321
+ rb_define_const( mDXRuby, "K_YEN" , INT2FIX(DIK_YEN) );
2322
+ rb_define_const( mDXRuby, "K_ABNT_C2" , INT2FIX(DIK_ABNT_C2) );
2323
+ rb_define_const( mDXRuby, "K_NUMPADEQUALS", INT2FIX(DIK_NUMPADEQUALS) );
2324
+ rb_define_const( mDXRuby, "K_PREVTRACK" , INT2FIX(DIK_PREVTRACK) );
2325
+ rb_define_const( mDXRuby, "K_AT" , INT2FIX(DIK_AT) );
2326
+ rb_define_const( mDXRuby, "K_COLON" , INT2FIX(DIK_COLON) );
2327
+ rb_define_const( mDXRuby, "K_UNDERLINE" , INT2FIX(DIK_UNDERLINE) );
2328
+ rb_define_const( mDXRuby, "K_KANJI" , INT2FIX(DIK_KANJI) );
2329
+ rb_define_const( mDXRuby, "K_STOP" , INT2FIX(DIK_STOP) );
2330
+ rb_define_const( mDXRuby, "K_AX" , INT2FIX(DIK_AX) );
2331
+ rb_define_const( mDXRuby, "K_UNLABELED" , INT2FIX(DIK_UNLABELED) );
2332
+ rb_define_const( mDXRuby, "K_NEXTTRACK" , INT2FIX(DIK_NEXTTRACK) );
2333
+ rb_define_const( mDXRuby, "K_NUMPADENTER", INT2FIX(DIK_NUMPADENTER) );
2334
+ rb_define_const( mDXRuby, "K_RCONTROL" , INT2FIX(DIK_RCONTROL) );
2335
+ rb_define_const( mDXRuby, "K_MUTE" , INT2FIX(DIK_MUTE) );
2336
+ rb_define_const( mDXRuby, "K_CALCULATOR" , INT2FIX(DIK_CALCULATOR) );
2337
+ rb_define_const( mDXRuby, "K_PLAYPAUSE" , INT2FIX(DIK_PLAYPAUSE) );
2338
+ rb_define_const( mDXRuby, "K_MEDIASTOP" , INT2FIX(DIK_MEDIASTOP) );
2339
+ rb_define_const( mDXRuby, "K_VOLUMEDOWN" , INT2FIX(DIK_VOLUMEDOWN) );
2340
+ rb_define_const( mDXRuby, "K_VOLUMEUP" , INT2FIX(DIK_VOLUMEUP) );
2341
+ rb_define_const( mDXRuby, "K_WEBHOME" , INT2FIX(DIK_WEBHOME) );
2342
+ rb_define_const( mDXRuby, "K_NUMPADCOMMA", INT2FIX(DIK_NUMPADCOMMA) );
2343
+ rb_define_const( mDXRuby, "K_DIVIDE" , INT2FIX(DIK_DIVIDE) );
2344
+ rb_define_const( mDXRuby, "K_SYSRQ" , INT2FIX(DIK_SYSRQ) );
2345
+ rb_define_const( mDXRuby, "K_RMENU" , INT2FIX(DIK_RMENU) );
2346
+ rb_define_const( mDXRuby, "K_PAUSE" , INT2FIX(DIK_PAUSE) );
2347
+ rb_define_const( mDXRuby, "K_HOME" , INT2FIX(DIK_HOME) );
2348
+ rb_define_const( mDXRuby, "K_UP" , INT2FIX(DIK_UP) );
2349
+ rb_define_const( mDXRuby, "K_PRIOR" , INT2FIX(DIK_PRIOR) );
2350
+ rb_define_const( mDXRuby, "K_LEFT" , INT2FIX(DIK_LEFT) );
2351
+ rb_define_const( mDXRuby, "K_RIGHT" , INT2FIX(DIK_RIGHT) );
2352
+ rb_define_const( mDXRuby, "K_END" , INT2FIX(DIK_END) );
2353
+ rb_define_const( mDXRuby, "K_DOWN" , INT2FIX(DIK_DOWN) );
2354
+ rb_define_const( mDXRuby, "K_NEXT" , INT2FIX(DIK_NEXT) );
2355
+ rb_define_const( mDXRuby, "K_INSERT" , INT2FIX(DIK_INSERT) );
2356
+ rb_define_const( mDXRuby, "K_DELETE" , INT2FIX(DIK_DELETE) );
2357
+ rb_define_const( mDXRuby, "K_LWIN" , INT2FIX(DIK_LWIN) );
2358
+ rb_define_const( mDXRuby, "K_RWIN" , INT2FIX(DIK_RWIN) );
2359
+ rb_define_const( mDXRuby, "K_APPS" , INT2FIX(DIK_APPS) );
2360
+ rb_define_const( mDXRuby, "K_POWER" , INT2FIX(DIK_POWER) );
2361
+ rb_define_const( mDXRuby, "K_SLEEP" , INT2FIX(DIK_SLEEP) );
2362
+ rb_define_const( mDXRuby, "K_WAKE" , INT2FIX(DIK_WAKE) );
2363
+ rb_define_const( mDXRuby, "K_WEBSEARCH" , INT2FIX(DIK_WEBSEARCH) );
2364
+ rb_define_const( mDXRuby, "K_WEBFAVORITES", INT2FIX(DIK_WEBFAVORITES) );
2365
+ rb_define_const( mDXRuby, "K_WEBREFRESH" , INT2FIX(DIK_WEBREFRESH) );
2366
+ rb_define_const( mDXRuby, "K_WEBSTOP" , INT2FIX(DIK_WEBSTOP) );
2367
+ rb_define_const( mDXRuby, "K_WEBFORWARD" , INT2FIX(DIK_WEBFORWARD) );
2368
+ rb_define_const( mDXRuby, "K_WEBBACK" , INT2FIX(DIK_WEBBACK) );
2369
+ rb_define_const( mDXRuby, "K_MYCOMPUTER" , INT2FIX(DIK_MYCOMPUTER) );
2370
+ rb_define_const( mDXRuby, "K_MAIL" , INT2FIX(DIK_MAIL) );
2371
+ rb_define_const( mDXRuby, "K_MEDIASELECT", INT2FIX(DIK_MEDIASELECT) );
2372
+ rb_define_const( mDXRuby, "K_BACKSPACE" , INT2FIX(DIK_BACK) );
2373
+ rb_define_const( mDXRuby, "K_NUMPADSTAR" , INT2FIX(DIK_MULTIPLY) );
2374
+ rb_define_const( mDXRuby, "K_LALT" , INT2FIX(DIK_LMENU) );
2375
+ rb_define_const( mDXRuby, "K_CAPSLOCK" , INT2FIX(DIK_CAPITAL) );
2376
+ rb_define_const( mDXRuby, "K_NUMPADMINUS", INT2FIX(DIK_SUBTRACT) );
2377
+ rb_define_const( mDXRuby, "K_NUMPADPLUS" , INT2FIX(DIK_ADD) );
2378
+ rb_define_const( mDXRuby, "K_NUMPADPERIOD", INT2FIX(DIK_DECIMAL) );
2379
+ rb_define_const( mDXRuby, "K_NUMPADSLASH", INT2FIX(DIK_DIVIDE) );
2380
+ rb_define_const( mDXRuby, "K_RALT" , INT2FIX(DIK_RMENU) );
2381
+ rb_define_const( mDXRuby, "K_UPARROW" , INT2FIX(DIK_UP) );
2382
+ rb_define_const( mDXRuby, "K_PGUP" , INT2FIX(DIK_PRIOR) );
2383
+ rb_define_const( mDXRuby, "K_LEFTARROW" , INT2FIX(DIK_LEFT) );
2384
+ rb_define_const( mDXRuby, "K_RIGHTARROW" , INT2FIX(DIK_RIGHT) );
2385
+ rb_define_const( mDXRuby, "K_DOWNARROW" , INT2FIX(DIK_DOWN) );
2386
+ rb_define_const( mDXRuby, "K_PGDN" , INT2FIX(DIK_NEXT) );
2387
+ rb_define_const( mDXRuby, "K_CIRCUMFLEX" , INT2FIX(DIK_CIRCUMFLEX) );
2388
+
2389
+ rb_define_const( mDXRuby, "P_UP" , INT2FIX(P_UP) );
2390
+ rb_define_const( mDXRuby, "P_LEFT" , INT2FIX(P_LEFT) );
2391
+ rb_define_const( mDXRuby, "P_RIGHT" , INT2FIX(P_RIGHT) );
2392
+ rb_define_const( mDXRuby, "P_DOWN" , INT2FIX(P_DOWN) );
2393
+ rb_define_const( mDXRuby, "P_BUTTON0" , INT2FIX(P_BUTTON0) );
2394
+ rb_define_const( mDXRuby, "P_BUTTON1" , INT2FIX(P_BUTTON1) );
2395
+ rb_define_const( mDXRuby, "P_BUTTON2" , INT2FIX(P_BUTTON2) );
2396
+ rb_define_const( mDXRuby, "P_BUTTON3" , INT2FIX(P_BUTTON3) );
2397
+ rb_define_const( mDXRuby, "P_BUTTON4" , INT2FIX(P_BUTTON4) );
2398
+ rb_define_const( mDXRuby, "P_BUTTON5" , INT2FIX(P_BUTTON5) );
2399
+ rb_define_const( mDXRuby, "P_BUTTON6" , INT2FIX(P_BUTTON6) );
2400
+ rb_define_const( mDXRuby, "P_BUTTON7" , INT2FIX(P_BUTTON7) );
2401
+ rb_define_const( mDXRuby, "P_BUTTON8" , INT2FIX(P_BUTTON8) );
2402
+ rb_define_const( mDXRuby, "P_BUTTON9" , INT2FIX(P_BUTTON9) );
2403
+ rb_define_const( mDXRuby, "P_BUTTON10" , INT2FIX(P_BUTTON10) );
2404
+ rb_define_const( mDXRuby, "P_BUTTON11" , INT2FIX(P_BUTTON11) );
2405
+ rb_define_const( mDXRuby, "P_BUTTON12" , INT2FIX(P_BUTTON12) );
2406
+ rb_define_const( mDXRuby, "P_BUTTON13" , INT2FIX(P_BUTTON13) );
2407
+ rb_define_const( mDXRuby, "P_BUTTON14" , INT2FIX(P_BUTTON14) );
2408
+ rb_define_const( mDXRuby, "P_BUTTON15" , INT2FIX(P_BUTTON15) );
2409
+
2410
+ rb_define_const( mDXRuby, "P_D_UP" , INT2FIX(P_D_UP) );
2411
+ rb_define_const( mDXRuby, "P_D_LEFT" , INT2FIX(P_D_LEFT) );
2412
+ rb_define_const( mDXRuby, "P_D_RIGHT" , INT2FIX(P_D_RIGHT));
2413
+ rb_define_const( mDXRuby, "P_D_DOWN" , INT2FIX(P_D_DOWN) );
2414
+ rb_define_const( mDXRuby, "P_L_UP" , INT2FIX(P_L_UP) );
2415
+ rb_define_const( mDXRuby, "P_L_LEFT" , INT2FIX(P_L_LEFT) );
2416
+ rb_define_const( mDXRuby, "P_L_RIGHT" , INT2FIX(P_L_RIGHT));
2417
+ rb_define_const( mDXRuby, "P_L_DOWN" , INT2FIX(P_L_DOWN) );
2418
+ rb_define_const( mDXRuby, "P_R_UP" , INT2FIX(P_R_UP) );
2419
+ rb_define_const( mDXRuby, "P_R_LEFT" , INT2FIX(P_R_LEFT) );
2420
+ rb_define_const( mDXRuby, "P_R_RIGHT" , INT2FIX(P_R_RIGHT));
2421
+ rb_define_const( mDXRuby, "P_R_DOWN" , INT2FIX(P_R_DOWN) );
2422
+
2423
+ rb_define_const( mDXRuby, "M_LBUTTON" , INT2FIX(M_LBUTTON) );
2424
+ rb_define_const( mDXRuby, "M_RBUTTON" , INT2FIX(M_RBUTTON) );
2425
+ rb_define_const( mDXRuby, "M_MBUTTON" , INT2FIX(M_MBUTTON) );
2426
+
2427
+ /* ���蓖�ď����� */
2428
+ for( i = 0; i < 256; i++)
2429
+ {
2430
+ g_diKeyConfig[i] = -1;
2431
+ g_diKeyCount[i] = 0; /* �J�E���g������ */
2432
+ }
2433
+ for( i = 0; i < PADMAX; i++)
2434
+ {
2435
+ for( j = 0; j < PADBUTTON_MAX; j++)
2436
+ {
2437
+ g_PadState[i].PadConfig[j] = -1;
2438
+ g_PadState[i].count[j] = 0; /* �J�E���g������ */
2439
+ }
2440
+ }
2441
+
2442
+ /* �f�t�H���g�̊��蓖�� */
2443
+ Input_SetConfig( 0, P_LEFT , DIK_LEFT );
2444
+ Input_SetConfig( 0, P_RIGHT , DIK_RIGHT );
2445
+ Input_SetConfig( 0, P_UP , DIK_UP );
2446
+ Input_SetConfig( 0, P_DOWN , DIK_DOWN );
2447
+ Input_SetConfig( 0, P_BUTTON0, DIK_Z );
2448
+ Input_SetConfig( 0, P_BUTTON1, DIK_X );
2449
+ Input_SetConfig( 0, P_BUTTON2, DIK_C );
2450
+
2451
+ // Input_SetConfig( 0, P_D_LEFT , DIK_DELETE );
2452
+ // Input_SetConfig( 0, P_D_RIGHT , DIK_NEXT );
2453
+ // Input_SetConfig( 0, P_D_UP , DIK_HOME );
2454
+ // Input_SetConfig( 0, P_D_DOWN , DIK_END );
2455
+
2456
+ // Input_SetConfig( 0, P_R_LEFT , DIK_NUMPAD4 );
2457
+ // Input_SetConfig( 0, P_R_RIGHT , DIK_NUMPAD6 );
2458
+ // Input_SetConfig( 0, P_R_UP , DIK_NUMPAD8 );
2459
+ // Input_SetConfig( 0, P_R_DOWN , DIK_NUMPAD2 );
2460
+
2461
+ rb_define_const( mDXRuby, "IDC_ARROW" , INT2FIX(32512) );
2462
+ rb_define_const( mDXRuby, "IDC_IBEAM" , INT2FIX(32513) );
2463
+ rb_define_const( mDXRuby, "IDC_WAIT" , INT2FIX(32514) );
2464
+ rb_define_const( mDXRuby, "IDC_CROSS" , INT2FIX(32515) );
2465
+ rb_define_const( mDXRuby, "IDC_UPARROW" , INT2FIX(32516) );
2466
+ rb_define_const( mDXRuby, "IDC_SIZE" , INT2FIX(32640) );
2467
+ rb_define_const( mDXRuby, "IDC_ICON" , INT2FIX(32641) );
2468
+ rb_define_const( mDXRuby, "IDC_SIZENWSE" , INT2FIX(32642) );
2469
+ rb_define_const( mDXRuby, "IDC_SIZENESW" , INT2FIX(32643) );
2470
+ rb_define_const( mDXRuby, "IDC_SIZEWE" , INT2FIX(32644) );
2471
+ rb_define_const( mDXRuby, "IDC_SIZENS" , INT2FIX(32645) );
2472
+ rb_define_const( mDXRuby, "IDC_SIZEALL" , INT2FIX(32646) );
2473
+ rb_define_const( mDXRuby, "IDC_NO" , INT2FIX(32648) );
2474
+ rb_define_const( mDXRuby, "IDC_HAND" , INT2FIX(32649) );
2475
+ rb_define_const( mDXRuby, "IDC_APPSTARTING", INT2FIX(32650) );
2476
+ rb_define_const( mDXRuby, "IDC_HELP" , INT2FIX(32651) );
2477
+
2478
+ #ifdef DXRUBY15
2479
+ /* Input::IME���W���[���o�^ */
2480
+ mIME = rb_define_module_under( mInput, "IME" );
2481
+
2482
+ /* Input::IME���W���[���Ƀ��\�b�h�o�^ */
2483
+ rb_define_singleton_method( mIME, "get_string" , Input_IME_getstring , 0 );
2484
+ rb_define_singleton_method( mIME, "getString" , Input_IME_getstring , 0 );
2485
+ rb_define_singleton_method( mIME, "enabled?" , Input_IME_getenable , 0 );
2486
+ rb_define_singleton_method( mIME, "enable=" , Input_IME_setenable , 1 );
2487
+ rb_define_singleton_method( mIME, "compositing?" , Input_IME_getcompositing , 0 );
2488
+ rb_define_singleton_method( mIME, "push_keys", Input_IME_getpushkeys , 0 );
2489
+ rb_define_singleton_method( mIME, "pushKeys" , Input_IME_getpushkeys , 0 );
2490
+ rb_define_singleton_method( mIME, "release_keys", Input_IME_getreleasekeys , 0 );
2491
+ rb_define_singleton_method( mIME, "releaseKeys" , Input_IME_getreleasekeys , 0 );
2492
+ rb_define_singleton_method( mIME, "get_comp_info" , Input_IME_getcompositioninfo , 0 );
2493
+ rb_define_singleton_method( mIME, "getCompInfo" , Input_IME_getcompositioninfo , 0 );
2494
+
2495
+ rb_define_const( mIME, "ATTR_INPUT" , INT2FIX(ATTR_INPUT) );
2496
+ rb_define_const( mIME, "ATTR_TARGET_CONVERTED" , INT2FIX(ATTR_TARGET_CONVERTED) );
2497
+ rb_define_const( mIME, "ATTR_CONVERTED" , INT2FIX(ATTR_CONVERTED) );
2498
+ rb_define_const( mIME, "ATTR_TARGET_NOTCONVERTED" , INT2FIX(ATTR_TARGET_NOTCONVERTED) );
2499
+ rb_define_const( mIME, "ATTR_INPUT_ERROR" , INT2FIX(ATTR_INPUT_ERROR) );
2500
+
2501
+ cCompInfo = rb_struct_define( NULL, "comp_str", "comp_attr", "cursor_pos", "can_list", "selection", "selection_total", "page_size", "total", 0 );
2502
+ rb_define_const( mIME, "CompInfo", cCompInfo );
2503
+
2504
+ {
2505
+ VALUE ary[8];
2506
+ ary[0] = rb_str_new2( "" );
2507
+ ary[1] = rb_ary_new();
2508
+ ary[2] = INT2FIX( 0 );
2509
+ ary[3] = rb_ary_new();
2510
+ ary[4] = Qnil;
2511
+ ary[5] = Qnil;
2512
+ ary[6] = Qnil;
2513
+ ary[7] = Qnil;
2514
+ g_vCompInfoArray = rb_ary_new4( 8, ary );
2515
+ }
2516
+ rb_global_variable( &g_vCompInfoArray );
2517
+ #endif
2518
+
2519
+ SetImeEnable( FALSE );
2520
+ }
2521
+
2522
+