From 12c85390e445203f435273809376cd7945c72031 Mon Sep 17 00:00:00 2001 From: Pirata Date: Tue, 8 Oct 2024 14:30:34 -0300 Subject: [PATCH] BadBLE Fix for non releasing ALT_GR key https://github.com/pr3y/Bruce/issues/322 --- lib/Bad_Usb_Lib/BleKeyboard.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Bad_Usb_Lib/BleKeyboard.cpp b/lib/Bad_Usb_Lib/BleKeyboard.cpp index 5b16f8d0..3b9a48d4 100644 --- a/lib/Bad_Usb_Lib/BleKeyboard.cpp +++ b/lib/Bad_Usb_Lib/BleKeyboard.cpp @@ -1,4 +1,5 @@ #include "BleKeyboard.h" +#include "KeyboardLayout.h" #if defined(USE_NIMBLE) #include @@ -308,12 +309,16 @@ size_t BleKeyboard::release(uint8_t k) if (!k) { return 0; } - if (k & 0x80) { // it's a capital letter or other character reached with shift + if ((k & ALT_GR) == ALT_GR) { + _keyReport.modifiers &= ~(0x40); // AltGr = right Alt + k &= 0x3F; + } else if ((k & SHIFT) == SHIFT) { _keyReport.modifiers &= ~(0x02); // the left shift modifier k &= 0x7F; } - if (k == 0x32) //ISO_REPLACEMENT - k = 0x64; //ISO_KEY + if (k == ISO_REPLACEMENT) { + k = ISO_KEY; + } } // Test the key report to see if k is present. Clear it if it exists.