diff --git a/src/common/emu.ts b/src/common/emu.ts index 6510b8e9..3ec11ac9 100644 --- a/src/common/emu.ts +++ b/src/common/emu.ts @@ -351,11 +351,12 @@ type KeyCodeMap = Map; export const Keys = { ANYKEY: {c: 0, n: "?"}, + // https://w3c.github.io/gamepad/#remapping // gamepad and keyboard (player 0) - UP: {c: 38, n: "Up", plyr:0, yaxis:-1}, - DOWN: {c: 40, n: "Down", plyr:0, yaxis:1}, - LEFT: {c: 37, n: "Left", plyr:0, xaxis:-1}, - RIGHT: {c: 39, n: "Right", plyr:0, xaxis:1}, + UP: {c: 38, n: "Up", plyr:0, button:12, yaxis:-1}, + DOWN: {c: 40, n: "Down", plyr:0, button:13, yaxis:1}, + LEFT: {c: 37, n: "Left", plyr:0, button:14, xaxis:-1}, + RIGHT: {c: 39, n: "Right", plyr:0, button:15, xaxis:1}, A: {c: 32, n: "Space", plyr:0, button:0}, B: {c: 16, n: "Shift", plyr:0, button:1}, GP_A: {c: 88, n: "X", plyr:0, button:0}, @@ -366,10 +367,10 @@ export const Keys = { START: {c: 13, n: "Enter", plyr:0, button:9}, OPTION: {c: 8, n: "Bcksp", plyr:0, button:10}, // gamepad and keyboard (player 1) - P2_UP: {c: 87, n: "W", plyr:1, yaxis:-1}, - P2_DOWN: {c: 83, n: "S", plyr:1, yaxis:1}, - P2_LEFT: {c: 65, n: "A", plyr:1, xaxis:-1}, - P2_RIGHT: {c: 68, n: "D", plyr:1, xaxis:1}, + P2_UP: {c: 87, n: "W", plyr:1, button:12, yaxis:-1}, + P2_DOWN: {c: 83, n: "S", plyr:1, button:13, yaxis:1}, + P2_LEFT: {c: 65, n: "A", plyr:1, button:14, xaxis:-1}, + P2_RIGHT: {c: 68, n: "D", plyr:1, button:15, xaxis:1}, P2_A: {c: 84, n: "T", plyr:1, button:0}, P2_B: {c: 82, n: "R", plyr:1, button:1}, P2_GP_A: {c: 69, n: "E", plyr:1, button:0}, diff --git a/src/machine/arm32.ts b/src/machine/arm32.ts index 00b70392..e85edc4a 100644 --- a/src/machine/arm32.ts +++ b/src/machine/arm32.ts @@ -8,6 +8,8 @@ import { hex, lpad } from "../common/util"; var GBA_KEYCODE_MAP = makeKeycodeMap([ [Keys.A, 0, 0x1], [Keys.B, 0, 0x2], + [Keys.GP_A, 0, 0x1], + [Keys.GP_B, 0, 0x2], [Keys.SELECT,0, 0x4], [Keys.START ,0, 0x8], [Keys.RIGHT, 0, 0x10], diff --git a/src/machine/atari7800.ts b/src/machine/atari7800.ts index ec61f81c..306508d1 100644 --- a/src/machine/atari7800.ts +++ b/src/machine/atari7800.ts @@ -42,6 +42,8 @@ const INPT0 = 8; const Atari7800_KEYCODE_MAP = makeKeycodeMap([ [Keys.A, INPT0+0, 0x80], [Keys.B, INPT0+1, 0x80], + [Keys.GP_A, INPT0+0, 0x80], + [Keys.GP_B, INPT0+1, 0x80], [Keys.SELECT, SWCHB, -0x02], [Keys.START, SWCHB, -0x01], [Keys.UP, SWCHA, -0x10], diff --git a/src/machine/coleco.ts b/src/machine/coleco.ts index 99b42ec1..cd759f8d 100644 --- a/src/machine/coleco.ts +++ b/src/machine/coleco.ts @@ -32,6 +32,8 @@ var COLECOVISION_KEYCODE_MAP = makeKeycodeMap([ [Keys.RIGHT, 0, 0x2], [Keys.A, 0, 0x40], [Keys.B, 1, 0x40], + [Keys.GP_A, 0, 0x40], + [Keys.GP_B, 1, 0x40], [Keys.P2_UP, 2, 0x1], [Keys.P2_DOWN, 2, 0x4], diff --git a/src/machine/sms.ts b/src/machine/sms.ts index 3872cbed..9c1cd720 100644 --- a/src/machine/sms.ts +++ b/src/machine/sms.ts @@ -18,6 +18,8 @@ var SG1000_KEYCODE_MAP = makeKeycodeMap([ [Keys.RIGHT, 0, 0x8], [Keys.A, 0, 0x10], [Keys.B, 0, 0x20], + [Keys.GP_A, 0, 0x10], + [Keys.GP_B, 0, 0x20], [Keys.P2_UP, 0, 0x40], [Keys.P2_DOWN, 0, 0x80], diff --git a/src/platform/nes.ts b/src/platform/nes.ts index 6fab6bd4..39f471b5 100644 --- a/src/platform/nes.ts +++ b/src/platform/nes.ts @@ -50,6 +50,8 @@ const JSNES_PRESETS = [ const JSNES_KEYCODE_MAP = makeKeycodeMap([ [Keys.A, 0, 0], [Keys.B, 0, 1], + [Keys.GP_A, 0, 0], + [Keys.GP_B, 0, 1], [Keys.SELECT, 0, 2], [Keys.START, 0, 3], [Keys.UP, 0, 4],