Skip to content

Commit

Permalink
BadBLE Fix for non releasing ALT_GR key
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorcelli committed Oct 8, 2024
1 parent 993409f commit 12c8539
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/Bad_Usb_Lib/BleKeyboard.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "BleKeyboard.h"
#include "KeyboardLayout.h"

#if defined(USE_NIMBLE)
#include <NimBLEDevice.h>
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 12c8539

Please sign in to comment.