Created
November 18, 2023 09:10
-
-
Save Sainan/0d285907961a22c8cafc106aa36513e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <base.hpp> | |
#include <Buffer.hpp> | |
#include <hwHid.hpp> | |
#include <string.hpp> | |
#include <wooting_enums.hpp> | |
enum class WootingKeys : uint8_t | |
{ | |
A = 1, | |
B, | |
C, | |
D, | |
E, | |
F, | |
G, | |
H, | |
I, | |
J, | |
K, | |
L, | |
M, | |
N, | |
O, | |
P, | |
Q, | |
R, | |
S, | |
T, | |
U, | |
V, | |
W, | |
X, | |
Y, | |
Z, | |
DIGIT_1, | |
DIGIT_2, | |
DIGIT_3, | |
DIGIT_4, | |
DIGIT_5, | |
DIGIT_6, | |
DIGIT_7, | |
DIGIT_8, | |
DIGIT_9, | |
DIGIT_0, | |
// TODO | |
MUTE_VOLUME = 195, | |
INCREASE_VOLUME, | |
DECREASE_VOLUME, | |
OPEN_MEDIA_PLAYER, | |
OPEN_EMAIL_CLIENT, | |
OPEN_CALULATOR, | |
OPEN_FILEBROWSER, | |
SEARCH, | |
OPEN_BROWSER, | |
BACK_BROWSER, | |
FORWARD_BROWSER, | |
STOP_MEDIA, | |
REFRESH_BROWSER, | |
BOOKMARK_BROWSER, | |
SYSTEM_POWER, | |
SYSTEM_SLEEP, | |
_UNUSED_211, | |
MACOS_MISSION_CONTROL, | |
MACOS_LAUNCHPAD, | |
DISPLAY_BRIGHTNESS_DOWN, | |
DISPLAY_BRIGHTNESS_UP, | |
MOUSE_L, | |
MOUSE_R, | |
MOUSE_M, | |
MOUSE_4, | |
MOUSE_5, | |
_UNUSED_221, | |
_UNUSED_222, | |
_UNUSED_223, | |
INCREASE_KEYBOARD_BRIGHTNESS, | |
DECREASE_KEYBOARD_BRIGHTNESS, | |
SWITCH_TO_ANALOG_PROFILE_1, | |
SWITCH_TO_ANALOG_PROFILE_2, | |
SWITCH_TO_ANALOG_PROFILE_3, | |
SWITCH_TO_DIGITAL_PROFILE, | |
MODE_KEY_TOGGLE, | |
FN_1, | |
KEY_LOCK, | |
_UNUSED_233, | |
FN_2, | |
FN_3, | |
CYCLE, | |
IME_ON, | |
IME_OFF, | |
}; | |
using namespace soup; | |
int main() | |
{ | |
for (auto& hid : hwHid::getAll()) | |
{ | |
if (hid.usage_page == 0x1337) | |
{ | |
#if false | |
{ | |
Buffer buf(8); | |
buf.push_back(/* 0 */ 0); // HID report index | |
buf.push_back(/* 1 */ 0xD0); // Magic word | |
buf.push_back(/* 2 */ 0xDA); // Magic word | |
buf.push_back(/* 3 */ (uint8_t)WootingCommand::GetMappingProfile); | |
buf.push_back(/* 4 */ 0); | |
buf.push_back(/* 5 */ 0); | |
buf.push_back(/* 6 */ 0); | |
buf.push_back(/* 7 */ 0); | |
hid.sendFeatureReport(std::move(buf)); | |
} | |
std::cout << string::bin2hex(hid.receiveReport().toString()) << "\n"; | |
std::cout << string::bin2hex(hid.receiveReport().toString()) << "\n"; | |
std::cout << string::bin2hex(hid.receiveReport().toString()) << "\n"; | |
std::cout << string::bin2hex(hid.receiveReport().toString()) << "\n"; | |
#endif | |
/* Example response from default layer: | |
D0DA3088960A170A1526FF3738393A3B3C3D3E3F404142434544FFFFFFFF0A170A15321B1C1D1E1F20212223242A2B27464748505153540A170A152811170512 | |
141915090F102C2D2E494A4B5D5E5F550A170A15360113040607080A0B0C30312E25FFFFFF5A5B5CFF0A170A1564611A180316020E0D333435FF68FF4FFF5758 | |
59560A170A15636665FFFFFF29FFFFFF696AE7674D4E4CFF6052FF00000000000000000000000000000000000000000000000000000000000000000000000000 | |
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | |
*/ | |
// HIDDevice.prototype.sendReport = console.log; | |
uint8_t buf[] = { | |
0x00, // HID report index | |
208, 218, // magic | |
(uint8_t)WootingReport::MappingProfile, | |
1, | |
0, // layer index (0-3) | |
0, | |
0, | |
150, // [8] - num values that follow? | |
10, 23, 10, 21, // [9-12] - unsure. set to this value when the layer is in use, 0 otherwise? | |
38, 255, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, /* fn keys end */ 67, 69, 68, /* oem keys: */ 226, 227, 228, 230, | |
10, 23, 10, 21, 50, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 42, 43, 39, 70, 71, 72, 80, 81, 83, 84, 10, 23, 10, 21, 40, 17, | |
23, 5, 18, 20, 25, 21, 9, 15, 16, 44, 45, 46, 73, 74, 75, 93, 94, 95, 85, 10, 23, 10, 21, | |
54, 1, 19, 4, 6, 7, 8, 10, 11, 12, 48, 49, 46, 37, 255, 255, 255, 90, 91, 92, 255, 10, 23, 10, 21, 100, | |
97, 26, 24, 3, 22, 2, 14, 13, 51, 52, 53, 255, 104, 255, 79, 255, 87, 88, 89, 86, 10, 23, 10, 21, | |
99, 102, 101, 255, 255, 255, 41, 255, 255, 255, 105, 106, 231, 103, 77, 78, 76, 255, 96, 82, 255, | |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | |
}; | |
for (uint8_t i = 64; i != 76; ++i) | |
{ | |
//buf[i] = (i - 64) + 26; | |
} | |
// NOTE: Specific to ARM-based keyboards! | |
// For older models, need to send this one chunk. | |
// Also didn't test this on anything other than TWO HE ARM, so idk if UwU would be happy with the data at all. | |
#if false | |
for (uint8_t i = 0; i != 4; ++i) | |
{ | |
buf[i * 64] = 0; | |
hid.sendReport(&buf[i * 64], 65); | |
} | |
#endif | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment