diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index b604de7fc..8fac566e3 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -609,6 +609,7 @@ namespace SohImGui { EnhancementCheckbox("Show Inputs", "gInputEnabled"); Tooltip("Shows currently pressed inputs on the bottom right of the screen"); + EnhancementCheckbox("Mouse/Touch Enabled", "gMouseTouchEnabled"); EnhancementCheckbox("Rumble Enabled", "gRumbleEnabled"); EnhancementSliderFloat("Input Scale: %.1f", "##Input", "gInputScale", 1.0f, 3.0f, "", 1.0f, false); diff --git a/soh/src/code/padmgr.c b/soh/src/code/padmgr.c index 62843fa50..7f574683a 100644 --- a/soh/src/code/padmgr.c +++ b/soh/src/code/padmgr.c @@ -271,17 +271,14 @@ void PadMgr_ProcessInputs(PadMgr* padMgr) { PadUtils_UpdateRelXY(input); input->press.stick_x += (s8)(input->cur.stick_x - input->prev.stick_x); input->press.stick_y += (s8)(input->cur.stick_y - input->prev.stick_y); - - u8 buttonDiff2; - buttonDiff2 = input->prev.left_click != input->cur.left_click; - input->press.left_click = (u8)(input->cur.left_click && buttonDiff2); - input->rel.left_click = (u8)(!input->cur.left_click && buttonDiff2); - - buttonDiff2 = input->prev.right_click != input->cur.right_click; - input->press.right_click = (u8)(input->cur.right_click && buttonDiff2); - input->rel.right_click = (u8)(!input->cur.right_click && buttonDiff2); } + buttonDiff = input->prev.left_click != input->cur.left_click; + input->press.left_click = buttonDiff; + + buttonDiff = input->prev.right_click != input->cur.right_click; + input->press.right_click = buttonDiff; + controllerCallback.rumble = CVar_GetS32("gRumbleEnabled", 0) && (padMgr->rumbleEnable[0] > 0); if (HealthMeter_IsCritical()) { @@ -303,6 +300,7 @@ void PadMgr_ProcessInputs(PadMgr* padMgr) { OTRControllerCallback(&controllerCallback); PadMgr_UnlockPadData(padMgr); + } void PadMgr_HandleRetraceMsg(PadMgr* padMgr) { diff --git a/soh/src/code/z_camera.c b/soh/src/code/z_camera.c index 8eb1ae579..4ae2f6555 100644 --- a/soh/src/code/z_camera.c +++ b/soh/src/code/z_camera.c @@ -1411,11 +1411,24 @@ s32 Camera_Noop(Camera* camera) { return true; } -s32 SetCameraManual(Camera* camera) { - f32 newCamX = -D_8015BD7C->state.input[0].cur.cam_x; - f32 newCamY = D_8015BD7C->state.input[0].cur.cam_y; +f32 lastMouseX2; +f32 lastMouseY2; - if ((fabsf(newCamX) >= 350.0f || fabsf(newCamY) >= 350.0f) && manualCamera == false) { +s32 SetCameraManual(Camera* camera) { + f32 mouseX = D_8015BD7C->state.input[0].cur.touch_x - lastMouseX2; + lastMouseX2 = D_8015BD7C->state.input[0].cur.touch_x; + f32 mouseY = D_8015BD7C->state.input[0].cur.touch_y - lastMouseY2; + lastMouseY2 = D_8015BD7C->state.input[0].cur.touch_y; + + if (CVar_GetS32("gMouseTouchEnabled", 0) != 1) { + mouseX = 0.0f; + mouseY = 0.0f; + } + + f32 newCamX = -D_8015BD7C->state.input[0].cur.cam_x + -(mouseX * 40.0f); + f32 newCamY = D_8015BD7C->state.input[0].cur.cam_y + (mouseY * 40.0f); + + if ((fabsf(newCamX) >= 200.0f || fabsf(newCamY) >= 200.0f) && manualCamera == false) { manualCamera = true; VecSph eyeAdjustment; @@ -1510,6 +1523,11 @@ s32 Camera_Free(Camera* camera) { f32 mouseY = D_8015BD7C->state.input[0].cur.touch_y - lastMouseY; lastMouseY = D_8015BD7C->state.input[0].cur.touch_y; + if (CVar_GetS32("gMouseTouchEnabled", 0) != 1) { + mouseX = 0.0f; + mouseY = 0.0f; + } + f32 newCamX = -D_8015BD7C->state.input[0].cur.cam_x + -(mouseX * 40.0f); f32 newCamY = D_8015BD7C->state.input[0].cur.cam_y + (mouseY * 40.0f); diff --git a/soh/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/soh/src/overlays/actors/ovl_En_Mag/z_en_mag.c index 1db2bac40..cd3471ed8 100644 --- a/soh/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/soh/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -341,7 +341,8 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->globalState < MAG_STATE_DISPLAY) { if (CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_START) || CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_A) || - CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_B) || globalCtx->state.input[0].press.left_click) { + CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_B) || + (CVar_GetS32("gMouseTouchEnabled", 0) != 0 && globalCtx->state.input[0].press.left_click)) { Audio_PlaySoundGeneral(NA_SE_SY_PIECE_OF_HEART, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); @@ -368,7 +369,7 @@ void EnMag_Update(Actor* thisx, GlobalContext* globalCtx) { if (CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_START) || CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_A) || CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_B) || - globalCtx->state.input[0].press.left_click) { + (CVar_GetS32("gMouseTouchEnabled", 0) != 0 && globalCtx->state.input[0].press.left_click)) { if (globalCtx->sceneLoadFlag != 20) { Audio_SetCutsceneFlag(0); diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 3e54c4121..168052224 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -164,12 +164,20 @@ void FileChoose_FinishFadeIn(GameState* thisx) { } void HandleMouseInput(Input* input) { + if (CVar_GetS32("gMouseTouchEnabled", 0) != 1) { + return; + } + if (input->press.left_click) { input->press.button = BTN_A; } } u8 HandleMouseCursor(FileChooseContext* this, Input* input, int minx, int miny, int maxx, int maxy) { + if (CVar_GetS32("gMouseTouchEnabled", 0) != 1) { + return 0; + } + float ogratio = 320.0f / 240.0f; float ratio = (float)OTRGetCurrentWidth() / (float)OTRGetCurrentHeight(); @@ -188,6 +196,13 @@ u8 HandleMouseCursor(FileChooseContext* this, Input* input, int minx, int miny, } Vec2f HandleMouseCursorSplit(FileChooseContext* this, Input* input, int minx, int miny, int maxx, int maxy, int countx, int county) { + if (CVar_GetS32("gMouseTouchEnabled", 0) != 1) { + Vec2f pos; + pos.x = -1; + pos.y = -1; + return pos; + } + float ogratio = 320.0f / 240.0f; float ratio = (float)OTRGetCurrentWidth() / (float)OTRGetCurrentHeight();