Inputs

Back


Picotron has multiple input factors: the mouse, keyboard and controllers.

Mouse inputs can be seen:
here

They keyboard can be queried with key() and keyp().
e.g: is the button 'A' down?
key("a")
e.g: is the button 'A' being pressed/repeated?
keyp("a")

The raw scancode can be acquired with the second argument of key/keyp - by setting it to true, it will get the key with no localisation.

The buttons are hard-coded into picotron and queried with btn() and btnp()
The first argument acts as the button index and the second argument as the player (defaults to player 0).
There can be a total of 16 controller inputs

There are a total of 16 (one is defunct, listed as reserved) buttons you can use

DPAD & Joysticks
The inputs of the joystick and DPAD use the same memory points, causing you to not be able to make use of both seperately

Querying the btn of DPAD and joystick returns:
false - not pressed
255 - fully pressed on DPAD or joystick pushed as far as possible
0-255 - between the bounds of the joystick


The inputs of these are also automatically normalised by picotron (to where the controller inputs would be what is physically possible on an analog joystick), though this is not normalised in memory, allowing you to get the raw input through peek()

Buttons 0-3 are left, right, up, down on either DPAD 1 (usually left dpad) or Joystick 1 (usually left joystick). - arrow keys on keyboard
Buttons 8-11 are left, right, up, down on either DPAD 2 (usually right dpad) or Joystick 2 (usually right joystick). - ADWS on keyboard
Buttons 4-5 are O, X buttons - z/x on keyboard
Buttons 12-13 are two unnamed buttons (suggested to use A and B) - f/g on keyboard
Buttons 14-15 are left and right bumpers - q/e on keyboard
Button 6 is the start button - enter on keyboard
Button 7 is listed as 'reserved', nothing has been found to trigger it as of writing this


Examples:

Is the left direction on DPAD/Joystick 1 active?
btn(0)

Is the X button down?
btn(5)


The function btnp() acts similarly to btn(), only returning true when the button is not held down in the previous frame.
This repeats every 30 frames, repeating every 8 frames afterwards if the button is down.

Examples:

Is the left direction on DPAD/Joystick 1 pressed?
btnp(0)

Is the X button pressed?
btnp(5)



You can use the multiple controller functionality with the second argument (0-15).
The second argument defaults to 0, meaning you never have to think about this if you are doing a singleplayer game
To get the second player's input you can simply do btn(button,1) or btnp(button,1)


Picotron's controller input is stored at 0x005580 ~ 0x0055ff with 128 raw bytes of controller input, though only 15 have been seen to do anything
This allows you to get the raw input through:
peek(0x5400 + player_index*16 + button_index) (taken from the Picotron Manual)


Imagining of the Picotron controller
This includes a DPAD 1 and Joystick 1 in hopes of full functionality for both in the future

Raw input function found here

Download