Kore
Loading...
Searching...
No Matches
system.h File Reference

Provides basic system and application-management functionality which doesn't fit anywhere else. More...

#include <kinc/global.h>
#include <kinc/log.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Typedefs

typedef uint64_t kinc_ticks_t

Functions

KINC_FUNC int kinc_init (const char *name, int width, int height, struct kinc_window_options *win, struct kinc_framebuffer_options *frame)
 Initializes a Kinc application and creates an initial window for systems which support windows (systems which do not support windows are treated as if the would provide a single window which cannot change). This has to be called before any other Kinc-function with the exception of the Display-API which can optionally be initialized beforehand using kinc_display_init.
KINC_FUNC const char * kinc_application_name (void)
 Returns the current application name as set by kinc_init or kinc_set_application_name.
KINC_FUNC void kinc_set_application_name (const char *name)
 Changes the application-name that was initially set by kinc_init.
KINC_FUNC int kinc_width (void)
 Returns the current width of the initial application-window which is equivalent to calling kinc_window_width(0).
KINC_FUNC int kinc_height (void)
 Returns the current height of the initial application-window which is equivalent to calling kinc_window_height(0).
KINC_FUNC void kinc_load_url (const char *url)
 Instruct the system to load up the provided URL which will usually open it in the system's default browser.
KINC_FUNC const char * kinc_system_id (void)
 Returns an ID representing the current type of target-system.
KINC_FUNC const char * kinc_language (void)
 Returns the current system-language.
KINC_FUNC void kinc_vibrate (int milliseconds)
 Vibrates the whole system if supported. This is primarily supported on mobile phones but don't blame us if your computer falls over.
KINC_FUNC float kinc_safe_zone (void)
 Returns the portion of the screen which can be safely used for important content. This is mostly relevant for TVs which often scale the image by default and thefore cut off some of the content.
KINC_FUNC bool kinc_automatic_safe_zone (void)
 Returns whether the system itself handles configuration of the safe-zone.
KINC_FUNC void kinc_set_safe_zone (float value)
 Sets the safe-zone for systems which return false for kinc_automatic_safe_zone.
KINC_FUNC double kinc_frequency (void)
 Returns the frequency of system-timestamps.
KINC_FUNC kinc_ticks_t kinc_timestamp (void)
 Returns a timestamp for right now in a system-specific unit.
KINC_FUNC int kinc_cpu_cores (void)
 Returns the number of proper CPU-cores (not the number of hardware-threads).
KINC_FUNC int kinc_hardware_threads (void)
 Returns the number of hardware-threads.
KINC_FUNC double kinc_time (void)
 Returns the current time. This can also be calculated ala kinc_timestamp() / kinc_frequency() but kinc_time is a little more precise on some systems.
KINC_FUNC void kinc_start (void)
 Starts Kinc's main-loop. kinc_set_update_callback should be called before kinc_start so the main-loop actually has something to do.
KINC_FUNC void kinc_stop (void)
 Stops Kinc's main loop and thereby returns to the function which called kinc_start.
KINC_FUNC void kinc_login (void)
 Instructs the system to login a user if that is supported.
KINC_FUNC bool kinc_waiting_for_login (void)
 Returns true if kinc_login was called and the login-process is still ongoing.
KINC_FUNC void kinc_unlock_achievement (int id)
 Unlocks an achievement or trophy or however you prefer to call it.
KINC_FUNC void kinc_disallow_user_change (void)
 Disallows the system to logout the current user.
KINC_FUNC void kinc_allow_user_change (void)
 Allows the system to logout the current user.
KINC_FUNC void kinc_set_keep_screen_on (bool on)
 Instructs the system whether it is allowed to turn off the screen while the application is running.
KINC_INLINE void kinc_debug_break (void)
 Tries to halt program-execution in an attached debugger when compiled in debug-mode (aka when NDEBUG is not defined).
KINC_FUNC bool kinc_debugger_attached (void)
 Returns whether a debugger is currently attached to the running program. This is not yet working though.
KINC_FUNC void kinc_copy_to_clipboard (const char *text)
 Copies the provided string to the system's clipboard.
KINC_FUNC void kinc_set_update_callback (void(*callback)(void *), void *data)
 Sets the update-callback which drives the application and is called for every frame.
KINC_FUNC void kinc_set_foreground_callback (void(*callback)(void *), void *data)
 Sets a callback which is called whenever the application is brought to the foreground.
KINC_FUNC void kinc_set_resume_callback (void(*callback)(void *), void *data)
 Sets a callback which is called whenever the application was paused and is being resumed.
KINC_FUNC void kinc_set_pause_callback (void(*callback)(void *), void *data)
 Sets a callback which is called whenever the application is paused.
KINC_FUNC void kinc_set_background_callback (void(*callback)(void *), void *data)
 Sets a callback which is called whenever the application is brought to the background.
KINC_FUNC void kinc_set_shutdown_callback (void(*callback)(void *), void *data)
 Sets a callback which is called whenever the application is about to shut down.
KINC_FUNC void kinc_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.
KINC_FUNC void kinc_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 cmd+x. Kinc does not take ownership of the provided string.
KINC_FUNC void kinc_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 cmd+c. Kinc does not take ownership of the provided string.
KINC_FUNC void kinc_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 cmd+v. The provided string is only valid during the callback-call - copy it if you want to keep it.
KINC_FUNC void kinc_set_login_callback (void(*callback)(void *), void *data)
 Sets a callback which is called when a user logs in.
KINC_FUNC void kinc_set_logout_callback (void(*callback)(void *), void *data)
 Sets a callback which is called when a user logs out.
static void kinc_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.
static void kinc_marker_end (const char *name)
 Ends the previously started marker of the same function.
KINC_FUNC void kinc_LivePP_start (void)
 Currently only supported on Windows. Starts up Live++ (see https://liveplusplus.tech), typically called right before kinc_start(). After calling this you can hit Ctrl+Alt+F11 to hot-reload. Call Project.addLivePP(path) in your kfile to make this do something. The path-parameter for addLivePP is the path to the unpacked Live++-archive that has to contain a LivePP-subdirectory. This will set the appropricate compiler- and linker-options and set the KINC_LIVEPP-define for the Debug- and Develop-configs (it does not touch the Release-config).
KINC_FUNC void kinc_LivePP_stop (void)
 Stops Live++, typically called right after kinc_start().

Detailed Description

Provides basic system and application-management functionality which doesn't fit anywhere else.

Function Documentation

◆ kinc_application_name()

KINC_FUNC const char * kinc_application_name ( void )

Returns the current application name as set by kinc_init or kinc_set_application_name.

Returns
The current name of the application

◆ kinc_automatic_safe_zone()

KINC_FUNC bool kinc_automatic_safe_zone ( void )

Returns whether the system itself handles configuration of the safe-zone.

Returns
Whether the safe-zone is handlet by the syste

◆ kinc_copy_to_clipboard()

KINC_FUNC void kinc_copy_to_clipboard ( const char * text)

Copies the provided string to the system's clipboard.

Parameters
textThe text to be copied into the clipboard

◆ kinc_cpu_cores()

KINC_FUNC int kinc_cpu_cores ( void )

Returns the number of proper CPU-cores (not the number of hardware-threads).

Returns
Number of cores

◆ kinc_debugger_attached()

KINC_FUNC bool kinc_debugger_attached ( void )

Returns whether a debugger is currently attached to the running program. This is not yet working though.

Returns
Whether a debugger is currently attached

◆ kinc_frequency()

KINC_FUNC double kinc_frequency ( void )

Returns the frequency of system-timestamps.

Returns
The frequency of the system's timestamps in 1 / second

◆ kinc_hardware_threads()

KINC_FUNC int kinc_hardware_threads ( void )

Returns the number of hardware-threads.

Returns
Number of hardware-threads

◆ kinc_height()

KINC_FUNC int kinc_height ( void )

Returns the current height of the initial application-window which is equivalent to calling kinc_window_height(0).

Returns
The height of the initial window

◆ kinc_init()

KINC_FUNC int kinc_init ( const char * name,
int width,
int height,
struct kinc_window_options * win,
struct kinc_framebuffer_options * frame )

Initializes a Kinc application and creates an initial window for systems which support windows (systems which do not support windows are treated as if the would provide a single window which cannot change). This has to be called before any other Kinc-function with the exception of the Display-API which can optionally be initialized beforehand using kinc_display_init.

Returns
The id of the initial window

◆ kinc_language()

KINC_FUNC const char * kinc_language ( void )

Returns the current system-language.

Returns
The current system-language as a two-letter language code

◆ kinc_LivePP_start()

KINC_FUNC void kinc_LivePP_start ( void )

Currently only supported on Windows. Starts up Live++ (see https://liveplusplus.tech), typically called right before kinc_start(). After calling this you can hit Ctrl+Alt+F11 to hot-reload. Call Project.addLivePP(path) in your kfile to make this do something. The path-parameter for addLivePP is the path to the unpacked Live++-archive that has to contain a LivePP-subdirectory. This will set the appropricate compiler- and linker-options and set the KINC_LIVEPP-define for the Debug- and Develop-configs (it does not touch the Release-config).

Returns

◆ kinc_LivePP_stop()

KINC_FUNC void kinc_LivePP_stop ( void )

Stops Live++, typically called right after kinc_start().

Returns

◆ kinc_load_url()

KINC_FUNC void kinc_load_url ( const char * url)

Instruct the system to load up the provided URL which will usually open it in the system's default browser.

Parameters
urlThe URL to open

◆ kinc_marker_start()

void kinc_marker_start ( const char * name,
uint32_t color )
inlinestatic

Starts a marker for profiling. Please match it with a marker_end-call in the same function.

Parameters
nameA unique name that will be shown in the profiler
colorA nice color in RGBX that will show up in the profiler

◆ kinc_safe_zone()

KINC_FUNC float kinc_safe_zone ( void )

Returns the portion of the screen which can be safely used for important content. This is mostly relevant for TVs which often scale the image by default and thefore cut off some of the content.

Returns
The safe-zone which can be multiplied with the width or height of the display to convert it to pixels

◆ kinc_set_application_name()

KINC_FUNC void kinc_set_application_name ( const char * name)

Changes the application-name that was initially set by kinc_init.

Parameters
nameThe new application-name

◆ kinc_set_background_callback()

KINC_FUNC void kinc_set_background_callback ( void(* callback )(void *),
void * data )

Sets a callback which is called whenever the application is brought to the background.

Parameters
callbackThe background-callback
dataArbitrary data-pointer that's passed to the callback

◆ kinc_set_copy_callback()

KINC_FUNC void kinc_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 cmd+c. Kinc does not take ownership of the provided string.

Parameters
callbackThe copy-callback
dataArbitrary data-pointer that's passed to the callback

◆ kinc_set_cut_callback()

KINC_FUNC void kinc_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 cmd+x. Kinc does not take ownership of the provided string.

Parameters
callbackThe cut-callback
dataArbitrary data-pointer that's passed to the callback

◆ kinc_set_drop_files_callback()

KINC_FUNC void kinc_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.

Parameters
callbackThe drop-files-callback
dataArbitrary data-pointer that's passed to the callback

◆ kinc_set_foreground_callback()

KINC_FUNC void kinc_set_foreground_callback ( void(* callback )(void *),
void * data )

Sets a callback which is called whenever the application is brought to the foreground.

Parameters
callbackThe foreground-callback
dataArbitrary data-pointer that's passed to the callback

◆ kinc_set_keep_screen_on()

KINC_FUNC void kinc_set_keep_screen_on ( bool on)

Instructs the system whether it is allowed to turn off the screen while the application is running.

Parameters
onWhether turning off the screen is allowed

◆ kinc_set_login_callback()

KINC_FUNC void kinc_set_login_callback ( void(* callback )(void *),
void * data )

Sets a callback which is called when a user logs in.

Parameters
callbackThe login-callback
dataArbitrary data-pointer that's passed to the callback

◆ kinc_set_logout_callback()

KINC_FUNC void kinc_set_logout_callback ( void(* callback )(void *),
void * data )

Sets a callback which is called when a user logs out.

Parameters
callbackThe logout-callback
dataArbitrary data-pointer that's passed to the callback

◆ kinc_set_paste_callback()

KINC_FUNC void kinc_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 cmd+v. The provided string is only valid during the callback-call - copy it if you want to keep it.

Parameters
callbackThe paste-callback
dataArbitrary data-pointer that's passed to the callback

◆ kinc_set_pause_callback()

KINC_FUNC void kinc_set_pause_callback ( void(* callback )(void *),
void * data )

Sets a callback which is called whenever the application is paused.

Parameters
callbackThe pause-callback
dataArbitrary data-pointer that's passed to the callback

◆ kinc_set_resume_callback()

KINC_FUNC void kinc_set_resume_callback ( void(* callback )(void *),
void * data )

Sets a callback which is called whenever the application was paused and is being resumed.

Parameters
callbackThe resume-callback
dataArbitrary data-pointer that's passed to the callback

◆ kinc_set_safe_zone()

KINC_FUNC void kinc_set_safe_zone ( float value)

Sets the safe-zone for systems which return false for kinc_automatic_safe_zone.

Parameters
valueThe safe-zone for width and height as a ratio of the full display-resolution.

◆ kinc_set_shutdown_callback()

KINC_FUNC void kinc_set_shutdown_callback ( void(* callback )(void *),
void * data )

Sets a callback which is called whenever the application is about to shut down.

Parameters
callbackThe shutdown-callback
dataArbitrary data-pointer that's passed to the callback

◆ kinc_set_update_callback()

KINC_FUNC void kinc_set_update_callback ( void(* callback )(void *),
void * data )

Sets the update-callback which drives the application and is called for every frame.

Parameters
callbackThe callback
dataArbitrary data-pointer that's passed to the callback

◆ kinc_system_id()

KINC_FUNC const char * kinc_system_id ( void )

Returns an ID representing the current type of target-system.

Returns
The ID representing the target system

◆ kinc_time()

KINC_FUNC double kinc_time ( void )

Returns the current time. This can also be calculated ala kinc_timestamp() / kinc_frequency() but kinc_time is a little more precise on some systems.

Returns
The current time in seconds

◆ kinc_timestamp()

KINC_FUNC kinc_ticks_t kinc_timestamp ( void )

Returns a timestamp for right now in a system-specific unit.

Returns
The current timestamp

◆ kinc_unlock_achievement()

KINC_FUNC void kinc_unlock_achievement ( int id)

Unlocks an achievement or trophy or however you prefer to call it.

Parameters
idThe id of the achievement/tropy

◆ kinc_waiting_for_login()

KINC_FUNC bool kinc_waiting_for_login ( void )

Returns true if kinc_login was called and the login-process is still ongoing.

Returns
Whether a login-process is still in progress

◆ kinc_width()

KINC_FUNC int kinc_width ( void )

Returns the current width of the initial application-window which is equivalent to calling kinc_window_width(0).

Returns
The width of the initial window