Added memory flushing to getMouseData function, added cooldown to mouse mode changing

This commit is contained in:
Maschell 2018-02-16 18:57:45 +01:00
parent cb17522af2
commit 54b321ad6e
5 changed files with 24 additions and 3 deletions

View File

@ -741,6 +741,9 @@ HID_Mouse_Data * ControllerPatcher::getMouseData(){
}
if(padinfo->type == CM_Type_Mouse){
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;
@ -766,12 +769,21 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcher::gettingInputAllDevices(Inp
s32 newhid = (1 << i);
s32 deviceslot = ControllerPatcherUtils::getDeviceSlot(newhid);
if(deviceslot < 0) continue;
output[result].type = CM_Type_Controller;
DeviceInfo * deviceinfo = &(output[result].device_info);
InputButtonData * buttondata = output[result].button_data;
deviceinfo->slotdata.deviceslot = deviceslot;
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.pid = config_controller[deviceslot][CONTRPS_PID][0] * 0x100 + config_controller[deviceslot][CONTRPS_PID][1];

View File

@ -359,6 +359,7 @@ typedef struct _InputButtonData{
*/
typedef struct _InputData{
DeviceInfo device_info; /**< Infos about the device where the data is coming from */
ControllerMapping_Type_Defines type;
InputButtonData button_data[HID_MAX_PADS_COUNT];
}InputData;

View File

@ -613,15 +613,19 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::checkAndSetMouseMode(
if(hidmask & gHID_LIST_KEYBOARD){
u8 * cur_data = &data->data_union.controller.cur_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){
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){
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;
}
}
if(gMouseModeCoolDown > 0){
gMouseModeCoolDown--;
}
}
return CONTROLLER_PATCHER_ERROR_NONE;
}

View File

@ -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 gMouseModeCoolDown __attribute__((section(".data"))) = 0;
u32 gGamePadValues[CONTRPS_MAX_VALUE] __attribute__((section(".data")));
u8 config_controller[gHIDMaxDevices][CONTRPS_MAX_VALUE][2] __attribute__((section(".data")));

View File

@ -36,6 +36,8 @@ extern HID_DEVICE_DATA gHID_Devices[gHIDMaxDevices];
extern u8 gHID_Mouse_Mode;
extern u8 gMouseModeCoolDown;
extern u32 gGamePadValues[CONTRPS_MAX_VALUE];
extern u8 config_controller[gHIDMaxDevices][CONTRPS_MAX_VALUE][2];