// =====================================================================================================================
//  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/>.
// =====================================================================================================================

#ifndef FENNEC_PLATFORM_LINUX_XKB_LIB_XKB_H
#define FENNEC_PLATFORM_LINUX_XKB_LIB_XKB_H

#include <xkbcommon/xkbcommon.h>

#define FENNEC_LIB(name)            extern bool FENNEC_HAS_LIB_##name;
#define FENNEC_SYMBOL(ret, fn, ...) using XKB_sym_##fn = ret(*)(__VA_ARGS__); \
                                    extern XKB_sym_##fn XKB_##fn;
#define FENNEC_GLOBAL(type, name)   extern type* XKB_##name;
#include <fennec/platform/linux/xkb/lib/sym.h>

#define xkb_keysym_get_name  XKB_xkb_keysym_get_name
#define xkb_keysym_from_name XKB_xkb_keysym_from_name
#define xkb_keysym_to_utf8   XKB_xkb_keysym_to_utf8
#define xkb_keysym_to_utf32  XKB_xkb_keysym_to_utf32
#define xkb_utf32_to_keysym  XKB_xkb_utf32_to_keysym
#define xkb_keysym_to_upper  XKB_xkb_keysym_to_upper
#define xkb_keysym_to_lower  XKB_xkb_keysym_to_lower

#define xkb_context_new                         XKB_xkb_context_new
#define xkb_context_ref                         XKB_xkb_context_ref
#define xkb_context_unref                       XKB_xkb_context_unref
#define xkb_context_set_user_data               XKB_xkb_context_set_user_data
#define xkb_context_get_user_data               XKB_xkb_context_get_user_data
#define xkb_context_include_path_append         XKB_xkb_context_include_path_append
#define xkb_context_include_path_append_default XKB_xkb_context_include_path_append_default
#define xkb_context_include_path_reset_defaults XKB_xkb_context_include_path_reset_defaults
#define xkb_context_include_path_clear          XKB_xkb_context_include_path_clear
#define xkb_context_num_include_paths           XKB_xkb_context_num_include_paths
#define xkb_context_include_path_get            XKB_xkb_context_include_path_get
#define xkb_context_set_log_level               XKB_xkb_context_set_log_level
#define xkb_context_get_log_level               XKB_xkb_context_get_log_level
#define xkb_context_set_log_verbosity           XKB_xkb_context_set_log_verbosity
#define xkb_context_get_log_verbosity           XKB_xkb_context_get_log_verbosity
#define xkb_context_set_log_fn                  XKB_xkb_context_set_log_fn

#define xkb_keymap_new_from_names         XKB_xkb_keymap_new_from_names
#define xkb_keymap_new_from_file          XKB_xkb_keymap_new_from_file
#define xkb_keymap_new_from_string        XKB_xkb_keymap_new_from_string
#define xkb_keymap_new_from_buffer        XKB_xkb_keymap_new_from_buffer
#define xkb_keymap_ref                    XKB_xkb_keymap_ref
#define xkb_keymap_unref                  XKB_xkb_keymap_unref
#define xkb_keymap_get_as_string          XKB_xkb_keymap_get_as_string
#define xkb_keymap_min_keycode            XKB_xkb_keymap_min_keycode
#define xkb_keymap_max_keycode            XKB_xkb_keymap_max_keycode
#define xkb_keymap_key_for_each           XKB_xkb_keymap_key_for_each
#define xkb_keymap_key_get_name           XKB_xkb_keymap_key_get_name
#define xkb_keymap_key_by_name            XKB_xkb_keymap_key_by_name
#define xkb_keymap_num_mods               XKB_xkb_keymap_num_mods
#define xkb_keymap_mod_get_name           XKB_xkb_keymap_mod_get_name
#define xkb_keymap_mod_get_index          XKB_xkb_keymap_mod_get_index
#define xkb_keymap_num_layouts            XKB_xkb_keymap_num_layouts
#define xkb_keymap_layout_get_name        XKB_xkb_keymap_layout_get_name
#define xkb_keymap_layout_get_index       XKB_xkb_keymap_layout_get_index
#define xkb_keymap_num_leds               XKB_xkb_keymap_num_leds
#define xkb_keymap_led_get_name           XKB_xkb_keymap_led_get_name
#define xkb_keymap_led_get_index          XKB_xkb_keymap_led_get_index
#define xkb_keymap_num_layouts_for_key    XKB_xkb_keymap_num_layouts_for_key
#define xkb_keymap_num_levels_for_key     XKB_xkb_keymap_num_levels_for_key
#define xkb_keymap_key_get_mods_for_level XKB_xkb_keymap_key_get_mods_for_level
#define xkb_keymap_key_get_syms_by_level  XKB_xkb_keymap_key_get_syms_by_level
#define xkb_keymap_key_repeats            XKB_xkb_keymap_key_repeats

#define xkb_state_new                      XKB_xkb_state_new
#define xkb_state_ref                      XKB_xkb_state_ref
#define xkb_state_unref                    XKB_xkb_state_unref
#define xkb_state_get_keymap               XKB_xkb_state_get_keymap
#define xkb_state_update_key               XKB_xkb_state_update_key
#define xkb_state_update_mask              XKB_xkb_state_update_mask
#define xkb_state_key_get_syms             XKB_xkb_state_key_get_syms
#define xkb_state_key_get_utf8             XKB_xkb_state_key_get_utf8
#define xkb_state_key_get_utf32            XKB_xkb_state_key_get_utf32
#define xkb_state_key_get_one_sym          XKB_xkb_state_key_get_one_sym
#define xkb_state_key_get_layout           XKB_xkb_state_key_get_layout
#define xkb_state_key_get_level            XKB_xkb_state_key_get_level
#define xkb_state_serialize_mods           XKB_xkb_state_serialize_mods
#define xkb_state_serialize_layout         XKB_xkb_state_serialize_layout
#define xkb_state_mod_name_is_active       XKB_xkb_state_mod_name_is_active
#define xkb_state_mod_names_are_active     XKB_xkb_state_mod_names_are_active
#define xkb_state_mod_index_is_active      XKB_xkb_state_mod_index_is_active
#define xkb_state_mod_indices_are_active   XKB_xkb_state_mod_indices_are_active
#define xkb_state_key_get_consumed_mods2   XKB_xkb_state_key_get_consumed_mods2
#define xkb_state_key_get_consumed_mods    XKB_xkb_state_key_get_consumed_mods
#define xkb_state_mod_index_is_consumed2   XKB_xkb_state_mod_index_is_consumed2
#define xkb_state_mod_index_is_consumed    XKB_xkb_state_mod_index_is_consumed
#define xkb_state_mod_mask_remove_consumed XKB_xkb_state_mod_mask_remove_consumed
#define xkb_state_layout_name_is_active    XKB_xkb_state_layout_name_is_active
#define xkb_state_layout_index_is_active   XKB_xkb_state_layout_index_is_active
#define xkb_state_led_name_is_active       XKB_xkb_state_led_name_is_active
#define xkb_state_led_index_is_active      XKB_xkb_state_led_index_is_active

#endif // FENNEC_PLATFORM_LINUX_XKB_LIB_XKB_H
