aboutsummaryrefslogtreecommitdiff
path: root/src/libui_sdl
diff options
context:
space:
mode:
authorJon Pacheco <jon.pacheco2@gmail.com>2019-05-12 11:41:46 +0100
committerJon Pacheco <jon.pacheco2@gmail.com>2019-05-12 11:41:46 +0100
commit7d2ba09fd7d43397e1e2915de0e9a7e8e0abb6c2 (patch)
treeba2255b5b32af36adce4f5f0dd78401660889f49 /src/libui_sdl
parent99b07f930084b6faa7ac130b0d2c82a6f2060306 (diff)
Add fast forward hotkeys
Diffstat (limited to 'src/libui_sdl')
-rw-r--r--src/libui_sdl/DlgInputConfig.cpp2
-rw-r--r--src/libui_sdl/PlatformConfig.cpp14
-rw-r--r--src/libui_sdl/PlatformConfig.h3
-rw-r--r--src/libui_sdl/main.cpp49
4 files changed, 58 insertions, 10 deletions
diff --git a/src/libui_sdl/DlgInputConfig.cpp b/src/libui_sdl/DlgInputConfig.cpp
index 513bd90..4f9307b 100644
--- a/src/libui_sdl/DlgInputConfig.cpp
+++ b/src/libui_sdl/DlgInputConfig.cpp
@@ -58,7 +58,7 @@ char dskeylabels[12][8] = {"A:", "B:", "Select:", "Start:", "Right:", "Left:", "
int identity[32] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
-char hotkeylabels[HK_MAX][32] = {"Close/open lid:", "Microphone:"};
+char hotkeylabels[HK_MAX][32] = {"Close/open lid:", "Microphone:", "Fast Forward:", "Fast Forward (Toggle):"};
int openedmask;
InputDlgData inputdlg[2];
diff --git a/src/libui_sdl/PlatformConfig.cpp b/src/libui_sdl/PlatformConfig.cpp
index 2daf746..335fe3e 100644
--- a/src/libui_sdl/PlatformConfig.cpp
+++ b/src/libui_sdl/PlatformConfig.cpp
@@ -85,11 +85,15 @@ ConfigEntry PlatformConfigFile[] =
{"Joy_X", 0, &JoyMapping[10], -1, NULL, 0},
{"Joy_Y", 0, &JoyMapping[11], -1, NULL, 0},
- {"HKKey_Lid", 0, &HKKeyMapping[HK_Lid], 0x0E, NULL, 0},
- {"HKKey_Mic", 0, &HKKeyMapping[HK_Mic], 0x35, NULL, 0},
-
- {"HKJoy_Lid", 0, &HKJoyMapping[HK_Lid], -1, NULL, 0},
- {"HKJoy_Mic", 0, &HKJoyMapping[HK_Mic], -1, NULL, 0},
+ {"HKKey_Lid", 0, &HKKeyMapping[HK_Lid], 0x0E, NULL, 0},
+ {"HKKey_Mic", 0, &HKKeyMapping[HK_Mic], 0x35, NULL, 0},
+ {"HKKey_FastForward", 0, &HKKeyMapping[HK_FastForward], 0x0F, NULL, 0},
+ {"HKKey_FastForwardToggle", 0, &HKKeyMapping[HK_FastForwardToggle], -1, NULL, 0}, // TODO: This doesn't unbind the key, just sets it to some random key
+
+ {"HKJoy_Lid", 0, &HKJoyMapping[HK_Lid], -1, NULL, 0},
+ {"HKJoy_Mic", 0, &HKJoyMapping[HK_Mic], -1, NULL, 0},
+ {"HKJoy_FastForward", 0, &HKJoyMapping[HK_FastForward], -1, NULL, 0},
+ {"HKJoy_FastForwardToggle", 0, &HKJoyMapping[HK_FastForwardToggle], -1, NULL, 0},
{"WindowWidth", 0, &WindowWidth, 256, NULL, 0},
{"WindowHeight", 0, &WindowHeight, 384, NULL, 0},
diff --git a/src/libui_sdl/PlatformConfig.h b/src/libui_sdl/PlatformConfig.h
index ed31e18..ce49b12 100644
--- a/src/libui_sdl/PlatformConfig.h
+++ b/src/libui_sdl/PlatformConfig.h
@@ -25,7 +25,8 @@ enum
{
HK_Lid = 0,
HK_Mic,
-
+ HK_FastForward,
+ HK_FastForwardToggle,
HK_MAX
};
diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp
index 3eea39c..83cfb6e 100644
--- a/src/libui_sdl/main.cpp
+++ b/src/libui_sdl/main.cpp
@@ -81,6 +81,8 @@ uiMenuItem* MenuItem_ScreenGap[6];
uiMenuItem* MenuItem_ScreenLayout[3];
uiMenuItem* MenuItem_ScreenSizing[4];
+uiMenuItem* MenuItem_LimitFPS;
+
SDL_Thread* EmuThread;
int EmuRunning;
volatile int EmuStatus;
@@ -127,6 +129,7 @@ s16* MicWavBuffer;
u32 MicCommand;
+bool HotkeyFPSToggle = false;
void SetupScreenRects(int width, int height);
@@ -497,6 +500,27 @@ int EmuThreadFunc(void* burp)
HotkeyMask |= 0x1;
}
+ if (JoyButtonPressed(Config::HKJoyMapping[HK_FastForwardToggle], njoybuttons, joybuttons, joyhat))
+ {
+ HotkeyFPSToggle = !HotkeyFPSToggle;
+ Config::LimitFPS = !Config::LimitFPS;
+ uiMenuItemSetChecked(MenuItem_LimitFPS, Config::LimitFPS==1);
+ }
+
+ if (!HotkeyFPSToggle) // For fast forward (hold) hotkey
+ {
+ if (JoyButtonHeld(Config::HKJoyMapping[HK_FastForward], njoybuttons, joybuttons, joyhat))
+ {
+ Config::LimitFPS = false;
+ uiMenuItemSetChecked(MenuItem_LimitFPS, false);
+ }
+ else if (!Config::LimitFPS)
+ {
+ Config::LimitFPS = true;
+ uiMenuItemSetChecked(MenuItem_LimitFPS, true);
+ }
+ }
+
if (JoyButtonHeld(Config::HKJoyMapping[HK_Mic], njoybuttons, joybuttons, joyhat))
MicCommand |= 2;
else
@@ -745,6 +769,19 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt)
if (evt->Scancode == Config::HKKeyMapping[HK_Mic])
MicCommand &= ~1;
+
+ if (evt->Scancode == Config::HKKeyMapping[HK_FastForwardToggle])
+ {
+ HotkeyFPSToggle = !HotkeyFPSToggle;
+ Config::LimitFPS = !Config::LimitFPS;
+ uiMenuItemSetChecked(MenuItem_LimitFPS, Config::LimitFPS==1);
+ }
+
+ if (evt->Scancode == Config::HKKeyMapping[HK_FastForward] && !HotkeyFPSToggle)
+ {
+ Config::LimitFPS = true;
+ uiMenuItemSetChecked(MenuItem_LimitFPS, Config::LimitFPS==1);
+ }
}
else if (!evt->Repeat)
{
@@ -776,6 +813,12 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt)
if (evt->Scancode == Config::HKKeyMapping[HK_Mic])
MicCommand |= 1;
+ if (evt->Scancode == Config::HKKeyMapping[HK_FastForward] && !HotkeyFPSToggle)
+ {
+ Config::LimitFPS = false;
+ uiMenuItemSetChecked(MenuItem_LimitFPS, Config::LimitFPS==1);
+ }
+
if (evt->Scancode == 0x57) // F11
NDS::debug(0);
}
@@ -1932,9 +1975,9 @@ int main(int argc, char** argv)
uiMenuItemOnClicked(menuitem, OnSetScreenFiltering, NULL);
uiMenuItemSetChecked(menuitem, Config::ScreenFilter==1);
- menuitem = uiMenuAppendCheckItem(menu, "Limit framerate");
- uiMenuItemOnClicked(menuitem, OnSetLimitFPS, NULL);
- uiMenuItemSetChecked(menuitem, Config::LimitFPS==1);
+ MenuItem_LimitFPS = uiMenuAppendCheckItem(menu, "Limit framerate");
+ uiMenuItemOnClicked(MenuItem_LimitFPS, OnSetLimitFPS, NULL);
+ uiMenuItemSetChecked(MenuItem_LimitFPS, Config::LimitFPS==1);
int w = Config::WindowWidth;