Created
March 3, 2021 03:17
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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