void Joystick_Init(void) { #ifndef PSP int i, nr_joys, nr_axes, nr_btns, nr_hats; #endif joy[0] = 1; // active only one joy[1] = 0; JoyKeyState = 0; JoyKeyState0 = 0; JoyKeyState1 = 0; JoyState0[0] = 0xff; JoyState0[1] = 0xff; JoyState1[0] = 0xff; JoyState1[1] = 0xff; JoyPortData[0] = 0; JoyPortData[1] = 0; #if defined(ANDROID) || TARGET_OS_IPHONE Joystick_Vbtn_Update(WinUI_get_vkscale()); #endif #ifndef PSP sdl_joy = 0; SDL_InitSubSystem(SDL_INIT_JOYSTICK); nr_joys = SDL_NumJoysticks(); p6logd("joy num %d\n", nr_joys); for (i = 0; i < nr_joys; i++) { sdl_joy = SDL_JoystickOpen(i); if (sdl_joy) { nr_btns = SDL_JoystickNumButtons(sdl_joy); nr_axes = SDL_JoystickNumAxes(sdl_joy); nr_hats = SDL_JoystickNumHats(sdl_joy); #if SDL_VERSION_ATLEAST(2, 0, 0) p6logd("Name: %s\n", SDL_JoystickNameForIndex(i)); #endif p6logd("# of Axes: %d\n", nr_axes); p6logd("# of Btns: %d\n", nr_btns); p6logd("# of Hats: %d\n", nr_hats); // skip accelerometer and keyboard if (nr_btns < 2 || (nr_axes < 2 && nr_hats == 0)) { Joystick_Cleanup(); sdl_joy = 0; } else { break; } } else { p6logd("can't open joy %d\n", i); } } #endif }
void Joystick_Init(void) { joy[0] = 1; // とりあえず一つ目だけ有効 joy[1] = 0; JoyKeyState = 0; JoyKeyState0 = 0; JoyKeyState1 = 0; JoyState0[0] = 0xff; JoyState0[1] = 0xff; JoyState1[0] = 0xff; JoyState1[1] = 0xff; JoyPortData[0] = 0; JoyPortData[1] = 0; #ifdef ANDROID Joystick_Vbtn_Update(WinUI_get_vkscale()); #endif }