1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-input-sdl - plugin.h *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2008-2009 Richard Goedeken *
* Copyright (C) 2008 Tillin9 *
* Copyright (C) 2002 Blight *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef __PLUGIN_H__
#define __PLUGIN_H__
#include <SDL.h>
#if ! SDL_VERSION_ATLEAST(1,3,0)
#define SDL_GetKeyboardState SDL_GetKeyState
#define SDL_SCANCODE_UNKNOWN SDLK_UNKNOWN
#define SDL_NUM_SCANCODES SDLK_LAST
#define SDL_SCANCODE_RCTRL SDLK_RCTRL
#define SDL_SCANCODE_RSHIFT SDLK_RSHIFT
#define SDL_SCANCODE_LCTRL SDLK_LCTRL
#define SDL_SCANCODE_LALT SDLK_LALT
#define SDL_Scancode SDLKey
#endif
#if SDL_VERSION_ATLEAST(2,0,0)
static inline const char* _SDL_JoystickName(int device_index)
{
SDL_Joystick *joystick;
const char *name;
static char JoyName[256];
joystick = SDL_JoystickOpen(device_index);
if (!joystick)
return NULL;
name = SDL_JoystickName(joystick);
if (name)
{
strncpy(JoyName, name, 255);
JoyName[255] = 0;
}
SDL_JoystickClose(joystick);
return JoyName;
}
#define SDL_JoystickName(device_index) _SDL_JoystickName(device_index)
#endif
#define M64P_PLUGIN_PROTOTYPES 1
#include "m64p_plugin.h"
#include "m64p_config.h"
#define DEVICE_NO_JOYSTICK (-1)
// Some stuff from n-rage plugin
#define RD_GETSTATUS 0x00 // get status
#define RD_READKEYS 0x01 // read button values
#define RD_READPAK 0x02 // read from controllerpack
#define RD_WRITEPAK 0x03 // write to controllerpack
#define RD_RESETCONTROLLER 0xff // reset controller
#define RD_READEEPROM 0x04 // read eeprom
#define RD_WRITEEPROM 0x05 // write eeprom
#define PAK_IO_RUMBLE 0xC000 // the address where rumble-commands are sent to
enum EButton
{
R_DPAD = 0,
L_DPAD,
D_DPAD,
U_DPAD,
START_BUTTON,
Z_TRIG,
B_BUTTON,
A_BUTTON,
R_CBUTTON,
L_CBUTTON,
D_CBUTTON,
U_CBUTTON,
R_TRIG,
L_TRIG,
MEMPAK,
RUMBLEPAK,
X_AXIS,
Y_AXIS,
NUM_BUTTONS
};
typedef struct
{
int button; // button index; -1 if notassigned
SDL_Scancode key; // sdl keysym; SDL_SCANCODE_UNKNOWN if not assigned
int axis, axis_dir; // aixs + direction (i.e. 0, 1 = X Axis +; 0, -1 = X Axis -); -1 if notassigned
int axis_deadzone; // -1 for default, or >= 0 for custom value
int hat, hat_pos; // hat + hat position; -1 if not assigned
int mouse; // mouse button
} SButtonMap;
typedef struct
{
int button_a, button_b; // up/down or left/right; -1 if not assigned
SDL_Scancode key_a, key_b; // up/down or left/right; SDL_SCANCODE_UNKNOWN if not assigned
int axis_a, axis_b; // axis index; -1 if not assigned
int axis_dir_a, axis_dir_b; // direction (1 = X+, 0, -1 = X-)
int hat, hat_pos_a, hat_pos_b; // hat + hat position up/down and left/right; -1 if not assigned
} SAxisMap;
typedef struct
{
CONTROL *control; // pointer to CONTROL struct in Core library
BUTTONS buttons;
// mappings
SButtonMap button[16]; // 14 buttons; in the order of EButton + mempak/rumblepak switches
SAxisMap axis[2]; // 2 axis
int device; // joystick device; -1 = keyboard; -2 = none
int mouse; // mouse enabled: 0 = no; 1 = yes
SDL_Joystick *joystick; // SDL joystick device
#if SDL_VERSION_ATLEAST(2,0,0)
SDL_Haptic *event_joystick; // the sdl device for force feeback
#else
int event_joystick; // the /dev/input/eventX device for force feeback
#endif
int axis_deadzone[2]; // minimum absolute value before analog movement is recognized
int axis_peak[2]; // highest analog value returned by SDL, used for scaling
float mouse_sens[2]; // mouse sensitivity
} SController;
/* global data definitions */
extern SController controller[4]; // 4 controllers
/* global function definitions */
extern void DebugMessage(int level, const char *message, ...);
/* declarations of pointers to Core config functions */
extern ptr_ConfigListSections ConfigListSections;
extern ptr_ConfigOpenSection ConfigOpenSection;
extern ptr_ConfigDeleteSection ConfigDeleteSection;
extern ptr_ConfigListParameters ConfigListParameters;
extern ptr_ConfigSaveFile ConfigSaveFile;
extern ptr_ConfigSaveSection ConfigSaveSection;
extern ptr_ConfigSetParameter ConfigSetParameter;
extern ptr_ConfigGetParameter ConfigGetParameter;
extern ptr_ConfigGetParameterHelp ConfigGetParameterHelp;
extern ptr_ConfigSetDefaultInt ConfigSetDefaultInt;
extern ptr_ConfigSetDefaultFloat ConfigSetDefaultFloat;
extern ptr_ConfigSetDefaultBool ConfigSetDefaultBool;
extern ptr_ConfigSetDefaultString ConfigSetDefaultString;
extern ptr_ConfigGetParamInt ConfigGetParamInt;
extern ptr_ConfigGetParamFloat ConfigGetParamFloat;
extern ptr_ConfigGetParamBool ConfigGetParamBool;
extern ptr_ConfigGetParamString ConfigGetParamString;
extern ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath;
extern ptr_ConfigGetUserConfigPath ConfigGetUserConfigPath;
extern ptr_ConfigGetUserDataPath ConfigGetUserDataPath;
extern ptr_ConfigGetUserCachePath ConfigGetUserCachePath;
#endif // __PLUGIN_H__
|