-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Implement an input event specific system call for SDL #35
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new file docs/syscall.md
, which describes the SDL oriented system calls.
The Quake ELF file should be updated in another pull request. Let's concentrate on code reviewing first.
Read How to Write a Git Commit Message carefully and improve the git commit messages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use git rebase -i
to squash and write down informative git commit messages.
719a566
to
91e5c11
Compare
The proposed git commit message:
Instead of "integrates," we can say, "introduces," which practically explains the motivation. |
6584874
to
91da769
Compare
uint32_t type; | ||
union { | ||
key_event_t key_event; | ||
union { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if a union
always works as expected. Can you confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the conflict with the latest master
branch.
754a64a
to
85fcaf5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve the writing of git commit message:
- Fix grammar mistakes.
- Explain why mouse motion and button are considered as different events from a classification perspective.
- Remove the statement " this new system will improve the interactivity of this emulator" since it is obvious.
Everytime a new frame is drawn, all new input events are pushed into the internal event queue, this commit introduces a new system call, poll_event, which attempts to pop events from the internal event queue and returns input specific event information to the user code. Supported event types: Keyboard Event: either a key is pressed or released Mouse motion event: the cursor is moved Mouse button event: either a mouse button is pressed or released Both the mouse motion and the mouse button event have a corresponding field under the "mouse" field in the event structure to store the event information. However, because these two types of event require entirely different fields in the value buffer, and are processed in different ways in the SDL library, they are considered as different events.
Thank @alanjian85 for contributing! |
Implement an input event specific system call for SDL
This PR added a dedicated event system for game demo input,
syscall_poll_event
requires the user code pass in anevent_t
structure to populate, and it returns a status flag that indicates whether the event queue is not empty. Theevent_t
structure is a simplified version ofSDL_Event
, it has atype
field which may contains:KEY_EVENT
,MOUSE_MOTION_EVENT
andMOUSE_BUTTON_EVENT
, these types of event are enough for the current game demo, and every event type has an associated value buffer stored inunion
, the user code may check the detail of event by accessing the corresponding value buffer.Resolve #27