Skip to content

Input stuff - #4804

Open
SuuperW wants to merge 8 commits into
TASEmulators:masterfrom
SuuperW:input-stuff
Open

SuuperW wants to merge 8 commits into
TASEmulators:masterfrom
SuuperW:input-stuff

Conversation

@SuuperW

@SuuperW SuuperW commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

This PR changes both JoypadApi.SetAnalog overloads, so that they behave similarly to the Set methods for buttons. This means (1) using OverrideAdapter instead of the sticky controller [fixes the Lua issue observed in #4766], (2) changing the way analog values are unset in the dictionary overload is by passing a dictionary without the relevant keys [allowing it to set neutral axis values], and (3) for Lua, throwing an exception if the input value cannot be converted to an int [instead of silently failing].

The old behavior is still available in a [Obosolete] overload. External tools wishing to make use of this fix will need to be updated for the new method signature. The C# method signature for Lua is identical, so the fixed version uses an updated name set_analog. Lua scripts using setanalog wishing to make use of this fix will need to be updated.

The documentation for the set methods are updated to include "as if the inputs came from the user" (same as the new SetAnalog). This implies that #4769 is indented behavior; auto-fire will obviously work when the button is not otherwise held. Sticky holds and autofires will also interact with buttons held by joypad.set. But this implication is probably not very obvious and better documentation may still be beneficial. Alternatively, we might want to change the behavior.

It also fixes the behavior of the set methods when called from the frame start event, adds tests, and cleans up some code a little bit.

Check if completed:

SuuperW added 6 commits July 26, 2026 13:27
- ButtonOverrideAdapter -> OverrideAdapter because it isn't just for buttons
- ClickyVirtualPadController -> ClickyController because it is not related to the Virtual Pad tool
…not need to know how to use it

fix: Soft/Hard reset menu items did not work if Lua was calling `joypad.set` from `onframestart` event.
@perfectchud

Copy link
Copy Markdown

I've tested this fix and it works perfectly. My mouse movements no longer override lua script's X/Y positions, and I don't have to manually unbind Touch X and Touch Y whenever I want to run a lua script that does touch inputs.
There is one issue that persists: my accidental left clicks still trigger unwanted inputs that would interfere with intended result of my lua script. But here's a workaround: force the script to do joypad.set({ ["Touch"] = false }) whenever the script isn't doing any Touch inputs.

Comment thread src/BizHawk.Client.Common/Api/Classes/JoypadApi.cs
Comment thread src/BizHawk.Client.Common/lua/CommonLibs/JoypadLuaLibrary.cs Outdated
Comment thread src/BizHawk.Tests.Client.Common/Api/JoypadApiTests.cs
@SuuperW

SuuperW commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Force push, to keep old behavior in [Obsolete] methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants