forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
13
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/atomic.h
Normal file
13
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/atomic.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#define KINC_ATOMIC_COMPARE_EXCHANGE(pointer, oldValue, newValue)
|
||||
|
||||
#define KINC_ATOMIC_COMPARE_EXCHANGE_POINTER(pointer, oldValue, newValue)
|
||||
|
||||
#define KINC_ATOMIC_INCREMENT(pointer)
|
||||
|
||||
#define KINC_ATOMIC_DECREMENT(pointer)
|
||||
|
||||
#define KINC_ATOMIC_EXCHANGE_32(pointer, value)
|
||||
|
||||
#define KINC_ATOMIC_EXCHANGE_FLOAT(pointer, value)
|
18
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/audio.c.h
Normal file
18
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/audio.c.h
Normal file
@ -0,0 +1,18 @@
|
||||
#include <kinc/audio2/audio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static kinc_a2_buffer_t a2_buffer;
|
||||
|
||||
void kinc_a2_init() {
|
||||
kinc_a2_internal_init();
|
||||
}
|
||||
|
||||
void kinc_a2_update() {}
|
||||
|
||||
void kinc_a2_shutdown() {}
|
||||
|
||||
static uint32_t samples_per_second = 44100;
|
||||
|
||||
uint32_t kinc_a2_samples_per_second(void) {
|
||||
return samples_per_second;
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
#include <kinc/display.h>
|
||||
|
||||
void kinc_display_init(void) {}
|
||||
|
||||
int kinc_primary_display(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kinc_count_displays(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool kinc_display_available(int display_index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *kinc_display_name(int display_index) {
|
||||
return "Browser";
|
||||
}
|
||||
|
||||
kinc_display_mode_t kinc_display_current_mode(int display_index) {
|
||||
kinc_display_mode_t mode;
|
||||
mode.x = 0;
|
||||
mode.y = 0;
|
||||
mode.width = 800;
|
||||
mode.height = 600;
|
||||
mode.pixels_per_inch = 96;
|
||||
mode.frequency = 60;
|
||||
mode.bits_per_pixel = 32;
|
||||
return mode;
|
||||
}
|
||||
|
||||
int kinc_display_count_available_modes(int display_index) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
kinc_display_mode_t kinc_display_available_mode(int display_index, int mode_index) {
|
||||
kinc_display_mode_t mode;
|
||||
mode.x = 0;
|
||||
mode.y = 0;
|
||||
mode.width = 800;
|
||||
mode.height = 600;
|
||||
mode.pixels_per_inch = 96;
|
||||
mode.frequency = 60;
|
||||
mode.bits_per_pixel = 32;
|
||||
return mode;
|
||||
}
|
15
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/event.c.h
Normal file
15
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/event.c.h
Normal file
@ -0,0 +1,15 @@
|
||||
#include <kinc/threads/event.h>
|
||||
|
||||
void kinc_event_init(kinc_event_t *event, bool auto_reset) {}
|
||||
|
||||
void kinc_event_destroy(kinc_event_t *event) {}
|
||||
|
||||
void kinc_event_signal(kinc_event_t *event) {}
|
||||
|
||||
void kinc_event_wait(kinc_event_t *event) {}
|
||||
|
||||
bool kinc_event_try_to_wait(kinc_event_t *event, double seconds) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void kinc_event_reset(kinc_event_t *event) {}
|
13
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/event.h
Normal file
13
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/event.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int nothing;
|
||||
} kinc_event_impl_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,11 @@
|
||||
#include "audio.c.h"
|
||||
#include "display.c.h"
|
||||
#include "event.c.h"
|
||||
#include "mouse.c.h"
|
||||
#include "mutex.c.h"
|
||||
#include "semaphore.c.h"
|
||||
#include "system.c.h"
|
||||
#include "thread.c.h"
|
||||
#include "threadlocal.c.h"
|
||||
#include "video.c.h"
|
||||
#include "window.c.h"
|
17
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/mouse.c.h
Normal file
17
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/mouse.c.h
Normal file
@ -0,0 +1,17 @@
|
||||
#include <kinc/input/mouse.h>
|
||||
|
||||
void kinc_internal_mouse_lock(int window) {}
|
||||
|
||||
void kinc_internal_mouse_unlock(void) {}
|
||||
|
||||
bool kinc_mouse_can_lock(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void kinc_mouse_show() {}
|
||||
|
||||
void kinc_mouse_hide() {}
|
||||
|
||||
void kinc_mouse_set_position(int window, int x, int y) {}
|
||||
|
||||
void kinc_mouse_get_position(int window, int *x, int *y) {}
|
23
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/mutex.c.h
Normal file
23
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/mutex.c.h
Normal file
@ -0,0 +1,23 @@
|
||||
#include <kinc/threads/mutex.h>
|
||||
|
||||
void kinc_mutex_init(kinc_mutex_t *mutex) {}
|
||||
|
||||
void kinc_mutex_destroy(kinc_mutex_t *mutex) {}
|
||||
|
||||
bool kinc_mutex_try_to_lock(kinc_mutex_t *mutex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void kinc_mutex_lock(kinc_mutex_t *mutex) {}
|
||||
|
||||
void kinc_mutex_unlock(kinc_mutex_t *mutex) {}
|
||||
|
||||
bool kinc_uber_mutex_init(kinc_uber_mutex_t *mutex, const char *name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void kinc_uber_mutex_destroy(kinc_uber_mutex_t *mutex) {}
|
||||
|
||||
void kinc_uber_mutex_lock(kinc_uber_mutex_t *mutex) {}
|
||||
|
||||
void kinc_uber_mutex_unlock(kinc_uber_mutex_t *mutex) {}
|
17
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/mutex.h
Normal file
17
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/mutex.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int nothing;
|
||||
} kinc_mutex_impl_t;
|
||||
|
||||
typedef struct {
|
||||
int nothing;
|
||||
} kinc_uber_mutex_impl_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,13 @@
|
||||
#include <kinc/threads/semaphore.h>
|
||||
|
||||
void kinc_semaphore_init(kinc_semaphore_t *semaphore, int current, int max) {}
|
||||
|
||||
void kinc_semaphore_destroy(kinc_semaphore_t *semaphore) {}
|
||||
|
||||
void kinc_semaphore_release(kinc_semaphore_t *semaphore, int count) {}
|
||||
|
||||
void kinc_semaphore_acquire(kinc_semaphore_t *semaphore) {}
|
||||
|
||||
bool kinc_semaphore_try_to_acquire(kinc_semaphore_t *semaphore, double seconds) {
|
||||
return false;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int nothing;
|
||||
} kinc_semaphore_impl_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
108
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/system.c.h
Normal file
108
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/system.c.h
Normal file
@ -0,0 +1,108 @@
|
||||
#include <kinc/audio2/audio.h>
|
||||
#include <kinc/graphics4/graphics.h>
|
||||
#include <kinc/input/keyboard.h>
|
||||
#include <kinc/input/mouse.h>
|
||||
#include <kinc/log.h>
|
||||
#include <kinc/system.h>
|
||||
#include <kinc/window.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
__attribute__((import_module("imports"), import_name("js_time"))) int js_time();
|
||||
|
||||
extern int kinc_internal_window_width;
|
||||
extern int kinc_internal_window_height;
|
||||
|
||||
#ifdef KINC_KONG
|
||||
void kong_init(void);
|
||||
#endif
|
||||
|
||||
int kinc_init(const char *name, int width, int height, kinc_window_options_t *win, kinc_framebuffer_options_t *frame) {
|
||||
kinc_window_options_t defaultWin;
|
||||
if (win == NULL) {
|
||||
kinc_window_options_set_defaults(&defaultWin);
|
||||
win = &defaultWin;
|
||||
}
|
||||
kinc_framebuffer_options_t defaultFrame;
|
||||
if (frame == NULL) {
|
||||
kinc_framebuffer_options_set_defaults(&defaultFrame);
|
||||
frame = &defaultFrame;
|
||||
}
|
||||
win->width = width;
|
||||
win->height = height;
|
||||
|
||||
kinc_internal_window_width = width;
|
||||
kinc_internal_window_height = height;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool kinc_internal_handle_messages() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void kinc_set_keep_screen_on(bool on) {}
|
||||
|
||||
double kinc_frequency(void) {
|
||||
return 1000.0;
|
||||
}
|
||||
|
||||
kinc_ticks_t kinc_timestamp(void) {
|
||||
return (kinc_ticks_t)(js_time());
|
||||
}
|
||||
|
||||
double kinc_time(void) {
|
||||
return js_time() / 1000.0;
|
||||
}
|
||||
|
||||
int kinc_cpu_cores(void) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
int kinc_hardware_threads(void) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
void kinc_internal_shutdown(void) {}
|
||||
|
||||
extern int kickstart(int argc, char **argv);
|
||||
|
||||
__attribute__((export_name("_start"))) void _start(void) {
|
||||
kickstart(0, NULL);
|
||||
}
|
||||
|
||||
__attribute__((export_name("_update"))) void _update(void) {
|
||||
kinc_internal_update_callback();
|
||||
kinc_a2_update();
|
||||
}
|
||||
|
||||
__attribute__((export_name("_mousedown"))) void _mousedown(int button, int x, int y) {
|
||||
kinc_internal_mouse_trigger_press(0, button, x, y);
|
||||
}
|
||||
|
||||
__attribute__((export_name("_mouseup"))) void _mouseup(int button, int x, int y) {
|
||||
kinc_internal_mouse_trigger_release(0, button, x, y);
|
||||
}
|
||||
|
||||
__attribute__((export_name("_mousemove"))) void _mousemove(int x, int y) {
|
||||
kinc_internal_mouse_trigger_move(0, x, y);
|
||||
}
|
||||
|
||||
__attribute__((export_name("_wheel"))) void _wheel(int delta) {
|
||||
kinc_internal_mouse_trigger_scroll(0, delta);
|
||||
}
|
||||
|
||||
__attribute__((export_name("_keydown"))) void _keydown(int key) {
|
||||
kinc_internal_keyboard_trigger_key_down(key);
|
||||
}
|
||||
|
||||
__attribute__((export_name("_keyup"))) void _keyup(int key) {
|
||||
kinc_internal_keyboard_trigger_key_up(key);
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
#include <kinc/threads/thread.h>
|
||||
|
||||
void kinc_thread_init(kinc_thread_t *t, void (*thread)(void *param), void *param) {}
|
||||
|
||||
void kinc_thread_wait_and_destroy(kinc_thread_t *thread) {}
|
||||
|
||||
bool kinc_thread_try_to_destroy(kinc_thread_t *thread) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void kinc_threads_init() {}
|
||||
|
||||
void kinc_threads_quit() {}
|
||||
|
||||
void kinc_thread_sleep(int milliseconds) {}
|
13
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/thread.h
Normal file
13
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/thread.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int nothing;
|
||||
} kinc_thread_impl_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,13 @@
|
||||
#include <kinc/threads/threadlocal.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
void kinc_thread_local_init(kinc_thread_local_t *local) {}
|
||||
|
||||
void kinc_thread_local_destroy(kinc_thread_local_t *local) {}
|
||||
|
||||
void *kinc_thread_local_get(kinc_thread_local_t *local) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void kinc_thread_local_set(kinc_thread_local_t *local, void *data) {}
|
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int nothing;
|
||||
} kinc_thread_local_impl_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
57
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/video.c.h
Normal file
57
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/video.c.h
Normal file
@ -0,0 +1,57 @@
|
||||
#include <kinc/video.h>
|
||||
|
||||
void kinc_video_init(kinc_video_t *video, const char *filename) {}
|
||||
|
||||
void kinc_video_destroy(kinc_video_t *video) {}
|
||||
|
||||
void kinc_video_play(kinc_video_t *video, bool loop) {}
|
||||
|
||||
void kinc_video_pause(kinc_video_t *video) {}
|
||||
|
||||
void kinc_video_stop(kinc_video_t *video) {}
|
||||
|
||||
int kinc_video_width(kinc_video_t *video) {
|
||||
return 256;
|
||||
}
|
||||
|
||||
int kinc_video_height(kinc_video_t *video) {
|
||||
return 256;
|
||||
}
|
||||
|
||||
kinc_g4_texture_t *kinc_video_current_image(kinc_video_t *video) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
double kinc_video_duration(kinc_video_t *video) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double kinc_video_position(kinc_video_t *video) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
bool kinc_video_finished(kinc_video_t *video) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool kinc_video_paused(kinc_video_t *video) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void kinc_video_update(kinc_video_t *video, double time) {}
|
||||
|
||||
void kinc_internal_video_sound_stream_init(kinc_internal_video_sound_stream_t *stream, int channel_count, int frequency) {}
|
||||
|
||||
void kinc_internal_video_sound_stream_destroy(kinc_internal_video_sound_stream_t *stream) {}
|
||||
|
||||
void kinc_internal_video_sound_stream_insert_data(kinc_internal_video_sound_stream_t *stream, float *data, int sample_count) {}
|
||||
|
||||
static float samples[2] = {0};
|
||||
|
||||
float *kinc_internal_video_sound_stream_next_frame(kinc_internal_video_sound_stream_t *stream) {
|
||||
return samples;
|
||||
}
|
||||
|
||||
bool kinc_internal_video_sound_stream_ended(kinc_internal_video_sound_stream_t *stream) {
|
||||
return true;
|
||||
}
|
27
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/video.h
Normal file
27
Kha/Kinc/Backends/System/Wasm/Sources/kinc/backend/video.h
Normal file
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int nothing;
|
||||
} kinc_video_impl_t;
|
||||
|
||||
typedef struct kinc_internal_video_sound_stream {
|
||||
int nothing;
|
||||
} kinc_internal_video_sound_stream_t;
|
||||
|
||||
void kinc_internal_video_sound_stream_init(kinc_internal_video_sound_stream_t *stream, int channel_count, int frequency);
|
||||
|
||||
void kinc_internal_video_sound_stream_destroy(kinc_internal_video_sound_stream_t *stream);
|
||||
|
||||
void kinc_internal_video_sound_stream_insert_data(kinc_internal_video_sound_stream_t *stream, float *data, int sample_count);
|
||||
|
||||
float *kinc_internal_video_sound_stream_next_frame(kinc_internal_video_sound_stream_t *stream);
|
||||
|
||||
bool kinc_internal_video_sound_stream_ended(kinc_internal_video_sound_stream_t *stream);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,81 @@
|
||||
#include <kinc/display.h>
|
||||
#include <kinc/graphics4/graphics.h>
|
||||
#include <kinc/window.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
int kinc_internal_window_width = 0;
|
||||
int kinc_internal_window_height = 0;
|
||||
kinc_window_mode_t kinc_internal_window_mode = KINC_WINDOW_MODE_WINDOW;
|
||||
|
||||
int kinc_count_windows(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int kinc_window_x(int window_index) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kinc_window_y(int window_index) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kinc_window_width(int window_index) {
|
||||
return kinc_internal_window_width;
|
||||
}
|
||||
|
||||
int kinc_window_height(int window_index) {
|
||||
return kinc_internal_window_height;
|
||||
}
|
||||
|
||||
void kinc_window_resize(int window_index, int width, int height) {}
|
||||
|
||||
void kinc_window_move(int window_index, int x, int y) {}
|
||||
|
||||
void kinc_window_change_framebuffer(int window_index, kinc_framebuffer_options_t *frame) {
|
||||
//**kinc_g4_changeFramebuffer(0, frame);
|
||||
}
|
||||
|
||||
void kinc_window_change_features(int window_index, int features) {}
|
||||
|
||||
// In HTML5 fullscreen is activable only from user input.
|
||||
void kinc_window_change_mode(int window_index, kinc_window_mode_t mode) {
|
||||
if (mode == KINC_WINDOW_MODE_FULLSCREEN || mode == KINC_WINDOW_MODE_EXCLUSIVE_FULLSCREEN) {
|
||||
if (kinc_internal_window_mode == KINC_WINDOW_MODE_FULLSCREEN || kinc_internal_window_mode == KINC_WINDOW_MODE_EXCLUSIVE_FULLSCREEN) {
|
||||
kinc_internal_window_mode = mode;
|
||||
return;
|
||||
}
|
||||
// TODO: call js Fullscreen API
|
||||
kinc_internal_window_mode = mode;
|
||||
}
|
||||
else {
|
||||
if (mode == kinc_internal_window_mode) {
|
||||
return;
|
||||
}
|
||||
// TODO: call js Fullscreen API
|
||||
kinc_internal_window_mode = mode;
|
||||
}
|
||||
}
|
||||
|
||||
void kinc_window_destroy(int window_index) {}
|
||||
|
||||
void kinc_window_show(int window_index) {}
|
||||
|
||||
void kinc_window_hide(int window_index) {}
|
||||
|
||||
// TODO: change browser title.
|
||||
void kinc_window_set_title(int window_index, const char *title) {}
|
||||
|
||||
int kinc_window_create(kinc_window_options_t *win, kinc_framebuffer_options_t *frame) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void kinc_window_set_resize_callback(int window_index, void (*callback)(int x, int y, void *data), void *data) {}
|
||||
|
||||
void kinc_window_set_ppi_changed_callback(int window_index, void (*callback)(int ppi, void *data), void *data) {}
|
||||
|
||||
void kinc_window_set_close_callback(int window, bool (*callback)(void *), void *data) {}
|
||||
|
||||
kinc_window_mode_t kinc_window_get_mode(int window_index) {
|
||||
return kinc_internal_window_mode;
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
namespace Kore {
|
||||
struct WindowData {
|
||||
int width, height, mode;
|
||||
WindowData();
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user