marcelhoffs / input-switcher

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

Works for the mouse on MacOS but not the keyboard #37

Closed mvmalyi closed 3 months ago

mvmalyi commented 3 months ago

Hi! Could anyone please help correcting my script? I would really appreciate that, I've been frustrated by this for hours. It works for my mouse but not the keyboard:

# Switch MX Keys Mini to Channel 1
hidapitester --vidpid 046D:B369 --usage 0x0202 --usagePage 0xFF43 --open --length 20 --send-output 0x11,0x00,0x09,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00

# Switch MX Master 3 to Channel 1
hidapitester --vidpid 046D:B034 --usage 0x0202 --usagePage 0xFF43 --open --length 20 --send-output 0x11,0xFF,0x0a,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00

This is what hidapitester --list-detail returns for the devices:

046D/B369: Logitech - MVM Logi Keyboard
  vendorId:      0x046D
  productId:     0xB369
  usagePage:     0x0001
  usage:         0x0006
  serial_number: 4B3A6C46 
  interface:     -1 
  path: DevSrvsID:4295067684

046D/B369: Logitech - MVM Logi Keyboard
  vendorId:      0x046D
  productId:     0xB369
  usagePage:     0x000C
  usage:         0x0001
  serial_number: 4B3A6C46 
  interface:     -1 
  path: DevSrvsID:4295067684

046D/B369: Logitech - MVM Logi Keyboard
  vendorId:      0x046D
  productId:     0xB369
  usagePage:     0xFF43
  usage:         0x0202
  serial_number: 4B3A6C46 
  interface:     -1 
  path: DevSrvsID:4295067684

046D/B034: Logitech - MVM Logi Mouse
  vendorId:      0x046D
  productId:     0xB034
  usagePage:     0x0001
  usage:         0x0002
  serial_number: 3BB22717 
  interface:     -1 
  path: DevSrvsID:4295067952

046D/B034: Logitech - MVM Logi Mouse
  vendorId:      0x046D
  productId:     0xB034
  usagePage:     0x0001
  usage:         0x0001
  serial_number: 3BB22717 
  interface:     -1 
  path: DevSrvsID:4295067952

046D/B034: Logitech - MVM Logi Mouse
  vendorId:      0x046D
  productId:     0xB034
  usagePage:     0xFF43
  usage:         0x0202
  serial_number: 3BB22717 
  interface:     -1 
  path: DevSrvsID:4295067952
mvmalyi commented 3 months ago

I still don't completely understand the whole thing but I made it work by using this script:

# Switch MX Keys Mini to Channel 1
sudo hidapitester --vidpid 046D:B369 --usage 0x0202 --usagePage 0xFF43 --open --length 20 --send-output 0x11,0x00,0x09,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
# Switch MX Master 3 to Channel 1
hidapitester --vidpid 046D:B034 --usage 0x0202 --usagePage 0xFF43 --open --length 20 --send-output 0x11,0xFF,0x0a,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x000x11,0xFF,0x0a,0x1b,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00

Because sudo commands require a password I also had to modify visudo by running this command:

export EDITOR=nano
sudo visudo

and adding this line at the end to the file, then saving it: username ALL=(ALL) NOPASSWD: /usr/local/bin/hidapitester