Skip to content

Conversation

@ccawley2011
Copy link
Contributor

No description provided.

@slouken
Copy link
Collaborator

slouken commented Oct 6, 2025

This needs to be adjusted to match the SDL coding style.

@ccawley2011
Copy link
Contributor Author

This needs to be adjusted to match the SDL coding style.

Could you clarify what needs changing?

@slouken slouken added this to the 3.x milestone Oct 9, 2025
@expikr
Copy link
Contributor

expikr commented Oct 24, 2025

What I had in mind while writing the original example was to convey the following two messages to anyone reading the code:

  1. You’ve seen joystick splitscreen before, that’s nothing special. But did you know that Mouse+Keyboard can do local splitscreen too?
  2. Look how little code it takes to get something like this working!

While adding additional device support is technically an improvement, the extra complexity adds a little bit of additional cognitive load to the reader of the example, while not conveying the strictly minimum requirement.

It also somewhat distracts from the uniqueness of mouse/keyboard splitscreen, I’d opine that a pointed omission of joystick support actually showcases the mouse/keyboard functionality better by distancing itself from traditional joystick implementation paradigms.

I think multi-joystick would be better suited to a separate standalone demo, maybe one with a top down cooperative platformer format. It would also better show off the analog directional capabilities of the thumb sticks instead of shoehorning them into a WASD control scheme.

@slouken
Copy link
Collaborator

slouken commented Oct 24, 2025

That's fair feedback, and since @ccawley2011 seems to be away, I'll go ahead and close this for now.

@slouken slouken closed this Oct 24, 2025
@ccawley2011
Copy link
Contributor Author

I probably ought to mention that the main reason for this PR is to better support systems like the 3DS, which doesn't have a keyboard and therefore requires this PR in order to allow input to work at all.

@slouken
Copy link
Collaborator

slouken commented Oct 24, 2025

I probably ought to mention that the main reason for this PR is to better support systems like the 3DS, which doesn't have a keyboard and therefore requires this PR in order to allow input to work at all.

In that case, can you clean up this PR based on our feedback, and I'll go ahead and merge it?

@slouken slouken reopened this Oct 24, 2025
@icculus
Copy link
Collaborator

icculus commented Nov 8, 2025

I rebased this to the latest in revision control and fixed up some things based on feedback. Can y'all take another look over this and see if it's ready to merge?

const Uint64 now = SDL_GetTicks();
int i;

if ((now - gamepad_update_ticks) >= 16) { /* only update joysticks at about 60Hz so framerate doesn't matter. */
Copy link
Contributor

@expikr expikr Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should just forward dt_ns to the gamepad function which multiplies it by the desired angular velocity to get the targeted angular displacement in floats, and the function should return two floats representing residual angles to be carried over next frame, saved as extra fields in the player struct.

}
break;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just get rid of dpad events entirely, use the left stick for analog movement instead.

}
}

static void updatePlayerGamepad(Player *player)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest have this function also handle the left stick to save a 2d direction as an extra field in the player struct representing the current frame’s intended joystick input, akin to how WASD is sampled each frame. It should then be combined with the normalized WASD vector to calculate the final X and Z acceleration

@expikr
Copy link
Contributor

expikr commented Nov 8, 2025

Still feels kinda shoehorned, I wonder if it could be simpler if joystick is made mutually exclusive with mkb, and have a unified sample_inputs function that returns two vectors representing the intended movement magnitude and the integrated angular displacement?

it also feels like it’s just not a very good showcase of joystick usage in general, I have something sketched up in mind of a separate example that I think would work better as demonstration of how to utilize joysticks.

@icculus
Copy link
Collaborator

icculus commented Nov 8, 2025

it also feels like it’s just not a very good showcase of joystick usage in general, I have something sketched up in mind of a separate example that I think would work better as demonstration of how to utilize joysticks.

I have no ego in this (and I assume @ccawley2011 doesn't either)...take a totally different approach and I'll happily close this PR unmerged. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants