2002-11-16 08:07:38 +00:00
|
|
|
#ifndef INPUTFILTER_H
|
|
|
|
|
#define INPUTFILTER_H
|
2002-04-16 17:31:00 +00:00
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
Class: InputFilter
|
|
|
|
|
|
|
|
|
|
Desc: Checks RageInput and generates a list of InputEvents, which can
|
|
|
|
|
represent when a button is first pressed, when a button is released,
|
|
|
|
|
or when an repeating input fires.
|
|
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
2002-04-16 17:31:00 +00:00
|
|
|
Chris Danford
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
2003-02-16 02:25:46 +00:00
|
|
|
#include "RageInputDevice.h"
|
2002-04-16 17:31:00 +00:00
|
|
|
|
|
|
|
|
enum InputEventType { IET_FIRST_PRESS, IET_SLOW_REPEAT, IET_FAST_REPEAT, IET_RELEASE };
|
|
|
|
|
|
2003-02-16 01:35:48 +00:00
|
|
|
struct InputEvent : public DeviceInput
|
2002-04-16 17:31:00 +00:00
|
|
|
{
|
|
|
|
|
InputEvent() { type=IET_FIRST_PRESS; };
|
2003-02-16 01:35:48 +00:00
|
|
|
InputEvent( InputDevice d, int b, InputEventType t ): DeviceInput(d, b) { type=t; };
|
|
|
|
|
InputEvent( DeviceInput di, InputEventType t ): DeviceInput(di) { type=t; };
|
2002-04-16 17:31:00 +00:00
|
|
|
|
|
|
|
|
InputEventType type;
|
|
|
|
|
};
|
|
|
|
|
|
2003-01-03 05:56:28 +00:00
|
|
|
typedef vector<InputEvent> InputEventArray;
|
2002-04-16 17:31:00 +00:00
|
|
|
|
2003-07-26 21:58:48 +00:00
|
|
|
class RageMutex;
|
2002-04-16 17:31:00 +00:00
|
|
|
class InputFilter
|
|
|
|
|
{
|
2003-10-07 05:59:58 +00:00
|
|
|
bool m_BeingHeld[NUM_INPUT_DEVICES][MAX_DEVICE_BUTTONS];
|
|
|
|
|
bool m_BeingForced[NUM_INPUT_DEVICES][MAX_DEVICE_BUTTONS];
|
|
|
|
|
float m_fSecsHeld[NUM_INPUT_DEVICES][MAX_DEVICE_BUTTONS];
|
2003-02-16 01:35:48 +00:00
|
|
|
|
2003-09-03 21:49:11 +00:00
|
|
|
/* If > 0, then when it reaches 0, stop forcing. */
|
2003-10-07 05:59:58 +00:00
|
|
|
float m_fSecsToForce[NUM_INPUT_DEVICES][MAX_DEVICE_BUTTONS];
|
2003-02-16 01:35:48 +00:00
|
|
|
InputEventArray queue;
|
2003-07-26 21:58:48 +00:00
|
|
|
RageMutex *queuemutex;
|
2003-02-16 01:35:48 +00:00
|
|
|
|
2003-09-03 21:49:11 +00:00
|
|
|
void ForceKey( DeviceInput di, float duration );
|
|
|
|
|
void StopForcingKey( DeviceInput di );
|
|
|
|
|
|
2002-04-16 17:31:00 +00:00
|
|
|
public:
|
2003-02-16 01:35:48 +00:00
|
|
|
void ButtonPressed( DeviceInput di, bool Down );
|
2003-06-21 20:58:40 +00:00
|
|
|
void ResetDevice( InputDevice dev );
|
|
|
|
|
|
2002-09-08 06:10:23 +00:00
|
|
|
InputFilter();
|
2003-07-26 21:58:48 +00:00
|
|
|
~InputFilter();
|
2003-06-22 04:38:05 +00:00
|
|
|
void Reset();
|
2003-02-16 01:35:48 +00:00
|
|
|
void Update(float fDeltaTime);
|
2002-04-16 17:31:00 +00:00
|
|
|
|
2003-11-25 21:46:30 +00:00
|
|
|
void SetRepeatRate( float fSlowDelay, float fSlowRate, float fFastDelay, float fFastRate );
|
|
|
|
|
void ResetRepeatRate();
|
|
|
|
|
void ResetKeyRepeat( DeviceInput di );
|
|
|
|
|
|
2002-09-08 06:10:23 +00:00
|
|
|
bool IsBeingPressed( DeviceInput di );
|
2002-10-18 19:01:32 +00:00
|
|
|
float GetSecsHeld( DeviceInput di );
|
2002-09-08 06:10:23 +00:00
|
|
|
|
2003-02-16 01:35:48 +00:00
|
|
|
void GetInputEvents( InputEventArray &array );
|
2002-04-16 17:31:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2002-05-19 01:59:48 +00:00
|
|
|
extern InputFilter* INPUTFILTER; // global and accessable from anywhere in our program
|
2002-04-16 17:31:00 +00:00
|
|
|
|
2002-07-31 19:40:40 +00:00
|
|
|
|
2002-11-16 08:07:38 +00:00
|
|
|
|
|
|
|
|
#endif
|