diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-11-08 02:07:23 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-11-08 02:07:23 +0100 |
commit | e3c90b41386986ef53e512994d6e2f7ceadfc177 (patch) | |
tree | 6fc1ad55e194a1c7663de3f2c9f178b1f67f2695 /include | |
parent | 16b0ce3748f1b3ea788bbaf4caaeb342a8f58d6f (diff) |
Add window function to get key state, allow invalid utf8
Diffstat (limited to 'include')
-rw-r--r-- | include/mgl/graphics/text.h | 1 | ||||
-rw-r--r-- | include/mgl/system/utf8.h | 8 | ||||
-rw-r--r-- | include/mgl/window/key.h | 5 | ||||
-rw-r--r-- | include/mgl/window/window.h | 2 |
4 files changed, 7 insertions, 9 deletions
diff --git a/include/mgl/graphics/text.h b/include/mgl/graphics/text.h index aca0650..2311d23 100644 --- a/include/mgl/graphics/text.h +++ b/include/mgl/graphics/text.h @@ -34,7 +34,6 @@ void mgl_text_deinit(mgl_text *self); /* Note: keeps a reference to |text|. |text| needs to be valid as long as |self| is used. |text| may be NULL. - |str| will be checked if its a valid utf8 string. */ int mgl_text_set_string(mgl_text *self, const char *str, size_t str_size); /* |font| may be NULL */ diff --git a/include/mgl/system/utf8.h b/include/mgl/system/utf8.h index 663e7e3..f745be7 100644 --- a/include/mgl/system/utf8.h +++ b/include/mgl/system/utf8.h @@ -5,13 +5,7 @@ #include <stdint.h> #include <stdbool.h> -bool mgl_utf8_is_valid(const unsigned char *str, size_t size); - -/* - Returns the byte length of the decoded codepoint. - Note: does not validate if the input |str| is a valid utf8 string. -*/ -size_t mgl_utf8_decode(const unsigned char *str, uint32_t *decoded_codepoint); +bool mgl_utf8_decode(const unsigned char *str, size_t size, uint32_t *decoded_codepoint, size_t *codepoint_length); #endif /* MGL_UTF8_H */ diff --git a/include/mgl/window/key.h b/include/mgl/window/key.h index 90a3366..0cd3c03 100644 --- a/include/mgl/window/key.h +++ b/include/mgl/window/key.h @@ -103,7 +103,10 @@ typedef enum { MGL_KEY_F13, MGL_KEY_F14, MGL_KEY_F15, - MGL_KEY_PAUSE + MGL_KEY_PAUSE, + + /* This should always be the last key */ + __MGL_NUM_KEYS__ } mgl_key; #endif /* _MGL_KEY_H_ */ diff --git a/include/mgl/window/window.h b/include/mgl/window/window.h index 9d7086c..c6fce87 100644 --- a/include/mgl/window/window.h +++ b/include/mgl/window/window.h @@ -3,6 +3,7 @@ #include "../graphics/color.h" #include "../system/vec.h" +#include "key.h" #include <stdbool.h> /* Vsync is automatically set for created windows, if supported by the system */ @@ -48,5 +49,6 @@ void mgl_window_set_view(mgl_window *self, mgl_view *new_view); void mgl_window_get_view(mgl_window *self, mgl_view *view); bool mgl_window_is_open(const mgl_window *self); +bool mgl_window_is_key_pressed(const mgl_window *self, mgl_key key); #endif /* MGL_WINDOW_H */ |