skraus-dev / cherryrgb-rs

Cherry RGB Keyboard - Multi platform tool to set RGB LEDs for Cherry keyboards
MIT License
41 stars 3 forks source link

RE: Available keys/mapping for each keyboard #19

Open skraus-dev opened 1 year ago

skraus-dev commented 1 year ago

The Cherry Utility for Windows holds some hardcoded per-device defaults, which describe each key and mapping.

See RESEARCH.md

Fetch device state

The function fetch_device_state (https://github.com/skraus-dev/cherryrgb-rs/blob/master/cherryrgb/src/lib.rs#L246) is currently just replaying captured requests that were sniffed.

Guesses, without having digged deeper into it

NOTE: The name fetch_device_state might be misleading - it could be very well something along the lines of set_device_state or set_key_config/mapping

Here is a captuire of the transfers:

DEBUG [cherryrgb] >> CONTROL TRANSFER "04010001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 1, inner: TransactionStart }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "03050900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
<< Failed to parse, err: bad magic at 0x0: 3

DEBUG [cherryrgb] >> CONTROL TRANSFER "04250003220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 37, inner: Unknown3 { unk: 34 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "04010001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
<< Packet { checksum: 1, inner: TransactionStart } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "043f0007380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 63, inner: Unknown7 { data_len: 56, data_offset: 0 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "043f00073800000020002920003520002b200039200200200100a0030020001e20001420000420006420080020003a20001f20001a20001620001d2004002000"
<< Packet { checksum: 63, inner: Unknown7 { data_len: 56, data_offset: 0 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "04770007383800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 119, inner: Unknown7 { data_len: 56, data_offset: 56 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "04770007383800003b20002020000820000720001b20000020003c20002120001520000920000620000020003d20002220001720000a20001920008b20003e20"
<< Packet { checksum: 119, inner: Unknown7 { data_len: 56, data_offset: 56 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "04af0007387000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 175, inner: Unknown7 { data_len: 56, data_offset: 112 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "04af000738700000002320001c20000b20000520002c20003f20002420001820000d20001120800020004020002520000c20000e20001020008a200041200026"
<< Packet { checksum: 175, inner: Unknown7 { data_len: 56, data_offset: 112 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "04e7000738a800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 231, inner: Unknown7 { data_len: 56, data_offset: 168 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "04e7000738a8000020001220000f20003620008820004220002720001320003320003720400020004320002d20002f200034200038a0010020004420002e2000"
<< Packet { checksum: 231, inner: Unknown7 { data_len: 56, data_offset: 168 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "041f010738e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 287, inner: Unknown7 { data_len: 56, data_offset: 224 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "041f010738e000003020003220008720006520004520002a20003120002820200020100020004620004920004c20008920000020005020004720004a20004d20"
<< Packet { checksum: 287, inner: Unknown7 { data_len: 56, data_offset: 224 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "04580007381801000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 88, inner: Unknown7 { data_len: 56, data_offset: 280 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "0458000738180100000020005220005120004820004b20004e20008520000020004fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000"
<< Packet { checksum: 88, inner: Unknown7 { data_len: 56, data_offset: 280 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "048200072a5001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 130, inner: Unknown7 { data_len: 42, data_offset: 336 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "048200072a500100ffffffffffffffffffffffffff0000ff0000ffffffffffffffffffffffffffffffff0000ffffffffffff0000000000000000000000000000"
<< Packet { checksum: 130, inner: Unknown7 { data_len: 42, data_offset: 336 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "0453001b380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 83, inner: Unknown1B { data_len: 56, data_offset: 0 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "0453001b38000000000102030405060708090a0b0c0d0e0f10111213141516ff18191a1b1cff1e1f202122232425262728292a2b2c2d2e2f3031323334353637"
<< Packet { checksum: 83, inner: Unknown1B { data_len: 56, data_offset: 0 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "048b001b383800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 139, inner: Unknown1B { data_len: 56, data_offset: 56 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "048b001b3838000038393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f5051525354555657ff595a5b5cff5e5f6061627bff6500000000000000000000"
<< Packet { checksum: 139, inner: Unknown1B { data_len: 56, data_offset: 56 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "0499001b0e7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 153, inner: Unknown1B { data_len: 14, data_offset: 112 } }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "0499001b0e7000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
<< Packet { checksum: 153, inner: Unknown1B { data_len: 14, data_offset: 112 } } Checksum valid: Ok(())

DEBUG [cherryrgb] >> CONTROL TRANSFER "04020002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
>> Packet { checksum: 2, inner: TransactionEnd }

DEBUG [cherryrgb] << INTERRUPT TRANSFER "04020002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
<< Packet { checksum: 2, inner: TransactionEnd } Checksum valid: Ok(())
felfert commented 1 year ago

Perhaps this should be moved into a separate doc (just like the compatibility map). This makes it easier to collaborate by editing and submit pull requests. Also: Maybe all those supplemental docs should go into some subdir.

skraus-dev commented 1 year ago

Perhaps this should be moved into a separate doc (just like the compatibility map).

The steps to download / extract the files from windows cherry utility were moved into a new document, RESEARCH.md

This makes it easier to collaborate by editing and submit pull requests.

Agree. For specific functionality that are subject to discuss, I would like to keep logs/notes inside the respective issues. When they reach a level of agreement / deeper understanding, they can be written down in

https://github.com/skraus-dev/cherryrgb-rs/blob/master/docs/PROTOCOL.md

Also: Maybe all those supplemental docs should go into some subdir.

At first I wanted to keep them in the top-level.. but at this point its starting to make sense to have them seperated. Done ;)

felfert commented 1 year ago

Perhaps a related idea: