66#ifdef GEODE_IS_ANDROID
77
88#include " ../loader/Event.hpp"
9+ #include < Geode/cocos/platform/android/jni/JniHelper.h>
910
1011namespace geode {
1112 namespace utils {
1213 /* * Gets the current version of the launcher. Returns an error if the method was not found. */
1314 geode::Result<int > getLauncherVersion ();
1415 }
1516
17+ geode::Result<int > getConnectedControllerCount ();
18+ geode::Result<std::vector<int >> getConnectedDevices ();
19+
1620 /* *
1721 * Input timestamp (in nanoseconds) sent by the launcher just before the next input event is received
1822 */
@@ -31,6 +35,133 @@ namespace geode {
3135
3236 ListenerResult handle (std::function<Callback> fn, AndroidInputTimestampEvent* event);
3337 };
38+
39+ class GEODE_DLL AndroidInputDevice final {
40+ private:
41+ int m_deviceId;
42+ jobject m_inputDevice{};
43+
44+ AndroidInputDevice (int deviceId, jobject inputDevice);
45+
46+ public:
47+ static Result<AndroidInputDevice> create (int deviceId);
48+
49+ AndroidInputDevice (const AndroidInputDevice&) = delete ;
50+ AndroidInputDevice& operator =(const AndroidInputDevice&) = delete ;
51+
52+ AndroidInputDevice (AndroidInputDevice&&);
53+ AndroidInputDevice& operator =(AndroidInputDevice&&);
54+
55+ ~AndroidInputDevice ();
56+
57+ std::string getDescriptor ();
58+
59+ std::string getName ();
60+ int getVendorId ();
61+ int getProductId ();
62+
63+ float getBatteryCapacity ();
64+ int getBatteryStatus ();
65+ bool hasBattery ();
66+
67+ int getSources ();
68+
69+ enum class LightType {
70+ None = 0 ,
71+ PlayerNumber = 1 ,
72+ Color = 2 ,
73+ All = 3
74+ };
75+
76+ int getLightCount ();
77+ LightType getLightType ();
78+ Result<> setLights (LightType type, std::uint32_t color);
79+
80+ int getMotorCount ();
81+ Result<> vibrateDevice (long durationMs, int intensity, int motorIdx = -1 );
82+
83+ int getDeviceId () const ;
84+ };
85+
86+ class GEODE_DLL AndroidInputDeviceInfoEvent final : public Event {
87+ protected:
88+ int m_deviceId;
89+ int m_eventSource;
90+
91+ public:
92+ AndroidInputDeviceInfoEvent (int deviceId, int eventSource);
93+
94+ int deviceId () const ;
95+ int eventSource () const ;
96+ };
97+
98+ class GEODE_DLL AndroidInputDeviceInfoFilter final : public EventFilter<AndroidInputDeviceInfoEvent> {
99+ public:
100+ using Callback = void (AndroidInputDeviceInfoEvent*);
101+
102+ ListenerResult handle (std::function<Callback> fn, AndroidInputDeviceInfoEvent* event);
103+ };
104+
105+ class GEODE_DLL AndroidInputDeviceEvent final : public Event {
106+ public:
107+ enum class Status {
108+ Added, Changed, Removed
109+ };
110+
111+ protected:
112+ int m_deviceId;
113+ Status m_status;
114+
115+ public:
116+ AndroidInputDeviceEvent (int deviceId, Status status);
117+
118+ int deviceId () const ;
119+ Status status () const ;
120+ };
121+
122+ class GEODE_DLL AndroidInputDeviceFilter final : public EventFilter<AndroidInputDeviceEvent> {
123+ public:
124+ using Callback = void (AndroidInputDeviceEvent*);
125+
126+ ListenerResult handle (std::function<Callback> fn, AndroidInputDeviceEvent* event);
127+ };
128+
129+ class GEODE_DLL AndroidInputJoystickEvent final : public Event {
130+ protected:
131+ std::vector<float > m_leftX;
132+ std::vector<float > m_leftY;
133+
134+ std::vector<float > m_rightX;
135+ std::vector<float > m_rightY;
136+
137+ std::vector<float > m_hatX;
138+ std::vector<float > m_hatY;
139+
140+ std::vector<float > m_leftTrigger;
141+ std::vector<float > m_rightTrigger;
142+
143+ public:
144+ 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 >);
145+
146+ std::vector<float > leftX () const ;
147+ std::vector<float > leftY () const ;
148+
149+ std::vector<float > rightX () const ;
150+ std::vector<float > rightY () const ;
151+
152+ std::vector<float > hatX () const ;
153+ std::vector<float > hatY () const ;
154+
155+ std::vector<float > leftTrigger () const ;
156+ std::vector<float > rightTrigger () const ;
157+ };
158+
159+ class GEODE_DLL AndroidInputJoystickFilter final : public EventFilter<AndroidInputJoystickEvent> {
160+ public:
161+ using Callback = void (AndroidInputJoystickEvent*);
162+
163+ ListenerResult handle (std::function<Callback> fn, AndroidInputJoystickEvent* event);
164+ };
34165}
35166
36167#endif
0 commit comments