mirror of
https://github.com/ddeverill/SteamlessController.git
synced 2026-10-23 07:02:16 -05:00
Fix custom back button mappings being ignored in mouse click mode
"Back Buttons as Mouse Click" hijacked L4 and R4 unconditionally: the virtual controller skipped their bindings entirely, so a paddle mapped to RT silently did nothing while the option was on. Only the upper paddles were affected, so the symptom read as "two of my four paddles are dead" rather than pointing at the toggle. The same gate also suppressed the Left/Right Click bindings the remap window already offered, meaning the feature disabled the very capability it existed to provide. The toggle was a strict subset of the remap window, which already offers left and right click per paddle, so retire it rather than teach it to cooperate: - Remove the backMouseEnabled gates, the tray item, and the duplicate L4/R4 handling in TrackpadMouse. Paddle mouse output now flows through the single edge-detection path in ReadLoop. - Default L4 and R4 to left click so a fresh install still clicks out of the box. - Add an explicit Off option to the picker. None was already a real "do nothing", but Reset now yields left click, so without this there would be no way to disable a paddle at all. - Migrate BackButtons=1 into real bindings, filling in only paddles with no binding of their own so an explicit mapping is never overwritten, then delete the value so it runs once. TrackpadMouse::Reset used to release a paddle held while game mode was torn down. Removing its L4/R4 handling would have stranded the mouse button down, so that cleanup moves to ReleasePaddleMouseButtons, which also covers right click and runs on the enable, disable, and destructor paths. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0833d51868
commit
ba215b2429
11 files changed
+78
-68
No files matched your search
@@ -34,6 +34,11 @@ struct ControllerManager::Slot {
|
||||
// thread for that timeout on every one of those attempts.
|
||||
std::chrono::steady_clock::time_point lastSilentAt{};
|
||||
|
||||
// Mouse buttons currently held down by a back paddle, so leaving game mode
|
||||
// mid-press releases them instead of stranding the button down.
|
||||
bool paddleMouseLeftDown = false;
|
||||
bool paddleMouseRightDown = false;
|
||||
|
||||
// Haptic edge-detection state for touch (movement ticks).
|
||||
bool hapticWasRightTouching = false;
|
||||
bool hapticWasLeftTouching = false;
|
||||
@@ -197,6 +202,7 @@ ControllerManager::~ControllerManager() {
|
||||
if (slot->gameModeActive) {
|
||||
StopReadLoop(*slot);
|
||||
slot->trackpad.Reset();
|
||||
ReleasePaddleMouseButtons(*slot);
|
||||
slot->vc.reset();
|
||||
slot->gameModeActive = false;
|
||||
}
|
||||
@@ -276,10 +282,17 @@ void ControllerManager::SetBackButtonConfig(const BackButtonConfig& cfg) {
|
||||
// change takes effect on the very next report.
|
||||
}
|
||||
|
||||
void ControllerManager::SetBackButtonsEnabled(bool enabled) {
|
||||
m_backButtonsEnabled = enabled;
|
||||
for (auto& slot : m_slots)
|
||||
slot->trackpad.SetBackButtonsEnabled(enabled);
|
||||
void ControllerManager::ReleasePaddleMouseButtons(Slot& slot) {
|
||||
auto send = [](DWORD flags) {
|
||||
INPUT inp{};
|
||||
inp.type = INPUT_MOUSE;
|
||||
inp.mi.dwFlags = flags;
|
||||
SendInput(1, &inp, sizeof(INPUT));
|
||||
};
|
||||
if (slot.paddleMouseLeftDown) send(MOUSEEVENTF_LEFTUP);
|
||||
if (slot.paddleMouseRightDown) send(MOUSEEVENTF_RIGHTUP);
|
||||
slot.paddleMouseLeftDown = false;
|
||||
slot.paddleMouseRightDown = false;
|
||||
}
|
||||
|
||||
void ControllerManager::SetControllerPlatform(ControllerPlatform platform) {
|
||||
@@ -443,9 +456,9 @@ ControllerManager::EnableGameModeSlot(Slot& slot, bool& vigemMissingOut,
|
||||
EventLog::Write("GAMEMODE: enabled %ls", slot.path.c_str());
|
||||
slot.gameModeActive = true;
|
||||
slot.trackpad.Reset();
|
||||
ReleasePaddleMouseButtons(slot);
|
||||
slot.trackpad.SetTrackpadEnabled(m_trackpadMouseEnabled);
|
||||
slot.trackpad.SetUseLeftTrackpad(m_useLeftTrackpad);
|
||||
slot.trackpad.SetBackButtonsEnabled(m_backButtonsEnabled);
|
||||
StartReadLoop(slot);
|
||||
return GameModeOutcome::Enabled;
|
||||
}
|
||||
@@ -457,6 +470,7 @@ void ControllerManager::DisableGameModeSlot(Slot& slot) {
|
||||
if (slot.sc->IsOpen())
|
||||
slot.sc->SetRumble(0, 0);
|
||||
slot.trackpad.Reset();
|
||||
ReleasePaddleMouseButtons(slot);
|
||||
slot.vc.reset();
|
||||
slot.sc->EnableLizardMode();
|
||||
// Reopen shared so Steam can obtain write access — game mode is no longer active.
|
||||
@@ -563,7 +577,7 @@ void ControllerManager::ReadLoop(Slot* slot) {
|
||||
|
||||
if (!SteamController::IsStateReportId(buf[0])) continue;
|
||||
|
||||
if (slot->vc) slot->vc->Update(buf, n, m_backConfig, m_backButtonsEnabled);
|
||||
if (slot->vc) slot->vc->Update(buf, n, m_backConfig);
|
||||
slot->trackpad.Update(buf, n);
|
||||
|
||||
// Trackpad haptics.
|
||||
@@ -764,8 +778,7 @@ void ControllerManager::ReadLoop(Slot* slot) {
|
||||
|
||||
// Fire mouse button events for back paddles mapped to LeftMouseButton/RightMouseButton.
|
||||
// Uses edge detection so we only send DOWN on press and UP on release.
|
||||
// Skipped when backButtonsEnabled — TrackpadMouse already handles L4/R4 in that mode.
|
||||
if (!m_backButtonsEnabled && hasPrev) {
|
||||
if (hasPrev) {
|
||||
struct PaddleEdge { bool cur; bool prev; BackButtonAction action; };
|
||||
const PaddleEdge edges[] = {
|
||||
{ n>4 && (buf[4]&SteamController::BTN_L4)!=0, (prevBuf[4]&SteamController::BTN_L4)!=0, m_backConfig.l4 },
|
||||
@@ -776,8 +789,13 @@ void ControllerManager::ReadLoop(Slot* slot) {
|
||||
for (const auto& e : edges) {
|
||||
if (e.cur == e.prev) continue;
|
||||
DWORD flag = 0;
|
||||
if (e.action == BackButtonAction::LeftMouseButton) flag = e.cur ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP;
|
||||
else if (e.action == BackButtonAction::RightMouseButton) flag = e.cur ? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_RIGHTUP;
|
||||
if (e.action == BackButtonAction::LeftMouseButton) {
|
||||
flag = e.cur ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_LEFTUP;
|
||||
slot->paddleMouseLeftDown = e.cur;
|
||||
} else if (e.action == BackButtonAction::RightMouseButton) {
|
||||
flag = e.cur ? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_RIGHTUP;
|
||||
slot->paddleMouseRightDown = e.cur;
|
||||
}
|
||||
if (flag) { INPUT inp{}; inp.type = INPUT_MOUSE; inp.mi.dwFlags = flag; SendInput(1, &inp, sizeof(INPUT)); }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user