desktop-ui, n64, ps1: Introduce stick configuration settings #2122
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 multi-faceted PR focuses upon giving analog stick configuration options to ares users. With the change in technology and mechanical properties of analog sticks over the years, flexible settings need to be offered to cater to both user preference and better representation of the older, higher tension analog sticks as well as the true electrical limit of a given system. The following settings have been introduced:
Output Style: This setting effectively controls shape with the assumption that the starting gate of a user's analog stick is circular. That circle can either remain or be cut or morphed into another shape. Depending upon the style, the initial circle will be sized to an appropriate saturation radius to ensure full diagonal output for the emulated system under default conditions. Currently, there are seven styles with an additional three max output adjustable custom styles.
Max Output Reducer 1/2 Factor: This pair of settings is intended for keyboard users and works by limiting the max output. When both factors are activated by their corresponding input buttons, the sum is taken of the two percentages and caps any result above 100% to 100%.
Custom Max Output: As alluded to earlier, this setting only applies when a custom style is selected. Changing the max output level can cause compatibility problems for a handful of games. Therefore, an attempt was made here to create a division line to keep the user conscious of reduced compatibility while allowing those who wish to tinker or test homebrew to have it.
Deadzone Shape: There are two options present: axial or radial. Axial is ares' current default and represents most analog sticks throughout gaming history. With that said, some users prefer a radial deadzone where all directions are treated equally and no cardinal snapping occurs.
Deadzone Size: This setting appears simple on the surface. Unfortunately, the analog stick gates of the systems ares emulates means the normal flat percentage approach cannot be taken. To combat this, the deadzone is a value from anywhere between 0 and 127 (the positive values and zero of an 8-bit signed integer), and up to two percentages are then calculated a displayed within the GUI window. With output styles that are virtually cut shapes, one percentage is needed for the deadzone size relative to the virtual max output and the other for the real max output at the edge of the circle. This provides clarity to user over a flat percentage that would falsely represent the size.
Sensitivity: This setting works as expected. Lower sensitivity proportionally leads to lower max output. Higher sensitivity allows you to reach mac output faster. This effect also holds true with an applied response curve.
Response Curve: This setting and its following two sub-settings are the main drivers for this pull request. Taking a cue from mechanics, many systems have a sinusoidal component and abide by simple harmonic motion. Therefore, the general response curve employed here follows a cosine step function in its sine form and allows for manipulation of the inflection point and response strength to take full advantage of what seems to be mechanically true. With this great flexibility, one can hopefully recreate some of the high tension feeling of an old analog stick with a relaxed to aggressive (or to linear) curve at the cost of a larger stick throw. Optionally, one can choose to produce more aggressive output if they desire or, for example, want to lower the impact of high tension analog stick.
Behavior Switch Distance: This response curve sub-setting shifts the point on the curve (in terms of percentage past the deadzone relative to the analog stick's edge) where the output changes behavior.
Response Strength: This response curve sub-setting simply defines how pronounced or subtle the curve will be. Mathematically, there are limits to what can be reached before encountering undefined behavior. The response strength works off of these limits and uses the linear scenario as its zero to form the percentage, thereby giving 100 points of control to the user between minimum and maximum strength.
Virtual Notches: This setting recognizes that the gates created by the output styles can be somewhat ignored and chooses a different approach to help bring out the feeling of a physical notch some analog sticks had. The algorithm here is heavily based on Ryzee119's usb64 MIT-licensed code and has been given the green light by the aforementioned individual to use in ares.
Notch Length from Edge: This virtual notch sub-setting intends to create the Euclidean length of the notch from the stick's edge. The widely used default is a fixed 10%. However, this may not be best for ares and needs consideration.
Angular Snapping Distance: This virtual notch sub-setting defines the angular distance threshold where the input will snap to the notch.
With all of these settings comes an extensive settings window with many sliders, a few combo boxes, a group of radio buttons, and a checkbox. Due to these numerous elements, the settings window had to be resized to fit. The window is now 825 x 560 instead of 700 x 425.
Finally, this PR is in a draft state for multiple reasons. First, the GUI lacks any way to handle storing settings and initializing to defaults for multiple systems, controller ports, and analog sticks. Therefore, only Controller Port 1 will be affected by these settings, and the remaining ports will resort to the core's default settings. Systems with two analog sticks will have both sticks treated equally. Second, only analog sticks connected at boot will have the settings applied immediately. For those not initially connected or disconnected and reconnected, the settings have to be nudged back into place. Third, some general code consolidation or simplification could be achievable. Next, testing is needed to make sure everything is in proper working order on all supported operating systems. Features such as save states and reload have not been tested yet.
Finally, assistance is requested to help overcome the limitations mentioned above.