• Annotate the report descriptor

    /* Annotate the report descriptor 
    http://www.usbmadesimple.co.uk/ums_g_an_­ms_8.gif
    */
    /* Copyright (c) 2015 Gordon Williams, Pur3 Ltd. See the file LICENSE for copying permission. */
    /* 
    
    var mouse = require("USBMouse");
    
    setWatch(function() {
      mouse.send(20,20,mouse.BUTTONS.NONE); // X movement, Y movement, buttons pressed
    }, BTN, {debounce:100,repeat:true, edge:"rising"});
    
    
    */
    /*
    E.setUSBHID ⇒
    
    (top)
    Call type:
    
    E.setUSBHID(opts)
    Description
    
    USB HID will only take effect next time you unplug and re-plug your Espruino. If you're disconnecting it from power you'll have to make sure you have save()d after calling this function.
    
    Note: This is only available in devices that support USB HID (Espruino Pico and Espruino WiFi)
    
    Parameters
    
    opts - An object containing at least reportDescriptor, an array representing the report descriptor. Pass undefined to disable HID.
    */
    E.setUSBHID({
      reportDescriptor : [
      0x05,   0x01, //Usage Page (Generic Desktop Controls)
      0x09,   0x02, //Usage (Mouse)
      0xA1,   0x01, //Collection (application)
      0x09,   0x01, //Usage (Pointer)
    
      0xA1,   0x00, //Collextion (Physical)
      0x05,   0x09, //Usage Page (Button)
      0x19,   0x01, //Usage Minimum (1)
      0x29,   0x03, //Usage Maximum (5)
    
      0x15,   0x00, //Logical Minimum (0)
      0x25,   0x01, //Logical Maximum (5)
      0x95,   0x03, //Report Count (3)
      0x75,   0x01, //Report Size (1)
    
      0x81,   0x02, //Input (Data, Variable,Absolute,Bit Field)
      0x95,   0x01, //Report Coint (1)
      0x75,   0x05, //Report Size (5)
      0x81,   0x01, //Input (Constant, Array, Absolute, Bit Field)
    
      0x05,   0x01, //Usage Page (Generic Desktop Controls)
      0x09,   0x30, //Usage 00
      0x09,   0x31, //Usage (X)
      0x09,   0x38, //Usage (Wheel)
    
      0x15,   0x81, //Logical Minimum(-127)
      0x25,   0x7F, //Logical Maximum(127)
      0x75,   0x08, //Report Size (8)
      0x95,   0x03, //Report Count (3)
    
      0x81,   0x06, // Input (Data, Variablr,Relative, Bit Field)
      0xC0,  //End Collection
    
      0x09,  0x3c, // ?????
      0x05,  0xff, 
        
      0x09,  0x01, 
      0x15,  0x00, 
      0x25,  0x01, 
        
      0x75,  0x01, 
      0x95,  0x02, 
      0xb1,  0x22, 
        
      0x75,  0x06, 
      0x95,  0x01, 
      0xb1,  0x01, 
      0xc0  //end collection
    ]
    });
    
    exports.BUTTONS = {
      NONE : 0,
      LEFT : 1,
      RIGHT : 2,
      MIDDLE : 4
    };
    
    exports.send = function(x,y,b) {
      E.sendUSBHID([b&7,x,y,0]);
    };
    
    
    /*
    E.sendUSBHID ⇒
    
    (top)
    Call type:
    
    E.sendUSBHID(data)
    Parameters
    
    data - An array of bytes to send as a USB HID packet
    
    Returns
    
    1 on success, 0 on failure
    */
    
About