// =====================================================================================================================
//  fennec, a free and open source game engine
//  Copyright © 2025 - 2026  Medusa Slockbower
//
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <https://www.gnu.org/licenses/>.
// =====================================================================================================================

#include <fennec/lang/types.h>

#ifndef FENNEC_LIB
#define FENNEC_LIB(...)
#endif

#ifndef FENNEC_SYMBOL
#define FENNEC_SYMBOL(...)
#endif

#ifndef FENNEC_GLOBAL
#define FENNEC_GLOBAL(...)
#endif

FENNEC_LIB(XKB);

FENNEC_SYMBOL(int,          xkb_keysym_get_name,  xkb_keysym_t, char*, size_t);
FENNEC_SYMBOL(xkb_keysym_t, xkb_keysym_from_name, const char*, enum xkb_keysym_flags);
FENNEC_SYMBOL(int,          xkb_keysym_to_utf8,   xkb_keysym_t, char*, size_t);
FENNEC_SYMBOL(uint32_t,     xkb_keysym_to_utf32,  xkb_keysym_t);
FENNEC_SYMBOL(xkb_keysym_t, xkb_utf32_to_keysym,  uint32_t);
FENNEC_SYMBOL(xkb_keysym_t, xkb_keysym_to_upper,  xkb_keysym_t);
FENNEC_SYMBOL(xkb_keysym_t, xkb_keysym_to_lower,  xkb_keysym_t);

FENNEC_SYMBOL(struct xkb_context*, xkb_context_new,                         enum   xkb_context_flags);
FENNEC_SYMBOL(struct xkb_context*, xkb_context_ref,                         struct xkb_context*);
FENNEC_SYMBOL(void,                xkb_context_unref,                       struct xkb_context*);
FENNEC_SYMBOL(void,                xkb_context_set_user_data,               struct xkb_context*, void*);
FENNEC_SYMBOL(void*,               xkb_context_get_user_data,               struct xkb_context*);
FENNEC_SYMBOL(int,                 xkb_context_include_path_append,         struct xkb_context*, const char*);
FENNEC_SYMBOL(int,                 xkb_context_include_path_append_default, struct xkb_context*);
FENNEC_SYMBOL(int,                 xkb_context_include_path_reset_defaults, struct xkb_context*);
FENNEC_SYMBOL(void,                xkb_context_include_path_clear,          struct xkb_context*);
FENNEC_SYMBOL(unsigned int,        xkb_context_num_include_paths,           struct xkb_context*);
FENNEC_SYMBOL(const char*,         xkb_context_include_path_get,            struct xkb_context*, unsigned int);
FENNEC_SYMBOL(void,                xkb_context_set_log_level,               struct xkb_context*, enum xkb_log_level);
FENNEC_SYMBOL(enum xkb_log_level,  xkb_context_get_log_level,               struct xkb_context*);
FENNEC_SYMBOL(void,                xkb_context_set_log_verbosity,           struct xkb_context*, int);
FENNEC_SYMBOL(int,                 xkb_context_get_log_verbosity,           struct xkb_context*);
FENNEC_SYMBOL(void,                xkb_context_set_log_fn,                  struct xkb_context*, void (*)(struct xkb_context*, enum xkb_log_level, const char*, va_list));

FENNEC_SYMBOL(struct xkb_keymap*, xkb_keymap_new_from_names,         struct xkb_context*, const struct xkb_rule_names*, enum xkb_keymap_compile_flags);
FENNEC_SYMBOL(struct xkb_keymap*, xkb_keymap_new_from_file,          struct xkb_context*, FILE*, enum xkb_keymap_format, enum xkb_keymap_compile_flags);
FENNEC_SYMBOL(struct xkb_keymap*, xkb_keymap_new_from_string,        struct xkb_context*, const char*, enum xkb_keymap_format, enum xkb_keymap_compile_flags);
FENNEC_SYMBOL(struct xkb_keymap*, xkb_keymap_new_from_buffer,        struct xkb_context*, const char*, size_t, enum xkb_keymap_format, enum xkb_keymap_compile_flags);
FENNEC_SYMBOL(struct xkb_keymap*, xkb_keymap_ref,                    struct xkb_keymap*);
FENNEC_SYMBOL(void,               xkb_keymap_unref,                  struct xkb_keymap*);
FENNEC_SYMBOL(char*,              xkb_keymap_get_as_string,          struct xkb_keymap*, enum xkb_keymap_format);
FENNEC_SYMBOL(xkb_keycode_t,      xkb_keymap_min_keycode,            struct xkb_keymap*);
FENNEC_SYMBOL(xkb_keycode_t,      xkb_keymap_max_keycode,            struct xkb_keymap*);
FENNEC_SYMBOL(void,               xkb_keymap_key_for_each,           struct xkb_keymap*, xkb_keymap_key_iter_t, void*);
FENNEC_SYMBOL(const char*,        xkb_keymap_key_get_name,           struct xkb_keymap*, xkb_keycode_t);
FENNEC_SYMBOL(xkb_keycode_t,      xkb_keymap_key_by_name,            struct xkb_keymap*, const char*);
FENNEC_SYMBOL(xkb_mod_index_t,    xkb_keymap_num_mods,               struct xkb_keymap*);
FENNEC_SYMBOL(const char*,        xkb_keymap_mod_get_name,           struct xkb_keymap*, xkb_mod_index_t);
FENNEC_SYMBOL(xkb_mod_index_t,    xkb_keymap_mod_get_index,          struct xkb_keymap*, const char*);
FENNEC_SYMBOL(xkb_layout_index_t, xkb_keymap_num_layouts,            struct xkb_keymap*);
FENNEC_SYMBOL(const char*,        xkb_keymap_layout_get_name,        struct xkb_keymap*, xkb_layout_index_t);
FENNEC_SYMBOL(xkb_layout_index_t, xkb_keymap_layout_get_index,       struct xkb_keymap*, const char*);
FENNEC_SYMBOL(xkb_led_index_t,    xkb_keymap_num_leds,               struct xkb_keymap*);
FENNEC_SYMBOL(const char*,        xkb_keymap_led_get_name,           struct xkb_keymap*, xkb_led_index_t);
FENNEC_SYMBOL(xkb_led_index_t,    xkb_keymap_led_get_index,          struct xkb_keymap*, const char*);
FENNEC_SYMBOL(xkb_layout_index_t, xkb_keymap_num_layouts_for_key,    struct xkb_keymap*, xkb_keycode_t);
FENNEC_SYMBOL(xkb_level_index_t,  xkb_keymap_num_levels_for_key,     struct xkb_keymap*, xkb_keycode_t, xkb_layout_index_t);
FENNEC_SYMBOL(size_t,             xkb_keymap_key_get_mods_for_level, struct xkb_keymap*, xkb_keycode_t, xkb_layout_index_t, xkb_level_index_t, xkb_mod_mask_t*, size_t);
FENNEC_SYMBOL(int,                xkb_keymap_key_get_syms_by_level,  struct xkb_keymap*, xkb_keycode_t, xkb_layout_index_t, xkb_level_index_t, const xkb_keysym_t**);
FENNEC_SYMBOL(int,                xkb_keymap_key_repeats,            struct xkb_keymap*, xkb_keycode_t);

FENNEC_SYMBOL(struct xkb_state*,        xkb_state_new,                      struct xkb_keymap*);
FENNEC_SYMBOL(struct xkb_state*,        xkb_state_ref,                      struct xkb_state*);
FENNEC_SYMBOL(void,                     xkb_state_unref,                    struct xkb_state*);
FENNEC_SYMBOL(struct xkb_keymap*,       xkb_state_get_keymap,               struct xkb_state*);
FENNEC_SYMBOL(enum xkb_state_component, xkb_state_update_key,               struct xkb_state*, xkb_keycode_t, enum xkb_key_direction);
FENNEC_SYMBOL(enum xkb_state_component, xkb_state_update_mask,              struct xkb_state*, xkb_mod_mask_t, xkb_mod_mask_t, xkb_mod_mask_t, xkb_layout_index_t, xkb_layout_index_t, xkb_layout_index_t);
FENNEC_SYMBOL(int,                      xkb_state_key_get_syms,             struct xkb_state*, xkb_keycode_t, const xkb_keysym_t**);
FENNEC_SYMBOL(int,                      xkb_state_key_get_utf8,             struct xkb_state*, xkb_keycode_t, char*, size_t);
FENNEC_SYMBOL(uint32_t,                 xkb_state_key_get_utf32,            struct xkb_state*, xkb_keycode_t);
FENNEC_SYMBOL(xkb_keysym_t,             xkb_state_key_get_one_sym,          struct xkb_state*, xkb_keycode_t);
FENNEC_SYMBOL(xkb_layout_index_t,       xkb_state_key_get_layout,           struct xkb_state*, xkb_keycode_t);
FENNEC_SYMBOL(xkb_level_index_t,        xkb_state_key_get_level,            struct xkb_state*, xkb_keycode_t, xkb_layout_index_t);
FENNEC_SYMBOL(xkb_mod_mask_t,           xkb_state_serialize_mods,           struct xkb_state*, enum xkb_state_component);
FENNEC_SYMBOL(xkb_layout_index_t,       xkb_state_serialize_layout,         struct xkb_state*, enum xkb_state_component);
FENNEC_SYMBOL(int,                      xkb_state_mod_name_is_active,       struct xkb_state*, const char*, enum xkb_state_component);
FENNEC_SYMBOL(int,                      xkb_state_mod_names_are_active,     struct xkb_state*, enum xkb_state_component, enum xkb_state_match, ...);
FENNEC_SYMBOL(int,                      xkb_state_mod_index_is_active,      struct xkb_state*, xkb_mod_index_t, enum xkb_state_component);
FENNEC_SYMBOL(int,                      xkb_state_mod_indices_are_active,   struct xkb_state*, enum xkb_state_component, enum xkb_state_match, ...);
FENNEC_SYMBOL(xkb_mod_mask_t,           xkb_state_key_get_consumed_mods2,   struct xkb_state*, xkb_keycode_t, enum xkb_consumed_mode);
FENNEC_SYMBOL(xkb_mod_mask_t,           xkb_state_key_get_consumed_mods,    struct xkb_state*, xkb_keycode_t);
FENNEC_SYMBOL(int,                      xkb_state_mod_index_is_consumed2,   struct xkb_state*, xkb_keycode_t, xkb_mod_index_t, enum xkb_consumed_mode);
FENNEC_SYMBOL(int,                      xkb_state_mod_index_is_consumed,    struct xkb_state*, xkb_keycode_t, xkb_mod_index_t);
FENNEC_SYMBOL(xkb_mod_mask_t,           xkb_state_mod_mask_remove_consumed, struct xkb_state*, xkb_keycode_t, xkb_mod_mask_t);
FENNEC_SYMBOL(int,                      xkb_state_layout_name_is_active,    struct xkb_state*, const char*, enum xkb_state_component);
FENNEC_SYMBOL(int,                      xkb_state_layout_index_is_active,   struct xkb_state*, xkb_layout_index_t, enum xkb_state_component);
FENNEC_SYMBOL(int,                      xkb_state_led_name_is_active,       struct xkb_state*, const char*);
FENNEC_SYMBOL(int,                      xkb_state_led_index_is_active,      struct xkb_state*, xkb_led_index_t);

#undef FENNEC_LIB
#undef FENNEC_SYMBOL
#undef FENNEC_GLOBAL
