title: Mouse emulation on Raspberry Pi 4 does not work
body: <br>
  For a personal project I am currently trying to make my Raspberry Pi 4 emulate both a keyboard as well as a mouse. The keyboard emulation works really well and convincing, but I keep getting problems when it comes to emulating the mouse. <br>
  I've configured my Pi as an HID device with the following code being executed at boot:
  <pre><code>#!/bin/bash
  cd /sys/kernel/config/usb_gadget/
  mkdir -p pihid
  cd pihid
  echo 0x1d6b &gt; idVendor # Linux Foundation
  echo 0x0104 &gt; idProduct # Multifunction Composite Gadget
  echo 0x0100 &gt; bcdDevice # v1.0.0
  echo 0x0200 &gt; bcdUSB # USB2
  mkdir -p strings/0x409
  echo &quot;fedcba9876543210&quot; &gt; strings/0x409/serialnumber
  echo &quot;test&quot; &gt; strings/0x409/manufacturer
  echo &quot;PiHID&quot; &gt; strings/0x409/product
  mkdir -p configs/c.1/strings/0x409
  echo &quot;Config 1: ECM network&quot; &gt; configs/c.1/strings/0x409/configuration
  echo 250 &gt; configs/c.1/MaxPower
  
  # Add functions here
  mkdir -p functions/hid.usb0
  echo 1 &gt; functions/hid.usb0/protocol
  echo 1 &gt; functions/hid.usb0/subclass
  echo 8 &gt; functions/hid.usb0/report_length
  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\\x65\\x05\\x07\\x19\\x00\\x29\\x65\\x81\\x00\\xc0 &gt; functions/hid.usb0/report_desc
  ln -s functions/hid.usb0 configs/c.1/
  
  mkdir -p functions/hid.usb1
  echo 2 &gt; functions/hid.usb1/protocol
  echo 2 &gt; functions/hid.usb1/subclass
  echo 8 &gt; functions/hid.usb1/report_length
  echo -ne \\x05\\x01\\x09\\x02\\xA1\\x01\\x09\\x01\\xA1\\x00\\x05\\x09\\x19\\x01\\x29\\x03\\x15\\x00\\x25\\x01\\x95\\x03\\x75\\x01\\x81\\x02\\x95\\x01\\x75\\x05\\x81\\x03\\x05\\x01\\x09\\x30\\x09\\x31\\x15\\x81\\x25\\x7F\\x75\\x08\\x95\\x02\\x81\\x06\\xC0\\xC0 &gt; functions/hid.usb1/report_desc
  ln -s functions/hid.usb1 configs/c.1/
  # End functions
  
  ls /sys/class/udc &gt; UDC
  </code></pre>
  <p>After boot there are two files in <code>/dev</code>, called &quot;hidg0&quot; and &quot;hidg1&quot;, which I should be able to write to. Writing keyboard commands to &quot;hidg0&quot; works completely fine with this python script:</p>
  <pre><code>NULL_CHAR = chr(0)
  
  def write_report(report):
      with open('/dev/hidg0', 'rb+') as fd:
          fd.write(report.encode())
  
  write_report(NULL_CHAR*2+chr(6)+chr(7)+chr(8)+chr(9)+chr(10)+chr(11))
  write_report(NULL_CHAR*8)
  </code></pre>
  <p>When I am in editor, &quot;cdefgh&quot; will appear.<br></p>
  <p>This is my script I use to write to &quot;hidg1&quot;:</p>
  <pre><code>NULL_CHAR = chr(0)
  
  def ms_write(report):
      with open(&quot;/dev/hidg1&quot;, &quot;rb+&quot;) as fd:
          fd.write(report.encode())
  
  ms_write(NULL_CHAR+chr(100)+NULL_CHAR*6)
  ms_write(NULL_CHAR*8)
  </code></pre>
  <p>But after executing, instead of moving the mouse 100 units, nothing happens and the program finishes.
  What am I doing wrong concerning the mouse emulation or the communication with the Windows HID Drivers?</p>