diff --git a/input/drivers_joypad/wiiu_joypad.c b/input/drivers_joypad/wiiu_joypad.c index 62e2317d2c..9414615f34 100644 --- a/input/drivers_joypad/wiiu_joypad.c +++ b/input/drivers_joypad/wiiu_joypad.c @@ -93,7 +93,7 @@ static const char* wiiu_joypad_name(unsigned pad) 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); + sprintf(hidName[hid_index],"HID %04X/%04X(%02X)",hid_data[hid_index].device_info.vidpid.vid,hid_data[hid_index].device_info.vidpid.pid,hid_data[hid_index].pad); return hidName[hid_index]; } diff --git a/wiiu/controller_patcher/ControllerPatcher.cpp b/wiiu/controller_patcher/ControllerPatcher.cpp index 7f5fb341ab..67c9833729 100644 --- a/wiiu/controller_patcher/ControllerPatcher.cpp +++ b/wiiu/controller_patcher/ControllerPatcher.cpp @@ -773,16 +773,18 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::gettingInputAllDevices(Inp for(s32 i = 0;i < gHIDMaxDevices;i++){ u8 * status = &output[result].status; *status = 0; - if(connectionOrderHelper[i] != NULL){ + if(connectionOrderHelper[i].usr != NULL){ *status = 1; - my_cb_user * usr = connectionOrderHelper[i]; + my_cb_user * usr = connectionOrderHelper[i].usr; pad_count[usr] = pad_count[usr] +1; s32 hid = usr->slotdata.hidmask; - //printf("result[%d] usr: %08X\n",result,usr); - s32 realpad = pad_count[usr] - 1; + s32 realpad = connectionOrderHelper[i].pad_slot; + //printf("result[%d] usr: %08X hid: %08X realpad: %08X\n",result,usr,hid,realpad); + + output[result].pad = realpad; output[result].device_info.pad_count = usr->pads_per_device; output[result].device_info.slotdata = usr->slotdata; output[result].device_info.vidpid = usr->vidpid; diff --git a/wiiu/controller_patcher/patcher/ControllerPatcherDefs.h b/wiiu/controller_patcher/patcher/ControllerPatcherDefs.h index f005e39173..0dcc7954d0 100644 --- a/wiiu/controller_patcher/patcher/ControllerPatcherDefs.h +++ b/wiiu/controller_patcher/patcher/ControllerPatcherDefs.h @@ -246,6 +246,12 @@ typedef struct _my_cb_user{ DeviceVIDPIDInfo vidpid; /**< The VID/PID of the device */ }my_cb_user; + +typedef struct _ConnectionHelper{ + my_cb_user* usr; + u8 pad_slot; +}ConnectionHelper; + /** * @brief Stores data for the mouse */ @@ -366,6 +372,7 @@ typedef struct _InputStickData{ typedef struct _InputData{ DeviceInfo device_info; /**< Infos about the device where the data is coming from */ u8 status; + u8 pad; InputButtonData button_data; InputStickData stick_data; }InputData; diff --git a/wiiu/controller_patcher/patcher/ControllerPatcherHID.cpp b/wiiu/controller_patcher/patcher/ControllerPatcherHID.cpp index 7bafcd0176..21664262a1 100644 --- a/wiiu/controller_patcher/patcher/ControllerPatcherHID.cpp +++ b/wiiu/controller_patcher/patcher/ControllerPatcherHID.cpp @@ -223,12 +223,15 @@ s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p for(s32 j = 0;j < pads_per_device; j++){ for(s32 i = 0;i < gHIDMaxDevices; i++){ - if(connectionOrderHelper[i] == NULL){ - connectionOrderHelper[i] = usr; + if(connectionOrderHelper[i].usr == NULL){ + connectionOrderHelper[i].usr = usr; + connectionOrderHelper[i].pad_slot = pad_slot+j; break; } } } + DCFlushRange(connectionOrderHelper,sizeof(connectionOrderHelper)); + DCInvalidateRange(connectionOrderHelper,sizeof(connectionOrderHelper)); if(HID_DEBUG){ printf("ControllerPatcherHID::AttachDetachCallback(line %d): Device successfully attached\n",__LINE__); } @@ -311,12 +314,15 @@ s32 ControllerPatcherHID::AttachDetachCallback(HIDClient *p_client, HIDDevice *p if(user_data){ for(s32 j = 0;j < user_data->pads_per_device; j++){ for(s32 i = 0;i < gHIDMaxDevices; i++){ - if(connectionOrderHelper[i] == user_data){ - connectionOrderHelper[i] = NULL; + if(connectionOrderHelper[i].usr == user_data){ + connectionOrderHelper[i].usr = NULL; + connectionOrderHelper[i].pad_slot = 0; break; } } } + DCFlushRange(connectionOrderHelper,sizeof(connectionOrderHelper)); + DCInvalidateRange(connectionOrderHelper,sizeof(connectionOrderHelper)); config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1] &= ~ (1 << user_data->pad_slot); DCFlushRange(&config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1],sizeof(config_controller[slotdata->deviceslot][CONTRPS_CONNECTED_PADS][1])); diff --git a/wiiu/controller_patcher/utils/CPRetainVars.cpp b/wiiu/controller_patcher/utils/CPRetainVars.cpp index 164275381b..b4c253fe43 100644 --- a/wiiu/controller_patcher/utils/CPRetainVars.cpp +++ b/wiiu/controller_patcher/utils/CPRetainVars.cpp @@ -64,7 +64,7 @@ u8 gCallbackCooldown __attribute__((section(".data"))) = 0; u8 gGlobalRumbleActivated __attribute__((section(".data"))) = 0; -my_cb_user * connectionOrderHelper[gHIDMaxDevices] __attribute__((section(".data"))); +ConnectionHelper connectionOrderHelper[gHIDMaxDevices] __attribute__((section(".data"))); u32 gUDPClientip __attribute__((section(".data"))) = 0; ControllerMappingPADInfo* gProPadInfo[4] __attribute__((section(".data"))) = {&gControllerMapping.proController[0].pad_infos[0], diff --git a/wiiu/controller_patcher/utils/CPRetainVars.hpp b/wiiu/controller_patcher/utils/CPRetainVars.hpp index 696212af68..87ab0d7af4 100644 --- a/wiiu/controller_patcher/utils/CPRetainVars.hpp +++ b/wiiu/controller_patcher/utils/CPRetainVars.hpp @@ -68,7 +68,7 @@ extern wpad_sampling_callback_t gSamplingCallback; extern u8 gCallbackCooldown; extern u8 gGlobalRumbleActivated; -extern my_cb_user * connectionOrderHelper[gHIDMaxDevices]; +extern ConnectionHelper connectionOrderHelper[gHIDMaxDevices]; extern u32 gUDPClientip; extern ControllerMappingPADInfo* gProPadInfo[4];