Path: blob/master/platform/linuxbsd/x11/key_mapping_x11.h
10278 views
/**************************************************************************/1/* key_mapping_x11.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "core/os/keyboard.h"33#include "core/templates/hash_map.h"3435#include <X11/XF86keysym.h>36#include <X11/Xlib.h>3738#define XK_MISCELLANY39#define XK_LATIN140#define XK_XKB_KEYS41#include <X11/keysymdef.h>4243class KeyMappingX11 {44struct HashMapHasherKeys {45static _FORCE_INLINE_ uint32_t hash(const Key p_key) { return hash_fmix32(static_cast<uint32_t>(p_key)); }46static _FORCE_INLINE_ uint32_t hash(const char32_t p_uchar) { return hash_fmix32(p_uchar); }47static _FORCE_INLINE_ uint32_t hash(const unsigned p_key) { return hash_fmix32(p_key); }48static _FORCE_INLINE_ uint32_t hash(const KeySym p_key) { return hash_fmix32(p_key); }49};5051static inline HashMap<KeySym, Key, HashMapHasherKeys> xkeysym_map;52static inline HashMap<unsigned int, Key, HashMapHasherKeys> scancode_map;53static inline HashMap<Key, unsigned int, HashMapHasherKeys> scancode_map_inv;54static inline HashMap<KeySym, char32_t, HashMapHasherKeys> xkeysym_unicode_map;55static inline HashMap<unsigned int, KeyLocation, HashMapHasherKeys> location_map;5657KeyMappingX11() {}5859public:60static void initialize();6162static bool is_sym_numpad(KeySym p_keysym);63static Key get_keycode(KeySym p_keysym);64static unsigned int get_xlibcode(Key p_keysym);65static Key get_scancode(unsigned int p_code);66static char32_t get_unicode_from_keysym(KeySym p_keysym);67static KeyLocation get_location(unsigned int p_code);68};697071