usbhidemulator
12 min
the usbhidemulator allows you to emulate usb hid devices usb keyboards are currently the only supported device type brightsign players with usb c (except for ls3 and ls4) can use this object usbhidemulator idl \[ constructor(string path, string type) ] interface usbhidemulator { promise\<void> enable(); promise\<void> disable(); promise\<void> clear(); promise\<void> keydown(int keycode); 	promise\<void> keypress(int keycode); promise\<void> keyup(int keycode); promise\<ledstate> getledstate(); promise\<modifierstate> getmodifierstate(); promise\<void> setmodifierstate(modifierstate) }; interface ledstate { \[optional] attribute bool numlock; \[optional] attribute bool capslock; \[optional] attribute bool scrolllock; }; interface modifierstate { \[optional] attribute bool leftctrl; \[optional] attribute bool leftshift; \[optional] attribute bool leftalt; \[optional] attribute bool leftgui; \[optional] attribute bool rightctrl; \[optional] attribute bool rightshift; \[optional] attribute bool rightalt; \[optional] attribute bool rightgui; }; object creation to create a usbhidemulator object, first load the @brightsign/usbhidemulator module using the require() method keyem = require('@brightsign/usbhidemulator') kbd = new keyem() usbhideemulator use this interface to configure a usbhidemulator interface the usbhidemulator class also generates "ledupdate" events which can be listened for with addeventlistener() enable() promise\<void> enable() enables the hid device disable() promise\<void> disable() disables the hid device this method is not currently supported clear() clears all active keystrokes and modifiers clears all active keystrokes and modifiers keydown() promise\<void> keydown(int keycode) sends a keydown event for the specified usb key code keypress() promise\<void> keypress(int keycode) this is the same as keydown() followed by keyup() keyup() promise\<void> keyup(int keycode) sends a keyup event for the specified usb key code getledstate() promise\<ledstate> getledstate() returns an associative array with the current state of all led states on the keyboard getmodifierstate() promise\<modifierstate> getmodifierstate() returns an associative array with the current state of all modifiers (such as, shift, alt, ctrl) setmodifierstate() promise\<modifierstate> setmodifierstate(modifierstate) sets the current modifier state as specified by an associative array only modifiers that are listed will cause the state to change keycode this interface contains the usb key code keycode \<font color="#6554c0"> int\</font> usb hid keyboard codes are in section 10 of www usb org/sites/default/files/documents/hut1 12v2 pdf http //www usb org/sites/default/files/documents/hut1 12v2 pdf ledstate this interface sends an led state change if number lock, capital lock, or scroll lock is pressed numlock \<font color="#6554c0">bool\</font> \<font color="#01a0af">optional\</font> capslock \<font color="#6554c0">bool\</font> \<font color="#01a0af">optional\</font> scrolllock \<font color="#6554c0">bool \</font> \<font color="#01a0af">optional\</font> modifierstate listed modifiers will cause the state to change leftctrl \<font color="#6554c0">bool\</font> \<font color="#01a0af">optional\</font> leftshift \<font color="#6554c0"> bool\</font> \<font color="#01a0af">optional\</font> leftalt \<font color="#6554c0">bool\</font> \<font color="#01a0af">optional\</font> leftgui \<font color="#6554c0">bool\</font> \<font color="#01a0af">optional\</font> rightctrl \<font color="#6554c0">bool\</font> \<font color="#01a0af">optional\</font> rightshift \<font color="#6554c0">bool\</font> \<font color="#01a0af">optional\</font> rightalt \<font color="#6554c0">bool\</font> \<font color="#01a0af">optional\</font> rightgui \<font color="#6554c0">bool\</font> \<font color="#01a0af">optional\</font> example keyem = require('@brightsign/usbhidemulator') kbd = new keyem() kbd addeventlistener("ledupdate", function f(e) { console log(e);}) kbd enable() kbd keypress(4)