add back some hotkeys.

remove some legacy cruft from NDS.cpp.
This commit is contained in:
Arisotura 2020-05-19 22:37:48 +02:00
parent b262313816
commit 95f9698077
5 changed files with 40 additions and 38 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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

View File

@ -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);
}

View File

@ -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)
{