Brunot
Loading...
Searching...
No Matches
ControllerStick.h
Go to the documentation of this file.
1
12// ____ __ __ __
13// /\__ _\/\ \ /\ \/\ \
14// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
15// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
16// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
17// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
18// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
19
20
21
22#pragma once
23#include <string>
24
30{
31public:
33
34 auto update(float dt, float stickState) -> void;
35
36 auto reset() -> void;
37
38 auto isPressed() const -> bool;
39
40 auto setEvents(std::pair<std::string,std::string> events) -> void;
41
47 auto getEvent() const -> std::string;
48
49private:
50
52 bool currentlyPressed = false;
53
54 float lastFrameState = 0.f;
56
57 bool isFast = false;
58
59 // If the stick is pushed further than this amount, then we consider it pressed
60 float pressThreshold = 0.7f;
61
62 // Because sticks can have an output from -1 to 1, we need to have outputs depending on where in the range it is
63
65 std::string minEvent;
67 std::string maxEvent;
68
69
70 static constexpr auto initialDelay = 0.3f;
71 static constexpr auto fastDelay = 0.2f;
72
73};
std::string minEvent
event for if the stick is pushed to the negative threshold
Definition ControllerStick.h:65
auto setEvents(std::pair< std::string, std::string > events) -> void
Definition ControllerStick.cpp:69
static constexpr auto initialDelay
Definition ControllerStick.h:70
float pressThreshold
Definition ControllerStick.h:60
static constexpr auto fastDelay
Definition ControllerStick.h:71
std::string maxEvent
event for if the stick is pushed to the positive threshold
Definition ControllerStick.h:67
bool currentlyPressed
Bool representing whether the stick should be considered pressed or not.
Definition ControllerStick.h:52
auto reset() -> void
Definition ControllerStick.cpp:56
auto getEvent() const -> std::string
Gets the output event corresponding to this stick.
Definition ControllerStick.cpp:75
bool isFast
Definition ControllerStick.h:57
float currentDelay
Definition ControllerStick.h:55
auto update(float dt, float stickState) -> void
Definition ControllerStick.cpp:27
auto isPressed() const -> bool
Definition ControllerStick.cpp:64
ControllerStick()
Definition ControllerStick.cpp:22
float lastFrameState
Definition ControllerStick.h:54