1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Mupen64plus-input-sdl - plugin.h *
3 * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
4 * Copyright (C) 2008-2009 Richard Goedeken *
5 * Copyright (C) 2008 Tillin9 *
6 * Copyright (C) 2002 Blight *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the *
20 * Free Software Foundation, Inc., *
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
22 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
28 #if ! SDL_VERSION_ATLEAST(1,3,0)
30 #define SDL_GetKeyboardState SDL_GetKeyState
31 #define SDL_SCANCODE_UNKNOWN SDLK_UNKNOWN
32 #define SDL_NUM_SCANCODES SDLK_LAST
33 #define SDL_SCANCODE_RCTRL SDLK_RCTRL
34 #define SDL_SCANCODE_RSHIFT SDLK_RSHIFT
35 #define SDL_SCANCODE_LCTRL SDLK_LCTRL
36 #define SDL_SCANCODE_LALT SDLK_LALT
37 #define SDL_Scancode SDLKey
41 #if SDL_VERSION_ATLEAST(2,0,0)
43 static inline const char* _SDL_JoystickName(int device_index)
45 SDL_Joystick *joystick;
47 static char JoyName[256];
49 joystick = SDL_JoystickOpen(device_index);
53 name = SDL_JoystickName(joystick);
56 strncpy(JoyName, name, 255);
59 SDL_JoystickClose(joystick);
64 #define SDL_JoystickName(device_index) _SDL_JoystickName(device_index)
68 #define M64P_PLUGIN_PROTOTYPES 1
69 #include "m64p_plugin.h"
70 #include "m64p_config.h"
72 #define DEVICE_NO_JOYSTICK (-1)
74 // Some stuff from n-rage plugin
75 #define RD_GETSTATUS 0x00 // get status
76 #define RD_READKEYS 0x01 // read button values
77 #define RD_READPAK 0x02 // read from controllerpack
78 #define RD_WRITEPAK 0x03 // write to controllerpack
79 #define RD_RESETCONTROLLER 0xff // reset controller
80 #define RD_READEEPROM 0x04 // read eeprom
81 #define RD_WRITEEPROM 0x05 // write eeprom
83 #define PAK_IO_RUMBLE 0xC000 // the address where rumble-commands are sent to
114 int button; // button index; -1 if notassigned
115 SDL_Scancode key; // sdl keysym; SDL_SCANCODE_UNKNOWN if not assigned
116 int axis, axis_dir; // aixs + direction (i.e. 0, 1 = X Axis +; 0, -1 = X Axis -); -1 if notassigned
117 int axis_deadzone; // -1 for default, or >= 0 for custom value
118 int hat, hat_pos; // hat + hat position; -1 if not assigned
119 int mouse; // mouse button
120 int mouse_up; // mouse direction pseudo buttons
128 int button_a, button_b; // up/down or left/right; -1 if not assigned
129 SDL_Scancode key_a, key_b; // up/down or left/right; SDL_SCANCODE_UNKNOWN if not assigned
130 int axis_a, axis_b; // axis index; -1 if not assigned
131 int axis_dir_a, axis_dir_b; // direction (1 = X+, 0, -1 = X-)
132 int hat, hat_pos_a, hat_pos_b; // hat + hat position up/down and left/right; -1 if not assigned
137 CONTROL *control; // pointer to CONTROL struct in Core library
141 SButtonMap button[NUM_BUTTONS]; // 14 buttons; in the order of EButton + mempak/rumblepak switches
142 SAxisMap axis[2]; // 2 axis
143 int device; // joystick device; -1 = keyboard; -2 = none
144 int mouse; // mouse enabled: 0 = no; 1 = yes
145 SDL_Joystick *joystick; // SDL joystick device
146 int event_joystick; // the /dev/input/eventX device for force feeback
147 int axis_deadzone[2]; // minimum absolute value before analog movement is recognized
148 int axis_peak[2]; // highest analog value returned by SDL, used for scaling
149 float mouse_sens[2]; // mouse sensitivity
156 /* global data definitions */
157 extern SController controller[4]; // 4 controllers
159 /* global function definitions */
160 extern void DebugMessage(int level, const char *message, ...);
162 /* declarations of pointers to Core config functions */
163 extern ptr_ConfigListSections ConfigListSections;
164 extern ptr_ConfigOpenSection ConfigOpenSection;
165 extern ptr_ConfigDeleteSection ConfigDeleteSection;
166 extern ptr_ConfigListParameters ConfigListParameters;
167 extern ptr_ConfigSaveFile ConfigSaveFile;
168 extern ptr_ConfigSaveSection ConfigSaveSection;
169 extern ptr_ConfigSetParameter ConfigSetParameter;
170 extern ptr_ConfigGetParameter ConfigGetParameter;
171 extern ptr_ConfigGetParameterHelp ConfigGetParameterHelp;
172 extern ptr_ConfigSetDefaultInt ConfigSetDefaultInt;
173 extern ptr_ConfigSetDefaultFloat ConfigSetDefaultFloat;
174 extern ptr_ConfigSetDefaultBool ConfigSetDefaultBool;
175 extern ptr_ConfigSetDefaultString ConfigSetDefaultString;
176 extern ptr_ConfigGetParamInt ConfigGetParamInt;
177 extern ptr_ConfigGetParamFloat ConfigGetParamFloat;
178 extern ptr_ConfigGetParamBool ConfigGetParamBool;
179 extern ptr_ConfigGetParamString ConfigGetParamString;
181 extern ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath;
182 extern ptr_ConfigGetUserConfigPath ConfigGetUserConfigPath;
183 extern ptr_ConfigGetUserDataPath ConfigGetUserDataPath;
184 extern ptr_ConfigGetUserCachePath ConfigGetUserCachePath;
186 #endif // __PLUGIN_H__