From 69d78e0a878cb1b3682d63e26e614104ac4e34e5 Mon Sep 17 00:00:00 2001 From: oleg238948234 <155594697+oleg238948234@users.noreply.github.com> Date: Tue, 30 Dec 2025 13:29:43 +0500 Subject: [PATCH] gitadora: (arena model) fix j32d encoding & use velocity (#483) ## Link to GitHub Issue, if one exists N/A ## Description of change in current implementation j32d analog values are not encoded properly, values are supposed to go up to 1023, but they show up as 771 in game ## Testing tested with M32-007-2025092400, used DM PAD CALIBRATION menu --- src/spice2x/games/gitadora/j32d.cpp | 50 ++++++++++++----------------- src/spice2x/games/gitadora/j32d.h | 2 +- 2 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/spice2x/games/gitadora/j32d.cpp b/src/spice2x/games/gitadora/j32d.cpp index c2106ba..3f645a6 100644 --- a/src/spice2x/games/gitadora/j32d.cpp +++ b/src/spice2x/games/gitadora/j32d.cpp @@ -53,37 +53,27 @@ bool games::gitadora::J32DSerialDevice::parse_msg( pid += 1; J32D_IO_STATUS payload; memset(&payload, 0, sizeof(J32D_IO_STATUS)); + auto &buttons = get_buttons(); + auto high_tom = (uint16_t) (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumHiTom]) * 1023); + auto low_tom = (uint16_t) (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumLowTom]) * 1023); + auto snare = (uint16_t) (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumSnare]) * 1023); + auto floor_tom = (uint16_t) (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumFloorTom]) * 1023); + auto left_cymbal = (uint16_t) (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumLeftCymbal]) * 1023); + auto right_cymbal = (uint16_t) (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumRightCymbal]) * 1023); + auto hihat = (uint16_t) ((GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumHiHat]) || + GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumHiHatClosed]) || + GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumHiHatHalfOpen])) * 1023); - if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumHiTom])) { - payload.high_tom = 4092; - } - - if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumLowTom])) { - payload.low_tom = 4092; - } - - if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumSnare])) { - payload.snare = 4092; - } - - if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumFloorTom])) { - payload.floor_tom = 4092; - } - - if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumLeftCymbal])) { - payload.left_cymbal = 4092; - } - - if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumRightCymbal])) { - payload.right_cymbal = 4092; - } - - if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumHiHat]) || - GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumHiHatClosed]) || - GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumHiHatHalfOpen])) { - payload.hihat = 4092; - } +#define ENCODE_ANALOG(__val) (((__val & 0x3f) << 10) | ((__val & 0x3c0) >> 6)) + payload.high_tom = ENCODE_ANALOG(high_tom); + payload.low_tom = ENCODE_ANALOG(low_tom); + payload.snare = ENCODE_ANALOG(snare); + payload.floor_tom = ENCODE_ANALOG(floor_tom); + payload.left_cymbal = ENCODE_ANALOG(left_cymbal); + payload.right_cymbal = ENCODE_ANALOG(right_cymbal); + payload.hihat = ENCODE_ANALOG(hihat); +#undef ENCODE_ANALOG if (GameAPI::Buttons::getState(RI_MGR, buttons[Buttons::DrumBassPedal])) { payload.pedals |= 1; @@ -107,4 +97,4 @@ bool games::gitadora::J32DSerialDevice::parse_msg( // mark as handled return true; -} \ No newline at end of file +} diff --git a/src/spice2x/games/gitadora/j32d.h b/src/spice2x/games/gitadora/j32d.h index 5adedee..799fa69 100644 --- a/src/spice2x/games/gitadora/j32d.h +++ b/src/spice2x/games/gitadora/j32d.h @@ -22,4 +22,4 @@ namespace games::gitadora { uint8_t pedals; }; }; -} \ No newline at end of file +}