| 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 | typedef struct { |
| 55 | |
| 56 | |
| 57 | } PlatformData; |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | extern CoreData CORE; |
| 63 | |
| 64 | static PlatformData platform = { 0 }; |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | int InitPlatform(void); |
| 70 | bool InitGraphicsDevice(void); |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | bool WindowShouldClose(void) |
| 83 | { |
| 84 | if (CORE.Window.ready) return CORE.Window.shouldClose; |
| 85 | else return true; |
| 86 | } |
| 87 | |
| 88 | |
| 89 | void ToggleFullscreen(void) |
| 90 | { |
| 91 | TRACELOG(LOG_WARNING, "ToggleFullscreen() not available on target platform"); |
| 92 | } |
| 93 | |
| 94 | |
| 95 | void ToggleBorderlessWindowed(void) |
| 96 | { |
| 97 | TRACELOG(LOG_WARNING, "ToggleBorderlessWindowed() not available on target platform"); |
| 98 | } |
| 99 | |
| 100 | |
| 101 | void MaximizeWindow(void) |
| 102 | { |
| 103 | TRACELOG(LOG_WARNING, "MaximizeWindow() not available on target platform"); |
| 104 | } |
| 105 | |
| 106 | |
| 107 | void MinimizeWindow(void) |
| 108 | { |
| 109 | TRACELOG(LOG_WARNING, "MinimizeWindow() not available on target platform"); |
| 110 | } |
| 111 | |
| 112 | |
| 113 | void RestoreWindow(void) |
| 114 | { |
| 115 | TRACELOG(LOG_WARNING, "RestoreWindow() not available on target platform"); |
| 116 | } |
| 117 | |
| 118 | |
| 119 | void SetWindowState(unsigned int flags) |
| 120 | { |
| 121 | TRACELOG(LOG_WARNING, "SetWindowState() not available on target platform"); |
| 122 | } |
| 123 | |
| 124 | |
| 125 | void ClearWindowState(unsigned int flags) |
| 126 | { |
| 127 | TRACELOG(LOG_WARNING, "ClearWindowState() not available on target platform"); |
| 128 | } |
| 129 | |
| 130 | |
| 131 | void SetWindowIcon(Image image) |
| 132 | { |
| 133 | TRACELOG(LOG_WARNING, "SetWindowIcon() not available on target platform"); |
| 134 | } |
| 135 | |
| 136 | |
| 137 | void SetWindowIcons(Image *images, int count) |
| 138 | { |
| 139 | TRACELOG(LOG_WARNING, "SetWindowIcons() not available on target platform"); |
| 140 | } |
| 141 | |
| 142 | |
| 143 | void SetWindowTitle(const char *title) |
| 144 | { |
| 145 | CORE.Window.title = title; |
| 146 | } |
| 147 | |
| 148 | |
| 149 | void SetWindowPosition(int x, int y) |
| 150 | { |
| 151 | TRACELOG(LOG_WARNING, "SetWindowPosition() not available on target platform"); |
| 152 | } |
| 153 | |
| 154 | |
| 155 | void SetWindowMonitor(int monitor) |
| 156 | { |
| 157 | TRACELOG(LOG_WARNING, "SetWindowMonitor() not available on target platform"); |
| 158 | } |
| 159 | |
| 160 | |
| 161 | void SetWindowMinSize(int width, int height) |
| 162 | { |
| 163 | CORE.Window.screenMin.width = width; |
| 164 | CORE.Window.screenMin.height = height; |
| 165 | } |
| 166 | |
| 167 | |
| 168 | void SetWindowMaxSize(int width, int height) |
| 169 | { |
| 170 | CORE.Window.screenMax.width = width; |
| 171 | CORE.Window.screenMax.height = height; |
| 172 | } |
| 173 | |
| 174 | |
| 175 | void SetWindowSize(int width, int height) |
| 176 | { |
| 177 | TRACELOG(LOG_WARNING, "SetWindowSize() not available on target platform"); |
| 178 | } |
| 179 | |
| 180 | |
| 181 | void SetWindowOpacity(float opacity) |
| 182 | { |
| 183 | TRACELOG(LOG_WARNING, "SetWindowOpacity() not available on target platform"); |
| 184 | } |
| 185 | |
| 186 | |
| 187 | void SetWindowFocused(void) |
| 188 | { |
| 189 | TRACELOG(LOG_WARNING, "SetWindowFocused() not available on target platform"); |
| 190 | } |
| 191 | |
| 192 | |
| 193 | void *GetWindowHandle(void) |
| 194 | { |
| 195 | TRACELOG(LOG_WARNING, "GetWindowHandle() not implemented on target platform"); |
| 196 | return NULL; |
| 197 | } |
| 198 | |
| 199 | |
| 200 | int GetMonitorCount(void) |
| 201 | { |
| 202 | TRACELOG(LOG_WARNING, "GetMonitorCount() not implemented on target platform"); |
| 203 | return 1; |
| 204 | } |
| 205 | |
| 206 | |
| 207 | int GetCurrentMonitor(void) |
| 208 | { |
| 209 | TRACELOG(LOG_WARNING, "GetCurrentMonitor() not implemented on target platform"); |
| 210 | return 0; |
| 211 | } |
| 212 | |
| 213 | |
| 214 | Vector2 GetMonitorPosition(int monitor) |
| 215 | { |
| 216 | TRACELOG(LOG_WARNING, "GetMonitorPosition() not implemented on target platform"); |
| 217 | return (Vector2){ 0, 0 }; |
| 218 | } |
| 219 | |
| 220 | |
| 221 | int GetMonitorWidth(int monitor) |
| 222 | { |
| 223 | TRACELOG(LOG_WARNING, "GetMonitorWidth() not implemented on target platform"); |
| 224 | return 0; |
| 225 | } |
| 226 | |
| 227 | |
| 228 | int GetMonitorHeight(int monitor) |
| 229 | { |
| 230 | TRACELOG(LOG_WARNING, "GetMonitorHeight() not implemented on target platform"); |
| 231 | return 0; |
| 232 | } |
| 233 | |
| 234 | |
| 235 | int GetMonitorPhysicalWidth(int monitor) |
| 236 | { |
| 237 | TRACELOG(LOG_WARNING, "GetMonitorPhysicalWidth() not implemented on target platform"); |
| 238 | return 0; |
| 239 | } |
| 240 | |
| 241 | |
| 242 | int GetMonitorPhysicalHeight(int monitor) |
| 243 | { |
| 244 | TRACELOG(LOG_WARNING, "GetMonitorPhysicalHeight() not implemented on target platform"); |
| 245 | return 0; |
| 246 | } |
| 247 | |
| 248 | |
| 249 | int GetMonitorRefreshRate(int monitor) |
| 250 | { |
| 251 | TRACELOG(LOG_WARNING, "GetMonitorRefreshRate() not implemented on target platform"); |
| 252 | return 0; |
| 253 | } |
| 254 | |
| 255 | |
| 256 | const char *GetMonitorName(int monitor) |
| 257 | { |
| 258 | TRACELOG(LOG_WARNING, "GetMonitorName() not implemented on target platform"); |
| 259 | return ""; |
| 260 | } |
| 261 | |
| 262 | |
| 263 | Vector2 GetWindowPosition(void) |
| 264 | { |
| 265 | TRACELOG(LOG_WARNING, "GetWindowPosition() not implemented on target platform"); |
| 266 | return (Vector2){ 0, 0 }; |
| 267 | } |
| 268 | |
| 269 | |
| 270 | Vector2 GetWindowScaleDPI(void) |
| 271 | { |
| 272 | TRACELOG(LOG_WARNING, "GetWindowScaleDPI() not implemented on target platform"); |
| 273 | return (Vector2){ 1.0f, 1.0f }; |
| 274 | } |
| 275 | |
| 276 | |
| 277 | void SetClipboardText(const char *text) |
| 278 | { |
| 279 | TRACELOG(LOG_WARNING, "SetClipboardText() not implemented on target platform"); |
| 280 | } |
| 281 | |
| 282 | |
| 283 | |
| 284 | const char *GetClipboardText(void) |
| 285 | { |
| 286 | TRACELOG(LOG_WARNING, "GetClipboardText() not implemented on target platform"); |
| 287 | return NULL; |
| 288 | } |
| 289 | |
| 290 | |
| 291 | Image GetClipboardImage(void) |
| 292 | { |
| 293 | Image image = { 0 }; |
| 294 | |
| 295 | TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform"); |
| 296 | |
| 297 | return image; |
| 298 | } |
| 299 | |
| 300 | |
| 301 | void ShowCursor(void) |
| 302 | { |
| 303 | CORE.Input.Mouse.cursorHidden = false; |
| 304 | } |
| 305 | |
| 306 | |
| 307 | void HideCursor(void) |
| 308 | { |
| 309 | CORE.Input.Mouse.cursorHidden = true; |
| 310 | } |
| 311 | |
| 312 | |
| 313 | void EnableCursor(void) |
| 314 | { |
| 315 | |
| 316 | SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2); |
| 317 | |
| 318 | CORE.Input.Mouse.cursorHidden = false; |
| 319 | } |
| 320 | |
| 321 | |
| 322 | void DisableCursor(void) |
| 323 | { |
| 324 | |
| 325 | SetMousePosition(CORE.Window.screen.width/2, CORE.Window.screen.height/2); |
| 326 | |
| 327 | CORE.Input.Mouse.cursorHidden = true; |
| 328 | } |
| 329 | |
| 330 | |
| 331 | void SwapScreenBuffer(void) |
| 332 | { |
| 333 | eglSwapBuffers(platform.device, platform.surface); |
| 334 | } |
| 335 | |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | double GetTime(void) |
| 342 | { |
| 343 | double time = 0.0; |
| 344 | struct timespec ts = { 0 }; |
| 345 | clock_gettime(CLOCK_MONOTONIC, &ts); |
| 346 | unsigned long long int nanoSeconds = (unsigned long long int)ts.tv_sec*1000000000LLU + (unsigned long long int)ts.tv_nsec; |
| 347 | time = (double)(nanoSeconds - CORE.Time.base)*1e-9; |
| 348 | |
| 349 | return time; |
| 350 | } |
| 351 | |
| 352 | |
| 353 | |
| 354 | |
| 355 | |
| 356 | |
| 357 | void OpenURL(const char *url) |
| 358 | { |
| 359 | |
| 360 | if (strchr(url, '\'') != NULL) TRACELOG(LOG_WARNING, "SYSTEM: Provided URL could be potentially malicious, avoid [\'] character"); |
| 361 | else |
| 362 | { |
| 363 | |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | |
| 368 | |
| 369 | |
| 370 | |
| 371 | |
| 372 | int SetGamepadMappings(const char *mappings) |
| 373 | { |
| 374 | TRACELOG(LOG_WARNING, "SetGamepadMappings() not implemented on target platform"); |
| 375 | return 0; |
| 376 | } |
| 377 | |
| 378 | |
| 379 | void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float duration) |
| 380 | { |
| 381 | TRACELOG(LOG_WARNING, "SetGamepadVibration() not implemented on target platform"); |
| 382 | } |
| 383 | |
| 384 | |
| 385 | void SetMousePosition(int x, int y) |
| 386 | { |
| 387 | CORE.Input.Mouse.currentPosition = (Vector2){ (float)x, (float)y }; |
| 388 | CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition; |
| 389 | } |
| 390 | |
| 391 | |
| 392 | void SetMouseCursor(int cursor) |
| 393 | { |
| 394 | TRACELOG(LOG_WARNING, "SetMouseCursor() not implemented on target platform"); |
| 395 | } |
| 396 | |
| 397 | |
| 398 | const char *GetKeyName(int key) |
| 399 | { |
| 400 | TRACELOG(LOG_WARNING, "GetKeyName() not implemented on target platform"); |
| 401 | return ""; |
| 402 | } |
| 403 | |
| 404 | |
| 405 | void PollInputEvents(void) |
| 406 | { |
| 407 | #if SUPPORT_GESTURES_SYSTEM |
| 408 | |
| 409 | |
| 410 | UpdateGestures(); |
| 411 | #endif |
| 412 | |
| 413 | |
| 414 | CORE.Input.Keyboard.keyPressedQueueCount = 0; |
| 415 | CORE.Input.Keyboard.charPressedQueueCount = 0; |
| 416 | |
| 417 | |
| 418 | for (int i = 0; i < MAX_KEYBOARD_KEYS; i++) CORE.Input.Keyboard.keyRepeatInFrame[i] = 0; |
| 419 | |
| 420 | |
| 421 | CORE.Input.Gamepad.lastButtonPressed = 0; |
| 422 | |
| 423 | |
| 424 | |
| 425 | for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.previousTouchState[i] = CORE.Input.Touch.currentTouchState[i]; |
| 426 | |
| 427 | |
| 428 | |
| 429 | |
| 430 | |
| 431 | |
| 432 | |
| 433 | |
| 434 | for (int i = 0; i < 260; i++) |
| 435 | { |
| 436 | CORE.Input.Keyboard.previousKeyState[i] = CORE.Input.Keyboard.currentKeyState[i]; |
| 437 | CORE.Input.Keyboard.keyRepeatInFrame[i] = 0; |
| 438 | } |
| 439 | |
| 440 | |
| 441 | } |
| 442 | |
| 443 | |
| 444 | |
| 445 | |
| 446 | |
| 447 | |
| 448 | int InitPlatform(void) |
| 449 | { |
| 450 | |
| 451 | |
| 452 | |
| 453 | |
| 454 | |
| 455 | |
| 456 | FLAG_SET(CORE.Window.flags, FLAG_FULLSCREEN_MODE); |
| 457 | |
| 458 | if (FLAG_IS_SET(CORE.Window.flags, FLAG_MSAA_4X_HINT)) |
| 459 | { |
| 460 | |
| 461 | |
| 462 | TRACELOG(LOG_INFO, "DISPLAY: Trying to enable MSAA x4"); |
| 463 | } |
| 464 | |
| 465 | |
| 466 | |
| 467 | |
| 468 | bool result = true; |
| 469 | if (result) |
| 470 | { |
| 471 | CORE.Window.ready = true; |
| 472 | |
| 473 | CORE.Window.render.width = CORE.Window.screen.width; |
| 474 | CORE.Window.render.height = CORE.Window.screen.height; |
| 475 | CORE.Window.currentFbo.width = CORE.Window.render.width; |
| 476 | CORE.Window.currentFbo.height = CORE.Window.render.height; |
| 477 | } |
| 478 | else |
| 479 | { |
| 480 | TRACELOG(LOG_FATAL, "PLATFORM: Failed to initialize graphics device"); |
| 481 | return -1; |
| 482 | } |
| 483 | |
| 484 | |
| 485 | |
| 486 | CORE.Window.render.width = CORE.Window.screen.width; |
| 487 | CORE.Window.render.height = CORE.Window.screen.height; |
| 488 | CORE.Window.currentFbo.width = CORE.Window.render.width; |
| 489 | CORE.Window.currentFbo.height = CORE.Window.render.height; |
| 490 | |
| 491 | TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully %s", |
| 492 | FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI)? "(HighDPI)" : ""); |
| 493 | TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height); |
| 494 | TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height); |
| 495 | TRACELOG(LOG_INFO, " > Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height); |
| 496 | TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y); |
| 497 | |
| 498 | |
| 499 | |
| 500 | |
| 501 | rlLoadExtensions(eglGetProcAddress); |
| 502 | |
| 503 | |
| 504 | |
| 505 | |
| 506 | |
| 507 | |
| 508 | |
| 509 | |
| 510 | |
| 511 | |
| 512 | |
| 513 | |
| 514 | InitTimer(); |
| 515 | |
| 516 | |
| 517 | |
| 518 | |
| 519 | CORE.Storage.basePath = GetWorkingDirectory(); |
| 520 | |
| 521 | |
| 522 | TRACELOG(LOG_INFO, "PLATFORM: CUSTOM: Initialized successfully"); |
| 523 | |
| 524 | return 0; |
| 525 | } |
| 526 | |
| 527 | |
| 528 | void ClosePlatform(void) |
| 529 | { |
| 530 | |
| 531 | } |
| 532 | |
| 533 | |