matlo / GIMX

The GIMX software.
GNU General Public License v3.0
590 stars 105 forks source link

Asymmetric compensation of axis #689

Open Lucashsmello opened 2 years ago

Lucashsmello commented 2 years ago

Hi @matlo,

This issue is related to a more precise 1:1 mouse to axis translation.

In DS4, the right stick X has 1 byte of values (-128 to 127). There are more negative values (128) than positive values (127) and the highest negative value is -128 while the highest positive value is 127, making the axis a bit asymmetric with respect to left and right. To compensate for this, some games use the value 0 as an additional positive value, making left and right symmetric. In this way, value 0 corresponds to the same speed (in absolute values) as -1, and 1 corresponds to -2, and 2 corresponds to -3, and so on. This occurs in the y axis too.

Evidence of this can be collected by just sending a gimx event with a right stick x value around the deadzone. For example, in Overwatch, I found that sending gimx --event "rstick x(13)" --dst IP:PORT moves the aim while sending gimx --event "rstick x(-13)" --dst IP:PORT, the aim does not move. Also, sending rstick x(-14) moves at the same speed as rstick x(13).

This is noticeable only when close to the deadzone and when using some aim response curves such as linear response. To implement this in gimx, it just needs to add +1 to the axis value, if axis>=0, at the end of the mouse2axis conversion or subtracting 1, if axis<0 (not both!). As I don't know if all games implement this mechanism, I suggest adding an option "symmetric_axis_mode" in the XML config file like this:

<axis id="rel_axis_2" label="Aim horizontal">
          <event type="axis" id="x" symmetric_axis_mode="increment" (...) />
</axis>

At first, the "symmetric_axis_mode" can be only "increment" (the implementation above) or "none" (current implementation). I can think of other ways that game developers may implement a kind of symmetric axis, such as

I am intending to implement this like suggested above and do a pull request. Is it seems good for you?