Supermodel/Src/Inputs/Inputs.h

298 lines
8.6 KiB
C
Raw Normal View History

/**
** Supermodel
** A Sega Model 3 Arcade Emulator.
** Copyright 2011 Bart Trzynadlowski, Nik Henson
**
** This file is part of Supermodel.
**
** Supermodel 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 3 of the License, or (at your option)
** any later version.
**
** Supermodel 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 Supermodel. If not, see <http://www.gnu.org/licenses/>.
**/
/*
* Inputs.h
*
* Header file for CInputs, a class which manages all individual inputs.
*/
2011-04-24 01:14:00 +00:00
#ifndef INCLUDED_INPUTS_H
#define INCLUDED_INPUTS_H
#include "Types.h"
#include <vector>
using namespace std;
class CInputSystem;
class CInput;
class CAnalogInput;
class CAxisInput;
class CSwitchInput;
class CGearShift4Input;
class CTriggerInput;
2011-04-24 01:14:00 +00:00
class CINIFile;
struct GameInfo;
/*
* Represents the collection of Model3 inputs.
*/
class CInputs
{
private:
// Assigned input system
CInputSystem *m_system;
// Vector of all created inputs
vector<CInput*> m_inputs;
/*
* Adds a switch input (eg button) to this collection.
*/
CSwitchInput *AddSwitchInput(const char *id, const char *label, unsigned gameFlags, const char *defaultMapping,
2011-04-24 01:14:00 +00:00
UINT16 offVal = 0x00, UINT16 onVal = 0x01);
/*
* Adds an analog input (eg pedal) to this collection.
*/
CAnalogInput *AddAnalogInput(const char *id, const char *label, unsigned gameFlags, const char *defaultMapping,
2011-04-24 01:14:00 +00:00
UINT16 minVal = 0x00, UINT16 maxVal = 0xFF);
/*
* Adds an axis input (eg jostick axis, light gun axis or steering wheel) to this collection.
*/
CAxisInput *AddAxisInput(const char *id, const char *label, unsigned gameFlags, const char *defaultMapping,
CAnalogInput *axisNeg, CAnalogInput *axisPos, UINT16 minVal = 0x00, UINT16 offVal = 0x80, UINT16 maxVal = 0xFF);
2011-04-24 01:14:00 +00:00
/*
* Adds a 4-gear shifter input to this collection.
*/
CGearShift4Input *AddGearShift4Input(const char *id, const char *label, unsigned gameFlags,
CSwitchInput *shift1, CSwitchInput *shift2, CSwitchInput *shift3, CSwitchInput *shift4, CSwitchInput *shiftN, CSwitchInput *shiftUp, CSwitchInput *shiftDown);
2011-04-24 01:14:00 +00:00
/*
* Adds a lightgun trigger input to this collection.
*/
CTriggerInput *AddTriggerInput(const char *id, const char *label, unsigned gameFlags,
CSwitchInput *trigger, CSwitchInput *offscreen, UINT16 offVal = 0x00, UINT16 onVal = 0x01);
2011-04-24 01:14:00 +00:00
void PrintHeader(const char *fmt, ...);
void PrintConfigureInputsHelp();
public:
// UI controls
CSwitchInput *uiExit;
CSwitchInput *uiReset;
CSwitchInput *uiPause;
Committing various small updates that have been hanging around in my source tree for a while now: - Added 'crosshairs' command line and config option. - Added 'vsync' command line and config option (so far only tested on NVidia cards on Windows 7 - other graphics drivers, O/Ss or driver settings may simply chose to ignore this). - Added fullscreen toggle within game using Alt+Enter key combination. - Added framework for lamp outputs and 'outputs' command line and config option. So far only the lamps for driving games are hooked up in the emulator (others to be added later). - Added an initial outputs implementation for Windows that sends MAMEHooker compatible messages (-outputs=win to enable) - Fixed fps calculation in Main.cpp that was producing incorrect results and so giving the impression that frame throttling wasn't working properly when in fact it was. - Fixed palette indexed colours as the index was always off by one, causing incorrect colours in various games, eg drivers' suits and flashing Start sign in Daytona 2. - Altered caching of models so that models with palette indexed colours use the dynamic cache rather than the static one. This is so that changes in palette indexed colours appear on screen, eg the flashing Start sign on the advanced course of Daytona 2 (although currently the START message itself is not visible due to other problems with texture decoding). - Fixed small bug in TileGen.cpp which meant both palettes were being completely recomputed pretty much with every frame. This was a significant performance hit, particularly as palette recomputation is currently being done in SyncSnapshots (it should be moved out of here at some point, although for now it's no big deal). - Made sure all OpenGL objects and resources are deleted in Render2D/3D destructors, in particular the deleting of the VBO buffer in DestroyModelCache. - Made sure that GLSL uniforms are always checked to see if they are bound before using them in order to stop unecessary (but harmless) GL errors. - Altered the default texture sheet handling to use a single large GL texture holding multiple Model3 texture sheets rather than multiple GL textures as before (if required, the old behaviour can still be selected with the mulisheet fragment shader). I believe this fixes the disappearing crosshairs/corrupt GL state problem which the multisheet fragment shader seemed to be triggering somehow. - Fixed a bug in debugger which meant memory watches were not triggering properly
2012-07-15 21:04:46 +00:00
CSwitchInput *uiFullScreen;
CSwitchInput *uiSaveState;
CSwitchInput *uiChangeSlot;
CSwitchInput *uiLoadState;
CSwitchInput *uiMusicVolUp;
CSwitchInput *uiMusicVolDown;
CSwitchInput *uiSoundVolUp;
CSwitchInput *uiSoundVolDown;
CSwitchInput *uiClearNVRAM;
CSwitchInput *uiSelectCrosshairs;
CSwitchInput *uiToggleFrLimit;
CSwitchInput *uiDumpInpState;
CSwitchInput *uiDumpTimings;
#ifdef SUPERMODEL_DEBUGGER
CSwitchInput *uiEnterDebugger;
#endif
2011-04-24 01:14:00 +00:00
// Common controls between all games
CSwitchInput *coin[2];
CSwitchInput *start[2];
CSwitchInput *test[2];
CSwitchInput *service[2];
2011-04-24 01:14:00 +00:00
// Joysticks (players 1 and 2)
CSwitchInput *up[2];
CSwitchInput *down[2];
CSwitchInput *left[2];
CSwitchInput *right[2];
2011-04-24 01:14:00 +00:00
// Fighting game controls (players 1 and 2)
CSwitchInput *punch[2];
CSwitchInput *kick[2];
CSwitchInput *guard[2];
CSwitchInput *escape[2];
// Spikeout controls
CSwitchInput *shift;
CSwitchInput *beat;
CSwitchInput *charge;
CSwitchInput *jump;
2011-04-24 01:14:00 +00:00
// Soccer game controls (players 1 and 2)
CSwitchInput *shortPass[2];
CSwitchInput *longPass[2];
CSwitchInput *shoot[2];
2011-04-24 01:14:00 +00:00
// Vehicle controls
CAxisInput *steering;
CAnalogInput *accelerator;
CAnalogInput *brake;
2011-04-24 01:14:00 +00:00
// VR view buttons: VR1 Red, VR2 Blue, VR3 Yellow, VR4 Green
CSwitchInput *vr[4];
2011-04-24 01:14:00 +00:00
Some updates to Supermodel made at beginning of the year but only now got around to checking in (better late than never...): - hooked up the remaining controls in Supermodel (except for Magical Truck Adventure which does not work at all yet). The new controls are: * InputAnalogJoyTrigger2 and InputAnalogJoyEvent2 for the additional second trigger and event buttons that were missing from Star Wars Trilogy, * InputRearBrake and InputMusicSelect for the rear brake and music selection buttons that were missing from Harley Davidson, * InputAnalogGunXXX, InputAnalogTriggerXXX, InputAnalogGunXXX2 and InputAnalogTriggerXXX2 for the analogue guns of Ocean Hunter and LA Machineguns (NOTE: these controls must be calibrated in the games' service menus otherwise they will not work properly. Also, the alignment of the gun cursor does not line up very well with the mouse position at the moment, but at least the games are a bit more playable now, although still with numerous graphical glitches...) * InputSkiXXX for the controls of Ski Champ, making the game playable now. - hooked up existing InputViewChange control to Harley Davidson's view change button - improved the handling of InputGearShiftUp/Down inputs so that they work better with the driving games. With Dirt Devils, ECA, Harley and LeMans this means they map directly to the game's own shift up/down controls, while with the 4-speed games such as Daytona 2, Scud Racer and Sega Rally 2, they simulate the user shifting up and down through the gears - added defaults for the new controls to Supermodel.ini - other small code tweaks: * fix small bug with handling of pos/neg inputs mapping to a control with inverted range (0XFF to 0x00) - this was needed to get Ski Champ's X-axis to work properly * removed Wait method from InputSystem and added to CThread as CThread::Sleep instead * added FrameTimings struct to hold all frame timings in a single place No networking code yet as just haven't had a chance to work on it since initial progress at the beginning of the year - am *hoping* might have some time to pick it up again over Christmas...
2013-11-30 19:39:59 +00:00
// Up/down gear shift
CSwitchInput *gearShiftUp;
CSwitchInput *gearShiftDown;
2011-04-24 01:14:00 +00:00
// 4-speed gear shift
CGearShift4Input *gearShift4;
2011-04-24 01:14:00 +00:00
// Rally controls
CSwitchInput *viewChange;
CSwitchInput *handBrake;
Some updates to Supermodel made at beginning of the year but only now got around to checking in (better late than never...): - hooked up the remaining controls in Supermodel (except for Magical Truck Adventure which does not work at all yet). The new controls are: * InputAnalogJoyTrigger2 and InputAnalogJoyEvent2 for the additional second trigger and event buttons that were missing from Star Wars Trilogy, * InputRearBrake and InputMusicSelect for the rear brake and music selection buttons that were missing from Harley Davidson, * InputAnalogGunXXX, InputAnalogTriggerXXX, InputAnalogGunXXX2 and InputAnalogTriggerXXX2 for the analogue guns of Ocean Hunter and LA Machineguns (NOTE: these controls must be calibrated in the games' service menus otherwise they will not work properly. Also, the alignment of the gun cursor does not line up very well with the mouse position at the moment, but at least the games are a bit more playable now, although still with numerous graphical glitches...) * InputSkiXXX for the controls of Ski Champ, making the game playable now. - hooked up existing InputViewChange control to Harley Davidson's view change button - improved the handling of InputGearShiftUp/Down inputs so that they work better with the driving games. With Dirt Devils, ECA, Harley and LeMans this means they map directly to the game's own shift up/down controls, while with the 4-speed games such as Daytona 2, Scud Racer and Sega Rally 2, they simulate the user shifting up and down through the gears - added defaults for the new controls to Supermodel.ini - other small code tweaks: * fix small bug with handling of pos/neg inputs mapping to a control with inverted range (0XFF to 0x00) - this was needed to get Ski Champ's X-axis to work properly * removed Wait method from InputSystem and added to CThread as CThread::Sleep instead * added FrameTimings struct to hold all frame timings in a single place No networking code yet as just haven't had a chance to work on it since initial progress at the beginning of the year - am *hoping* might have some time to pick it up again over Christmas...
2013-11-30 19:39:59 +00:00
// Harley Davidson controls
CAnalogInput *rearBrake;
CSwitchInput *musicSelect;
// Twin joysticks (individually mapped version; 1 = left stick, 2 = right stick)
CSwitchInput *twinJoyLeft1;
CSwitchInput *twinJoyLeft2;
CSwitchInput *twinJoyRight1;
CSwitchInput *twinJoyRight2;
CSwitchInput *twinJoyUp1;
CSwitchInput *twinJoyUp2;
CSwitchInput *twinJoyDown1;
CSwitchInput *twinJoyDown2;
CSwitchInput *twinJoyShot1;
CSwitchInput *twinJoyShot2;
CSwitchInput *twinJoyTurbo1;
CSwitchInput *twinJoyTurbo2;
// Twin joysticks (macro mapping, for users w/out dual joysticks)
CSwitchInput *twinJoyTurnLeft;
CSwitchInput *twinJoyTurnRight;
CSwitchInput *twinJoyStrafeLeft;
CSwitchInput *twinJoyStrafeRight;
CSwitchInput *twinJoyForward;
CSwitchInput *twinJoyReverse;
CSwitchInput *twinJoyJump;
CSwitchInput *twinJoyCrouch;
2011-04-24 01:14:00 +00:00
// Analog joystick
CAxisInput *analogJoyX;
CAxisInput *analogJoyY;
Some updates to Supermodel made at beginning of the year but only now got around to checking in (better late than never...): - hooked up the remaining controls in Supermodel (except for Magical Truck Adventure which does not work at all yet). The new controls are: * InputAnalogJoyTrigger2 and InputAnalogJoyEvent2 for the additional second trigger and event buttons that were missing from Star Wars Trilogy, * InputRearBrake and InputMusicSelect for the rear brake and music selection buttons that were missing from Harley Davidson, * InputAnalogGunXXX, InputAnalogTriggerXXX, InputAnalogGunXXX2 and InputAnalogTriggerXXX2 for the analogue guns of Ocean Hunter and LA Machineguns (NOTE: these controls must be calibrated in the games' service menus otherwise they will not work properly. Also, the alignment of the gun cursor does not line up very well with the mouse position at the moment, but at least the games are a bit more playable now, although still with numerous graphical glitches...) * InputSkiXXX for the controls of Ski Champ, making the game playable now. - hooked up existing InputViewChange control to Harley Davidson's view change button - improved the handling of InputGearShiftUp/Down inputs so that they work better with the driving games. With Dirt Devils, ECA, Harley and LeMans this means they map directly to the game's own shift up/down controls, while with the 4-speed games such as Daytona 2, Scud Racer and Sega Rally 2, they simulate the user shifting up and down through the gears - added defaults for the new controls to Supermodel.ini - other small code tweaks: * fix small bug with handling of pos/neg inputs mapping to a control with inverted range (0XFF to 0x00) - this was needed to get Ski Champ's X-axis to work properly * removed Wait method from InputSystem and added to CThread as CThread::Sleep instead * added FrameTimings struct to hold all frame timings in a single place No networking code yet as just haven't had a chance to work on it since initial progress at the beginning of the year - am *hoping* might have some time to pick it up again over Christmas...
2013-11-30 19:39:59 +00:00
CSwitchInput *analogJoyTrigger1;
CSwitchInput *analogJoyTrigger2;
CSwitchInput *analogJoyEvent1;
CSwitchInput *analogJoyEvent2;
2011-04-24 01:14:00 +00:00
Some updates to Supermodel made at beginning of the year but only now got around to checking in (better late than never...): - hooked up the remaining controls in Supermodel (except for Magical Truck Adventure which does not work at all yet). The new controls are: * InputAnalogJoyTrigger2 and InputAnalogJoyEvent2 for the additional second trigger and event buttons that were missing from Star Wars Trilogy, * InputRearBrake and InputMusicSelect for the rear brake and music selection buttons that were missing from Harley Davidson, * InputAnalogGunXXX, InputAnalogTriggerXXX, InputAnalogGunXXX2 and InputAnalogTriggerXXX2 for the analogue guns of Ocean Hunter and LA Machineguns (NOTE: these controls must be calibrated in the games' service menus otherwise they will not work properly. Also, the alignment of the gun cursor does not line up very well with the mouse position at the moment, but at least the games are a bit more playable now, although still with numerous graphical glitches...) * InputSkiXXX for the controls of Ski Champ, making the game playable now. - hooked up existing InputViewChange control to Harley Davidson's view change button - improved the handling of InputGearShiftUp/Down inputs so that they work better with the driving games. With Dirt Devils, ECA, Harley and LeMans this means they map directly to the game's own shift up/down controls, while with the 4-speed games such as Daytona 2, Scud Racer and Sega Rally 2, they simulate the user shifting up and down through the gears - added defaults for the new controls to Supermodel.ini - other small code tweaks: * fix small bug with handling of pos/neg inputs mapping to a control with inverted range (0XFF to 0x00) - this was needed to get Ski Champ's X-axis to work properly * removed Wait method from InputSystem and added to CThread as CThread::Sleep instead * added FrameTimings struct to hold all frame timings in a single place No networking code yet as just haven't had a chance to work on it since initial progress at the beginning of the year - am *hoping* might have some time to pick it up again over Christmas...
2013-11-30 19:39:59 +00:00
// Light gun controls (players 1 and 2)
CAxisInput *gunX[2];
CAxisInput *gunY[2];
CTriggerInput *trigger[2];
Some updates to Supermodel made at beginning of the year but only now got around to checking in (better late than never...): - hooked up the remaining controls in Supermodel (except for Magical Truck Adventure which does not work at all yet). The new controls are: * InputAnalogJoyTrigger2 and InputAnalogJoyEvent2 for the additional second trigger and event buttons that were missing from Star Wars Trilogy, * InputRearBrake and InputMusicSelect for the rear brake and music selection buttons that were missing from Harley Davidson, * InputAnalogGunXXX, InputAnalogTriggerXXX, InputAnalogGunXXX2 and InputAnalogTriggerXXX2 for the analogue guns of Ocean Hunter and LA Machineguns (NOTE: these controls must be calibrated in the games' service menus otherwise they will not work properly. Also, the alignment of the gun cursor does not line up very well with the mouse position at the moment, but at least the games are a bit more playable now, although still with numerous graphical glitches...) * InputSkiXXX for the controls of Ski Champ, making the game playable now. - hooked up existing InputViewChange control to Harley Davidson's view change button - improved the handling of InputGearShiftUp/Down inputs so that they work better with the driving games. With Dirt Devils, ECA, Harley and LeMans this means they map directly to the game's own shift up/down controls, while with the 4-speed games such as Daytona 2, Scud Racer and Sega Rally 2, they simulate the user shifting up and down through the gears - added defaults for the new controls to Supermodel.ini - other small code tweaks: * fix small bug with handling of pos/neg inputs mapping to a control with inverted range (0XFF to 0x00) - this was needed to get Ski Champ's X-axis to work properly * removed Wait method from InputSystem and added to CThread as CThread::Sleep instead * added FrameTimings struct to hold all frame timings in a single place No networking code yet as just haven't had a chance to work on it since initial progress at the beginning of the year - am *hoping* might have some time to pick it up again over Christmas...
2013-11-30 19:39:59 +00:00
// Analog gun controls (players 1 and 2)
CAxisInput *analogGunX[2];
CAxisInput *analogGunY[2];
CSwitchInput *analogTriggerLeft[2];
CSwitchInput *analogTriggerRight[2];
// Ski Champ controls
CAxisInput *skiX;
CAxisInput *skiY;
CSwitchInput *skiPollLeft;
CSwitchInput *skiPollRight;
CSwitchInput *skiSelect1;
CSwitchInput *skiSelect2;
CSwitchInput *skiSelect3;
2011-04-24 01:14:00 +00:00
/*
* Creates a set of inputs with the given input system.
*/
CInputs(CInputSystem *system);
/*
* CInputs destructor.
*/
2011-04-24 01:14:00 +00:00
~CInputs();
/*
* Returns the number of available inputs.
*/
unsigned Count();
/*
* Returns the input with the given index.
*/
CInput *operator[](const unsigned index);
/*
* Returns the input with the given id or label.
*/
CInput *operator[](const char *idOrLabel);
2011-04-24 01:14:00 +00:00
/*
* Returns the assigned input system.
*/
CInputSystem *GetInputSystem();
/*
* Initializes the inputs. Must be called before any other methods are used.
*/
bool Initialize();
/*
* Reads the input mapping assignments from the given INI file.
*/
void ReadFromINIFile(CINIFile *ini, const char *section);
/*
* Writes the current input mapping assignments to the given INI file.
*/
void WriteToINIFile(CINIFile *ini, const char *section);
/*
* Configures the current input mapping assignments for the given game, or all inputs if game is NULL, by asking the user for input.
* Returns true if the inputs were configured okay or false if the user exited without requesting to save changes.
*/
bool ConfigureInputs(const GameInfo *game);
/*
* Configures the current input mapping assignments for the given game, or all inputs if game is NULL, by asking the user for input.
* Takes display geometry if this has not been set previously by a call to Poll().
* Returns true if the inputs were configured okay or false if the user exited without requesting to save changes.
*/
2011-04-24 01:14:00 +00:00
bool ConfigureInputs(const GameInfo *game, unsigned dispX, unsigned dispY, unsigned dispW, unsigned dispH);
void CalibrateJoysticks();
void CalibrateJoystick(int joyNum);
2011-04-24 01:14:00 +00:00
/*
* Prints to stdout the current input mapping assignments for the given game, or all inputs if game is NULL.
*/
void PrintInputs(const GameInfo *game);
/*
* Polls (updates) the inputs for the given game, or all inputs if game is NULL, updating their values from their respective input sources.
* First the input system is polled (CInputSystem.Poll()) and then each input is polled (CInput.Poll()).
*/
bool Poll(const GameInfo *game, unsigned dispX, unsigned dispY, unsigned dispW, unsigned dispH);
/*
* Prints the current values of the inputs for the given game, or all inputs if game is NULL, to stdout for debugging purposes.
*/
void DumpState(const GameInfo *game);
};
#endif // INCLUDED_INPUTS_H