EHS/include/ehs/io/hid/HID.h

105 lines
1.9 KiB
C
Raw Permalink Normal View History

2024-02-05 22:25:30 -08:00
#pragma once
#include "ehs/Array.h"
#include "ButtonState.h"
#define EHS_HID_UNKNOWN 0
namespace ehs
{
2024-07-24 01:36:20 -07:00
class EHS_LIB_IO HID
2024-02-05 22:25:30 -08:00
{
protected:
UInt_8 type;
UInt_64 hashName;
Str_8 name;
UInt_64 id;
Array<ButtonState> states;
Button lastState;
float heldTime;
float activateTime;
bool active;
2024-02-05 22:25:30 -08:00
public:
HID();
HID(UInt_8 type, Str_8 name, UInt_64 id);
2024-02-05 22:25:30 -08:00
HID(HID&& hid) noexcept;
HID(const HID& hid);
HID& operator=(HID&& hid) noexcept;
HID& operator=(const HID& hid);
bool operator==(const HID& other) const;
bool operator!=(const HID& other) const;
bool operator==(UInt_64 otherId) const;
2024-02-05 22:25:30 -08:00
bool operator!=(UInt_64 otherId) const;
2024-02-05 22:25:30 -08:00
virtual void Poll(float delta);
2024-02-05 22:25:30 -08:00
UInt_8 GetType() const;
Str_8 GetName() const;
UInt_64 GetId() const;
void ReleaseAll();
Vector<const ButtonState*> GetAllTouched() const;
const ButtonState* IsTouched(const Button& button) const;
const ButtonState* IsTouched() const;
Vector<const ButtonState*> GetAllDown() const;
const ButtonState* IsDown(const Button& button) const;
const ButtonState* IsDown() const;
Vector<const ButtonState*> GetAllJustReleased() const;
const ButtonState* IsJustReleased(const Button& button) const;
const ButtonState* IsJustReleased() const;
Vector<const ButtonState*> GetAllUp() const;
const ButtonState* IsUp(const Button& button) const;
const ButtonState* IsUp() const;
const ButtonState *IsPressed(const Button &button);
const ButtonState *GetPressed();
2024-02-05 22:25:30 -08:00
void ButtonDown(const Button& button);
void ButtonUp(const Button& button);
const ButtonState* GetState(const Button& button) const;
bool IsValid() const;
virtual HID* Clone() const;
private:
bool HasState(const Button& button) const;
bool AddState(const ButtonState& state);
ButtonState* GetState(const Button& button);
bool TickHoldTime(float delta);
void ResetTime();
void TickActivateTime(float delta);
2024-02-05 22:25:30 -08:00
};
}