From 043216aa7503eb7645ff3240663349f3cdb61f14 Mon Sep 17 00:00:00 2001 From: Greenlamp Date: Sat, 11 May 2024 02:36:47 +0200 Subject: [PATCH] adding essential data into config file --- src/configs/pad_dualshock.ts | 26 ++++++++++++++++++++++++-- src/configs/pad_generic.ts | 24 ++++++++++++++++++++++++ src/configs/pad_unlicensedSNES.ts | 22 ++++++++++++++++++++++ src/inputs-controller.ts | 11 +++++++++++ 4 files changed, 81 insertions(+), 2 deletions(-) diff --git a/src/configs/pad_dualshock.ts b/src/configs/pad_dualshock.ts index e9cb844ed..427a70c4c 100644 --- a/src/configs/pad_dualshock.ts +++ b/src/configs/pad_dualshock.ts @@ -1,3 +1,6 @@ +import {SettingGamepad} from "../system/settings-gamepad"; +import {Button} from "../enums/buttons"; + /** * Dualshock mapping */ @@ -21,7 +24,6 @@ const pad_dualshock = { LC_S: 13, LC_W: 14, LC_E: 15, - MENU: 16, TOUCH: 17 }, icons: { @@ -41,8 +43,28 @@ const pad_dualshock = { LC_S: "T_P4_Dpad_Down_Default.png", LC_W: "T_P4_Dpad_Left_Default.png", LC_E: "T_P4_Dpad_Right_Default.png", - MENU: "", TOUCH: "T_P4_Touch_Pad_Default.png" + }, + setting: { + RC_S: SettingGamepad.Button_Action, + RC_E: SettingGamepad.Button_Cancel, + }, + default: { + RC_S: Button.ACTION, + RC_E: Button.CANCEL, + RC_W: Button.CYCLE_NATURE, + RC_N: Button.CYCLE_VARIANT, + START: Button.MENU, + SELECT: Button.STATS, + LB: Button.CYCLE_FORM, + RB: Button.CYCLE_SHINY, + LT: Button.CYCLE_GENDER, + RT: Button.CYCLE_ABILITY, + LC_N: Button.UP, + LC_S: Button.DOWN, + LC_W: Button.LEFT, + LC_E: Button.RIGHT, + TOUCH: Button.SUBMIT, } }; diff --git a/src/configs/pad_generic.ts b/src/configs/pad_generic.ts index 00346413d..f4f459aeb 100644 --- a/src/configs/pad_generic.ts +++ b/src/configs/pad_generic.ts @@ -1,3 +1,6 @@ +import {SettingGamepad} from "../system/settings-gamepad"; +import {Button} from "../enums/buttons"; + /** * Generic pad mapping */ @@ -40,6 +43,27 @@ const pad_generic = { LC_W: "T_X_Dpad_Left_Alt.png", LC_E: "T_X_Dpad_Right_Alt.png", MENU: "" + }, + setting: { + RC_S: SettingGamepad.Button_Action, + RC_E: SettingGamepad.Button_Cancel, + }, + default: { + RC_S: Button.ACTION, + RC_E: Button.CANCEL, + RC_W: Button.CYCLE_NATURE, + RC_N: Button.CYCLE_VARIANT, + START: Button.MENU, + SELECT: Button.STATS, + LB: Button.CYCLE_FORM, + RB: Button.CYCLE_SHINY, + LT: Button.CYCLE_GENDER, + RT: Button.CYCLE_ABILITY, + LC_N: Button.UP, + LC_S: Button.DOWN, + LC_W: Button.LEFT, + LC_E: Button.RIGHT, + TOUCH: Button.SUBMIT, } }; diff --git a/src/configs/pad_unlicensedSNES.ts b/src/configs/pad_unlicensedSNES.ts index 2da76b804..ca58d7649 100644 --- a/src/configs/pad_unlicensedSNES.ts +++ b/src/configs/pad_unlicensedSNES.ts @@ -1,3 +1,6 @@ +import {SettingGamepad} from "../system/settings-gamepad"; +import {Button} from "../enums/buttons"; + /** * 081f-e401 - UnlicensedSNES */ @@ -31,6 +34,25 @@ const pad_unlicensedSNES = { LC_S: "T_X_Dpad_Down_Alt.png", LC_W: "T_X_Dpad_Left_Alt.png", LC_E: "T_X_Dpad_Right_Alt.png", + }, + setting: { + RC_S: SettingGamepad.Button_Action, + RC_E: SettingGamepad.Button_Cancel, + }, + default: { + RC_S: Button.ACTION, + RC_E: Button.CANCEL, + RC_W: Button.CYCLE_NATURE, + RC_N: Button.CYCLE_VARIANT, + START: Button.MENU, + SELECT: Button.STATS, + LB: Button.CYCLE_FORM, + RB: Button.CYCLE_SHINY, + LC_N: Button.UP, + LC_S: Button.DOWN, + LC_W: Button.LEFT, + LC_E: Button.RIGHT, + TOUCH: Button.SUBMIT, } }; diff --git a/src/inputs-controller.ts b/src/inputs-controller.ts index c2b376109..2dba78f36 100644 --- a/src/inputs-controller.ts +++ b/src/inputs-controller.ts @@ -18,11 +18,21 @@ export interface IconsMapping { [key: string]: string; } +export interface SettingMapping { + [key: string]: string; +} + +export interface DefaultMapping { + [key: string]: Button; +} + export interface GamepadConfig { padID: string; padType: string; gamepadMapping: GamepadMapping; icons: IconsMapping; + setting: SettingMapping; + default: DefaultMapping; } export interface ActionGamepadMapping { @@ -289,6 +299,7 @@ export class InputsController { this.player[gamepad]['custom'] = mappedPad.gamepadMapping; this.player[gamepad]['icons'] = mappedPad.icons; this.player[gamepad]['type'] = mappedPad.padType; + this.player[gamepad]['default'] = mappedPad.default; } if (this.chosenGamepad === thisGamepad.id) this.initChosenGamepad(this.chosenGamepad) }