aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArisotura <thetotalworm@gmail.com>2020-05-19 22:37:48 +0200
committerArisotura <thetotalworm@gmail.com>2020-05-19 22:37:48 +0200
commit95f9698077fe50d2567aacd8728ff2625f88f228 (patch)
tree3c579695c0e86c1ee886015cffe7207a426a5600
parentb262313816b9fac581353f74dd71e1dde1f23013 (diff)
add back some hotkeys.
remove some legacy cruft from NDS.cpp.
-rw-r--r--src/NDS.cpp18
-rw-r--r--src/NDS.h3
-rw-r--r--src/frontend/qt_sdl/Input.cpp5
-rw-r--r--src/frontend/qt_sdl/Input.h4
-rw-r--r--src/frontend/qt_sdl/main.cpp48
5 files changed, 40 insertions, 38 deletions
diff --git a/src/NDS.cpp b/src/NDS.cpp
index 745ed28..e89aa66 100644
--- a/src/NDS.cpp
+++ b/src/NDS.cpp
@@ -951,23 +951,15 @@ void CancelEvent(u32 id)
}
-void PressKey(u32 key)
-{
- KeyInput &= ~(1 << key);
-}
-
-void ReleaseKey(u32 key)
-{
- KeyInput |= (1 << key);
-}
-
void TouchScreen(u16 x, u16 y)
{
+ KeyInput &= ~(1<<22);
SPI_TSC::SetTouchCoords(x, y);
}
void ReleaseScreen()
{
+ KeyInput |= (1<<22);
SPI_TSC::SetTouchCoords(0x000, 0xFFF);
}
@@ -981,6 +973,12 @@ void SetKeyMask(u32 mask)
KeyInput |= key_lo | (key_hi << 16);
}
+bool IsLidClosed()
+{
+ if (KeyInput & (1<<23)) return true;
+ return false;
+}
+
void SetLidClosed(bool closed)
{
if (closed)
diff --git a/src/NDS.h b/src/NDS.h
index c7b455e..daeadc4 100644
--- a/src/NDS.h
+++ b/src/NDS.h
@@ -142,13 +142,12 @@ void RelocateSave(const char* path, bool write);
u32 RunFrame();
-void PressKey(u32 key);
-void ReleaseKey(u32 key);
void TouchScreen(u16 x, u16 y);
void ReleaseScreen();
void SetKeyMask(u32 mask);
+bool IsLidClosed();
void SetLidClosed(bool closed);
void MicInputFrame(s16* data, int samples);
diff --git a/src/frontend/qt_sdl/Input.cpp b/src/frontend/qt_sdl/Input.cpp
index d60271c..84d20ad 100644
--- a/src/frontend/qt_sdl/Input.cpp
+++ b/src/frontend/qt_sdl/Input.cpp
@@ -217,6 +217,11 @@ void Process()
}
+bool HotkeyDown(int id) { return HotkeyMask & (1<<id); }
+bool HotkeyPressed(int id) { return HotkeyPress & (1<<id); }
+bool HotkeyReleased(int id) { return HotkeyRelease & (1<<id); }
+
+
// TODO: MacOS version of this!
// distinguish between left and right modifier keys (Ctrl, Alt, Shift)
// Qt provides no real cross-platform way to do this, so here we go
diff --git a/src/frontend/qt_sdl/Input.h b/src/frontend/qt_sdl/Input.h
index 57b5a4a..14e7ea8 100644
--- a/src/frontend/qt_sdl/Input.h
+++ b/src/frontend/qt_sdl/Input.h
@@ -40,6 +40,10 @@ void KeyRelease(QKeyEvent* event);
void Process();
+bool HotkeyDown(int id);
+bool HotkeyPressed(int id);
+bool HotkeyReleased(int id);
+
bool IsRightModKey(QKeyEvent* event);
}
diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp
index 962fdaf..67ac92c 100644
--- a/src/frontend/qt_sdl/main.cpp
+++ b/src/frontend/qt_sdl/main.cpp
@@ -42,6 +42,7 @@
#include "FrontendUtil.h"
#include "NDS.h"
+#include "GBACart.h"
#include "GPU.h"
#include "SPU.h"
#include "Wifi.h"
@@ -136,8 +137,7 @@ void EmuThread::run()
}
Input::Init();
- /*Touching = false;
- LidStatus = false;*/
+ /*Touching = false;*/
u32 nframes = 0;
u32 starttick = SDL_GetTicks();
@@ -150,35 +150,33 @@ void EmuThread::run()
while (EmuRunning != 0)
{
Input::Process();
- /*ProcessInput();
- if (HotkeyPressed(HK_FastForwardToggle))
+ /*if (Input::HotkeyPressed(HK_FastForwardToggle))
{
Config::LimitFPS = !Config::LimitFPS;
- uiQueueMain(UpdateFPSLimit, NULL);
- }
- // TODO: similar hotkeys for video/audio sync?
+ // TODO: reflect in UI!
+ }*/
- if (HotkeyPressed(HK_Pause)) uiQueueMain(TogglePause, NULL);
- if (HotkeyPressed(HK_Reset)) uiQueueMain(Reset, NULL);
+ //if (Input::HotkeyPressed(HK_Pause)) uiQueueMain(TogglePause, NULL);
+ //if (Input::HotkeyPressed(HK_Reset)) uiQueueMain(Reset, NULL);
if (GBACart::CartInserted && GBACart::HasSolarSensor)
{
- if (HotkeyPressed(HK_SolarSensorDecrease))
+ if (Input::HotkeyPressed(HK_SolarSensorDecrease))
{
if (GBACart_SolarSensor::LightLevel > 0) GBACart_SolarSensor::LightLevel--;
- char msg[64];
- sprintf(msg, "Solar sensor level set to %d", GBACart_SolarSensor::LightLevel);
- OSD::AddMessage(0, msg);
+ //char msg[64];
+ //sprintf(msg, "Solar sensor level set to %d", GBACart_SolarSensor::LightLevel);
+ //OSD::AddMessage(0, msg);
}
- if (HotkeyPressed(HK_SolarSensorIncrease))
+ if (Input::HotkeyPressed(HK_SolarSensorIncrease))
{
if (GBACart_SolarSensor::LightLevel < 10) GBACart_SolarSensor::LightLevel++;
- char msg[64];
- sprintf(msg, "Solar sensor level set to %d", GBACart_SolarSensor::LightLevel);
- OSD::AddMessage(0, msg);
+ //char msg[64];
+ //sprintf(msg, "Solar sensor level set to %d", GBACart_SolarSensor::LightLevel);
+ //OSD::AddMessage(0, msg);
}
- }*/
+ }
if (EmuRunning == 1)
{
@@ -186,14 +184,13 @@ void EmuThread::run()
// process input and hotkeys
NDS::SetKeyMask(Input::InputMask);
- /*NDS::SetKeyMask(KeyInputMask & JoyInputMask);
- if (HotkeyPressed(HK_Lid))
+ if (Input::HotkeyPressed(HK_Lid))
{
- LidStatus = !LidStatus;
- NDS::SetLidClosed(LidStatus);
- OSD::AddMessage(0, LidStatus ? "Lid closed" : "Lid opened");
- }*/
+ bool lid = !NDS::IsLidClosed();
+ NDS::SetLidClosed(lid);
+ //OSD::AddMessage(0, lid ? "Lid closed" : "Lid opened");
+ }
// microphone input
/*FeedMicInput();
@@ -250,8 +247,7 @@ void EmuThread::run()
uiAreaQueueRedrawAll(MainDrawArea);*/
mainWindow->update();
- bool fastforward = false;
- //bool fastforward = HotkeyDown(HK_FastForward);
+ bool fastforward = Input::HotkeyDown(HK_FastForward);
if (Config::AudioSync && (!fastforward) && audioDevice)
{