diff options
| author | Nicholas Rodrigues Lordello <[email protected]> | 2026-10-26 08:32:08 +0100 |
|---|---|---|
| committer | Nicholas Rodrigues Lordello <[email protected]> | 2026-10-26 08:42:53 +0100 |
| commit | 4957ca8373273721017fc8106b52d5bc6b2a0180 (patch) | |
| tree | 6372e708f63b61927b93dec2e70162546947c7fe /src/input.c | |
| parent | bbc8cadc76aa6419a318d8aeccfb0c25b7a30115 (diff) | |
Implement Audio Device and Remaining ASM Consts
We abstract over SDL's audio subsystem and implement an audio
device that fits into PICO-8's model. We fixed the implementation
for the PICO-8 window focus and key buffer and can now actually
boot into PICO-8 games with working sounds and controls!
There are a few issues that remain:
1. There is no "exit" option in the pause menu, I think it thinks
that we are on the BBS, and maybe there is someway to fix this?
2. The clipboard textarea is not implemented at all; we should
keep a text buffer in `pw_input` and interact with SDL's
clipboard system
3. Multicart's don't always work; in particular Undune II tries
to download from the BBS, I would like to shim this somehow
to support both `LOAD("FOO.P8")` and `LOAD("#FOO")` forms
transparently.
Diffstat (limited to 'src/input.c')
| -rw-r--r-- | src/input.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/input.c b/src/input.c index e082393..93aed4e 100644 --- a/src/input.c +++ b/src/input.c @@ -410,6 +410,25 @@ bool pw_input_iterate(struct pw_input *input, struct pw_framebuffer *fb) { return update_mouse(input, fb); } +enum pw_window_flags pw_input_window(struct pw_input *input) { + enum pw_window_flags result = PW_WINDOW_NONE; + if (!input) { + SDL_InvalidParamError("input"); + return result; + } + + SDL_WindowFlags flags = SDL_GetWindowFlags(input->window); + if (!(flags & + (SDL_WINDOW_MINIMIZED | SDL_WINDOW_HIDDEN | SDL_WINDOW_MINIMIZED))) { + result |= PW_WINDOW_VISIBLE; + } + if (flags & SDL_WINDOW_INPUT_FOCUS) { + result |= PW_WINDOW_FOCUS; + } + + return result; +} + size_t pw_input_players(struct pw_input *input) { if (!input) { SDL_InvalidParamError("input"); @@ -451,6 +470,22 @@ enum pw_keymod pw_input_keymod(struct pw_input *input) { return input->keyboard.mod; } +bool pw_input_key(struct pw_input *input, int32_t *key) { + if (!input) { + if (key) { + *key = -1; + } + return SDL_InvalidParamError("input"); + } + + struct pw_keyboard_queue *q = &input->keyboard.text; + if (key) { + return dequeue_item(q, (uint32_t *)key); + } else { + return q->start != q->end; + } +} + enum pw_mouse_button pw_input_mouse(struct pw_input *input, struct pw_coordinates *pos) { if (!input) { |
