AdamsLair / duality

a 2D Game Development Framework
https://adamslair.github.io/duality
MIT License
1.41k stars 290 forks source link

Fix iNNEXT SNES Controller Input #683

Closed ilexp closed 5 years ago

ilexp commented 5 years ago

Summary

The iNNEXT SNES Controller only works partially in Duality / OpenTK. Investigate the cause and fix this.

How to reproduce

Workaround

Analysis

ilexp commented 5 years ago

SDL2 seems to have switched to a different controller mapping string format between 2.0.4, 2.0.5 and 2.0.6, which means the new SDL2 source input mappings cannot be used as they are. It could be worth extending the format implementation in OpenTK to match.

More links:

ilexp commented 5 years ago

OpenTK issues that may or may not be distantly related, but that could provide a good opportunity to read up on related input concepts and implementations:

ilexp commented 5 years ago

Progress

ToDo

ilexp commented 5 years ago

Investigating the OpenTK Joystick GUID structure and comparing old vs. new SDL2 gamepad mapping schemes, it seems like the switch was from (by example):

ffff0000000000000000504944564944
PID VID             P I D V I D

4c056802000000000000504944564944
PID VID             P I D V I D

to

03000000ffff00000000000000000000
?       PID VID

030000004c0500006802000000000000
?       PID     VID

Which means it should be possible to make the same switch in OpenTK. Need to investigate first whether that GUID is used anywhere to query OS / hardware functionality, which might require a specific format.

ilexp commented 5 years ago

Progress

ToDo

ilexp commented 5 years ago

Progress

ToDo

ilexp commented 5 years ago

Progress

ToDo

ilexp commented 5 years ago

Progress

Ran the InputTest linked above with a potentially different, but probably similar SNES controller from iNNEXT with and without SDL2.

Without SDL2

examples_2018-09-24_19-10-17

With SDL2

examples_2018-09-24_19-10-46

ToDo

SirePi commented 5 years ago

Without SDL

PS4 DualShock 4 controller 03000000-4c05-0000-cc09-000000000000; PS4 Controller Right analog's Y axis mapped as L2 trigger (mapped 0...1, 0.5 at rest) R2 trigger mapped as Right analog's Y axis (mapped -1...1) L2 trigger is seen as R2 trigger

XBox 360 wired controller 78696e70-7574-0000-0000-000000000000; XInput Controller Working ok

With SDL 2.0.8 x64

PS4 DualShock 4 controller 03000000-4c05-0000-cc09-000000000000; PS4 Controller Working "ok" (see below)

XBox 360 wired controller 03000000-5e04-0000-8e02-000000007801; XInput Controller Working "ok" (see below)

In both cases, with SDL, the Left and Right triggers start at 0.5 - once pressed they report correctly from 0 in rest position to 1 fully pressed

ilexp commented 5 years ago

Progress

ToDo

ilexp commented 5 years ago

@SirePi Thanks! Since the PS4 Controller seems to have some problems, can you check the InputHandling sample from the latest Duality master branch version? Does it work there? If it doesn't, does it fail in the same way?

ilexp commented 5 years ago

Talked to @SirePi about the PS4 Controller issue.

With SDL: https://gfycat.com/DescriptiveEthicalCub Without SDL: https://gfycat.com/CreepyFabulousCoypu

Without SDL, the mapping is off, one of the triggers is mapped to a sticks Y axis and vice versa. Could this be a similar issue as with the iNNEXT SNES controller, such as SDL enumerating axes differently?

ToDo

ilexp commented 5 years ago

Progress

Looked into different axis behaviors between SDL2 and OpenTK with iNNEXT SNES.

ToDo

ilexp commented 5 years ago

Progress

ToDo

ilexp commented 5 years ago

Progress

ToDo

ilexp commented 5 years ago

@SirePi Can you check whether there's any change to PS4 controller behavior on the most recent InputTest3.zip download?

Edit: Talked to SirePi on the chat. No changes in PS4 controller behavior after the recent fix.

SirePi commented 5 years ago

Sadly, no changes

ilexp commented 5 years ago

Progress

ToDo

ilexp commented 5 years ago

Progress

Closing this.