From d79403ada7f544a1fa85e9391cb199bdd5f413d7 Mon Sep 17 00:00:00 2001 From: Robert Konrad Date: Fri, 6 Oct 2023 12:30:23 +0200 Subject: [PATCH] Make Kong work on iOS and fix some warnings --- .../iOS/Sources/kinc/backend/GLView.m.h | 2 +- .../Sources/kinc/backend/GLViewController.m.h | 16 +++++----- .../System/iOS/Sources/kinc/backend/audio.m.h | 6 ++-- .../iOS/Sources/kinc/backend/display.m.h | 6 ++-- .../System/iOS/Sources/kinc/backend/mouse.c.h | 4 +-- .../iOS/Sources/kinc/backend/system.m.h | 32 ++++++++++++------- .../iOS/Sources/kinc/backend/window.c.h | 2 +- 7 files changed, 38 insertions(+), 30 deletions(-) diff --git a/Backends/System/iOS/Sources/kinc/backend/GLView.m.h b/Backends/System/iOS/Sources/kinc/backend/GLView.m.h index bdf70950c..ffd13c81c 100644 --- a/Backends/System/iOS/Sources/kinc/backend/GLView.m.h +++ b/Backends/System/iOS/Sources/kinc/backend/GLView.m.h @@ -17,7 +17,7 @@ static const int touchmaxcount = 20; static void *touches[touchmaxcount]; -static void initTouches() { +static void initTouches(void) { for (int i = 0; i < touchmaxcount; ++i) { touches[i] = NULL; } diff --git a/Backends/System/iOS/Sources/kinc/backend/GLViewController.m.h b/Backends/System/iOS/Sources/kinc/backend/GLViewController.m.h index 0f6f0e383..8bdee73c9 100644 --- a/Backends/System/iOS/Sources/kinc/backend/GLViewController.m.h +++ b/Backends/System/iOS/Sources/kinc/backend/GLViewController.m.h @@ -12,7 +12,7 @@ static GLView *glView; static bool visible; -void beginGL() { +void beginGL(void) { #ifdef KORE_METAL if (!visible) { return; @@ -21,7 +21,7 @@ void beginGL() { [glView begin]; } -void endGL() { +void endGL(void) { #ifdef KORE_METAL if (!visible) { return; @@ -30,29 +30,29 @@ void endGL() { [glView end]; } -void showKeyboard() { +void showKeyboard(void) { [glView showKeyboard]; } -void hideKeyboard() { +void hideKeyboard(void) { [glView hideKeyboard]; } #ifdef KORE_METAL -CAMetalLayer *getMetalLayer() { +CAMetalLayer *getMetalLayer(void) { return [glView metalLayer]; } -id getMetalDevice() { +id getMetalDevice(void) { return [glView metalDevice]; } -id getMetalLibrary() { +id getMetalLibrary(void) { return [glView metalLibrary]; } -id getMetalQueue() { +id getMetalQueue(void) { return [glView metalQueue]; } diff --git a/Backends/System/iOS/Sources/kinc/backend/audio.m.h b/Backends/System/iOS/Sources/kinc/backend/audio.m.h index fc19a5246..40a4392df 100644 --- a/Backends/System/iOS/Sources/kinc/backend/audio.m.h +++ b/Backends/System/iOS/Sources/kinc/backend/audio.m.h @@ -109,7 +109,7 @@ static void sampleRateListener(void *inRefCon, AudioUnit inUnit, AudioUnitProper static bool initialized = false; -void kinc_a2_init() { +void kinc_a2_init(void) { if (initialized) { return; } @@ -183,9 +183,9 @@ void kinc_a2_init() { soundPlaying = true; } -void kinc_a2_update() {} +void kinc_a2_update(void) {} -void kinc_a2_shutdown() { +void kinc_a2_shutdown(void) { if (!initialized) return; if (!soundPlaying) diff --git a/Backends/System/iOS/Sources/kinc/backend/display.m.h b/Backends/System/iOS/Sources/kinc/backend/display.m.h index 384aa57a3..bf798bdf1 100644 --- a/Backends/System/iOS/Sources/kinc/backend/display.m.h +++ b/Backends/System/iOS/Sources/kinc/backend/display.m.h @@ -3,7 +3,7 @@ #include #include -void kinc_display_init() {} +void kinc_display_init(void) {} kinc_display_mode_t kinc_display_available_mode(int display, int mode) { kinc_display_mode_t dm; @@ -35,10 +35,10 @@ kinc_display_mode_t kinc_display_current_mode(int display) { return dm; } -int kinc_count_displays() { +int kinc_count_displays(void) { return 1; } -int kinc_primary_display() { +int kinc_primary_display(void) { return 0; } diff --git a/Backends/System/iOS/Sources/kinc/backend/mouse.c.h b/Backends/System/iOS/Sources/kinc/backend/mouse.c.h index 9347296c1..7b75836d4 100644 --- a/Backends/System/iOS/Sources/kinc/backend/mouse.c.h +++ b/Backends/System/iOS/Sources/kinc/backend/mouse.c.h @@ -8,9 +8,9 @@ bool kinc_mouse_can_lock(void) { return false; } -void kinc_mouse_show() {} +void kinc_mouse_show(void) {} -void kinc_mouse_hide() {} +void kinc_mouse_hide(void) {} void kinc_mouse_set_position(int window, int x, int y) {} diff --git a/Backends/System/iOS/Sources/kinc/backend/system.m.h b/Backends/System/iOS/Sources/kinc/backend/system.m.h index 85f861326..4da9571ab 100644 --- a/Backends/System/iOS/Sources/kinc/backend/system.m.h +++ b/Backends/System/iOS/Sources/kinc/backend/system.m.h @@ -35,17 +35,17 @@ void kinc_set_keep_screen_on(bool on) {} void showKeyboard(void); void hideKeyboard(void); -void kinc_keyboard_show() { +void kinc_keyboard_show(void) { keyboardshown = true; showKeyboard(); } -void kinc_keyboard_hide() { +void kinc_keyboard_hide(void) { keyboardshown = false; hideKeyboard(); } -bool kinc_keyboard_active() { +bool kinc_keyboard_active(void) { return keyboardshown; } @@ -62,7 +62,7 @@ void kinc_vibrate(int ms) { static char language[3]; -const char *kinc_language() { +const char *kinc_language(void) { NSString *nsstr = [[NSLocale preferredLanguages] objectAtIndex:0]; const char *lang = [nsstr UTF8String]; language[0] = lang[0]; @@ -72,7 +72,7 @@ const char *kinc_language() { } // called on rotation event -void KoreUpdateKeyboard() { +void KoreUpdateKeyboard(void) { if (keyboardshown) { hideKeyboard(); showKeyboard(); @@ -82,7 +82,11 @@ void KoreUpdateKeyboard() { } } -void kinc_internal_shutdown() {} +#ifdef KINC_KONG +void kong_init(void); +#endif + +void kinc_internal_shutdown(void) {} int kinc_init(const char *name, int width, int height, struct kinc_window_options *win, struct kinc_framebuffer_options *frame) { kinc_window_options_t defaultWin; @@ -97,6 +101,10 @@ int kinc_init(const char *name, int width, int height, struct kinc_window_option } kinc_g4_internal_init(); kinc_g4_internal_init_window(0, frame->depth_bits, frame->stencil_bits, true); + +#ifdef KINC_KONG + kong_init(); +#endif return 0; } @@ -108,7 +116,7 @@ void swapBuffersiOS(void) { static char sysid[512]; -const char *kinc_system_id() { +const char *kinc_system_id(void) { const char *name = [[[UIDevice currentDevice] name] UTF8String]; const char *vendorId = [[[[UIDevice currentDevice] identifierForVendor] UUIDString] UTF8String]; strcpy(sysid, name); @@ -132,30 +140,30 @@ static const char *getSavePath(void) { return [resolvedPath cStringUsingEncoding:1]; } -const char *kinc_internal_save_path() { +const char *kinc_internal_save_path(void) { return getSavePath(); } static const char *videoFormats[] = {"mp4", NULL}; -const char **kinc_video_formats() { +const char **kinc_video_formats(void) { return videoFormats; } #include -double kinc_frequency() { +double kinc_frequency(void) { mach_timebase_info_data_t info; mach_timebase_info(&info); return (double)info.denom / (double)info.numer / 1e-9; } -kinc_ticks_t kinc_timestamp() { +kinc_ticks_t kinc_timestamp(void) { kinc_ticks_t time = mach_absolute_time(); return time; } -void kinc_login() {} +void kinc_login(void) {} void kinc_unlock_achievement(int id) {} diff --git a/Backends/System/iOS/Sources/kinc/backend/window.c.h b/Backends/System/iOS/Sources/kinc/backend/window.c.h index 96159ff03..e42a899d3 100644 --- a/Backends/System/iOS/Sources/kinc/backend/window.c.h +++ b/Backends/System/iOS/Sources/kinc/backend/window.c.h @@ -13,7 +13,7 @@ int kinc_window_y(int window) { return 0; } -int kinc_count_windows() { +int kinc_count_windows(void) { return 1; }