Supermodel/Src/Inputs/InputSource.h
Nik Henson 5e247021be Changes relating to input system:
- Fixed bug with mapping of multiple assignments.
- Added new ! operator for input mappings, which lets the user specify that an input must not be active.
- Added option to print info about input system (such as settings and detected keyboards, mice and joysticks) during input configuration.
- Added new trigger input for lightgun games with a configurable option to automatically pull trigger when offscreen input is activated (this makes playing with the mouse easier as the gun can be reloaded with single mouse button, rather than having to press both
 buttons at the same time).
- Added -xinput command line option that switches to using XInput API rather than DirectInput for XBox 360 controllers (this allows the XBox 360 controller's two triggers to be read independently which works better for driving games when they are mapped to accele
rator and brake).
- Added initial version of force feedback implementation to DirectInputSystem (this still needs work).
2011-06-05 20:53:39 +00:00

79 lines
2.1 KiB
C++

#ifndef INCLUDED_INPUTSOURCE_H
#define INCLUDED_INPUTSOURCE_H
#include <string>
using namespace std;
class CInputSystem;
struct ForceFeedbackCmd;
/*
* Enumeration to represent different types of sources.
*/
enum ESourceType
{
SourceInvalid = -1,
SourceEmpty = 0,
SourceSwitch = 1,
SourceHalfAxis = 2,
SourceFullAxis = 3
};
/*
* Provides values to inputs, either in the form of a bool for switch inputs or an int value within a given range for analog/axis inputs.
*/
class CInputSource
{
protected:
CInputSource(ESourceType sourceType);
public:
/*
* The type of this source.
*/
const ESourceType type;
//
// Static helper methods
//
/*
* Clamps the given value to between the min and max values.
*/
static int Clamp(int val, int minVal, int maxVal);
/*
* Scales the given value, that falls within the stated 'from' range, to be between the given 'to' range.
*/
static int Scale(int val, int fromMinVal, int fromMaxVal, int toMinVal, int toMaxVal);
/*
* Scales the given value, that falls within the stated 'from' range, to be between the given 'to' range.
* The off values are supplied to avoid rounding errors and ensure that the scaled value has the correct off value when required.
*/
static int Scale(int val, int fromMinVal, int fromOffVal, int fromMaxVal, int toMinVal, int toOffVal, int toMaxVal);
/*
* Returns true if the source is active (taken from GetValueAsSwitch).
*/
bool IsActive();
/*
* Reads a boolean value for a switch input.
* Returns true if the value was set.
*/
virtual bool GetValueAsSwitch(bool &val) = 0;
/*
* Reads an int value for an analog/axis input, guaranteeing that the value falls within the given range and has the correct off value when required.
* Returns true if the value was set.
*/
virtual bool GetValueAsAnalog(int &val, int minVal, int offVal, int maxVal) = 0;
/*
* Sends a force feedback command to the input source.
*/
virtual bool SendForceFeedbackCmd(ForceFeedbackCmd *ffCmd);
};
#endif // INCLUDED_INPUTSOURCE_H