aboutsummaryrefslogtreecommitdiff
path: root/src/input.c
AgeCommit message (Collapse)Author
2026-10-29Add PS Vita PortNicholas Rodrigues Lordello
Compile PICO-w for the PS Vita :tada:. Fixes some minor compiler warnings that only showed up because of the different compilation target, and makes the Makefile port system a little more opinionated.
2026-10-29Support SDL 3.2Nicholas Rodrigues Lordello
2026-10-29Minor FixesNicholas Rodrigues Lordello
2026-10-29Minor FixesNicholas Rodrigues Lordello
2026-10-29Implement Cart ShutdownNicholas Rodrigues Lordello
2026-10-29Add Clipboard SupportNicholas Rodrigues Lordello
2026-10-28Implement Remaining SyscallsNicholas Rodrigues Lordello
2026-10-28Fix Relative Mouse MotionNicholas Rodrigues Lordello
We do some fixes, namely fixing relative mouse motion which worked very differently compared to mouse motion outside of pointer lock. This appears to be something built in to PICO-8 itself (as evident by keeping track of `STAT(32-33,38-39)` under pointer lock: PICO-8 scales relative mouse motion by a factor of `.25` before adding to the absolute mouse position. Additionally, we support running PICO-w on systems with no audio playback.
2026-10-26Implement Audio Device and Remaining ASM ConstsNicholas Rodrigues Lordello
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.
2026-10-24Improve Mouse Position HandlingNicholas Rodrigues Lordello
After some playing around with devkit mode, I noticed two things: 1. The mouse pointer can be outside of the range [0. 128) in case the window is larger than the PICO-8 screen, but it does not move to positions that would be outside of the window 2. Under pointer lock, relative positions continue to be reported even when the mouse is stuck to the edge of the window This means our implementation was slightly wrong, as it it did not properly handle the second case in a few ways: - We would always round to integer relative mouse mouse motions, meaning we would incorrectly approximate in case we collected multiple frames of relative mouse motion - We would compute the relative motion based on the mouse position, which is incorrect under pointer lock (as the position doesn't change but PICO-8 still needs relative mouse motion) - We would reset relative mouse motion every frame, meaning that we would not correctly accumulate relative motion in case the host's refresh rate was faster than PICO-8's (which seems to only run its frame logic at 30 FPS). We fix that here.
2026-10-24Improve Gamepad HandlingNicholas Rodrigues Lordello
There were a few cases where we would have stale input information becaues the `pw_input` only receives events while the game is running. This fixes that by: - Reseting the player count on game start - Clearing button states for disconnected players - Improve handling of the POOM player 2 support in case a second player connects
2026-10-23Various Small Bug FixesNicholas Rodrigues Lordello
2026-10-21More ASM ConstantsNicholas Rodrigues Lordello
We also implement some additional mouse functionality for pointer locking and for reading the mouse wheel (although, that is currently not hooked up over the ASM constants quite yet).
2026-10-19Started Implementing ASM ConstantsNicholas Rodrigues Lordello
2026-10-19Implement Many Host FunctionsNicholas Rodrigues Lordello
Implemented many of the missing host functions, but some things are still unimplemented: 1. Audio, because I have _no_ idea how that works. 2. Syscalls, they look hairy and will look into them separately. 3. ASM constants, we need to go over the array in the the exported JS module and understand how each one maps to our host. The other functions are _mostly_ straightforward to implement, and I did so with some caveats (for example, only supporting the single format the PICO-8 uses for `strftime`) which is good enough for us. Next, I need to refactor how we load carts: in particular, all carts need to come from the `_cartdat` mechanism, so the "embedded" carts instead of loading them ad-hoc. This requires us to refactor how we do the multicart loading to pre-load the entire `.p8.dir` when a cart is selected (instead of just keeping their names and lazy-loading them in).
2026-10-15wire up SDL eventsNicholas Rodrigues Lordello
2026-10-12Implement Partial Emscripten SDL APINicholas Rodrigues Lordello
Start implementing the surface-specific SDL API so that we can get our stub PICO-8 engine to draw a mouse crosshairs to screen. The Emscripten runtime still needs its own file, and we need to convert everything over to `wasm2c`.
2026-10-10Fix Some BugsNicholas Rodrigues Lordello
2026-10-10Separate Scene LogicNicholas Rodrigues Lordello
We now have two separate "scenes": - cart selection - game In their own modules. Instead of implementing some scene management logic, we just hardcode the scene logic directly in the `picow` main module - I don't forsee more scenes and there is no need to over-engineer at this point.
2026-10-09Player and Framebuffer ManagementNicholas Rodrigues Lordello
We now handle player controller connection/disconnection in a separate component (since, for scene selection we actually don't want 1:1 PICO-8 input semantics). We also added a new `pw_framebuffer` type for managing the framebuffer that can be written to by PICO-8. The target rect is updated every frame, and we provide utilities for mapping window coordinates to clamped framebuffer coordinates (used for the mouse). Next up is actually implementing the scenes in their separate file, at which point we can move the FB logic into our stub PICO-8 WAT implementation and wireup the events correctly!
2026-10-09Factor Out Controller LogicNicholas Rodrigues Lordello
Start factoring out controller logic, note that we need to manage controllers at the app-level and not the scene level, as the different scenes need gamepad events (for controlling cart selection and passing to the game respectively). There are some hacks to work around how the new abstraction does not exactly fit the previous model, we will fix that up once we wire up the rest of input handling: PICO-8 needs keyboard and mouse events only from the host, and they need to be in SDL 1.3 format (the Emscripten SDL builtin that PICO-8 uses).