Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

Code Block
title
languagejsusbhidemulator 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;
};                                                                                                                          
                                                                                                                           
Panel
borderColor#3D3D3D
bgColor#F4F4F4
titleColor#3D3D3D
borderWidth0
titleBGColor#3D3D3D
borderStylesolid

ON THIS PAGE

Table of Contents
indent20px



Object Creation

To create a usbhidemulator object, first load the @brightsign/usbhidemulator module using

the 

the require() method.

Code Block
languagejs
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()
Code Block
languagejs
Promise<void> enable()

Enables the HID device.

disable()
Code Block
languagejs
Promise<void> disable()

Disables the HID device. This method is not currently supported.

clear()
Code Block
languagejs
Promise<void> clear()

Clears all active keystrokes and modifiers.

keyDown()
Code Block
languagejs
Promise<void> keyDown(int keycode)

Sends a keydown event for the specified USB key code.

keyPress()
Code Block
languagejs
Promise<void> keyPress(int keycode)

This is the same

as keyDown

as keyDown() followed by keyUp().

keyUp()
Code Block
languagejs
Promise<void> keyUp(int keycode)
Sends

Sends a keyup event for the specified USB key code.

getLedState()
Code Block
languagejs
Promise<LedState> getLedState()

Returns an associative array with the current state of all LED states on the keyboard.

getModifierState()
Code Block
languagejs
Promise<ModifierState> getModifierState()

Returns an associative array with the current state of all modifiers (such as, shift, alt, ctrl).

setModifierState()
Code Block
languagejs
Promise<ModifierState> setModifierState(ModifierState)
Sets

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 int

] keycode
Note

USB HID keyboard codes are in section 10 of 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 bool

]
  • optional

numLock
[
  • capsLock bool

]
  • optional

capsLock
[
  • scrollLock bool

]
  • optional

scrollLock

ModifierState

Listed modifiers will cause the state to change.

[
  • leftCtrl bool

]
  • optional

leftCtrl
[
  • leftShift bool

]
  • optional

leftShift 
[
  • leftAlt bool

]
  • optional

leftAlt 
[
  • leftGui bool

]
  • optional

leftGui 
[
  • rightCtrl bool

]
  • optional

rightCtrl 
[
  • rightShift bool

]
  • optional

rightShift 
[
  • rightAlt bool

]
  • optional

rightAlt 
[
  • rightGui bool

]
  • optional

rightGui 

Example

Code Block
languagejs
keyem = require('@brightsign/usbhidemulator')
kbd = new keyem()
kbd.addEventListener("ledupdate", function f(e) { console.log(e);})
kbd.enable()

kbd.keyPress(4)