@@ -15,41 +15,107 @@ namespace geode {
1515 }
1616
1717 /* *
18- * Input timestamp (in nanoseconds) sent by the launcher just before the next input event is received
18+ * An input representing some kind of key input (whether it is controller or )
1919 */
20- class GEODE_DLL AndroidInputTimestampEvent final : public Event {
20+ class GEODE_DLL AndroidKeyInput final {
2121 protected:
22- long m_timestamp;
22+ int m_keycode;
23+ int m_modifiers;
24+ int m_repeatCount;
25+ bool m_isDown;
2326
2427 public:
25- AndroidInputTimestampEvent (long timestamp);
26- long getTimestamp () const ;
28+ AndroidKeyInput (int keycode, int modifiers, bool isDown, int repeatCount);
29+
30+ int keycode () const ;
31+ bool isDown () const ;
32+ int repeatCount () const ;
33+ int modifiers () const ;
34+ };
35+
36+ class GEODE_DLL AndroidScrollInput final {
37+ protected:
38+ float m_scrollX;
39+ float m_scrollY;
40+
41+ public:
42+ AndroidScrollInput (float scrollX, float scrollY);
43+
44+ float scrollX () const ;
45+ float scrollY () const ;
46+ };
47+
48+ // this type is intended to be used for variant discrimination, for now. i'm lazy
49+ class GEODE_DLL AndroidTouchInput final {
50+ public:
51+ struct Data {
52+ int m_id;
53+ float m_x;
54+ float m_y;
55+ };
56+
57+ enum class Type {
58+ Began = 0 , Moved = 1 , Ended = 2 , Cancelled = 3
59+ };
60+
61+ AndroidTouchInput (std::vector<Data> touches, Type type);
62+
63+ std::vector<Data> touches () const ;
64+ Type type () const ;
65+
66+ private:
67+ std::vector<Data> m_touches;
68+ Type m_type;
2769 };
2870
29- class GEODE_DLL AndroidInputTimestampFilter final : public EventFilter<AndroidInputTimestampEvent> {
71+ class GEODE_DLL AndroidJoystickInput final {
3072 public:
31- using Callback = void (AndroidInputTimestampEvent*);
73+ struct Data final {
74+ float leftX;
75+ float leftY;
76+
77+ float rightX;
78+ float rightY;
79+
80+ float hatX;
81+ float hatY;
82+
83+ float leftTrigger;
84+ float rightTrigger;
85+ };
3286
33- ListenerResult handle (std::function<Callback> fn, AndroidInputTimestampEvent* event);
87+ AndroidJoystickInput (std::vector<Data> packets);
88+
89+ std::vector<Data> packets () const ;
90+
91+ private:
92+ std::vector<Data> m_packets;
3493 };
3594
36- class GEODE_DLL AndroidInputDeviceInfoEvent final : public Event {
95+ using AndroidRichInput = std::variant<AndroidJoystickInput, AndroidTouchInput, AndroidKeyInput, AndroidScrollInput>;
96+
97+ class GEODE_DLL AndroidRichInputEvent final : public Event {
3798 protected:
99+ std::int64_t m_timestamp;
38100 int m_deviceId;
39101 int m_eventSource;
40102
103+ AndroidRichInput m_data;
104+
41105 public:
42- AndroidInputDeviceInfoEvent ( int deviceId, int eventSource);
106+ AndroidRichInputEvent (std:: int64_t timestamp, int deviceId, int eventSource, AndroidRichInput data );
43107
108+ std::int64_t timestamp () const ;
44109 int deviceId () const ;
45110 int eventSource () const ;
111+ AndroidRichInput data () const ;
46112 };
47113
48- class GEODE_DLL AndroidInputDeviceInfoFilter final : public EventFilter<AndroidInputDeviceInfoEvent > {
114+ class GEODE_DLL AndroidRichInputFilter final : public EventFilter<AndroidRichInputEvent > {
49115 public:
50- using Callback = void (AndroidInputDeviceInfoEvent *);
116+ using Callback = void (AndroidRichInputEvent *);
51117
52- ListenerResult handle (std::function<Callback> fn, AndroidInputDeviceInfoEvent * event);
118+ ListenerResult handle (std::function<Callback> fn, AndroidRichInputEvent * event);
53119 };
54120
55121 class GEODE_DLL AndroidInputDeviceEvent final : public Event {
@@ -75,43 +141,6 @@ namespace geode {
75141
76142 ListenerResult handle (std::function<Callback> fn, AndroidInputDeviceEvent* event);
77143 };
78-
79- class GEODE_DLL AndroidInputJoystickEvent final : public Event {
80- protected:
81- std::vector<float > m_leftX;
82- std::vector<float > m_leftY;
83-
84- std::vector<float > m_rightX;
85- std::vector<float > m_rightY;
86-
87- std::vector<float > m_hatX;
88- std::vector<float > m_hatY;
89-
90- std::vector<float > m_leftTrigger;
91- std::vector<float > m_rightTrigger;
92-
93- public:
94- AndroidInputJoystickEvent (std::vector<float >, std::vector<float >, std::vector<float >, std::vector<float >, std::vector<float >, std::vector<float >, std::vector<float >, std::vector<float >);
95-
96- std::vector<float > leftX () const ;
97- std::vector<float > leftY () const ;
98-
99- std::vector<float > rightX () const ;
100- std::vector<float > rightY () const ;
101-
102- std::vector<float > hatX () const ;
103- std::vector<float > hatY () const ;
104-
105- std::vector<float > leftTrigger () const ;
106- std::vector<float > rightTrigger () const ;
107- };
108-
109- class GEODE_DLL AndroidInputJoystickFilter final : public EventFilter<AndroidInputJoystickEvent> {
110- public:
111- using Callback = void (AndroidInputJoystickEvent*);
112-
113- ListenerResult handle (std::function<Callback> fn, AndroidInputJoystickEvent* event);
114- };
115144}
116145
117146#endif
0 commit comments