diff --git a/input/drivers_joypad/ctr_joypad.c b/input/drivers_joypad/ctr_joypad.c index 9ec4bfc637..59faf35fc0 100644 --- a/input/drivers_joypad/ctr_joypad.c +++ b/input/drivers_joypad/ctr_joypad.c @@ -44,13 +44,13 @@ static const char *ctr_joypad_name(unsigned pad) static void ctr_joypad_autodetect_add(unsigned autoconf_pad) { if (!input_autoconfigure_connect( - ctr_joypad_name(autoconf_pad), - NULL, - ctr_joypad.ident, - autoconf_pad, - 0, - 0 - )) + ctr_joypad_name(autoconf_pad), + NULL, + ctr_joypad.ident, + autoconf_pad, + 0, + 0 + )) input_config_set_device_name(autoconf_pad, ctr_joypad_name(autoconf_pad)); } @@ -168,9 +168,9 @@ static void ctr_joypad_poll(void) /* panic button */ if((state_tmp & KEY_START) && - (state_tmp & KEY_SELECT) && - (state_tmp & KEY_L) && - (state_tmp & KEY_R)) + (state_tmp & KEY_SELECT) && + (state_tmp & KEY_L) && + (state_tmp & KEY_R)) command_event(CMD_EVENT_QUIT, NULL); } diff --git a/input/drivers_joypad/wiiu_joypad.c b/input/drivers_joypad/wiiu_joypad.c index 34483832c2..4b59c909eb 100644 --- a/input/drivers_joypad/wiiu_joypad.c +++ b/input/drivers_joypad/wiiu_joypad.c @@ -50,13 +50,14 @@ #define KPAD_OFFSET (GAMEPAD_OFFSET + GAMEPAD_COUNT) #define HID_OFFSET (KPAD_OFFSET + KPAD_COUNT) -static uint64_t pad_state[MAX_PADS]; -static u8 pad_type[KPAD_COUNT] = {WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE}; +extern uint64_t lifecycle_state; -static u8 hid_status[HID_COUNT]; +static uint64_t pad_state[MAX_PADS]; +static uint8_t pad_type[KPAD_COUNT] = {WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE}; + +static uint8_t hid_status[HID_COUNT]; static InputData hid_data[HID_COUNT]; static int16_t analog_state[MAX_PADS][2][2]; -extern uint64_t lifecycle_state; static bool wiiu_pad_inited = false; static char hidName[HID_COUNT][255]; @@ -71,27 +72,28 @@ static const char* wiiu_joypad_name(unsigned pad) int i = pad - KPAD_OFFSET; switch (pad_type[i]) { - case WIIUINPUT_TYPE_NONE: - return "N/A"; + case WIIUINPUT_TYPE_NONE: + return "N/A"; - case WIIUINPUT_TYPE_PRO_CONTROLLER: - return "WIIU Pro Controller"; + case WIIUINPUT_TYPE_PRO_CONTROLLER: + return "WIIU Pro Controller"; - case WIIUINPUT_TYPE_WIIMOTE: - return "Wiimote Controller"; + case WIIUINPUT_TYPE_WIIMOTE: + return "Wiimote Controller"; - case WIIUINPUT_TYPE_NUNCHUK: - return "Nunchuk Controller"; + case WIIUINPUT_TYPE_NUNCHUK: + return "Nunchuk Controller"; - case WIIUINPUT_TYPE_CLASSIC_CONTROLLER: - return "Classic Controller"; + case WIIUINPUT_TYPE_CLASSIC_CONTROLLER: + return "Classic Controller"; } } - if(pad < MAX_PADS){ - s32 hid_index = pad-HID_OFFSET; - sprintf(hidName[hid_index],"HID %04X/%04X",hid_data[hid_index].device_info.vidpid.vid,hid_data[hid_index].device_info.vidpid.pid); - return hidName[hid_index]; + if (pad < MAX_PADS) + { + s32 hid_index = pad-HID_OFFSET; + sprintf(hidName[hid_index],"HID %04X/%04X",hid_data[hid_index].device_info.vidpid.vid,hid_data[hid_index].device_info.vidpid.pid); + return hidName[hid_index]; } return "unknown"; @@ -106,8 +108,8 @@ static void wiiu_joypad_autodetect_add(unsigned autoconf_pad) autoconf_pad, 0, 0 - )) - input_config_set_device_name(autoconf_pad, wiiu_joypad_name(autoconf_pad)); + )) + input_config_set_device_name(autoconf_pad, wiiu_joypad_name(autoconf_pad)); } static bool wiiu_joypad_button(unsigned port_num, uint16_t key) @@ -146,21 +148,21 @@ static int16_t wiiu_joypad_axis(unsigned port_num, uint32_t joyaxis) switch (axis) { - case 0: - val = analog_state[port_num][0][0]; - break; + case 0: + val = analog_state[port_num][0][0]; + break; - case 1: - val = analog_state[port_num][0][1]; - break; + case 1: + val = analog_state[port_num][0][1]; + break; - case 2: - val = analog_state[port_num][1][0]; - break; + case 2: + val = analog_state[port_num][1][0]; + break; - case 3: - val = analog_state[port_num][1][1]; - break; + case 3: + val = analog_state[port_num][1][1]; + break; } if (is_neg && val > 0) @@ -173,10 +175,12 @@ static int16_t wiiu_joypad_axis(unsigned port_num, uint32_t joyaxis) static void wiiu_joypad_poll(void) { - int c; + int i, c, result; VPADStatus vpad; VPADReadError vpadError; + VPADRead(0, &vpad, 1, &vpadError); + if (!vpadError) { pad_state[0] = vpad.hold & ~0x7F800000; /* clear out emulated analog sticks */ @@ -246,30 +250,33 @@ static void wiiu_joypad_poll(void) } memset(hid_data,0,sizeof(hid_data)); - int result = gettingInputAllDevices(hid_data,HID_COUNT); + result = gettingInputAllDevices(hid_data,HID_COUNT); - if(result+HID_OFFSET > MAX_PADS){ + if (result + HID_OFFSET > MAX_PADS) result = MAX_PADS - HID_OFFSET; - } - for(int i = HID_OFFSET;i