Skip to content

Commit

Permalink
Add bindings for toggling mouse control and touch screen controls. No…
Browse files Browse the repository at this point in the history
…t bound by default.

I think I'll find myself using both of these for testing, feel worthwhile.

Suggested in #18464
  • Loading branch information
hrydgard committed Dec 29, 2023
1 parent 01d7361 commit 679b833
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Core/KeyMap.cpp
Expand Up @@ -465,6 +465,9 @@ const KeyMap_IntStrPair psp_button_names[] = {
{VIRTKEY_TOGGLE_WLAN, "Toggle WLAN"},
{VIRTKEY_EXIT_APP, "Exit App"},

{VIRTKEY_TOGGLE_MOUSE, "Toggle mouse input"},
{VIRTKEY_TOGGLE_TOUCH_CONTROLS, "Toggle touch controls"},

{VIRTKEY_AXIS_RIGHT_Y_MAX, "RightAn.Up"},
{VIRTKEY_AXIS_RIGHT_Y_MIN, "RightAn.Down"},
{VIRTKEY_AXIS_RIGHT_X_MIN, "RightAn.Left"},
Expand Down
2 changes: 2 additions & 0 deletions Core/KeyMap.h
Expand Up @@ -74,6 +74,8 @@ enum {
VIRTKEY_PREVIOUS_SLOT = 0x40000027,
VIRTKEY_TOGGLE_WLAN = 0x40000028,
VIRTKEY_EXIT_APP = 0x40000029,
VIRTKEY_TOGGLE_MOUSE = 0x40000030,
VIRTKEY_TOGGLE_TOUCH_CONTROLS = 0x40000031,
VIRTKEY_LAST,
VIRTKEY_COUNT = VIRTKEY_LAST - VIRTKEY_FIRST
};
Expand Down
24 changes: 23 additions & 1 deletion UI/EmuScreen.cpp
Expand Up @@ -788,7 +788,29 @@ void EmuScreen::onVKey(int virtualKeyCode, bool down) {
if (down)
System_ToggleFullscreenState("");
break;

case VIRTKEY_TOGGLE_TOUCH_CONTROLS:
if (down) {
if (g_Config.bShowTouchControls) {
// This just messes with opacity if enabled, so you can touch the screen again to bring them back.
if (GamepadGetOpacity() < 0.01f) {
GamepadTouch();
} else {
// Reset.
GamepadTouch(true);
}
} else {
// If touch controls are disabled though, they'll get enabled.
g_Config.bShowTouchControls = true;
RecreateViews();
GamepadTouch();
}
}
break;
case VIRTKEY_TOGGLE_MOUSE:
if (down) {
g_Config.bMouseControl = !g_Config.bMouseControl;
}
break;
case VIRTKEY_SCREENSHOT:
if (down)
g_TakeScreenshot = true;
Expand Down
4 changes: 2 additions & 2 deletions UI/GamepadEmu.cpp
Expand Up @@ -70,8 +70,8 @@ void GamepadUpdateOpacity(float force) {
g_gamepadOpacity = opacity * multiplier;
}

void GamepadTouch() {
g_lastTouch = time_now_d();
void GamepadTouch(bool reset) {
g_lastTouch = reset ? 0.0f : time_now_d();
}

float GamepadGetOpacity() {
Expand Down
2 changes: 1 addition & 1 deletion UI/GamepadEmu.h
Expand Up @@ -369,6 +369,6 @@ namespace GestureKey {
};
}

void GamepadTouch();
void GamepadTouch(bool reset = false);
void GamepadUpdateOpacity(float force = -1.0f);
float GamepadGetOpacity();

0 comments on commit 679b833

Please sign in to comment.