Example on the Use of a Third-Party USB Input Device- Webex
In this example, we want to demonstrate how to operate specific tasks on a room or desk device by using the buttons on a third-party USB input device (in this case, a remote control).
We demonstrate how to use the keys on a Bluetooth remote control (in conjunction with a USB dongle) to adjust the volume, toggle the standby mode, and control the camera of a room or desk device. We develop a macro that acts as an event listener and then uses the application programming interface (API) of the desk or room device to carry out the appropriate activities.
This article provides more information regarding the Third-Party USB Input Device capability.
In the following illustration, it is necessary for you to enter the text that is formatted using a standard font. The response that was obtained from the room or desk device can be found in the text that is formatted with italics.
SSH will allow you to log in to the device in the room or the device on the desk. You will require a user who has administrative access on the local system.
Adjust the device’s settings so that a USB remote control purchased from a third party can be used with it.
The xConfiguration Peripherals InputDevice is currently set to On ** end OK as its mode.
By selecting the relevant option with this command, you will be able to discover whether the configuration is currently Active or Inactive:
- Peripherals Configuration InputDevice Mode c xConfiguration Peripherals InputDevice Mode is the xConfiguration parameter. In xConfiguration, the Peripherals InputDevice Mode should be set to On ** end OK.
- Register to provide feedback in order to keep track of when the buttons on the remote control are pressed and when they are released.
- xFeedback Register ** end OK @ userinterface/event/userinterface/inputdevice @ userinterface/event/userinterface/inputdeviceYou will be able to determine for which feedbacks the device is registered by carrying out this command, as it will allow you to do so:
- This is the end of the xFeedback list. OK // Event // User Interface // Input Device
- You need to press and then let go of a button on the remote control before proceeding with the feedback registration process. This will guarantee that the process is working correctly.
- The two events that are generated as a consequence of this action are referred to respectively as Pressed and Released. You will continue to see the Pressed event until the button you are pressing and holding is no longer being pressed. Once this occurs, the event will no longer appear. After that, the Released event will be produced automatically.
- The actions described below take place whenever the Enter key is pushed and then released:
- UserInterface Key Action Key: * KEY_ENTER UserInterface InputDevice KeyUserInterface Key Action Code for InputDevice: 28 e UserInterface InputDevice Key**UserInterface InputDevice Key Action Type: Pressed ** end * * ** end * UserInterface Key on an InputDevice* KEY_ENTER is the action key for the e UserInterface InputDevice Key.* UserInterface Key Action Code for InputDevice: 28* UserInterface Key Action Code for InputDevice: 28end eUserInterface InputDevice Key Action Type: Released end eUserInterface e UserInterface
- Construct a macro that will keep an eye out for the relevant InputDevice events and will then make use of the application programming interface (API) of the device in order to carry out the tasks that are associated with those events.
- Bring back to life the inactive standby, volume up, and volume down buttons. When the macro recognizes an event that contains the keystrokes KEY_VOLUMEUP, KEY_VOLUMEDOWN, or KEY_SLEEP, it executes the commands that are pertinent to the situation.
- Create a function that enables the user to control the camera by using the arrow keys. We want the camera to continue moving in the same direction as long as the button is pressed; this is the desired behavior. When you let off of the button, the camera will stop moving and remain still until you press it again. In response to an event that contains the string “KEY_LEFT,” “KEY_RIGHT,” “KEY_UP,” or “KEY_DOWN,” accordingly, the macro will execute the necessary instructions and take the required actions.
const xapi = require(‘xapi’); log(command +” + JSON.stringify(args)); function log(event); function com(command, args=”) xapi.command(command, args); log(command +” + JSON.stringify(args)); { console.log(event); } function notify(message) xapi.command(‘UserInterface Message TextLine Display’, ‘Text: message, duration: 3 ‘); function cameraControl(motor, direction, cameraId=’1’) com(‘Camera Ramp’, ‘CameraId’: cameraId, [motor]: direction ); function init(); com(‘Camera Ramp’, ‘CameraId’: cameraId); { let standbyState; xapi.status.get(‘Standby’).if that’s the case… => ‘Standby’, state => xapi.status.on(‘Standby’); standbyState = state.State === ‘Off’; false: true; ‘Standby’, state => xapi.event.on(‘UserInterface InputDevice Key Action’, press => true; standbyState = state.State === ‘Off’? false: true; ); standbyState = state.State === ‘Off’? false: true; ); if (press.Type == “Pressed”) then… toggle (press.Key) the switch. break; case “KEY_LEFT”: cameraControl(‘Pan’, ‘Left’); break; case “KEY_RIGHT”: cameraControl(‘Pan’, ‘Right’); break; case “KEY_UP”: cameraControl(‘Tilt’, ‘Up’); break; case “KEY_DOWN”: cameraControl(‘Tilt’, ‘Down’); break; default: break; else if (press.Switch (press.Key) = type (which equals “Released”). case “KEY_LEFT” should call cameraControl(‘Pan’, ‘Stop’); break; case “KEY_RIGHT” should call cameraControl(‘Pan’, ‘Stop’); break; case “KEY_UP” should call cameraControl(‘Tilt’, ‘Stop’); break; case “KEY_DOWN” should call cameraControl(‘Tilt’, ‘Stop’); break; case “KEY_VOLUMEUP”(standbyState ? ‘Standby Deactivate’: ‘Standby Activate’); break; default: break; ); init(); ‘Standby Deactivate’: ‘Standby Activate’