add d-pad switches to game controller

mapped some 2-button controllers to Z and X also
This commit is contained in:
Steven Hugg 2023-08-01 12:47:23 -05:00
parent cc385b7d98
commit 3dba86c75d
6 changed files with 19 additions and 8 deletions

View File

@ -351,11 +351,12 @@ type KeyCodeMap = Map<number,KeyMapEntry>;
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},

View File

@ -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],

View File

@ -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],

View File

@ -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],

View File

@ -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],

View File

@ -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],