PVSnesLib  4.3.0
Documentation to code in C or ASM for the Nintendo SNES
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 
34 #ifndef SNES_INPUT_INCLUDE
35 #define SNES_INPUT_INCLUDE
36 
37 #include <snes/snestypes.h>
38 #include <snes/interrupt.h>
39 
46 typedef enum KEYPAD_BITS
47 {
48  KEY_A = BIT(7),
49  KEY_B = BIT(15),
50  KEY_SELECT = BIT(13),
51  KEY_START = BIT(12),
52  KEY_RIGHT = BIT(8),
53  KEY_LEFT = BIT(9),
54  KEY_DOWN = BIT(10),
55  KEY_UP = BIT(11),
56  KEY_R = BIT(4),
57  KEY_L = BIT(5),
58  KEY_X = BIT(6),
59  KEY_Y = BIT(14),
61 
66 typedef enum SUPERSCOPE_BITS
67 {
68  SSC_FIRE = BIT(15),
69  SSC_CURSOR = BIT(14),
70  SSC_PAUSE = BIT(12),
71  SSC_TURBO = BIT(13),
73  SSC_NOISE = BIT(8),
75 
76 extern u16 pad_keys[2];
77 extern u16 pad_keysold[2];
78 extern u16 pad_keysrepeat[2];
79 
80 extern u8 snes_mplay5;
81 extern u8 snes_mouse;
82 extern u8 snes_sscope;
84 extern u8 mouseConnect[2];
85 extern u8 mouseButton[2];
86 extern u8 mousePressed[2];
87 extern u8 mouse_x[2], mouse_y[2];
88 extern u8 mouseSpeedSet[2];
90 #define mouse_L 0x01
91 #define mouse_R 0x02
93 extern u16 scope_holddelay;
94 extern u16 scope_repdelay;
95 extern u16 scope_shothraw;
96 extern u16 scope_shotvraw;
97 extern u16 scope_shoth;
98 extern u16 scope_shotv;
99 extern u16 scope_centerh;
100 extern u16 scope_centerv;
101 extern u16 scope_down;
102 extern u16 scope_now;
103 extern u16 scope_held;
104 extern u16 scope_last;
105 extern u16 scope_sinceshot;
148 #define REG_JOYxLH(a) (((vuint16 *)0x4218)[(a)])
149 
153 void scanPads(void);
154 
160 // unsigned short padsCurrent(u16 value);
161 #define padsCurrent(value) (pad_keys[value])
162 
168 unsigned short padsDown(u16 value);
169 
175 unsigned short padsUp(u16 value);
176 
181 void padsClear(u16 value);
182 
186 void detectMPlay5(void);
187 
191 void scanMPlay5(void);
192 
196 void detectMouse(void);
197 
201 void mouseRead(void);
202 
207 void mouseSpeedChange(u8 port);
208 
212 void detectSuperScope(void);
213 
241 void scanScope(void);
242 
243 #endif // SNES_PADS_INCLUDE
u8 snes_mouse
1 if MultiPlay5 is connected
u16 scope_shothraw
Repeat rate.
u16 scope_repdelay
Hold delay.
void mouseSpeedChange(u8 port)
Set mouse hardware speed (populate mouseSpeed[] first).
u16 scope_last
flagsthat have been true for a certain length of time.
void padsClear(u16 value)
Clear internal variables for selected pad.
u16 scope_now
flags that are currently true.
u8 mouseConnect[2]
1 if SuperScope is connected
void scanPads(void)
Wait for pad ready and read pad values in.
u8 snes_sscope
1 if Mouse is going to be used
u16 scope_centerh
Vertical shot position, adjusted for aim.
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.
unsigned short padsDown(u16 value)
Return value of down keys for selected pad.
void scanMPlay5(void)
Wait for multiplayer5 pads ready and read pad values in.
u16 scope_shotv
Horizontal shot position, adjusted for aim.
u8 mouse_x[2]
1 if button is pressed, stays until is unpressed (Turbo mode).
void scanScope(void)
Nintendo SHVC Scope BIOS version 1.00 Quickly disassembled and commented by Revenant on 31 Jan 2013.
u8 mouseButton[2]
1 if Mouse present
u8 mouseSpeedSet[2]
Mouse acceleration. daaaaaaa, d = direction (0: up/left, 1: down/right), a = acceleration.
SUPERSCOPE_BITS
enum values for the SuperScope buttons and flags.
Definition: input.h:67
@ SSC_OFFSCREEN
superscope OFFSCREEN flag.
Definition: input.h:72
@ SSC_FIRE
superscope FIRE button.
Definition: input.h:68
@ SSC_TURBO
superscope TURBO flag.
Definition: input.h:71
@ SSC_PAUSE
superscope PAUSE button.
Definition: input.h:70
@ SSC_NOISE
superscope NOISE flag.
Definition: input.h:73
@ SSC_CURSOR
superscope CURSOR button.
Definition: input.h:69
u16 scope_shoth
Vertical shot position, not adjusted.
u16 scope_sinceshot
flags that were true on the previous frame.
u16 scope_down
0x0000 is the center of the screen, positive values go to bottom right.
KEYPAD_BITS
enum values for the pad buttons.
Definition: input.h:47
@ KEY_UP
pad UP button.
Definition: input.h:55
@ KEY_B
pad B button.
Definition: input.h:49
@ KEY_SELECT
pad SELECT button.
Definition: input.h:50
@ KEY_X
pad X button.
Definition: input.h:58
@ KEY_Y
pad Y button.
Definition: input.h:59
@ KEY_LEFT
pad LEFT button.
Definition: input.h:53
@ KEY_START
pad START button.
Definition: input.h:51
@ KEY_RIGHT
pad RIGHT button.
Definition: input.h:52
@ KEY_R
Right shoulder button.
Definition: input.h:56
@ KEY_A
pad A button.
Definition: input.h:48
@ KEY_DOWN
pad DOWN button.
Definition: input.h:54
@ KEY_L
Left shoulder button.
Definition: input.h:57
u8 mousePressed[2]
1 if button is pressed, stays for a bit and then it gets released (Click mode).
void detectMPlay5(void)
Check if MultiPlayer5 is connected and populate snes_mplay5 (0 or 1 for connected)
u16 scope_shotvraw
Horizontal shot position, not adjusted.
void detectSuperScope(void)
Detects if SuperScope is connected on Port 1 (second controller port on console) and populate snes_ss...
void mouseRead(void)
Wait for mouse ready and read mouse values in.
u16 scope_held
flags that have become true this frame.
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