-
-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Hyperkin mouse and new mouse API #291
Merged
alekmaul
merged 22 commits into
alekmaul:develop
from
undisbeliever:fix-mouse-with-new-api
Aug 18, 2024
Merged
Fix Hyperkin mouse and new mouse API #291
alekmaul
merged 22 commits into
alekmaul:develop
from
undisbeliever:fix-mouse-with-new-api
Aug 18, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The Hyperkin mouse always outputs a sensitivity of 0, which will cause the mouseSpeedChange loop to always timeout. Decreasing the maximum number of loops will reduce CPU usage when using a Hyperkin mouse.
Also removes the unread private `mouse_sp` variable
and into mouseSpeedChange, since mouseConnect is always true when speed_change is called by the VBlank ISR.
if a non-standard controller is connected to the other controller port.
If the developer was unaware `snes_mouse` was cleared by the VBlank ISR then the player could lock the game if the mouse was ever disconnected. `snes_mouse` can no-longer be used to detect if the mouse has been disconnected from the console. The developer will have to check the `mouseConnect[]` variable instead.
Fixes a typo in the `mouseSpeedSet` mask.
… API) The old `mouseSpeedChange(u8 port)` function has a timing conflict with the auto-joypad-read. The automatic joypad read must not start while the CPU is in the middle of the `mouseSpeedChange()` function. Delaying all mouse sensitivity changes to the VBlank ISR will remove this timing conflict and ensure the mouse sensitivity is cycled at the correct time. This commit removes the old `mouseSpeedSet` variable and the `mouseSpeedChange()` function, replacing them with a `mouseRequestChangeSensitivity` variable that will signal to `_MouseData` that the MainLoop wants to either: * Cycle the mouse sensitivity once. * Cycle the mouse sensitivity twice (decrementing the sensitivity). * Setting the mouse sensitivity to a specific value. This commit also adds a `mouseSensitivity` variable that serves three purposes: 1. Allows the developer to read the reported mouse sensitivity. 2. Allows the developer to set the initial mouse sensitivity. 3. Restore the mouse sensitivity when the mouse is disconnected, then reconnected. Three helper functions have been added to simplify the `mouseRequestChangeSensitivity` writes: * void mouseCycleSensitivity(u16 port) * void mouseCycleSensitivityTwice(u16 port) * void mouseSetSensitivity(u16 port, u16 sensitivity) The two mouse examples have been modified to use the new mouse sensitivity functions and to display the reported mouse sensitivity.
The direction bits now match the snes wiki https://snes.nesdev.org/wiki/Mouse#Report
not matching the mouseSetSensitivity comment in `pvsneslib/source/input.asm`.
Also added a few notes about the mouse buttons and mouse sensitivity
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR serves two purposes.
First, it fixes multiple bugs in the mouse code:
detectMouse()
not detecting a mouse if a non-standard controller is connected to the other controller port. (86fb147)Secondly, it changes the mouse API.
This new API delays all change-mouse-sensitivity commands to the VBlank ISR to prevent a potential timing-conflict that can corrupt the joypad registers (and the mouse reading code).
An
initMouse(u8 sensitivity)
function has been added to simplify mouse initialisation.snes_mouse
is no-longer cleared when the mouse is disconnectedsnes_mouse
was cleared by the VBlank ISR then the player could lock the game if the mouse was ever disconnected.snes_mouse
can no-longer be used to detect if the mouse has been disconnected from the console. The developer will have to check themouseConnect[]
variable instead.The
mouseSpeedSet
variable and themouseSpeedChange()
function have been removed and replaced with amouseRequestChangeSensitivity
variable that will signal to the VBlank ISR that the MainLoop wants to either:A
mouseSensitivity
variable has been added that serves three purposes:Three helper functions have been added to simplify the
mouseRequestChangeSensitivity
writes:void mouseCycleSensitivity(u16 port)
void mouseCycleSensitivityTwice(u16 port)
void mouseSetSensitivity(u16 port, u16 sensitivity)
The existing mouse example has been updated to the new API a new mouse example (
mouse-data-test
) has been added.The two mouse examples in this PR have been tested on my 1-chip Super Famicom console with a Nintendo mouse and a Hyperkin Hyper Click Retro Style Mouse.