Skip to content
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

Merged
merged 1 commit into from
Aug 8, 2022

Conversation

alanjian85
Copy link
Collaborator

This PR added a dedicated event system for game demo input, syscall_poll_event requires the user code pass in an event_t structure to populate, and it returns a status flag that indicates whether the event queue is not empty. The event_t structure is a simplified version of SDL_Event, it has a type field which may contains: KEY_EVENT, MOUSE_MOTION_EVENT and MOUSE_BUTTON_EVENT, these types of event are enough for the current game demo, and every event type has an associated value buffer stored in union, the user code may check the detail of event by accessing the corresponding value buffer.

Resolve #27

syscall_sdl.c Outdated Show resolved Hide resolved
Copy link
Contributor

@jserv jserv left a 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.

syscall_sdl.c Outdated Show resolved Hide resolved
@jserv
Copy link
Contributor

jserv commented Aug 5, 2022

Read How to Write a Git Commit Message carefully and improve the git commit messages.

syscall_sdl.c Outdated Show resolved Hide resolved
syscall_sdl.c Outdated Show resolved Hide resolved
syscall_sdl.c Outdated Show resolved Hide resolved
syscall_sdl.c Outdated Show resolved Hide resolved
Copy link
Contributor

@jserv jserv left a 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.

@alanjian85 alanjian85 force-pushed the master branch 2 times, most recently from 719a566 to 91e5c11 Compare August 6, 2022 03:51
syscall_sdl.c Outdated Show resolved Hide resolved
docs/syscall.md Outdated Show resolved Hide resolved
docs/syscall.md Outdated Show resolved Hide resolved
docs/syscall.md Outdated Show resolved Hide resolved
docs/syscall.md Outdated Show resolved Hide resolved
syscall_sdl.c Outdated Show resolved Hide resolved
docs/syscall.md Outdated Show resolved Hide resolved
syscall_sdl.c Outdated Show resolved Hide resolved
@jserv
Copy link
Contributor

jserv commented Aug 6, 2022

The proposed git commit message:

This commit integrates a new system call, syscall_poll_event, with SDL's event system,

Instead of "integrates," we can say, "introduces," which practically explains the motivation.

@alanjian85 alanjian85 force-pushed the master branch 2 times, most recently from 6584874 to 91da769 Compare August 7, 2022 03:38
docs/syscall.md Outdated Show resolved Hide resolved
@jserv jserv changed the title Implement input event specific system calls for SDL support Implement an input event specific system call for SDL Aug 7, 2022
uint32_t type;
union {
key_event_t key_event;
union {
Copy link
Contributor

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?

syscall_sdl.c Outdated Show resolved Hide resolved
Copy link
Contributor

@jserv jserv left a 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.

docs/syscall.md Outdated Show resolved Hide resolved
docs/syscall.md Outdated Show resolved Hide resolved
docs/syscall.md Outdated Show resolved Hide resolved
docs/syscall.md Outdated Show resolved Hide resolved
Copy link
Contributor

@jserv jserv left a 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.
@jserv jserv merged commit 5d782b8 into sysprog21:master Aug 8, 2022
@jserv
Copy link
Contributor

jserv commented Aug 8, 2022

Thank @alanjian85 for contributing!

vestata pushed a commit to vestata/rv32emu that referenced this pull request Jan 24, 2025
Implement an input event specific system call for SDL
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement input event specific system calls for SDL support
2 participants