USB HID control plugin for tSIP

This plugin was written to allow answering / hanging up calls using wireless Mairdi M890BT/M890DBT headset, but after changing default settings it should work with other USB HID devices. It is quite similar to my previous EX-03 plugin.

Installation

For Mairdi M890 it is necessary to check "Start audio input (e.g. microphone) before call is confirmed" in tSIP Audio I/O settings tab, but this is probably specific for device.

Customization

Plugin settings are contained in HidControl.cfg file that is created first time after HidControl.dll was enabled in tSIP and then tSIP was closed. It can be then edited with any text editor or JSON editor.

HidControl.cfg

Device to connect to is specified by USB VID, PID and usage page. You can find device VID and PID in Windows device manager. Default usage page is 0xB (Telephony) and it probably would not make much sense to use Consumer page (0xC) as it would be simpler to just use tSIP global hotkeys mechanism then, defining actions for multimedia keys like PLAY/PAUSE/NEXT/PREV track.

To customize device button handling, connect with device first (using matching USB VID, PID and usage page) and look into tSIP log for incoming device reports when buttons are pressed. In HidControls.cfg file there is "reportActions" array used to match reports with scripts to be executed. Items from this array are checked sequentially and plugin is checking whether all bytes from configuration entry are present in received report and matching it. If entry is shorter than received report but bytes are matching - it's a match, thus longer sequences should be placed in configuration before shorter sequences. Example tSIP log when there is incoming call and "phone" button is pressed on Mairdi headset looks like this :

[HidControl.dll] HID REPORT_IN received 65 B: 0x01 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x30 0x78 0x37 0x37 0x20 0x00 
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x74 0x02 
0x00 0x00 0x70 0x02 0x00 0x00 0x7C 0x02 0x00 0x00

For the purpose of detecting keypress checking only first byte from this report seems sufficient, so only value = 1 (0x01) was placed in default dll configuration.

Each entry contains Lua script that would be executed when incoming report is matching. Default configuration contains single entry for answer/hangup action (depending on current call state).

Source and binary

This DLL was built with Code::Blocks 16.01/MinGW. Using newer version of Code::Blocks might be more difficult as it looks like 32-bit libraries (hid.a, setupapi.a) are no longer distributed with Code::Blocks 20.

Github: https://github.com/tomek-o/tSIP-plugin-HidControl.

Back to tSIP softphone