• SUCCESS!
    After a bit more experimenting (aka brute forcing) I managed to figure out how to call the 2nd report. This code will add the ability to toggle the on screen keyboard in iOS devices when connected to a BLE keyboard from espruino.
    We extend the built in keyboards report with the additional codes and then set that wiht servies so you can still use all the existing features of ble_hid_keyboard like kb.tap(kb.KEY.A, 0);

    I've tested this on a pixl.js running 2.09 against an iPhone running iOs 14.6 so it works until Apple decide to change something!

    var kb = require("ble_hid_keyboard");
    
    togleReport = new Uint8Array([
    // 2nd Report for iOS Toggle Keyboard  
      0x05, 0x0C,                     // Usage Page (Consumer)
      0x09, 0x01,                     // Usage (Consumer Control)
      0xA1, 0x01,                     // Collection (Application)
      0x85, 0x02,                     //     Report Id (2)
      0x15, 0x00,                     //     Logical minimum (0)
      0x25, 0x01,                     //     Logical maximum (1)
      0x75, 0x01,                     //     Report Size (1)
      0x95, 0x01,                     //     Report Count (1)
    
      0x0A, 0xAE, 0x01,               //     Usage (AL Keyboard Layout)
      0x81, 0x06,                     //     Input (Data,Value,Relative,Bit Field)
      0xC0                            // End Collection
    ]);
    //Append the new report to the built in kb report
    var report = new Uint8Array(kb.report.length + togleReport.length);
    report.set(kb.report);
    report.set(togleReport, kb.report.length);
    
    //Set services with new combined report
    NRF.setServices(undefined, { hid : report });
    
    //Call this function to toggle the on screen keyboard
    function toggleKB(){
      NRF.sendHIDReport([2,1], function() {
        NRF.sendHIDReport([2,0], function() {}); 
      });
    }
    
    
    
    
About

Avatar for sammachin @sammachin started