From ab10245dcc6ef0673f3dba46dc459b4243e442c4 Mon Sep 17 00:00:00 2001 From: Guillaume Hansali Date: Tue, 29 Mar 2022 12:27:48 +0900 Subject: [PATCH] * Added DEFAULT controller --- higan/target-web/shell.html | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/higan/target-web/shell.html b/higan/target-web/shell.html index cf8cc70..23dd688 100644 --- a/higan/target-web/shell.html +++ b/higan/target-web/shell.html @@ -2100,6 +2100,20 @@

👋First time around?

'A', 'B', 'X', 'Y', 'C', 'Z', 'C', 'Z', 'Select', 'Start', null, null, 'Up', 'Down', 'Left', 'Right', 'Select', 'Start', ] + }, + 'DEFAULT': { + 'Famicom': [ + 'A', 'B', 'X', 'Y', 'L', 'R', 'L', 'R', + 'Select', 'Start', null, null, 'Up', 'Down', 'Left', 'Right' + ], + 'Super Famicom': [ + 'A', 'B', 'X', 'Y', 'L', 'R', 'L', 'R', + 'Select', 'Start', null, null, 'Up', 'Down', 'Left', 'Right' + ], + 'Mega Drive': [ + 'A', 'B', 'X', 'Y', 'C', 'Z', 'C', 'Z', + 'Select', 'Start', null, null, 'Up', 'Down', 'Left', 'Right' + ] } } @@ -2110,12 +2124,14 @@

👋First time around?

function connectGamepad(gamepad) { if (!gamepadButtonKeymaps[gamepad.id]) { - return notify(` + gamepad.id = 'DEFAULT'; + + /*return notify(`

😲 Cannot connect gamepad

Gamepad detected but no button mappings are available for ${gamepad.id}

- `, 'warning'); + `, 'warning');*/ } for (const [port, currentGamepad] of Object.entries(gamepadControllers)) { @@ -2182,6 +2198,12 @@

💨 Gamepad disconnected

} const { id, buttons } = gamepads[index]; + + // Check if the mapping exists for the controller and use the default otherwise + if (!gamepadButtonKeymaps[id]) { + id = 'DEFAULT'; + } + const map = gamepadButtonKeymaps[id][Module.info.currentEmulator]; for (const [index, button] of buttons.entries()) {