我們顯示如何使用藍牙裝置遠端控制 USB 配接器)來控制待命功能、調高和降低音量,以及控制會議室或桌上裝置攝影機。 我們建立用於聆聽相關事件的宏,並且使用會議室或桌面裝置 API 執行相關動作。

本文中說明了協力廠商 USB 輸入裝置 功能

在下列範例中,您必須輸入以一般字型大小撰寫的文字。 斜體文字是從會議室或桌上裝置收到的回應。

1

在 SSH 上登錄會議室或桌面裝置。 您需要一個本地管理員 使用者。

2

設定裝置以允許使用協力廠商 USB 遠端控制。


       xConfiguration Peripherals InputDevice Mode: On 
      ** end OK  
               

 

您可以使用以下指令檢查組配置是開還是關:


        xConfiguration Peripherals InputDevice Mode 
        *c xConfiguration Peripherals InputDevice Mode: On ** end OK  
                  
3

註冊意見回饋,如此一來,當按下及遠端控制按鈕時,我們會收到通知。


       xFeedback Register /event/userinterface/inputdevice 
       ** end OK  
               

 

您可以使用此指令檢查裝置註冊的意見回饋:


        xFeedback list 
       /event/userinterface/inputdevice ** end OK  
                  
4

按下按鈕並放開,遠端控制回饋註冊是否有效。

此動作會產生兩個事件: 已按下及 已釋出。 如果您按住按鈕,則會看到 已按下事件 ,直到放開該按鈕。 然後產生 已釋 出事件。

按下並放開 Enter 鍵時,將發出這些事件:

 
                   *e UserInterface InputDevice Key Action Key: KEY_ENTER *e UserInterface InputDevice Key Action Code: 28 *e UserInterface InputDevice Key Action Type: Pressed ** end *e UserInterface InputDevice Key Action Key: KEY_ENTER *e UserInterface InputDevice Key Action Code: 28 *e UserInterface InputDevice Key Action Type: Released ** end  
               
5

寫入用於聆聽相關 InputDevice 事件的宏,然後使用裝置 API 執行相關動作。

  • 讓待命、音量調高和音量降低按鈕恢復使用。 當宏發現包含 KEY_VOLUMEUP、KEY_VOLUMEDOWN 或 KEY_SLEEP 的事件時,會執行相關的指令。

  • 為方向鍵建立攝影機控制功能。 只要按下按鈕,我們即可保持移動攝影機。 釋出按鈕時,攝影機會停止移動。 當宏發現包含 KEY_LEFT、KEY_RIGHT、KEY UP 或 KEY__DOWN 的事件時,會執行相關的指令。


       const xapi = require('xapi'); function com(command, args='') { xapi.command(command, args); log(command + ' ' + JSON.stringify(args)); } function log(event) { 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() { let standbyState; xapi.status.get('Standby').then((state) => {standbyState = state.State === 'Off' ? false : true; }); xapi.status.on('Standby', state => { standbyState = state.State === 'Off' ? false : true; }); xapi.event.on('UserInterface InputDevice Key Action', press => { if (press.Type == "Pressed") { switch (press.Key) { 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.Type == "Released") { switch (press.Key) { case "KEY_LEFT": cameraControl('Pan', 'Stop'); break; case "KEY_RIGHT": cameraControl('Pan', 'Stop'); break; case "KEY_UP": cameraControl('Tilt', 'Stop'); break; case "KEY_DOWN": cameraControl('Tilt', 'Stop'); break; case 'KEY_VOLUMEUP': com('Audio Volume Increase'); break; case 'KEY_VOLUMEDOWN': com('Audio Volume Decrease'); break; case 'KEY_SLEEP': com(standbyState ? 'Standby Deactivate' : 'Standby Activate'); break; default: break; } } }); } init();