Skip to content

Instantly share code, notes, and snippets.

@fitsyu
Created March 3, 2021 03:17
Show Gist options
  • Save fitsyu/31ba9d529b0f65960c26ef5e5f142fa5 to your computer and use it in GitHub Desktop.
Save fitsyu/31ba9d529b0f65960c26ef5e5f142fa5 to your computer and use it in GitHub Desktop.
Make use of Logitech G29 steering wheel to press commonly used buttons on a Mac
const g29 = require('logitech-g29')
const robot = require('robotjs')
g29.on('shifter-gear', function(gear) {
switch (gear) {
case 0:
break;
case 1:
robot.keyTap('v', ['command']);
break;
case 2:
robot.keyTap('c', ['command']);
break;
case 3:
robot.keyTap('r', ['command']);
break;
case 4:
robot.keyTap('b', ['command']);
break;
case 5:
robot.keyTap('u', ['command']);
break;
case 6:
robot.keyTap('f', ['command']);
break;
case -1:
robot.keyTap('o', ['command']);
break;
}
}
)
g29.on('pedals-clutch',
function(press) {
if (press === 1) {
robot.keyTap('escape');
}
}
)
g29.on('pedals-brake',
function(press) {
if (press === 1) {
robot.keyTap('delete');
}
}
)
g29.on('pedals-gas',
function(press) {
if (press === 1) {
robot.keyTap('space', ['command']);
}
}
)
g29.connect()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment