Skip to content

Commit

Permalink
Make extra keys usable in keyboard mode (OpenStickCommunity#1128)
Browse files Browse the repository at this point in the history
* Add E1 button as a test

* Add remaining Extra keys to KeyboardMapping

* Add support for E1-12 buttons in input history

* Revert "Add support for E1-12 buttons in input history"

This reverts commit bd21be6.

* Update KeyboardMapping enum, re-order merged lines
  • Loading branch information
rmaccrimm authored Sep 20, 2024
1 parent 96e97b2 commit f26f03c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
13 changes: 13 additions & 0 deletions proto/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ message KeyboardMapping
optional uint32 keyButtonA2 = 18;
optional uint32 keyButtonA3 = 19;
optional uint32 keyButtonA4 = 20;
optional uint32 keyButtonE1 = 21;
optional uint32 keyButtonE2 = 22;
optional uint32 keyButtonE3 = 23;
optional uint32 keyButtonE4 = 24;
optional uint32 keyButtonE5 = 25;
optional uint32 keyButtonE6 = 26;
optional uint32 keyButtonE7 = 27;
optional uint32 keyButtonE8 = 28;
optional uint32 keyButtonE9 = 29;
optional uint32 keyButtonE10 = 30;
optional uint32 keyButtonE11 = 31;
optional uint32 keyButtonE12 = 32;

}

message HotkeyEntry
Expand Down
26 changes: 25 additions & 1 deletion src/configs/webconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,18 @@ std::string setKeyMappings()
readDoc(keyboardMapping.keyButtonA2, doc, "A2");
readDoc(keyboardMapping.keyButtonA3, doc, "A3");
readDoc(keyboardMapping.keyButtonA4, doc, "A4");
readDoc(keyboardMapping.keyButtonE1, doc, "E1");
readDoc(keyboardMapping.keyButtonE2, doc, "E2");
readDoc(keyboardMapping.keyButtonE3, doc, "E3");
readDoc(keyboardMapping.keyButtonE4, doc, "E4");
readDoc(keyboardMapping.keyButtonE5, doc, "E5");
readDoc(keyboardMapping.keyButtonE6, doc, "E6");
readDoc(keyboardMapping.keyButtonE7, doc, "E7");
readDoc(keyboardMapping.keyButtonE8, doc, "E8");
readDoc(keyboardMapping.keyButtonE9, doc, "E9");
readDoc(keyboardMapping.keyButtonE10, doc, "E10");
readDoc(keyboardMapping.keyButtonE11, doc, "E11");
readDoc(keyboardMapping.keyButtonE12, doc, "E12");

Storage::getInstance().save();

Expand Down Expand Up @@ -1164,7 +1176,19 @@ std::string getKeyMappings()
writeDoc(doc, "A2", keyboardMapping.keyButtonA2);
writeDoc(doc, "A3", keyboardMapping.keyButtonA3);
writeDoc(doc, "A4", keyboardMapping.keyButtonA4);

writeDoc(doc, "E1", keyboardMapping.keyButtonE1);
writeDoc(doc, "E2", keyboardMapping.keyButtonE2);
writeDoc(doc, "E3", keyboardMapping.keyButtonE3);
writeDoc(doc, "E4", keyboardMapping.keyButtonE4);
writeDoc(doc, "E5", keyboardMapping.keyButtonE5);
writeDoc(doc, "E6", keyboardMapping.keyButtonE6);
writeDoc(doc, "E7", keyboardMapping.keyButtonE7);
writeDoc(doc, "E8", keyboardMapping.keyButtonE8);
writeDoc(doc, "E9", keyboardMapping.keyButtonE9);
writeDoc(doc, "E10", keyboardMapping.keyButtonE10);
writeDoc(doc, "E11", keyboardMapping.keyButtonE11);
writeDoc(doc, "E12", keyboardMapping.keyButtonE12);

return serialize_json(doc);
}

Expand Down
12 changes: 12 additions & 0 deletions src/drivers/keyboard/KeyboardDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,18 @@ void KeyboardDriver::process(Gamepad * gamepad) {
if(gamepad->pressedR3()) { pressKey(keyboardMapping.keyButtonR3); }
if(gamepad->pressedA1()) { pressKey(keyboardMapping.keyButtonA1); }
if(gamepad->pressedA2()) { pressKey(keyboardMapping.keyButtonA2); }
if(gamepad->pressedE1()) { pressKey(keyboardMapping.keyButtonE1); }
if(gamepad->pressedE2()) { pressKey(keyboardMapping.keyButtonE2); }
if(gamepad->pressedE3()) { pressKey(keyboardMapping.keyButtonE3); }
if(gamepad->pressedE4()) { pressKey(keyboardMapping.keyButtonE4); }
if(gamepad->pressedE5()) { pressKey(keyboardMapping.keyButtonE5); }
if(gamepad->pressedE6()) { pressKey(keyboardMapping.keyButtonE6); }
if(gamepad->pressedE7()) { pressKey(keyboardMapping.keyButtonE7); }
if(gamepad->pressedE8()) { pressKey(keyboardMapping.keyButtonE8); }
if(gamepad->pressedE9()) { pressKey(keyboardMapping.keyButtonE9); }
if(gamepad->pressedE10()) { pressKey(keyboardMapping.keyButtonE10); }
if(gamepad->pressedE11()) { pressKey(keyboardMapping.keyButtonE11); }
if(gamepad->pressedE12()) { pressKey(keyboardMapping.keyButtonE12); }

// Wake up TinyUSB device
if (tud_suspended())
Expand Down

0 comments on commit f26f03c

Please sign in to comment.