From 41012b4543bc798e47e15c8b5e1b7cd12fec1977 Mon Sep 17 00:00:00 2001 From: Maschell Date: Mon, 10 Apr 2017 17:15:26 +0200 Subject: [PATCH] Again fixing the controller configuration with many config files. - fix pre-defined values for xinput and ds4 - changed datatypes in order to fix "no controller config"-found issues with many config files --- ControllerPatcher.cpp | 6 ++---- config/ConfigValues.hpp | 4 ++-- network/UDPServer.cpp | 4 +--- patcher/ControllerPatcherDefs.h | 2 +- patcher/ControllerPatcherHID.cpp | 6 +++--- patcher/ControllerPatcherHID.hpp | 2 +- patcher/ControllerPatcherUtils.cpp | 10 +++++----- patcher/ControllerPatcherUtils.hpp | 6 +++--- utils/CPRetainVars.cpp | 14 +++++++------- utils/CPRetainVars.hpp | 14 +++++++------- 10 files changed, 32 insertions(+), 36 deletions(-) diff --git a/ControllerPatcher.cpp b/ControllerPatcher.cpp index 648d3a2..e68bbf3 100644 --- a/ControllerPatcher.cpp +++ b/ControllerPatcher.cpp @@ -138,7 +138,6 @@ void ControllerPatcher::ResetConfig(){ config_controller_hidmask[ds4_slot] = ds4_hid; config_controller_hidmask[xinput_slot] = xinput_hid; - /* We need to give the GamePad, Mouse and Keyboard a unique VID/PID to find the right slots.*/ //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! GamePad @@ -355,7 +354,6 @@ void ControllerPatcher::ResetConfig(){ //!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //! XInput //!--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ControllerPatcherUtils::setConfigValue((u8*)&config_controller[xinput_slot][CONTRPS_VID], (HID_XINPUT_VID>>8)&0xFF, HID_XINPUT_VID&0xFF); ControllerPatcherUtils::setConfigValue((u8*)&config_controller[xinput_slot][CONTRPS_PID], (HID_XINPUT_PID>>8)&0xFF, HID_XINPUT_PID&0xFF); ControllerPatcherUtils::setConfigValue((u8*)&config_controller[xinput_slot][CONTRPS_BUF_SIZE], CONTROLLER_PATCHER_VALUE_SET, 128); @@ -616,8 +614,8 @@ bool ControllerPatcher::isControllerConnectedAndActive(UController_Type type,s32 return false; } - s32 hidmask = device_info.slotdata.hidmask; - s32 pad = padinfo->pad; + u32 hidmask = device_info.slotdata.hidmask; + u32 pad = padinfo->pad; HID_Data * data_cur; diff --git a/config/ConfigValues.hpp b/config/ConfigValues.hpp index a049ded..9dc36ed 100644 --- a/config/ConfigValues.hpp +++ b/config/ConfigValues.hpp @@ -483,12 +483,12 @@ private: presetSticks["XINPUT_STICK_L_X"] = HID_XINPUT_STICK_L_X; presetSticks["XINPUT_STICK_L_Y"] = HID_XINPUT_STICK_L_Y; - presetSticks["XINPUT_STICK_R_X"] = HID_XINPUT_STICK_L_X; + presetSticks["XINPUT_STICK_R_X"] = HID_XINPUT_STICK_R_X; presetSticks["XINPUT_STICK_R_Y"] = HID_XINPUT_STICK_R_Y; presetSticks["GC_DPAD_MODE"] = HID_GC_BUTTON_DPAD_TYPE; presetSticks["DS3_DPAD_MODE"] = HID_DS3_BUTTON_DPAD_TYPE; - presetSticks["DS4_DPAD_MODE"] = HID_XINPUT_BUTTON_DPAD_TYPE; + presetSticks["DS4_DPAD_MODE"] = HID_DS4_BUTTON_DPAD_TYPE; presetSticks["XINPUT_DPAD_MODE"] = HID_XINPUT_BUTTON_DPAD_TYPE; gGamePadValuesToCONTRPSString["VPAD_BUTTON_A"] = CONTRPS_VPAD_BUTTON_A; diff --git a/network/UDPServer.cpp b/network/UDPServer.cpp index 4e56fc5..a60c00d 100644 --- a/network/UDPServer.cpp +++ b/network/UDPServer.cpp @@ -110,10 +110,9 @@ void UDPServer::DoUDPThreadInternal(){ memcpy((void *)&count_commands,buffer+bufferoffset,sizeof(count_commands)); bufferoffset += sizeof(count_commands); for(s32 i = 0;i ControllerPatcherHID::getHIDDataAll(){ - s32 hid = gHIDCurrentDevice; + u32 hid = gHIDCurrentDevice; std::vector data_list; for(s32 i = 0;i < gHIDMaxDevices;i++){ if((hid & (1 << i)) != 0){ - s32 cur_hidmask = config_controller_hidmask[i]; + u32 cur_hidmask = config_controller_hidmask[i]; for(s32 pad = 0; pad < HID_MAX_PADS_COUNT; pad++){ s32 res; HID_Data * new_data = NULL; @@ -461,7 +461,7 @@ std::vector ControllerPatcherHID::getHIDDataAll(){ /* The slotdata in the HID_Data pointer is empty. We need to provide the hidmask via the parameter */ -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherHID::getHIDData(s32 hidmask, s32 pad, HID_Data ** data){ +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherHID::getHIDData(u32 hidmask, s32 pad, HID_Data ** data){ if(data == NULL) return CONTROLLER_PATCHER_ERROR_INVALID_BUFFER; if(!(hidmask & gHIDCurrentDevice)) return CONTROLLER_PATCHER_ERROR_HID_NOT_CONNECTED; if(pad < 0 && pad > 3) return CONTROLLER_PATCHER_ERROR_INVALID_CHAN; diff --git a/patcher/ControllerPatcherHID.hpp b/patcher/ControllerPatcherHID.hpp index c4ace47..b6102f7 100644 --- a/patcher/ControllerPatcherHID.hpp +++ b/patcher/ControllerPatcherHID.hpp @@ -47,7 +47,7 @@ class ControllerPatcherHID{ private: static CONTROLLER_PATCHER_RESULT_OR_ERROR setVPADControllerData(VPADData * buffer,std::vector& data); static std::vector getHIDDataAll(); - static CONTROLLER_PATCHER_RESULT_OR_ERROR getHIDData(s32 hidmask, s32 pad, HID_Data ** data); + static CONTROLLER_PATCHER_RESULT_OR_ERROR getHIDData(u32 hidmask, s32 pad, HID_Data ** data); /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * Rumble diff --git a/patcher/ControllerPatcherUtils.cpp b/patcher/ControllerPatcherUtils.cpp index 69cecab..e19f2d7 100644 --- a/patcher/ControllerPatcherUtils.cpp +++ b/patcher/ControllerPatcherUtils.cpp @@ -228,7 +228,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::isValueSet(HID_Data * u8 * cur_data = &data->data_union.controller.cur_hid_data[0]; if(cur_data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; - s32 hidmask = data->slotdata.hidmask; + u32 hidmask = data->slotdata.hidmask; s32 deviceslot = data->slotdata.deviceslot; s32 result = CONTROLLER_PATCHER_ERROR_NONE; @@ -292,7 +292,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setButtonData(VPADDat * Pad Status functions *---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::checkActivePad(s32 hidmask,s32 pad){ +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::checkActivePad(u32 hidmask,s32 pad){ if(hidmask & gHID_LIST_GC && pad >= 0 && pad <= 3){ if (!(((gHID_Devices[gHID_SLOT_GC].pad_data[pad].data_union.controller.cur_hid_data[0] & 0x10) == 0) && ((gHID_Devices[gHID_SLOT_GC].pad_data[pad].data_union.controller.cur_hid_data[0] & 0x22) != 0x22))) return 1; return CONTROLLER_PATCHER_ERROR_NO_PAD_CONNECTED; @@ -309,7 +309,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::checkActivePad(s32 hi } /* -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getActivePad(s32 hidmask){ +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getActivePad(u32 hidmask){ if(hidmask & gHID_LIST_GC){ if (!(((gHID_Devices[gHID_SLOT_GC].pad_data[0].data_union.controller.cur_hid_data[0] & 0x10) == 0) && ((gHID_Devices[gHID_SLOT_GC].pad_data[0].data_union.controller.cur_hid_data[0] & 0x22) != 0x22))) return 0; if (!(((gHID_Devices[gHID_SLOT_GC].pad_data[1].data_union.controller.cur_hid_data[0] & 0x10) == 0) && ((gHID_Devices[gHID_SLOT_GC].pad_data[1].data_union.controller.cur_hid_data[0] & 0x22) != 0x22))) return 1; @@ -609,7 +609,7 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::setTouch(HID_Data * d } CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::checkAndSetMouseMode(HID_Data * data){ - s32 hidmask = data->slotdata.hidmask; + u32 hidmask = data->slotdata.hidmask; if(hidmask & gHID_LIST_KEYBOARD){ u8 * cur_data = &data->data_union.controller.cur_hid_data[0]; @@ -817,7 +817,7 @@ void ControllerPatcherUtils::setConfigValue(u8 * dest, u8 first, u8 second){ dest[1] = second; } -CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getDeviceSlot(s32 hidmask){ +CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::getDeviceSlot(u32 hidmask){ for(s32 i = 0;i < gHIDMaxDevices;i++){ if(hidmask & config_controller_hidmask[i]){ return i; diff --git a/patcher/ControllerPatcherUtils.hpp b/patcher/ControllerPatcherUtils.hpp index fbfd9dd..52d9c91 100644 --- a/patcher/ControllerPatcherUtils.hpp +++ b/patcher/ControllerPatcherUtils.hpp @@ -48,7 +48,7 @@ class ControllerPatcherUtils{ \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful. The returned value is the deviceslot of the given HID-Mask **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR getDeviceSlot(s32 hidmask); + static CONTROLLER_PATCHER_RESULT_OR_ERROR getDeviceSlot(u32 hidmask); /** \brief Returns the device slot for a given HID-Mask. @@ -154,7 +154,7 @@ class ControllerPatcherUtils{ \return When the functions failed result < 0 is returned. If the pad is active/connected, 1 is returned. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR checkActivePad(s32 hidmask,s32 pad); + static CONTROLLER_PATCHER_RESULT_OR_ERROR checkActivePad(u32 hidmask,s32 pad); /** \brief Returns the first active pad of devices with the given HID-Mask. Currently only implemented for the GC-Adapter. Every other pad will always return 0. @@ -163,7 +163,7 @@ class ControllerPatcherUtils{ \return When the functions failed result < 0 is returned. If the result is >= 0 the function was successful. The returned value is fist active pad. **/ - static CONTROLLER_PATCHER_RESULT_OR_ERROR getActivePad(s32 hidmask); + static CONTROLLER_PATCHER_RESULT_OR_ERROR getActivePad(u32 hidmask); /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * Stick functions diff --git a/utils/CPRetainVars.cpp b/utils/CPRetainVars.cpp index 892a1f7..992ad6b 100644 --- a/utils/CPRetainVars.cpp +++ b/utils/CPRetainVars.cpp @@ -24,8 +24,8 @@ ControllerMapping gControllerMapping __attribute__((section(".data"))); u8 gConfig_done __attribute__((section(".data"))) = 0; u8 gButtonRemappingConfigDone __attribute__((section(".data"))) = 0; -u16 gHIDAttached __attribute__((section(".data"))) = 0; -u16 gHIDCurrentDevice __attribute__((section(".data"))) = 0; +u32 gHIDAttached __attribute__((section(".data"))) = 0; +u32 gHIDCurrentDevice __attribute__((section(".data"))) = 0; u16 gHIDRegisteredDevices __attribute__((section(".data"))) = 0; @@ -38,12 +38,12 @@ u8 gHID_Mouse_Mode __attribute__((section(".data"))) = HID_MOUSE_MODE_TOUCH; u32 gGamePadValues[CONTRPS_MAX_VALUE] __attribute__((section(".data"))); u8 config_controller[gHIDMaxDevices][CONTRPS_MAX_VALUE][2] __attribute__((section(".data"))); -u16 config_controller_hidmask[gHIDMaxDevices] __attribute__((section(".data"))); +u32 config_controller_hidmask[gHIDMaxDevices] __attribute__((section(".data"))); -u16 gHID_LIST_GC __attribute__((section(".data"))) = 0; -u16 gHID_LIST_DS3 __attribute__((section(".data"))) = 0; -u16 gHID_LIST_KEYBOARD __attribute__((section(".data"))) = 0; -u16 gHID_LIST_MOUSE __attribute__((section(".data"))) = 0; +u32 gHID_LIST_GC __attribute__((section(".data"))) = 0; +u32 gHID_LIST_DS3 __attribute__((section(".data"))) = 0; +u32 gHID_LIST_KEYBOARD __attribute__((section(".data"))) = 0; +u32 gHID_LIST_MOUSE __attribute__((section(".data"))) = 0; u16 gGamePadSlot __attribute__((section(".data"))) = 0; u16 gHID_SLOT_GC __attribute__((section(".data"))) = 0; diff --git a/utils/CPRetainVars.hpp b/utils/CPRetainVars.hpp index c31ad25..d8ee434 100644 --- a/utils/CPRetainVars.hpp +++ b/utils/CPRetainVars.hpp @@ -25,8 +25,8 @@ extern ControllerMapping gControllerMapping; extern u8 gConfig_done; extern u8 gButtonRemappingConfigDone; -extern u16 gHIDAttached; -extern u16 gHIDCurrentDevice; +extern u32 gHIDAttached; +extern u32 gHIDCurrentDevice; extern HIDClient gHIDClient; extern u16 gHIDRegisteredDevices; @@ -38,12 +38,12 @@ extern u8 gHID_Mouse_Mode; extern u32 gGamePadValues[CONTRPS_MAX_VALUE]; extern u8 config_controller[gHIDMaxDevices][CONTRPS_MAX_VALUE][2]; -extern u16 config_controller_hidmask[gHIDMaxDevices]; +extern u32 config_controller_hidmask[gHIDMaxDevices]; -extern u16 gHID_LIST_GC; -extern u16 gHID_LIST_DS3; -extern u16 gHID_LIST_KEYBOARD; -extern u16 gHID_LIST_MOUSE; +extern u32 gHID_LIST_GC; +extern u32 gHID_LIST_DS3; +extern u32 gHID_LIST_KEYBOARD; +extern u32 gHID_LIST_MOUSE; extern u16 gGamePadSlot; extern u16 gHID_SLOT_GC;