mirror of
https://github.com/danbulant/console-hub
synced 2026-06-17 13:31:05 +00:00
Testing gamepad to keyboard
This commit is contained in:
parent
355c050522
commit
fa882c2f97
2 changed files with 10 additions and 8 deletions
|
|
@ -24,6 +24,7 @@ $(document).keypress((event) => {
|
|||
}
|
||||
})
|
||||
var keyBinds = new Map();
|
||||
keyBinds.set('button_1', '~')//set button_1 (A) as enter
|
||||
var pressed = [];
|
||||
var gameLooper = 0;
|
||||
//Sending keys from gamepad
|
||||
|
|
@ -36,16 +37,17 @@ function changeToGame(){
|
|||
gamepad.off('press', 'button_1');
|
||||
gamepad.off('press', 'button_2');
|
||||
//add custom ones
|
||||
keyBinds.foreach((val, key) => {
|
||||
keyBinds.forEach((val, key) => {
|
||||
gamepad.on('press', key, () => {
|
||||
pressed.push(val);
|
||||
sendKeys(val);
|
||||
})
|
||||
})
|
||||
|
||||
gameLooper = setInterval(() => {
|
||||
sendKeys(pressed);
|
||||
pressed = [];
|
||||
}, 100);
|
||||
// gameLooper = setInterval(() => {
|
||||
// if(pressed == []) return;
|
||||
// sendKeys(pressed);
|
||||
// pressed = [];
|
||||
// }, 100);
|
||||
}
|
||||
|
||||
function changeToMenu(){
|
||||
|
|
|
|||
4
main.js
4
main.js
|
|
@ -3,7 +3,7 @@ var fs = require('fs');
|
|||
var path = require('path');
|
||||
var files = require('./files');
|
||||
var wifi = require('node-wifi');
|
||||
var ks = require('node-key-sender');
|
||||
const sendkeys = require('sendkeys-js')
|
||||
let win;
|
||||
|
||||
wifi.init({
|
||||
|
|
@ -176,7 +176,7 @@ ipcMain.on('fullscreen', (event, arg) => {
|
|||
})
|
||||
ipcMain.on('sendKeys', (event, arg) => {
|
||||
console.log('Sending keys: '+arg);
|
||||
ks.sendCombination(arg);
|
||||
sendkeys.send(arg);
|
||||
})
|
||||
ipcMain.on('listFiles', (event, arg) => {
|
||||
console.log('Listing all files and directories in ' + arg);
|
||||
|
|
|
|||
Loading…
Reference in a new issue