Skip to content

Commit

Permalink
Update Kinc and fix the system-callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Dec 18, 2022
1 parent 5de75be commit f53bef6
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 43 deletions.
4 changes: 2 additions & 2 deletions Backends/Kinc-HL/kinc-bridge/kinc.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ typedef float (*FN_AUDIO_READ_SAMPLE)(void);
void (*audioCallCallback)(int);
float (*audioReadSample)(void);

static void update(void) {
static void update(void *data) {
if (paused) {
return;
}
Expand Down Expand Up @@ -86,7 +86,7 @@ void hl_init_kore(vbyte *title, int width, int height, int samplesPerPixel, bool
frame.samples_per_pixel = samplesPerPixel;
kinc_init((char *)title, width, height, &win, &frame);

kinc_set_update_callback(update);
kinc_set_update_callback(update, NULL);
}

void hl_kinc_init_audio(vclosure *callCallback, vclosure *readSample, int *outSamplesPerSecond) {
Expand Down
32 changes: 16 additions & 16 deletions Backends/Kinc-HL/kinc-bridge/system.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,19 @@ void hl_kinc_register_sensor(vclosure *accelerometerChanged, vclosure *gyroscope
}

// typedef void(*FN_CB_ORIENTATION)(int);
typedef void (*FN_CB_FOREGROUND)(void);
typedef void (*FN_CB_RESUME)(void);
typedef void (*FN_CB_PAUSE)(void);
typedef void (*FN_CB_BACKGROUND)(void);
typedef void (*FN_CB_SHUTDOWN)(void);
typedef void (*FN_CB_FOREGROUND)(void *);
typedef void (*FN_CB_RESUME)(void *);
typedef void (*FN_CB_PAUSE)(void *);
typedef void (*FN_CB_BACKGROUND)(void *);
typedef void (*FN_CB_SHUTDOWN)(void *);

void hl_kinc_register_callbacks(vclosure *foreground, vclosure *resume, vclosure *pause, vclosure *background, vclosure *shutdown) {
// kinc_set_orientation_callback(orientation);
kinc_set_foreground_callback(*((FN_CB_FOREGROUND *)(&foreground->fun)));
kinc_set_resume_callback(*((FN_CB_RESUME *)(&resume->fun)));
kinc_set_pause_callback(*((FN_CB_PAUSE *)(&pause->fun)));
kinc_set_background_callback(*((FN_CB_BACKGROUND *)(&background->fun)));
kinc_set_shutdown_callback(*((FN_CB_SHUTDOWN *)(&shutdown->fun)));
kinc_set_foreground_callback(*((FN_CB_FOREGROUND *)(&foreground->fun)), NULL);
kinc_set_resume_callback(*((FN_CB_RESUME *)(&resume->fun)), NULL);
kinc_set_pause_callback(*((FN_CB_PAUSE *)(&pause->fun)), NULL);
kinc_set_background_callback(*((FN_CB_BACKGROUND *)(&background->fun)), NULL);
kinc_set_shutdown_callback(*((FN_CB_SHUTDOWN *)(&shutdown->fun)), NULL);
}

typedef void (*FN_CB_DROPFILES)(wchar_t *);
Expand All @@ -181,14 +181,14 @@ void hl_kinc_register_dropfiles(vclosure *dropFiles) {
// kinc_set_drop_files_callback(*((FN_CB_DROPFILES*)(&dropFiles->fun)));
}

typedef char *(*FN_CB_COPY)(void);
typedef char *(*FN_CB_CUT)(void);
typedef void (*FN_CB_PASTE)(char *);
typedef char *(*FN_CB_COPY)(void *);
typedef char *(*FN_CB_CUT)(void *);
typedef void (*FN_CB_PASTE)(char *, void *);

void hl_kinc_register_copycutpaste(vclosure *copy, vclosure *cut, vclosure *paste) {
kinc_set_copy_callback(*((FN_CB_COPY *)(&copy->fun)));
kinc_set_cut_callback(*((FN_CB_CUT *)(&cut->fun)));
kinc_set_paste_callback(*((FN_CB_PASTE *)(&paste->fun)));
kinc_set_copy_callback(*((FN_CB_COPY *)(&copy->fun)), NULL);
kinc_set_cut_callback(*((FN_CB_CUT *)(&cut->fun)), NULL);
kinc_set_paste_callback(*((FN_CB_PASTE *)(&paste->fun)), NULL);
}

const char *hl_kinc_video_format(void) {
Expand Down
48 changes: 24 additions & 24 deletions Backends/Kinc-hxcpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ namespace {
bool visible = true;
bool paused = false;

void update() {
void update(void *) {
//**if (paused) return;
kinc_a2_update();

Expand Down Expand Up @@ -167,31 +167,31 @@ namespace {
#endif
}

void foreground() {
void foreground(void *) {
visible = true;
SystemImpl_obj::foreground();
}

void resume() {
void resume(void *) {
SystemImpl_obj::resume();
paused = false;
}

void pause() {
void pause(void *) {
SystemImpl_obj::pause();
paused = true;
}

void background() {
void background(void *) {
visible = false;
SystemImpl_obj::background();
}

void shutdown() {
void shutdown(void *) {
SystemImpl_obj::shutdown();
}

void dropFiles(wchar_t *filePath) {
void dropFiles(wchar_t *filePath, void *) {
SystemImpl_obj::dropFiles(String(filePath));
}

Expand Down Expand Up @@ -246,7 +246,7 @@ namespace {

char cutCopyString[4096];

char *copy() {
char *copy(void *) {
String text = SystemImpl_obj::copy();
if (hx::IsNull(text)) {
return NULL;
Expand All @@ -255,7 +255,7 @@ namespace {
return cutCopyString;
}

char *cut() {
char *cut(void *) {
String text = SystemImpl_obj::cut();
if (hx::IsNull(text)) {
return NULL;
Expand All @@ -264,15 +264,15 @@ namespace {
return cutCopyString;
}

void paste(char *data) {
void paste(char *data, void *) {
SystemImpl_obj::paste(String(data));
}

void login() {
void login(void *) {
SystemImpl_obj::loginevent();
}

void logout() {
void logout(void *) {
SystemImpl_obj::logoutevent();
}
}
Expand All @@ -284,18 +284,18 @@ void init_kinc(const char *name, int width, int height, kinc_window_options_t *w

kinc_mutex_init(&mutex);

kinc_set_foreground_callback(foreground);
kinc_set_resume_callback(resume);
kinc_set_pause_callback(pause);
kinc_set_background_callback(background);
kinc_set_shutdown_callback(shutdown);
kinc_set_drop_files_callback(dropFiles);
kinc_set_update_callback(update);
kinc_set_copy_callback(copy);
kinc_set_cut_callback(cut);
kinc_set_paste_callback(paste);
kinc_set_login_callback(login);
kinc_set_logout_callback(logout);
kinc_set_foreground_callback(foreground, nullptr);
kinc_set_resume_callback(resume, nullptr);
kinc_set_pause_callback(pause, nullptr);
kinc_set_background_callback(background, nullptr);
kinc_set_shutdown_callback(shutdown, nullptr);
kinc_set_drop_files_callback(dropFiles, nullptr);
kinc_set_update_callback(update, nullptr);
kinc_set_copy_callback(copy, nullptr);
kinc_set_cut_callback(cut, nullptr);
kinc_set_paste_callback(paste, nullptr);
kinc_set_login_callback(login, nullptr);
kinc_set_logout_callback(logout, nullptr);

kinc_keyboard_set_key_down_callback(keyDown);
kinc_keyboard_set_key_up_callback(keyUp);
Expand Down

0 comments on commit f53bef6

Please sign in to comment.