Skip to content

Commit

Permalink
Make Kong work on iOS and fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Oct 6, 2023
1 parent 0205eae commit d79403a
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Backends/System/iOS/Sources/kinc/backend/GLView.m.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
16 changes: 8 additions & 8 deletions Backends/System/iOS/Sources/kinc/backend/GLViewController.m.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static GLView *glView;

static bool visible;

void beginGL() {
void beginGL(void) {
#ifdef KORE_METAL
if (!visible) {
return;
Expand All @@ -21,7 +21,7 @@ void beginGL() {
[glView begin];
}

void endGL() {
void endGL(void) {
#ifdef KORE_METAL
if (!visible) {
return;
Expand All @@ -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];
}

Expand Down
6 changes: 3 additions & 3 deletions Backends/System/iOS/Sources/kinc/backend/audio.m.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions Backends/System/iOS/Sources/kinc/backend/display.m.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <kinc/display.h>
#include <kinc/log.h>

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;
Expand Down Expand Up @@ -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;
}
4 changes: 2 additions & 2 deletions Backends/System/iOS/Sources/kinc/backend/mouse.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

Expand Down
32 changes: 20 additions & 12 deletions Backends/System/iOS/Sources/kinc/backend/system.m.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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];
Expand All @@ -72,7 +72,7 @@ const char *kinc_language() {
}

// called on rotation event
void KoreUpdateKeyboard() {
void KoreUpdateKeyboard(void) {
if (keyboardshown) {
hideKeyboard();
showKeyboard();
Expand All @@ -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;
Expand All @@ -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;
}

Expand All @@ -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);
Expand All @@ -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 <mach/mach_time.h>

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) {}

Expand Down
2 changes: 1 addition & 1 deletion Backends/System/iOS/Sources/kinc/backend/window.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int kinc_window_y(int window) {
return 0;
}

int kinc_count_windows() {
int kinc_count_windows(void) {
return 1;
}

Expand Down

0 comments on commit d79403a

Please sign in to comment.