Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't grab/release keyboard and mouse, but can release #40

Open
6 tasks done
rolandog opened this issue Jun 12, 2023 · 1 comment
Open
6 tasks done

Can't grab/release keyboard and mouse, but can release #40

rolandog opened this issue Jun 12, 2023 · 1 comment

Comments

@rolandog
Copy link

According to the ReadMe:

Press Ctrl + Raspberry to grab/release your keyboard and mouse, switching between local use and USB.

Press Ctrl + Shift + Raspberry (on the grabbed keyboard) to exit.

However, Ctrl + Raspberry doesn't seem to grab/release the keyboard (Ctrl + Shift + Raspberry works fine, though).

I'll document my debugging journey to get the main branch working after compiling and installing (may help #39):

  • added libcomposite to /etc/modules (echo 'libcomposite' | sudo tee -a /etc/modules, as commented on readme: Autorun example #19 ), and rebooted
  • HOOK_PATH is hard-coded to /home/pi/pi400kb/hook.sh on pi400.h and on CMakeLists.txt; updated and re-compiled.
  • LED path may be outdated for Bullseye (replaced /sys/class/leds/led0/trigger and /sys/class/leds/led0/brightness to /sys/class/leds/PWR/trigger and /sys/class/leds/PWR/brightness, respectively, in hook.sh).
  • Manually inspected the Keyboard and Mouse variables passed to CMake and manually passed them when building: cmake .. -DMOUSE_DEV="/dev/input/by-id/usb-PixArt_USB_Optical_Mouse-event-mouse" -DMOUSE_VID=0x093a -DMOUSE_PID=0x2510 -DKEYBOARD_DEV="/dev/input/by-id/usb-_Raspberry_Pi_Internal_Keyboard-event-kbd" -DKEYBOARD_VID=0x04d9 -DKEYBOARD_PID=0x0007

I have tried:

  • creating a shortcut to manually restart the service (doesn't work?) in /etc/xdg/openbox/lxde-pi-rc.xml (though I'm not sure if C-W is the right combination for Ctrl + Raspberry).
  <keyboard>
    <!-- 
         [... default commands ...]
    -->
    <!-- My Custom Keyboard Shortcuts -->
    <keybind key="C-W">
      <action name="Execute">
        <command>sudo systemctl restart pi400kb.service</command>
      </action>
    </keybind>
  </keyboard>
  • Manually inspected the pi400kb.service logs (journalctl -f -u pi400kb.service), and found the following error message:
Jun 12 14:33:53 pi systemd[1]: Started pi400kb USB OTG Keyboard & Mouse forwarding.
Jun 12 14:33:53 pi pi400kb[2515]: usbg_create_gadget()  duplicate gadget name
Jun 12 14:33:53 pi pi400kb[2515]:  
Jun 12 14:33:53 pi pi400kb[2515]: Error creating gadget
Jun 12 14:33:53 pi pi400kb[2515]: Error: USBG_ERROR_EXIST : Already exist
Jun 12 14:33:54 pi pi400kb[2515]: Found keyboard at: /dev/hidraw1
Jun 12 14:33:54 pi pi400kb[2515]: Found mouse at: /dev/hidraw0
Jun 12 14:33:54 pi pi400kb[2515]: Grabbing Keyboard and/or Mouse
Jun 12 14:33:54 pi pi400kb[2515]: Grabbing: /dev/input/by-id/usb-_Raspberry_Pi_Internal_Keyboard-event-kbd
Jun 12 14:33:54 pi pi400kb[2515]: Grabbing: /dev/input/by-id/usb-PixArt_USB_Optical_Mouse-event-mouse
Jun 12 14:33:54 pi pi400kb[2515]: Running...
Jun 12 14:33:54 pi pi400kb[2515]: K:1 0 0 0 0 0 0 0
Jun 12 14:33:54 pi pi400kb[2515]: K:9 0 0 0 0 0 0 0
Jun 12 14:33:54 pi pi400kb[2515]: Releasing Keyboard and/or Mouse
Jun 12 14:33:54 pi pi400kb[2515]: K:b 0 0 0 0 0 0 0
Jun 12 14:33:54 pi pi400kb[2515]: Releasing Keyboard and/or Mouse
Jun 12 14:33:54 pi pi400kb[2515]: Cleanup USB
Jun 12 14:33:54 pi systemd[1]: pi400kb.service: Succeeded.

I'm not knowledgeable in C, so that's the limit to my ability to debug (and I'm unsure if the problem may be on pi400kb's gadget-hid.c:

usbg_ret = usbg_create_gadget(s, "g1", &g_attrs, &g_strs, &g);

... or the usbg_create_gadget function from libusbgx:

https://github.com/linux-usb-gadgets/libusbgx/blob/721e3a1cbd7e2b6361bb439d3959e7403e4f0092/src/usbg.c#L1531

I'd like to help in getting it to work... so, please let me know what I can do to continue debugging.

@Gadgetoid
Copy link
Owner

It's been a long time since I used/worked on this, so I'll have to get up to speed first. The Gadget HID stuff might be a red-herring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants