Loading...
Searching...
No Matches
input.h
Go to the documentation of this file.
1
44#ifndef OPENSNES_INPUT_H
45#define OPENSNES_INPUT_H
46
47#include <snes/types.h>
48
49/*============================================================================
50 * Button Constants
51 *============================================================================*/
52
57/*
58 * SNES Joypad Register Layout (16-bit read as JOY1L | JOY1H << 8):
59 *
60 * $4219 (JOY1H) → bits 15-8: B, Y, Select, Start, Up, Down, Left, Right
61 * $4218 (JOY1L) → bits 7-0: A, X, L, R, (signature bits)
62 *
63 * Bit layout (16-bit, active high):
64 * 15 14 13 12 11 10 9 8 7 6 5 4 3-0
65 * B Y Sel Sta Up Dn Lt Rt A X L R ID
66 *
67 * Verified against fullsnes documentation and real hardware.
68 */
69
70/* High byte ($4219 → result bits 15-8) */
71#define KEY_B BIT(15)
72#define KEY_Y BIT(14)
73#define KEY_SELECT BIT(13)
74#define KEY_START BIT(12)
75#define KEY_UP BIT(11)
76#define KEY_DOWN BIT(10)
77#define KEY_LEFT BIT(9)
78#define KEY_RIGHT BIT(8)
80/* Low byte ($4218 → result bits 7-0) */
81#define KEY_A BIT(7)
82#define KEY_X BIT(6)
83#define KEY_L BIT(5)
84#define KEY_R BIT(4)
87#define KEY_DPAD (KEY_UP | KEY_DOWN | KEY_LEFT | KEY_RIGHT)
88
90#define KEY_FACE (KEY_A | KEY_B | KEY_X | KEY_Y)
91
94/*============================================================================
95 * Functions
96 *============================================================================*/
97
113
129
139
149
157
158/*============================================================================
159 * Mouse Constants
160 *============================================================================*/
161
191#define MOUSE_BUTTON_LEFT 0x01
192#define MOUSE_BUTTON_RIGHT 0x02
194#define MOUSE_SENS_LOW 0
195#define MOUSE_SENS_MEDIUM 1
196#define MOUSE_SENS_HIGH 2
209
217
228
238
246
254
264void mouseSetSensitivity(u8 port, u8 sensitivity);
265
273
276/*============================================================================
277 * Super Scope Constants
278 *============================================================================*/
279
311#define SSC_FIRE 0x8000
312#define SSC_CURSOR 0x4000
313#define SSC_TURBO 0x2000
314#define SSC_PAUSE 0x1000
315#define SSC_OFFSCREEN 0x0200
316#define SSC_NOISE 0x0100
328
335
342
349
356
363
371
378
388
396void scopeCalibrate(void);
397
404
411
418
421#endif /* OPENSNES_INPUT_H */
u8 mouseGetSensitivity(u8 port)
Get current mouse sensitivity.
s16 mouseGetY(u8 port)
Get Y displacement since last frame.
u8 mouseButtonsHeld(u8 port)
Get currently held mouse buttons.
u8 mouseIsConnected(u8 port)
Check if mouse is connected on port.
u8 mouseInit(u8 port)
Initialize mouse on given port.
s16 mouseGetX(u8 port)
Get X displacement since last frame.
void mouseSetSensitivity(u8 port, u8 sensitivity)
Set mouse sensitivity.
u8 mouseButtonsPressed(u8 port)
Get newly pressed mouse buttons this frame.
u16 scopeButtonsHeld(void)
Get buttons held past the hold delay threshold.
u16 scopeSinceShot(void)
Get frames since last detected shot.
u16 scopeButtonsDown(void)
Get currently held buttons.
u16 scopeGetRawY(void)
Get raw (uncalibrated) V position from PPU.
void scopeCalibrate(void)
Calibrate aim from a center-screen shot.
void scopeSetHoldDelay(u16 frames)
Set hold delay (frames before hold triggers).
u16 scopeButtonsPressed(void)
Get newly pressed buttons this frame.
u8 scopeIsConnected(void)
Check if Super Scope is connected.
u16 scopeGetX(void)
Get calibration-adjusted H position.
u8 scopeInit(void)
Detect Super Scope on port 2.
void scopeSetRepeatDelay(u16 frames)
Set repeat delay (frames between repeat fires after hold).
u16 scopeGetRawX(void)
Get raw (uncalibrated) H position from PPU.
u16 scopeGetY(void)
Get calibration-adjusted V position.
signed short s16
16-bit signed integer (-32768 to 32767)
Definition types.h:49
unsigned short u16
16-bit unsigned integer (0 to 65535)
Definition types.h:52
unsigned char u8
8-bit unsigned integer (0 to 255)
Definition types.h:46
u16 padReleased(u8 pad)
Get buttons released this frame.
u16 padHeld(u8 pad)
Get buttons currently held.
u8 padIsConnected(u8 pad)
Check if controller is connected.
u16 padRaw(u8 pad)
Get raw button state.
u16 padPressed(u8 pad)
Get buttons pressed this frame.
OpenSNES Standard Types.