• Looks like I'd need to register the Pico as a Consumer Device (but not too sure what's involved with that)

    Compromise for now is to use a AutoHotkey script to control multimedia functions:

    [#NoEnv](https://forum.espruino.com/sear­ch/?q=%23NoEnv)  ; Recommended for performance and compatibility with future AutoHotkey releases.
    ; [#Warn](https://forum.espruino.com/searc­h/?q=%23Warn)  ; Enable warnings to assist with detecting common errors.
    SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
    SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
    
    ; AutoHotkey Media Keys
    !M::Send   {Media_Play_Pause}
    ^!Left::Send        {Media_Prev}
    ^!Right::Send       {Media_Next}
    ^!NumpadMult::Send  {Volume_Mute}
    ^!NumpadAdd::Send   {Volume_Up}
    ^!NumpadSub::Send   {Volume_Down}  
    

    Along with my Pico script:

    let kb = require("USBKeyboard");
    let debug = 0;
    let code = 0;
    let timeout;
    let lastTime;
    // function to do something with the code when we get it
    function handleCode() {
      timeout = undefined;
      if (debug) print(code);
      LED2.write(true);
      switch(code) {
        case 16712445: {
          console.log('Volume +');
          kb.setModifiers(kb.MODIFY.CTRL, function() {
            kb.tap(kb.KEY.F12);
          });
          break;
        }
        case 16750695: {
          console.log('Volume -');
          kb.setModifiers(kb.MODIFY.CTRL, function() {
            kb.tap(kb.KEY.F11);
          });
          break;
        }
        case 16754775: {
          console.log('Play/Pause');
          kb.setModifiers(kb.MODIFY.ALT, function() {
            kb.tap(kb.KEY.M);
          });
          break;
        }
        case 16720605: {
          console.log('Mute');
          kb.setModifiers(kb.MODIFY.CTRL, function() {
            kb.tap(kb.KEY.F10);
          });
          break;
        }
        case 16748655: {
          console.log('Skip');
          kb.setModifiers(kb.MODIFY.SHIFT, function() {
            kb.tap(kb.KEY.N);
          });
          break;
        }
        case 16738455: {
          console.log('Prev desktop');
          kb.setModifiers(kb.MODIFY.SHIFT, function() {
            kb.setModifiers(kb.MODIFY.GUI, function() {
              kb.tap(kb.KEY.LEFT);
            });
          });
          break;
        }
        case 16756815: {
          console.log('Next desktop');
          kb.setModifiers(kb.MODIFY.GUI, function() {
            kb.setModifiers(kb.MODIFY.SHIFT, function() {
              kb.tap(kb.KEY.RIGHT);
            });
          });
          break;
        }
        case 16753245: {
          console.log('Lock');
          kb.setModifiers(kb.MODIFY.GUI, function() {
            kb.tap(kb.KEY.L);
          });
          break;
        }
        default: {
          //console.log('default');
        }
        kb.setModifiers(0, function() {});
      }
      code = 0;
      LED2.write(false);
    }
    
    function onPulseOn(e) {
      code = (code*2) | ((e.time - lastTime) > 0.0008);
      if (timeout!==undefined) clearTimeout(timeout);
      timeout = setTimeout(handleCode, 20);
      lastTime = e.time;
    }
    
    function onPulseOff(e) {
      lastTime = e.time;
    }
    
    setWatch(onPulseOff, A5, { repeat:true, edge:"rising" });
    setWatch(onPulseOn, A5, { repeat:true, edge:"falling" });
    
    setWatch(function(e) {
      debug = !debug;
      console.log(`Debug mode ${debug ? 'on' : 'off' }`);
    }, BTN, { repeat: true });
    
    
About

Avatar for Stoaty @Stoaty started