LCtrl+LAlt+Delete = reboot

This commit is contained in:
penfold42 2018-08-03 15:39:48 +10:00
parent c55c5169dd
commit 98961a9421
2 changed files with 16 additions and 11 deletions

View File

@ -23,6 +23,7 @@
extern "C" extern "C"
{ {
#include "rpi-aux.h" #include "rpi-aux.h"
extern void reboot_now(void);
} }
// If disk swaps can be done via multiple cores then directDiskSwapRequest needs to be volatile. WARNING: volatile acesses can be very expensive. // If disk swaps can be done via multiple cores then directDiskSwapRequest needs to be volatile. WARNING: volatile acesses can be very expensive.
@ -152,6 +153,9 @@ bool InputMappings::CheckKeyboardBrowseMode()
keyboardFlags = 0; keyboardFlags = 0;
if (keyboard->KeyHeld(KEY_DELETE) && keyboard->KeyLCtrlAlt() )
reboot_now();
if (keyboard->KeyHeld(KEY_ESC)) if (keyboard->KeyHeld(KEY_ESC))
SetKeyboardFlag(ESC_FLAG); SetKeyboardFlag(ESC_FLAG);
else if (keyboard->KeyHeld(KEY_ENTER)) else if (keyboard->KeyHeld(KEY_ENTER))
@ -245,6 +249,10 @@ void InputMappings::CheckKeyboardEmulationMode(unsigned numberOfImages, unsigned
keyboardFlags = 0; keyboardFlags = 0;
if (keyboard->CheckChanged()) if (keyboard->CheckChanged())
{ {
if (keyboard->KeyHeld(KEY_DELETE) && keyboard->KeyLCtrlAlt() )
reboot_now();
if (keyboard->KeyHeld(KEY_ESC)) if (keyboard->KeyHeld(KEY_ESC))
SetKeyboardFlag(ESC_FLAG); SetKeyboardFlag(ESC_FLAG);
else if (keyboard->KeyHeld(KEY_PAGEUP)) else if (keyboard->KeyHeld(KEY_PAGEUP))

View File

@ -340,17 +340,14 @@ public:
u64 mask = 1ULL << (rawKey & 0x3f); u64 mask = 1ULL << (rawKey & 0x3f);
return (keyStatus[keyStatusIndex] & mask); return (keyStatus[keyStatusIndex] & mask);
} }
inline bool KeyAnyHeld() inline bool KeyAnyHeld()
{ { return (keyStatus[0] | keyStatus[1]); }
return (keyStatus[0] | keyStatus[1]);
} inline bool KeyEitherAlt() { return (modifier & (KEY_MOD_LALT | KEY_MOD_RALT) ); }
inline bool KeyEitherAlt()
{ inline bool KeyNoModifiers() { return (!modifier ); }
return (modifier & (KEY_MOD_LALT | KEY_MOD_RALT) );
} inline bool KeyLCtrlAlt() { return (modifier == (KEY_MOD_LALT | KEY_MOD_LCTRL) ); }
inline bool KeyNoModifiers()
{
return (!modifier );
}
}; };
#endif #endif