Joystick

Direct access to joystick

Joystick_Read
u8 Joystick_Read(
u8 port
) __FASTCALL __PRESERVES(b, c, d, e, h, iyl, iyh)

Gets current joystick information

Parameters
port
u8

JOY_PORT_1 or JOY_PORT_2

Returns

Joystick state (bit=0: pressed)

xxBARLDU
│││││└─ Up
││││└── Down
│││└─── Left
││└──── Right
│└───── Trigger A
└────── Trigger B
Joystick_Update
void Joystick_Update()

Updates both joystick stats at once and stores the result Only available when INPUT_JOY_UPDATE is TRUE

Joystick_GetDirection
inline u8 Joystick_GetDirection(
u8 port
)

Gets current direction of the given joystick If INPUT_JOY_UPDATE is TRUE, this function uses data retrieved by Joystick_Update().  Otherwise, this function reads I/O data.

Parameters
port
u8

JOY_PORT_1 or JOY_PORT_2

Returns

One or two of those defines:

JOY_INPUT_DIR_NONE
JOY_INPUT_DIR_UP
JOY_INPUT_DIR_DOWN
JOY_INPUT_DIR_LEFT
JOY_INPUT_DIR_RIGHT
Joystick_GetDirectionChange
inline u8 Joystick_GetDirectionChange(
u8 port
)

Gets current direction of the given joystick if different from previous one Only available if INPUT_JOY_UPDATE is TRUE.

Parameters
port
u8

JOY_PORT_1 or JOY_PORT_2

Returns

One or two of those defines:

JOY_INPUT_DIR_NONE
JOY_INPUT_DIR_UP
JOY_INPUT_DIR_DOWN
JOY_INPUT_DIR_LEFT
JOY_INPUT_DIR_RIGHT
JOY_INPUT_DIR_UNCHANGED
Joystick_IsButtonPressed
inline bool Joystick_IsButtonPressed(
u8 port,
u8 trigger
)

Gets current trigger status of the given joystick If INPUT_JOY_UPDATE is TRUE, this function uses data retrieved by Joystick_Update().  Otherwise, this function read I/O data.

Parameters
port
u8

JOY_PORT_1 or JOY_PORT_2

trigger
u8

JOY_INPUT_TRIGGER_A or JOY_INPUT_TRIGGER_B

Returns

TRUE if given button is pressed

Joystick_IsButtonPushed
inline bool Joystick_IsButtonPushed(
u8 port,
u8 trigger
)

Gets current trigger status of the given joystick Only available if INPUT_JOY_UPDATE is TRUE.

Parameters
port
u8

JOY_PORT_1 or JOY_PORT_2

trigger
u8

JOY_INPUT_TRIGGER_A or JOY_INPUT_TRIGGER_B

Returns

TRUE if given button is pressed

Detect

General purpose port device detection

Input_Detect
u8 Input_Detect(
enum INPUT_PORT port
)

Detect device plugged in General purpose ports

Mouse

Direct access to mouse

Mouse_Read
void Mouse_Read(
u8 port,
Mouse_State* data
)
Mouse_GetOffsetX
inline i8 Mouse_GetOffsetX(
Mouse_State* data
)
Mouse_GetOffsetY
inline i8 Mouse_GetOffsetY(
Mouse_State* data
)
Mouse_GetAdjustedOffsetX
inline i8 Mouse_GetAdjustedOffsetX(
Mouse_State* data,
u8 spd
)
Mouse_GetAdjustedOffsetY
inline i8 Mouse_GetAdjustedOffsetY(
Mouse_State* data,
u8 spd
)
Mouse_IsButtonPress
inline bool Mouse_IsButtonPress(
Mouse_State* data,
u8 btn
)
Mouse_IsButtonClick
inline bool Mouse_IsButtonClick(
Mouse_State* data,
u8 btn
)
Keyboard

Direct access to keyboard

KEY_ID
enum KEY_ID

Value encoded by combining a row number with a given physical key index in that row Can be KEY_1, KEY_SPACE, KEY_A, KEY_F1, etc.

Keyboard_Read
u8 Keyboard_Read(
u8 row
) __FASTCALL __PRESERVES(b, c, d, e, h, iyl, iyh)

Reads keyboard matrix row

Parameters
row
u8

The row to read (0-10)

Returns

8-bits value where each bit to 0 represents the pressed keys

Keyboard_SetBuffer
inline void Keyboard_SetBuffer(
u8* new,
u8* old
)
Keyboard_Update
void Keyboard_Update()

Updates all keyboard rows at once Only available when INPUT_KB_UPDATE is TRUE

Keyboard_IsKeyPressed
bool Keyboard_IsKeyPressed(
u8 key
)

When INPUT_KB_UPDATE is TRUE, this function uses data retrieved by Keyboard_Update() function Otherwise, the function reads the key's row before checking the key.

Parameters
key
u8

The key ID to check

Returns

TRUE if key is pressed

Keyboard_IsKeyPushed
bool Keyboard_IsKeyPushed(
u8 key
)

Checks if a given key was just pushed Only available when INPUT_KB_UPDATE is TRUE

Parameters
key
u8

The key ID to check

Returns

TRUE if the key was pushed on this frame