00001
00002
00003
#ifndef INPUTMAPPER_H
00004
#define INPUTMAPPER_H
00005
00006
#include "RageInputDevice.h"
00007
#include "GameInput.h"
00008
#include "MenuInput.h"
00009
#include "StyleInput.h"
00010
#include "GameConstantsAndTypes.h"
00011
00012
00013
00014 const int NUM_GAME_TO_DEVICE_SLOTS = 3;
00015
00016
00017 class InputMapper
00018 {
00019
public:
00020
InputMapper();
00021
~InputMapper();
00022
00023
void ReadMappingsFromDisk();
00024
void SaveMappingsToDisk();
00025
00026
void ClearAllMappings();
00027
00028
void SetInputMap(
DeviceInput DeviceI,
GameInput GameI,
int iSlotIndex );
00029
void ClearFromInputMap(
DeviceInput DeviceI );
00030
void ClearFromInputMap(
GameInput GameI,
int iSlotIndex );
00031
00032
void AddDefaultMappingsForCurrentGameIfUnmapped();
00033
void AutoMapJoysticksForCurrentGame();
00034
00035
bool IsMapped(
DeviceInput DeviceI );
00036
bool IsMapped(
GameInput GameI );
00037
00038
bool DeviceToGame(
DeviceInput DeviceI,
GameInput& GameI );
00039
bool GameToDevice(
GameInput GameI,
int iSoltNum,
DeviceInput& DeviceI );
00040
00041
void GameToStyle(
GameInput GameI,
StyleInput &StyleI );
00042
void StyleToGame(
StyleInput StyleI,
GameInput &GameI );
00043
00044
void GameToMenu(
GameInput GameI,
MenuInput &MenuI );
00045
void MenuToGame(
MenuInput MenuI,
GameInput GameIout[4] );
00046
00047
float GetSecsHeld(
GameInput GameI );
00048
float GetSecsHeld(
MenuInput MenuI );
00049
float GetSecsHeld(
StyleInput StyleI );
00050
00051
bool IsButtonDown(
GameInput GameI );
00052
bool IsButtonDown(
MenuInput MenuI );
00053
bool IsButtonDown(
StyleInput StyleI );
00054
00055
void ResetKeyRepeat(
GameInput GameI );
00056
void ResetKeyRepeat(
MenuInput MenuI );
00057
void ResetKeyRepeat(
StyleInput StyleI );
00058
00059 struct Mapping {
00060 bool IsEndMarker()
const {
return iSlotIndex==-1; }
00061
00062 int iSlotIndex;
00063 int deviceButton;
00064 GameButton gb;
00065
00066
00067
00068
00069
00070
00071
00072
00073 bool SecondController;
00074 };
00075
00076
void ApplyMapping(
const Mapping *maps, GameController gc, InputDevice device );
00077
00078
protected:
00079
00080 DeviceInput m_GItoDI[
MAX_GAME_CONTROLLERS][
MAX_GAME_BUTTONS][
NUM_GAME_TO_DEVICE_SLOTS];
00081
00082
00083
00084 GameInput m_tempDItoGI[
NUM_INPUT_DEVICES][
MAX_DEVICE_BUTTONS];
00085
void UpdateTempDItoGI();
00086 };
00087
00088
00089 extern InputMapper*
INPUTMAPPER;
00090
00091
00092
#endif
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117