PVSnesLib  4.3.0
Documentation to code in C or ASM for the Nintendo SNES
Loading...
Searching...
No Matches
input.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------------------
2
3 Input registers
4
5 Copyright (C) 2012-2013
6 Alekmaul
7
8 This software is provided 'as-is', without any express or implied
9 warranty. In no event will the authors be held liable for any
10 damages arising from the use of this software.
11
12 Permission is granted to anyone to use this software for any
13 purpose, including commercial applications, and to alter it and
14 redistribute it freely, subject to the following restrictions:
15
16 1. The origin of this software must not be misrepresented; you
17 must not claim that you wrote the original software. If you use
18 this software in a product, an acknowledgment in the product
19 documentation would be appreciated but is not required.
20
21 2. Altered source versions must be plainly marked as such, and
22 must not be misrepresented as being the original software.
23
24 3. This notice may not be removed or altered from any source
25 distribution.
26
27
28---------------------------------------------------------------------------------*/
29
37#ifndef SNES_INPUT_INCLUDE
38#define SNES_INPUT_INCLUDE
39
40#include <snes/snestypes.h>
41#include <snes/interrupt.h>
42
49typedef enum KEYPAD_BITS
50{
51 KEY_A = BIT(7),
52 KEY_B = BIT(15),
54 KEY_START = BIT(12),
57 KEY_DOWN = BIT(10),
58 KEY_UP = BIT(11),
59 KEY_R = BIT(4),
60 KEY_L = BIT(5),
61 KEY_X = BIT(6),
62 KEY_Y = BIT(14),
64
78
90
91extern u16 pad_keys[5];
92extern u16 pad_keysold[5];
93extern u16 pad_keysdown[5];
94
95extern u8 snes_mplay5;
96extern u8 snes_mouse;
97extern u8 snes_sscope;
99extern u8 mouseConnect[2];
100extern u8 mouseButton[2];
101extern u8 mousePressed[2];
102extern u8 mousePreviousPressed[2];
103extern u8 mouse_x[2];
104extern u8 mouse_y[2];
114extern u8 mouseSensitivity[2];
115
131
132#define mouse_L 0x01
133#define mouse_R 0x02
135extern u16 scope_holddelay;
136extern u16 scope_repdelay;
137extern u16 scope_shothraw;
138extern u16 scope_shotvraw;
139extern u16 scope_shoth;
140extern u16 scope_shotv;
141extern u16 scope_centerh;
142extern u16 scope_centerv;
143extern u16 scope_down;
144extern u16 scope_now;
145extern u16 scope_held;
146extern u16 scope_last;
147extern u16 scope_sinceshot;
190#define REG_JOYxLH(a) (((vuint16 *)0x4218)[(a)])
191
197// unsigned short padsCurrent(u16 value);
198#define padsCurrent(value) (pad_keys[value])
199
205// unsigned short padsDown(u16 value);
206#define padsDown(value) (pad_keysdown[value])
207
213unsigned short padsUp(u16 value);
214
219void padsClear(u16 value);
220
227void detectMPlay5(void);
228
232void detectMouse(void);
233
238
239
248void initMouse(u8 sensitivity);
249
250
262
274
287void mouseSetSensitivity(u16 port, u8 sensitivity);
288
289#endif // SNES_PADS_INCLUDE
u8 snes_mouse
1 if Mouse is going to be used
u8 snes_mplay5
1 if MultiPlay5 is connected
u16 scope_shothraw
Horizontal shot position, not adjusted.
u16 scope_repdelay
Repeat rate.
u16 scope_last
flags that were true on the previous frame.
u16 pad_keysold[5]
previous pad value
void padsClear(u16 value)
Clear internal variables for selected pad.
u16 scope_now
flags that have become true this frame.
u8 mouseConnect[2]
1 if Mouse present
u8 mouse_y[2]
Mouse vertical displacement. daaaaaaa, d = direction (1: up, 0: down), a = acceleration.
u8 snes_sscope
1 if SuperScope is connected
u16 scope_centerh
0x0000 is the center of the screen, positive values go to bottom right.
unsigned short padsUp(u16 value)
Return value of up keys for selected pad.
u16 scope_centerv
0x0000 is the center of the screen, positive values go to bottom right.
u8 mouseRequestChangeSensitivity[2]
Request a change mouse sensitivity.
u16 pad_keys[5]
current pad value
void initMouse(u8 sensitivity)
Enable mouse reading and set the initial mouse sensitivity.
u16 scope_shotv
Vertical shot position, adjusted for aim.
u8 mouse_x[2]
Mouse horizontal displacement. daaaaaaa, d = direction (1: left, 0: right), a = acceleration.
void mouseCycleSensitivityTwice(u16 port)
Queue a cycle mouse sensitivity twice (decrementing the sensitivity) command for the next VBlank.
u8 mouseButton[2]
Mouse buttons that are pressed on this frame (Click mode).
u16 scope_holddelay
Hold delay.
u8 mouseSensitivity[2]
Mouse sensitivity.
MOUSE_SENSITIVITY
Mouse sensitivity values.
Definition input.h:85
@ MOUSE_FAST
fast sensitivity
Definition input.h:88
@ MOUSE_SLOW
slow sensitivity
Definition input.h:86
@ MOUSE_MEDIUM
medium sensitivity
Definition input.h:87
SUPERSCOPE_BITS
common values for SuperScope input.
Definition input.h:70
@ SSC_OFFSCREEN
superscope OFFSCREEN flag.
Definition input.h:75
@ SSC_FIRE
superscope FIRE button.
Definition input.h:71
@ SSC_TURBO
superscope TURBO flag.
Definition input.h:74
@ SSC_PAUSE
superscope PAUSE button.
Definition input.h:73
@ SSC_NOISE
superscope NOISE flag.
Definition input.h:76
@ SSC_CURSOR
superscope CURSOR button.
Definition input.h:72
u16 scope_shoth
Horizontal shot position, adjusted for aim.
u16 scope_sinceshot
Number of frames elapsed since last shot was fired.
u16 scope_down
flags that are currently true.
u16 pad_keysdown[5]
newly pressed down pad keys
KEYPAD_BITS
common values for pad input.
Definition input.h:50
@ KEY_UP
pad UP button.
Definition input.h:58
@ KEY_B
pad B button.
Definition input.h:52
@ KEY_SELECT
pad SELECT button.
Definition input.h:53
@ KEY_X
pad X button.
Definition input.h:61
@ KEY_Y
pad Y button.
Definition input.h:62
@ KEY_LEFT
pad LEFT button.
Definition input.h:56
@ KEY_START
pad START button.
Definition input.h:54
@ KEY_RIGHT
pad RIGHT button.
Definition input.h:55
@ KEY_R
Right shoulder button.
Definition input.h:59
@ KEY_A
pad A button.
Definition input.h:51
@ KEY_DOWN
pad DOWN button.
Definition input.h:57
@ KEY_L
Left shoulder button.
Definition input.h:60
void mouseCycleSensitivity(u16 port)
Queue a cycle mouse sensitivity command for the next VBlank.
u8 mousePressed[2]
Mouse buttons that are currently pressed, stays until is unpressed (Turbo mode).
u8 mousePreviousPressed[2]
Mouse buttons held or pressed in the previous frame.
void detectMPlay5(void)
Check if MultiPlayer5 is connected and populate snes_mplay5 (0 or 1 for connected)
u16 scope_shotvraw
Vertical shot position, not adjusted.
void mouseSetSensitivity(u16 port, u8 sensitivity)
Queue a set mouse sensitivity command (to be executed on the next VBlank).
void detectSuperScope(void)
Detects if SuperScope is connected on Port 1 (second controller port on console) and populate snes_ss...
u16 scope_held
flagsthat have been true for a certain length of time.
void detectMouse(void)
Check if Mouse is connected and populate snes_mouse (0 or 1 for connected)
snes interrupt support.
Custom types used by libsnes.
#define BIT(n)
bit field
Definition snestypes.h:34