First of all, thank you for BTT. If only all software was so imaginative!
This is the javascript and the triggers for the Logitech G13, a gamepad controller that was widely sold, but for which Logitech discontinued the software support, making it useless for every system after 10.14. Everything works except for the joystick (I got dizzy watching the output it produces...) and the illumination button top right.
There is another solution to revive the G13 and that is a free app on the App Store called "Extra Keys"; which allows you to use the profiles made with the Logitech software on a supported system or to write your own profiles in xml (good luck with that...). Using BTT offers much more flexibility though.
Javascript:
// Enter your input analyzer script here.
// Do not change the function signatures
function analyzeDeviceInput(targetDevice, reportID, reportDataHex) {
let reportBuffer = buffer.Buffer.from(reportDataHex, 'hex');
// the values you see above are in hex format. To read such a byte
// use readUInt8(index).
if(reportBuffer.readUInt8(3) === 0x01) {
log('G1');
bttTriggerDeviceTrigger(targetDevice, 'G1');
} else if (reportBuffer.readUInt8(3) === 0x02) {
log('G2');
bttTriggerDeviceTrigger(targetDevice, 'G2');
} else if (reportBuffer.readUInt8(3) === 0x04) {
log('G3');
bttTriggerDeviceTrigger(targetDevice, 'G3');
} else if (reportBuffer.readUInt8(3) === 0x08) {
log('G4');
bttTriggerDeviceTrigger(targetDevice, 'G4');
} else if (reportBuffer.readUInt8(3) === 0x10) {
log('G5');
bttTriggerDeviceTrigger(targetDevice, 'G5');
} else if (reportBuffer.readUInt8(3) === 0x20) {
log('G6');
bttTriggerDeviceTrigger(targetDevice, 'G6');
} else if (reportBuffer.readUInt8(3) === 0x40) {
log('G7');
bttTriggerDeviceTrigger(targetDevice, 'G7');
} else if (reportBuffer.readUInt8(3) === 0x80) {
log('G8');
bttTriggerDeviceTrigger(targetDevice, 'G8');
} else if (reportBuffer.readUInt8(4) === 0x01) {
log('G9');
bttTriggerDeviceTrigger(targetDevice, 'G9');
} else if (reportBuffer.readUInt8(4) === 0x02) {
log('G10');
bttTriggerDeviceTrigger(targetDevice, 'G10');
} else if (reportBuffer.readUInt8(4) === 0x04) {
log('G11');
bttTriggerDeviceTrigger(targetDevice, 'G11');
} else if (reportBuffer.readUInt8(4) === 0x08) {
log('G12');
bttTriggerDeviceTrigger(targetDevice, 'G12');
} else if (reportBuffer.readUInt8(4) === 0x10) {
log('G13');
bttTriggerDeviceTrigger(targetDevice, 'G13');
} else if (reportBuffer.readUInt8(4) === 0x20) {
log('G14');
bttTriggerDeviceTrigger(targetDevice, 'G14');
} else if (reportBuffer.readUInt8(4) === 0x40) {
log('G15');
bttTriggerDeviceTrigger(targetDevice, 'G15');
} else if (reportBuffer.readUInt8(4) === 0x80) {
log('G16');
bttTriggerDeviceTrigger(targetDevice, 'G16');
} else if (reportBuffer.readUInt8(5) === 0x81) {
log('G17');
bttTriggerDeviceTrigger(targetDevice, 'G17');
} else if (reportBuffer.readUInt8(5) === 0x82) {
log('G18');
bttTriggerDeviceTrigger(targetDevice, 'G18');
} else if (reportBuffer.readUInt8(5) === 0x84) {
log('G19');
bttTriggerDeviceTrigger(targetDevice, 'G19');
} else if (reportBuffer.readUInt8(5) === 0x88) {
log('G20');
bttTriggerDeviceTrigger(targetDevice, 'G20');
} else if (reportBuffer.readUInt8(5) === 0x90) {
log('G21');
bttTriggerDeviceTrigger(targetDevice, 'G21');
} else if (reportBuffer.readUInt8(5) === 0xa0) {
log('G22');
bttTriggerDeviceTrigger(targetDevice, 'G22');
} else if (reportBuffer.readUInt8(7) === 0x02 || reportBuffer.readUInt8(7) === 0x82) {
log('StickLeft');
bttTriggerDeviceTrigger(targetDevice, 'StickLeft');
} else if (reportBuffer.readUInt8(7) === 0x04 || reportBuffer.readUInt8(7) === 0x84) {
log('StickRight');
bttTriggerDeviceTrigger(targetDevice, 'StickRight');
} else if (reportBuffer.readUInt8(6) === 0x20) {
log('M1');
bttTriggerDeviceTrigger(targetDevice, 'M1');
} else if (reportBuffer.readUInt8(6) === 0x40) {
log('M2');
bttTriggerDeviceTrigger(targetDevice, 'M2');
} else if (reportBuffer.readUInt8(6) === 0x80) {
log('M3');
bttTriggerDeviceTrigger(targetDevice, 'M3');
} else if (reportBuffer.readUInt8(7) === 0x01) {
log('MR');
bttTriggerDeviceTrigger(targetDevice, 'MR');
} else if (reportBuffer.readUInt8(6) === 0x02) {
log('Top1');
bttTriggerDeviceTrigger(targetDevice, 'Top1');
} else if (reportBuffer.readUInt8(6) === 0x04) {
log('Top2');
bttTriggerDeviceTrigger(targetDevice, 'Top2');
} else if (reportBuffer.readUInt8(6) === 0x08) {
log('Top3');
bttTriggerDeviceTrigger(targetDevice, 'Top3');
} else if (reportBuffer.readUInt8(6) === 0x10) {
log('Top4');
bttTriggerDeviceTrigger(targetDevice, 'Top5');
} else if (reportBuffer.readUInt8(6) === 0x01) {
log('TopRoundLeft');
bttTriggerDeviceTrigger(targetDevice, 'TopRoundLeft');
}
// If you want to get the next report even though,
// the data has not changed, call this function:
// bttGetNextEvenWithoutChange(targetDevice, reportID)
}
// Advanced, optional. Use if you want to trigger commands that send data to
// the device, from a BTT predefined action.
// See https://docs.folivora.ai/1500_generic_devices.html
async function executeBTTCommand(targetDevice, commandName, commandInput) {
log("execute command: " + commandName)
switch(commandName) {
case "exampleCommand": {
// send any hex string to the device
let deviceResponse = await bttSendDataToDevice({
BTTActionSendDataTargetDevice: targetDevice,
BTTActionSendDataData: 'FEEDC0DE',
BTTActionSendDataReportType: 1,
BTTActionSendDataResponseType: -1,
BTTActionSendDataResponsePrefix: ''
});
break;
}
}
return 'done executing ' + commandName
}
Trigger names used in the javascript:
G1
G2
G3
G4
G5
G6
G7
G8
G9
G10
G11
G12
G13
G14
G15
G16
G17
G18
G19
G20
G21
G22
StickLeft
StickRight
M1
M2
M3
MR
Top1
Top2
Top3
Top4
TopRoundLeft