mirror of
https://github.com/danbulant/console-hub
synced 2026-07-03 10:00:52 +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();
|
var keyBinds = new Map();
|
||||||
|
keyBinds.set('button_1', '~')//set button_1 (A) as enter
|
||||||
var pressed = [];
|
var pressed = [];
|
||||||
var gameLooper = 0;
|
var gameLooper = 0;
|
||||||
//Sending keys from gamepad
|
//Sending keys from gamepad
|
||||||
|
|
@ -36,16 +37,17 @@ function changeToGame(){
|
||||||
gamepad.off('press', 'button_1');
|
gamepad.off('press', 'button_1');
|
||||||
gamepad.off('press', 'button_2');
|
gamepad.off('press', 'button_2');
|
||||||
//add custom ones
|
//add custom ones
|
||||||
keyBinds.foreach((val, key) => {
|
keyBinds.forEach((val, key) => {
|
||||||
gamepad.on('press', key, () => {
|
gamepad.on('press', key, () => {
|
||||||
pressed.push(val);
|
sendKeys(val);
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
gameLooper = setInterval(() => {
|
// gameLooper = setInterval(() => {
|
||||||
sendKeys(pressed);
|
// if(pressed == []) return;
|
||||||
pressed = [];
|
// sendKeys(pressed);
|
||||||
}, 100);
|
// pressed = [];
|
||||||
|
// }, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeToMenu(){
|
function changeToMenu(){
|
||||||
|
|
|
||||||
4
main.js
4
main.js
|
|
@ -3,7 +3,7 @@ var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var files = require('./files');
|
var files = require('./files');
|
||||||
var wifi = require('node-wifi');
|
var wifi = require('node-wifi');
|
||||||
var ks = require('node-key-sender');
|
const sendkeys = require('sendkeys-js')
|
||||||
let win;
|
let win;
|
||||||
|
|
||||||
wifi.init({
|
wifi.init({
|
||||||
|
|
@ -176,7 +176,7 @@ ipcMain.on('fullscreen', (event, arg) => {
|
||||||
})
|
})
|
||||||
ipcMain.on('sendKeys', (event, arg) => {
|
ipcMain.on('sendKeys', (event, arg) => {
|
||||||
console.log('Sending keys: '+arg);
|
console.log('Sending keys: '+arg);
|
||||||
ks.sendCombination(arg);
|
sendkeys.send(arg);
|
||||||
})
|
})
|
||||||
ipcMain.on('listFiles', (event, arg) => {
|
ipcMain.on('listFiles', (event, arg) => {
|
||||||
console.log('Listing all files and directories in ' + arg);
|
console.log('Listing all files and directories in ' + arg);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue