[ Last updated : 2009-01-05 ]
OpenGL での 3D CG の操作をスムーズにするために USB ゲームパッドを導入し た際の覚え書きです。
/* 10 button Joystick */#define GLUT_JOYSTICK_BUTTON_E 0x10 /* 5 */#define GLUT_JOYSTICK_BUTTON_F 0x20 /* 6 */#define GLUT_JOYSTICK_BUTTON_G 0x40 /* 7 */#define GLUT_JOYSTICK_BUTTON_H 0x80 /* 8 */#define GLUT_JOYSTICK_BUTTON_I 0x100 /* 9 */#define GLUT_JOYSTICK_BUTTON_J 0x200 /* 10 *//* 10 button Joystick */main(){ ... glutMouseFunc(mouse); glutJoystickFunc(joystick,100); glutMainLoop(); ...{void glutJoystickFunc(void (*func)(unsigned int buttonMask, int x, int y, int z), int pollInterval);void joystick(unsigned int buttonMask, int x, int y, int z){ if (x) { /* 左スティックを左右に倒した際の処理 */ } if (y) { /* 左スティックを上下に倒した際の処理 */ } if (z) { /* 右スティックを左右に倒した際の処理 */ } switch (buttonMask) { case GLUT_JOYSTICK_BUTTON_A: /* ボタン 1 を押した際の処理 */ break; ... }}