mirror of
https://github.com/Maschell/controller_patcher.git
synced 2024-11-22 12:09:16 +01:00
Added memory flushing to getMouseData function, added cooldown to mouse mode changing
This commit is contained in:
parent
cb17522af2
commit
54b321ad6e
@ -741,6 +741,9 @@ HID_Mouse_Data * ControllerPatcher::getMouseData(){
|
|||||||
}
|
}
|
||||||
if(padinfo->type == CM_Type_Mouse){
|
if(padinfo->type == CM_Type_Mouse){
|
||||||
result = &(gHID_Devices[gMouseSlot].pad_data[padinfo->pad].data_union.mouse.cur_mouse_data);
|
result = &(gHID_Devices[gMouseSlot].pad_data[padinfo->pad].data_union.mouse.cur_mouse_data);
|
||||||
|
DCFlushRange(&result,sizeof(result));
|
||||||
|
DCInvalidateRange(&result,sizeof(result));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -766,12 +769,21 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::gettingInputAllDevices(Inp
|
|||||||
s32 newhid = (1 << i);
|
s32 newhid = (1 << i);
|
||||||
s32 deviceslot = ControllerPatcherUtils::getDeviceSlot(newhid);
|
s32 deviceslot = ControllerPatcherUtils::getDeviceSlot(newhid);
|
||||||
if(deviceslot < 0) continue;
|
if(deviceslot < 0) continue;
|
||||||
|
|
||||||
|
output[result].type = CM_Type_Controller;
|
||||||
|
|
||||||
DeviceInfo * deviceinfo = &(output[result].device_info);
|
DeviceInfo * deviceinfo = &(output[result].device_info);
|
||||||
InputButtonData * buttondata = output[result].button_data;
|
InputButtonData * buttondata = output[result].button_data;
|
||||||
|
|
||||||
deviceinfo->slotdata.deviceslot = deviceslot;
|
deviceinfo->slotdata.deviceslot = deviceslot;
|
||||||
deviceinfo->slotdata.hidmask = newhid;
|
deviceinfo->slotdata.hidmask = newhid;
|
||||||
|
|
||||||
|
if(newhid == gHID_LIST_MOUSE){
|
||||||
|
output[result].type = CM_Type_Mouse;
|
||||||
|
} else if(newhid == gHID_LIST_KEYBOARD){
|
||||||
|
output[result].type = CM_Type_Keyboard;
|
||||||
|
}
|
||||||
|
|
||||||
deviceinfo->vidpid.vid = config_controller[deviceslot][CONTRPS_VID][0] * 0x100 + config_controller[deviceslot][CONTRPS_VID][1];
|
deviceinfo->vidpid.vid = config_controller[deviceslot][CONTRPS_VID][0] * 0x100 + config_controller[deviceslot][CONTRPS_VID][1];
|
||||||
deviceinfo->vidpid.pid = config_controller[deviceslot][CONTRPS_PID][0] * 0x100 + config_controller[deviceslot][CONTRPS_PID][1];
|
deviceinfo->vidpid.pid = config_controller[deviceslot][CONTRPS_PID][0] * 0x100 + config_controller[deviceslot][CONTRPS_PID][1];
|
||||||
|
|
||||||
|
@ -359,6 +359,7 @@ typedef struct _InputButtonData{
|
|||||||
*/
|
*/
|
||||||
typedef struct _InputData{
|
typedef struct _InputData{
|
||||||
DeviceInfo device_info; /**< Infos about the device where the data is coming from */
|
DeviceInfo device_info; /**< Infos about the device where the data is coming from */
|
||||||
|
ControllerMapping_Type_Defines type;
|
||||||
InputButtonData button_data[HID_MAX_PADS_COUNT];
|
InputButtonData button_data[HID_MAX_PADS_COUNT];
|
||||||
}InputData;
|
}InputData;
|
||||||
|
|
||||||
|
@ -613,15 +613,19 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::checkAndSetMouseMode(
|
|||||||
if(hidmask & gHID_LIST_KEYBOARD){
|
if(hidmask & gHID_LIST_KEYBOARD){
|
||||||
u8 * cur_data = &data->data_union.controller.cur_hid_data[0];
|
u8 * cur_data = &data->data_union.controller.cur_hid_data[0];
|
||||||
u8 * last_data = &data->data_union.controller.last_hid_data[0];
|
u8 * last_data = &data->data_union.controller.last_hid_data[0];
|
||||||
if((isInKeyboardData(cur_data,HID_KEYBOARD_BUTTON_F1) > 0) && ((isInKeyboardData(cur_data,HID_KEYBOARD_BUTTON_F1) > 0) != (isInKeyboardData(last_data,HID_KEYBOARD_BUTTON_F1) > 0))){
|
if((isInKeyboardData(cur_data,HID_KEYBOARD_BUTTON_F1) > 0) && ((isInKeyboardData(cur_data,HID_KEYBOARD_BUTTON_F1) > 0) != (isInKeyboardData(last_data,HID_KEYBOARD_BUTTON_F1) > 0)) && gMouseModeCoolDown == 0){
|
||||||
|
gMouseModeCoolDown = 60;
|
||||||
if(gHID_Mouse_Mode == HID_MOUSE_MODE_AIM){
|
if(gHID_Mouse_Mode == HID_MOUSE_MODE_AIM){
|
||||||
gHID_Mouse_Mode = HID_MOUSE_MODE_TOUCH;
|
gHID_Mouse_Mode = HID_MOUSE_MODE_TOUCH;
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcherUtils::checkAndSetMouseMode(line %d): Mouse mode changed! to touch \n",__LINE__); }
|
//log_printf("ControllerPatcherUtils::checkAndSetMouseMode(line %d): Mouse mode changed! to touch \n",__LINE__);
|
||||||
}else if(gHID_Mouse_Mode == HID_MOUSE_MODE_TOUCH){
|
}else if(gHID_Mouse_Mode == HID_MOUSE_MODE_TOUCH){
|
||||||
if(HID_DEBUG){ log_printf("ControllerPatcherUtils::checkAndSetMouseMode(line %d): Mouse mode changed! to aim \n",__LINE__); }
|
//log_printf("ControllerPatcherUtils::checkAndSetMouseMode(line %d): Mouse mode changed! to aim \n",__LINE__);
|
||||||
gHID_Mouse_Mode = HID_MOUSE_MODE_AIM;
|
gHID_Mouse_Mode = HID_MOUSE_MODE_AIM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(gMouseModeCoolDown > 0){
|
||||||
|
gMouseModeCoolDown--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return CONTROLLER_PATCHER_ERROR_NONE;
|
return CONTROLLER_PATCHER_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@ HID_DEVICE_DATA gHID_Devices[gHIDMaxDevices] __attribute__((section(".data")));
|
|||||||
|
|
||||||
u8 gHID_Mouse_Mode __attribute__((section(".data"))) = HID_MOUSE_MODE_TOUCH;
|
u8 gHID_Mouse_Mode __attribute__((section(".data"))) = HID_MOUSE_MODE_TOUCH;
|
||||||
|
|
||||||
|
u8 gMouseModeCoolDown __attribute__((section(".data"))) = 0;
|
||||||
|
|
||||||
u32 gGamePadValues[CONTRPS_MAX_VALUE] __attribute__((section(".data")));
|
u32 gGamePadValues[CONTRPS_MAX_VALUE] __attribute__((section(".data")));
|
||||||
|
|
||||||
u8 config_controller[gHIDMaxDevices][CONTRPS_MAX_VALUE][2] __attribute__((section(".data")));
|
u8 config_controller[gHIDMaxDevices][CONTRPS_MAX_VALUE][2] __attribute__((section(".data")));
|
||||||
|
@ -36,6 +36,8 @@ extern HID_DEVICE_DATA gHID_Devices[gHIDMaxDevices];
|
|||||||
|
|
||||||
extern u8 gHID_Mouse_Mode;
|
extern u8 gHID_Mouse_Mode;
|
||||||
|
|
||||||
|
extern u8 gMouseModeCoolDown;
|
||||||
|
|
||||||
extern u32 gGamePadValues[CONTRPS_MAX_VALUE];
|
extern u32 gGamePadValues[CONTRPS_MAX_VALUE];
|
||||||
|
|
||||||
extern u8 config_controller[gHIDMaxDevices][CONTRPS_MAX_VALUE][2];
|
extern u8 config_controller[gHIDMaxDevices][CONTRPS_MAX_VALUE][2];
|
||||||
|
Loading…
Reference in New Issue
Block a user