diff --git a/source/ControllerPatcherDefs.h b/source/ControllerPatcherDefs.h index 5953416..7b6434b 100644 --- a/source/ControllerPatcherDefs.h +++ b/source/ControllerPatcherDefs.h @@ -174,6 +174,9 @@ enum Controller_Patcher_Settings CONTRPS_VPAD_BUTTON_R_STICK_LEFT, CONTRPS_VPAD_BUTTON_R_STICK_RIGHT, + CONTRPS_VPAD_STICK_L_COPY_DPAD, + CONTRPS_VPAD_STICK_R_COPY_DPAD, + CONTRPS_VPAD_BUTTON_TV, CONTRPS_DOUBLE_USE, //!When used: e.g. CONTROLLER_PATCHER_VALUE_SET, CONTROLLER_PATCHER_GC_DOUBLE_USE CONTRPS_DOUBLE_USE_BUTTON_ACTIVATOR, diff --git a/source/config/ConfigValues.hpp b/source/config/ConfigValues.hpp index ac650ef..bdacafc 100644 --- a/source/config/ConfigValues.hpp +++ b/source/config/ConfigValues.hpp @@ -270,6 +270,9 @@ private: CONTPRStringToValueSingle["DOUBLE_USE"] = CONTRPS_DOUBLE_USE; CONTPRStringToValueSingle["PAD_COUNT"] = CONTRPS_PAD_COUNT; + CONTPRStringToValueSingle["VPAD_L_STICK_COPY_DPAD"] = CONTRPS_VPAD_STICK_L_COPY_DPAD; + CONTPRStringToValueSingle["VPAD_R_STICK_COPY_DPAD"] = CONTRPS_VPAD_STICK_R_COPY_DPAD; + mouseLeftValues["LEFT_CLICK"] = CONTRPS_VPAD_BUTTON_LEFT; mouseLeftValues["RIGHT_CLICK"] = CONTRPS_VPAD_BUTTON_RIGHT; mouseLeftValues["EMULATED_STICK"] = CONTRPS_MOUSE_STICK; diff --git a/source/patcher/ControllerPatcherUtils.cpp b/source/patcher/ControllerPatcherUtils.cpp index f8f5145..e898ca8 100644 --- a/source/patcher/ControllerPatcherUtils.cpp +++ b/source/patcher/ControllerPatcherUtils.cpp @@ -418,7 +418,6 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(H s32 deviceslot = data->slotdata.deviceslot; if (data->type == DEVICE_TYPE_MOUSE){ - if(gHID_Mouse_Mode == HID_MOUSE_MODE_AIM){ // TODO: tweak values HID_Mouse_Data * ms_data = &data->data_union.mouse.cur_mouse_data; if(ms_data == NULL) return CONTROLLER_PATCHER_ERROR_NULL_POINTER; @@ -522,6 +521,39 @@ CONTROLLER_PATCHER_RESULT_OR_ERROR ControllerPatcherUtils::convertAnalogSticks(H buffer->rstick.y += stick.y; } + if(config_controller[deviceslot][CONTRPS_VPAD_STICK_L_COPY_DPAD][0] != CONTROLLER_PATCHER_INVALIDVALUE){ + if(config_controller[deviceslot][CONTRPS_VPAD_STICK_L_COPY_DPAD][0] == 1){ + u8 stick_values = 0; + + if(buffer->btns_h & VPAD_BUTTON_UP){ stick_values |= STICK_VALUE_UP; } + if(buffer->btns_h & VPAD_BUTTON_DOWN){ stick_values |= STICK_VALUE_DOWN; } + if(buffer->btns_h & VPAD_BUTTON_LEFT){ stick_values |= STICK_VALUE_LEFT; } + if(buffer->btns_h & VPAD_BUTTON_RIGHT){ stick_values |= STICK_VALUE_RIGHT; } + + if(stick_values > 0 ){ + Vec2D stick = getAnalogValueByButtons(stick_values); + buffer->lstick.x += stick.x; + buffer->lstick.y += stick.y; + } + } + } + if(config_controller[deviceslot][CONTRPS_VPAD_STICK_R_COPY_DPAD][0] != CONTROLLER_PATCHER_INVALIDVALUE){ + if(config_controller[deviceslot][CONTRPS_VPAD_STICK_R_COPY_DPAD][0] == 1){ + u8 stick_values = 0; + + if(buffer->btns_h & VPAD_BUTTON_UP){ stick_values |= STICK_VALUE_UP; } + if(buffer->btns_h & VPAD_BUTTON_DOWN){ stick_values |= STICK_VALUE_DOWN; } + if(buffer->btns_h & VPAD_BUTTON_LEFT){ stick_values |= STICK_VALUE_LEFT; } + if(buffer->btns_h & VPAD_BUTTON_RIGHT){ stick_values |= STICK_VALUE_RIGHT; } + + if(stick_values > 0 ){ + Vec2D stick = getAnalogValueByButtons(stick_values); + buffer->rstick.x += stick.x; + buffer->rstick.y += stick.y; + } + } + } + /*log_printf("LX %f(%02X) LY %f(%02X) RX %f(%02X) RY %f(%02X)\n",buffer->lstick.x,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_X][0]], buffer->lstick.y,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_L_STICK_Y][0]], buffer->rstick.x,cur_data[config_controller[deviceslot][CONTRPS_VPAD_BUTTON_R_STICK_X][0]],