M913: Implement button mappings a-z

This commit is contained in:
dokutan 2022-01-03 16:03:31 +01:00
parent a1fac5dba1
commit 010169acd2
3 changed files with 46 additions and 15 deletions

View file

@ -17,3 +17,4 @@ How to map a button on the M913 (M686) as a keyboard key:
5, 6, 7, 8 = modifiers
8, 11 = keyboard key
13, 14 = checksum? if this value is incorrect the mapping will fail
16 = physical button

View file

@ -29,6 +29,7 @@ dpi5=16000
# left, middle, right, forward, back
# led_toggle, report_rate, default, none
# dpi-, dpi+, dpi-cycle
# a-z
button_left=left
button_right=right
button_middle=middle

View file

@ -52,22 +52,22 @@ std::map< int, std::string > mouse_m913::_c_button_names = {
};
std::map< int, std::array<uint8_t, 3> > mouse_m913::_c_keyboard_key_buttons = {
{ 0, {0xff, 0xff, 0xff} }, // button_1 TODO!
{ 1, {0xff, 0xff, 0xff} }, // button_2 TODO!
{ 2, {0xff, 0xff, 0xff} }, // button_3 TODO!
{ 3, {0xff, 0xff, 0xff} }, // button_4 TODO!
{ 4, {0xff, 0xff, 0xff} }, // button_5 TODO!
{ 0, {0x01, 0x00, 0xe8} }, // button_1
{ 1, {0x01, 0x20, 0xc8} }, // button_2
{ 2, {0x01, 0x40, 0xa8} }, // button_3
{ 3, {0x01, 0x60, 0x88} }, // button_4
{ 4, {0x01, 0x80, 0x68} }, // button_5
{ 5, {0x01, 0xa0, 0x48} }, // button_6
{ 6, {0xff, 0xff, 0xff} }, // button_right TODO!
{ 7, {0xff, 0xff, 0xff} }, // button_left TODO!
{ 6, {0x01, 0xc0, 0x28} }, // button_right
{ 7, {0x01, 0xe0, 0x08} }, // button_left
{ 8, {0x02, 0x00, 0xe7} }, // button_7
{ 9, {0xff, 0xff, 0xff} }, // button_8 TODO!
{ 10, {0xff, 0xff, 0xff} }, // button_middle TODO!
{ 11, {0xff, 0xff, 0xff} }, // button_fire TODO!
{ 12, {0xff, 0xff, 0xff} }, // button_9 TODO!
{ 13, {0xff, 0xff, 0xff} }, // button_10 TODO!
{ 14, {0xff, 0xff, 0xff} }, // button_11 TODO!
{ 15, {0xff, 0xff, 0xff} }, // button_12 TODO!
{ 9, {0x02, 0x20, 0xc7} }, // button_8
{ 10, {0x02, 0x40, 0xa7} }, // button_middle
{ 11, {0x02, 0x60, 0x87} }, // button_fire
{ 12, {0x02, 0x80, 0x67} }, // button_9
{ 13, {0x02, 0xa0, 0x47} }, // button_10
{ 14, {0x02, 0xc0, 0x27} }, // button_11
{ 15, {0x02, 0xe0, 0x07} }, // button_12
};
std::map< std::string, std::array<uint8_t, 4> > mouse_m913::_c_keycodes = {
@ -86,10 +86,39 @@ std::map< std::string, std::array<uint8_t, 4> > mouse_m913::_c_keycodes = {
{ "profile_switch", { 0x09, 0x00, 0x00, 0x4c } },
};
// see documentation/m913-key-press.txt for a description of these packets
/* see documentation/m913-key-press.txt for a description of these packets, generated with:
#!/usr/bin/env julia
for i in [0:25;]
println("{ \"", Char('a'+i), "\", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x", string(4+i, base=16, pad=2), ", 0x00, 0x41, 0x", string(4+i, base=16, pad=2), ", 0x00, 0x", string(0x89 - 2*i, base=16, pad=2), ", 0x00, 0x00, 0x48} },")
end
*/
std::map< std::string, std::array<uint8_t, 17> > mouse_m913::_c_keyboard_key_packets = {
{ "a", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x04, 0x00, 0x41, 0x04, 0x00, 0x89, 0x00, 0x00, 0x48} },
{ "b", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x05, 0x00, 0x41, 0x05, 0x00, 0x87, 0x00, 0x00, 0x48} },
{ "c", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x06, 0x00, 0x41, 0x06, 0x00, 0x85, 0x00, 0x00, 0x48} },
{ "d", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x07, 0x00, 0x41, 0x07, 0x00, 0x83, 0x00, 0x00, 0x48} },
{ "e", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x08, 0x00, 0x41, 0x08, 0x00, 0x81, 0x00, 0x00, 0x48} },
{ "f", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x09, 0x00, 0x41, 0x09, 0x00, 0x7f, 0x00, 0x00, 0x48} },
{ "g", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x0a, 0x00, 0x41, 0x0a, 0x00, 0x7d, 0x00, 0x00, 0x48} },
{ "h", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x0b, 0x00, 0x41, 0x0b, 0x00, 0x7b, 0x00, 0x00, 0x48} },
{ "i", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x0c, 0x00, 0x41, 0x0c, 0x00, 0x79, 0x00, 0x00, 0x48} },
{ "j", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x0d, 0x00, 0x41, 0x0d, 0x00, 0x77, 0x00, 0x00, 0x48} },
{ "k", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x0e, 0x00, 0x41, 0x0e, 0x00, 0x75, 0x00, 0x00, 0x48} },
{ "l", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x0f, 0x00, 0x41, 0x0f, 0x00, 0x73, 0x00, 0x00, 0x48} },
{ "m", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x10, 0x00, 0x41, 0x10, 0x00, 0x71, 0x00, 0x00, 0x48} },
{ "n", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x11, 0x00, 0x41, 0x11, 0x00, 0x6f, 0x00, 0x00, 0x48} },
{ "o", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x12, 0x00, 0x41, 0x12, 0x00, 0x6d, 0x00, 0x00, 0x48} },
{ "p", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x13, 0x00, 0x41, 0x13, 0x00, 0x6b, 0x00, 0x00, 0x48} },
{ "q", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x14, 0x00, 0x41, 0x14, 0x00, 0x69, 0x00, 0x00, 0x48} },
{ "r", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x15, 0x00, 0x41, 0x15, 0x00, 0x67, 0x00, 0x00, 0x48} },
{ "s", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x16, 0x00, 0x41, 0x16, 0x00, 0x65, 0x00, 0x00, 0x48} },
{ "t", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x17, 0x00, 0x41, 0x17, 0x00, 0x63, 0x00, 0x00, 0x48} },
{ "u", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x18, 0x00, 0x41, 0x18, 0x00, 0x61, 0x00, 0x00, 0x48} },
{ "v", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x19, 0x00, 0x41, 0x19, 0x00, 0x5f, 0x00, 0x00, 0x48} },
{ "w", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x1a, 0x00, 0x41, 0x1a, 0x00, 0x5d, 0x00, 0x00, 0x48} },
{ "x", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x1b, 0x00, 0x41, 0x1b, 0x00, 0x5b, 0x00, 0x00, 0x48} },
{ "y", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x1c, 0x00, 0x41, 0x1c, 0x00, 0x59, 0x00, 0x00, 0x48} },
{ "z", {0x08, 0x07, 0x00, 0x01, 0xa0, 0x08, 0x02, 0x81, 0x1d, 0x00, 0x41, 0x1d, 0x00, 0x57, 0x00, 0x00, 0x48} },
};
// DPI → bytecode