Browse Source

Remove unused virtual methods

Thomas Buck 8 years ago
parent
commit
c3c81bce34
4 changed files with 6 additions and 109 deletions
  1. 5
    16
      events.h
  2. 1
    35
      events_buttons.cpp
  3. 0
    24
      events_cppm.cpp
  4. 0
    34
      events_deadzone.cpp

+ 5
- 16
events.h View File

21
 class JoystickEvents {
21
 class JoystickEvents {
22
   public:
22
   public:
23
     JoystickEvents(JoystickEvents* _client = 0) : client(_client) { }
23
     JoystickEvents(JoystickEvents* _client = 0) : client(_client) { }
24
-    virtual void OnGamePadChanged(const GamePadEventData& evt) = 0;
25
-    virtual void OnHatSwitch(uint8_t hat) = 0;
26
-    virtual void OnButtonUp(uint8_t but_id) = 0;
27
-    virtual void OnButtonDown(uint8_t but_id) = 0;
28
-    virtual void OnMouseMoved(uint8_t x, uint8_t y) = 0;
24
+    virtual void OnGamePadChanged(const GamePadEventData& evt) { if (client) client->OnGamePadChanged(evt); }
25
+    virtual void OnHatSwitch(uint8_t hat) { if(client) client->OnHatSwitch(hat); }
26
+    virtual void OnButtonUp(uint8_t but_id) { if(client) client->OnButtonUp(but_id); }
27
+    virtual void OnButtonDown(uint8_t but_id) { if(client) client->OnButtonDown(but_id); }
28
+    virtual void OnMouseMoved(uint8_t x, uint8_t y) { if (client) client->OnMouseMoved(x, y); }
29
 
29
 
30
   protected:
30
   protected:
31
     JoystickEvents* client;
31
     JoystickEvents* client;
35
   public:
35
   public:
36
     JoystickEventsDeadZone(JoystickEvents* client = 0) : JoystickEvents(client) { }
36
     JoystickEventsDeadZone(JoystickEvents* client = 0) : JoystickEvents(client) { }
37
     virtual void OnGamePadChanged(const GamePadEventData& evt);
37
     virtual void OnGamePadChanged(const GamePadEventData& evt);
38
-    virtual void OnHatSwitch(uint8_t hat);
39
-    virtual void OnButtonUp(uint8_t but_id);
40
-    virtual void OnButtonDown(uint8_t but_id);
41
     virtual void OnMouseMoved(uint8_t x, uint8_t y);
38
     virtual void OnMouseMoved(uint8_t x, uint8_t y);
42
 
39
 
43
   private:
40
   private:
52
   public:
49
   public:
53
     JoystickEventsCPPM(JoystickEvents* client = 0);
50
     JoystickEventsCPPM(JoystickEvents* client = 0);
54
     virtual void OnGamePadChanged(const GamePadEventData& evt);
51
     virtual void OnGamePadChanged(const GamePadEventData& evt);
55
-    virtual void OnHatSwitch(uint8_t hat);
56
-    virtual void OnButtonUp(uint8_t but_id);
57
-    virtual void OnButtonDown(uint8_t but_id);
58
-    virtual void OnMouseMoved(uint8_t x, uint8_t y);
59
 
52
 
60
   private:
53
   private:
61
     const static uint8_t channels = 12;
54
     const static uint8_t channels = 12;
65
 class JoystickEventsButtons : public JoystickEvents {
58
 class JoystickEventsButtons : public JoystickEvents {
66
   public:
59
   public:
67
     JoystickEventsButtons(X52* x = 0, JoystickEvents* client = 0);
60
     JoystickEventsButtons(X52* x = 0, JoystickEvents* client = 0);
68
-    virtual void OnGamePadChanged(const GamePadEventData& evt);
69
-    virtual void OnHatSwitch(uint8_t hat);
70
-    virtual void OnButtonUp(uint8_t but_id);
71
     virtual void OnButtonDown(uint8_t but_id);
61
     virtual void OnButtonDown(uint8_t but_id);
72
-    virtual void OnMouseMoved(uint8_t x, uint8_t y);
73
 
62
 
74
   private:
63
   private:
75
     enum MenuState {
64
     enum MenuState {

+ 1
- 35
events_buttons.cpp View File

16
 #include "cppm.h"
16
 #include "cppm.h"
17
 #include "events.h"
17
 #include "events.h"
18
 
18
 
19
-#define DEBUG_OUTPUT
19
+//#define DEBUG_OUTPUT
20
 //#define DEBUG_BUTTON_MFD
20
 //#define DEBUG_BUTTON_MFD
21
 
21
 
22
 #define MENU_BUTTON_ENTER_1 29
22
 #define MENU_BUTTON_ENTER_1 29
31
 JoystickEventsButtons::JoystickEventsButtons(X52* x, JoystickEvents* client)
31
 JoystickEventsButtons::JoystickEventsButtons(X52* x, JoystickEvents* client)
32
         : JoystickEvents(client), x52(x), state(NONE), index(0), value(0) { }
32
         : JoystickEvents(client), x52(x), state(NONE), index(0), value(0) { }
33
 
33
 
34
-void JoystickEventsButtons::OnGamePadChanged(const GamePadEventData& evt) {
35
-    if (client) {
36
-        client->OnGamePadChanged(evt);
37
-    }
38
-}
39
-
40
-void JoystickEventsButtons::OnHatSwitch(uint8_t hat) {
41
-#ifdef DEBUG_BUTTON_MFD
42
-    String text = "Hat is " + String(hat);
43
-    x52->setMFDText(1, text.c_str());
44
-#endif
45
-
46
-    if (client) {
47
-        client->OnHatSwitch(hat);
48
-    }
49
-}
50
-
51
-void JoystickEventsButtons::OnButtonUp(uint8_t but_id) {
52
-#ifdef DEBUG_BUTTON_MFD
53
-    String text = "Button " + String(but_id) + " up";
54
-    x52->setMFDText(1, text.c_str());
55
-#endif
56
-
57
-    if (client) {
58
-        client->OnButtonUp(but_id);
59
-    }
60
-}
61
-
62
 void JoystickEventsButtons::menuHelper(uint8_t count, const char** menu, const char* title) {
34
 void JoystickEventsButtons::menuHelper(uint8_t count, const char** menu, const char* title) {
63
     if (index >= count) {
35
     if (index >= count) {
64
         index = count - 1;
36
         index = count - 1;
214
     }
186
     }
215
 }
187
 }
216
 
188
 
217
-void JoystickEventsButtons::OnMouseMoved(uint8_t x, uint8_t y) {
218
-    if (client) {
219
-        client->OnMouseMoved(x, y);
220
-    }
221
-}
222
-

+ 0
- 24
events_cppm.cpp View File

48
     }
48
     }
49
 }
49
 }
50
 
50
 
51
-void JoystickEventsCPPM::OnHatSwitch(uint8_t hat) {
52
-    if (client) {
53
-        client->OnHatSwitch(hat);
54
-    }
55
-}
56
-
57
-void JoystickEventsCPPM::OnButtonUp(uint8_t but_id) {
58
-    if (client) {
59
-        client->OnButtonUp(but_id);
60
-    }
61
-}
62
-
63
-void JoystickEventsCPPM::OnButtonDown(uint8_t but_id) {
64
-    if (client) {
65
-        client->OnButtonDown(but_id);
66
-    }
67
-}
68
-
69
-void JoystickEventsCPPM::OnMouseMoved(uint8_t x, uint8_t y) {
70
-    if (client) {
71
-        client->OnMouseMoved(x, y);
72
-    }
73
-}
74
-

+ 0
- 34
events_deadzone.cpp View File

145
     }
145
     }
146
 }
146
 }
147
 
147
 
148
-void JoystickEventsDeadZone::OnHatSwitch(uint8_t hat) {
149
-#ifdef DEBUG_OUTPUT
150
-    Serial.print("Hat Switch: ");
151
-    PrintHex<uint8_t > (hat, 0x80);
152
-    Serial.println("");
153
-#endif
154
-
155
-    if (client) {
156
-        client->OnHatSwitch(hat);
157
-    }
158
-}
159
-
160
-void JoystickEventsDeadZone::OnButtonUp(uint8_t but_id) {
161
-#ifdef DEBUG_OUTPUT
162
-    Serial.print("Up: ");
163
-    Serial.println(but_id, DEC);
164
-#endif
165
-
166
-    if (client) {
167
-        client->OnButtonUp(but_id);
168
-    }
169
-}
170
-
171
-void JoystickEventsDeadZone::OnButtonDown(uint8_t but_id) {
172
-#ifdef DEBUG_OUTPUT
173
-    Serial.print("Down: ");
174
-    Serial.println(but_id, DEC);
175
-#endif
176
-
177
-    if (client) {
178
-        client->OnButtonDown(but_id);
179
-    }
180
-}
181
-
182
 void JoystickEventsDeadZone::OnMouseMoved(uint8_t x, uint8_t y) {
148
 void JoystickEventsDeadZone::OnMouseMoved(uint8_t x, uint8_t y) {
183
 #ifdef DEBUG_OUTPUT_RAW
149
 #ifdef DEBUG_OUTPUT_RAW
184
     Serial.print("Mouse X: ");
150
     Serial.print("Mouse X: ");

Loading…
Cancel
Save