diff options
| author | Mitchell Hashimoto <mitchell.hashimoto@gmail.com> | 2023-02-17 22:12:03 -0800 |
|---|---|---|
| committer | Mitchell Hashimoto <mitchell.hashimoto@gmail.com> | 2023-02-19 10:44:56 -0800 |
| commit | 573b163636d5c76ff2592d07bfdff434d2671dd0 (patch) | |
| tree | 2abd8d8ca99a8979d72ac0d03cdb9d8a944f837d /include | |
| parent | 074664398a1c30f1f75bb8f363a86234b927150c (diff) | |
start input, its broken but we're getting there
Diffstat (limited to 'include')
| -rw-r--r-- | include/ghostty.h | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/include/ghostty.h b/include/ghostty.h index 5bf1fd588..c7d65e4b0 100644 --- a/include/ghostty.h +++ b/include/ghostty.h @@ -14,8 +14,19 @@ extern "C" { #include <stdint.h> +//------------------------------------------------------------------- +// Macros + #define GHOSTTY_SUCCESS 0 +// Masks for input modifiers +#define GHOSTTY_INPUT_SHIFT 1 +#define GHOSTTY_INPUT_CTRL 2 +#define GHOSTTY_INPUT_ALT 4 +#define GHOSTTY_INPUT_SUPER 8 +#define GHOSTTY_INPUT_CAPS 16 +#define GHOSTTY_INPUT_NUM 32 + //------------------------------------------------------------------- // Types @@ -23,15 +34,153 @@ extern "C" { // structs. To find the Zig struct, grep for this type name. The documentation // for all of these types is available in the Zig source. typedef void (*ghostty_runtime_wakeup_cb)(void *); + typedef struct { void *userdata; ghostty_runtime_wakeup_cb wakeup_cb; } ghostty_runtime_config_s; + typedef struct { void *nsview; double scale_factor; } ghostty_surface_config_s; +typedef enum { release, press, repeat } ghostty_input_action_e; +typedef enum { + invalid, + + // a-z + a, + b, + c, + d, + e, + f, + g, + h, + i, + j, + k, + l, + m, + n, + o, + p, + q, + r, + s, + t, + u, + v, + w, + x, + y, + z, + + // numbers + zero, + one, + two, + three, + four, + five, + six, + seven, + eight, + nine, + + // puncuation + semicolon, + space, + apostrophe, + comma, + grave_accent, // ` + period, + slash, + minus, + equal, + left_bracket, // [ + right_bracket, // ] + backslash, // / + + // control + up, + down, + right, + left, + home, + end, + insert, + delete, + caps_lock, + scroll_lock, + num_lock, + page_up, + page_down, + escape, + enter, + tab, + backspace, + print_screen, + pause, + + // function keys + f1, + f2, + f3, + f4, + f5, + f6, + f7, + f8, + f9, + f10, + f11, + f12, + f13, + f14, + f15, + f16, + f17, + f18, + f19, + f20, + f21, + f22, + f23, + f24, + f25, + + // keypad + kp_0, + kp_1, + kp_2, + kp_3, + kp_4, + kp_5, + kp_6, + kp_7, + kp_8, + kp_9, + kp_decimal, + kp_divide, + kp_multiply, + kp_subtract, + kp_add, + kp_enter, + kp_equal, + + // modifiers + left_shift, + left_control, + left_alt, + left_super, + right_shift, + right_control, + right_alt, + right_super, +} ghostty_input_key_e; + // Opaque types typedef void *ghostty_app_t; typedef void *ghostty_config_t; @@ -56,6 +205,7 @@ void ghostty_surface_free(ghostty_surface_t); void ghostty_surface_refresh(ghostty_surface_t); void ghostty_surface_set_content_scale(ghostty_surface_t, double, double); void ghostty_surface_set_size(ghostty_surface_t, uint32_t, uint32_t); +void ghostty_surface_key(ghostty_surface_t, ghostty_input_action_e, ghostty_input_key_e, uint8_t); #ifdef __cplusplus } |
