File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed
Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ void EZButton::Loop()
107107 delete[] buttonStates;
108108}
109109
110- void EZButton::Subscribe (int index, void (* event)() , EventTypes type)
110+ void EZButton::Subscribe (int index, Event event, EventTypes type)
111111{
112112 _events[EventIndex (index, type)] = event;
113113
@@ -121,7 +121,7 @@ void EZButton::CallEvent(int index, EventTypes type)
121121 LogEvent (" Call:" ,index, type);
122122
123123 if (_events[i] != nullptr )
124- _events[i]();
124+ _events[i](index );
125125}
126126
127127int EZButton::EventIndex (int index, EventTypes type)
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ enum EventTypes
1212 RELEASED
1313};
1414
15+ typedef void (*Event)(int ); // Type alias for function pointer
16+
1517class EZButton
1618{
1719public:
@@ -29,7 +31,7 @@ class EZButton
2931
3032 void Blackout (unsigned long milis);
3133 void Loop ();
32- void Subscribe (int index, void (* event)() , EventTypes type);
34+ void Subscribe (int index, Event event, EventTypes type);
3335
3436private:
3537 int _numButtons;
@@ -39,7 +41,6 @@ class EZButton
3941 bool *_buttonLastState;
4042 unsigned long _blackoutTime = 0 ;
4143
42- typedef void (*Event)(); // Type alias for function pointer
4344 Event *_events;
4445 void (*_readButtons)(bool *, int );
4546
You can’t perform that action at this time.
0 commit comments