Files
itgmania212121/stepmania/src/InputFilter.h
T

68 lines
1.7 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
2002-09-10 06:27:57 +00:00
const float TIME_BEFORE_SLOW_REPEATS = 0.25f;
2002-07-27 19:29:51 +00:00
const float TIME_BEFORE_FAST_REPEATS = 1.5f;
2002-04-16 17:31:00 +00:00
2002-05-01 19:14:55 +00:00
//const float TIME_BETWEEN_SLOW_REPEATS = 0.25f;
const float TIME_BETWEEN_SLOW_REPEATS = 0.125f;
2002-04-16 17:31:00 +00:00
const float TIME_BETWEEN_FAST_REPEATS = 0.125f;
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
{
bool m_BeingHeld[NUM_INPUT_DEVICES][NUM_DEVICE_BUTTONS];
float m_fSecsHeld[NUM_INPUT_DEVICES][NUM_DEVICE_BUTTONS];
InputEventArray queue;
2003-07-26 21:58:48 +00:00
RageMutex *queuemutex;
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
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