Added support for Arcade Control Panel for AtGames Legends Pinball Controller (#559)

* Added support for Atgames arcade control panel

* Fixed missing brace

* Swap L & R mapping

After further gameplay, swapped L & R mappings.

* Moved m_arcadepanel init to constructor

---------

Co-authored-by: Matt Simmons <matt.simmons@fedex.com>
This commit is contained in:
SK360 2023-02-17 13:21:41 -05:00 committed by GitHub
parent 540d1fdb23
commit 16a216ebb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 81 additions and 33 deletions

View file

@ -36,38 +36,81 @@ namespace ams::controller {
}
void AtGamesController::MapInputReport0x01(const AtGamesReportData *src) {
m_left_stick.SetData(
STICK_ZERO + 0x7ff * (src->input0x01.nudge_left - src->input0x01.nudge_right),
STICK_ZERO
);
m_right_stick.SetData(
STICK_ZERO,
static_cast<uint16_t>(stick_scale_factor * (UINT8_MAX - src->input0x01.right_stick.x)) & 0xfff
);
m_buttons.dpad_down = (src->input0x01.dpad == AtGamesDPad_S) ||
(src->input0x01.dpad == AtGamesDPad_SE) ||
(src->input0x01.dpad == AtGamesDPad_SW);
m_buttons.dpad_up = (src->input0x01.dpad == AtGamesDPad_N) ||
(src->input0x01.dpad == AtGamesDPad_NE) ||
(src->input0x01.dpad == AtGamesDPad_NW);
m_buttons.dpad_right = (src->input0x01.dpad == AtGamesDPad_E) ||
(src->input0x01.dpad == AtGamesDPad_NE) ||
(src->input0x01.dpad == AtGamesDPad_SE);
m_buttons.dpad_left = (src->input0x01.dpad == AtGamesDPad_W) ||
(src->input0x01.dpad == AtGamesDPad_NW) ||
(src->input0x01.dpad == AtGamesDPad_SW);
if (!m_arcadepanel) {
// Checking if any of the optional Arcade Control Panel buttons are pressed and and switching the mapping
if (src->input0x01.a_button || src->input0x01.b_button || src->input0x01.c_button || src->input0x01.x_button || src->input0x01.y_button || src->input0x01.z_button) {
m_arcadepanel = true;
}
m_left_stick.SetData(
STICK_ZERO + 0x7ff * (src->input0x01.nudge_left - src->input0x01.nudge_right),
STICK_ZERO
);
m_right_stick.SetData(
STICK_ZERO,
static_cast<uint16_t>(stick_scale_factor * (UINT8_MAX - src->input0x01.right_stick.x)) & 0xfff
);
m_buttons.dpad_down = (src->input0x01.dpad == AtGamesDPad_S) ||
(src->input0x01.dpad == AtGamesDPad_SE) ||
(src->input0x01.dpad == AtGamesDPad_SW);
m_buttons.dpad_up = (src->input0x01.dpad == AtGamesDPad_N) ||
(src->input0x01.dpad == AtGamesDPad_NE) ||
(src->input0x01.dpad == AtGamesDPad_NW);
m_buttons.dpad_right = (src->input0x01.dpad == AtGamesDPad_E) ||
(src->input0x01.dpad == AtGamesDPad_NE) ||
(src->input0x01.dpad == AtGamesDPad_SE);
m_buttons.dpad_left = (src->input0x01.dpad == AtGamesDPad_W) ||
(src->input0x01.dpad == AtGamesDPad_NW) ||
(src->input0x01.dpad == AtGamesDPad_SW);
m_buttons.A = src->input0x01.play;
m_buttons.B = src->input0x01.rewind;
m_buttons.Y = src->input0x01.nudge_front;
m_buttons.A = src->input0x01.play;
m_buttons.B = src->input0x01.rewind;
m_buttons.Y = src->input0x01.nudge_front;
m_buttons.R = src->input0x01.flipper_right;
m_buttons.ZR = src->input0x01.flipper_right;
m_buttons.L = src->input0x01.flipper_left;
m_buttons.ZL = src->input0x01.flipper_left;
m_buttons.R = src->input0x01.flipper_right;
m_buttons.ZR = src->input0x01.flipper_right;
m_buttons.L = src->input0x01.flipper_left;
m_buttons.ZL = src->input0x01.flipper_left;
m_buttons.plus = src->input0x01.home_twirl;
m_buttons.plus = src->input0x01.home_twirl;
} else {
m_left_stick.SetData(
STICK_ZERO + 0x7ff * (src->input0x01.nudge_left - src->input0x01.nudge_right),
STICK_ZERO + 0x7ff * (src->input0x01.nudge_front)
);
m_right_stick.SetData(
STICK_ZERO,
static_cast<uint16_t>(stick_scale_factor * (UINT8_MAX - src->input0x01.right_stick.x)) & 0xfff
);
m_buttons.dpad_down = (src->input0x01.dpad == AtGamesDPad_S) ||
(src->input0x01.dpad == AtGamesDPad_SE) ||
(src->input0x01.dpad == AtGamesDPad_SW);
m_buttons.dpad_up = (src->input0x01.dpad == AtGamesDPad_N) ||
(src->input0x01.dpad == AtGamesDPad_NE) ||
(src->input0x01.dpad == AtGamesDPad_NW);
m_buttons.dpad_right = (src->input0x01.dpad == AtGamesDPad_E) ||
(src->input0x01.dpad == AtGamesDPad_NE) ||
(src->input0x01.dpad == AtGamesDPad_SE);
m_buttons.dpad_left = (src->input0x01.dpad == AtGamesDPad_W) ||
(src->input0x01.dpad == AtGamesDPad_NW) ||
(src->input0x01.dpad == AtGamesDPad_SW);
m_buttons.A = src->input0x01.a_button;
m_buttons.B = src->input0x01.b_button;
m_buttons.X = src->input0x01.x_button;
m_buttons.Y = src->input0x01.y_button;
m_buttons.R = src->input0x01.c_button;
m_buttons.ZR = src->input0x01.flipper_right;
m_buttons.L = src->input0x01.z_button;
m_buttons.ZL = src->input0x01.flipper_left;
m_buttons.minus = src->input0x01.rewind;
m_buttons.plus = src->input0x01.play;
m_buttons.home = src->input0x01.home_twirl;
}
}
}

View file

@ -38,16 +38,19 @@ namespace ams::controller {
struct AtGamesInputReport0x01 {
uint8_t rewind : 1;
uint8_t nudge_front : 1;
uint8_t : 2;
uint8_t b_button : 1;
uint8_t y_button : 1;
uint8_t nudge_left : 1;
uint8_t flipper_right : 1;
uint8_t : 1;
uint8_t x_button : 1;
uint8_t play : 1;
uint8_t : 1;
uint8_t a_button : 1;
uint8_t home_twirl : 1;
uint8_t flipper_left : 1;
uint8_t nudge_right : 1;
uint8_t z_button : 1;
uint8_t c_button : 1;
uint8_t : 0;
uint8_t unk1[2];
@ -73,12 +76,14 @@ namespace ams::controller {
};
AtGamesController(const bluetooth::Address *address, HardwareID id)
: EmulatedSwitchController(address, id) { }
: EmulatedSwitchController(address, id), m_arcadepanel(false) { }
void ProcessInputData(const bluetooth::HidReport *report) override;
private:
void MapInputReport0x01(const AtGamesReportData *src);
bool m_arcadepanel;
};