diff options
Diffstat (limited to 'src/input.c')
| -rw-r--r-- | src/input.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/input.c b/src/input.c index 945c798..fcedb1f 100644 --- a/src/input.c +++ b/src/input.c @@ -66,6 +66,14 @@ static bool handle_connection(struct pw_input *input, static void set_button(enum pw_button *player, enum pw_button button, bool pressed) { + // Note that we map several different controls (axis and buttons) to the + // same PICO-8 button, meaning that they can compete for the 'set' state + // of these buttons. We opt to, for simplicity, to just take the value + // of the last control that set this state. This means that if you press + // both buttons for X, and release one of them, PICO-8 will think that + // the button was released (even while the second button was held). We + // are OK with this for now, and will consider changing this in case it + // ends up feeling unatural while playing. if (pressed) { *player |= button; } else { @@ -242,6 +250,14 @@ static bool handle_key(struct pw_input *input, SDL_KeyboardEvent *event) { } sc |= (uint32_t)event->mod << PW_SCANCODE_MOD_SHIFT; + // The scancode and key queue size was selected to not be an issue under + // regular use, PICO-8 seems to drain many of the queue items ever frame + // so I do not believe we will run into issues where the queue is full + // in practice (which would manifest as dropped keys and potentially + // keyboard state in PICO-8 drifting from the real keyboard state). Warn + // in case either queue is full, and if this proves to be an issue in + // practice consider either making the queue bigger or dynamically sized. + if (!enqueue_item(&input->keyboard.scancodes, sc)) { SDL_LogDebug(0, "keyboard event queue full, dropping scancode"); } |
