Skip to content

Add new sokol_poll.h layer#788

Open
Toctave wants to merge 2 commits into
floooh:masterfrom
Toctave:toctave-sokol-poll
Open

Add new sokol_poll.h layer#788
Toctave wants to merge 2 commits into
floooh:masterfrom
Toctave:toctave-sokol-poll

Conversation

@Toctave

@Toctave Toctave commented Feb 11, 2023

Copy link
Copy Markdown

Basic polling layer on top of sokol_app's event API. Only supports keyboard input for now.

@floooh

floooh commented Feb 12, 2023

Copy link
Copy Markdown
Owner

It's a good PR for discussion, but I'll probably won't merge it, sorry :)

I have a couple more things in mind apart from just managing a key-pressed bitfield:

  • have an "any" and "all" function which take bitmasks to check if any of a key group or all of a key group is currently pressed
  • then there's the whole problem area of missing presses when the down- and up-event happen in the same frame, so "is key X currently pressed" becomes a "was key X pressed at any time during the last frame" => which in turn means that the library needs to know when a new frame starts... for a solution there should probably a separate bitmask for key-down events and key-up events in a frame, which are then 'consolidated' into a key-pressed bitmask.
  • and the 'key mask' should probably be a 'button mask' which at least includes mouse buttons
  • and it should also be possible to poll the current mouse position
  • ...and while at it, it would be nice to tackle gamepad support, but not sure if this should go into a separate header - but the input polling header should at least somehow integrate the gamepad input.

...etc... etc...

@Toctave

Toctave commented Feb 12, 2023

Copy link
Copy Markdown
Author

Yeah I thought of this as a starting point / discussion PR, ofc it won't be merged until it fits what you had in mind.

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.

2 participants