Files
itgmania212121/stepmania/src/InputFilter.h
T

71 lines
1.9 KiB
C++
Raw Normal View History

#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 };
struct InputEvent : public DeviceInput
2002-04-16 17:31:00 +00:00
{
InputEvent() { type=IET_FIRST_PRESS; };
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-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];
InputEventArray queue;
2003-07-26 21:58:48 +00:00
RageMutex *queuemutex;
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:
void ButtonPressed( DeviceInput di, bool Down );
2003-06-21 20:58:40 +00:00
void ResetDevice( InputDevice dev );
InputFilter();
2003-07-26 21:58:48 +00:00
~InputFilter();
2003-06-22 04:38:05 +00:00
void Reset();
void Update(float fDeltaTime);
2002-04-16 17:31:00 +00:00
void SetRepeatRate( float fSlowDelay, float fSlowRate, float fFastDelay, float fFastRate );
void ResetRepeatRate();
void ResetKeyRepeat( DeviceInput di );
bool IsBeingPressed( DeviceInput di );
2002-10-18 19:01:32 +00:00
float GetSecsHeld( DeviceInput di );
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
#endif