kriomant / ch57x-keyboard-tool

Utility for programming ch57x small keyboard
MIT License
533 stars 65 forks source link

Supporting 1189:8840 #60

Open pferreir opened 8 months ago

pferreir commented 8 months ago

I have one of those, which don't seem to work with this tool.

$ sudo RUST_LOG=debug .cargo/bin/ch57x-keyboard-tool --vendor-id 0x1189 --product-id 0x8840 upload < mapping.yaml
[...]
[2024-02-24T13:53:23Z DEBUG ch57x_keyboard_tool] Bus 001 Device 012 ID 1189:8840
[...]
[2024-02-24T13:53:23Z DEBUG ch57x_keyboard_tool::keyboard] send: [03, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00]
Error: init keyboard

Caused by:
    Invalid parameter

Any way I can figure out what is going on?

The lettering on the MCU seems to have been sanded off, unfortunately.

image

Is there anything I can do to help reverse-engineer this variant?

kriomant commented 8 months ago

Product ID is different. Can it be programmed with some software? If yes, it's possible to reverse-engineer it using wireshark + usb plugin.

pferreir commented 8 months ago

There is some Windows software which is supposed to work, and I tried to run it on Wine with no success. I'll try it on a real windows machine. I just wanted to avoid running potential malware.

On Sun, 25 Feb 2024, 06:25 Mikhail Trishchenkov, @.***> wrote:

Product ID is different. Can it be programmed with some software? If yes, it's possible to reverse-engineer it using wireshark + usb plugin.

— Reply to this email directly, view it on GitHub https://github.com/kriomant/ch57x-keyboard-tool/issues/60#issuecomment-1962818551, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAVCZZ2Z4YF2XRYOASNK3YVLDNPAVCNFSM6AAAAABDYKRP5WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRSHAYTQNJVGE . You are receiving this because you authored the thread.Message ID: @.***>

djipaul commented 8 months ago

Hi, Same issue here. Unable to programm it because of "Invalid Parameter" message.. Device Manger shows exactly the same Product ID than @pferreir. (https://imgur.com/a/uPrm2RG)

Interesting because the Keyboard looks identical to that of the readme.. (https://imgur.com/a/Bxxx5mN)

Anything we could try?

pferreir commented 8 months ago

I think I figured it out. The interface which is being used by default (0) is not the right one on my device. If I change that to 1 in the code, the device starts accepting instructions. However, the protocol also seems slightly different, from what I see in the Wireshark dumps. More news later.

On Sun, 25 Feb 2024, 18:25 djipaul, @.***> wrote:

Hi, Same issue here. Unable to programm it because of "Invalid Parameter" message.. Device Manger shows exactly the same Product ID than @pferreir https://github.com/pferreir. (https://imgur.com/a/uPrm2RG)

Interesting because the Keyboard looks identical to that of the readme.. (https://imgur.com/a/Bxxx5mN)

Anything we could try?

— Reply to this email directly, view it on GitHub https://github.com/kriomant/ch57x-keyboard-tool/issues/60#issuecomment-1963006192, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAVCZHCEBGVDUGXR3RDB3YVNXXNAVCNFSM6AAAAABDYKRP5WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRTGAYDMMJZGI . You are receiving this because you were mentioned.Message ID: @.***>

pferreir commented 8 months ago

@djipaul could you try compiling and running this branch?

You need to run it like so:

cargo run -- --vendor-id 0x1189 --product-id 0x8840 --endpoint-address 4 --interface-number 0 upload < mapping.yaml

It does work fine for me, so that's already a win.

djipaul commented 8 months ago

Would be happy to test it, although I can not compil it myself. So would it be possible to give me a prebuilt version wich I could run? Thanks!

hchastelaramis commented 8 months ago

Hello there! I'm stuck like you with my mac and the new product ID:

          Product ID: 0x8840
          Vendor ID: 0x1189  (Trisat Industrial Co., Ltd.)
          Version: 1.00
          Serial Number: CD70134330363135
          Speed: Up to 12 Mb/s
          Location ID: 0x02100000 / 2
          Current Available (mA): 500
          Current Required (mA): 100
          Extra Operating Current (mA): 0

I tried to run the following with the last release:

➜  ch57x-keyboard-tool-universal-apple-darwin sudo ch57x-keyboard-tool --vendor-id 0x1189 --product-id 0x8840 upload < your-config.yaml
Error: init keyboard

Caused by:
    Invalid parameter

And then I found @pferreir 's post and tried

➜  ch57x-keyboard-tool git:(master) ✗ cargo run -- --vendor-id 0x1189 --product-id 0x8840 --endpoint-address 4 --interface-number 0 upload < your-config.yaml
    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/ch57x-keyboard-tool --vendor-id 0x1189 --product-id 0x8840 --endpoint-address 4 --interface-number 0 upload`
error: Found argument '--interface-number' which wasn't expected, or isn't valid in this context

Usage: ch57x-keyboard-tool <--vendor-id <VENDOR_ID>|--product-id <PRODUCT_ID>|--address <ADDRESS>|--endpoint-address <ENDPOINT_ADDRESS>> <COMMAND>

For more information try '--help'

Can't go any further as I don't want to download the shady PC tool :(

pferreir commented 8 months ago

You need to compile my branch, otherwise it won't work.

On Mon, 26 Feb 2024, 16:00 Hugues Chastel, @.***> wrote:

Hello there! I'm stuck like you with my mac and the new product ID:

      Product ID: 0x8840
      Vendor ID: 0x1189  (Trisat Industrial Co., Ltd.)
      Version: 1.00
      Serial Number: CD70134330363135
      Speed: Up to 12 Mb/s
      Location ID: 0x02100000 / 2
      Current Available (mA): 500
      Current Required (mA): 100
      Extra Operating Current (mA): 0

I tried to run the following with the last release:

➜ ch57x-keyboard-tool-universal-apple-darwin sudo ch57x-keyboard-tool --vendor-id 0x1189 --product-id 0x8840 upload < your-config.yaml Error: init keyboard

Caused by: Invalid parameter

And then I found @pferreir https://github.com/pferreir 's post and tried

➜ ch57x-keyboard-tool git:(master) ✗ cargo run -- --vendor-id 0x1189 --product-id 0x8840 --endpoint-address 4 --interface-number 0 upload < your-config.yaml Finished dev [unoptimized + debuginfo] target(s) in 0.05s Running target/debug/ch57x-keyboard-tool --vendor-id 0x1189 --product-id 0x8840 --endpoint-address 4 --interface-number 0 upload error: Found argument '--interface-number' which wasn't expected, or isn't valid in this context

Usage: ch57x-keyboard-tool <--vendor-id |--product-id |--address

|--endpoint-address >

For more information try '--help'

Can't go any further as I don't want to download the shady PC tool :(

— Reply to this email directly, view it on GitHub https://github.com/kriomant/ch57x-keyboard-tool/issues/60#issuecomment-1964350844, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAVC77ADZ3BUKHIH4RO6LYVSPRVAVCNFSM6AAAAABDYKRP5WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRUGM2TAOBUGQ . You are receiving this because you were mentioned.Message ID: @.***>

hchastelaramis commented 8 months ago

That's what I did, I cloned your branch and ran this. I forgot to mention it on my comment

hchastelaramis commented 8 months ago

my bad, I was on master. Not a dev here! Thanks it works! You are the best

pferreir commented 8 months ago

Glad to hear! I will have to fix a few things, and then if @kriomant agrees, I will open a PR.

djipaul commented 8 months ago

@hchastelaramis could you explain what you have done, to compile that branch? Would be amazing.

hchastelaramis commented 8 months ago

@hchastelaramis could you explain what you have done, to compile that branch? Would be amazing.

Sure! First make sure to install rustup You need to clone @pferreir s project and move to his wip branch

git clone git@github.com:pferreir/ch57x-keyboard-tool.git
git checkout support-8840-wip

And then you can run the command directly to compile and run:

sudo cargo run -- --vendor-id 0x1189 --product-id 0x8840 --endpoint-address 4 --interface-number 0 upload < your-config.yaml
hchastelaramis commented 8 months ago

Only problem here, but I don't know if it's related, When the keyboard is wired, I can program my keys (I'm using it to control a googleMeet meeting) and it works fine as long as it's kept plugged But when I unplug the controller, the keys mapping seem to be forgotten and I need to do the programming again. I'm using the bluetooth 1 knob, 2 rows, 3 columns I bought on aliExpress.

kriomant commented 8 months ago

Glad to hear! I will have to fix a few things, and then if @kriomant agrees, I will open a PR.

I'm ready to incorporate support for another keyboard variation, but not the way used in branch. Too many copy-paste, no automatic keyboard detection. You may open PR and we'll polish code there.

djipaul commented 8 months ago

@hchastelaramis Thanks for that! Yes same thing for me, it worked until I unplug the Keyboard, than the Mapping seems to have gone. Until that is works perfectly fine. Hope that this also can be fixed.

pferreir commented 8 months ago

@kriomant glad to do automatic detection. Not sure what you mean with "copy-paste", but I'll open the PR and we can discuss how to proceed.

pferreir commented 8 months ago

@djipaul @hchastelaramis I tried plugging and unplugging and the settings seem to persist... maybe an issue with your hardware?

djipaul commented 8 months ago

Maybe @hchastelaramis can say something different, but for me the mapping is always gone after I unplug the keyboard. Tried now to flash on 2 different PCs but the problem still exists.

damnkrat commented 8 months ago

@djipaul could you try compiling and running this branch?

@pferreir tried to compile on Linux and got error

❯ cargo run -- --vendor-id 0x1189 --product-id 0x8840 --endpoint-address 4 --interface-number 0 upload
   Compiling rustix v0.36.6
error[E0554]: `#![feature]` may not be used on the stable release channel
  --> /home/dannkunt/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustix-0.36.6/src/lib.rs:99:26
   |
99 | #![cfg_attr(rustc_attrs, feature(rustc_attrs))]
   |                          ^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
   --> /home/dannkunt/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustix-0.36.6/src/lib.rs:116:5
    |
116 |     feature(core_intrinsics)
    |     ^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
   --> /home/dannkunt/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustix-0.36.6/src/lib.rs:116:13
    |
116 |     feature(core_intrinsics)
    |             ^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0554`.
error: could not compile `rustix` (lib) due to 3 previous errors
EagleonePrimo commented 8 months ago

@pferreir I has similar model one with vendor-id 0x514c and product-id 0x8842 buttons is work fine (I think so, I haven't tested it in detail yet.). but on knobs It hasn't been programmed. it still be factory bind. any idea. 20240302_172447

thomas-louvigne commented 8 months ago

@EagleonePrimo : i got the same, if it works, tell me !

damnkrat commented 8 months ago

@pferreir I has similar model one with vendor-id 0x514c and product-id 0x8842 buttons is work fine (I think so, I haven't tested it in detail yet.). but on knobs It hasn't been programmed. it still be factory bind. any idea. 20240302_172447

My work(redirection to another driver). It is 8442

EagleonePrimo commented 8 months ago

@EagleonePrimo : i got the same, if it works, tell me !

I tested everything I could. No luck It only work on first layer of key and try to rotate orientation and it completely broken.

pferreir commented 8 months ago

@EagleonePrimo no idea. We'd need to see what is being transmitted in the wire. I set up a VM with Windows and then used wireshark to sniff USB traffic while using the "official" programming tool. It's not a hard thing to do, you could just give us a dump of the data and that would be enough to figure out what is going on.

damnkrat commented 8 months ago

@EagleonePrimo What's in your mapping.yaml. My device with same params working.

Try mine and report does it work (remove .txt) mapping.yaml.txt

kamaaina commented 8 months ago

@pferreir stumbled across your branch and it works for me with 0x8840, thanks for sharing! @kriomant thanks for starting this project, i am learning a lot from looking through your code. i have a few variants as well, so i'll be glad to help test when things get merged in

Trobeloo commented 8 months ago

@pferreir thank you with your PR I was able to use this 5×3 with 3 knobs device: ch57x-keyboard-tool.exe --vendor-id 0x1189 --product-id 0x8840 --endpoint-address 4 --interface-number 0 upload < Mapping.yaml image

EagleonePrimo commented 8 months ago

@EagleonePrimo What's in your mapping.yaml. My device with same params working.

Try mine and report does it work (remove .txt) mapping.yaml.txt

sorry for this late. but same result. it only work on first layer of config other layer still factory config.

EagleonePrimo commented 8 months ago

@EagleonePrimo no idea. We'd need to see what is being transmitted in the wire. I set up a VM with Windows and then used wireshark to sniff USB traffic while using the "official" programming tool. It's not a hard thing to do, you could just give us a dump of the data and that would be enough to figure out what is going on.

I want to do that. But I don't have enough time to investigate in detail. I hope to have some free time to do it.

JamesConlan96 commented 7 months ago

Only problem here, but I don't know if it's related, When the keyboard is wired, I can program my keys (I'm using it to control a googleMeet meeting) and it works fine as long as it's kept plugged But when I unplug the controller, the keys mapping seem to be forgotten and I need to do the programming again. I'm using the bluetooth 1 knob, 2 rows, 3 columns I bought on aliExpress.

Did you manage to fix this in the end? I'm experiencing the same issue.

snowSBA commented 7 months ago

@pferreir Thank you for sharing your branch! I used it for my 1189:8842 device (4x3 keys + 2 knobs) with the help of this thread and it worked for all the keys and knobs. Additionally, it was able to retain the programmed keys after I unplugged it, though I'm not sure if the fact it is actively connected via bluetooth has anything to do with that. Maybe this is something device specific.

The only issue I encountered is that I am mapping single modifier keys, intending to use them simultaneously with other keys, but that doesn't work. For example, I map key 1 to shift and key 2 to 'a'. Holding key 1 with key 2 won't give me uppercase 'A' because the up event for key 1 is forcefully triggered the moment another key is pressed (the log shows key1 down -> key1 up -> key2 down -> key2 up). I am on a mac so I ended up going back to the original tool linked in the product page by running it in Parallels, which allowed programmed keys to be used simultaneously. Wondering if anyone has the same experience and if there's a solution to that somewhere.

REXDES commented 7 months ago

Any follow-up on this issue? I have the 4x3 with 2 knobs keyboard, but it following the orientations in this thread doesn`t seem to work in my case. Tried in both @pferreir and @kriomant branches, but it does not seem to recognize my keyboard... my mapping.yaml file is only 1 layer, binding F13-F24 keys to the keyboard

Here is what shows up in my terminal:

$ cargo run -- --vendor-id 0x1189 --product-id 0x8840 --endpoint-address 4 --interface-number 0 upload < mapping.yaml
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s
     Running `target\debug\ch57x-keyboard-tool.exe --vendor-id 0x1189 --product-id 0x8840 --endpoint-address 4 --interface-number 0 upload`
Error: find USB device

Caused by:
    CH57x keyboard device not found. Use --vendor-id and --product-id to override settings.
error: process didn't exit successfully: `target\debug\ch57x-keyboard-tool.exe --vendor-id 0x1189 --product-id 0x8840 --endpoint-address 4 --interface-number 0 upload` (exit code: 1)

if I try to compile the code without inserting parameters, i get this:

$ ch57x-keyboard-tool upload < mapping.yaml
Error: unexpected interface parameters: InterfaceDescriptor {
    bLength: 9,
    bDescriptorType: 4,
    bInterfaceNumber: 0,
    bAlternateSetting: 0,
    bNumEndpoints: 1,
    bInterfaceClass: 3,
    bInterfaceSubClass: 1,
    bInterfaceProtocol: 1,
    iInterface: 0,
}

...Even though the keyboard exists in the USB devices index as

USB Composite Device | USB\VID_1189&PID_8890\5&2CF64626&0&9 | (Standard USB Host Controller) | OK

kamaaina commented 6 months ago

to all those who have reported the issue about the device losing programming when disconnected, i have a fix for that. i will incorporate that fix when i finish the reading of the configuration of the device that i'm currently working on referenced here

kamaaina commented 6 months ago

until code changes get refactored and merged in, you can try using this tool. https://github.com/kamaaina/macropad_tool

simon-something commented 6 months ago

until code changes get refactored and merged in, you can try using this tool. https://github.com/kamaaina/macropad_tool

I added the "termination" signal you've been adding to a quick fork of this repo @kamaaina, but couldn't make my configuration persisting when unplugging.

Where did you find this signal? wireshark? Where they really 65 long (tried 64 without success neither tho)? I will try to sniff locally too, maybe there are some different protocol co-existing

Thanks for this nice repo @kriomant , pretty cool!

kamaaina commented 6 months ago

@drgorillamd - did my tool work for you? what type of macropad do you have?

simon-something commented 6 months ago

So it's even weirder, I'm on 1189:8840 too (so kinda relevant to this issue) and noticed:

kamaaina commented 6 months ago

right, that is one of the many changes i've made in my repo as you can see it here All programming of keys should be sent with 0xfd

Therefore, I was asking if you tried compiling and using my repo to make your changes and see if they persist? It works for me and my macropads and since you have the same one, it should work for you as well.

simon-something commented 6 months ago

@pferreir Thank you for sharing your branch! I used it for my 1189:8842 device (4x3 keys + 2 knobs) with the help of this thread and it worked for all the keys and knobs. Additionally, it was able to retain the programmed keys after I unplugged it, though I'm not sure if the fact it is actively connected via bluetooth has anything to do with that. Maybe this is something device specific.

The only issue I encountered is that I am mapping single modifier keys, intending to use them simultaneously with other keys, but that doesn't work. For example, I map key 1 to shift and key 2 to 'a'. Holding key 1 with key 2 won't give me uppercase 'A' because the up event for key 1 is forcefully triggered the moment another key is pressed (the log shows key1 down -> key1 up -> key2 down -> key2 up). I am on a mac so I ended up going back to the original tool linked in the product page by running it in Parallels, which allowed programmed keys to be used simultaneously. Wondering if anyone has the same experience and if there's a solution to that somewhere.

@snowSBA I fixed this in the PR #77 feel free to check it out!

simon-something commented 6 months ago

right, that is one of the many changes i've made in my repo as you can see it here All programming of keys should be sent with 0xfd

Therefore, I was asking if you tried compiling and using my repo to make your changes and see if they persist? It works for me and my macropads and since you have the same one, it should work for you as well.

As mentioned, this byte didn't change anything noticeable on my side (both 0xfd and 0xfe are part of persisting config, without issue), same as with or without the extra end-packet. Maybe something in the very first interactions between the original software and keyboard? I didn't capture these unfortunately

You've made some nice additions @kamaaina , why not opening some PR with them:)?

kamaaina commented 6 months ago

at first, i started to go down the PR route, but i end up making large changes that @kriomant might not agree with and i listed the bigger changes here. I shared the repo so he could pick/choose what he wants. however, it has significantly diverged from what it was so that is why i didn't open a PR

spikerguy commented 4 months ago

@pferreir thank you with your PR I was able to use this 5×3 with 3 knobs device: ch57x-keyboard-tool.exe --vendor-id 0x1189 --product-id 0x8840 --endpoint-address 4 --interface-number 0 upload < Mapping.yaml image

@Trobeloo Can you please share the mapping you used?

It is failing for me when I try to upload the example one with rows and columns changed.

I have exactly the same one but it fails to process led 1 I compiled it from @pferreir support-8840-wip branch

image

UPDATE: Fixed it there was a typo it seems. I have issue with usb-dongle connection

last row and layer 2 and 3 are not saved after switching from usb-c connection to usb-dongle connection. I see there were similar reports before.

UPDATE 2: I used @kamaaina version from macropad-tool and it worked perfectly even after power cycles and also have more features like ready current values and detailed led as per colors.

Is there a way to keep led on even when using wirelessly? I Don't think that would be possible, so I found a hack, provide power to the macropad using power bank while using it wirelessly. :D

KingDuckZ commented 1 month ago

Just wanted to say that for me this device identifies itself as 1189:8840 Acer Communications & Multimedia USB Composite Device - it's got no LEDs, no switches or layers, only 2 knobs. The board inside the plastic does have "on/off" printed on it and some space for what looks like a layer switch, but there is nothing connected, it's cut clean all around. Program worked just fine.