SNES Controller Input. More...
#include <snes/types.h>Go to the source code of this file.
Macros | |
| #define | KEY_A BIT(7) |
| #define | KEY_B BIT(15) |
| #define | KEY_DOWN BIT(10) |
| #define | KEY_DPAD (KEY_UP | KEY_DOWN | KEY_LEFT | KEY_RIGHT) |
| All D-pad directions. | |
| #define | KEY_FACE (KEY_A | KEY_B | KEY_X | KEY_Y) |
| All face buttons. | |
| #define | KEY_L BIT(5) |
| #define | KEY_LEFT BIT(9) |
| #define | KEY_R BIT(4) |
| #define | KEY_RIGHT BIT(8) |
| #define | KEY_SELECT BIT(13) |
| #define | KEY_START BIT(12) |
| #define | KEY_UP BIT(11) |
| #define | KEY_X BIT(6) |
| #define | KEY_Y BIT(14) |
| #define | MOUSE_BUTTON_LEFT 0x01 |
| #define | MOUSE_BUTTON_RIGHT 0x02 |
| #define | MOUSE_SENS_HIGH 2 |
| #define | MOUSE_SENS_LOW 0 |
| #define | MOUSE_SENS_MEDIUM 1 |
| #define | padHeld(pad) |
| #define | padPressed(pad) |
| #define | SSC_CURSOR 0x4000 |
| #define | SSC_FIRE 0x8000 |
| #define | SSC_NOISE 0x0100 |
| #define | SSC_OFFSCREEN 0x0200 |
| #define | SSC_PAUSE 0x1000 |
| #define | SSC_TURBO 0x2000 |
Functions | |
| u8 | mouseButtonsHeld (u8 port) |
| Get currently held mouse buttons. | |
| u8 | mouseButtonsPressed (u8 port) |
| Get newly pressed mouse buttons this frame. | |
| u8 | mouseGetSensitivity (u8 port) |
| Get current mouse sensitivity. | |
| s16 | mouseGetX (u8 port) |
| Get X displacement since last frame. | |
| s16 | mouseGetY (u8 port) |
| Get Y displacement since last frame. | |
| u8 | mouseInit (u8 port) |
| Initialize mouse on given port. | |
| u8 | mouseIsConnected (u8 port) |
| Check if mouse is connected on port. | |
| void | mouseSetSensitivity (u8 port, u8 sensitivity) |
| Set mouse sensitivity. | |
| u16 | padHeld (u8 pad) |
| Get buttons currently held. | |
| u8 | padIsConnected (u8 pad) |
| Check if controller is connected. | |
| u16 | padPressed (u8 pad) |
| Get buttons pressed this frame. | |
| u16 | padReleased (u8 pad) |
| Get buttons released this frame. | |
| u16 | scopeButtonsHeld (void) |
| Buttons currently down — the same meaning as padHeld() and mouseButtonsHeld(). | |
| u16 | scopeButtonsPressed (void) |
| Get newly pressed buttons this frame. | |
| u16 | scopeButtonsRepeat (void) |
| Buttons held past the hold delay, re-triggering every repeat delay (see scopeSetRepeatDelay()) — a keyboard-style auto-repeat. | |
| void | scopeCalibrate (void) |
| Calibrate aim from a center-screen shot. | |
| u16 | scopeGetRawX (void) |
| Get raw (uncalibrated) H position from PPU. | |
| u16 | scopeGetRawY (void) |
| Get raw (uncalibrated) V position from PPU. | |
| u16 | scopeGetX (void) |
| Get calibration-adjusted H position. | |
| u16 | scopeGetY (void) |
| Get calibration-adjusted V position. | |
| u8 | scopeInit (void) |
| Detect Super Scope on port 2. | |
| u8 | scopeIsConnected (void) |
| Check if Super Scope is connected. | |
| void | scopeSetHoldDelay (u16 frames) |
| Set hold delay (frames before hold triggers). | |
| void | scopeSetRepeatDelay (u16 frames) |
| Set repeat delay (frames between repeat fires after hold). | |
| u16 | scopeSinceShot (void) |
| Get frames since last detected shot. | |
Variables | |
| u16 | pad_keys [5] |
| u16 | pad_keysdown [5] |
| u16 | pad_keysold [5] |
SNES Controller Input.
Functions for reading controller input.
Use these constants with padPressed(), padHeld(), etc:
| Constant | Button |
|---|---|
| KEY_A | A button |
| KEY_B | B button |
| KEY_X | X button |
| KEY_Y | Y button |
| KEY_L | L shoulder |
| KEY_R | R shoulder |
| KEY_START | Start |
| KEY_SELECT | Select |
| KEY_UP | D-pad up |
| KEY_DOWN | D-pad down |
| KEY_LEFT | D-pad left |
| KEY_RIGHT | D-pad right |
| #define padPressed | ( | pad | ) |
Get buttons currently held.
Returns all buttons currently being pressed.
| pad | Controller number: 0 or 1. Indices 2-4 are accepted and always read 0 — the multitap path cannot be armed (KNOWN_LIMITATIONS.md) |
Check if controller is connected.
| pad | Controller number: 0 or 1. Indices 2-4 are accepted and always read 0 — the multitap path cannot be armed (KNOWN_LIMITATIONS.md) |
The NMI handler reads one serial bit past the 16 of auto-joypad reading: a joypad returns 1s after its 16 bits (anomie's register doc, Joypads), which is how the snesdev-wiki Multitap page detects controllers. A port holding another device (mouse, Super Scope) reads 0: it is not a pad. Valid from the first VBlank after consoleInit() / setScreenOn().
Get buttons pressed this frame.
Returns buttons that were just pressed (not held from previous frame).
| pad | Controller number: 0 or 1. Indices 2-4 are accepted and always read 0 — the multitap path cannot be armed (KNOWN_LIMITATIONS.md) |
Get buttons released this frame.
Returns buttons that were just released (held last frame, not now).
| pad | Controller number: 0 or 1. Indices 2-4 are accepted and always read 0 — the multitap path cannot be armed (KNOWN_LIMITATIONS.md) |
|
extern |
Buttons down, per pad (written by the NMI handler)
|
extern |
Buttons that went down on this frame
|
extern |
Buttons down on the previous frame