Testing keybinds (gamepad to keyboard)

Not currently working
This commit is contained in:
danbulant 2019-06-25 15:06:53 +02:00
parent 59db56981b
commit cabd300089
3 changed files with 8 additions and 8 deletions

View file

@ -24,7 +24,7 @@ $(document).keypress((event) => {
} }
}) })
var keyBinds = new Map(); var keyBinds = new Map();
keyBinds.set('button_1', '~')//set button_1 (A) as enter keyBinds.set('button_1', 'enter')//set button_1 (A) as enter
var pressed = []; var pressed = [];
var gameLooper = 0; var gameLooper = 0;
//Sending keys from gamepad //Sending keys from gamepad
@ -39,7 +39,7 @@ function changeToGame(){
//add custom ones //add custom ones
keyBinds.forEach((val, key) => { keyBinds.forEach((val, key) => {
gamepad.on('press', key, () => { gamepad.on('press', key, () => {
sendKeys(val); sendKeys([], val);
}) })
}) })

View file

@ -27,8 +27,8 @@ if(typeof require !== typeof undefined){
files = arg; files = arg;
refreshFiles(); refreshFiles();
}) })
function sendKeys(arg){ function sendKeys(arg, arg2){
ipcRenderer.send('sendKeys', arg); ipcRenderer.send('sendKeys', arg, arg2);
return true; return true;
} }
var loc = window.location.pathname; var loc = window.location.pathname;

View file

@ -176,13 +176,13 @@ ipcMain.on('fullscreen', (event, arg) => {
}) })
function sendKeybinding (win, modifiers, keyCode) { function sendKeybinding (win, modifiers, keyCode) {
win.webContents.sendInputEvent({ type: 'keyDown', modifiers, keyCode }) win.webContents.sendInputEvent({ type: 'keyDown', modifiers: modifiers, keyCode: keyCode })
win.webContents.sendInputEvent({ type: 'char', modifiers, keyCode }) win.webContents.sendInputEvent({ type: 'char', modifiers: modifiers, keyCode: keyCode })
win.webContents.sendInputEvent({ type: 'keyUp', modifiers, keyCode }) win.webContents.sendInputEvent({ type: 'keyUp', modifiers: modifiers, keyCode: keyCode })
} }
ipcMain.on('sendKeys', (event, modifiers, keyCode) => { ipcMain.on('sendKeys', (event, modifiers, keyCode) => {
console.log('Sending keys: '+arg); console.log('Sending keys: '+keyCode + " with modifiers " + modifiers);
sendKeybinding(win, modifiers, keyCode); sendKeybinding(win, modifiers, keyCode);
}) })
ipcMain.on('listFiles', (event, arg) => { ipcMain.on('listFiles', (event, arg) => {