2 * Copyright (c) 2009, Wei Mingzhi <whistler@openoffice.org>.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see <http://www.gnu.org/licenses>.
38 #include <SDL_joystick.h>
41 #include <Carbon/Carbon.h>
42 typedef void *Display;
43 #define ThreadID ThreadID_MACOSX
46 #include <X11/Xutil.h>
47 #include <X11/keysym.h>
48 #include <X11/XKBlib.h>
51 #include "psemu_plugin_defs.h"
56 #define _(x) gettext(x)
91 enum { NONE = 0, AXIS, HAT, BUTTON };
93 typedef struct tagKeyDef {
97 int16_t Axis; // positive=axis+, negative=axis-, abs(Axis)-1=axis index
98 uint16_t Hat; // 8-bit for hat number, 8-bit for direction
99 uint16_t Button; // button number
104 enum { ANALOG_XP = 0, ANALOG_XM, ANALOG_YP, ANALOG_YM };
106 typedef struct tagPadDef {
109 KEYDEF KeyDef[DKEY_TOTAL];
110 KEYDEF AnalogDef[ANALOG_TOTAL][4];
113 typedef struct tagConfig {
118 typedef struct tagPadState {
119 SDL_Joystick *JoyDev;
122 volatile uint16_t KeyStatus;
123 volatile uint16_t JoyKeyStatus;
124 volatile uint8_t AnalogStatus[ANALOG_TOTAL][2]; // 0-255 where 127 is center position
125 volatile uint8_t AnalogKeyStatus[ANALOG_TOTAL][4];
128 typedef struct tagGlobalData {
134 PADSTATE PadState[2];
135 volatile long KeyLeftOver;
141 CMD_READ_DATA_AND_VIBRATE = 0x42,
142 CMD_CONFIG_MODE = 0x43,
143 CMD_SET_MODE_AND_LOCK = 0x44,
144 CMD_QUERY_MODEL_AND_MODE = 0x45,
145 CMD_QUERY_ACT = 0x46, // ??
146 CMD_QUERY_COMB = 0x47, // ??
147 CMD_QUERY_MODE = 0x4C, // QUERY_MODE ??
148 CMD_VIBRATION_TOGGLE = 0x4D,
151 // cfg.c functions...
152 void LoadPADConfig();
153 void SavePADConfig();
155 // sdljoy.c functions...
157 void DestroySDLJoy();
160 // xkb.c functions...
162 void DestroyKeyboard();
163 void CheckKeyboard();
165 // analog.c functions...
168 int AnalogKeyPressed(uint16_t Key);
169 int AnalogKeyReleased(uint16_t Key);
171 // pad.c functions...
172 char *PSEgetLibName(void);
173 uint32_t PSEgetLibType(void);
174 uint32_t PSEgetLibVersion(void);
175 long PADinit(long flags);
176 long PADshutdown(void);
177 long PADopen(unsigned long *Disp);
180 unsigned char PADstartPoll(int pad);
181 unsigned char PADpoll(unsigned char value);
182 long PADreadPort1(PadDataS *pad);
183 long PADreadPort2(PadDataS *pad);
184 long PADkeypressed(void);
185 long PADconfigure(void);