1use crate::ext::window_handle::WindowHandle;
2use crate::utils::{array_from_c, string_from_c};
3use raylib_ffi::{enums::*, *};
4use std::char;
5use std::ffi::{c_char, c_uchar, c_void};
6use std::fmt::{Debug, Display};
7
8#[derive(Clone, Copy, Debug, Default)]
9pub(crate) struct RcoreImpl;
10
11impl RcoreImpl {
13 pub fn __init_window(width: i32, height: i32, title: impl Display) {
16 unsafe { InitWindow(width, height, rl_str!(title)) }
17 }
18
19 pub fn __close_window() {
20 unsafe { CloseWindow() }
21 }
22
23 pub fn __window_should_close() -> bool {
24 unsafe { WindowShouldClose() }
25 }
26
27 pub fn __is_window_ready() -> bool {
28 unsafe { IsWindowReady() }
29 }
30
31 pub fn __is_window_fullscreen() -> bool {
32 unsafe { IsWindowFullscreen() }
33 }
34
35 pub fn __is_window_hidden() -> bool {
36 unsafe { IsWindowHidden() }
37 }
38
39 pub fn __is_window_minimized() -> bool {
40 unsafe { IsWindowMinimized() }
41 }
42
43 pub fn __is_window_maximized() -> bool {
44 unsafe { IsWindowMaximized() }
45 }
46
47 pub fn __is_window_focused() -> bool {
48 unsafe { IsWindowFocused() }
49 }
50
51 pub fn __is_window_resized() -> bool {
52 unsafe { IsWindowResized() }
53 }
54
55 pub fn __is_window_state(flag: usize) -> bool {
56 unsafe { IsWindowState(flag as u32) }
57 }
58
59 pub fn __set_window_state(flag: usize) {
60 let flag: usize = flag;
61 unsafe { SetWindowState(flag as u32) }
62 }
63
64 pub fn __clear_window_state(flag: usize) {
65 let flag: usize = flag;
66 unsafe { ClearWindowState(flag as u32) }
67 }
68
69 pub fn __toggle_fullscreen() {
70 unsafe { ToggleFullscreen() }
71 }
72
73 pub fn __toggle_borderless_windowed() {
74 unsafe { ToggleBorderlessWindowed() }
75 }
76
77 pub fn __maximize_window() {
78 unsafe { MaximizeWindow() }
79 }
80
81 pub fn __minimize_window() {
82 unsafe { MinimizeWindow() }
83 }
84
85 pub fn __restore_window() {
86 unsafe { RestoreWindow() }
87 }
88
89 pub fn __set_window_icon(image: Image) {
90 unsafe { SetWindowIcon(image) }
91 }
92
93 pub fn __set_window_icons(images: &mut Vec<Image>) {
94 unsafe {
95 let count = images.len() as i32;
96 SetWindowIcons(images.as_mut_ptr(), count)
97 }
98 }
99
100 pub fn __set_window_title(title: impl Display) {
101 unsafe { SetWindowTitle(rl_str!(title)) }
102 }
103
104 pub fn __set_window_position(x: i32, y: i32) {
105 unsafe { SetWindowPosition(x, y) }
106 }
107
108 pub fn __set_window_monitor(monitor: i32) {
109 unsafe { SetWindowMonitor(monitor) }
110 }
111
112 pub fn __set_window_min_size(width: i32, height: i32) {
113 unsafe { SetWindowMinSize(width, height) }
114 }
115
116 pub fn __set_window_max_size(width: i32, height: i32) {
117 unsafe { SetWindowMaxSize(width, height) }
118 }
119
120 pub fn __set_window_size(width: i32, height: i32) {
121 unsafe { SetWindowSize(width, height) }
122 }
123
124 pub fn __set_window_opacity(opacity: f32) {
125 unsafe { SetWindowOpacity(opacity) }
126 }
127
128 pub fn __set_window_focused() {
129 unsafe { SetWindowFocused() }
130 }
131
132 pub fn __get_window_handle<'a>() -> Result<WindowHandle<'a>, String> {
133 unsafe {
134 let raw = GetWindowHandle();
135 if raw.is_null() {
136 Err("couldn't get window handle".to_owned())
137 } else {
138 Ok(raw.into())
139 }
140 }
141 }
142
143 pub fn __get_screen_width() -> i32 {
144 unsafe { GetScreenWidth() }
145 }
146
147 pub fn __get_screen_height() -> i32 {
148 unsafe { GetScreenHeight() }
149 }
150
151 pub fn __get_render_width() -> i32 {
152 unsafe { GetRenderWidth() }
153 }
154
155 pub fn __get_render_height() -> i32 {
156 unsafe { GetRenderHeight() }
157 }
158
159 pub fn __get_monitor_count() -> i32 {
160 unsafe { GetMonitorCount() }
161 }
162
163 pub fn __get_current_monitor() -> i32 {
164 unsafe { GetCurrentMonitor() }
165 }
166
167 pub fn __get_monitor_position(monitor: i32) -> Vector2 {
168 unsafe { GetMonitorPosition(monitor) }
169 }
170
171 pub fn __get_monitor_width(monitor: i32) -> i32 {
172 unsafe { GetMonitorWidth(monitor) }
173 }
174
175 pub fn __get_monitor_height(monitor: i32) -> i32 {
176 unsafe { GetMonitorHeight(monitor) }
177 }
178
179 pub fn __get_monitor_physical_width(monitor: i32) -> i32 {
180 unsafe { GetMonitorPhysicalWidth(monitor) }
181 }
182
183 pub fn __get_monitor_physical_height(monitor: i32) -> i32 {
184 unsafe { GetMonitorPhysicalHeight(monitor) }
185 }
186
187 pub fn __get_monitor_refresh_rate(monitor: i32) -> i32 {
188 unsafe { GetMonitorRefreshRate(monitor) }
189 }
190
191 pub fn __get_window_position() -> Vector2 {
192 unsafe { GetWindowPosition() }
193 }
194
195 pub fn __get_window_scale_dpi() -> Vector2 {
196 unsafe { GetWindowScaleDPI() }
197 }
198
199 pub fn __get_monitor_name(monitor: i32) -> Result<String, String> {
200 unsafe { string_from_c(GetMonitorName(monitor) as *mut c_char) }
201 }
202
203 pub fn __set_clipboard_text(text: impl Display) {
204 unsafe { SetClipboardText(rl_str!(text)) }
205 }
206
207 pub fn __get_clipboard_text() -> Result<String, String> {
208 unsafe { string_from_c(GetClipboardText() as *mut c_char) }
209 }
210
211 pub fn __enable_event_waiting() {
212 unsafe { EnableEventWaiting() }
213 }
214
215 pub fn __disable_event_waiting() {
216 unsafe { DisableEventWaiting() }
217 }
218
219 pub fn __show_cursor() {
222 unsafe { ShowCursor() }
223 }
224
225 pub fn __hide_cursor() {
226 unsafe { HideCursor() }
227 }
228
229 pub fn __is_cursor_hiden() -> bool {
230 unsafe { IsCursorHidden() }
231 }
232
233 pub fn __enable_cursor() {
234 unsafe { EnableCursor() }
235 }
236
237 pub fn __disable_cursor() {
238 unsafe { DisableCursor() }
239 }
240
241 pub fn __is_cursor_on_screen() -> bool {
242 unsafe { IsCursorOnScreen() }
243 }
244
245 pub fn __clear_background(color: Color) {
248 unsafe { ClearBackground(color) }
249 }
250
251 pub fn __begin_drawing() {
252 unsafe { BeginDrawing() }
253 }
254
255 pub fn __end_drawing() {
256 unsafe { EndDrawing() }
257 }
258
259 #[allow(non_snake_case)]
260 pub fn __begin_mode_2D(camera: Camera2D) {
261 unsafe { BeginMode2D(camera) }
262 }
263
264 #[allow(non_snake_case)]
265 pub fn __end_mode_2D() {
266 unsafe { EndMode2D() }
267 }
268
269 #[allow(non_snake_case)]
270 pub fn __begin_mode_3D(camera: Camera3D) {
271 unsafe { BeginMode3D(camera) }
272 }
273
274 #[allow(non_snake_case)]
275 pub fn __end_mode_3D() {
276 unsafe { EndMode3D() }
277 }
278
279 pub fn __begin_texture_mode(target: RenderTexture2D) {
280 unsafe { BeginTextureMode(target) }
281 }
282
283 pub fn __end_texture_mode() {
284 unsafe { EndTextureMode() }
285 }
286
287 pub fn __begin_shader_mode(shader: Shader) {
288 unsafe { BeginShaderMode(shader) }
289 }
290
291 pub fn __end_shader_mode() {
292 unsafe { EndShaderMode() }
293 }
294
295 pub fn __begin_blend_mode(mode: impl Into<usize>) {
296 unsafe { BeginBlendMode(mode.into() as i32) }
297 }
298
299 pub fn __end_blend_mode() {
300 unsafe { EndBlendMode() }
301 }
302
303 pub fn __begin_scissor_mode(x: i32, y: i32, width: i32, height: i32) {
304 unsafe { BeginScissorMode(x, y, width, height) }
305 }
306
307 pub fn __end_scissor_mode() {
308 unsafe { EndScissorMode() }
309 }
310
311 pub fn __begin_vr_stereo_mode(config: VrStereoConfig) {
312 unsafe { BeginVrStereoMode(config) }
313 }
314
315 pub fn __end_vr_stereo_mode() {
316 unsafe { EndVrStereoMode() }
317 }
318
319 pub fn __load_vr_stereo_config(device: VrDeviceInfo) -> VrStereoConfig {
322 unsafe { LoadVrStereoConfig(device) }
323 }
324
325 pub fn __unload_vr_stereo_config(config: VrStereoConfig) {
326 unsafe { UnloadVrStereoConfig(config) }
327 }
328
329 pub fn __load_shader(
332 vs_filename: impl Display,
333 fs_filename: impl Display,
334 ) -> Result<Shader, String> {
335 unsafe {
336 let shader = LoadShader(rl_str!(vs_filename), rl_str!(fs_filename));
337 if shader.locs.is_null() {
338 Err(format!(
339 "couldn't load shader from [vs]{} [fs]{}",
340 vs_filename, fs_filename
341 ))
342 } else {
343 Ok(shader)
344 }
345 }
346 }
347
348 pub fn __load_shader_from_memory(
349 vs_code: impl Display,
350 fs_code: impl Display,
351 ) -> Result<Shader, String> {
352 unsafe {
353 let shader = LoadShaderFromMemory(rl_str!(vs_code), rl_str!(fs_code));
354 if shader.locs.is_null() {
355 Err("failed to load shader from memory".to_owned())
356 } else {
357 Ok(shader)
358 }
359 }
360 }
361
362 pub fn __is_shader_ready(shader: Shader) -> bool {
363 unsafe { IsShaderReady(shader) }
364 }
365
366 pub fn __get_shader_location(shader: Shader, name: impl Display) -> i32 {
367 unsafe { GetShaderLocation(shader, rl_str!(name)) }
368 }
369
370 pub fn __get_shader_location_attrib(
371 shader: Shader,
372 name: impl Display,
373 ) -> Result<ShaderLocationIndex, String> {
374 unsafe {
375 match GetShaderLocationAttrib(shader, rl_str!(name)) {
376 0 => Ok(enums::ShaderLocationIndex::VertexPosition),
377 1 => Ok(enums::ShaderLocationIndex::VertexTexcoord01),
378 2 => Ok(enums::ShaderLocationIndex::VertexTexcoord02),
379 3 => Ok(enums::ShaderLocationIndex::VertexNormal),
380 4 => Ok(enums::ShaderLocationIndex::VertexTangent),
381 5 => Ok(enums::ShaderLocationIndex::VertexColor),
382 6 => Ok(enums::ShaderLocationIndex::MatrixMvp),
383 7 => Ok(enums::ShaderLocationIndex::MatrixView),
384 8 => Ok(enums::ShaderLocationIndex::MatrixProjection),
385 9 => Ok(enums::ShaderLocationIndex::MatrixModel),
386 10 => Ok(enums::ShaderLocationIndex::MatrixNormal),
387 11 => Ok(enums::ShaderLocationIndex::VectorView),
388 12 => Ok(enums::ShaderLocationIndex::ColorDiffuse),
389 13 => Ok(enums::ShaderLocationIndex::ColorSpecular),
390 14 => Ok(enums::ShaderLocationIndex::ColorAmbient),
391 15 => Ok(enums::ShaderLocationIndex::MapAlbedo),
392 16 => Ok(enums::ShaderLocationIndex::MapMetalness),
393 17 => Ok(enums::ShaderLocationIndex::MapNormal),
394 18 => Ok(enums::ShaderLocationIndex::MapRoughness),
395 19 => Ok(enums::ShaderLocationIndex::MapOcclusion),
396 20 => Ok(enums::ShaderLocationIndex::MapEmission),
397 21 => Ok(enums::ShaderLocationIndex::MapHeight),
398 22 => Ok(enums::ShaderLocationIndex::MapCubemap),
399 23 => Ok(enums::ShaderLocationIndex::MapIrradiance),
400 24 => Ok(enums::ShaderLocationIndex::MapPrefilter),
401 25 => Ok(enums::ShaderLocationIndex::MapBrdf),
402 num => Err(format!("could not translate location {}", num)),
403 }
404 }
405 }
406
407 pub fn __set_shader_value<T>(
408 shader: Shader,
409 index: i32,
410 value: &T,
411 tpe: enums::ShaderUniformDataType,
412 ) {
413 unsafe {
414 let tpe = tpe as usize;
415 let value = value as *const T as *const c_void;
416 SetShaderValue(shader, index, value, tpe as i32)
417 }
418 }
419
420 pub fn __set_shader_value_v<T>(
421 shader: Shader,
422 index: i32,
423 value: &[&T],
424 tpe: enums::ShaderUniformDataType,
425 ) {
426 unsafe {
427 let tpe = tpe as usize;
428 let count = value.len() as i32;
429 let value = value.as_ptr() as *const c_void;
430 SetShaderValueV(shader, index, value, tpe as i32, count)
431 }
432 }
433
434 pub fn __set_shader_value_matrix(shader: Shader, loc: i32, mat: Matrix) {
435 unsafe { SetShaderValueMatrix(shader, loc, mat) }
436 }
437
438 pub fn __set_shader_value_texture(shader: Shader, index: i32, texture: Texture2D) {
439 unsafe { SetShaderValueTexture(shader, index, texture) }
440 }
441
442 pub fn __unload_shader(shader: Shader) {
443 unsafe { UnloadShader(shader) }
444 }
445
446 pub fn __get_mouse_ray(mouse_position: Vector2, camera: Camera3D) -> Ray {
449 unsafe { GetMouseRay(mouse_position, camera) }
450 }
451
452 pub fn __get_camera_matrix_2d(camera: Camera2D) -> Matrix {
453 unsafe { GetCameraMatrix2D(camera) }
454 }
455
456 pub fn __get_camera_matrix_3d(camera: Camera3D) -> Matrix {
457 unsafe { GetCameraMatrix(camera) }
458 }
459
460 pub fn __get_world_to_screen_2d(position: Vector2, camera: Camera2D) -> Vector2 {
461 unsafe { GetWorldToScreen2D(position, camera) }
462 }
463
464 pub fn __get_screen_to_world_2d(position: Vector2, camera: Camera2D) -> Vector2 {
465 unsafe { GetScreenToWorld2D(position, camera) }
466 }
467
468 pub fn __get_world_to_screen_3d(position: Vector3, camera: Camera3D) -> Vector2 {
469 unsafe { GetWorldToScreen(position, camera) }
470 }
471
472 pub fn __get_world_to_screen_3d_ex(
473 position: Vector3,
474 camera: Camera3D,
475 width: i32,
476 height: i32,
477 ) -> Vector2 {
478 unsafe { GetWorldToScreenEx(position, camera, width, height) }
479 }
480
481 pub fn __set_target_fps(fps: i32) {
484 unsafe { SetTargetFPS(fps) }
485 }
486
487 pub fn __get_frame_time() -> f32 {
488 unsafe { GetFrameTime() }
489 }
490
491 pub fn __get_time() -> f64 {
492 unsafe { GetTime() }
493 }
494
495 pub fn __get_fps() -> i32 {
496 unsafe { GetFPS() }
497 }
498
499 pub fn __swap_screen_buffer() {
502 unsafe { SwapScreenBuffer() }
503 }
504
505 pub fn __poll_input_events() {
506 unsafe { PollInputEvents() }
507 }
508
509 pub fn __wait_time(seconds: f64) {
510 unsafe { WaitTime(seconds) }
511 }
512
513 pub fn __set_random_seed(seed: u32) {
516 unsafe { SetRandomSeed(seed) }
517 }
518
519 pub fn __get_random_value(min: i32, max: i32) -> i32 {
520 unsafe { GetRandomValue(min, max) }
521 }
522
523 pub fn __load_random_sequence(count: usize, min: i32, max: i32) -> Result<Vec<i32>, String> {
524 unsafe {
525 let raw = LoadRandomSequence(count as u32, min, max);
526 let res = array_from_c(raw, count, || {
527 "could not generate random sequence".to_owned()
528 })?
529 .to_vec();
530 UnloadRandomSequence(raw);
531 Ok(res)
532 }
533 }
534
535 pub fn __take_screenshot(filename: impl Display) {
538 unsafe { TakeScreenshot(rl_str!(filename)) }
539 }
540
541 pub fn __set_config_flags(flags: impl Into<usize>) {
542 unsafe { SetConfigFlags(flags.into() as u32) }
543 }
544
545 pub fn __open_url(url: impl Display) {
546 unsafe { OpenURL(rl_str!(url)) }
547 }
548
549 pub fn __trace_log(level: impl Into<usize>, text: impl Display) {
550 unsafe { TraceLog(level.into() as i32, rl_str!(text)) }
551 }
552
553 pub fn __set_trace_log_level(level: impl Into<usize>) {
554 unsafe { SetTraceLogLevel(level.into() as i32) }
555 }
556
557 pub fn __load_file_data(filename: impl Display) -> Result<Vec<u8>, String> {
572 unsafe {
573 let mut size = 0;
574 let raw = LoadFileData(rl_str!(filename), &mut size);
575 let res = array_from_c(raw, size as usize, || {
576 format!("couldn't load file data from {}", filename)
577 })?
578 .to_vec();
579 UnloadFileData(raw);
580 Ok(res)
581 }
582 }
583
584 pub fn __save_file_data(filename: impl Display, data: &mut Vec<u8>) -> bool {
585 unsafe {
586 let size = data.len() as i32;
587 let data = data.as_mut_ptr() as *mut c_void;
588 SaveFileData(rl_str!(filename), data, size)
589 }
590 }
591
592 pub fn __export_data_as_code(data: &str, filename: impl Display) -> bool {
593 unsafe {
594 let size = data.len() as i32;
595 ExportDataAsCode(rl_str!(data) as *const c_uchar, size, rl_str!(filename))
596 }
597 }
598
599 pub fn __load_file_text(filename: impl Display) -> Result<String, String> {
600 unsafe {
601 let raw = LoadFileText(rl_str!(filename)) as *mut c_char;
602 let res = string_from_c(raw);
603 UnloadFileText(raw);
604 res
605 }
606 }
607
608 pub fn __save_file_text(filename: impl Display, text: impl Display) -> bool {
609 unsafe { SaveFileText(rl_str!(filename), rl_str!(text) as *mut c_char) }
610 }
611
612 pub fn __get_application_directory() -> Result<String, String> {
655 unsafe { string_from_c(GetApplicationDirectory() as *mut c_char) }
656 }
657
658 pub fn __load_automation_event_list(
746 filename: impl Display,
747 ) -> Result<AutomationEventList, String> {
748 unsafe {
749 let list = LoadAutomationEventList(rl_str!(filename));
750 if list.events.is_null() {
751 Err(format!("couldn't load automation events from {}", filename))
752 } else {
753 Ok(list)
754 }
755 }
756 }
757
758 pub fn __unload_automation_event_list(mut list: AutomationEventList) {
759 unsafe { UnloadAutomationEventList(&mut list) }
760 }
761
762 pub fn __export_automation_event_list(
763 list: AutomationEventList,
764 filename: impl Display,
765 ) -> bool {
766 unsafe { ExportAutomationEventList(list, rl_str!(filename)) }
767 }
768
769 pub fn __set_automation_event_list(mut list: AutomationEventList) {
770 unsafe { SetAutomationEventList(&mut list) }
771 }
772
773 pub fn __set_automation_event_base_frame(frame: i32) {
774 unsafe { SetAutomationEventBaseFrame(frame) }
775 }
776
777 pub fn __start_automation_event_record() {
778 unsafe { StartAutomationEventRecording() }
779 }
780
781 pub fn __stop_automation_event_record() {
782 unsafe { StopAutomationEventRecording() }
783 }
784
785 pub fn __play_automation_event(event: AutomationEvent) {
786 unsafe { PlayAutomationEvent(event) }
787 }
788
789 pub fn __is_key_pressed(key: impl Into<usize>) -> bool {
792 unsafe { IsKeyPressed(key.into() as i32) }
793 }
794
795 pub fn __is_key_pressed_repeat(key: impl Into<usize>) -> bool {
796 unsafe { IsKeyPressedRepeat(key.into() as i32) }
797 }
798
799 pub fn __is_key_down(key: impl Into<usize>) -> bool {
800 unsafe { IsKeyDown(key.into() as i32) }
801 }
802
803 pub fn __is_key_released(key: impl Into<usize>) -> bool {
804 unsafe { IsKeyReleased(key.into() as i32) }
805 }
806
807 pub fn __is_key_up(key: impl Into<usize>) -> bool {
808 unsafe { IsKeyUp(key.into() as i32) }
809 }
810
811 pub fn __get_key_pressed() -> KeyboardKey {
812 unsafe {
813 match GetKeyPressed() {
814 39 => KeyboardKey::Apostrophe,
815 44 => KeyboardKey::Comma,
816 45 => KeyboardKey::Minus,
817 46 => KeyboardKey::Period,
818 47 => KeyboardKey::Slash,
819 48 => KeyboardKey::Zero,
820 49 => KeyboardKey::One,
821 50 => KeyboardKey::Two,
822 51 => KeyboardKey::Three,
823 52 => KeyboardKey::Four,
824 53 => KeyboardKey::Five,
825 54 => KeyboardKey::Six,
826 55 => KeyboardKey::Seven,
827 56 => KeyboardKey::Eight,
828 57 => KeyboardKey::Nine,
829 59 => KeyboardKey::Semicolon,
830 61 => KeyboardKey::Equal,
831 65 => KeyboardKey::A,
832 66 => KeyboardKey::B,
833 67 => KeyboardKey::C,
834 68 => KeyboardKey::D,
835 69 => KeyboardKey::E,
836 70 => KeyboardKey::F,
837 71 => KeyboardKey::G,
838 72 => KeyboardKey::H,
839 73 => KeyboardKey::I,
840 74 => KeyboardKey::J,
841 75 => KeyboardKey::K,
842 76 => KeyboardKey::L,
843 77 => KeyboardKey::M,
844 78 => KeyboardKey::N,
845 79 => KeyboardKey::O,
846 80 => KeyboardKey::P,
847 81 => KeyboardKey::Q,
848 82 => KeyboardKey::R,
849 83 => KeyboardKey::S,
850 84 => KeyboardKey::T,
851 85 => KeyboardKey::U,
852 86 => KeyboardKey::V,
853 87 => KeyboardKey::W,
854 88 => KeyboardKey::X,
855 89 => KeyboardKey::Y,
856 90 => KeyboardKey::Z,
857 91 => KeyboardKey::LeftBracket,
858 92 => KeyboardKey::Backslash,
859 93 => KeyboardKey::RightBracket,
860 96 => KeyboardKey::Grave,
861 32 => KeyboardKey::Space,
862 256 => KeyboardKey::Escape,
863 257 => KeyboardKey::Enter,
864 258 => KeyboardKey::Tab,
865 259 => KeyboardKey::Backspace,
866 260 => KeyboardKey::Insert,
867 261 => KeyboardKey::Delete,
868 262 => KeyboardKey::Right,
869 263 => KeyboardKey::Left,
870 264 => KeyboardKey::Down,
871 265 => KeyboardKey::Up,
872 266 => KeyboardKey::PageUp,
873 267 => KeyboardKey::PageDown,
874 268 => KeyboardKey::Home,
875 269 => KeyboardKey::End,
876 280 => KeyboardKey::CapsLock,
877 281 => KeyboardKey::ScrollLock,
878 282 => KeyboardKey::NumLock,
879 283 => KeyboardKey::PrintScreen,
880 284 => KeyboardKey::Pause,
881 290 => KeyboardKey::F1,
882 291 => KeyboardKey::F2,
883 292 => KeyboardKey::F3,
884 293 => KeyboardKey::F4,
885 294 => KeyboardKey::F5,
886 295 => KeyboardKey::F6,
887 296 => KeyboardKey::F7,
888 297 => KeyboardKey::F8,
889 298 => KeyboardKey::F9,
890 299 => KeyboardKey::F10,
891 300 => KeyboardKey::F11,
892 301 => KeyboardKey::F12,
893 340 => KeyboardKey::LeftShift,
894 341 => KeyboardKey::LeftControl,
895 342 => KeyboardKey::LeftAlt,
896 343 => KeyboardKey::LeftSuper,
897 344 => KeyboardKey::RightShift,
898 345 => KeyboardKey::RightControl,
899 346 => KeyboardKey::RightAlt,
900 347 => KeyboardKey::RightSuper,
901 348 => KeyboardKey::KbMenu,
902 320 => KeyboardKey::Kp0,
903 321 => KeyboardKey::Kp1,
904 322 => KeyboardKey::Kp2,
905 323 => KeyboardKey::Kp3,
906 324 => KeyboardKey::Kp4,
907 325 => KeyboardKey::Kp5,
908 326 => KeyboardKey::Kp6,
909 327 => KeyboardKey::Kp7,
910 328 => KeyboardKey::Kp8,
911 329 => KeyboardKey::Kp9,
912 330 => KeyboardKey::KpDecimal,
913 331 => KeyboardKey::KpDivide,
914 332 => KeyboardKey::KpMultiply,
915 333 => KeyboardKey::KpSubtract,
916 334 => KeyboardKey::KpAdd,
917 335 => KeyboardKey::KpEnter,
918 336 => KeyboardKey::KpEqual,
919 4 => KeyboardKey::Back,
920 24 => KeyboardKey::VolumeUp,
921 25 => KeyboardKey::VolumeDown,
922 _ => KeyboardKey::Null,
923 }
924 }
925 }
926
927 pub fn __get_char_pressed() -> String {
928 unsafe {
929 char::from_u32(GetCharPressed() as u32)
930 .map(|c| c.to_string())
931 .unwrap_or("".to_owned())
932 }
933 }
934
935 pub fn __set_exit_key(key: impl Into<usize>) {
936 unsafe { SetExitKey(key.into() as i32) }
937 }
938
939 pub fn __is_gamepad_available(gamepad: i32) -> bool {
942 unsafe { IsGamepadAvailable(gamepad) }
943 }
944
945 pub fn __get_gamepad_name(gamepad: i32) -> Result<String, String> {
946 unsafe { string_from_c(GetGamepadName(gamepad) as *mut c_char) }
947 }
948
949 pub fn __is_gamepad_button_pressed(gamepad: i32, button: impl Into<usize>) -> bool {
950 unsafe { IsGamepadButtonPressed(gamepad, button.into() as i32) }
951 }
952
953 pub fn __is_gamepad_button_down(gamepad: i32, button: impl Into<usize>) -> bool {
954 unsafe { IsGamepadButtonDown(gamepad, button.into() as i32) }
955 }
956
957 pub fn __is_gamepad_button_released(gamepad: i32, button: impl Into<usize>) -> bool {
958 unsafe { IsGamepadButtonReleased(gamepad, button.into() as i32) }
959 }
960
961 pub fn __is_gamepad_button_up(gamepad: i32, button: impl Into<usize>) -> bool {
962 unsafe { IsGamepadButtonUp(gamepad, button.into() as i32) }
963 }
964
965 pub fn __get_gamepad_button_pressed() -> GamepadButton {
966 unsafe {
967 match GetGamepadButtonPressed() {
968 1 => GamepadButton::LeftFaceUp,
969 2 => GamepadButton::LeftFaceRight,
970 3 => GamepadButton::LeftFaceDown,
971 4 => GamepadButton::LeftFaceLeft,
972 5 => GamepadButton::RightFaceUp,
973 6 => GamepadButton::RightFaceRight,
974 7 => GamepadButton::RightFaceDown,
975 8 => GamepadButton::RightFaceLeft,
976 9 => GamepadButton::LeftTrigger1,
977 10 => GamepadButton::LeftTrigger2,
978 11 => GamepadButton::RightTrigger1,
979 12 => GamepadButton::RightTrigger2,
980 13 => GamepadButton::MiddleLeft,
981 14 => GamepadButton::Middle,
982 15 => GamepadButton::MiddleRight,
983 16 => GamepadButton::LeftThumb,
984 17 => GamepadButton::RightThumb,
985 _ => GamepadButton::Unknown,
986 }
987 }
988 }
989
990 pub fn __get_gamepad_axis_count(gamepad: i32) -> i32 {
991 unsafe { GetGamepadAxisCount(gamepad) }
992 }
993
994 pub fn __get_gamepad_axis_movement(gamepad: i32, axis: impl Into<usize>) -> f32 {
995 unsafe { GetGamepadAxisMovement(gamepad, axis.into() as i32) }
996 }
997
998 pub fn __set_gamepad_mappings(mappings: impl Display) -> i32 {
999 unsafe { SetGamepadMappings(rl_str!(mappings)) }
1000 }
1001
1002 pub fn __is_mouse_button_pressed(button: impl Into<usize>) -> bool {
1005 unsafe { IsMouseButtonPressed(button.into() as i32) }
1006 }
1007
1008 pub fn __is_mouse_button_down(button: impl Into<usize>) -> bool {
1009 unsafe { IsMouseButtonDown(button.into() as i32) }
1010 }
1011
1012 pub fn __is_mouse_button_released(button: impl Into<usize>) -> bool {
1013 unsafe { IsMouseButtonReleased(button.into() as i32) }
1014 }
1015
1016 pub fn __is_mouse_button_up(button: impl Into<usize>) -> bool {
1017 unsafe { IsMouseButtonUp(button.into() as i32) }
1018 }
1019
1020 pub fn __get_mouse_x() -> i32 {
1021 unsafe { GetMouseX() }
1022 }
1023
1024 pub fn __get_mouse_y() -> i32 {
1025 unsafe { GetMouseY() }
1026 }
1027
1028 pub fn __get_mouse_position() -> Vector2 {
1029 unsafe { GetMousePosition() }
1030 }
1031
1032 pub fn __get_mouse_delta() -> Vector2 {
1033 unsafe { GetMouseDelta() }
1034 }
1035
1036 pub fn __set_mouse_position(x: i32, y: i32) {
1037 unsafe { SetMousePosition(x, y) }
1038 }
1039
1040 pub fn __set_mouse_offset(x: i32, y: i32) {
1041 unsafe { SetMouseOffset(x, y) }
1042 }
1043
1044 pub fn __set_mouse_scale(x: f32, y: f32) {
1045 unsafe { SetMouseScale(x, y) }
1046 }
1047
1048 pub fn __get_mouse_wheel_move() -> f32 {
1049 unsafe { GetMouseWheelMove() }
1050 }
1051
1052 pub fn __get_mouse_wheel_move_v() -> Vector2 {
1053 unsafe { GetMouseWheelMoveV() }
1054 }
1055
1056 pub fn __set_mouse_cursor(cursor: impl Into<usize>) {
1057 unsafe { SetMouseCursor(cursor.into() as i32) }
1058 }
1059
1060 pub fn __get_touch_x() -> i32 {
1063 unsafe { GetTouchX() }
1064 }
1065
1066 pub fn __get_touch_y() -> i32 {
1067 unsafe { GetTouchY() }
1068 }
1069
1070 pub fn __get_touch_position(index: i32) -> Vector2 {
1071 unsafe { GetTouchPosition(index) }
1072 }
1073
1074 pub fn __get_touch_point_id(index: i32) -> i32 {
1075 unsafe { GetTouchPointId(index) }
1076 }
1077
1078 pub fn __get_touch_point_count() -> i32 {
1079 unsafe { GetTouchPointCount() }
1080 }
1081}
1082
1083pub trait Rcore: Debug {
1085 fn init_window(&self, width: i32, height: i32, title: impl Display) {
1089 RcoreImpl::__init_window(width, height, title)
1090 }
1091
1092 fn close_window(&self) {
1094 RcoreImpl::__close_window()
1095 }
1096
1097 fn window_should_close(&self) -> bool {
1099 RcoreImpl::__window_should_close()
1100 }
1101
1102 fn is_window_ready() -> bool {
1104 RcoreImpl::__is_window_ready()
1105 }
1106
1107 fn is_window_fullscreen(&self) -> bool {
1109 RcoreImpl::__is_window_fullscreen()
1110 }
1111
1112 fn is_window_hidden(&self) -> bool {
1114 RcoreImpl::__is_window_hidden()
1115 }
1116
1117 fn is_window_minimized(&self) -> bool {
1119 RcoreImpl::__is_window_minimized()
1120 }
1121
1122 fn is_window_maximized(&self) -> bool {
1124 RcoreImpl::__is_window_maximized()
1125 }
1126
1127 fn is_window_focused(&self) -> bool {
1129 RcoreImpl::__is_window_focused()
1130 }
1131
1132 fn is_window_resized(&self) -> bool {
1134 RcoreImpl::__is_window_resized()
1135 }
1136
1137 fn is_window_state(&self, flag: usize) -> bool {
1139 RcoreImpl::__is_window_state(flag)
1140 }
1141
1142 fn set_window_state(&self, flag: usize) {
1144 RcoreImpl::__set_window_state(flag)
1145 }
1146
1147 fn clear_window_state(&self, flag: usize) {
1149 RcoreImpl::__clear_window_state(flag)
1150 }
1151
1152 fn toggle_fullscreen(&self) {
1154 RcoreImpl::__toggle_fullscreen()
1155 }
1156
1157 fn toggle_borderless_windowed(&self) {
1159 RcoreImpl::__toggle_borderless_windowed()
1160 }
1161
1162 fn maximize_window(&self) {
1164 RcoreImpl::__maximize_window()
1165 }
1166
1167 fn minimize_window(&self) {
1169 RcoreImpl::__minimize_window()
1170 }
1171
1172 fn restore_window(&self) {
1174 RcoreImpl::__restore_window()
1175 }
1176
1177 fn set_window_icon(&self, image: Image) {
1179 RcoreImpl::__set_window_icon(image)
1180 }
1181
1182 fn set_window_icons(&self, images: &mut Vec<Image>) {
1184 RcoreImpl::__set_window_icons(images)
1185 }
1186
1187 fn set_window_title(&self, title: impl Display) {
1189 RcoreImpl::__set_window_title(title)
1190 }
1191
1192 fn set_window_position(&self, x: i32, y: i32) {
1194 RcoreImpl::__set_window_position(x, y)
1195 }
1196
1197 fn set_window_monitor(&self, monitor: i32) {
1199 RcoreImpl::__set_window_monitor(monitor)
1200 }
1201
1202 fn set_window_min_size(&self, width: i32, height: i32) {
1204 RcoreImpl::__set_window_min_size(width, height)
1205 }
1206
1207 fn set_window_max_size(&self, width: i32, height: i32) {
1209 RcoreImpl::__set_window_max_size(width, height)
1210 }
1211
1212 fn set_window_size(&self, width: i32, height: i32) {
1214 RcoreImpl::__set_window_size(width, height)
1215 }
1216
1217 fn set_window_opacity(&self, opacity: f32) {
1219 RcoreImpl::__set_window_opacity(opacity)
1220 }
1221
1222 fn set_window_focused(&self) {
1224 RcoreImpl::__set_window_focused()
1225 }
1226
1227 fn get_window_handle(&self) -> Result<WindowHandle<'_>, String> {
1229 RcoreImpl::__get_window_handle()
1230 }
1231
1232 fn get_screen_width(&self) -> i32 {
1234 RcoreImpl::__get_screen_width()
1235 }
1236
1237 fn get_screen_height(&self) -> i32 {
1239 RcoreImpl::__get_screen_height()
1240 }
1241
1242 fn get_screen_rec(&self) -> Rectangle {
1244 Rectangle {
1245 x: 0.0,
1246 y: 0.0,
1247 width: RcoreImpl::__get_screen_width() as f32,
1248 height: RcoreImpl::__get_screen_height() as f32,
1249 }
1250 }
1251
1252 fn get_render_width(&self) -> i32 {
1254 RcoreImpl::__get_render_width()
1255 }
1256
1257 fn get_render_height(&self) -> i32 {
1259 RcoreImpl::__get_render_height()
1260 }
1261
1262 fn get_render_rec(&self) -> Rectangle {
1264 let pos = RcoreImpl::__get_window_position();
1265 Rectangle {
1266 x: pos.x,
1267 y: pos.y,
1268 width: RcoreImpl::__get_render_width() as f32,
1269 height: RcoreImpl::__get_render_height() as f32,
1270 }
1271 }
1272
1273 fn get_monitor_count(&self) -> i32 {
1275 RcoreImpl::__get_monitor_count()
1276 }
1277
1278 fn get_current_monitor(&self) -> i32 {
1280 RcoreImpl::__get_current_monitor()
1281 }
1282
1283 fn get_monitor_position(&self, monitor: i32) -> Vector2 {
1285 RcoreImpl::__get_monitor_position(monitor)
1286 }
1287
1288 fn get_monitor_width(&self, monitor: i32) -> i32 {
1290 RcoreImpl::__get_monitor_width(monitor)
1291 }
1292
1293 fn get_monitor_height(&self, monitor: i32) -> i32 {
1295 RcoreImpl::__get_monitor_height(monitor)
1296 }
1297
1298 fn get_monitor_rec(&self, monitor: i32) -> Rectangle {
1300 let pos = RcoreImpl::__get_monitor_position(monitor);
1301 Rectangle {
1302 x: pos.x,
1303 y: pos.y,
1304 width: RcoreImpl::__get_monitor_width(monitor) as f32,
1305 height: RcoreImpl::__get_monitor_height(monitor) as f32,
1306 }
1307 }
1308
1309 fn get_monitor_physical_width(&self, monitor: i32) -> i32 {
1311 RcoreImpl::__get_monitor_physical_width(monitor)
1312 }
1313
1314 fn get_monitor_physical_height(&self, monitor: i32) -> i32 {
1316 RcoreImpl::__get_monitor_physical_height(monitor)
1317 }
1318
1319 fn get_monitor_refresh_rate(&self, monitor: i32) -> i32 {
1321 RcoreImpl::__get_monitor_refresh_rate(monitor)
1322 }
1323
1324 fn get_window_position(&self) -> Vector2 {
1326 RcoreImpl::__get_window_position()
1327 }
1328
1329 fn get_window_scale_dpi(&self) -> Vector2 {
1331 RcoreImpl::__get_window_scale_dpi()
1332 }
1333
1334 fn get_monitor_name(&self, monitor: i32) -> Result<String, String> {
1336 RcoreImpl::__get_monitor_name(monitor)
1337 }
1338
1339 fn set_clipboard_text(&self, text: impl Display) {
1341 RcoreImpl::__set_clipboard_text(text)
1342 }
1343
1344 fn get_clipboard_text(&self) -> Result<String, String> {
1346 RcoreImpl::__get_clipboard_text()
1347 }
1348
1349 fn enable_event_waiting(&self) {
1351 RcoreImpl::__enable_event_waiting()
1352 }
1353
1354 fn disable_event_waiting(&self) {
1356 RcoreImpl::__disable_event_waiting()
1357 }
1358
1359 fn show_cursor(&self) {
1363 RcoreImpl::__show_cursor()
1364 }
1365
1366 fn hide_cursor(&self) {
1368 RcoreImpl::__hide_cursor()
1369 }
1370
1371 fn is_cursor_hiden(&self) -> bool {
1373 RcoreImpl::__is_cursor_hiden()
1374 }
1375
1376 fn enable_cursor(&self) {
1378 RcoreImpl::__enable_cursor()
1379 }
1380
1381 fn disable_cursor(&self) {
1383 RcoreImpl::__disable_cursor()
1384 }
1385
1386 fn is_cursor_on_screen(&self) -> bool {
1388 RcoreImpl::__is_cursor_on_screen()
1389 }
1390
1391 fn clear_background(&self, color: Color) {
1395 RcoreImpl::__clear_background(color)
1396 }
1397
1398 fn begin_drawing(&self) {
1400 RcoreImpl::__begin_drawing()
1401 }
1402
1403 fn end_drawing(&self) {
1405 RcoreImpl::__end_drawing()
1406 }
1407
1408 fn begin_mode_2d(&self, camera: Camera2D) {
1410 RcoreImpl::__begin_mode_2D(camera)
1411 }
1412
1413 fn end_mode_2d(&self) {
1415 RcoreImpl::__end_mode_2D()
1416 }
1417
1418 fn begin_mode_3d(&self, camera: Camera3D) {
1420 RcoreImpl::__begin_mode_3D(camera)
1421 }
1422
1423 fn end_mode_3d(&self) {
1425 RcoreImpl::__end_mode_3D()
1426 }
1427
1428 fn begin_texture_mode(&self, target: RenderTexture2D) {
1430 RcoreImpl::__begin_texture_mode(target)
1431 }
1432
1433 fn end_texture_mode(&self) {
1435 RcoreImpl::__end_texture_mode()
1436 }
1437
1438 fn begin_shader_mode(&self, shader: Shader) {
1440 RcoreImpl::__begin_shader_mode(shader)
1441 }
1442
1443 fn end_shader_mode(&self) {
1445 RcoreImpl::__end_shader_mode()
1446 }
1447
1448 fn begin_blend_mode(&self, mode: BlendMode) {
1450 RcoreImpl::__begin_blend_mode(mode as usize)
1451 }
1452
1453 fn end_blend_mode(&self) {
1455 RcoreImpl::__end_blend_mode()
1456 }
1457
1458 fn begin_scissor_mode(&self, x: i32, y: i32, width: i32, height: i32) {
1460 RcoreImpl::__begin_scissor_mode(x, y, width, height)
1461 }
1462
1463 fn end_scissor_mode(&self) {
1465 RcoreImpl::__end_scissor_mode()
1466 }
1467
1468 fn begin_vr_stereo_mode(&self, config: VrStereoConfig) {
1470 RcoreImpl::__begin_vr_stereo_mode(config)
1471 }
1472
1473 fn end_vr_stereo_mode(&self) {
1475 RcoreImpl::__end_vr_stereo_mode()
1476 }
1477
1478 fn texture_mode<F, R, E>(&self, target: RenderTexture2D, block: F) -> Result<R, E>
1482 where
1483 F: FnOnce() -> Result<R, E>,
1484 {
1485 self.begin_texture_mode(target);
1486 let res = block();
1487 self.end_texture_mode();
1488 res
1489 }
1490
1491 fn shader_mode<F, R, E>(&self, shader: Shader, block: F) -> Result<R, E>
1493 where
1494 F: FnOnce() -> Result<R, E>,
1495 {
1496 self.begin_shader_mode(shader);
1497 let res = block();
1498 self.end_shader_mode();
1499 res
1500 }
1501
1502 fn blend_mode<F, R, E>(&self, mode: BlendMode, block: F) -> Result<R, E>
1504 where
1505 F: FnOnce() -> Result<R, E>,
1506 {
1507 self.begin_blend_mode(mode);
1508 let res = block();
1509 self.end_blend_mode();
1510 res
1511 }
1512
1513 fn scissor_mode<F, R, E>(
1515 &self,
1516 x: i32,
1517 y: i32,
1518 width: i32,
1519 height: i32,
1520 block: F,
1521 ) -> Result<R, E>
1522 where
1523 F: FnOnce() -> Result<R, E>,
1524 {
1525 self.begin_scissor_mode(x, y, width, height);
1526 let res = block();
1527 self.end_scissor_mode();
1528 res
1529 }
1530
1531 fn vr_stereo_mode<F, R, E>(&self, config: VrStereoConfig, block: F) -> Result<R, E>
1533 where
1534 F: FnOnce() -> Result<R, E>,
1535 {
1536 self.begin_vr_stereo_mode(config);
1537 let res = block();
1538 self.end_vr_stereo_mode();
1539 res
1540 }
1541
1542 fn load_vr_stereo_config(&self, device: VrDeviceInfo) -> VrStereoConfig {
1546 RcoreImpl::__load_vr_stereo_config(device)
1547 }
1548
1549 fn unload_vr_stereo_config(&self, config: VrStereoConfig) {
1551 RcoreImpl::__unload_vr_stereo_config(config)
1552 }
1553
1554 fn load_shader(
1558 &self,
1559 vs_filename: impl Display,
1560 fs_filename: impl Display,
1561 ) -> Result<Shader, String> {
1562 RcoreImpl::__load_shader(vs_filename, fs_filename)
1563 }
1564
1565 fn load_shader_from_memory(
1567 &self,
1568 vs_code: impl Display,
1569 fs_code: impl Display,
1570 ) -> Result<Shader, String> {
1571 RcoreImpl::__load_shader_from_memory(vs_code, fs_code)
1572 }
1573
1574 fn is_shader_ready(&self, shader: Shader) -> bool {
1576 RcoreImpl::__is_shader_ready(shader)
1577 }
1578
1579 fn get_shader_location(&self, shader: Shader, name: impl Display) -> i32 {
1581 RcoreImpl::__get_shader_location(shader, name)
1582 }
1583
1584 fn get_shader_location_attrib(
1586 &self,
1587 shader: Shader,
1588 name: impl Display,
1589 ) -> Result<enums::ShaderLocationIndex, String> {
1590 RcoreImpl::__get_shader_location_attrib(shader, name)
1591 }
1592
1593 fn set_shader_value<T>(
1595 &self,
1596 shader: Shader,
1597 index: i32,
1598 value: &T,
1599 tpe: enums::ShaderUniformDataType,
1600 ) {
1601 RcoreImpl::__set_shader_value(shader, index, value, tpe)
1602 }
1603
1604 fn set_shader_value_v<T>(
1606 &self,
1607 shader: Shader,
1608 index: i32,
1609 value: &[&T],
1610 tpe: enums::ShaderUniformDataType,
1611 ) {
1612 RcoreImpl::__set_shader_value_v(shader, index, value, tpe)
1613 }
1614
1615 fn set_shader_value_matrix(&self, shader: Shader, loc: i32, mat: Matrix) {
1617 RcoreImpl::__set_shader_value_matrix(shader, loc, mat)
1618 }
1619
1620 fn set_shader_value_texture(&self, shader: Shader, index: i32, texture: Texture2D) {
1622 RcoreImpl::__set_shader_value_texture(shader, index, texture)
1623 }
1624
1625 fn unload_shader(&self, shader: Shader) {
1627 RcoreImpl::__unload_shader(shader)
1628 }
1629
1630 fn get_mouse_ray(&self, mouse_position: Vector2, camera: Camera3D) -> Ray {
1634 RcoreImpl::__get_mouse_ray(mouse_position, camera)
1635 }
1636
1637 fn get_camera_matrix_2d(&self, camera: Camera2D) -> Matrix {
1639 RcoreImpl::__get_camera_matrix_2d(camera)
1640 }
1641
1642 fn get_camera_matrix_3d(&self, camera: Camera3D) -> Matrix {
1644 RcoreImpl::__get_camera_matrix_3d(camera)
1645 }
1646
1647 fn get_world_to_screen_2d(&self, position: Vector2, camera: Camera2D) -> Vector2 {
1649 RcoreImpl::__get_world_to_screen_2d(position, camera)
1650 }
1651
1652 fn get_screen_to_world_2d(&self, position: Vector2, camera: Camera2D) -> Vector2 {
1654 RcoreImpl::__get_screen_to_world_2d(position, camera)
1655 }
1656
1657 fn get_world_to_screen_3d(&self, position: Vector3, camera: Camera3D) -> Vector2 {
1659 RcoreImpl::__get_world_to_screen_3d(position, camera)
1660 }
1661
1662 fn get_world_to_screen_3d_ex(
1664 &self,
1665 position: Vector3,
1666 camera: Camera3D,
1667 width: i32,
1668 height: i32,
1669 ) -> Vector2 {
1670 RcoreImpl::__get_world_to_screen_3d_ex(position, camera, width, height)
1671 }
1672
1673 fn set_target_fps(&self, fps: i32) {
1677 RcoreImpl::__set_target_fps(fps)
1678 }
1679
1680 fn get_frame_time(&self) -> f32 {
1682 RcoreImpl::__get_frame_time()
1683 }
1684
1685 fn get_time(&self) -> f64 {
1687 RcoreImpl::__get_time()
1688 }
1689
1690 fn get_fps(&self) -> i32 {
1692 RcoreImpl::__get_fps()
1693 }
1694
1695 fn swap_screen_buffer(&self) {
1699 RcoreImpl::__trace_log(
1700 TraceLogLevel::Warning as usize,
1701 "avoid rcore.swap_screen_buffer(), use rcore.end_drawing() instead",
1702 );
1703 RcoreImpl::__swap_screen_buffer()
1704 }
1705
1706 fn poll_input_events(&self) {
1708 RcoreImpl::__trace_log(
1709 TraceLogLevel::Warning as usize,
1710 "avoid rcore.poll_input_events(), use rcore.end_drawing() instead",
1711 );
1712 RcoreImpl::__poll_input_events()
1713 }
1714
1715 fn wait_time(&self, seconds: f64) {
1717 RcoreImpl::__trace_log(
1718 TraceLogLevel::Info as usize,
1719 format!("halting execution for {} seconds", seconds),
1720 );
1721 RcoreImpl::__wait_time(seconds)
1722 }
1723
1724 fn set_random_seed(&self, seed: u32) {
1728 RcoreImpl::__set_random_seed(seed)
1729 }
1730
1731 fn get_random_value(&self, min: i32, max: i32) -> i32 {
1733 RcoreImpl::__get_random_value(min, max)
1734 }
1735
1736 fn load_random_sequence(&self, count: usize, min: i32, max: i32) -> Vec<i32> {
1738 RcoreImpl::__load_random_sequence(count, min, max).unwrap_or_else(|_| vec![])
1739 }
1740
1741 fn take_screenshot(&self, filename: impl Display) {
1745 RcoreImpl::__take_screenshot(filename)
1746 }
1747
1748 fn set_config_flags(&self, flags: impl Into<usize>) {
1750 RcoreImpl::__set_config_flags(flags)
1751 }
1752
1753 fn open_url(&self, url: impl Display) {
1755 RcoreImpl::__open_url(url)
1756 }
1757
1758 fn trace_log(&self, level: TraceLogLevel, text: impl Display) {
1760 RcoreImpl::__trace_log(level as usize, text)
1761 }
1762
1763 fn set_trace_log_level(&self, level: TraceLogLevel) {
1765 RcoreImpl::__set_trace_log_level(level as usize)
1766 }
1767
1768 fn load_file_data(&self, filename: impl Display) -> Result<Vec<u8>, String> {
1772 RcoreImpl::__load_file_data(filename)
1773 }
1774
1775 fn save_file_data(&self, filename: impl Display, data: &mut Vec<u8>) -> bool {
1777 RcoreImpl::__save_file_data(filename, data)
1778 }
1779
1780 fn export_data_as_code(&self, data: &str, filename: impl Display) -> bool {
1782 RcoreImpl::__export_data_as_code(data, filename)
1783 }
1784
1785 fn load_file_text(&self, filename: impl Display) -> Result<String, String> {
1787 RcoreImpl::__load_file_text(filename)
1788 }
1789
1790 fn save_file_text(&self, filename: impl Display, text: impl Display) -> bool {
1792 RcoreImpl::__save_file_text(filename, text)
1793 }
1794
1795 fn get_application_directory(&self) -> Result<String, String> {
1799 RcoreImpl::__get_application_directory()
1800 }
1801
1802 fn load_automation_event_list(
1806 &self,
1807 filename: impl Display,
1808 ) -> Result<AutomationEventList, String> {
1809 RcoreImpl::__load_automation_event_list(filename)
1810 }
1811
1812 fn unload_automation_event_list(&self, list: AutomationEventList) {
1814 RcoreImpl::__unload_automation_event_list(list)
1815 }
1816
1817 fn export_automation_event_list(
1819 &self,
1820 list: AutomationEventList,
1821 filename: impl Display,
1822 ) -> bool {
1823 RcoreImpl::__export_automation_event_list(list, filename)
1824 }
1825
1826 fn set_automation_event_list(&self, list: AutomationEventList) {
1828 RcoreImpl::__set_automation_event_list(list)
1829 }
1830
1831 fn set_automation_event_base_frame(&self, frame: i32) {
1833 RcoreImpl::__set_automation_event_base_frame(frame)
1834 }
1835
1836 fn start_automation_event_record(&self) {
1838 RcoreImpl::__start_automation_event_record()
1839 }
1840
1841 fn stop_automation_event_record(&self) {
1843 RcoreImpl::__stop_automation_event_record()
1844 }
1845
1846 fn play_automation_event(&self, event: AutomationEvent) {
1848 RcoreImpl::__play_automation_event(event)
1849 }
1850
1851 fn is_key_pressed(&self, key: KeyboardKey) -> bool {
1855 RcoreImpl::__is_key_pressed(key as usize)
1856 }
1857
1858 fn is_key_pressed_repeat(&self, key: KeyboardKey) -> bool {
1860 RcoreImpl::__is_key_pressed_repeat(key as usize)
1861 }
1862
1863 fn is_key_down(&self, key: KeyboardKey) -> bool {
1865 RcoreImpl::__is_key_down(key as usize)
1866 }
1867
1868 fn is_key_released(&self, key: KeyboardKey) -> bool {
1870 RcoreImpl::__is_key_released(key as usize)
1871 }
1872
1873 fn is_key_up(&self, key: KeyboardKey) -> bool {
1875 RcoreImpl::__is_key_up(key as usize)
1876 }
1877
1878 fn get_key_pressed(&self) -> KeyboardKey {
1880 RcoreImpl::__get_key_pressed()
1881 }
1882
1883 fn get_char_pressed(&self) -> String {
1885 RcoreImpl::__get_char_pressed()
1886 }
1887
1888 fn set_exit_key(&self, key: KeyboardKey) {
1890 RcoreImpl::__set_exit_key(key as usize)
1891 }
1892
1893 fn is_gamepad_available(&self, gamepad: i32) -> bool {
1897 RcoreImpl::__is_gamepad_available(gamepad)
1898 }
1899
1900 fn get_gamepad_name(&self, gamepad: i32) -> Result<String, String> {
1902 RcoreImpl::__get_gamepad_name(gamepad)
1903 }
1904
1905 fn is_gamepad_button_pressed(&self, gamepad: i32, button: GamepadButton) -> bool {
1907 RcoreImpl::__is_gamepad_button_pressed(gamepad, button as usize)
1908 }
1909
1910 fn is_gamepad_button_down(&self, gamepad: i32, button: GamepadButton) -> bool {
1912 RcoreImpl::__is_gamepad_button_down(gamepad, button as usize)
1913 }
1914
1915 fn is_gamepad_button_released(&self, gamepad: i32, button: GamepadButton) -> bool {
1917 RcoreImpl::__is_gamepad_button_released(gamepad, button as usize)
1918 }
1919
1920 fn is_gamepad_button_up(&self, gamepad: i32, button: GamepadButton) -> bool {
1922 RcoreImpl::__is_gamepad_button_up(gamepad, button as usize)
1923 }
1924
1925 fn get_gamepad_button_pressed(&self) -> GamepadButton {
1927 RcoreImpl::__get_gamepad_button_pressed()
1928 }
1929
1930 fn get_gamepad_axis_count(&self, gamepad: i32) -> i32 {
1932 RcoreImpl::__get_gamepad_axis_count(gamepad)
1933 }
1934
1935 fn get_gamepad_axis_movement(&self, gamepad: i32, axis: GamepadAxis) -> f32 {
1937 RcoreImpl::__get_gamepad_axis_movement(gamepad, axis as usize)
1938 }
1939
1940 fn set_gamepad_mappings(&self, mappings: impl Display) -> i32 {
1942 RcoreImpl::__set_gamepad_mappings(mappings)
1943 }
1944
1945 fn is_mouse_button_pressed(&self, button: MouseButton) -> bool {
1949 RcoreImpl::__is_mouse_button_pressed(button as usize)
1950 }
1951
1952 fn is_mouse_button_down(&self, button: MouseButton) -> bool {
1954 RcoreImpl::__is_mouse_button_down(button as usize)
1955 }
1956
1957 fn is_mouse_button_released(&self, button: MouseButton) -> bool {
1959 RcoreImpl::__is_mouse_button_released(button as usize)
1960 }
1961
1962 fn is_mouse_button_up(&self, button: MouseButton) -> bool {
1964 RcoreImpl::__is_mouse_button_up(button as usize)
1965 }
1966
1967 fn get_mouse_x(&self) -> i32 {
1969 RcoreImpl::__get_mouse_x()
1970 }
1971
1972 fn get_mouse_y(&self) -> i32 {
1974 RcoreImpl::__get_mouse_y()
1975 }
1976
1977 fn get_mouse_position(&self) -> Vector2 {
1979 RcoreImpl::__get_mouse_position()
1980 }
1981
1982 fn get_mouse_delta(&self) -> Vector2 {
1984 RcoreImpl::__get_mouse_delta()
1985 }
1986
1987 fn set_mouse_position(&self, x: i32, y: i32) {
1989 RcoreImpl::__set_mouse_position(x, y)
1990 }
1991
1992 fn set_mouse_offset(&self, x: i32, y: i32) {
1994 RcoreImpl::__set_mouse_offset(x, y)
1995 }
1996
1997 fn set_mouse_scale(&self, x: f32, y: f32) {
1999 RcoreImpl::__set_mouse_scale(x, y)
2000 }
2001
2002 fn get_mouse_wheel_move(&self) -> f32 {
2004 RcoreImpl::__get_mouse_wheel_move()
2005 }
2006
2007 fn get_mouse_wheel_move_v(&self) -> Vector2 {
2009 RcoreImpl::__get_mouse_wheel_move_v()
2010 }
2011
2012 fn set_mouse_cursor(&self, cursor: MouseCursor) {
2014 RcoreImpl::__set_mouse_cursor(cursor as usize)
2015 }
2016
2017 fn get_touch_x(&self) -> i32 {
2021 RcoreImpl::__get_touch_x()
2022 }
2023
2024 fn get_touch_y(&self) -> i32 {
2026 RcoreImpl::__get_touch_y()
2027 }
2028
2029 fn get_touch_position(&self, index: i32) -> Vector2 {
2031 RcoreImpl::__get_touch_position(index)
2032 }
2033
2034 fn get_touch_point_id(&self, index: i32) -> i32 {
2036 RcoreImpl::__get_touch_point_id(index)
2037 }
2038
2039 fn get_touch_point_count(&self) -> i32 {
2041 RcoreImpl::__get_touch_point_count()
2042 }
2043}