Skip to content

Commit

Permalink
don't try to "fix" y axis in touchpad (it should just match the mouse…
Browse files Browse the repository at this point in the history
… convention), add touchpad button to default controls for nds/3ds touch

note that touchpad axes aren't put in default controls, can't actually have multiple axes bound at the same time
  • Loading branch information
CasualPokePlayer committed Jan 7, 2025
1 parent cf1c2a9 commit 24a4b47
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Assets/defctrl.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
"ZR": "R, J1 B8, X1 RightTrigger",
"Select": "Space, J1 B9, X1 Back",
"Start": "Enter, J1 B10, X1 Start",
"Touch": "WMouse L",
"Touch": "WMouse L, X1 Touchpad",
"Tilt": "WMouse R",
},
"NDS Controller": {
Expand All @@ -145,7 +145,7 @@
"R": "E, J1 B6, X1 RightShoulder",
"Select": "Space, J1 B9, X1 Back",
"Start": "Enter, J1 B10, X1 Start",
"Touch": "WMouse L",
"Touch": "WMouse L, X1 Touchpad",
"Microphone": "M"
},
"Atari 2600 Basic Controller": {
Expand Down
8 changes: 5 additions & 3 deletions src/BizHawk.Bizware.Input/SDL2/SDL2Gamepad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ private SDL2Gamepad(int index)
("RightTrigger", Conv(SDL_GameControllerGetAxis(Opaque, SDL_GameControllerAxis.SDL_CONTROLLER_AXIS_TRIGGERRIGHT)))
];

static int TouchConv(float num) => (int)((num * 2.0f - 1.0f) * 10000.0f);
// note: this mimics the mouse conversion in MainForm
// also, don't try to "correct" the Y axis here, -/+ for u/d is how mouse does it, so that should be used here
static int TouchConv(float num) => (int)((num * 20000) - 10000);
var numTouchpads = SDL_GameControllerGetNumTouchpads(Opaque);
if (numTouchpads == 1)
{
Expand All @@ -305,7 +307,7 @@ private SDL2Gamepad(int index)
if (state != 0)
{
values.Add(("TouchpadX", TouchConv(x)));
values.Add(("TouchpadY", -TouchConv(y)));
values.Add(("TouchpadY", TouchConv(y)));
}
else
{
Expand All @@ -321,7 +323,7 @@ private SDL2Gamepad(int index)
if (state != 0)
{
values.Add(($"Touchpad{i}X", TouchConv(x)));
values.Add(($"Touchpad{i}Y", -TouchConv(y)));
values.Add(($"Touchpad{i}Y", TouchConv(y)));
}
else
{
Expand Down

0 comments on commit 24a4b47

Please sign in to comment.