InputEvents v1.4.0
An easy to use but comprehensive Event Library for Buttons, Encoders, Encoder Buttons, Analog Inputs, Joysticks and Switches.
InputEvents.h
Go to the documentation of this file.
1
11#ifndef INPUT_EVENTS_H
12#define INPUT_EVENTS_H
13
14#include <Arduino.h>
15
16#ifndef FUNCTIONAL_SUPPORTED
17 #if defined(__has_include) // Check if __has_include is supported
18 #if __has_include(<functional>)
19 #define FUNCTIONAL_SUPPORTED
20 #endif
21 #endif
22#endif
23
24#if defined(__has_include) // Check if __has_include is supported
25 #if !__has_include(<EncoderAdapter.h>)
26 #ifndef EXCLUDE_EVENT_ENCODER //might be defined by build_flags
27 #define EXCLUDE_EVENT_ENCODER
28 #endif
29 #endif
30#endif
31
32
34/*
35 * Some platforms stupidly use #define for DISABLED (ahem, espressif), so replace it with a constexpr variable
36 * Many thanks to @kfoltman https://github.com/kfoltman for the workaround.
37 */
38#ifdef DISABLED
39constexpr auto ACTUAL_DISABLED_VALUE=DISABLED;
40#undef DISABLED
41constexpr auto DISABLED=ACTUAL_DISABLED_VALUE;
42#endif
44
45
50constexpr size_t NUM_EVENT_TYPE_ENUMS = 19;
51
55enum class InputEventType : uint8_t {
56 NONE,
57 ENABLED,
58 DISABLED,
59 IDLE,
60 PRESSED,
61 RELEASED,
62 CLICKED,
67 CHANGED,
70 CHANGED_X,
71 CHANGED_Y,
72 ON,
73 OFF,
74 DRAGGED,
76};
77
78#endif
constexpr size_t NUM_EVENT_TYPE_ENUMS
The size of the InputEventType enum.
Definition: InputEvents.h:50
InputEventType
A list of all events that can be fired by InputEvents classes.
Definition: InputEvents.h:55
@ DISABLED
2 Fired by all imputs
@ DRAGGED_RELEASED
19 Fired by EventTouchScreen (experimental)
@ RELEASED
5 Fired by EventButton, EventEncoderButton and EventTouchScreen
@ CLICKED
6 Fired by EventButton, EventEncoderButton and EventTouchScreen
@ DRAGGED
18 Fired by [EventTouchScreen]() (experimental)
@ PRESSED
4 Fired by EventButton, EventEncoderButton and EventTouchScreen
@ LONG_PRESS
10 Fired by EventButton, EventEncoderButton and EventTouchScreen
@ CHANGED_Y
15 Fired Bby EventJoystick
@ DOUBLE_CLICKED
7 Fired by EventButton, EventEncoderButton and EventTouchScreen
@ LONG_CLICKED
9 Fired by EventButton, EventEncoderButton and EventTouchScreen
@ OFF
17 Fired by EventSwitch
@ ON
16 Fired by EventSwitch
@ IDLE
3 Fired by all imputs
@ CHANGED_X
14 Fired Bby EventJoystick
@ NONE
0 Used for initialising/testing
@ MULTI_CLICKED
8 Fired by EventButton, EventEncoderButton and EventTouchScreen
@ CHANGED_RELEASED
13 Fired by EventEncoderButton
@ ENABLED
1 Fired by all imputs
@ CHANGED_PRESSED
12 Fired by EventEncoderButton
@ CHANGED
11 Fired by EventEncoder and EventAnalog