mirror of
https://github.com/EmulatorJS/EmulatorJS.git
synced 2024-09-20 02:46:23 +00:00
ability to explicitly define control scheme for controls menu and virtual gamepad. Introduces new option EJS_controlScheme. Default behaviour (when option is undefined) not changed
This commit is contained in:
parent
764262f348
commit
2afbcf41d9
2 changed files with 26 additions and 18 deletions
|
@ -1749,6 +1749,13 @@ class EmulatorJS {
|
||||||
|
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
getControlScheme() {
|
||||||
|
if (this.config.controlScheme) {
|
||||||
|
return this.config.controlScheme;
|
||||||
|
} else {
|
||||||
|
return this.getCore(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
createControlSettingMenu() {
|
createControlSettingMenu() {
|
||||||
let buttonListeners = [];
|
let buttonListeners = [];
|
||||||
this.checkGamepadInputs = () => buttonListeners.forEach(elem => elem());
|
this.checkGamepadInputs = () => buttonListeners.forEach(elem => elem());
|
||||||
|
@ -1773,7 +1780,7 @@ class EmulatorJS {
|
||||||
body.classList.add("ejs_control_body");
|
body.classList.add("ejs_control_body");
|
||||||
|
|
||||||
let buttons;
|
let buttons;
|
||||||
if (['nes', 'gb'] === this.getCore(true)) {
|
if (['nes', 'gb'].includes(this.getControlScheme())) {
|
||||||
buttons = [
|
buttons = [
|
||||||
{id: 8, label: 'A'},
|
{id: 8, label: 'A'},
|
||||||
{id: 0, label: 'B'},
|
{id: 0, label: 'B'},
|
||||||
|
@ -1787,7 +1794,7 @@ class EmulatorJS {
|
||||||
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
||||||
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
||||||
];
|
];
|
||||||
} else if ('snes' === this.getCore(true)) {
|
} else if ('snes' === this.getControlScheme()) {
|
||||||
buttons = [
|
buttons = [
|
||||||
{id: 8, label: 'A'},
|
{id: 8, label: 'A'},
|
||||||
{id: 0, label: 'B'},
|
{id: 0, label: 'B'},
|
||||||
|
@ -1805,7 +1812,7 @@ class EmulatorJS {
|
||||||
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
||||||
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
||||||
];
|
];
|
||||||
} else if ('n64' === this.getCore(true)) {
|
} else if ('n64' === this.getControlScheme()) {
|
||||||
buttons = [
|
buttons = [
|
||||||
{id: 0, label: 'A'},
|
{id: 0, label: 'A'},
|
||||||
{id: 1, label: 'B'},
|
{id: 1, label: 'B'},
|
||||||
|
@ -1829,7 +1836,7 @@ class EmulatorJS {
|
||||||
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
||||||
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
||||||
];
|
];
|
||||||
} else if ('nds' === this.getCore(true)) {
|
} else if ('nds' === this.getControlScheme()) {
|
||||||
buttons = [
|
buttons = [
|
||||||
{id: 8, label: 'A'},
|
{id: 8, label: 'A'},
|
||||||
{id: 0, label: 'B'},
|
{id: 0, label: 'B'},
|
||||||
|
@ -1848,7 +1855,7 @@ class EmulatorJS {
|
||||||
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
||||||
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
||||||
];
|
];
|
||||||
} else if (['segaMD', 'segaCD', 'sega32x'].includes(this.getCore(true))) {
|
} else if (['segaMD', 'segaCD', 'sega32x'].includes(this.getControlScheme())) {
|
||||||
buttons = [
|
buttons = [
|
||||||
{id: 1, label: 'A'},
|
{id: 1, label: 'A'},
|
||||||
{id: 0, label: 'B'},
|
{id: 0, label: 'B'},
|
||||||
|
@ -1866,7 +1873,7 @@ class EmulatorJS {
|
||||||
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
||||||
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
||||||
];
|
];
|
||||||
} else if ('segaMS' === this.getCore(true)) {
|
} else if ('segaMS' === this.getControlScheme()) {
|
||||||
buttons = [
|
buttons = [
|
||||||
{id: 0, label: 'BUTTON 1 / START'},
|
{id: 0, label: 'BUTTON 1 / START'},
|
||||||
{id: 8, label: 'BUTTON 2'},
|
{id: 8, label: 'BUTTON 2'},
|
||||||
|
@ -1878,7 +1885,7 @@ class EmulatorJS {
|
||||||
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
||||||
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
||||||
];
|
];
|
||||||
} else if ('segaGG' === this.getCore(true)) {
|
} else if ('segaGG' === this.getControlScheme()) {
|
||||||
buttons = [
|
buttons = [
|
||||||
{id: 0, label: 'BUTTON 1'},
|
{id: 0, label: 'BUTTON 1'},
|
||||||
{id: 8, label: 'BUTTON 2'},
|
{id: 8, label: 'BUTTON 2'},
|
||||||
|
@ -1891,7 +1898,7 @@ class EmulatorJS {
|
||||||
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
{id: 25, label: this.localization('QUICK LOAD STATE')},
|
||||||
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
{id: 26, label: this.localization('CHANGE STATE SLOT')},
|
||||||
];
|
];
|
||||||
} else if ('segaSaturn' === this.getCore(true)) {
|
} else if ('segaSaturn' === this.getControlScheme()) {
|
||||||
buttons = [
|
buttons = [
|
||||||
{id: 1, label: 'A'},
|
{id: 1, label: 'A'},
|
||||||
{id: 0, label: 'B'},
|
{id: 0, label: 'B'},
|
||||||
|
@ -2379,19 +2386,19 @@ class EmulatorJS {
|
||||||
return true;
|
return true;
|
||||||
}(this.config.VirtualGamepadSettings)) {
|
}(this.config.VirtualGamepadSettings)) {
|
||||||
info = this.config.VirtualGamepadSettings;
|
info = this.config.VirtualGamepadSettings;
|
||||||
} else if ("gba" === this.getCore(true)) {
|
} else if ("gba" === this.getControlScheme()) {
|
||||||
info = [{"type":"button","text":"A","id":"a","location":"right","left":81,"top":40,"bold":true,"input_value":8},{"type":"button","text":"B","id":"b","location":"right","left":10,"top":70,"bold":true,"input_value":0},{"type":"dpad","location":"left","left":"50%","top":"50%","joystickInput":false,"inputValues":[4,5,6,7]},{"type":"button","text":"Start","id":"start","location":"center","left":60,"fontSize":15,"block":true,"input_value":3},{"type":"button","text":"Select","id":"select","location":"center","left":-5,"fontSize":15,"block":true,"input_value":2},{"type":"button","text":"L","id":"l","location":"left","left":3,"top":-100,"bold":true,"block":true,"input_value":10},{"type":"button","text":"R","id":"r","location":"right","right":3,"top":-100,"bold":true,"block":true,"input_value":11}];
|
info = [{"type":"button","text":"A","id":"a","location":"right","left":81,"top":40,"bold":true,"input_value":8},{"type":"button","text":"B","id":"b","location":"right","left":10,"top":70,"bold":true,"input_value":0},{"type":"dpad","location":"left","left":"50%","top":"50%","joystickInput":false,"inputValues":[4,5,6,7]},{"type":"button","text":"Start","id":"start","location":"center","left":60,"fontSize":15,"block":true,"input_value":3},{"type":"button","text":"Select","id":"select","location":"center","left":-5,"fontSize":15,"block":true,"input_value":2},{"type":"button","text":"L","id":"l","location":"left","left":3,"top":-100,"bold":true,"block":true,"input_value":10},{"type":"button","text":"R","id":"r","location":"right","right":3,"top":-100,"bold":true,"block":true,"input_value":11}];
|
||||||
} else if ("gb" === this.getCore(true)) {
|
} else if ("gb" === this.getControlScheme()) {
|
||||||
info = [{"type":"button","text":"A","id":"a","location":"right","left":81,"top":40,"bold":true,"input_value":8},{"type":"button","text":"B","id":"b","location":"right","left":10,"top":70,"bold":true,"input_value":0},{"type":"dpad","location":"left","left":"50%","top":"50%","joystickInput":false,"inputValues":[4,5,6,7]},{"type":"button","text":"Start","id":"start","location":"center","left":60,"fontSize":15,"block":true,"input_value":3},{"type":"button","text":"Select","id":"select","location":"center","left":-5,"fontSize":15,"block":true,"input_value":2}];
|
info = [{"type":"button","text":"A","id":"a","location":"right","left":81,"top":40,"bold":true,"input_value":8},{"type":"button","text":"B","id":"b","location":"right","left":10,"top":70,"bold":true,"input_value":0},{"type":"dpad","location":"left","left":"50%","top":"50%","joystickInput":false,"inputValues":[4,5,6,7]},{"type":"button","text":"Start","id":"start","location":"center","left":60,"fontSize":15,"block":true,"input_value":3},{"type":"button","text":"Select","id":"select","location":"center","left":-5,"fontSize":15,"block":true,"input_value":2}];
|
||||||
} else if (['vb', 'nes'].includes(this.getCore(true))) {
|
} else if (['vb', 'nes'].includes(this.getControlScheme())) {
|
||||||
info = [{"type":"button","text":"B","id":"b","location":"right","right":-10,"top":70,"bold":true,"input_value":0},{"type":"button","text":"A","id":"a","location":"right","right":60,"top":70,"bold":true,"input_value":8},{"type":"dpad","location":"left","left":"50%","right":"50%","joystickInput":false,"inputValues":[4,5,6,7]},{"type":"button","text":"Start","id":"start","location":"center","left":60,"fontSize":15,"block":true,"input_value":3},{"type":"button","text":"Select","id":"select","location":"center","left":-5,"fontSize":15,"block":true,"input_value":2}];
|
info = [{"type":"button","text":"B","id":"b","location":"right","right":-10,"top":70,"bold":true,"input_value":0},{"type":"button","text":"A","id":"a","location":"right","right":60,"top":70,"bold":true,"input_value":8},{"type":"dpad","location":"left","left":"50%","right":"50%","joystickInput":false,"inputValues":[4,5,6,7]},{"type":"button","text":"Start","id":"start","location":"center","left":60,"fontSize":15,"block":true,"input_value":3},{"type":"button","text":"Select","id":"select","location":"center","left":-5,"fontSize":15,"block":true,"input_value":2}];
|
||||||
} else if (this.getCore(true) === 'n64') {
|
} else if ('n64' === this.getControlScheme()) {
|
||||||
info = [{"type":"button","text":"B","id":"b","location":"right","left":-10,"top":95,"input_value":1,"bold":true},{"type":"button","text":"A","id":"a","location":"right","left":40,"top":150,"input_value":0,"bold":true},{"type":"zone","location":"left","left":"50%","top":"100%","joystickInput":true,"inputValues":[16, 17, 18, 19]},{"type":"zone","location":"left","left":"50%","top":"0%","joystickInput":false,"inputValues":[4,5,6,7]},{"type":"button","text":"Start","id":"start","location":"center","left":30,"top":-10,"fontSize":15,"block":true,"input_value":3},{"type":"button","text":"L","id":"l","block":true,"location":"top","left":10,"top":-40,"bold":true,"input_value":10},{"type":"button","text":"R","id":"r","block":true,"location":"top","right":10,"top":-40,"bold":true,"input_value":11},{"type":"button","text":"Z","id":"z","block":true,"location":"top","left":10,"bold":true,"input_value":12},{"fontSize":20,"type":"button","text":"CU","id":"cu","location":"right","left":25,"top":-65,"input_value":23},{"fontSize":20,"type":"button","text":"CD","id":"cd","location":"right","left":25,"top":15,"input_value":22},{"fontSize":20,"type":"button","text":"CL","id":"cl","location":"right","left":-15,"top":-25,"input_value":21},{"fontSize":20,"type":"button","text":"CR","id":"cr","location":"right","left":65,"top":-25,"input_value":20}];
|
info = [{"type":"button","text":"B","id":"b","location":"right","left":-10,"top":95,"input_value":1,"bold":true},{"type":"button","text":"A","id":"a","location":"right","left":40,"top":150,"input_value":0,"bold":true},{"type":"zone","location":"left","left":"50%","top":"100%","joystickInput":true,"inputValues":[16, 17, 18, 19]},{"type":"zone","location":"left","left":"50%","top":"0%","joystickInput":false,"inputValues":[4,5,6,7]},{"type":"button","text":"Start","id":"start","location":"center","left":30,"top":-10,"fontSize":15,"block":true,"input_value":3},{"type":"button","text":"L","id":"l","block":true,"location":"top","left":10,"top":-40,"bold":true,"input_value":10},{"type":"button","text":"R","id":"r","block":true,"location":"top","right":10,"top":-40,"bold":true,"input_value":11},{"type":"button","text":"Z","id":"z","block":true,"location":"top","left":10,"bold":true,"input_value":12},{"fontSize":20,"type":"button","text":"CU","id":"cu","location":"right","left":25,"top":-65,"input_value":23},{"fontSize":20,"type":"button","text":"CD","id":"cd","location":"right","left":25,"top":15,"input_value":22},{"fontSize":20,"type":"button","text":"CL","id":"cl","location":"right","left":-15,"top":-25,"input_value":21},{"fontSize":20,"type":"button","text":"CR","id":"cr","location":"right","left":65,"top":-25,"input_value":20}];
|
||||||
} else if (this.getCore(true) === "nds") {
|
} else if ("nds" === this.getControlScheme()) {
|
||||||
info = [{"type":"button","text":"X","id":"x","location":"right","left":40,"bold":true,"input_value":9},{"type":"button","text":"Y","id":"y","location":"right","top":40,"bold":true,"input_value":1},{"type":"button","text":"A","id":"a","location":"right","left":81,"top":40,"bold":true,"input_value":8},{"type":"button","text":"B","id":"b","location":"right","left":40,"top":80,"bold":true,"input_value":0},{"type":"dpad","location":"left","left":"50%","top":"50%","joystickInput":false,"inputValues":[4,5,6,7]},{"type":"button","text":"Start","id":"start","location":"center","left":60,"fontSize":15,"block":true,"input_value":3},{"type":"button","text":"Select","id":"select","location":"center","left":-5,"fontSize":15,"block":true,"input_value":2},{"type":"button","text":"L","id":"l","location":"left","left":3,"top":-100,"bold":true,"block":true,"input_value":10},{"type":"button","text":"R","id":"r","location":"right","right":3,"top":-100,"bold":true,"block":true,"input_value":11}];
|
info = [{"type":"button","text":"X","id":"x","location":"right","left":40,"bold":true,"input_value":9},{"type":"button","text":"Y","id":"y","location":"right","top":40,"bold":true,"input_value":1},{"type":"button","text":"A","id":"a","location":"right","left":81,"top":40,"bold":true,"input_value":8},{"type":"button","text":"B","id":"b","location":"right","left":40,"top":80,"bold":true,"input_value":0},{"type":"dpad","location":"left","left":"50%","top":"50%","joystickInput":false,"inputValues":[4,5,6,7]},{"type":"button","text":"Start","id":"start","location":"center","left":60,"fontSize":15,"block":true,"input_value":3},{"type":"button","text":"Select","id":"select","location":"center","left":-5,"fontSize":15,"block":true,"input_value":2},{"type":"button","text":"L","id":"l","location":"left","left":3,"top":-100,"bold":true,"block":true,"input_value":10},{"type":"button","text":"R","id":"r","location":"right","right":3,"top":-100,"bold":true,"block":true,"input_value":11}];
|
||||||
} else if (this.getCore(true) === "snes") {
|
} else if ("snes" === this.getControlScheme()) {
|
||||||
info = [{"type":"button","text":"X","id":"x","location":"right","left":40,"bold":true,"input_value":9},{"type":"button","text":"Y","id":"y","location":"right","top":40,"bold":true,"input_value":1},{"type":"button","text":"A","id":"a","location":"right","left":81,"top":40,"bold":true,"input_value":8},{"type":"button","text":"B","id":"b","location":"right","left":40,"top":80,"bold":true,"input_value":0},{"type":"dpad","location":"left","left":"50%","top":"50%","joystickInput":false,"inputValues":[4,5,6,7]},{"type":"button","text":"Start","id":"start","location":"center","left":60,"fontSize":15,"block":true,"input_value":3},{"type":"button","text":"Select","id":"select","location":"center","left":-5,"fontSize":15,"block":true,"input_value":2},{"type":"button","text":"L","id":"l","location":"left","left":3,"top":-100,"bold":true,"block":true,"input_value":10},{"type":"button","text":"R","id":"r","location":"right","right":3,"top":-100,"bold":true,"block":true,"input_value":11}];
|
info = [{"type":"button","text":"X","id":"x","location":"right","left":40,"bold":true,"input_value":9},{"type":"button","text":"Y","id":"y","location":"right","top":40,"bold":true,"input_value":1},{"type":"button","text":"A","id":"a","location":"right","left":81,"top":40,"bold":true,"input_value":8},{"type":"button","text":"B","id":"b","location":"right","left":40,"top":80,"bold":true,"input_value":0},{"type":"dpad","location":"left","left":"50%","top":"50%","joystickInput":false,"inputValues":[4,5,6,7]},{"type":"button","text":"Start","id":"start","location":"center","left":60,"fontSize":15,"block":true,"input_value":3},{"type":"button","text":"Select","id":"select","location":"center","left":-5,"fontSize":15,"block":true,"input_value":2},{"type":"button","text":"L","id":"l","location":"left","left":3,"top":-100,"bold":true,"block":true,"input_value":10},{"type":"button","text":"R","id":"r","location":"right","right":3,"top":-100,"bold":true,"block":true,"input_value":11}];
|
||||||
} else if (['segaMD', 'segaCD', 'sega32x'].includes(this.getCore(true))) {
|
} else if (['segaMD', 'segaCD', 'sega32x'].includes(this.getControlScheme())) {
|
||||||
info = [
|
info = [
|
||||||
{"type":"button","text":"A","id":"a","location":"right","right":145,"top":70,"bold":true,"input_value":9},
|
{"type":"button","text":"A","id":"a","location":"right","right":145,"top":70,"bold":true,"input_value":9},
|
||||||
{"type":"button","text":"B","id":"b","location":"right","right":75,"top":70,"bold":true,"input_value":0},
|
{"type":"button","text":"B","id":"b","location":"right","right":75,"top":70,"bold":true,"input_value":0},
|
||||||
|
@ -2403,20 +2410,20 @@ class EmulatorJS {
|
||||||
{"type":"button","text":"Mode","id":"mode","location":"center","left":-5,"fontSize":15,"block":true,"input_value":2},
|
{"type":"button","text":"Mode","id":"mode","location":"center","left":-5,"fontSize":15,"block":true,"input_value":2},
|
||||||
{"type":"button","text":"Start","id":"start","location":"center","left":60,"fontSize":15,"block":true,"input_value":3}
|
{"type":"button","text":"Start","id":"start","location":"center","left":60,"fontSize":15,"block":true,"input_value":3}
|
||||||
];
|
];
|
||||||
} else if ("segaMS" === this.getCore(true)) {
|
} else if ("segaMS" === this.getControlScheme()) {
|
||||||
info = [
|
info = [
|
||||||
{"type":"button","text":"1","id":"button1","location":"right","left":10,"top":40,"bold":true,"input_value":0},
|
{"type":"button","text":"1","id":"button1","location":"right","left":10,"top":40,"bold":true,"input_value":0},
|
||||||
{"type":"button","text":"2","id":"button2","location":"right","left":81,"top":40,"bold":true,"input_value":8},
|
{"type":"button","text":"2","id":"button2","location":"right","left":81,"top":40,"bold":true,"input_value":8},
|
||||||
{"type":"dpad","location":"left","left":"50%","right":"50%","joystickInput":false,"inputValues":[4,5,6,7]}
|
{"type":"dpad","location":"left","left":"50%","right":"50%","joystickInput":false,"inputValues":[4,5,6,7]}
|
||||||
];
|
];
|
||||||
} else if ("segaGG" === this.getCore(true)) {
|
} else if ("segaGG" === this.getControlScheme()) {
|
||||||
info = [
|
info = [
|
||||||
{"type":"button","text":"1","id":"button1","location":"right","left":10,"top":70,"bold":true,"input_value":0},
|
{"type":"button","text":"1","id":"button1","location":"right","left":10,"top":70,"bold":true,"input_value":0},
|
||||||
{"type":"button","text":"2","id":"button2","location":"right","left":81,"top":40,"bold":true,"input_value":8},
|
{"type":"button","text":"2","id":"button2","location":"right","left":81,"top":40,"bold":true,"input_value":8},
|
||||||
{"type":"dpad","location":"left","left":"50%","top":"50%","joystickInput":false,"inputValues":[4,5,6,7]},
|
{"type":"dpad","location":"left","left":"50%","top":"50%","joystickInput":false,"inputValues":[4,5,6,7]},
|
||||||
{"type":"button","text":"Start","id":"start","location":"center","left":30,"fontSize":15,"block":true,"input_value":3}
|
{"type":"button","text":"Start","id":"start","location":"center","left":30,"fontSize":15,"block":true,"input_value":3}
|
||||||
];
|
];
|
||||||
} else if ("segaSaturn" === this.getCore(true)) {
|
} else if ("segaSaturn" === this.getControlScheme()) {
|
||||||
info = [
|
info = [
|
||||||
{"type":"button","text":"A","id":"a","location":"right","right":145,"top":70,"bold":true,"input_value":1},
|
{"type":"button","text":"A","id":"a","location":"right","right":145,"top":70,"bold":true,"input_value":1},
|
||||||
{"type":"button","text":"B","id":"b","location":"right","right":75,"top":70,"bold":true,"input_value":0},
|
{"type":"button","text":"B","id":"b","location":"right","right":75,"top":70,"bold":true,"input_value":0},
|
||||||
|
|
|
@ -71,6 +71,7 @@
|
||||||
config.netplayUrl = window.EJS_netplayServer;
|
config.netplayUrl = window.EJS_netplayServer;
|
||||||
config.gameId = window.EJS_gameID;
|
config.gameId = window.EJS_gameID;
|
||||||
config.backgroundImg = window.EJS_backgroundImage;
|
config.backgroundImg = window.EJS_backgroundImage;
|
||||||
|
config.controlScheme = window.EJS_controlScheme;
|
||||||
|
|
||||||
if (typeof window.EJS_language === "string" && window.EJS_language !== "en-US") {
|
if (typeof window.EJS_language === "string" && window.EJS_language !== "en-US") {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue