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