No internet connection
  1. Home
  2. Technical Support

No Mouse/KB

By Glen Wooden @glenwooden
    2021-04-30 18:40:11.239Z

    Hi - Brilliant device! Unfortunately, I can't seem to get KB/mouse activity. I have the "Hobbyist" kit.

    I'm using this to connect to a security-camera NVR system (a ReoLink RLN16-410.

    The video capture is perfect, but no KB/Mouse - any ideas / suggestions?

    • 12 replies

    There are 12 replies. Estimated reading time: 11 minutes

    1. Sorry to hear about the issues!

      Can you share your logs (from System > Logs)?

      Do you see the same behavior from both USB ports on the NVR?

      TinyPilot presents itself as a USB hub with a USB keyboard and mouse attached. Do you know if the NVR accepts USB hubs? Computers generally do, but more niche devices like Enterprise KVMs sometimes are picky and want a direct connection to a USB keyboard or mouse.

      1. G
        In reply toglenwooden:
        Glen Wooden @glenwooden
          2021-04-30 20:59:07.749Z

          So, after a little RTFM, it looks like it supports only a mouse. can the TP emulate a mouse only?

          1. It can't do it natively but I can try making a custom configuration for you next week. If you'd like to give it a shot in the meantime, the file to modify is on the TinyPilot device at:

            /opt/tinypilot-privileged/init-usb-gadget
            

            It's currently set up as a Multifunction Composite Gadget, but we'll need to change it to be just a mouse and delete the keyboard parts of the file.

            1. GGlen Wooden @glenwooden
                2021-05-04 00:21:37.253Z

                so, I put this together - The host (testing with my PX) detects it as a mouse, but I don't get any mouse movement...

                #!/bin/bash

                set -e
                set -x
                set -u
                modprobe libcomposite

                cd /sys/kernel/config/usb_gadget/
                mkdir -p g1
                cd g1

                echo 0x1d6b > idVendor # Linux Foundation
                echo 0x0104 > idProduct # Multifunction Composite Gadget
                echo 0x0100 > bcdDevice # v1.0.0
                echo 0x0200 > bcdUSB # USB2

                STRINGS_DIR="strings/0x409"
                mkdir -p "$STRINGS_DIR"
                echo "6b65796d696d6570690" > "${STRINGS_DIR}/serialnumber"
                echo "tinypilot" > "${STRINGS_DIR}/manufacturer"
                echo "Mouse" > "${STRINGS_DIR}/product"

                Mouse

                MOUSE_FUNCTIONS_DIR="functions/hid.mouse"
                mkdir -p "$MOUSE_FUNCTIONS_DIR"
                echo 0 > "${MOUSE_FUNCTIONS_DIR}/protocol"
                echo 0 > "${MOUSE_FUNCTIONS_DIR}/subclass"
                echo 5 > "${MOUSE_FUNCTIONS_DIR}/report_length"

                Write the report descriptor

                D=$(mktemp)
                {
                echo -ne \x05\x01 # USAGE_PAGE (Generic Desktop)
                echo -ne \x09\x02 # USAGE (Mouse)
                echo -ne \xA1\x01 # COLLECTION (Application)
                # 8-buttons
                echo -ne \x05\x09 # USAGE_PAGE (Button)
                echo -ne \x19\x01 # USAGE_MINIMUM (Button 1)
                echo -ne \x29\x08 # USAGE_MAXIMUM (Button 8)
                echo -ne \x15\x00 # LOGICAL_MINIMUM (0)
                echo -ne \x25\x01 # LOGICAL_MAXIMUM (1)
                echo -ne \x95\x08 # REPORT_COUNT (8)
                echo -ne \x75\x01 # REPORT_SIZE (1)
                echo -ne \x81\x02 # INPUT (Data,Var,Abs)
                # x,y absolute coordinates
                echo -ne \x05\x01 # USAGE_PAGE (Generic Desktop)
                echo -ne \x09\x30 # USAGE (X)
                echo -ne \x09\x31 # USAGE (Y)
                echo -ne \x16\x00\x00 # LOGICAL_MINIMUM (0)
                echo -ne \x26\xFF\x7F # LOGICAL_MAXIMUM (32767)
                echo -ne \x75\x10 # REPORT_SIZE (16)
                echo -ne \x95\x02 # REPORT_COUNT (2)
                echo -ne \x81\x02 # INPUT (Data,Var,Abs)
                # vertical wheel
                echo -ne \x09\x38 # USAGE (wheel)
                echo -ne \x15\x81 # LOGICAL_MINIMUM (-127)
                echo -ne \x25\x7F # LOGICAL_MAXIMUM (127)
                echo -ne \x75\x08 # REPORT_SIZE (8)
                echo -ne \x95\x01 # REPORT_COUNT (1)
                echo -ne \x81\x06 # INPUT (Data,Var,Rel)
                # horizontal wheel
                echo -ne \x05\x0C # USAGE_PAGE (Consumer Devices)
                echo -ne \x0A\x38\x02 # USAGE (AC Pan)
                echo -ne \x15\x81 # LOGICAL_MINIMUM (-127)
                echo -ne \x25\x7F # LOGICAL_MAXIMUM (127)
                echo -ne \x75\x08 # REPORT_SIZE (8)
                echo -ne \x95\x01 # REPORT_COUNT (1)
                echo -ne \x81\x06 # INPUT (Data,Var,Rel)
                echo -ne \xC0 # END_COLLECTION
                } >> "$D"
                cp "$D" "${MOUSE_FUNCTIONS_DIR}/report_desc"

                CONFIG_INDEX=1
                CONFIGS_DIR="configs/c.${CONFIG_INDEX}"
                mkdir -p "$CONFIGS_DIR"
                echo 250 > "${CONFIGS_DIR}/MaxPower"

                CONFIGS_STRINGS_DIR="${CONFIGS_DIR}/strings/0x409"
                mkdir -p "$CONFIGS_STRINGS_DIR"
                echo "Config ${CONFIG_INDEX}: ECM network" > "${CONFIGS_STRINGS_DIR}/configuration"

                ln -s "$MOUSE_FUNCTIONS_DIR" "${CONFIGS_DIR}/"
                ls /sys/class/udc > UDC

                chmod 777 /dev/hidg0
                #chmod 777 /dev/hidg1

                1. I suspect the issue is this line:

                  echo 0x0104 > idProduct # Multifunction Composite Gadget

                  It's still reporting itself as a USB hub, when we want it to declare itself a mouse. I'm not sure offhand where to find the code for mouse, but I can search later this week.

                  1. GGlen Wooden @glenwooden
                      2021-05-04 00:50:40.563Z

                      The mouse that came with the device reports as Vendor: 10c4 and Product 8105
                      I tried that, and no dice... detects if properly, but no activity...

                      pilot@tinypilot:/opt/tinypilot-privileged $ lsusb
                      Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
                      Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
                      Bus 001 Device 004: ID 10c4:8105 Cygnal Integrated Products, Inc.
                      Bus 001 Device 003: ID 534d:2109
                      Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
                      Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

                      1. Oh, you're right. I was expecting the host to treat it as a different device based on different idProduct values, but I don't think those have any effect.

                        I unfortunately can't think of any other ways to make it work with the NVR. If the Voyager doesn't work for the scenario you wanted, I can process a return for you if you email me your order number.

                        Edit: Sorry, got threads crossed and got confused about the customer. Updated.

                        1. GGlen Wooden @glenwooden
                            2021-05-10 00:45:12.891Z

                            So, is the limitation a hardware or software one? If software, I'd be willing to take a stab at it if you want to share the code. Happy to sign an NDA and share the results with you.

                            1. I suspect that it's a limitation of the Linux USB HID gadget driver, which is what allows TinyPilot to emulate USB HID devices.

                              I haven't investigated it too deeply, but the driver might always announce itself to the target computer as a multifunction USB device, which is potentially causing the NVR to reject it since it wants a simple USB HID mouse.

                              The code is all open source, so no NDA required. If you're able to find a solution, I'd be happy to work with you on integrating it.

                              The portion that initializes the USB gadget is the file you've seen, source is here:

                              https://github.com/mtlynch/ansible-role-tinypilot/blob/ed29bacf132625c26b24898c7a08376ba3d22c61/files/init-usb-gadget

                              If you edit the file, you can reinitialize the USB gadget by restarting the usb-gadget service:

                              sudo service usb-gadget restart
                              

                              The part of the code that sends messages to the USB gadget interface (at /dev/hidg1) is here:

                              https://github.com/mtlynch/tinypilot/blob/763ef08bab8fc7fe57fa05c4863c5ceb5783f7af/app/hid/mouse.py

                              1. GGlen Wooden @glenwooden
                                  2021-06-01 16:49:59.498Z

                                  ok - interesting new update-
                                  I so want to use the TP for this that I returned the original Camera system and went with a more advanced one. New behavior is that video is great, and mouse clicks are registering, but no mouse movement - any ideas???

                                  1. It might be related to this:

                                    https://github.com/mtlynch/ansible-role-tinypilot/pull/134

                                    I haven't cut a release yet that includes this fix, but you can try applying the same fix locally on your TinyPilot by just manually updating your init-usb-gadget script in /opt/tinypilot-privileged.

                  2. G
                    In reply toglenwooden:
                    Glen Wooden @glenwooden
                      2021-04-30 21:10:58.143Z

                      Fantastic! Thank you! I'll play with it a little, but I'm sure your solution will be the one that actually will work :)