2020-05-24 14:02:23 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
gname=rpikvm
|
|
|
|
gserial=$(awk '/Serial/ { print $3 }' /proc/cpuinfo)
|
|
|
|
gmanufacturer="Petrkr.NET"
|
|
|
|
gproduct="rPi KVM"
|
|
|
|
|
2020-06-05 13:04:15 +02:00
|
|
|
#Mouse 1 absolute descriptor
|
|
|
|
MOUSE1=""
|
|
|
|
MOUSE1="$MOUSE1\\x05\\x01\\x09\\x02" # Usage generic desktop, Usage mouse
|
|
|
|
MOUSE1="$MOUSE1\\xa1\\x01\\x09\\x01" # Collection App, Usage Pointer
|
|
|
|
MOUSE1="$MOUSE1\\xa1\\x00" # Collection Physical
|
|
|
|
MOUSE1="$MOUSE1\\x05\\x09" # Use Page buttons
|
|
|
|
MOUSE1="$MOUSE1\\x19\\x01\\x29\\x08\\x15\\x00\\x25\\x01\\x75\\x01\\x95\\x08" # Usage min 1, max 8, logical min 0, max 1, report 8, size 1
|
|
|
|
MOUSE1="$MOUSE1\\x81\\x02" # Input data, variable, absolute
|
|
|
|
MOUSE1="$MOUSE1\\x05\\x01" # Usage page generic desktop
|
|
|
|
MOUSE1="$MOUSE1\\x09\\x30\\x09\\x31\\x15\\x00\\x25\\xff\\x75\\x08\\x95\\x02" # Usage X,Y, Log min 0, log max 255, size 8, report 2
|
|
|
|
MOUSE1="$MOUSE1\\x81\\x02" # Input data, variable, absolute
|
|
|
|
MOUSE1="$MOUSE1\\x05\\x01" # Usage page generic desktop
|
|
|
|
MOUSE1="$MOUSE1\\x09\\x38\\x15\\x81\\x25\\x7f\\x75\\x08\\x95\\x01" # Usage Wheel, log min -127, max 127, size 8, report 1
|
|
|
|
MOUSE1="$MOUSE1\\x81\\x06" # Input data, variable, relative
|
|
|
|
MOUSE1="$MOUSE1\\xc0" # End collection Physical
|
|
|
|
MOUSE1="$MOUSE1\\xc0" # End collection Application
|
|
|
|
|
2020-05-24 14:02:23 +02:00
|
|
|
cd /sys/kernel/config/usb_gadget/
|
|
|
|
mkdir -p $gname
|
|
|
|
cd $gname
|
|
|
|
|
|
|
|
echo "Creating USB Device"
|
|
|
|
echo 0x1d6b > idVendor # Linux Foundation
|
|
|
|
echo 0x0104 > idProduct # Multifunction Composite Gadget
|
|
|
|
echo 0x0100 > bcdDevice # v1.0.0
|
|
|
|
echo 0x0200 > bcdUSB # USB2
|
|
|
|
|
|
|
|
echo "Creating strings"
|
|
|
|
mkdir -p strings/0x409
|
|
|
|
echo "$gserial" > strings/0x409/serialnumber
|
|
|
|
echo "$gmanufacturer" > strings/0x409/manufacturer
|
|
|
|
echo "$gproduct" > strings/0x409/product
|
|
|
|
mkdir -p configs/c.1/strings/0x409
|
|
|
|
|
2020-06-04 14:06:16 +02:00
|
|
|
echo "Config: KVM Composite" > configs/c.1/strings/0x409/configuration
|
2020-05-24 14:02:23 +02:00
|
|
|
echo 250 > configs/c.1/MaxPower
|
|
|
|
|
|
|
|
echo "Creating usb devices"
|
|
|
|
# Gadget HID Keyboard
|
|
|
|
echo " HID Keyboard"
|
2020-05-24 19:36:17 +02:00
|
|
|
mkdir -p functions/hid.kbd0
|
|
|
|
echo 1 > functions/hid.kbd0/protocol
|
|
|
|
echo 1 > functions/hid.kbd0/subclass
|
|
|
|
echo 8 > functions/hid.kbd0/report_length
|
2020-05-25 01:28:26 +02:00
|
|
|
echo -ne \\x05\\x01\\x09\\x06\\xa1\\x01\\x05\\x07\\x19\\xe0\\x29\\xe7\\x15\\x00\\x25\\x01\\x75\\x01\\x95\\x08\\x81\\x02\\x95\\x01\\x75\\x08\\x81\\x03\\x95\\x05\\x75\\x01\\x05\\x08\\x19\\x01\\x29\\x05\\x91\\x02\\x95\\x01\\x75\\x03\\x91\\x03\\x95\\x06\\x75\\x08\\x15\\x00\\x25\\xff\\x05\\x07\\x19\\x00\\x29\\x65\\x81\\x00\\xc0 > functions/hid.kbd0/report_desc
|
2020-05-24 19:36:17 +02:00
|
|
|
|
2020-06-04 14:00:54 +02:00
|
|
|
echo " HID Mouse Relative"
|
2020-05-24 20:02:59 +02:00
|
|
|
mkdir -p functions/hid.mouse0
|
|
|
|
echo 2 > functions/hid.mouse0/protocol
|
2020-05-25 01:28:26 +02:00
|
|
|
echo 1 > functions/hid.mouse0/subclass
|
2020-05-24 20:02:59 +02:00
|
|
|
echo 8 > functions/hid.mouse0/report_length
|
2020-05-25 01:28:26 +02:00
|
|
|
echo -ne \\x05\\x01\\x09\\x02\\xa1\\x01\\x09\\x01\\xa1\\x00\\x05\\x09\\x19\\x01\\x29\\x08\\x15\\x00\\x25\\x01\\x95\\x08\\x75\\x01\\x81\\x02\\x05\\x01\\x09\\x30\\x09\\x31\\x09\\x38\\x15\\x81\\x25\\x7f\\x75\\x08\\x95\\x03\\x81\\x06\\xc0\\xc0 > functions/hid.mouse0/report_desc
|
2020-05-24 20:02:59 +02:00
|
|
|
|
2020-06-04 14:00:54 +02:00
|
|
|
echo " HID Mouse Absolute"
|
|
|
|
mkdir -p functions/hid.mouse1
|
|
|
|
echo 2 > functions/hid.mouse1/protocol
|
|
|
|
echo 1 > functions/hid.mouse1/subclass
|
|
|
|
echo 8 > functions/hid.mouse1/report_length
|
2020-06-05 13:04:15 +02:00
|
|
|
echo -ne $MOUSE1 > functions/hid.mouse1/report_desc
|
2020-06-04 14:00:54 +02:00
|
|
|
|
2020-05-24 14:20:06 +02:00
|
|
|
|
|
|
|
echo " Mass storage"
|
2020-05-24 19:36:17 +02:00
|
|
|
mkdir -p functions/mass_storage.disk1
|
|
|
|
|
|
|
|
echo " CD-ROM"
|
|
|
|
mkdir -p functions/mass_storage.cdrom1
|
|
|
|
echo 1 > functions/mass_storage.cdrom1/lun.0/cdrom
|
|
|
|
echo 1 > functions/mass_storage.cdrom1/lun.0/removable
|
2020-05-24 14:20:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
echo "Activating gadgeds"
|
2020-05-24 19:36:17 +02:00
|
|
|
ln -s functions/hid.kbd0 configs/c.1/
|
2020-05-24 20:02:59 +02:00
|
|
|
ln -s functions/hid.mouse0 configs/c.1/
|
2020-06-04 14:00:54 +02:00
|
|
|
ln -s functions/hid.mouse1 configs/c.1/
|
2020-05-24 19:36:17 +02:00
|
|
|
ln -s functions/mass_storage.disk1 configs/c.1/
|
|
|
|
ln -s functions/mass_storage.cdrom1 configs/c.1/
|
|
|
|
|
2020-05-24 14:02:23 +02:00
|
|
|
|
2020-05-24 14:20:06 +02:00
|
|
|
echo "Turn on gadget"
|
2020-05-24 14:02:23 +02:00
|
|
|
ls /sys/class/udc > UDC
|