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
This commit is contained in:
Maschell 2017-04-10 17:15:26 +02:00
parent 74d422a87e
commit 41012b4543
10 changed files with 32 additions and 36 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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<count_commands;i++){
s32 handle;
u16 deviceSlot;
u16 hid;
u32 hid;
u8 padslot;
u8 datasize;
@ -131,7 +130,6 @@ void UDPServer::DoUDPThreadInternal(){
//log_printf("UDPServer::DoUDPThreadInternal(): Got handle: %d slot %04X hid %04X pad %02X datasize %02X\n",handle,deviceSlot,hid,padslot,datasize);
if(!cpyIncrementBufferOffset((void *)databuffer, (void *)buffer,&bufferoffset,datasize, n))continue;
memset(&user,0,sizeof(user));
user.pad_slot = padslot;
user.slotdata.deviceslot = deviceSlot;

View File

@ -49,7 +49,7 @@
#define CONTROLLER_PATCHER_INVALIDVALUE 0xFF
#define HID_INVALID_SLOT 0xFFFF
#define HID_INVALID_HIDMASK 0xFFFF
#define HID_INVALID_HIDMASK 0xFFFFFFFF
typedef int CONTROLLER_PATCHER_RESULT_OR_ERROR;

View File

@ -438,12 +438,12 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherHID::setVPADControllerData(V
}
std::vector<HID_Data *> ControllerPatcherHID::getHIDDataAll(){
s32 hid = gHIDCurrentDevice;
u32 hid = gHIDCurrentDevice;
std::vector<HID_Data *> 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<HID_Data *> 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;

View File

@ -47,7 +47,7 @@ class ControllerPatcherHID{
private:
static CONTROLLER_PATCHER_RESULT_OR_ERROR setVPADControllerData(VPADData * buffer,std::vector<HID_Data *>& data);
static std::vector<HID_Data *> 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

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;