mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 21:37:42 -07:00
hook lid close/open to the actual hotkey system
This commit is contained in:
parent
ff1e21733d
commit
a64e59bf99
@ -279,6 +279,23 @@ void MicCallback(void* data, Uint8* stream, int len)
|
|||||||
MicBufferWritePos &= (kMicBufferSize-1);
|
MicBufferWritePos &= (kMicBufferSize-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool JoyButtonPressed(int btnid, int njoybuttons, Uint8* joybuttons, Uint32 hat)
|
||||||
|
{
|
||||||
|
bool pressed;
|
||||||
|
if (btnid == 0x101) // up
|
||||||
|
pressed = (hat & SDL_HAT_UP);
|
||||||
|
else if (btnid == 0x104) // down
|
||||||
|
pressed = (hat & SDL_HAT_DOWN);
|
||||||
|
else if (btnid == 0x102) // right
|
||||||
|
pressed = (hat & SDL_HAT_RIGHT);
|
||||||
|
else if (btnid == 0x108) // left
|
||||||
|
pressed = (hat & SDL_HAT_LEFT);
|
||||||
|
else
|
||||||
|
pressed = (btnid < njoybuttons) ? joybuttons[btnid] : false;
|
||||||
|
|
||||||
|
return pressed;
|
||||||
|
}
|
||||||
|
|
||||||
int EmuThreadFunc(void* burp)
|
int EmuThreadFunc(void* burp)
|
||||||
{
|
{
|
||||||
NDS::Init();
|
NDS::Init();
|
||||||
@ -294,6 +311,13 @@ int EmuThreadFunc(void* burp)
|
|||||||
LidCommand = false;
|
LidCommand = false;
|
||||||
LidStatus = false;
|
LidStatus = false;
|
||||||
|
|
||||||
|
Uint8* joybuttons = NULL; int njoybuttons = 0;
|
||||||
|
if (Joystick)
|
||||||
|
{
|
||||||
|
njoybuttons = SDL_JoystickNumButtons(Joystick);
|
||||||
|
if (njoybuttons) joybuttons = new Uint8[njoybuttons];
|
||||||
|
}
|
||||||
|
|
||||||
u32 nframes = 0;
|
u32 nframes = 0;
|
||||||
u32 starttick = SDL_GetTicks();
|
u32 starttick = SDL_GetTicks();
|
||||||
u32 lasttick = starttick;
|
u32 lasttick = starttick;
|
||||||
@ -319,22 +343,15 @@ int EmuThreadFunc(void* burp)
|
|||||||
Sint16 axisX = SDL_JoystickGetAxis(Joystick, 0);
|
Sint16 axisX = SDL_JoystickGetAxis(Joystick, 0);
|
||||||
Sint16 axisY = SDL_JoystickGetAxis(Joystick, 1);
|
Sint16 axisY = SDL_JoystickGetAxis(Joystick, 1);
|
||||||
|
|
||||||
|
for (int i = 0; i < njoybuttons; i++)
|
||||||
|
joybuttons[i] = SDL_JoystickGetButton(Joystick, i);
|
||||||
|
|
||||||
for (int i = 0; i < 12; i++)
|
for (int i = 0; i < 12; i++)
|
||||||
{
|
{
|
||||||
int btnid = Config::JoyMapping[i];
|
int btnid = Config::JoyMapping[i];
|
||||||
if (btnid < 0) continue;
|
if (btnid < 0) continue;
|
||||||
|
|
||||||
bool pressed;
|
bool pressed = JoyButtonPressed(btnid, njoybuttons, joybuttons, hat);
|
||||||
if (btnid == 0x101) // up
|
|
||||||
pressed = (hat & SDL_HAT_UP);
|
|
||||||
else if (btnid == 0x104) // down
|
|
||||||
pressed = (hat & SDL_HAT_DOWN);
|
|
||||||
else if (btnid == 0x102) // right
|
|
||||||
pressed = (hat & SDL_HAT_RIGHT);
|
|
||||||
else if (btnid == 0x108) // left
|
|
||||||
pressed = (hat & SDL_HAT_LEFT);
|
|
||||||
else
|
|
||||||
pressed = SDL_JoystickGetButton(Joystick, btnid);
|
|
||||||
|
|
||||||
if (i == 4) // right
|
if (i == 4) // right
|
||||||
pressed = pressed || (axisX >= 16384);
|
pressed = pressed || (axisX >= 16384);
|
||||||
@ -347,6 +364,16 @@ int EmuThreadFunc(void* burp)
|
|||||||
|
|
||||||
if (pressed) joymask &= ~(1<<i);
|
if (pressed) joymask &= ~(1<<i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (JoyButtonPressed(Config::HKJoyMapping[HK_Lid], njoybuttons, joybuttons, hat))
|
||||||
|
{
|
||||||
|
LidStatus = !LidStatus;
|
||||||
|
LidCommand = true;
|
||||||
|
}
|
||||||
|
if (JoyButtonPressed(Config::HKJoyMapping[HK_Mic], njoybuttons, joybuttons, hat))
|
||||||
|
{
|
||||||
|
// microphone shit here
|
||||||
|
}
|
||||||
}
|
}
|
||||||
NDS::SetKeyMask(keymask & joymask);
|
NDS::SetKeyMask(keymask & joymask);
|
||||||
|
|
||||||
@ -480,6 +507,8 @@ int EmuThreadFunc(void* burp)
|
|||||||
|
|
||||||
EmuStatus = 0;
|
EmuStatus = 0;
|
||||||
|
|
||||||
|
if (joybuttons) delete[] joybuttons;
|
||||||
|
|
||||||
NDS::DeInit();
|
NDS::DeInit();
|
||||||
|
|
||||||
return 44203;
|
return 44203;
|
||||||
@ -629,11 +658,15 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt)
|
|||||||
if (evt->Scancode == Config::KeyMapping[i])
|
if (evt->Scancode == Config::KeyMapping[i])
|
||||||
KeyInputMask &= ~(1<<i);
|
KeyInputMask &= ~(1<<i);
|
||||||
|
|
||||||
if (evt->Scancode == 0x44) // F10, test
|
if (evt->Scancode == Config::HKKeyMapping[HK_Lid])
|
||||||
{
|
{
|
||||||
LidStatus = !LidStatus;
|
LidStatus = !LidStatus;
|
||||||
LidCommand = true;
|
LidCommand = true;
|
||||||
}
|
}
|
||||||
|
if (evt->Scancode == Config::HKKeyMapping[HK_Mic])
|
||||||
|
{
|
||||||
|
// microphone shit here
|
||||||
|
}
|
||||||
|
|
||||||
if (evt->Scancode == 0x57) // F11
|
if (evt->Scancode == 0x57) // F11
|
||||||
NDS::debug(0);
|
NDS::debug(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user