forked from Bigfoot71/raymob
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraymob.h
More file actions
343 lines (287 loc) · 8.81 KB
/
Copy pathraymob.h
File metadata and controls
343 lines (287 loc) · 8.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
/*
* raymob License (MIT)
*
* Copyright (c) 2023-2024 Le Juez Victor
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef RAYMOB_H
#define RAYMOB_H
#include "android_native_app_glue.h"
#include "raylib.h"
#include "jni.h"
/* ENUMS */
typedef enum {
SENSOR_ACCELEROMETER = 0,
SENSOR_GYROSCOPE = 1,
} Sensor;
typedef enum {
ORIENTATION_PORTRAIT = 0,
ORIENTATION_LANDSCAPE = 1,
ORIENTATION_PORTRAIT_REVERSED = 2,
ORIENTATION_LANDSCAPE_REVERSED = 3,
ORIENTATION_OTHER = -1,
} Orientation;
/* Callback define */
typedef void (*Callback)();
#if defined(__cplusplus)
extern "C" {
#endif
/**
* @brief Retrieves the Android application object.
*
* This function is defined in 'raylib/platforms/rcore_android.c'.
* The function is not public by default, so we are making its declaration
* public here now (instead of doing it in 'raylib.h'), in order to keep a
* clean version of raylib.
*
* @return Pointer to the Android application object.
*/
struct android_app *GetAndroidApp(void);
/* Helper functions */
/**
* @brief Attaches the current native thread to the Java VM environment.
*
* @return Pointer to the JNIEnv structure.
*/
JNIEnv* AttachCurrentThread(void);
/**
* @brief Detaches the current native thread from the Java VM environment.
*/
void DetachCurrentThread(void);
/**
* @brief Returns a pointer to the class that initiated the native activity.
*
* @return Pointer to the native loader instance.
*/
jobject GetNativeLoaderInstance(void);
/**
* @brief Gets the cache directory path of the Android application.
*
* @warning This function returns a string allocated on the heap.
* The responsibility for releasing the memory lies with the user.
*
* @return Pointer to the cache directory path string.
*/
char* GetCacheDir(void);
/**
* @brief Read file from cache directory, the readFile from raylib is reserved to read in Assets folder.
*
* @param fileName to read
* @return file content
*/
char* LoadCacheFile(const char* fileName);
/**
* @brief Get localized string resource by name L10N.
*
* @see L10N: https://en.wikipedia.org/wiki/Internationalization_and_localization
*
* @warning This function returns a string allocated on the heap.
* The responsibility for releasing the memory lies with the user.
*
* @param value string resource name
* @return localized string
*/
char* GetL10NString(const char* value);
/* Vibrator functions */
/**
* @brief Initiates device vibration for the specified duration in seconds.
*
* @param seconds Duration of vibration in seconds.
*/
void Vibrate(float seconds);
/**
* @brief Initiates device vibration for the specified duration in milliseconds.
*
* @param ms Duration of vibration in milliseconds.
*/
void VibrateMS(uint64_t ms);
/**
* @brief Initiates device vibration for the specified duration and intensity in seconds.
*
* @param seconds Duration of vibration in seconds.
* @param intensity Intensity of the vibration (0.0 to 1.0).
*/
void VibrateEx(float seconds, float intensity);
/**
* @brief Initiates device vibration for the specified duration and intensity in milliseconds.
*
* @param ms Duration of vibration in milliseconds.
* @param intensity Intensity of the vibration (0.0 to 1.0).
*/
void VibrateExMS(uint64_t ms, float intensity);
/* Sensor functions */
/**
* @brief Initializes the sensor manager for accessing device sensors.
*/
void InitSensorManager(void);
/**
* @brief Enables the specified sensor.
*
* @param sensor The sensor to be enabled (e.g., Gyroscope, Accelerometer).
*/
void EnableSensor(Sensor sensor);
/**
* @brief Disables the specified sensor.
*
* @param sensor The sensor to be disabled (e.g., Gyroscope, Accelerometer).
*/
void DisableSensor(Sensor sensor);
/**
* Get screen orientation.
*/
Orientation GetScreenOrientation();
/**
* @brief Retrieves the current accelerometer axis values.
*
* @return A Vector3 representing the accelerometer axis (x, y, z).
*/
Vector3 GetAccelerotmerAxis(void);
/**
* @brief Retrieves the current gyroscope axis values.
*
* @return A Vector3 representing the gyroscope axis (x, y, z).
*/
Vector3 GetGyroscopeAxis(void);
/* Soft Keyboard functions */
/**
* @brief Displays the soft keyboard on the screen.
*/
void ShowSoftKeyboard(void);
/**
* @brief Hides the soft keyboard from the screen.
*/
void HideSoftKeyboard(void);
/**
* @brief Returns the code of the last key pressed on the soft keyboard.
*
* @return Code of the last key pressed on the soft keyboard.
*/
int GetLastSoftKeyCode(void);
/**
* @brief Returns the label of the last key pressed on the soft keyboard.
*
* @return Label of the last key pressed on the soft keyboard.
*/
unsigned short GetLastSoftKeyLabel(void);
/**
* @brief Returns the Unicode value of the last key pressed on the soft keyboard.
*
* @return Unicode value of the last key pressed on the soft keyboard.
*/
int GetLastSoftKeyUnicode(void);
/**
* @brief Returns the character value of the last key pressed on the soft keyboard.
*
* @return Character value of the last key pressed on the soft keyboard.
*/
char GetLastSoftKeyChar(void);
/**
* @brief Clears the record of the last soft key pressed.
*/
void ClearLastSoftKey(void);
/**
* @brief Allows editing the text displayed in the soft keyboard.
*
* @param text Pointer to the text to be edited.
* @param size Size of the text buffer.
*/
void SoftKeyboardEditText(char* text, unsigned int size);
/**
* @brief Controls whether the screen should remain on or not.
*
* @param keepOn If true, the screen should remain on; otherwise, it should not.
*/
void KeepScreenOn(bool keepOn);
/* Callback functions */
/**
* @brief Initializes all callback functions to their default states.
*/
void InitCallBacks(void);
/**
* @brief Sets the callback function to be called when the application starts.
*
* @param callback The callback function to be executed on start.
*/
void SetOnStartCallBack(Callback callback);
/**
* @brief Sets the callback function to be called when the application resumes.
*
* @param callback The callback function to be executed on resume.
*/
void SetOnResumeCallBack(Callback callback);
/**
* @brief Sets the callback function to be called when the application pauses.
*
* @param callback The callback function to be executed on pause.
*/
void SetOnPauseCallBack(Callback callback);
/**
* @brief Sets the callback function to be called when the application is stopped.
*
* @param callback The callback function to be executed on destroy.
*/
void SetOnStopCallBack(Callback callback);
/**
* @brief Get the app specific storage root path.
*
* @warning This function returns a string allocated on the heap.
* The responsibility for releasing the memory lies with the user.
* Use free().
*
* @return app specific storage path.
*/
char* GetAppStoragePath();
/**
* @brief Read file in app specific storage.
*
* @param filepath Path of the file relative to app specific storage.
* @param size Variable to store size of data read.
*
* @return the data read.
*/
void* ReadFromAppStorage(const char *filepath, int *size);
/**
* @brief Write file in app specific storage.
*
* @param filepath Path of the file relative to app specific storage.
* @param data Pointer to the data.
* @param size Size of the data.
*
* @return true on success.
*/
bool WriteToAppStorage(const char *filepath, void *data, unsigned int size);
/**
* @brief Check file exist or not in app specific storage.
*
* @param filepath Path of the file relative to app specific storage.
*
* @return true if file exists.
*/
bool IsFileExistsInAppStorage(const char *filepath);
/**
* @brief Remove a file in app specific storage.
*
* @param filepath Path of the file relative to app specific storage.
*/
void RemoveFileInAppStorage(const char *filepath);
#if defined(__cplusplus)
}
#endif
#endif //RAYMOB_H