It's possible to convert the whole input state into ~60-64 bites of data. This can then be used as the return of the as_raw_state functions.
I believe it could look something like this:
16 bits for all button states. ABCD, start, select, up, down, left, right, R1, R2, R3, L1, L2, L3
32 bits total for analog sticks. 16 bits per stick (two sticks total), and each stick can have x and y represented as an i8.
14 bits for analog triggers. Can be stored as a 7-bit value from 0-127 (or an i8 with the sign bit removed)
This actually leaves us at 62 bits. The last two can be used to signal a bad input state, such as when the wasm requests a player_id which is out of the range of connected players.
In the future I could see some alternative version where we use only 60 bits, by removing the R2/L2 as buttons and relying on the analog trigger data. Alternatively, down to 48 bits if we just scrapped analog triggers entirely.
Long term considerations:
We also may want to allow mouse input in the long term future, so it would be good to consider how to potentilaly represent that state as 64 bits too. For example, triggers or analog inputs and giving us room for pixel-perfect UI screen coordinates for mouse (11 bits to each to support 1920 x 1080 resolution).
It's possible to convert the whole
input state
into ~60-64 bites of data. This can then be used as the return of theas_raw_state
functions.I believe it could look something like this:
This actually leaves us at 62 bits. The last two can be used to signal a bad input state, such as when the wasm requests a player_id which is out of the range of connected players.
In the future I could see some alternative version where we use only 60 bits, by removing the R2/L2 as buttons and relying on the analog trigger data. Alternatively, down to 48 bits if we just scrapped analog triggers entirely.
Long term considerations:
We also may want to allow mouse input in the long term future, so it would be good to consider how to potentilaly represent that state as 64 bits too. For example, triggers or analog inputs and giving us room for pixel-perfect UI screen coordinates for mouse (11 bits to each to support 1920 x 1080 resolution).