Kore 3
Loading...
Searching...
No Matches
system.h
Go to the documentation of this file.
1#ifndef KORE_SYSTEM_HEADER
2#define KORE_SYSTEM_HEADER
3
4#include <kore3/global.h>
5
6#include <kore3/log.h>
7
8#include <stdbool.h>
9#include <stddef.h>
10#include <stdint.h>
11
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
22
29KORE_FUNC int kore_init(const char *name, int width, int height, struct kore_window_parameters *win, struct kore_framebuffer_parameters *frame);
30
35KORE_FUNC const char *kore_application_name(void);
36
41KORE_FUNC void kore_set_application_name(const char *name);
42
47KORE_FUNC int kore_width(void);
48
53KORE_FUNC int kore_height(void);
54
59KORE_FUNC void kore_load_url(const char *url);
60
65KORE_FUNC const char *kore_system_id(void);
66
71KORE_FUNC const char *kore_language(void);
72
76KORE_FUNC void kore_vibrate(int milliseconds);
77
83KORE_FUNC float kore_safe_zone(void);
84
89KORE_FUNC bool kore_automatic_safe_zone(void);
90
95KORE_FUNC void kore_set_safe_zone(float value);
96
97typedef uint64_t kore_ticks;
98
103KORE_FUNC double kore_frequency(void);
104
109KORE_FUNC kore_ticks kore_timestamp(void);
110
115KORE_FUNC int kore_cpu_cores(void);
116
121KORE_FUNC int kore_hardware_threads(void);
122
127KORE_FUNC double kore_time(void);
128
132KORE_FUNC void kore_start(void);
133
137KORE_FUNC void kore_stop(void);
138
142KORE_FUNC void kore_login(void);
143
148KORE_FUNC bool kore_waiting_for_login(void);
149
154KORE_FUNC void kore_unlock_achievement(int id);
155
159KORE_FUNC void kore_disallow_user_change(void);
160
164KORE_FUNC void kore_allow_user_change(void);
165
170KORE_FUNC void kore_set_keep_screen_on(bool on);
171
175KORE_INLINE void kore_debug_break(void) {
176#ifndef NDEBUG
177#if defined(_MSC_VER)
178 __debugbreak();
179#elif defined(__clang__)
180 __builtin_debugtrap();
181#else
182#if defined(__aarch64__)
183 __asm__ volatile(".inst 0xd4200000");
184#elif defined(__x86_64__)
185 __asm__ volatile("int $0x03");
186#else
187 kore_log(KORE_LOG_LEVEL_WARNING, "Oh no, kore_debug_break is not implemented for the current compiler and CPU.");
188#endif
189#endif
190#endif
191}
192
197KORE_FUNC bool kore_debugger_attached(void);
198
203KORE_FUNC void kore_copy_to_clipboard(const char *text);
204
210KORE_FUNC void kore_set_update_callback(void (*callback)(void *), void *data);
211
217KORE_FUNC void kore_set_foreground_callback(void (*callback)(void *), void *data);
218
224KORE_FUNC void kore_set_resume_callback(void (*callback)(void *), void *data);
225
231KORE_FUNC void kore_set_pause_callback(void (*callback)(void *), void *data);
232
238KORE_FUNC void kore_set_background_callback(void (*callback)(void *), void *data);
239
245KORE_FUNC void kore_set_shutdown_callback(void (*callback)(void *), void *data);
246
252KORE_FUNC void kore_set_drop_files_callback(void (*callback)(wchar_t *, void *), void *data);
253
260KORE_FUNC void kore_set_cut_callback(char *(*callback)(void *), void *data);
261
268KORE_FUNC void kore_set_copy_callback(char *(*callback)(void *), void *data);
269
276KORE_FUNC void kore_set_paste_callback(void (*callback)(char *, void *), void *data);
277
283KORE_FUNC void kore_set_login_callback(void (*callback)(void *), void *data);
284
290KORE_FUNC void kore_set_logout_callback(void (*callback)(void *), void *data);
291
292#ifdef KORE_VTUNE
293#include <ittnotify.h>
294
295extern __itt_domain *kore_itt_domain;
296#endif
297
298#ifdef KORE_SUPERLUMINAL
299#include <Superluminal/PerformanceAPI_capi.h>
300#endif
301
307static inline void kore_marker_start(const char *name, uint32_t color) {
308#ifdef KORE_VTUNE
309 __itt_task_begin(kore_itt_domain, __itt_null, __itt_null, __itt_string_handle_create(name));
310#endif
311
312#ifdef KORE_SUPERLUMINAL
313 PerformanceAPI_BeginEvent(name, NULL, color);
314#endif
315}
316
320static inline void kore_marker_end(const char *name) {
321#ifdef KORE_VTUNE
322 __itt_task_end(kore_itt_domain);
323#endif
324
325#ifdef KORE_SUPERLUMINAL
326 PerformanceAPI_EndEvent();
327#endif
328}
329
340KORE_FUNC void kore_LivePP_start(void);
341
347KORE_FUNC void kore_LivePP_stop(void);
348
349bool kore_internal_frame(void);
350const char *kore_internal_save_path(void);
351bool kore_internal_handle_messages(void);
352void kore_internal_shutdown(void);
353void kore_internal_update_callback(void);
354void kore_internal_foreground_callback(void);
355void kore_internal_resume_callback(void);
356void kore_internal_pause_callback(void);
357void kore_internal_background_callback(void);
358void kore_internal_shutdown_callback(void);
359void kore_internal_drop_files_callback(wchar_t *);
360char *kore_internal_cut_callback(void);
361char *kore_internal_copy_callback(void);
362void kore_internal_paste_callback(char *);
363void kore_internal_login_callback(void);
364void kore_internal_logout_callback(void);
365
366#ifdef __cplusplus
367}
368#endif
369
370#endif
Provides basic functionality that's used all over the place. There's usually no need to manually incl...
Contains basic logging functionality.
KORE_FUNC void kore_log(kore_log_level log_level, const char *format,...)
Logging function similar to printf including some system-specific bonuses.
Definition window.h:16
Definition window.h:37
KORE_FUNC const char * kore_system_id(void)
Returns an ID representing the current type of target-system.
KORE_FUNC int kore_hardware_threads(void)
Returns the number of hardware-threads.
KORE_FUNC void kore_copy_to_clipboard(const char *text)
Copies the provided string to the system's clipboard.
KORE_FUNC void kore_allow_user_change(void)
Allows the system to logout the current user.
KORE_FUNC void kore_stop(void)
Stops Kore's main loop and thereby returns to the function which called kore_start.
KORE_FUNC int kore_width(void)
Returns the current width of the initial application-window which is equivalent to calling kore_windo...
KORE_FUNC double kore_frequency(void)
Returns the frequency of system-timestamps.
KORE_FUNC int kore_cpu_cores(void)
Returns the number of proper CPU-cores (not the number of hardware-threads).
KORE_FUNC void kore_set_copy_callback(char *(*callback)(void *), void *data)
Sets a callback which is called when the application is instructed to copy, typically via ctrl+c or c...
KORE_FUNC void kore_unlock_achievement(int id)
Unlocks an achievement or trophy or however you prefer to call it.
KORE_FUNC void kore_LivePP_stop(void)
Stops Live++, typically called right after kore_start().
KORE_FUNC void kore_set_login_callback(void(*callback)(void *), void *data)
Sets a callback which is called when a user logs in.
KORE_FUNC int kore_height(void)
Returns the current height of the initial application-window which is equivalent to calling kore_wind...
KORE_FUNC void kore_set_shutdown_callback(void(*callback)(void *), void *data)
Sets a callback which is called whenever the application is about to shut down.
KORE_FUNC kore_ticks kore_timestamp(void)
Returns a timestamp for right now in a system-specific unit.
KORE_INLINE void kore_debug_break(void)
Tries to halt program-execution in an attached debugger when compiled in debug-mode (aka when NDEBUG ...
Definition system.h:175
KORE_FUNC void kore_set_foreground_callback(void(*callback)(void *), void *data)
Sets a callback which is called whenever the application is brought to the foreground.
static void kore_marker_end(const char *name)
Ends the previously started marker of the same function.
Definition system.h:320
KORE_FUNC void kore_set_background_callback(void(*callback)(void *), void *data)
Sets a callback which is called whenever the application is brought to the background.
KORE_FUNC bool kore_debugger_attached(void)
Returns whether a debugger is currently attached to the running program. This is not yet working thou...
KORE_FUNC const char * kore_language(void)
Returns the current system-language.
KORE_FUNC void kore_set_drop_files_callback(void(*callback)(wchar_t *, void *), void *data)
Sets a callback which is called when files are dropped on the application-window.
KORE_FUNC void kore_set_safe_zone(float value)
Sets the safe-zone for systems which return false for kore_automatic_safe_zone.
KORE_FUNC void kore_set_pause_callback(void(*callback)(void *), void *data)
Sets a callback which is called whenever the application is paused.
KORE_FUNC float kore_safe_zone(void)
Returns the portion of the screen which can be safely used for important content. This is mostly rele...
KORE_FUNC void kore_set_paste_callback(void(*callback)(char *, void *), void *data)
Sets a callback which is called when the application is instructed to paste, typically via ctrl+v or ...
KORE_FUNC void kore_start(void)
Starts Kore's main-loop. kore_set_update_callback should be called before kore_start so the main-loop...
KORE_FUNC void kore_set_resume_callback(void(*callback)(void *), void *data)
Sets a callback which is called whenever the application was paused and is being resumed.
KORE_FUNC void kore_set_keep_screen_on(bool on)
Instructs the system whether it is allowed to turn off the screen while the application is running.
KORE_FUNC void kore_set_logout_callback(void(*callback)(void *), void *data)
Sets a callback which is called when a user logs out.
KORE_FUNC void kore_LivePP_start(void)
Currently only supported on Windows. Starts up Live++ (see https://liveplusplus.tech),...
KORE_FUNC double kore_time(void)
Returns the current time. This can also be calculated ala kore_timestamp() / kore_frequency() but kor...
KORE_FUNC void kore_vibrate(int milliseconds)
Vibrates the whole system if supported. This is primarily supported on mobile phones but don't blame ...
KORE_FUNC void kore_set_cut_callback(char *(*callback)(void *), void *data)
Sets a callback which is called when the application is instructed to cut, typically via ctrl+x or cm...
KORE_FUNC bool kore_waiting_for_login(void)
Returns true if kore_login was called and the login-process is still ongoing.
KORE_FUNC int kore_init(const char *name, int width, int height, struct kore_window_parameters *win, struct kore_framebuffer_parameters *frame)
Initializes a Kore application and creates an initial window for systems which support windows (syste...
KORE_FUNC void kore_load_url(const char *url)
Instruct the system to load up the provided URL which will usually open it in the system's default br...
KORE_FUNC void kore_set_application_name(const char *name)
Changes the application-name that was initially set by kore_init.
KORE_FUNC void kore_disallow_user_change(void)
Disallows the system to logout the current user.
KORE_FUNC void kore_login(void)
Instructs the system to login a user if that is supported.
KORE_FUNC bool kore_automatic_safe_zone(void)
Returns whether the system itself handles configuration of the safe-zone.
KORE_FUNC void kore_set_update_callback(void(*callback)(void *), void *data)
Sets the update-callback which drives the application and is called for every frame.
static void kore_marker_start(const char *name, uint32_t color)
Starts a marker for profiling. Please match it with a marker_end-call in the same function.
Definition system.h:307
KORE_FUNC const char * kore_application_name(void)
Returns the current application name as set by kore_init or kore_set_application_name.