Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/genplus-gx32/core/input_hw/input.h
2 views
1
/***************************************************************************************
2
* Genesis Plus
3
* Input peripherals support
4
*
5
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Charles Mac Donald (original code)
6
* Copyright (C) 2007-2013 Eke-Eke (Genesis Plus GX)
7
*
8
* Redistribution and use of this code or any derivative works are permitted
9
* provided that the following conditions are met:
10
*
11
* - Redistributions may not be sold, nor may they be used in a commercial
12
* product or activity.
13
*
14
* - Redistributions that are modified from the original source must include the
15
* complete source code, including the source code for all components used by a
16
* binary built from the modified sources. However, as a special exception, the
17
* source code distributed need not include anything that is normally distributed
18
* (in either source or binary form) with the major components (compiler, kernel,
19
* and so on) of the operating system on which the executable runs, unless that
20
* component itself accompanies the executable.
21
*
22
* - Redistributions must reproduce the above copyright notice, this list of
23
* conditions and the following disclaimer in the documentation and/or other
24
* materials provided with the distribution.
25
*
26
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36
* POSSIBILITY OF SUCH DAMAGE.
37
*
38
****************************************************************************************/
39
40
#ifndef _INPUT_H_
41
#define _INPUT_H_
42
43
/* Max. number of devices */
44
#define MAX_DEVICES (8)
45
46
/* Ports configuration */
47
#define NO_SYSTEM (0) /* unconnected port*/
48
#define SYSTEM_MD_GAMEPAD (1) /* single 3-buttons or 6-buttons Control Pad */
49
#define SYSTEM_MOUSE (2) /* Sega Mouse */
50
#define SYSTEM_MENACER (3) /* Sega Menacer (port B only) */
51
#define SYSTEM_JUSTIFIER (4) /* Konami Justifiers (port B only) */
52
#define SYSTEM_XE_A1P (5) /* XE-A1P analog controller (port A only) */
53
#define SYSTEM_ACTIVATOR (6) /* Sega Activator */
54
#define SYSTEM_MS_GAMEPAD (7) /* single 2-buttons Control Pad (Master System) */
55
#define SYSTEM_LIGHTPHASER (8) /* Sega Light Phaser (Master System) */
56
#define SYSTEM_PADDLE (9) /* Sega Paddle Control (Master System) */
57
#define SYSTEM_SPORTSPAD (10) /* Sega Sports Pad (Master System) */
58
#define SYSTEM_TEAMPLAYER (11) /* Multi Tap -- Sega TeamPlayer */
59
#define SYSTEM_WAYPLAY (12) /* Multi Tap -- EA 4-Way Play (use both ports) */
60
61
/* Device type */
62
#define NO_DEVICE (0xff) /* unconnected device (fixed ID for Team Player) */
63
#define DEVICE_PAD3B (0x00) /* 3-buttons Control Pad (fixed ID for Team Player)*/
64
#define DEVICE_PAD6B (0x01) /* 6-buttons Control Pad (fixed ID for Team Player) */
65
#define DEVICE_PAD2B (0x02) /* 2-buttons Control Pad */
66
#define DEVICE_MOUSE (0x03) /* Sega Mouse */
67
#define DEVICE_LIGHTGUN (0x04) /* Sega Light Phaser, Menacer or Konami Justifiers */
68
#define DEVICE_PADDLE (0x05) /* Sega Paddle Control */
69
#define DEVICE_SPORTSPAD (0x06) /* Sega Sports Pad */
70
#define DEVICE_PICO (0x07) /* PICO tablet */
71
#define DEVICE_TEREBI (0x08) /* Terebi Oekaki tablet */
72
#define DEVICE_XE_A1P (0x09) /* XE-A1P analog controller */
73
#define DEVICE_ACTIVATOR (0x0a) /* Activator */
74
75
/* Default Input bitmasks */
76
#define INPUT_MODE (0x0800)
77
#define INPUT_X (0x0400)
78
#define INPUT_Y (0x0200)
79
#define INPUT_Z (0x0100)
80
#define INPUT_START (0x0080)
81
#define INPUT_A (0x0040)
82
#define INPUT_C (0x0020)
83
#define INPUT_B (0x0010)
84
#define INPUT_RIGHT (0x0008)
85
#define INPUT_LEFT (0x0004)
86
#define INPUT_DOWN (0x0002)
87
#define INPUT_UP (0x0001)
88
89
/* Master System specific bitmasks */
90
#define INPUT_BUTTON2 (0x0020)
91
#define INPUT_BUTTON1 (0x0010)
92
93
/* Mega Mouse specific bitmask */
94
#define INPUT_MOUSE_CENTER (0x0040)
95
#define INPUT_MOUSE_RIGHT (0x0020)
96
#define INPUT_MOUSE_LEFT (0x0010)
97
98
/* Pico hardware specific bitmask */
99
#define INPUT_PICO_PEN (0x0080)
100
#define INPUT_PICO_RED (0x0010)
101
102
/* XE-1AP specific bitmask */
103
#define INPUT_XE_E1 (0x0800)
104
#define INPUT_XE_E2 (0x0400)
105
#define INPUT_XE_START (0x0200)
106
#define INPUT_XE_SELECT (0x0100)
107
#define INPUT_XE_A (0x0080)
108
#define INPUT_XE_B (0x0040)
109
#define INPUT_XE_C (0x0020)
110
#define INPUT_XE_D (0x0010)
111
112
/* Activator specific bitmasks */
113
#define INPUT_ACTIVATOR_8U (0x8000)
114
#define INPUT_ACTIVATOR_8L (0x4000)
115
#define INPUT_ACTIVATOR_7U (0x2000)
116
#define INPUT_ACTIVATOR_7L (0x1000)
117
#define INPUT_ACTIVATOR_6U (0x0800)
118
#define INPUT_ACTIVATOR_6L (0x0400)
119
#define INPUT_ACTIVATOR_5U (0x0200)
120
#define INPUT_ACTIVATOR_5L (0x0100)
121
#define INPUT_ACTIVATOR_4U (0x0080)
122
#define INPUT_ACTIVATOR_4L (0x0040)
123
#define INPUT_ACTIVATOR_3U (0x0020)
124
#define INPUT_ACTIVATOR_3L (0x0010)
125
#define INPUT_ACTIVATOR_2U (0x0008)
126
#define INPUT_ACTIVATOR_2L (0x0004)
127
#define INPUT_ACTIVATOR_1U (0x0002)
128
#define INPUT_ACTIVATOR_1L (0x0001)
129
130
typedef struct
131
{
132
uint8 system[2]; /* can be one of the SYSTEM_* values */
133
uint8 dev[MAX_DEVICES]; /* can be one of the DEVICE_* values */
134
uint16 pad[MAX_DEVICES]; /* digital inputs (any of INPUT_* values) */
135
int16 analog[MAX_DEVICES][2]; /* analog inputs (x/y) */
136
int x_offset; /* gun horizontal offset */
137
int y_offset; /* gun vertical offset */
138
} t_input;
139
140
struct
141
{
142
uint8 State;
143
uint8 Counter;
144
uint8 Timeout;
145
} gamepad[MAX_DEVICES];
146
147
/* Global variables */
148
extern t_input input;
149
extern int old_system[2];
150
151
/* Function prototypes */
152
extern void input_init(void);
153
extern void input_reset(void);
154
extern void input_refresh(void);
155
156
#endif
157
158