From 98961a94215e1f0e63e11a14df8440abd215c0cc Mon Sep 17 00:00:00 2001 From: penfold42 Date: Fri, 3 Aug 2018 15:39:48 +1000 Subject: [PATCH] LCtrl+LAlt+Delete = reboot --- src/InputMappings.cpp | 8 ++++++++ src/Keyboard.h | 19 ++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/InputMappings.cpp b/src/InputMappings.cpp index a300ede..3f2a1e0 100644 --- a/src/InputMappings.cpp +++ b/src/InputMappings.cpp @@ -23,6 +23,7 @@ extern "C" { #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. @@ -152,6 +153,9 @@ bool InputMappings::CheckKeyboardBrowseMode() keyboardFlags = 0; + if (keyboard->KeyHeld(KEY_DELETE) && keyboard->KeyLCtrlAlt() ) + reboot_now(); + if (keyboard->KeyHeld(KEY_ESC)) SetKeyboardFlag(ESC_FLAG); else if (keyboard->KeyHeld(KEY_ENTER)) @@ -245,6 +249,10 @@ void InputMappings::CheckKeyboardEmulationMode(unsigned numberOfImages, unsigned keyboardFlags = 0; if (keyboard->CheckChanged()) { + + if (keyboard->KeyHeld(KEY_DELETE) && keyboard->KeyLCtrlAlt() ) + reboot_now(); + if (keyboard->KeyHeld(KEY_ESC)) SetKeyboardFlag(ESC_FLAG); else if (keyboard->KeyHeld(KEY_PAGEUP)) diff --git a/src/Keyboard.h b/src/Keyboard.h index 774ef6c..2a62ddd 100644 --- a/src/Keyboard.h +++ b/src/Keyboard.h @@ -340,17 +340,14 @@ public: u64 mask = 1ULL << (rawKey & 0x3f); return (keyStatus[keyStatusIndex] & mask); } + inline bool KeyAnyHeld() - { - return (keyStatus[0] | keyStatus[1]); - } - inline bool KeyEitherAlt() - { - return (modifier & (KEY_MOD_LALT | KEY_MOD_RALT) ); - } - inline bool KeyNoModifiers() - { - return (!modifier ); - } + { return (keyStatus[0] | keyStatus[1]); } + + inline bool KeyEitherAlt() { return (modifier & (KEY_MOD_LALT | KEY_MOD_RALT) ); } + + inline bool KeyNoModifiers() { return (!modifier ); } + + inline bool KeyLCtrlAlt() { return (modifier == (KEY_MOD_LALT | KEY_MOD_LCTRL) ); } }; #endif