marcelhoffs / input-switcher

Switch inputs with hidapitester (Windows & Linux)
403 stars 32 forks source link

Can't switch to channel 2. #14

Closed netizeni closed 1 year ago

netizeni commented 1 year ago

I'm trying to connect MX Keys and MX Master 2S with two laptops. First connection over dongle on channel 1, second over Bluetooth on channel 2, and both are using Win 10. So far, I can't even make devices switch to channel 2, so I would like to know which step I'm missing? After default values from readme didn't work, this is what I've tried.

While on channel 1 .\hidapitester.exe --vidpid 046D:C52B --list-detail gives a list of 8 elements, like these:

046D/C52B: Logitech - USB Receiver
  vendorId:      0x046D
  productId:     0xC52B
  usagePage:     0xFF00
  usage:         0x0001
  serial_number: (null)
  interface:     2
  path: \\?\hid#vid_046d&pid_c52b&mi_02&col01...

046D/C52B: Logitech - USB Receiver
  vendorId:      0x046D
  productId:     0xC52B
  usagePage:     0xFF00
  usage:         0x0002
  serial_number: (null)
  interface:     2
  path: \\?\hid#vid_046d&pid_c52b&mi_02&col02...

046D/C52B: Logitech - USB Receiver
  vendorId:      0x046D
  productId:     0xC52B
  usagePage:     0xFF00
  usage:         0x0004
  serial_number: (null)
  interface:     2
  path: \\?\hid#vid_046d&pid_c52b&mi_02&col03...
...

Sniffing with .\hidapitester.exe --vidpid 046D:C52B --usage 0x0001 --usagePage 0xFF00 --timeout 2000 --open --read-input-forever --length 7 --read-feature 1 registers only switch device buttons (both on keyboard and mouse) and nothing else, with an output:

Opening device, vid/pid:0x046D/0xC52B, usagePage/usage: FF00/1
Device opened
Reading 64-byte input report 0, 2000 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 2000 msec timeout...read 7 bytes:
 10 06 41 04 71 8A 40 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 //pressed channel 2 on mx keys
 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
Reading 64-byte input report 0, 2000 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 2000 msec timeout...read 0 bytes:
Reading 64-byte input report 0, 2000 msec timeout...read 7 bytes:
 10 06 41 04 B1 8A 40 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 //pressed channel 1 on mx keys
 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
Reading 64-byte input report 0, 2000 msec timeout...

I tried both versions

//Value from above
C:\Program Files\InputSwitcher>.\hidapitester.exe --vidpid 046D:C52B --usage 0x0001 --usagePage 0xFF00 --open --length 7 --send-output 0x10,0x06,0x41,0x04,0x71,0x8A,0x40
Opening device, vid/pid:0x046D/0xC52B, usagePage/usage: FF00/1
Device opened
Writing output report of 7-bytes...wrote 7 bytes:
 10 06 41 04 71 8A 40
Closing device
//Default value
C:\Program Files\InputSwitcher>.\hidapitester.exe --vidpid 046D:C52B --usage 0x0001 --usagePage 0xFF00 --open --length 7 --send-output 0x10,0x01,0x09,0x1e,0x01,0x00,0x00
Opening device, vid/pid:0x046D/0xC52B, usagePage/usage: FF00/1
Device opened
Writing output report of 7-bytes...wrote 7 bytes:
 10 01 09 1E 01 00 00
Closing device

but neither command switches to channel 2. I tried to sniff the next entry, which I got with --list-detail by changing usage and usagePage, and it registers pressing channel 2 button, but for channel 1 it enters in some form of loop and shows 30+ entries. Regardless, trying the value I've got from sniffing, as well as the default value, gives wrote -1 bytes

C:\Program Files\InputSwitcher>.\hidapitester.exe --vidpid 046D:C52B --usage 0x000**2** --usagePage 0xFF00 --open --length 7 --send-output 0x10,0x06,0x08,0x20,0x00,0xD2,0x01
Opening device, vid/pid:0x046D/0xC52B, usagePage/usage: FF00/2
Device opened
Writing output report of 7-bytes...wrote -1 bytes:
 10 06 08 20 00 D2 01
Closing device

C:\Program Files\InputSwitcher>.\hidapitester.exe --vidpid 046D:C52B --usage 0x000**2** --usagePage 0xFF00 --open --length 7 --send-output 0x10,0x01,0x09,0x1e,0x01,0x00,0x00
Opening device, vid/pid:0x046D/0xC52B, usagePage/usage: FF00/2
Device opened
Writing output report of 7-bytes...wrote -1 bytes:
 10 01 09 1E 01 00 00
Closing device

so I assume this is not the correct usage and usagePage to use? After this entry, every other one either doesn't register keypresses while sniffing or it shows wrong values like for example 40 00 00 00 00 00 00. With that being said, what am I doing wrong?

netizeni commented 1 year ago

As I couldn't make it work at all, I switched to the unifying receiver I got with MX Keys, and the keyboard worked instantly with the default command .\hidapitester.exe --vidpid 046D:C52B --usage 0x0001 --usagePage 0xFF00 --open --length 7 --send-output 0x10,0x01,0x09,0x1e,0x01,0x00,0x00, but MX Master 2S doesn't switch to channel 2.

I tried every command I saw in other "Issues" here on github, which worked for other people using MX Master and MX Master 3. For both models, send-output is basically the same, so I assume it should be the same for MX Master 2S.

Solaar on Linux indeed switches MX Master 2S to channel 2, but the log doesn't show the necessary info I need:

pc@pc:~$ solaar -dd config "MX Master 2S" change-host 2
2023-06-09 13:51:35,284,284     INFO [MainThread] hidapi.udev: Found device BID 0003 VID 0000046D PID 0000C52B HID++ True True USB 2 2
2023-06-09 13:51:35,284,284     INFO [MainThread] logitech_receiver.base: New lock 4
2023-06-09 13:51:35,287,287  WARNING [MainThread] hidapi.udev: Report Descriptor not processed for BID 0003 VID 0000056A PID 00005146: Unsupported global tag: 0b101
2023-06-09 13:51:35,288,288  WARNING [MainThread] hidapi.udev: Report Descriptor not processed for BID 0003 VID 0000056A PID 00005146: Unsupported global tag: 0b1010
2023-06-09 13:51:35,300,300     INFO [MainThread] logitech_receiver.receiver: <UnifyingReceiver(/dev/hidraw2,4)>: found new device 1 (408A)
2023-06-09 13:51:35,308,308     INFO [MainThread] logitech_receiver.receiver: <UnifyingReceiver(/dev/hidraw2,4)>: found new device 2 (4069)
2023-06-09 13:51:35,308,308     INFO [MainThread] logitech_receiver.base: New lock 6
2023-06-09 13:51:35,783,783     INFO [MainThread] logitech_receiver.device: <Device(2,4069,Wireless Mouse MX Master 2S,redacted)>: unitId EF1148EF does not match serial redacted
Setting change-host of Wireless Mouse MX Master 2S to 2

Any idea how to find C and D params for send-output?

Rasoul77 commented 1 year ago

In case you are still looking for the solution, this worked for me (by sniffing...)

rem Switch MX Master 2S to channel 2
.\hidapitester.exe --vidpid 046D:C52B --usage 0x0001 --usagePage 0xFF00 --open --length 7 --send-output 0x10,0x02,0x09,0x1c,0x01,0x00,0x00

Assuming that you are switching from channel 1 to channel 2