You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit integrates a new system call, syscall_poll_event, with SDL's
event system, three types of input-specific events are supported:
keyboard event, mouse motion event and mouse button event, this input
system will improve the interactivity of the demos.
These system calls are experimental for demonstration of RISC-V graphics applications, they don't exist in the ABI interface of POSIX and Linux, and are only for the convenience of accessing the SDL library.
6
+
7
+
### `syscall_draw_frame(screen, width, height)`
8
+
Update the framebuffer of the given size, the window is lazy-initialized, if it does not exist when this system call is called, a new window will be created with the given width and height. This system call also poll events from SDL library, and update the internal input specific event queue if neccessary.
Same as `syscall_draw_frame`, but with indexed-coloring, `pal` is a RGB look up table which contains 256 distinct colors, all pixels in the framebuffer will be automatically mapped before drawing on the screen.
12
+
13
+
### `syscall_poll_event(event)`
14
+
Poll a input-specific event from the event system, `event` should contains a 32-bit `type` field, and associated with a suitably sized value buffer, the internal event queue will be updated whenever `syscall_draw_frame` or `syscall_draw_frame_pal` is called.
15
+
16
+
The following types of event are currently supported:
17
+
*`KEY_EVENT`(`0x0`): Triggered when the status of keyboard is changed, either a key is pressed or released, returns a 32-bit keycode and a 8-bit key state, the hexadecimal keycode values are listed in [SDL Keycode Lookup Table](https://wiki.libsdl.org/SDLKeycodeLookup)
18
+
*`MOUSE_MOTION_EVENT`(`0x1`): A mouse move event, with relative position information, two 32-bit signed integers which is correspond to the x and y delta value, the mouse is repeatedly wrapped in the window border by default.
19
+
*`MOUSE_BUTTON_EVENT`(`0x2`): Whenever the state of a mouse button is changed, either a button is pressed or released, the user code will receive this event, it returns a 8-bit value indicates which button is updated(1 is left, 2 is middle, 3 is right and so on), and the 8-bit state value whether the button is pressed.
0 commit comments