Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* Added DEFAULT controller #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions higan/target-web/shell.html
Original file line number Diff line number Diff line change
Expand Up @@ -2100,6 +2100,20 @@ <h1>👋First time around?</h1>
'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'
]
}
}

Expand All @@ -2110,12 +2124,14 @@ <h1>👋First time around?</h1>

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

/*return notify(`
<h1>😲 Cannot connect gamepad</h1>
<p>
Gamepad detected but no button mappings are available for <strong>${gamepad.id}</strong>
</p>
`, 'warning');
`, 'warning');*/
}

for (const [port, currentGamepad] of Object.entries(gamepadControllers)) {
Expand Down Expand Up @@ -2182,6 +2198,12 @@ <h1>💨 Gamepad disconnected</h1>
}

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()) {
Expand Down