Generic Devices: Success!

Hi Andreas, @here,

Just reporting in to say a huge "thanks" for this features which, with a little tinkering, has brought back my beloved XKeys80 back from oblivion! No other keypad/keyboard combination has quite fitted my workflow so well, and I've done without it since OSX something killed ControllerMate.

I have all the keys successfully mapped for key presses - can I get a consult on the best way to tackle function keys, which need to have press and release mapped? Should I use BTT variables to store which keys are currently down and, if so, can I get/set them from the GD script? Or can I get the system report about which keys are currently down?

Thanks again,


Looks like a very interesting device!

Can you give some more information about the F keys? Are their changes shown in the GD script?
You can use btt variables - to retrieve them you can use something like this:

let value = await callBTT('get_string_variable',{variableName:'theVariableName'})

However this is relatively slow. If you just need to store information, you can create a global variable before the analyzeDeviceInput function. Have a look here:

Generic Devices: Please give function analyzeDeviceInput() access to the previous state - Feature Requests - BetterTouchTool Community (

Thanks Andreas,

I've not explained myself very well - all of the keys are of the same type, but what I want to do is to map some to Ctrl/Option/Shift/Cmd. So I need them to be "held down" and not momentary, and need the key-down and key-up to be captured.

The solution by Back-To-Topic has proved a winner - I have adapted it for the Xkeys and all working perfectly - thanks both!


Great to hear!

I'll soon be creating a collection of user created device support scripts - if you want to share yours I'd definitely include it too!

Hey Andreas and forum,

Many months of satisfied use with BTT and my X-Keys device later, I'm hoping to take the next step and see if I can control the lights on the device (to visualise another BTT preset). I have the spec of the device, and know the 36 byte hex arrays that I need to send it, and the report type that needs to be returned.

Can you suggest what format the data needs to be in for the Send Data To Generic Device to successfully pass it on, and what the report types should be set to? An example hex array would be:


(as in 0:179:7:1:(32x0))

Some example code from the manufacturers uses the Swift IOKit.hid library and the code:

let device:IOHIDDevice
let bytes = [UInt8](repeating: 0, count: 35)
bytes[0] = 0xb3
bytes[1] = 0x07
bytes[2] = 0x01
let reportId : CFIndex = CFIndex(0)
let deviceNameResult:IOReturn
deviceNameResult = IOHIDDeviceSetReport(device, kIOHIDReportTypeOutput, reportId, UInt8, data.count)

in case that helps more than it hinders…

Any suggestions would be very gratefully received!



In that case it should be:


And the report type needs to be set to Output:

However I have not tested this very much. The code of your example would respond with the device name, correct? This could only be tested with the "Run Real Java Script" action (I can post some example if you need that).
For just changing the lights, you probably don't need the return value though.