diff options
Diffstat (limited to 'platform')
88 files changed, 4407 insertions, 3634 deletions
diff --git a/platform/android/android_input_handler.cpp b/platform/android/android_input_handler.cpp index e3f93086dc..17903b3965 100644 --- a/platform/android/android_input_handler.cpp +++ b/platform/android/android_input_handler.cpp @@ -56,7 +56,7 @@ void AndroidInputHandler::_set_key_modifier_state(Ref<InputEventWithModifiers> e ev->set_ctrl_pressed(control_mem); } -void AndroidInputHandler::process_key_event(int p_keycode, int p_physical_keycode, int p_unicode, bool p_pressed) { +void AndroidInputHandler::process_key_event(int p_physical_keycode, int p_unicode, int p_key_label, bool p_pressed) { static char32_t prev_wc = 0; char32_t unicode = p_unicode; if ((p_unicode & 0xfffffc00) == 0xd800) { @@ -81,8 +81,18 @@ void AndroidInputHandler::process_key_event(int p_keycode, int p_physical_keycod Key physical_keycode = godot_code_from_android_code(p_physical_keycode); Key keycode = physical_keycode; - if (p_keycode != 0) { - keycode = godot_code_from_unicode(p_keycode); + if (unicode == '\b') { // 0x08 + keycode = Key::BACKSPACE; + } else if (unicode == '\t') { // 0x09 + keycode = Key::TAB; + } else if (unicode == '\n') { // 0x0A + keycode = Key::ENTER; + } else if (unicode == 0x1B) { + keycode = Key::ESCAPE; + } else if (unicode == 0x1F) { + keycode = Key::KEY_DELETE; + } else { + keycode = fix_keycode(unicode, physical_keycode); } switch (physical_keycode) { @@ -104,7 +114,8 @@ void AndroidInputHandler::process_key_event(int p_keycode, int p_physical_keycod ev->set_keycode(keycode); ev->set_physical_keycode(physical_keycode); - ev->set_unicode(unicode); + ev->set_key_label(fix_key_label(p_key_label, keycode)); + ev->set_unicode(fix_unicode(unicode)); ev->set_pressed(p_pressed); _set_key_modifier_state(ev); diff --git a/platform/android/android_input_handler.h b/platform/android/android_input_handler.h index 34259efd81..6e53dcfc89 100644 --- a/platform/android/android_input_handler.h +++ b/platform/android/android_input_handler.h @@ -97,7 +97,7 @@ public: void process_magnify(Point2 p_pos, float p_factor); void process_pan(Point2 p_pos, Vector2 p_delta); void process_joy_event(JoypadEvent p_event); - void process_key_event(int p_keycode, int p_physical_keycode, int p_unicode, bool p_pressed); + void process_key_event(int p_physical_keycode, int p_unicode, int p_key_label, bool p_pressed); }; #endif // ANDROID_INPUT_HANDLER_H diff --git a/platform/android/android_keys_utils.cpp b/platform/android/android_keys_utils.cpp index 0dc2d19cdd..f50437e82a 100644 --- a/platform/android/android_keys_utils.cpp +++ b/platform/android/android_keys_utils.cpp @@ -38,41 +38,3 @@ Key godot_code_from_android_code(unsigned int p_code) { } return Key::UNKNOWN; } - -Key godot_code_from_unicode(unsigned int p_code) { - unsigned int code = p_code; - if (code > 0xFF) { - return Key::UNKNOWN; - } - // Known control codes. - if (code == '\b') { // 0x08 - return Key::BACKSPACE; - } - if (code == '\t') { // 0x09 - return Key::TAB; - } - if (code == '\n') { // 0x0A - return Key::ENTER; - } - if (code == 0x1B) { - return Key::ESCAPE; - } - if (code == 0x1F) { - return Key::KEY_DELETE; - } - // Unknown control codes. - if (code <= 0x1F || (code >= 0x80 && code <= 0x9F)) { - return Key::UNKNOWN; - } - // Convert to uppercase. - if (code >= 'a' && code <= 'z') { // 0x61 - 0x7A - code -= ('a' - 'A'); - } - if (code >= u'à' && code <= u'ö') { // 0xE0 - 0xF6 - code -= (u'à' - u'À'); // 0xE0 - 0xC0 - } - if (code >= u'ø' && code <= u'þ') { // 0xF8 - 0xFF - code -= (u'ø' - u'Ø'); // 0xF8 - 0xD8 - } - return Key(code); -} diff --git a/platform/android/android_keys_utils.h b/platform/android/android_keys_utils.h index 33e7929278..3a587dd680 100644 --- a/platform/android/android_keys_utils.h +++ b/platform/android/android_keys_utils.h @@ -165,13 +165,14 @@ static AndroidGodotCodePair android_godot_code_pairs[] = { { AKEYCODE_NUMPAD_DOT, Key::KP_PERIOD }, // (158) Numeric keypad '.' key (for decimals or digit grouping). { AKEYCODE_NUMPAD_ENTER, Key::KP_ENTER }, // (160) Numeric keypad Enter key. { AKEYCODE_VOLUME_MUTE, Key::VOLUMEMUTE }, // (164) Volume Mute key. + { AKEYCODE_EISU, Key::JIS_EISU }, // (212) JIS EISU key. { AKEYCODE_YEN, Key::YEN }, // (216) Japanese Yen key. + { AKEYCODE_KANA, Key::JIS_KANA }, // (218) JIS KANA key. { AKEYCODE_HELP, Key::HELP }, // (259) Help key. { AKEYCODE_REFRESH, Key::REFRESH }, // (285) Refresh key. { AKEYCODE_MAX, Key::UNKNOWN } }; Key godot_code_from_android_code(unsigned int p_code); -Key godot_code_from_unicode(unsigned int p_code); #endif // ANDROID_KEYS_UTILS_H diff --git a/platform/android/display_server_android.cpp b/platform/android/display_server_android.cpp index 6b3bdb7fe6..3fcb926f86 100644 --- a/platform/android/display_server_android.cpp +++ b/platform/android/display_server_android.cpp @@ -212,7 +212,18 @@ float DisplayServerAndroid::screen_get_scale(int p_screen) const { GodotIOJavaWrapper *godot_io_java = OS_Android::get_singleton()->get_godot_io_java(); ERR_FAIL_NULL_V(godot_io_java, 1.0f); - return godot_io_java->get_scaled_density(); + float screen_scale = godot_io_java->get_scaled_density(); + + // Update the scale to avoid cropping. + Size2i screen_size = screen_get_size(p_screen); + if (screen_size != Size2i()) { + float width_scale = screen_size.width / (float)OS_Android::DEFAULT_WINDOW_WIDTH; + float height_scale = screen_size.height / (float)OS_Android::DEFAULT_WINDOW_HEIGHT; + screen_scale = MIN(screen_scale, MIN(width_scale, height_scale)); + } + + print_line("Selected screen scale: ", screen_scale); + return screen_scale; } float DisplayServerAndroid::screen_get_refresh_rate(int p_screen) const { diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index bb1ad3d83b..587caf81bf 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -437,6 +437,14 @@ String EditorExportPlatformAndroid::get_project_name(const String &p_name) const String EditorExportPlatformAndroid::get_package_name(const String &p_package) const { String pname = p_package; + String name = get_valid_basename(); + pname = pname.replace("$genname", name); + return pname; +} + +// Returns the project name without invalid characters +// or the "noname" string if all characters are invalid. +String EditorExportPlatformAndroid::get_valid_basename() const { String basename = GLOBAL_GET("application/config/name"); basename = basename.to_lower(); @@ -452,13 +460,12 @@ String EditorExportPlatformAndroid::get_package_name(const String &p_package) co first = false; } } + if (name.is_empty()) { name = "noname"; } - pname = pname.replace("$genname", name); - - return pname; + return name; } String EditorExportPlatformAndroid::get_assets_directory(const Ref<EditorExportPreset> &p_preset, int p_export_format) const { @@ -466,7 +473,7 @@ String EditorExportPlatformAndroid::get_assets_directory(const Ref<EditorExportP } bool EditorExportPlatformAndroid::is_package_name_valid(const String &p_package, String *r_error) const { - String pname = p_package; + String pname = get_package_name(p_package); if (pname.length() == 0) { if (r_error) { @@ -525,6 +532,24 @@ bool EditorExportPlatformAndroid::is_package_name_valid(const String &p_package, return false; } + if (p_package.find("$genname") >= 0 && !is_project_name_valid()) { + if (r_error) { + *r_error = TTR("The project name does not meet the requirement for the package name format. Please explicitly specify the package name."); + } + return false; + } + + return true; +} + +bool EditorExportPlatformAndroid::is_project_name_valid() const { + // Get the original project name and convert to lowercase. + String basename = GLOBAL_GET("application/config/name"); + basename = basename.to_lower(); + // Check if there are invalid characters. + if (basename != get_valid_basename()) { + return false; + } return true; } @@ -2286,7 +2311,7 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Ref<Edit String pn = p_preset->get("package/unique_name"); String pn_err; - if (!is_package_name_valid(get_package_name(pn), &pn_err)) { + if (!is_package_name_valid(pn, &pn_err)) { valid = false; err += TTR("Invalid package name:") + " " + pn_err + "\n"; } diff --git a/platform/android/export/export_plugin.h b/platform/android/export/export_plugin.h index a6dfc9fcb3..bff769fcba 100644 --- a/platform/android/export/export_plugin.h +++ b/platform/android/export/export_plugin.h @@ -91,9 +91,12 @@ class EditorExportPlatformAndroid : public EditorExportPlatform { String get_package_name(const String &p_package) const; + String get_valid_basename() const; + String get_assets_directory(const Ref<EditorExportPreset> &p_preset, int p_export_format) const; bool is_package_name_valid(const String &p_package, String *r_error = nullptr) const; + bool is_project_name_valid() const; static bool _should_compress_asset(const String &p_path, const Vector<uint8_t> &p_data); diff --git a/platform/android/java/editor/src/dev/res/values/strings.xml b/platform/android/java/editor/src/dev/res/values/strings.xml index 45fae3fd39..215f2c7d0a 100644 --- a/platform/android/java/editor/src/dev/res/values/strings.xml +++ b/platform/android/java/editor/src/dev/res/values/strings.xml @@ -1,4 +1,4 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <string name="godot_editor_name_string">Godot Editor 4.x (dev)</string> + <string name="godot_editor_name_string">Godot Editor 4 (dev)</string> </resources> diff --git a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt index f848089aa8..71385315ae 100644 --- a/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt +++ b/platform/android/java/editor/src/main/java/org/godotengine/editor/GodotEditor.kt @@ -31,12 +31,11 @@ package org.godotengine.editor import android.Manifest +import android.app.ActivityManager +import android.content.Context import android.content.Intent import android.content.pm.PackageManager -import android.os.Build -import android.os.Bundle -import android.os.Debug -import android.os.Environment +import android.os.* import android.util.Log import android.widget.Toast import androidx.window.layout.WindowMetricsCalculator @@ -64,11 +63,18 @@ open class GodotEditor : FullScreenGodotApp() { private const val COMMAND_LINE_PARAMS = "command_line_params" + private const val EDITOR_ID = 777 private const val EDITOR_ARG = "--editor" private const val EDITOR_ARG_SHORT = "-e" + private const val EDITOR_PROCESS_NAME_SUFFIX = ":GodotEditor" + private const val GAME_ID = 667 + private const val GAME_PROCESS_NAME_SUFFIX = ":GodotGame" + + private const val PROJECT_MANAGER_ID = 555 private const val PROJECT_MANAGER_ARG = "--project-manager" private const val PROJECT_MANAGER_ARG_SHORT = "-p" + private const val PROJECT_MANAGER_PROCESS_NAME_SUFFIX = ":GodotProjectManager" } private val commandLineParams = ArrayList<String>() @@ -102,9 +108,10 @@ open class GodotEditor : FullScreenGodotApp() { override fun getCommandLine() = commandLineParams - override fun onNewGodotInstanceRequested(args: Array<String>) { + override fun onNewGodotInstanceRequested(args: Array<String>): Int { // Parse the arguments to figure out which activity to start. var targetClass: Class<*> = GodotGame::class.java + var instanceId = GAME_ID // Whether we should launch the new godot instance in an adjacent window // https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_LAUNCH_ADJACENT @@ -115,12 +122,14 @@ open class GodotEditor : FullScreenGodotApp() { if (EDITOR_ARG == arg || EDITOR_ARG_SHORT == arg) { targetClass = GodotEditor::class.java launchAdjacent = false + instanceId = EDITOR_ID break } if (PROJECT_MANAGER_ARG == arg || PROJECT_MANAGER_ARG_SHORT == arg) { targetClass = GodotProjectManager::class.java launchAdjacent = false + instanceId = PROJECT_MANAGER_ID break } } @@ -139,6 +148,37 @@ open class GodotEditor : FullScreenGodotApp() { Log.d(TAG, "Starting $targetClass") startActivity(newInstance) } + return instanceId + } + + override fun onGodotForceQuit(godotInstanceId: Int): Boolean { + val processNameSuffix = when (godotInstanceId) { + GAME_ID -> { + GAME_PROCESS_NAME_SUFFIX + } + EDITOR_ID -> { + EDITOR_PROCESS_NAME_SUFFIX + } + PROJECT_MANAGER_ID -> { + PROJECT_MANAGER_PROCESS_NAME_SUFFIX + } + else -> "" + } + if (processNameSuffix.isBlank()) { + return false + } + + val activityManager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager + val runningProcesses = activityManager.runningAppProcesses + for (runningProcess in runningProcesses) { + if (runningProcess.processName.endsWith(processNameSuffix)) { + Log.v(TAG, "Killing Godot process ${runningProcess.processName}") + Process.killProcess(runningProcess.pid) + return true + } + } + + return false } // Get the screen's density scale diff --git a/platform/android/java/editor/src/main/res/values/strings.xml b/platform/android/java/editor/src/main/res/values/strings.xml index 837a5d62e1..216d02d9c7 100644 --- a/platform/android/java/editor/src/main/res/values/strings.xml +++ b/platform/android/java/editor/src/main/res/values/strings.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - <string name="godot_editor_name_string">Godot Editor 4.x</string> + <string name="godot_editor_name_string">Godot Editor 4</string> <string name="denied_storage_permission_error_msg">Missing storage access permission!</string> </resources> diff --git a/platform/android/java/lib/res/values/strings.xml b/platform/android/java/lib/res/values/strings.xml index f5a4ab1071..7efac4ce71 100644 --- a/platform/android/java/lib/res/values/strings.xml +++ b/platform/android/java/lib/res/values/strings.xml @@ -48,7 +48,7 @@ <string name="state_failed_unlicensed">Download failed because you may not have purchased this app</string> <string name="state_failed_fetching_url">Download failed because the resources could not be found</string> <string name="state_failed_sdcard_full">Download failed because the external storage is full</string> - <string name="state_failed_cancelled">Download cancelled</string> + <string name="state_failed_cancelled">Download canceled</string> <string name="state_failed">Download failed</string> <string name="kilobytes_per_second">%1$s KB/s</string> diff --git a/platform/android/java/lib/src/org/godotengine/godot/FullScreenGodotApp.java b/platform/android/java/lib/src/org/godotengine/godot/FullScreenGodotApp.java index 863e67f1e9..65032d6a68 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/FullScreenGodotApp.java +++ b/platform/android/java/lib/src/org/godotengine/godot/FullScreenGodotApp.java @@ -74,28 +74,36 @@ public abstract class FullScreenGodotApp extends FragmentActivity implements God public void onDestroy() { Log.v(TAG, "Destroying Godot app..."); super.onDestroy(); - onGodotForceQuit(godotFragment); + terminateGodotInstance(godotFragment); } @Override public final void onGodotForceQuit(Godot instance) { + runOnUiThread(() -> { + terminateGodotInstance(instance); + }); + } + + private void terminateGodotInstance(Godot instance) { if (instance == godotFragment) { Log.v(TAG, "Force quitting Godot instance"); - ProcessPhoenix.forceQuit(this); + ProcessPhoenix.forceQuit(FullScreenGodotApp.this); } } @Override public final void onGodotRestartRequested(Godot instance) { - if (instance == godotFragment) { - // It's very hard to properly de-initialize Godot on Android to restart the game - // from scratch. Therefore, we need to kill the whole app process and relaunch it. - // - // Restarting only the activity, wouldn't be enough unless it did proper cleanup (including - // releasing and reloading native libs or resetting their state somehow and clearing statics). - Log.v(TAG, "Restarting Godot instance..."); - ProcessPhoenix.triggerRebirth(this); - } + runOnUiThread(() -> { + if (instance == godotFragment) { + // It's very hard to properly de-initialize Godot on Android to restart the game + // from scratch. Therefore, we need to kill the whole app process and relaunch it. + // + // Restarting only the activity, wouldn't be enough unless it did proper cleanup (including + // releasing and reloading native libs or resetting their state somehow and clearing statics). + Log.v(TAG, "Restarting Godot instance..."); + ProcessPhoenix.triggerRebirth(FullScreenGodotApp.this); + } + }); } @Override diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.java b/platform/android/java/lib/src/org/godotengine/godot/Godot.java index 905db13c85..50263bc392 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java @@ -348,11 +348,9 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC } public void restart() { - runOnUiThread(() -> { - if (godotHost != null) { - godotHost.onGodotRestartRequested(this); - } - }); + if (godotHost != null) { + godotHost.onGodotRestartRequested(this); + } } public void alert(final String message, final String title) { @@ -889,11 +887,20 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC private void forceQuit() { // TODO: This is a temp solution. The proper fix will involve tracking down and properly shutting down each // native Godot components that is started in Godot#onVideoInit. - runOnUiThread(() -> { - if (godotHost != null) { - godotHost.onGodotForceQuit(this); - } - }); + forceQuit(0); + } + + @Keep + private boolean forceQuit(int instanceId) { + if (godotHost == null) { + return false; + } + if (instanceId == 0) { + godotHost.onGodotForceQuit(this); + return true; + } else { + return godotHost.onGodotForceQuit(instanceId); + } } private boolean obbIsCorrupted(String f, String main_pack_md5) { @@ -1052,11 +1059,10 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC } @Keep - private void createNewGodotInstance(String[] args) { - runOnUiThread(() -> { - if (godotHost != null) { - godotHost.onNewGodotInstanceRequested(args); - } - }); + private int createNewGodotInstance(String[] args) { + if (godotHost != null) { + return godotHost.onNewGodotInstanceRequested(args); + } + return 0; } } diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotHost.java b/platform/android/java/lib/src/org/godotengine/godot/GodotHost.java index 256d04e3a5..7700b9b628 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotHost.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotHost.java @@ -55,21 +55,35 @@ public interface GodotHost { default void onGodotMainLoopStarted() {} /** - * Invoked on the UI thread as the last step of the Godot instance clean up phase. + * Invoked on the render thread to terminate the given Godot instance. */ default void onGodotForceQuit(Godot instance) {} /** - * Invoked on the UI thread when the Godot instance wants to be restarted. It's up to the host + * Invoked on the render thread to terminate the Godot instance with the given id. + * @param godotInstanceId id of the Godot instance to terminate. See {@code onNewGodotInstanceRequested} + * + * @return true if successful, false otherwise. + */ + default boolean onGodotForceQuit(int godotInstanceId) { + return false; + } + + /** + * Invoked on the render thread when the Godot instance wants to be restarted. It's up to the host * to perform the appropriate action(s). */ default void onGodotRestartRequested(Godot instance) {} /** - * Invoked on the UI thread when a new Godot instance is requested. It's up to the host to + * Invoked on the render thread when a new Godot instance is requested. It's up to the host to * perform the appropriate action(s). * * @param args Arguments used to initialize the new instance. + * + * @return the id of the new instance. See {@code onGodotForceQuit} */ - default void onNewGodotInstanceRequested(String[] args) {} + default int onNewGodotInstanceRequested(String[] args) { + return 0; + } } diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java b/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java index aca0c4381b..41d06a6458 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java @@ -150,7 +150,6 @@ public class GodotIO { } else { selectedScaledDensity = 0.75f; } - Log.d(TAG, "Selected scaled density: " + selectedScaledDensity); return selectedScaledDensity; } diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java index 31b512d2dd..75a01dc787 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java @@ -148,7 +148,7 @@ public class GodotLib { /** * Forward regular key events. */ - public static native void key(int p_keycode, int p_physical_keycode, int p_unicode, boolean p_pressed); + public static native void key(int p_physical_keycode, int p_unicode, int p_key_label, boolean p_pressed); /** * Forward game device's key events. diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java b/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java index f2bd3e28e6..cedbbfb7c3 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java +++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java @@ -129,12 +129,10 @@ public class GodotInputHandler implements InputManager.InputDeviceListener { } } else { // getKeyCode(): The physical key that was pressed. - // Godot's keycodes match the ASCII codes, so for single byte unicode characters, - // we can use the unmodified unicode character to determine Godot's keycode. - final int keycode = event.getUnicodeChar(0); final int physical_keycode = event.getKeyCode(); final int unicode = event.getUnicodeChar(); - GodotLib.key(keycode, physical_keycode, unicode, false); + final int key_label = event.getDisplayLabel(); + GodotLib.key(physical_keycode, unicode, key_label, false); }; return true; @@ -166,10 +164,10 @@ public class GodotInputHandler implements InputManager.InputDeviceListener { GodotLib.joybutton(godotJoyId, button, true); } } else { - final int keycode = event.getUnicodeChar(0); final int physical_keycode = event.getKeyCode(); final int unicode = event.getUnicodeChar(); - GodotLib.key(keycode, physical_keycode, unicode, true); + final int key_label = event.getDisplayLabel(); + GodotLib.key(physical_keycode, unicode, key_label, true); } return true; diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotTextInputWrapper.java b/platform/android/java/lib/src/org/godotengine/godot/input/GodotTextInputWrapper.java index fdfe20f32b..7b628e25ed 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/input/GodotTextInputWrapper.java +++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotTextInputWrapper.java @@ -93,8 +93,8 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene @Override public void beforeTextChanged(final CharSequence pCharSequence, final int start, final int count, final int after) { for (int i = 0; i < count; ++i) { - GodotLib.key(0, KeyEvent.KEYCODE_DEL, 0, true); - GodotLib.key(0, KeyEvent.KEYCODE_DEL, 0, false); + GodotLib.key(KeyEvent.KEYCODE_DEL, 0, 0, true); + GodotLib.key(KeyEvent.KEYCODE_DEL, 0, 0, false); if (mHasSelection) { mHasSelection = false; @@ -110,13 +110,13 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene newChars[i - start] = pCharSequence.charAt(i); } for (int i = 0; i < count; ++i) { - int key = newChars[i]; - if ((key == '\n') && !(mEdit.getKeyboardType() == GodotEditText.VirtualKeyboardType.KEYBOARD_TYPE_MULTILINE)) { + final int character = newChars[i]; + if ((character == '\n') && !(mEdit.getKeyboardType() == GodotEditText.VirtualKeyboardType.KEYBOARD_TYPE_MULTILINE)) { // Return keys are handled through action events continue; } - GodotLib.key(key, 0, key, true); - GodotLib.key(key, 0, key, false); + GodotLib.key(0, character, 0, true); + GodotLib.key(0, character, 0, false); } } @@ -126,17 +126,17 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene final String characters = pKeyEvent.getCharacters(); for (int i = 0; i < characters.length(); i++) { - final int ch = characters.codePointAt(i); - GodotLib.key(ch, 0, ch, true); - GodotLib.key(ch, 0, ch, false); + final int character = characters.codePointAt(i); + GodotLib.key(0, character, 0, true); + GodotLib.key(0, character, 0, false); } } if (pActionID == EditorInfo.IME_ACTION_DONE) { // Enter key has been pressed mRenderView.queueOnRenderThread(() -> { - GodotLib.key(0, KeyEvent.KEYCODE_ENTER, 0, true); - GodotLib.key(0, KeyEvent.KEYCODE_ENTER, 0, false); + GodotLib.key(KeyEvent.KEYCODE_ENTER, 0, 0, true); + GodotLib.key(KeyEvent.KEYCODE_ENTER, 0, 0, false); }); mRenderView.getView().requestFocus(); return true; diff --git a/platform/android/java/lib/src/org/godotengine/godot/io/directory/AssetsDirectoryAccess.kt b/platform/android/java/lib/src/org/godotengine/godot/io/directory/AssetsDirectoryAccess.kt index 9649b0aecc..b9b7ebac6e 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/io/directory/AssetsDirectoryAccess.kt +++ b/platform/android/java/lib/src/org/godotengine/godot/io/directory/AssetsDirectoryAccess.kt @@ -64,7 +64,7 @@ internal class AssetsDirectoryAccess(context: Context) : DirectoryAccessHandler. override fun hasDirId(dirId: Int) = dirs.indexOfKey(dirId) >= 0 override fun dirOpen(path: String): Int { - val assetsPath = getAssetsPath(path) ?: return INVALID_DIR_ID + val assetsPath = getAssetsPath(path) try { val files = assetManager.list(assetsPath) ?: return INVALID_DIR_ID // Empty directories don't get added to the 'assets' directory, so @@ -99,7 +99,7 @@ internal class AssetsDirectoryAccess(context: Context) : DirectoryAccessHandler. } override fun fileExists(path: String): Boolean { - val assetsPath = getAssetsPath(path) ?: return false + val assetsPath = getAssetsPath(path) try { val files = assetManager.list(assetsPath) ?: return false // Empty directories don't get added to the 'assets' directory, so diff --git a/platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix.java b/platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix.java index 2cc37b627a..3ee3478fcb 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix.java +++ b/platform/android/java/lib/src/org/godotengine/godot/utils/ProcessPhoenix.java @@ -120,7 +120,7 @@ public final class ProcessPhoenix extends Activity { /** * Checks if the current process is a temporary Phoenix Process. - * This can be used to avoid initialisation of unused resources or to prevent running code that + * This can be used to avoid initialization of unused resources or to prevent running code that * is not multi-process ready. * * @return true if the current process is a temporary Phoenix Process diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index e6cdd7932a..1ee1cccb82 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -382,11 +382,11 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyconnectionchanged( } // Called on the UI thread -JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv *env, jclass clazz, jint p_keycode, jint p_physical_keycode, jint p_unicode, jboolean p_pressed) { +JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv *env, jclass clazz, jint p_physical_keycode, jint p_unicode, jint p_key_label, jboolean p_pressed) { if (step.get() <= 0) { return; } - input_handler->process_key_event(p_keycode, p_physical_keycode, p_unicode, p_pressed); + input_handler->process_key_event(p_physical_keycode, p_unicode, p_key_label, p_pressed); } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_accelerometer(JNIEnv *env, jclass clazz, jfloat x, jfloat y, jfloat z) { diff --git a/platform/android/java_godot_lib_jni.h b/platform/android/java_godot_lib_jni.h index 3f07a8cfe1..0020ddffd2 100644 --- a/platform/android/java_godot_lib_jni.h +++ b/platform/android/java_godot_lib_jni.h @@ -49,7 +49,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_dispatchMouseEvent(JN JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_dispatchTouchEvent(JNIEnv *env, jclass clazz, jint ev, jint pointer, jint pointer_count, jfloatArray positions, jboolean p_double_tap); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_magnify(JNIEnv *env, jclass clazz, jfloat p_x, jfloat p_y, jfloat p_factor); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_pan(JNIEnv *env, jclass clazz, jfloat p_x, jfloat p_y, jfloat p_delta_x, jfloat p_delta_y); -JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv *env, jclass clazz, jint p_keycode, jint p_physical_keycode, jint p_unicode, jboolean p_pressed); +JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv *env, jclass clazz, jint p_physical_keycode, jint p_unicode, jint p_key_label, jboolean p_pressed); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv *env, jclass clazz, jint p_device, jint p_button, jboolean p_pressed); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv *env, jclass clazz, jint p_device, jint p_axis, jfloat p_value); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv *env, jclass clazz, jint p_device, jint p_hat_x, jint p_hat_y); diff --git a/platform/android/java_godot_wrapper.cpp b/platform/android/java_godot_wrapper.cpp index 03548d11f6..9d9d087896 100644 --- a/platform/android/java_godot_wrapper.cpp +++ b/platform/android/java_godot_wrapper.cpp @@ -60,7 +60,7 @@ GodotJavaWrapper::GodotJavaWrapper(JNIEnv *p_env, jobject p_activity, jobject p_ // get some Godot method pointers... _on_video_init = p_env->GetMethodID(godot_class, "onVideoInit", "()Z"); _restart = p_env->GetMethodID(godot_class, "restart", "()V"); - _finish = p_env->GetMethodID(godot_class, "forceQuit", "()V"); + _finish = p_env->GetMethodID(godot_class, "forceQuit", "(I)Z"); _set_keep_screen_on = p_env->GetMethodID(godot_class, "setKeepScreenOn", "(Z)V"); _alert = p_env->GetMethodID(godot_class, "alert", "(Ljava/lang/String;Ljava/lang/String;)V"); _get_GLES_version_code = p_env->GetMethodID(godot_class, "getGLESVersionCode", "()I"); @@ -77,7 +77,7 @@ GodotJavaWrapper::GodotJavaWrapper(JNIEnv *p_env, jobject p_activity, jobject p_ _get_input_fallback_mapping = p_env->GetMethodID(godot_class, "getInputFallbackMapping", "()Ljava/lang/String;"); _on_godot_setup_completed = p_env->GetMethodID(godot_class, "onGodotSetupCompleted", "()V"); _on_godot_main_loop_started = p_env->GetMethodID(godot_class, "onGodotMainLoopStarted", "()V"); - _create_new_godot_instance = p_env->GetMethodID(godot_class, "createNewGodotInstance", "([Ljava/lang/String;)V"); + _create_new_godot_instance = p_env->GetMethodID(godot_class, "createNewGodotInstance", "([Ljava/lang/String;)I"); _get_render_view = p_env->GetMethodID(godot_class, "getRenderView", "()Lorg/godotengine/godot/GodotRenderView;"); // get some Activity method pointers... @@ -179,14 +179,15 @@ void GodotJavaWrapper::restart(JNIEnv *p_env) { } } -void GodotJavaWrapper::force_quit(JNIEnv *p_env) { +bool GodotJavaWrapper::force_quit(JNIEnv *p_env, int p_instance_id) { if (_finish) { if (p_env == nullptr) { p_env = get_jni_env(); } - ERR_FAIL_NULL(p_env); - p_env->CallVoidMethod(godot_instance, _finish); + ERR_FAIL_NULL_V(p_env, false); + return p_env->CallBooleanMethod(godot_instance, _finish, p_instance_id); } + return false; } void GodotJavaWrapper::set_keep_screen_on(bool p_enabled) { @@ -345,14 +346,16 @@ void GodotJavaWrapper::vibrate(int p_duration_ms) { } } -void GodotJavaWrapper::create_new_godot_instance(List<String> args) { +int GodotJavaWrapper::create_new_godot_instance(List<String> args) { if (_create_new_godot_instance) { JNIEnv *env = get_jni_env(); - ERR_FAIL_NULL(env); + ERR_FAIL_NULL_V(env, 0); jobjectArray jargs = env->NewObjectArray(args.size(), env->FindClass("java/lang/String"), env->NewStringUTF("")); for (int i = 0; i < args.size(); i++) { env->SetObjectArrayElement(jargs, i, env->NewStringUTF(args[i].utf8().get_data())); } - env->CallVoidMethod(godot_instance, _create_new_godot_instance, jargs); + return env->CallIntMethod(godot_instance, _create_new_godot_instance, jargs); + } else { + return 0; } } diff --git a/platform/android/java_godot_wrapper.h b/platform/android/java_godot_wrapper.h index 5dad2a3eb9..1bd79584d8 100644 --- a/platform/android/java_godot_wrapper.h +++ b/platform/android/java_godot_wrapper.h @@ -85,7 +85,7 @@ public: void on_godot_setup_completed(JNIEnv *p_env = nullptr); void on_godot_main_loop_started(JNIEnv *p_env = nullptr); void restart(JNIEnv *p_env = nullptr); - void force_quit(JNIEnv *p_env = nullptr); + bool force_quit(JNIEnv *p_env = nullptr, int p_instance_id = 0); void set_keep_screen_on(bool p_enabled); void alert(const String &p_message, const String &p_title); int get_gles_version_code(); @@ -103,7 +103,7 @@ public: bool is_activity_resumed(); void vibrate(int p_duration_ms); String get_input_fallback_mapping(); - void create_new_godot_instance(List<String> args); + int create_new_godot_instance(List<String> args); }; #endif // JAVA_GODOT_WRAPPER_H diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 942bf0a904..725fea8d54 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -695,8 +695,8 @@ bool OS_Android::_check_internal_feature_support(const String &p_feature) { } OS_Android::OS_Android(GodotJavaWrapper *p_godot_java, GodotIOJavaWrapper *p_godot_io_java, bool p_use_apk_expansion) { - display_size.width = 800; - display_size.height = 600; + display_size.width = DEFAULT_WINDOW_WIDTH; + display_size.height = DEFAULT_WINDOW_HEIGHT; use_apk_expansion = p_use_apk_expansion; @@ -739,9 +739,19 @@ Error OS_Android::create_process(const String &p_path, const List<String> &p_arg } Error OS_Android::create_instance(const List<String> &p_arguments, ProcessID *r_child_id) { - godot_java->create_new_godot_instance(p_arguments); + int instance_id = godot_java->create_new_godot_instance(p_arguments); + if (r_child_id) { + *r_child_id = instance_id; + } return OK; } +Error OS_Android::kill(const ProcessID &p_pid) { + if (godot_java->force_quit(nullptr, p_pid)) { + return OK; + } + return OS_Unix::kill(p_pid); +} + OS_Android::~OS_Android() { } diff --git a/platform/android/os_android.h b/platform/android/os_android.h index 68b6fefe33..53910b1498 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -86,6 +86,8 @@ private: public: static const char *ANDROID_EXEC_PATH; + static const int DEFAULT_WINDOW_WIDTH = 800; + static const int DEFAULT_WINDOW_HEIGHT = 600; virtual void initialize_core() override; virtual void initialize() override; @@ -156,6 +158,7 @@ public: virtual Error execute(const String &p_path, const List<String> &p_arguments, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr, bool p_open_console = false) override; virtual Error create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id = nullptr, bool p_open_console = false) override; virtual Error create_instance(const List<String> &p_arguments, ProcessID *r_child_id = nullptr) override; + virtual Error kill(const ProcessID &p_pid) override; virtual bool _check_internal_feature_support(const String &p_feature) override; OS_Android(GodotJavaWrapper *p_godot_java, GodotIOJavaWrapper *p_godot_io_java, bool p_use_apk_expansion); diff --git a/platform/ios/SCsub b/platform/ios/SCsub index bf12ab6dd7..f3925c146f 100644 --- a/platform/ios/SCsub +++ b/platform/ios/SCsub @@ -20,6 +20,7 @@ ios_lib = [ "godot_view_gesture_recognizer.mm", "device_metrics.m", "keyboard_input_view.mm", + "key_mapping_ios.mm", ] env_ios = env.Clone() diff --git a/platform/ios/detect.py b/platform/ios/detect.py index 38e62134b5..71612cf1fa 100644 --- a/platform/ios/detect.py +++ b/platform/ios/detect.py @@ -99,8 +99,8 @@ def configure(env: "Environment"): if env["ios_simulator"]: detect_darwin_sdk_path("iossimulator", env) - env.Append(ASFLAGS=["-mios-simulator-version-min=13.0"]) - env.Append(CCFLAGS=["-mios-simulator-version-min=13.0"]) + env.Append(ASFLAGS=["-mios-simulator-version-min=11.0"]) + env.Append(CCFLAGS=["-mios-simulator-version-min=11.0"]) env.extra_suffix = ".simulator" + env.extra_suffix else: detect_darwin_sdk_path("ios", env) @@ -153,3 +153,11 @@ def configure(env: "Environment"): if env["vulkan"]: env.Append(CPPDEFINES=["VULKAN_ENABLED"]) + + if env["opengl3"]: + env.Append(CPPDEFINES=["GLES3_ENABLED"]) + env.Prepend( + CPPPATH=[ + "$IOS_SDK_PATH/System/Library/Frameworks/OpenGLES.framework/Headers", + ] + ) diff --git a/platform/ios/display_layer.h b/platform/ios/display_layer.h index 10f42264df..e719a42cd9 100644 --- a/platform/ios/display_layer.h +++ b/platform/ios/display_layer.h @@ -33,7 +33,8 @@ @protocol DisplayLayer <NSObject> -- (void)renderDisplayLayer; +- (void)startRenderDisplayLayer; +- (void)stopRenderDisplayLayer; - (void)initializeDisplayLayer; - (void)layoutDisplayLayer; diff --git a/platform/ios/display_layer.mm b/platform/ios/display_layer.mm index 24614fea56..3129ebb276 100644 --- a/platform/ios/display_layer.mm +++ b/platform/ios/display_layer.mm @@ -60,7 +60,10 @@ - (void)layoutDisplayLayer { } -- (void)renderDisplayLayer { +- (void)startRenderDisplayLayer { +} + +- (void)stopRenderDisplayLayer { } @end @@ -76,8 +79,6 @@ } - (void)initializeDisplayLayer { - // Get our backing layer - // Configure it so that it is opaque, does not retain the contents of the backbuffer when displayed, and uses RGBA8888 color. self.opaque = YES; self.drawableProperties = [NSDictionary @@ -87,8 +88,6 @@ kEAGLDrawablePropertyColorFormat, nil]; - // FIXME: Add Vulkan support via MoltenVK. Add fallback code back? - // Create GL ES 3 context if (GLOBAL_GET("rendering/renderer/rendering_method") == "gl_compatibility") { context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]; @@ -115,8 +114,22 @@ [self createFramebuffer]; } -- (void)renderDisplayLayer { +- (void)startRenderDisplayLayer { [EAGLContext setCurrentContext:context]; + + glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); +} + +- (void)stopRenderDisplayLayer { + glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); + [context presentRenderbuffer:GL_RENDERBUFFER_OES]; + +#ifdef DEBUG_ENABLED + GLenum err = glGetError(); + if (err) { + NSLog(@"DrawView: %x error", err); + } +#endif } - (void)dealloc { @@ -154,11 +167,15 @@ return NO; } + GLES3::TextureStorage::system_fbo = viewFramebuffer; + return YES; } // Clean up any buffers we have allocated. - (void)destroyFramebuffer { + GLES3::TextureStorage::system_fbo = 0; + glDeleteFramebuffersOES(1, &viewFramebuffer); viewFramebuffer = 0; glDeleteRenderbuffersOES(1, &viewRenderbuffer); diff --git a/platform/ios/display_server_ios.h b/platform/ios/display_server_ios.h index dd1157f668..6eaa7c8edc 100644 --- a/platform/ios/display_server_ios.h +++ b/platform/ios/display_server_ios.h @@ -47,6 +47,10 @@ #endif #endif +#if defined(GLES3_ENABLED) +#include "drivers/gles3/rasterizer_gles3.h" +#endif // GLES3_ENABLED + #import <Foundation/Foundation.h> #import <QuartzCore/CAMetalLayer.h> @@ -109,11 +113,12 @@ public: void touch_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_double_click); void touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y, float p_pressure, Vector2 p_tilt); - void touches_cancelled(int p_idx); + void touches_canceled(int p_idx); // MARK: Keyboard - void key(Key p_key, char32_t p_char, bool p_pressed); + void key(Key p_key, char32_t p_char, Key p_unshifted, Key p_physical, NSInteger p_modifier, bool p_pressed); + bool is_keyboard_active() const; // MARK: Motion @@ -216,6 +221,7 @@ public: virtual bool screen_is_kept_on() const override; void resize_window(CGSize size); + virtual void swap_buffers() override {} }; #endif // DISPLAY_SERVER_IOS_H diff --git a/platform/ios/display_server_ios.mm b/platform/ios/display_server_ios.mm index 86ea602a98..469bc9be17 100644 --- a/platform/ios/display_server_ios.mm +++ b/platform/ios/display_server_ios.mm @@ -36,6 +36,7 @@ #import "device_metrics.h" #import "godot_view.h" #include "ios.h" +#import "key_mapping_ios.h" #import "keyboard_input_view.h" #include "os_ios.h" #include "tts_ios.h" @@ -50,33 +51,14 @@ DisplayServerIOS *DisplayServerIOS::get_singleton() { } DisplayServerIOS::DisplayServerIOS(const String &p_rendering_driver, WindowMode p_mode, DisplayServer::VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Error &r_error) { + KeyMappingIOS::initialize(); + rendering_driver = p_rendering_driver; // Init TTS tts = [[TTS_IOS alloc] init]; -#if defined(GLES3_ENABLED) - if (rendering_driver == "opengl3") { - bool gl_initialization_error = false; - - if (RasterizerGLES3::is_viable() == OK) { - RasterizerGLES3::register_config(); - RasterizerGLES3::make_current(); - } else { - gl_initialization_error = true; - } - - if (gl_initialization_error) { - OS::get_singleton()->alert( - "Your device seems not to support the required OpenGL ES 3.0 version.\n\n", - "Unable to initialize OpenGL video driver"); - } - } -#endif - #if defined(VULKAN_ENABLED) - rendering_driver = "vulkan"; - context_vulkan = nullptr; rendering_device_vulkan = nullptr; @@ -91,13 +73,14 @@ DisplayServerIOS::DisplayServerIOS(const String &p_rendering_driver, WindowMode CALayer *layer = [AppDelegate.viewController.godotView initializeRenderingForDriver:@"vulkan"]; if (!layer) { - ERR_FAIL_MSG("Failed to create iOS rendering layer."); + ERR_FAIL_MSG("Failed to create iOS Vulkan rendering layer."); } Size2i size = Size2i(layer.bounds.size.width, layer.bounds.size.height) * screen_get_max_scale(); if (context_vulkan->window_create(MAIN_WINDOW_ID, p_vsync_mode, layer, size.width, size.height) != OK) { memdelete(context_vulkan); context_vulkan = nullptr; + r_error = ERR_UNAVAILABLE; ERR_FAIL_MSG("Failed to create Vulkan window."); } @@ -108,6 +91,18 @@ DisplayServerIOS::DisplayServerIOS(const String &p_rendering_driver, WindowMode } #endif +#if defined(GLES3_ENABLED) + if (rendering_driver == "opengl3") { + CALayer *layer = [AppDelegate.viewController.godotView initializeRenderingForDriver:@"opengl3"]; + + if (!layer) { + ERR_FAIL_MSG("Failed to create iOS OpenGLES rendering layer."); + } + + RasterizerGLES3::make_current(); + } +#endif + bool keep_screen_on = bool(GLOBAL_GET("display/window/energy_saving/keep_screen_on")); screen_set_keep_on(keep_screen_on); @@ -233,20 +228,35 @@ void DisplayServerIOS::perform_event(const Ref<InputEvent> &p_event) { Input::get_singleton()->parse_input_event(p_event); } -void DisplayServerIOS::touches_cancelled(int p_idx) { +void DisplayServerIOS::touches_canceled(int p_idx) { touch_press(p_idx, -1, -1, false, false); } // MARK: Keyboard -void DisplayServerIOS::key(Key p_key, char32_t p_char, bool p_pressed) { +void DisplayServerIOS::key(Key p_key, char32_t p_char, Key p_unshifted, Key p_physical, NSInteger p_modifier, bool p_pressed) { Ref<InputEventKey> ev; ev.instantiate(); ev->set_echo(false); ev->set_pressed(p_pressed); - ev->set_keycode(p_key); - ev->set_physical_keycode(p_key); - ev->set_unicode(p_char); + ev->set_keycode(fix_keycode(p_char, p_key)); + if (@available(iOS 13.4, *)) { + if (p_key != Key::SHIFT) { + ev->set_shift_pressed(p_modifier & UIKeyModifierShift); + } + if (p_key != Key::CTRL) { + ev->set_ctrl_pressed(p_modifier & UIKeyModifierControl); + } + if (p_key != Key::ALT) { + ev->set_alt_pressed(p_modifier & UIKeyModifierAlternate); + } + if (p_key != Key::META) { + ev->set_meta_pressed(p_modifier & UIKeyModifierCommand); + } + } + ev->set_key_label(p_unshifted); + ev->set_physical_keycode(p_physical); + ev->set_unicode(fix_unicode(p_char)); perform_event(ev); } @@ -624,6 +634,10 @@ void DisplayServerIOS::virtual_keyboard_show(const String &p_existing_text, cons cursorEnd:_convert_utf32_offset_to_utf16(p_existing_text, p_cursor_end)]; } +bool DisplayServerIOS::is_keyboard_active() const { + return [AppDelegate.viewController.keyboardView isFirstResponder]; +} + void DisplayServerIOS::virtual_keyboard_hide() { [AppDelegate.viewController.keyboardView resignFirstResponder]; } @@ -670,15 +684,18 @@ void DisplayServerIOS::resize_window(CGSize viewSize) { void DisplayServerIOS::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window) { _THREAD_SAFE_METHOD_ #if defined(VULKAN_ENABLED) - context_vulkan->set_vsync_mode(p_window, p_vsync_mode); + if (context_vulkan) { + context_vulkan->set_vsync_mode(p_window, p_vsync_mode); + } #endif } DisplayServer::VSyncMode DisplayServerIOS::window_get_vsync_mode(WindowID p_window) const { _THREAD_SAFE_METHOD_ #if defined(VULKAN_ENABLED) - return context_vulkan->get_vsync_mode(p_window); -#else - return DisplayServer::VSYNC_ENABLED; + if (context_vulkan) { + return context_vulkan->get_vsync_mode(p_window); + } #endif + return DisplayServer::VSYNC_ENABLED; } diff --git a/platform/ios/godot_view.mm b/platform/ios/godot_view.mm index 1c8c578bd2..4b10f95ab8 100644 --- a/platform/ios/godot_view.mm +++ b/platform/ios/godot_view.mm @@ -74,16 +74,20 @@ static const float earth_gravity = 9.80665; CALayer<DisplayLayer> *layer; if ([driverName isEqualToString:@"vulkan"]) { +#if defined(TARGET_OS_SIMULATOR) && TARGET_OS_SIMULATOR + if (@available(iOS 13, *)) { + layer = [GodotMetalLayer layer]; + } else { + return nil; + } +#else layer = [GodotMetalLayer layer]; +#endif } else if ([driverName isEqualToString:@"opengl3"]) { if (@available(iOS 13, *)) { NSLog(@"OpenGL ES is deprecated on iOS 13"); } -#if defined(TARGET_OS_SIMULATOR) && TARGET_OS_SIMULATOR - return nil; -#else layer = [GodotOpenGLLayer layer]; -#endif } else { return nil; } @@ -238,7 +242,7 @@ static const float earth_gravity = 9.80665; [self.displayLink setPaused:NO]; } - [self.renderingLayer renderDisplayLayer]; + [self.renderingLayer startRenderDisplayLayer]; if (!self.renderer) { return; @@ -258,6 +262,8 @@ static const float earth_gravity = 9.80665; [self handleMotion]; [self.renderer renderOnView:self]; + + [self.renderingLayer stopRenderDisplayLayer]; } - (BOOL)canRender { @@ -391,7 +397,7 @@ static const float earth_gravity = 9.80665; UITouch *touch = [tlist objectAtIndex:i]; int tid = [self getTouchIDForTouch:touch]; ERR_FAIL_COND(tid == -1); - DisplayServerIOS::get_singleton()->touches_cancelled(tid); + DisplayServerIOS::get_singleton()->touches_canceled(tid); } } [self clearTouches]; diff --git a/platform/ios/key_mapping_ios.h b/platform/ios/key_mapping_ios.h new file mode 100644 index 0000000000..6cc61175bb --- /dev/null +++ b/platform/ios/key_mapping_ios.h @@ -0,0 +1,46 @@ +/**************************************************************************/ +/* key_mapping_ios.h */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef KEY_MAPPING_IOS_H +#define KEY_MAPPING_IOS_H + +#include "core/os/keyboard.h" + +#import <UIKit/UIKit.h> + +class KeyMappingIOS { + KeyMappingIOS() {} + +public: + static void initialize(); + static Key remap_key(CFIndex p_keycode); +}; + +#endif // KEY_MAPPING_IOS_H diff --git a/platform/ios/key_mapping_ios.mm b/platform/ios/key_mapping_ios.mm new file mode 100644 index 0000000000..c378186778 --- /dev/null +++ b/platform/ios/key_mapping_ios.mm @@ -0,0 +1,186 @@ +/**************************************************************************/ +/* key_mapping_ios.mm */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#include "key_mapping_ios.h" + +#include "core/templates/hash_map.h" + +struct HashMapHasherKeys { + static _FORCE_INLINE_ uint32_t hash(const Key p_key) { return hash_fmix32(static_cast<uint32_t>(p_key)); } + static _FORCE_INLINE_ uint32_t hash(const CFIndex p_key) { return hash_fmix32(p_key); } +}; + +HashMap<CFIndex, Key, HashMapHasherKeys> keyusage_map; + +void KeyMappingIOS::initialize() { + if (@available(iOS 13.4, *)) { + keyusage_map[UIKeyboardHIDUsageKeyboardA] = Key::A; + keyusage_map[UIKeyboardHIDUsageKeyboardB] = Key::B; + keyusage_map[UIKeyboardHIDUsageKeyboardC] = Key::C; + keyusage_map[UIKeyboardHIDUsageKeyboardD] = Key::D; + keyusage_map[UIKeyboardHIDUsageKeyboardE] = Key::E; + keyusage_map[UIKeyboardHIDUsageKeyboardF] = Key::F; + keyusage_map[UIKeyboardHIDUsageKeyboardG] = Key::G; + keyusage_map[UIKeyboardHIDUsageKeyboardH] = Key::H; + keyusage_map[UIKeyboardHIDUsageKeyboardI] = Key::I; + keyusage_map[UIKeyboardHIDUsageKeyboardJ] = Key::J; + keyusage_map[UIKeyboardHIDUsageKeyboardK] = Key::K; + keyusage_map[UIKeyboardHIDUsageKeyboardL] = Key::L; + keyusage_map[UIKeyboardHIDUsageKeyboardM] = Key::M; + keyusage_map[UIKeyboardHIDUsageKeyboardN] = Key::N; + keyusage_map[UIKeyboardHIDUsageKeyboardO] = Key::O; + keyusage_map[UIKeyboardHIDUsageKeyboardP] = Key::P; + keyusage_map[UIKeyboardHIDUsageKeyboardQ] = Key::Q; + keyusage_map[UIKeyboardHIDUsageKeyboardR] = Key::R; + keyusage_map[UIKeyboardHIDUsageKeyboardS] = Key::S; + keyusage_map[UIKeyboardHIDUsageKeyboardT] = Key::T; + keyusage_map[UIKeyboardHIDUsageKeyboardU] = Key::U; + keyusage_map[UIKeyboardHIDUsageKeyboardV] = Key::V; + keyusage_map[UIKeyboardHIDUsageKeyboardW] = Key::W; + keyusage_map[UIKeyboardHIDUsageKeyboardX] = Key::X; + keyusage_map[UIKeyboardHIDUsageKeyboardY] = Key::Y; + keyusage_map[UIKeyboardHIDUsageKeyboardZ] = Key::Z; + keyusage_map[UIKeyboardHIDUsageKeyboard0] = Key::KEY_0; + keyusage_map[UIKeyboardHIDUsageKeyboard1] = Key::KEY_1; + keyusage_map[UIKeyboardHIDUsageKeyboard2] = Key::KEY_2; + keyusage_map[UIKeyboardHIDUsageKeyboard3] = Key::KEY_3; + keyusage_map[UIKeyboardHIDUsageKeyboard4] = Key::KEY_4; + keyusage_map[UIKeyboardHIDUsageKeyboard5] = Key::KEY_5; + keyusage_map[UIKeyboardHIDUsageKeyboard6] = Key::KEY_6; + keyusage_map[UIKeyboardHIDUsageKeyboard7] = Key::KEY_7; + keyusage_map[UIKeyboardHIDUsageKeyboard8] = Key::KEY_8; + keyusage_map[UIKeyboardHIDUsageKeyboard9] = Key::KEY_9; + keyusage_map[UIKeyboardHIDUsageKeyboardBackslash] = Key::BACKSLASH; + keyusage_map[UIKeyboardHIDUsageKeyboardCloseBracket] = Key::BRACKETRIGHT; + keyusage_map[UIKeyboardHIDUsageKeyboardComma] = Key::COMMA; + keyusage_map[UIKeyboardHIDUsageKeyboardEqualSign] = Key::EQUAL; + keyusage_map[UIKeyboardHIDUsageKeyboardHyphen] = Key::MINUS; + keyusage_map[UIKeyboardHIDUsageKeyboardNonUSBackslash] = Key::SECTION; + keyusage_map[UIKeyboardHIDUsageKeyboardNonUSPound] = Key::ASCIITILDE; + keyusage_map[UIKeyboardHIDUsageKeyboardOpenBracket] = Key::BRACKETLEFT; + keyusage_map[UIKeyboardHIDUsageKeyboardPeriod] = Key::PERIOD; + keyusage_map[UIKeyboardHIDUsageKeyboardQuote] = Key::QUOTEDBL; + keyusage_map[UIKeyboardHIDUsageKeyboardSemicolon] = Key::SEMICOLON; + keyusage_map[UIKeyboardHIDUsageKeyboardSeparator] = Key::SECTION; + keyusage_map[UIKeyboardHIDUsageKeyboardSlash] = Key::SLASH; + keyusage_map[UIKeyboardHIDUsageKeyboardSpacebar] = Key::SPACE; + keyusage_map[UIKeyboardHIDUsageKeyboardCapsLock] = Key::CAPSLOCK; + keyusage_map[UIKeyboardHIDUsageKeyboardLeftAlt] = Key::ALT; + keyusage_map[UIKeyboardHIDUsageKeyboardLeftControl] = Key::CTRL; + keyusage_map[UIKeyboardHIDUsageKeyboardLeftShift] = Key::SHIFT; + keyusage_map[UIKeyboardHIDUsageKeyboardRightAlt] = Key::ALT; + keyusage_map[UIKeyboardHIDUsageKeyboardRightControl] = Key::CTRL; + keyusage_map[UIKeyboardHIDUsageKeyboardRightShift] = Key::SHIFT; + keyusage_map[UIKeyboardHIDUsageKeyboardScrollLock] = Key::SCROLLLOCK; + keyusage_map[UIKeyboardHIDUsageKeyboardLeftArrow] = Key::LEFT; + keyusage_map[UIKeyboardHIDUsageKeyboardRightArrow] = Key::RIGHT; + keyusage_map[UIKeyboardHIDUsageKeyboardUpArrow] = Key::UP; + keyusage_map[UIKeyboardHIDUsageKeyboardDownArrow] = Key::DOWN; + keyusage_map[UIKeyboardHIDUsageKeyboardPageUp] = Key::PAGEUP; + keyusage_map[UIKeyboardHIDUsageKeyboardPageDown] = Key::PAGEDOWN; + keyusage_map[UIKeyboardHIDUsageKeyboardHome] = Key::HOME; + keyusage_map[UIKeyboardHIDUsageKeyboardEnd] = Key::END; + keyusage_map[UIKeyboardHIDUsageKeyboardDeleteForward] = Key::KEY_DELETE; + keyusage_map[UIKeyboardHIDUsageKeyboardDeleteOrBackspace] = Key::BACKSPACE; + keyusage_map[UIKeyboardHIDUsageKeyboardEscape] = Key::ESCAPE; + keyusage_map[UIKeyboardHIDUsageKeyboardInsert] = Key::INSERT; + keyusage_map[UIKeyboardHIDUsageKeyboardReturn] = Key::ENTER; + keyusage_map[UIKeyboardHIDUsageKeyboardTab] = Key::TAB; + keyusage_map[UIKeyboardHIDUsageKeyboardF1] = Key::F1; + keyusage_map[UIKeyboardHIDUsageKeyboardF2] = Key::F2; + keyusage_map[UIKeyboardHIDUsageKeyboardF3] = Key::F3; + keyusage_map[UIKeyboardHIDUsageKeyboardF4] = Key::F4; + keyusage_map[UIKeyboardHIDUsageKeyboardF5] = Key::F5; + keyusage_map[UIKeyboardHIDUsageKeyboardF6] = Key::F6; + keyusage_map[UIKeyboardHIDUsageKeyboardF7] = Key::F7; + keyusage_map[UIKeyboardHIDUsageKeyboardF8] = Key::F8; + keyusage_map[UIKeyboardHIDUsageKeyboardF9] = Key::F9; + keyusage_map[UIKeyboardHIDUsageKeyboardF10] = Key::F10; + keyusage_map[UIKeyboardHIDUsageKeyboardF11] = Key::F11; + keyusage_map[UIKeyboardHIDUsageKeyboardF12] = Key::F12; + keyusage_map[UIKeyboardHIDUsageKeyboardF13] = Key::F13; + keyusage_map[UIKeyboardHIDUsageKeyboardF14] = Key::F14; + keyusage_map[UIKeyboardHIDUsageKeyboardF15] = Key::F15; + keyusage_map[UIKeyboardHIDUsageKeyboardF16] = Key::F16; + keyusage_map[UIKeyboardHIDUsageKeyboardF17] = Key::F17; + keyusage_map[UIKeyboardHIDUsageKeyboardF18] = Key::F18; + keyusage_map[UIKeyboardHIDUsageKeyboardF19] = Key::F19; + keyusage_map[UIKeyboardHIDUsageKeyboardF20] = Key::F20; + keyusage_map[UIKeyboardHIDUsageKeyboardF21] = Key::F21; + keyusage_map[UIKeyboardHIDUsageKeyboardF22] = Key::F22; + keyusage_map[UIKeyboardHIDUsageKeyboardF23] = Key::F23; + keyusage_map[UIKeyboardHIDUsageKeyboardF24] = Key::F24; + keyusage_map[UIKeyboardHIDUsageKeypad0] = Key::KP_0; + keyusage_map[UIKeyboardHIDUsageKeypad1] = Key::KP_1; + keyusage_map[UIKeyboardHIDUsageKeypad2] = Key::KP_2; + keyusage_map[UIKeyboardHIDUsageKeypad3] = Key::KP_3; + keyusage_map[UIKeyboardHIDUsageKeypad4] = Key::KP_4; + keyusage_map[UIKeyboardHIDUsageKeypad5] = Key::KP_5; + keyusage_map[UIKeyboardHIDUsageKeypad6] = Key::KP_6; + keyusage_map[UIKeyboardHIDUsageKeypad7] = Key::KP_7; + keyusage_map[UIKeyboardHIDUsageKeypad8] = Key::KP_8; + keyusage_map[UIKeyboardHIDUsageKeypad9] = Key::KP_9; + keyusage_map[UIKeyboardHIDUsageKeypadAsterisk] = Key::KP_MULTIPLY; + keyusage_map[UIKeyboardHIDUsageKeyboardGraveAccentAndTilde] = Key::BAR; + keyusage_map[UIKeyboardHIDUsageKeypadEnter] = Key::KP_ENTER; + keyusage_map[UIKeyboardHIDUsageKeypadHyphen] = Key::KP_SUBTRACT; + keyusage_map[UIKeyboardHIDUsageKeypadNumLock] = Key::NUMLOCK; + keyusage_map[UIKeyboardHIDUsageKeypadPeriod] = Key::KP_PERIOD; + keyusage_map[UIKeyboardHIDUsageKeypadPlus] = Key::KP_ADD; + keyusage_map[UIKeyboardHIDUsageKeypadSlash] = Key::KP_DIVIDE; + keyusage_map[UIKeyboardHIDUsageKeyboardPause] = Key::PAUSE; + keyusage_map[UIKeyboardHIDUsageKeyboardStop] = Key::STOP; + keyusage_map[UIKeyboardHIDUsageKeyboardMute] = Key::VOLUMEMUTE; + keyusage_map[UIKeyboardHIDUsageKeyboardVolumeUp] = Key::VOLUMEUP; + keyusage_map[UIKeyboardHIDUsageKeyboardVolumeDown] = Key::VOLUMEDOWN; + keyusage_map[UIKeyboardHIDUsageKeyboardFind] = Key::SEARCH; + keyusage_map[UIKeyboardHIDUsageKeyboardHelp] = Key::HELP; + keyusage_map[UIKeyboardHIDUsageKeyboardLeftGUI] = Key::META; + keyusage_map[UIKeyboardHIDUsageKeyboardRightGUI] = Key::META; + keyusage_map[UIKeyboardHIDUsageKeyboardMenu] = Key::MENU; + keyusage_map[UIKeyboardHIDUsageKeyboardPrintScreen] = Key::PRINT; + keyusage_map[UIKeyboardHIDUsageKeyboardReturnOrEnter] = Key::ENTER; + keyusage_map[UIKeyboardHIDUsageKeyboardSysReqOrAttention] = Key::SYSREQ; + keyusage_map[0x01AE] = Key::KEYBOARD; // On-screen keyboard key on smart connector keyboard. + keyusage_map[0x029D] = Key::GLOBE; // "Globe" key on smart connector / Mac keyboard. + keyusage_map[UIKeyboardHIDUsageKeyboardLANG1] = Key::JIS_EISU; + keyusage_map[UIKeyboardHIDUsageKeyboardLANG2] = Key::JIS_KANA; + } +} + +Key KeyMappingIOS::remap_key(CFIndex p_keycode) { + if (@available(iOS 13.4, *)) { + const Key *key = keyusage_map.getptr(p_keycode); + if (key) { + return *key; + } + } + return Key::NONE; +} diff --git a/platform/ios/keyboard_input_view.mm b/platform/ios/keyboard_input_view.mm index f40db48ee3..2764403d68 100644 --- a/platform/ios/keyboard_input_view.mm +++ b/platform/ios/keyboard_input_view.mm @@ -115,8 +115,8 @@ - (void)deleteText:(NSInteger)charactersToDelete { for (int i = 0; i < charactersToDelete; i++) { - DisplayServerIOS::get_singleton()->key(Key::BACKSPACE, 0, true); - DisplayServerIOS::get_singleton()->key(Key::BACKSPACE, 0, false); + DisplayServerIOS::get_singleton()->key(Key::BACKSPACE, 0, Key::BACKSPACE, Key::NONE, 0, true); + DisplayServerIOS::get_singleton()->key(Key::BACKSPACE, 0, Key::BACKSPACE, Key::NONE, 0, false); } } @@ -134,20 +134,10 @@ key = Key::ENTER; } else if (character == 0x2006) { key = Key::SPACE; - } else if (character == U'¥') { - key = Key::YEN; - } else if (character == U'§') { - key = Key::SECTION; - } else if (character >= 0x20 && character <= 0x7E) { // ASCII. - if (character > 0x60 && character < 0x7B) { // Lowercase ASCII. - key = (Key)(character - 32); - } else { - key = (Key)character; - } } - DisplayServerIOS::get_singleton()->key(key, character, true); - DisplayServerIOS::get_singleton()->key(key, character, false); + DisplayServerIOS::get_singleton()->key(key, character, key, Key::NONE, 0, true); + DisplayServerIOS::get_singleton()->key(key, character, key, Key::NONE, 0, false); } } diff --git a/platform/ios/view_controller.mm b/platform/ios/view_controller.mm index b787ed6709..a5aba201d7 100644 --- a/platform/ios/view_controller.mm +++ b/platform/ios/view_controller.mm @@ -33,6 +33,7 @@ #include "display_server_ios.h" #import "godot_view.h" #import "godot_view_renderer.h" +#import "key_mapping_ios.h" #import "keyboard_input_view.h" #include "os_ios.h" @@ -54,6 +55,64 @@ return (GodotView *)self.view; } +- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event { + [super pressesBegan:presses withEvent:event]; + + if (!DisplayServerIOS::get_singleton() || DisplayServerIOS::get_singleton()->is_keyboard_active()) { + return; + } + if (@available(iOS 13.4, *)) { + for (UIPress *press in presses) { + String u32lbl = String::utf8([press.key.charactersIgnoringModifiers UTF8String]); + String u32text = String::utf8([press.key.characters UTF8String]); + Key key = KeyMappingIOS::remap_key(press.key.keyCode); + + if (press.key.keyCode == 0 && u32text.is_empty() && u32lbl.is_empty()) { + continue; + } + + char32_t us = 0; + if (!u32lbl.is_empty() && !u32lbl.begins_with("UIKey")) { + us = u32lbl[0]; + } + + if (!u32text.is_empty() && !u32text.begins_with("UIKey")) { + for (int i = 0; i < u32text.length(); i++) { + const char32_t c = u32text[i]; + DisplayServerIOS::get_singleton()->key(fix_keycode(us, key), c, fix_key_label(us, key), key, press.key.modifierFlags, true); + } + } else { + DisplayServerIOS::get_singleton()->key(fix_keycode(us, key), 0, fix_key_label(us, key), key, press.key.modifierFlags, true); + } + } + } +} + +- (void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event { + [super pressesEnded:presses withEvent:event]; + + if (!DisplayServerIOS::get_singleton() || DisplayServerIOS::get_singleton()->is_keyboard_active()) { + return; + } + if (@available(iOS 13.4, *)) { + for (UIPress *press in presses) { + String u32lbl = String::utf8([press.key.charactersIgnoringModifiers UTF8String]); + Key key = KeyMappingIOS::remap_key(press.key.keyCode); + + if (press.key.keyCode == 0 && u32lbl.is_empty()) { + continue; + } + + char32_t us = 0; + if (!u32lbl.is_empty() && !u32lbl.begins_with("UIKey")) { + us = u32lbl[0]; + } + + DisplayServerIOS::get_singleton()->key(fix_keycode(us, key), 0, fix_key_label(us, key), key, press.key.modifierFlags, false); + } + } +} + - (void)loadView { GodotView *view = [[GodotView alloc] init]; GodotViewRenderer *renderer = [[GodotViewRenderer alloc] init]; diff --git a/platform/linuxbsd/SCsub b/platform/linuxbsd/SCsub index fcd739cdc9..3c5dc78c60 100644 --- a/platform/linuxbsd/SCsub +++ b/platform/linuxbsd/SCsub @@ -11,6 +11,7 @@ common_linuxbsd = [ "joypad_linux.cpp", "freedesktop_portal_desktop.cpp", "freedesktop_screensaver.cpp", + "xkbcommon-so_wrap.c", ] if env["x11"]: diff --git a/platform/linuxbsd/crash_handler_linuxbsd.cpp b/platform/linuxbsd/crash_handler_linuxbsd.cpp index 8d03e3d31c..3a245460b4 100644 --- a/platform/linuxbsd/crash_handler_linuxbsd.cpp +++ b/platform/linuxbsd/crash_handler_linuxbsd.cpp @@ -81,7 +81,13 @@ static void handle_crash(int sig) { print_error(vformat("Dumping the backtrace. %s", msg)); char **strings = backtrace_symbols(bt_buffer, size); // PIE executable relocation, zero for non-PIE executables +#ifdef __GLIBC__ + // This is a glibc only thing apparently. uintptr_t relocation = _r_debug.r_map->l_addr; +#else + // Non glibc systems apparently don't give PIE relocation info. + uintptr_t relocation = 0; +#endif //__GLIBC__ if (strings) { List<String> args; for (size_t i = 0; i < size; i++) { diff --git a/platform/linuxbsd/dbus-so_wrap.c b/platform/linuxbsd/dbus-so_wrap.c index 48d0d9b907..d03a9166a3 100644 --- a/platform/linuxbsd/dbus-so_wrap.c +++ b/platform/linuxbsd/dbus-so_wrap.c @@ -1,7 +1,7 @@ // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./generate-wrapper.py 0.3 on 2022-07-29 07:23:21 -// flags: ./generate-wrapper.py --include /usr/include/dbus-1.0/dbus/dbus.h --sys-include <dbus/dbus.h> --soname libdbus-1.so.3 --init-name dbus --output-header dbus-so_wrap.h --output-implementation dbus-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-12 10:26:35 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/dbus/dbus.h --sys-include "thirdparty/linuxbsd_headers/dbus/dbus.h" --soname libdbus-1.so.3 --init-name dbus --output-header ./platform/linuxbsd/dbus-so_wrap.h --output-implementation ./platform/linuxbsd/dbus-so_wrap.c // #include <stdint.h> @@ -243,7 +243,7 @@ #define dbus_validate_utf8 dbus_validate_utf8_dylibloader_orig_dbus #define dbus_threads_init dbus_threads_init_dylibloader_orig_dbus #define dbus_threads_init_default dbus_threads_init_default_dylibloader_orig_dbus -#include <dbus/dbus.h> +#include "thirdparty/linuxbsd_headers/dbus/dbus.h" #undef dbus_error_init #undef dbus_error_free #undef dbus_set_error diff --git a/platform/linuxbsd/dbus-so_wrap.h b/platform/linuxbsd/dbus-so_wrap.h index 52e1dd300c..6981912a12 100644 --- a/platform/linuxbsd/dbus-so_wrap.h +++ b/platform/linuxbsd/dbus-so_wrap.h @@ -2,8 +2,8 @@ #define DYLIBLOAD_WRAPPER_DBUS // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./generate-wrapper.py 0.3 on 2022-07-29 07:23:21 -// flags: ./generate-wrapper.py --include /usr/include/dbus-1.0/dbus/dbus.h --sys-include <dbus/dbus.h> --soname libdbus-1.so --init-name dbus --output-header dbus-so_wrap.h --output-implementation dbus-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-12 10:26:35 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/dbus/dbus.h --sys-include "thirdparty/linuxbsd_headers/dbus/dbus.h" --soname libdbus-1.so.3 --init-name dbus --output-header ./platform/linuxbsd/dbus-so_wrap.h --output-implementation ./platform/linuxbsd/dbus-so_wrap.c // #include <stdint.h> @@ -245,7 +245,7 @@ #define dbus_validate_utf8 dbus_validate_utf8_dylibloader_orig_dbus #define dbus_threads_init dbus_threads_init_dylibloader_orig_dbus #define dbus_threads_init_default dbus_threads_init_default_dylibloader_orig_dbus -#include <dbus/dbus.h> +#include "thirdparty/linuxbsd_headers/dbus/dbus.h" #undef dbus_error_init #undef dbus_error_free #undef dbus_set_error diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py index f4d36f1a87..36e149f2b4 100644 --- a/platform/linuxbsd/detect.py +++ b/platform/linuxbsd/detect.py @@ -43,10 +43,11 @@ def get_opts(): BoolVariable("use_lsan", "Use LLVM/GCC compiler leak sanitizer (LSAN)", False), BoolVariable("use_tsan", "Use LLVM/GCC compiler thread sanitizer (TSAN)", False), BoolVariable("use_msan", "Use LLVM compiler memory sanitizer (MSAN)", False), - BoolVariable("pulseaudio", "Detect and use PulseAudio", True), - BoolVariable("dbus", "Detect and use D-Bus to handle screensaver and portal desktop settings", True), - BoolVariable("speechd", "Detect and use Speech Dispatcher for Text-to-Speech support", True), - BoolVariable("fontconfig", "Detect and use fontconfig for system fonts support", True), + BoolVariable("alsa", "Use ALSA", True), + BoolVariable("pulseaudio", "Use PulseAudio", True), + BoolVariable("dbus", "Use D-Bus to handle screensaver and portal desktop settings", True), + BoolVariable("speechd", "Use Speech Dispatcher for Text-to-Speech support", True), + BoolVariable("fontconfig", "Use fontconfig for system fonts support", True), BoolVariable("udev", "Use udev for gamepad connection callbacks", True), BoolVariable("x11", "Enable X11 display", True), BoolVariable("touch", "Enable touch events", True), @@ -183,16 +184,6 @@ def configure(env: "Environment"): ## Dependencies - if env["x11"]: - # Only cflags, we dlopen the libraries. - env.ParseConfig("pkg-config x11 --cflags") - env.ParseConfig("pkg-config xcursor --cflags") - env.ParseConfig("pkg-config xinerama --cflags") - env.ParseConfig("pkg-config xext --cflags") - env.ParseConfig("pkg-config xrandr --cflags") - env.ParseConfig("pkg-config xrender --cflags") - env.ParseConfig("pkg-config xi --cflags") - if env["touch"]: env.Append(CPPDEFINES=["TOUCH_ENABLED"]) @@ -271,7 +262,7 @@ def configure(env: "Environment"): env.Append(LIBS=["miniupnpc"]) # On Linux wchar_t should be 32-bits - # 16-bit library shouldn't be required due to compiler optimisations + # 16-bit library shouldn't be required due to compiler optimizations if not env["builtin_pcre2"]: env.ParseConfig("pkg-config libpcre2-32 --cflags --libs") @@ -282,53 +273,24 @@ def configure(env: "Environment"): ## Flags if env["fontconfig"]: - if os.system("pkg-config --exists fontconfig") == 0: # 0 means found - env.Append(CPPDEFINES=["FONTCONFIG_ENABLED"]) - env.ParseConfig("pkg-config fontconfig --cflags") # Only cflags, we dlopen the library. - else: - env["fontconfig"] = False - print("Warning: fontconfig libraries not found. Disabling the system fonts support.") + env.Append(CPPDEFINES=["FONTCONFIG_ENABLED"]) - if os.system("pkg-config --exists alsa") == 0: # 0 means found - env["alsa"] = True + if env["alsa"]: env.Append(CPPDEFINES=["ALSA_ENABLED", "ALSAMIDI_ENABLED"]) - env.ParseConfig("pkg-config alsa --cflags") # Only cflags, we dlopen the library. - else: - print("Warning: ALSA libraries not found. Disabling the ALSA audio driver.") if env["pulseaudio"]: - if os.system("pkg-config --exists libpulse") == 0: # 0 means found - env.Append(CPPDEFINES=["PULSEAUDIO_ENABLED"]) - env.ParseConfig("pkg-config libpulse --cflags") # Only cflags, we dlopen the library. - else: - env["pulseaudio"] = False - print("Warning: PulseAudio development libraries not found. Disabling the PulseAudio audio driver.") + env.Append(CPPDEFINES=["PULSEAUDIO_ENABLED", "_REENTRANT"]) if env["dbus"]: - if os.system("pkg-config --exists dbus-1") == 0: # 0 means found - env.Append(CPPDEFINES=["DBUS_ENABLED"]) - env.ParseConfig("pkg-config dbus-1 --cflags") # Only cflags, we dlopen the library. - else: - env["dbus"] = False - print("Warning: D-Bus development libraries not found. Disabling screensaver prevention.") + env.Append(CPPDEFINES=["DBUS_ENABLED"]) if env["speechd"]: - if os.system("pkg-config --exists speech-dispatcher") == 0: # 0 means found - env.Append(CPPDEFINES=["SPEECHD_ENABLED"]) - env.ParseConfig("pkg-config speech-dispatcher --cflags") # Only cflags, we dlopen the library. - else: - env["speechd"] = False - print("Warning: Speech Dispatcher development libraries not found. Disabling Text-to-Speech support.") + env.Append(CPPDEFINES=["SPEECHD_ENABLED"]) if platform.system() == "Linux": env.Append(CPPDEFINES=["JOYDEV_ENABLED"]) if env["udev"]: - if os.system("pkg-config --exists libudev") == 0: # 0 means found - env.Append(CPPDEFINES=["UDEV_ENABLED"]) - env.ParseConfig("pkg-config libudev --cflags") # Only cflags, we dlopen the library. - else: - env["udev"] = False - print("Warning: libudev development libraries not found. Disabling controller hotplugging support.") + env.Append(CPPDEFINES=["UDEV_ENABLED"]) else: env["udev"] = False # Linux specific @@ -336,7 +298,7 @@ def configure(env: "Environment"): if not env["builtin_zlib"]: env.ParseConfig("pkg-config zlib --cflags --libs") - env.Prepend(CPPPATH=["#platform/linuxbsd"]) + env.Prepend(CPPPATH=["#platform/linuxbsd", "#thirdparty/linuxbsd_headers"]) env.Append( CPPDEFINES=[ @@ -405,9 +367,9 @@ def configure(env: "Environment"): # Link those statically for portability if env["use_static_cpp"]: env.Append(LINKFLAGS=["-static-libgcc", "-static-libstdc++"]) - if env["use_llvm"]: + if env["use_llvm"] and platform.system() != "FreeBSD": env["LINKCOM"] = env["LINKCOM"] + " -l:libatomic.a" else: - if env["use_llvm"]: + if env["use_llvm"] and platform.system() != "FreeBSD": env.Append(LIBS=["atomic"]) diff --git a/platform/linuxbsd/export/export_plugin.cpp b/platform/linuxbsd/export/export_plugin.cpp index c900cad007..2528bb2b99 100644 --- a/platform/linuxbsd/export/export_plugin.cpp +++ b/platform/linuxbsd/export/export_plugin.cpp @@ -378,8 +378,8 @@ Error EditorExportPlatformLinuxBSD::run(const Ref<EditorExportPreset> &p_preset, if (port.is_empty()) { port = "22"; } - Vector<String> extra_args_ssh = p_preset->get("ssh_remote_deploy/extra_args_ssh").operator String().split(" "); - Vector<String> extra_args_scp = p_preset->get("ssh_remote_deploy/extra_args_scp").operator String().split(" "); + Vector<String> extra_args_ssh = p_preset->get("ssh_remote_deploy/extra_args_ssh").operator String().split(" ", false); + Vector<String> extra_args_scp = p_preset->get("ssh_remote_deploy/extra_args_scp").operator String().split(" ", false); const String basepath = dest.path_join("tmp_linuxbsd_export"); diff --git a/platform/linuxbsd/fontconfig-so_wrap.c b/platform/linuxbsd/fontconfig-so_wrap.c index 62901b14a9..6278522b69 100644 --- a/platform/linuxbsd/fontconfig-so_wrap.c +++ b/platform/linuxbsd/fontconfig-so_wrap.c @@ -1,7 +1,7 @@ // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./generate-wrapper.py 0.3 on 2022-11-22 10:28:00 -// flags: ./generate-wrapper.py --include /usr/include/fontconfig/fontconfig.h --sys-include <fontconfig/fontconfig.h> --soname libfontconfig.so.1 --init-name fontconfig --output-header fontconfig-so_wrap.h --output-implementation fontconfig-so_wrap.c --omit-prefix FcCharSetFirst --omit-prefix FcCharSetNext +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-12 10:15:54 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/fontconfig/fontconfig.h --sys-include "thirdparty/linuxbsd_headers/fontconfig/fontconfig.h" --soname libfontconfig.so.1 --init-name fontconfig --omit-prefix FcCharSetFirst --omit-prefix FcCharSetNext --output-header ./platform/linuxbsd/fontconfig-so_wrap.h --output-implementation ./platform/linuxbsd/fontconfig-so_wrap.c // #include <stdint.h> @@ -18,8 +18,6 @@ #define FcDirCacheValid FcDirCacheValid_dylibloader_orig_fontconfig #define FcDirCacheClean FcDirCacheClean_dylibloader_orig_fontconfig #define FcCacheCreateTagFile FcCacheCreateTagFile_dylibloader_orig_fontconfig -#define FcDirCacheCreateUUID FcDirCacheCreateUUID_dylibloader_orig_fontconfig -#define FcDirCacheDeleteUUID FcDirCacheDeleteUUID_dylibloader_orig_fontconfig #define FcConfigHome FcConfigHome_dylibloader_orig_fontconfig #define FcConfigEnableHome FcConfigEnableHome_dylibloader_orig_fontconfig #define FcConfigFilename FcConfigFilename_dylibloader_orig_fontconfig @@ -46,9 +44,6 @@ #define FcConfigSubstitute FcConfigSubstitute_dylibloader_orig_fontconfig #define FcConfigGetSysRoot FcConfigGetSysRoot_dylibloader_orig_fontconfig #define FcConfigSetSysRoot FcConfigSetSysRoot_dylibloader_orig_fontconfig -#define FcConfigFileInfoIterInit FcConfigFileInfoIterInit_dylibloader_orig_fontconfig -#define FcConfigFileInfoIterNext FcConfigFileInfoIterNext_dylibloader_orig_fontconfig -#define FcConfigFileInfoIterGet FcConfigFileInfoIterGet_dylibloader_orig_fontconfig #define FcCharSetCreate FcCharSetCreate_dylibloader_orig_fontconfig #define FcCharSetNew FcCharSetNew_dylibloader_orig_fontconfig #define FcCharSetDestroy FcCharSetDestroy_dylibloader_orig_fontconfig @@ -81,7 +76,6 @@ #define FcDirCacheLoadFile FcDirCacheLoadFile_dylibloader_orig_fontconfig #define FcDirCacheUnload FcDirCacheUnload_dylibloader_orig_fontconfig #define FcFreeTypeQuery FcFreeTypeQuery_dylibloader_orig_fontconfig -#define FcFreeTypeQueryAll FcFreeTypeQueryAll_dylibloader_orig_fontconfig #define FcFontSetCreate FcFontSetCreate_dylibloader_orig_fontconfig #define FcFontSetDestroy FcFontSetDestroy_dylibloader_orig_fontconfig #define FcFontSetAdd FcFontSetAdd_dylibloader_orig_fontconfig @@ -152,7 +146,6 @@ #define FcValueEqual FcValueEqual_dylibloader_orig_fontconfig #define FcValueSave FcValueSave_dylibloader_orig_fontconfig #define FcPatternDestroy FcPatternDestroy_dylibloader_orig_fontconfig -#define FcPatternObjectCount FcPatternObjectCount_dylibloader_orig_fontconfig #define FcPatternEqual FcPatternEqual_dylibloader_orig_fontconfig #define FcPatternEqualSubset FcPatternEqualSubset_dylibloader_orig_fontconfig #define FcPatternHash FcPatternHash_dylibloader_orig_fontconfig @@ -186,18 +179,8 @@ #define FcRangeDestroy FcRangeDestroy_dylibloader_orig_fontconfig #define FcRangeCopy FcRangeCopy_dylibloader_orig_fontconfig #define FcRangeGetDouble FcRangeGetDouble_dylibloader_orig_fontconfig -#define FcPatternIterStart FcPatternIterStart_dylibloader_orig_fontconfig -#define FcPatternIterNext FcPatternIterNext_dylibloader_orig_fontconfig -#define FcPatternIterEqual FcPatternIterEqual_dylibloader_orig_fontconfig -#define FcPatternFindIter FcPatternFindIter_dylibloader_orig_fontconfig -#define FcPatternIterIsValid FcPatternIterIsValid_dylibloader_orig_fontconfig -#define FcPatternIterGetObject FcPatternIterGetObject_dylibloader_orig_fontconfig -#define FcPatternIterValueCount FcPatternIterValueCount_dylibloader_orig_fontconfig -#define FcPatternIterGetValue FcPatternIterGetValue_dylibloader_orig_fontconfig #define FcWeightFromOpenType FcWeightFromOpenType_dylibloader_orig_fontconfig -#define FcWeightFromOpenTypeDouble FcWeightFromOpenTypeDouble_dylibloader_orig_fontconfig #define FcWeightToOpenType FcWeightToOpenType_dylibloader_orig_fontconfig -#define FcWeightToOpenTypeDouble FcWeightToOpenTypeDouble_dylibloader_orig_fontconfig #define FcStrCopy FcStrCopy_dylibloader_orig_fontconfig #define FcStrCopyFilename FcStrCopyFilename_dylibloader_orig_fontconfig #define FcStrPlus FcStrPlus_dylibloader_orig_fontconfig @@ -227,7 +210,7 @@ #define FcStrListDone FcStrListDone_dylibloader_orig_fontconfig #define FcConfigParseAndLoad FcConfigParseAndLoad_dylibloader_orig_fontconfig #define FcConfigParseAndLoadFromMemory FcConfigParseAndLoadFromMemory_dylibloader_orig_fontconfig -#include <fontconfig/fontconfig.h> +#include "thirdparty/linuxbsd_headers/fontconfig/fontconfig.h" #undef FcBlanksCreate #undef FcBlanksDestroy #undef FcBlanksAdd @@ -241,8 +224,6 @@ #undef FcDirCacheValid #undef FcDirCacheClean #undef FcCacheCreateTagFile -#undef FcDirCacheCreateUUID -#undef FcDirCacheDeleteUUID #undef FcConfigHome #undef FcConfigEnableHome #undef FcConfigFilename @@ -269,9 +250,6 @@ #undef FcConfigSubstitute #undef FcConfigGetSysRoot #undef FcConfigSetSysRoot -#undef FcConfigFileInfoIterInit -#undef FcConfigFileInfoIterNext -#undef FcConfigFileInfoIterGet #undef FcCharSetCreate #undef FcCharSetNew #undef FcCharSetDestroy @@ -304,7 +282,6 @@ #undef FcDirCacheLoadFile #undef FcDirCacheUnload #undef FcFreeTypeQuery -#undef FcFreeTypeQueryAll #undef FcFontSetCreate #undef FcFontSetDestroy #undef FcFontSetAdd @@ -375,7 +352,6 @@ #undef FcValueEqual #undef FcValueSave #undef FcPatternDestroy -#undef FcPatternObjectCount #undef FcPatternEqual #undef FcPatternEqualSubset #undef FcPatternHash @@ -409,18 +385,8 @@ #undef FcRangeDestroy #undef FcRangeCopy #undef FcRangeGetDouble -#undef FcPatternIterStart -#undef FcPatternIterNext -#undef FcPatternIterEqual -#undef FcPatternFindIter -#undef FcPatternIterIsValid -#undef FcPatternIterGetObject -#undef FcPatternIterValueCount -#undef FcPatternIterGetValue #undef FcWeightFromOpenType -#undef FcWeightFromOpenTypeDouble #undef FcWeightToOpenType -#undef FcWeightToOpenTypeDouble #undef FcStrCopy #undef FcStrCopyFilename #undef FcStrPlus @@ -465,8 +431,6 @@ FcBool (*FcDirCacheUnlink_dylibloader_wrapper_fontconfig)(const FcChar8*, FcConf FcBool (*FcDirCacheValid_dylibloader_wrapper_fontconfig)(const FcChar8*); FcBool (*FcDirCacheClean_dylibloader_wrapper_fontconfig)(const FcChar8*, FcBool); void (*FcCacheCreateTagFile_dylibloader_wrapper_fontconfig)(const FcConfig*); -FcBool (*FcDirCacheCreateUUID_dylibloader_wrapper_fontconfig)( FcChar8*, FcBool, FcConfig*); -FcBool (*FcDirCacheDeleteUUID_dylibloader_wrapper_fontconfig)(const FcChar8*, FcConfig*); FcChar8* (*FcConfigHome_dylibloader_wrapper_fontconfig)( void); FcBool (*FcConfigEnableHome_dylibloader_wrapper_fontconfig)( FcBool); FcChar8* (*FcConfigFilename_dylibloader_wrapper_fontconfig)(const FcChar8*); @@ -493,9 +457,6 @@ FcBool (*FcConfigSubstituteWithPat_dylibloader_wrapper_fontconfig)( FcConfig*, F FcBool (*FcConfigSubstitute_dylibloader_wrapper_fontconfig)( FcConfig*, FcPattern*, FcMatchKind); const FcChar8* (*FcConfigGetSysRoot_dylibloader_wrapper_fontconfig)(const FcConfig*); void (*FcConfigSetSysRoot_dylibloader_wrapper_fontconfig)( FcConfig*,const FcChar8*); -void (*FcConfigFileInfoIterInit_dylibloader_wrapper_fontconfig)( FcConfig*, FcConfigFileInfoIter*); -FcBool (*FcConfigFileInfoIterNext_dylibloader_wrapper_fontconfig)( FcConfig*, FcConfigFileInfoIter*); -FcBool (*FcConfigFileInfoIterGet_dylibloader_wrapper_fontconfig)( FcConfig*, FcConfigFileInfoIter*, FcChar8**, FcChar8**, FcBool*); FcCharSet* (*FcCharSetCreate_dylibloader_wrapper_fontconfig)( void); FcCharSet* (*FcCharSetNew_dylibloader_wrapper_fontconfig)( void); void (*FcCharSetDestroy_dylibloader_wrapper_fontconfig)( FcCharSet*); @@ -527,8 +488,7 @@ FcCache* (*FcDirCacheRescan_dylibloader_wrapper_fontconfig)(const FcChar8*, FcCo FcCache* (*FcDirCacheRead_dylibloader_wrapper_fontconfig)(const FcChar8*, FcBool, FcConfig*); FcCache* (*FcDirCacheLoadFile_dylibloader_wrapper_fontconfig)(const FcChar8*,struct stat*); void (*FcDirCacheUnload_dylibloader_wrapper_fontconfig)( FcCache*); -FcPattern* (*FcFreeTypeQuery_dylibloader_wrapper_fontconfig)(const FcChar8*, unsigned int, FcBlanks*, int*); -unsigned int (*FcFreeTypeQueryAll_dylibloader_wrapper_fontconfig)(const FcChar8*, unsigned int, FcBlanks*, int*, FcFontSet*); +FcPattern* (*FcFreeTypeQuery_dylibloader_wrapper_fontconfig)(const FcChar8*, int, FcBlanks*, int*); FcFontSet* (*FcFontSetCreate_dylibloader_wrapper_fontconfig)( void); void (*FcFontSetDestroy_dylibloader_wrapper_fontconfig)( FcFontSet*); FcBool (*FcFontSetAdd_dylibloader_wrapper_fontconfig)( FcFontSet*, FcPattern*); @@ -599,7 +559,6 @@ void (*FcValueDestroy_dylibloader_wrapper_fontconfig)( FcValue); FcBool (*FcValueEqual_dylibloader_wrapper_fontconfig)( FcValue, FcValue); FcValue (*FcValueSave_dylibloader_wrapper_fontconfig)( FcValue); void (*FcPatternDestroy_dylibloader_wrapper_fontconfig)( FcPattern*); -int (*FcPatternObjectCount_dylibloader_wrapper_fontconfig)(const FcPattern*); FcBool (*FcPatternEqual_dylibloader_wrapper_fontconfig)(const FcPattern*,const FcPattern*); FcBool (*FcPatternEqualSubset_dylibloader_wrapper_fontconfig)(const FcPattern*,const FcPattern*,const FcObjectSet*); FcChar32 (*FcPatternHash_dylibloader_wrapper_fontconfig)(const FcPattern*); @@ -633,18 +592,8 @@ FcRange* (*FcRangeCreateInteger_dylibloader_wrapper_fontconfig)( FcChar32, FcCha void (*FcRangeDestroy_dylibloader_wrapper_fontconfig)( FcRange*); FcRange* (*FcRangeCopy_dylibloader_wrapper_fontconfig)(const FcRange*); FcBool (*FcRangeGetDouble_dylibloader_wrapper_fontconfig)(const FcRange*, double*, double*); -void (*FcPatternIterStart_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*); -FcBool (*FcPatternIterNext_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*); -FcBool (*FcPatternIterEqual_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*,const FcPattern*, FcPatternIter*); -FcBool (*FcPatternFindIter_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*,const char*); -FcBool (*FcPatternIterIsValid_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*); -const char* (*FcPatternIterGetObject_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*); -int (*FcPatternIterValueCount_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*); -FcResult (*FcPatternIterGetValue_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*, int, FcValue*, FcValueBinding*); int (*FcWeightFromOpenType_dylibloader_wrapper_fontconfig)( int); -double (*FcWeightFromOpenTypeDouble_dylibloader_wrapper_fontconfig)( double); int (*FcWeightToOpenType_dylibloader_wrapper_fontconfig)( int); -double (*FcWeightToOpenTypeDouble_dylibloader_wrapper_fontconfig)( double); FcChar8* (*FcStrCopy_dylibloader_wrapper_fontconfig)(const FcChar8*); FcChar8* (*FcStrCopyFilename_dylibloader_wrapper_fontconfig)(const FcChar8*); FcChar8* (*FcStrPlus_dylibloader_wrapper_fontconfig)(const FcChar8*,const FcChar8*); @@ -789,22 +738,6 @@ int initialize_fontconfig(int verbose) { fprintf(stderr, "%s\n", error); } } -// FcDirCacheCreateUUID - *(void **) (&FcDirCacheCreateUUID_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcDirCacheCreateUUID"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } -// FcDirCacheDeleteUUID - *(void **) (&FcDirCacheDeleteUUID_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcDirCacheDeleteUUID"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } // FcConfigHome *(void **) (&FcConfigHome_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcConfigHome"); if (verbose) { @@ -1013,30 +946,6 @@ int initialize_fontconfig(int verbose) { fprintf(stderr, "%s\n", error); } } -// FcConfigFileInfoIterInit - *(void **) (&FcConfigFileInfoIterInit_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcConfigFileInfoIterInit"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } -// FcConfigFileInfoIterNext - *(void **) (&FcConfigFileInfoIterNext_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcConfigFileInfoIterNext"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } -// FcConfigFileInfoIterGet - *(void **) (&FcConfigFileInfoIterGet_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcConfigFileInfoIterGet"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } // FcCharSetCreate *(void **) (&FcCharSetCreate_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcCharSetCreate"); if (verbose) { @@ -1293,14 +1202,6 @@ int initialize_fontconfig(int verbose) { fprintf(stderr, "%s\n", error); } } -// FcFreeTypeQueryAll - *(void **) (&FcFreeTypeQueryAll_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcFreeTypeQueryAll"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } // FcFontSetCreate *(void **) (&FcFontSetCreate_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcFontSetCreate"); if (verbose) { @@ -1861,14 +1762,6 @@ int initialize_fontconfig(int verbose) { fprintf(stderr, "%s\n", error); } } -// FcPatternObjectCount - *(void **) (&FcPatternObjectCount_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternObjectCount"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } // FcPatternEqual *(void **) (&FcPatternEqual_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternEqual"); if (verbose) { @@ -2133,70 +2026,6 @@ int initialize_fontconfig(int verbose) { fprintf(stderr, "%s\n", error); } } -// FcPatternIterStart - *(void **) (&FcPatternIterStart_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternIterStart"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } -// FcPatternIterNext - *(void **) (&FcPatternIterNext_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternIterNext"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } -// FcPatternIterEqual - *(void **) (&FcPatternIterEqual_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternIterEqual"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } -// FcPatternFindIter - *(void **) (&FcPatternFindIter_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternFindIter"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } -// FcPatternIterIsValid - *(void **) (&FcPatternIterIsValid_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternIterIsValid"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } -// FcPatternIterGetObject - *(void **) (&FcPatternIterGetObject_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternIterGetObject"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } -// FcPatternIterValueCount - *(void **) (&FcPatternIterValueCount_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternIterValueCount"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } -// FcPatternIterGetValue - *(void **) (&FcPatternIterGetValue_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcPatternIterGetValue"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } // FcWeightFromOpenType *(void **) (&FcWeightFromOpenType_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcWeightFromOpenType"); if (verbose) { @@ -2205,14 +2034,6 @@ int initialize_fontconfig(int verbose) { fprintf(stderr, "%s\n", error); } } -// FcWeightFromOpenTypeDouble - *(void **) (&FcWeightFromOpenTypeDouble_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcWeightFromOpenTypeDouble"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } // FcWeightToOpenType *(void **) (&FcWeightToOpenType_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcWeightToOpenType"); if (verbose) { @@ -2221,14 +2042,6 @@ int initialize_fontconfig(int verbose) { fprintf(stderr, "%s\n", error); } } -// FcWeightToOpenTypeDouble - *(void **) (&FcWeightToOpenTypeDouble_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcWeightToOpenTypeDouble"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } // FcStrCopy *(void **) (&FcStrCopy_dylibloader_wrapper_fontconfig) = dlsym(handle, "FcStrCopy"); if (verbose) { diff --git a/platform/linuxbsd/fontconfig-so_wrap.h b/platform/linuxbsd/fontconfig-so_wrap.h index 0c8259deb7..021b2148ae 100644 --- a/platform/linuxbsd/fontconfig-so_wrap.h +++ b/platform/linuxbsd/fontconfig-so_wrap.h @@ -2,8 +2,8 @@ #define DYLIBLOAD_WRAPPER_FONTCONFIG // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./generate-wrapper.py 0.3 on 2022-11-22 10:28:00 -// flags: ./generate-wrapper.py --include /usr/include/fontconfig/fontconfig.h --sys-include <fontconfig/fontconfig.h> --soname libfontconfig.so --init-name fontconfig --output-header fontconfig-so_wrap.h --output-implementation fontconfig-so_wrap.c --omit-prefix FcCharSetFirst --omit-prefix FcCharSetNext +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-12 10:15:54 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/fontconfig/fontconfig.h --sys-include "thirdparty/linuxbsd_headers/fontconfig/fontconfig.h" --soname libfontconfig.so.1 --init-name fontconfig --omit-prefix FcCharSetFirst --omit-prefix FcCharSetNext --output-header ./platform/linuxbsd/fontconfig-so_wrap.h --output-implementation ./platform/linuxbsd/fontconfig-so_wrap.c // #include <stdint.h> @@ -20,8 +20,6 @@ #define FcDirCacheValid FcDirCacheValid_dylibloader_orig_fontconfig #define FcDirCacheClean FcDirCacheClean_dylibloader_orig_fontconfig #define FcCacheCreateTagFile FcCacheCreateTagFile_dylibloader_orig_fontconfig -#define FcDirCacheCreateUUID FcDirCacheCreateUUID_dylibloader_orig_fontconfig -#define FcDirCacheDeleteUUID FcDirCacheDeleteUUID_dylibloader_orig_fontconfig #define FcConfigHome FcConfigHome_dylibloader_orig_fontconfig #define FcConfigEnableHome FcConfigEnableHome_dylibloader_orig_fontconfig #define FcConfigFilename FcConfigFilename_dylibloader_orig_fontconfig @@ -48,9 +46,6 @@ #define FcConfigSubstitute FcConfigSubstitute_dylibloader_orig_fontconfig #define FcConfigGetSysRoot FcConfigGetSysRoot_dylibloader_orig_fontconfig #define FcConfigSetSysRoot FcConfigSetSysRoot_dylibloader_orig_fontconfig -#define FcConfigFileInfoIterInit FcConfigFileInfoIterInit_dylibloader_orig_fontconfig -#define FcConfigFileInfoIterNext FcConfigFileInfoIterNext_dylibloader_orig_fontconfig -#define FcConfigFileInfoIterGet FcConfigFileInfoIterGet_dylibloader_orig_fontconfig #define FcCharSetCreate FcCharSetCreate_dylibloader_orig_fontconfig #define FcCharSetNew FcCharSetNew_dylibloader_orig_fontconfig #define FcCharSetDestroy FcCharSetDestroy_dylibloader_orig_fontconfig @@ -83,7 +78,6 @@ #define FcDirCacheLoadFile FcDirCacheLoadFile_dylibloader_orig_fontconfig #define FcDirCacheUnload FcDirCacheUnload_dylibloader_orig_fontconfig #define FcFreeTypeQuery FcFreeTypeQuery_dylibloader_orig_fontconfig -#define FcFreeTypeQueryAll FcFreeTypeQueryAll_dylibloader_orig_fontconfig #define FcFontSetCreate FcFontSetCreate_dylibloader_orig_fontconfig #define FcFontSetDestroy FcFontSetDestroy_dylibloader_orig_fontconfig #define FcFontSetAdd FcFontSetAdd_dylibloader_orig_fontconfig @@ -154,7 +148,6 @@ #define FcValueEqual FcValueEqual_dylibloader_orig_fontconfig #define FcValueSave FcValueSave_dylibloader_orig_fontconfig #define FcPatternDestroy FcPatternDestroy_dylibloader_orig_fontconfig -#define FcPatternObjectCount FcPatternObjectCount_dylibloader_orig_fontconfig #define FcPatternEqual FcPatternEqual_dylibloader_orig_fontconfig #define FcPatternEqualSubset FcPatternEqualSubset_dylibloader_orig_fontconfig #define FcPatternHash FcPatternHash_dylibloader_orig_fontconfig @@ -188,18 +181,8 @@ #define FcRangeDestroy FcRangeDestroy_dylibloader_orig_fontconfig #define FcRangeCopy FcRangeCopy_dylibloader_orig_fontconfig #define FcRangeGetDouble FcRangeGetDouble_dylibloader_orig_fontconfig -#define FcPatternIterStart FcPatternIterStart_dylibloader_orig_fontconfig -#define FcPatternIterNext FcPatternIterNext_dylibloader_orig_fontconfig -#define FcPatternIterEqual FcPatternIterEqual_dylibloader_orig_fontconfig -#define FcPatternFindIter FcPatternFindIter_dylibloader_orig_fontconfig -#define FcPatternIterIsValid FcPatternIterIsValid_dylibloader_orig_fontconfig -#define FcPatternIterGetObject FcPatternIterGetObject_dylibloader_orig_fontconfig -#define FcPatternIterValueCount FcPatternIterValueCount_dylibloader_orig_fontconfig -#define FcPatternIterGetValue FcPatternIterGetValue_dylibloader_orig_fontconfig #define FcWeightFromOpenType FcWeightFromOpenType_dylibloader_orig_fontconfig -#define FcWeightFromOpenTypeDouble FcWeightFromOpenTypeDouble_dylibloader_orig_fontconfig #define FcWeightToOpenType FcWeightToOpenType_dylibloader_orig_fontconfig -#define FcWeightToOpenTypeDouble FcWeightToOpenTypeDouble_dylibloader_orig_fontconfig #define FcStrCopy FcStrCopy_dylibloader_orig_fontconfig #define FcStrCopyFilename FcStrCopyFilename_dylibloader_orig_fontconfig #define FcStrPlus FcStrPlus_dylibloader_orig_fontconfig @@ -229,7 +212,7 @@ #define FcStrListDone FcStrListDone_dylibloader_orig_fontconfig #define FcConfigParseAndLoad FcConfigParseAndLoad_dylibloader_orig_fontconfig #define FcConfigParseAndLoadFromMemory FcConfigParseAndLoadFromMemory_dylibloader_orig_fontconfig -#include <fontconfig/fontconfig.h> +#include "thirdparty/linuxbsd_headers/fontconfig/fontconfig.h" #undef FcBlanksCreate #undef FcBlanksDestroy #undef FcBlanksAdd @@ -243,8 +226,6 @@ #undef FcDirCacheValid #undef FcDirCacheClean #undef FcCacheCreateTagFile -#undef FcDirCacheCreateUUID -#undef FcDirCacheDeleteUUID #undef FcConfigHome #undef FcConfigEnableHome #undef FcConfigFilename @@ -271,9 +252,6 @@ #undef FcConfigSubstitute #undef FcConfigGetSysRoot #undef FcConfigSetSysRoot -#undef FcConfigFileInfoIterInit -#undef FcConfigFileInfoIterNext -#undef FcConfigFileInfoIterGet #undef FcCharSetCreate #undef FcCharSetNew #undef FcCharSetDestroy @@ -306,7 +284,6 @@ #undef FcDirCacheLoadFile #undef FcDirCacheUnload #undef FcFreeTypeQuery -#undef FcFreeTypeQueryAll #undef FcFontSetCreate #undef FcFontSetDestroy #undef FcFontSetAdd @@ -377,7 +354,6 @@ #undef FcValueEqual #undef FcValueSave #undef FcPatternDestroy -#undef FcPatternObjectCount #undef FcPatternEqual #undef FcPatternEqualSubset #undef FcPatternHash @@ -411,18 +387,8 @@ #undef FcRangeDestroy #undef FcRangeCopy #undef FcRangeGetDouble -#undef FcPatternIterStart -#undef FcPatternIterNext -#undef FcPatternIterEqual -#undef FcPatternFindIter -#undef FcPatternIterIsValid -#undef FcPatternIterGetObject -#undef FcPatternIterValueCount -#undef FcPatternIterGetValue #undef FcWeightFromOpenType -#undef FcWeightFromOpenTypeDouble #undef FcWeightToOpenType -#undef FcWeightToOpenTypeDouble #undef FcStrCopy #undef FcStrCopyFilename #undef FcStrPlus @@ -468,8 +434,6 @@ extern "C" { #define FcDirCacheValid FcDirCacheValid_dylibloader_wrapper_fontconfig #define FcDirCacheClean FcDirCacheClean_dylibloader_wrapper_fontconfig #define FcCacheCreateTagFile FcCacheCreateTagFile_dylibloader_wrapper_fontconfig -#define FcDirCacheCreateUUID FcDirCacheCreateUUID_dylibloader_wrapper_fontconfig -#define FcDirCacheDeleteUUID FcDirCacheDeleteUUID_dylibloader_wrapper_fontconfig #define FcConfigHome FcConfigHome_dylibloader_wrapper_fontconfig #define FcConfigEnableHome FcConfigEnableHome_dylibloader_wrapper_fontconfig #define FcConfigFilename FcConfigFilename_dylibloader_wrapper_fontconfig @@ -496,9 +460,6 @@ extern "C" { #define FcConfigSubstitute FcConfigSubstitute_dylibloader_wrapper_fontconfig #define FcConfigGetSysRoot FcConfigGetSysRoot_dylibloader_wrapper_fontconfig #define FcConfigSetSysRoot FcConfigSetSysRoot_dylibloader_wrapper_fontconfig -#define FcConfigFileInfoIterInit FcConfigFileInfoIterInit_dylibloader_wrapper_fontconfig -#define FcConfigFileInfoIterNext FcConfigFileInfoIterNext_dylibloader_wrapper_fontconfig -#define FcConfigFileInfoIterGet FcConfigFileInfoIterGet_dylibloader_wrapper_fontconfig #define FcCharSetCreate FcCharSetCreate_dylibloader_wrapper_fontconfig #define FcCharSetNew FcCharSetNew_dylibloader_wrapper_fontconfig #define FcCharSetDestroy FcCharSetDestroy_dylibloader_wrapper_fontconfig @@ -531,7 +492,6 @@ extern "C" { #define FcDirCacheLoadFile FcDirCacheLoadFile_dylibloader_wrapper_fontconfig #define FcDirCacheUnload FcDirCacheUnload_dylibloader_wrapper_fontconfig #define FcFreeTypeQuery FcFreeTypeQuery_dylibloader_wrapper_fontconfig -#define FcFreeTypeQueryAll FcFreeTypeQueryAll_dylibloader_wrapper_fontconfig #define FcFontSetCreate FcFontSetCreate_dylibloader_wrapper_fontconfig #define FcFontSetDestroy FcFontSetDestroy_dylibloader_wrapper_fontconfig #define FcFontSetAdd FcFontSetAdd_dylibloader_wrapper_fontconfig @@ -602,7 +562,6 @@ extern "C" { #define FcValueEqual FcValueEqual_dylibloader_wrapper_fontconfig #define FcValueSave FcValueSave_dylibloader_wrapper_fontconfig #define FcPatternDestroy FcPatternDestroy_dylibloader_wrapper_fontconfig -#define FcPatternObjectCount FcPatternObjectCount_dylibloader_wrapper_fontconfig #define FcPatternEqual FcPatternEqual_dylibloader_wrapper_fontconfig #define FcPatternEqualSubset FcPatternEqualSubset_dylibloader_wrapper_fontconfig #define FcPatternHash FcPatternHash_dylibloader_wrapper_fontconfig @@ -636,18 +595,8 @@ extern "C" { #define FcRangeDestroy FcRangeDestroy_dylibloader_wrapper_fontconfig #define FcRangeCopy FcRangeCopy_dylibloader_wrapper_fontconfig #define FcRangeGetDouble FcRangeGetDouble_dylibloader_wrapper_fontconfig -#define FcPatternIterStart FcPatternIterStart_dylibloader_wrapper_fontconfig -#define FcPatternIterNext FcPatternIterNext_dylibloader_wrapper_fontconfig -#define FcPatternIterEqual FcPatternIterEqual_dylibloader_wrapper_fontconfig -#define FcPatternFindIter FcPatternFindIter_dylibloader_wrapper_fontconfig -#define FcPatternIterIsValid FcPatternIterIsValid_dylibloader_wrapper_fontconfig -#define FcPatternIterGetObject FcPatternIterGetObject_dylibloader_wrapper_fontconfig -#define FcPatternIterValueCount FcPatternIterValueCount_dylibloader_wrapper_fontconfig -#define FcPatternIterGetValue FcPatternIterGetValue_dylibloader_wrapper_fontconfig #define FcWeightFromOpenType FcWeightFromOpenType_dylibloader_wrapper_fontconfig -#define FcWeightFromOpenTypeDouble FcWeightFromOpenTypeDouble_dylibloader_wrapper_fontconfig #define FcWeightToOpenType FcWeightToOpenType_dylibloader_wrapper_fontconfig -#define FcWeightToOpenTypeDouble FcWeightToOpenTypeDouble_dylibloader_wrapper_fontconfig #define FcStrCopy FcStrCopy_dylibloader_wrapper_fontconfig #define FcStrCopyFilename FcStrCopyFilename_dylibloader_wrapper_fontconfig #define FcStrPlus FcStrPlus_dylibloader_wrapper_fontconfig @@ -690,8 +639,6 @@ extern FcBool (*FcDirCacheUnlink_dylibloader_wrapper_fontconfig)(const FcChar8*, extern FcBool (*FcDirCacheValid_dylibloader_wrapper_fontconfig)(const FcChar8*); extern FcBool (*FcDirCacheClean_dylibloader_wrapper_fontconfig)(const FcChar8*, FcBool); extern void (*FcCacheCreateTagFile_dylibloader_wrapper_fontconfig)(const FcConfig*); -extern FcBool (*FcDirCacheCreateUUID_dylibloader_wrapper_fontconfig)( FcChar8*, FcBool, FcConfig*); -extern FcBool (*FcDirCacheDeleteUUID_dylibloader_wrapper_fontconfig)(const FcChar8*, FcConfig*); extern FcChar8* (*FcConfigHome_dylibloader_wrapper_fontconfig)( void); extern FcBool (*FcConfigEnableHome_dylibloader_wrapper_fontconfig)( FcBool); extern FcChar8* (*FcConfigFilename_dylibloader_wrapper_fontconfig)(const FcChar8*); @@ -718,9 +665,6 @@ extern FcBool (*FcConfigSubstituteWithPat_dylibloader_wrapper_fontconfig)( FcCon extern FcBool (*FcConfigSubstitute_dylibloader_wrapper_fontconfig)( FcConfig*, FcPattern*, FcMatchKind); extern const FcChar8* (*FcConfigGetSysRoot_dylibloader_wrapper_fontconfig)(const FcConfig*); extern void (*FcConfigSetSysRoot_dylibloader_wrapper_fontconfig)( FcConfig*,const FcChar8*); -extern void (*FcConfigFileInfoIterInit_dylibloader_wrapper_fontconfig)( FcConfig*, FcConfigFileInfoIter*); -extern FcBool (*FcConfigFileInfoIterNext_dylibloader_wrapper_fontconfig)( FcConfig*, FcConfigFileInfoIter*); -extern FcBool (*FcConfigFileInfoIterGet_dylibloader_wrapper_fontconfig)( FcConfig*, FcConfigFileInfoIter*, FcChar8**, FcChar8**, FcBool*); extern FcCharSet* (*FcCharSetCreate_dylibloader_wrapper_fontconfig)( void); extern FcCharSet* (*FcCharSetNew_dylibloader_wrapper_fontconfig)( void); extern void (*FcCharSetDestroy_dylibloader_wrapper_fontconfig)( FcCharSet*); @@ -752,8 +696,7 @@ extern FcCache* (*FcDirCacheRescan_dylibloader_wrapper_fontconfig)(const FcChar8 extern FcCache* (*FcDirCacheRead_dylibloader_wrapper_fontconfig)(const FcChar8*, FcBool, FcConfig*); extern FcCache* (*FcDirCacheLoadFile_dylibloader_wrapper_fontconfig)(const FcChar8*,struct stat*); extern void (*FcDirCacheUnload_dylibloader_wrapper_fontconfig)( FcCache*); -extern FcPattern* (*FcFreeTypeQuery_dylibloader_wrapper_fontconfig)(const FcChar8*, unsigned int, FcBlanks*, int*); -extern unsigned int (*FcFreeTypeQueryAll_dylibloader_wrapper_fontconfig)(const FcChar8*, unsigned int, FcBlanks*, int*, FcFontSet*); +extern FcPattern* (*FcFreeTypeQuery_dylibloader_wrapper_fontconfig)(const FcChar8*, int, FcBlanks*, int*); extern FcFontSet* (*FcFontSetCreate_dylibloader_wrapper_fontconfig)( void); extern void (*FcFontSetDestroy_dylibloader_wrapper_fontconfig)( FcFontSet*); extern FcBool (*FcFontSetAdd_dylibloader_wrapper_fontconfig)( FcFontSet*, FcPattern*); @@ -824,7 +767,6 @@ extern void (*FcValueDestroy_dylibloader_wrapper_fontconfig)( FcValue); extern FcBool (*FcValueEqual_dylibloader_wrapper_fontconfig)( FcValue, FcValue); extern FcValue (*FcValueSave_dylibloader_wrapper_fontconfig)( FcValue); extern void (*FcPatternDestroy_dylibloader_wrapper_fontconfig)( FcPattern*); -extern int (*FcPatternObjectCount_dylibloader_wrapper_fontconfig)(const FcPattern*); extern FcBool (*FcPatternEqual_dylibloader_wrapper_fontconfig)(const FcPattern*,const FcPattern*); extern FcBool (*FcPatternEqualSubset_dylibloader_wrapper_fontconfig)(const FcPattern*,const FcPattern*,const FcObjectSet*); extern FcChar32 (*FcPatternHash_dylibloader_wrapper_fontconfig)(const FcPattern*); @@ -858,18 +800,8 @@ extern FcRange* (*FcRangeCreateInteger_dylibloader_wrapper_fontconfig)( FcChar32 extern void (*FcRangeDestroy_dylibloader_wrapper_fontconfig)( FcRange*); extern FcRange* (*FcRangeCopy_dylibloader_wrapper_fontconfig)(const FcRange*); extern FcBool (*FcRangeGetDouble_dylibloader_wrapper_fontconfig)(const FcRange*, double*, double*); -extern void (*FcPatternIterStart_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*); -extern FcBool (*FcPatternIterNext_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*); -extern FcBool (*FcPatternIterEqual_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*,const FcPattern*, FcPatternIter*); -extern FcBool (*FcPatternFindIter_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*,const char*); -extern FcBool (*FcPatternIterIsValid_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*); -extern const char* (*FcPatternIterGetObject_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*); -extern int (*FcPatternIterValueCount_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*); -extern FcResult (*FcPatternIterGetValue_dylibloader_wrapper_fontconfig)(const FcPattern*, FcPatternIter*, int, FcValue*, FcValueBinding*); extern int (*FcWeightFromOpenType_dylibloader_wrapper_fontconfig)( int); -extern double (*FcWeightFromOpenTypeDouble_dylibloader_wrapper_fontconfig)( double); extern int (*FcWeightToOpenType_dylibloader_wrapper_fontconfig)( int); -extern double (*FcWeightToOpenTypeDouble_dylibloader_wrapper_fontconfig)( double); extern FcChar8* (*FcStrCopy_dylibloader_wrapper_fontconfig)(const FcChar8*); extern FcChar8* (*FcStrCopyFilename_dylibloader_wrapper_fontconfig)(const FcChar8*); extern FcChar8* (*FcStrPlus_dylibloader_wrapper_fontconfig)(const FcChar8*,const FcChar8*); diff --git a/platform/linuxbsd/libudev-so_wrap.c b/platform/linuxbsd/libudev-so_wrap.c index a9fa4a494a..9593b5fb0f 100644 --- a/platform/linuxbsd/libudev-so_wrap.c +++ b/platform/linuxbsd/libudev-so_wrap.c @@ -1,7 +1,7 @@ // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by /home/hp/Projects/godot/pulse/generate-wrapper.py 0.3 on 2021-02-20 00:08:59 -// flags: /home/hp/Projects/godot/pulse/generate-wrapper.py --include /usr/include/libudev.h --sys-include <libudev.h> --soname libudev.so.1 --init-name libudev --omit-prefix gnu_ --output-header libudev-so_wrap.h --output-implementation libudev-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-12 10:23:01 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/udev/libudev.h --sys-include "thirdparty/linuxbsd_headers/udev/libudev.h" --soname libudev.so.1 --init-name libudev --omit-prefix gnu_ --output-header ./platform/linuxbsd/libudev-so_wrap.h --output-implementation ./platform/linuxbsd/libudev-so_wrap.c // #include <stdint.h> @@ -95,7 +95,7 @@ #define udev_hwdb_unref udev_hwdb_unref_dylibloader_orig_libudev #define udev_hwdb_get_properties_list_entry udev_hwdb_get_properties_list_entry_dylibloader_orig_libudev #define udev_util_encode_string udev_util_encode_string_dylibloader_orig_libudev -#include <libudev.h> +#include "thirdparty/linuxbsd_headers/udev/libudev.h" #undef udev_ref #undef udev_unref #undef udev_new @@ -229,7 +229,7 @@ const char* (*udev_device_get_action_dylibloader_wrapper_libudev)(struct udev_de unsigned long long int (*udev_device_get_seqnum_dylibloader_wrapper_libudev)(struct udev_device*); unsigned long long int (*udev_device_get_usec_since_initialized_dylibloader_wrapper_libudev)(struct udev_device*); const char* (*udev_device_get_sysattr_value_dylibloader_wrapper_libudev)(struct udev_device*,const char*); -int (*udev_device_set_sysattr_value_dylibloader_wrapper_libudev)(struct udev_device*,const char*,const char*); +int (*udev_device_set_sysattr_value_dylibloader_wrapper_libudev)(struct udev_device*,const char*, char*); int (*udev_device_has_tag_dylibloader_wrapper_libudev)(struct udev_device*,const char*); struct udev_monitor* (*udev_monitor_ref_dylibloader_wrapper_libudev)(struct udev_monitor*); struct udev_monitor* (*udev_monitor_unref_dylibloader_wrapper_libudev)(struct udev_monitor*); @@ -276,7 +276,7 @@ struct udev_list_entry* (*udev_queue_get_queued_list_entry_dylibloader_wrapper_l struct udev_hwdb* (*udev_hwdb_new_dylibloader_wrapper_libudev)(struct udev*); struct udev_hwdb* (*udev_hwdb_ref_dylibloader_wrapper_libudev)(struct udev_hwdb*); struct udev_hwdb* (*udev_hwdb_unref_dylibloader_wrapper_libudev)(struct udev_hwdb*); -struct udev_list_entry* (*udev_hwdb_get_properties_list_entry_dylibloader_wrapper_libudev)(struct udev_hwdb*,const char*, unsigned); +struct udev_list_entry* (*udev_hwdb_get_properties_list_entry_dylibloader_wrapper_libudev)(struct udev_hwdb*,const char*, unsigned int); int (*udev_util_encode_string_dylibloader_wrapper_libudev)(const char*, char*, size_t); int initialize_libudev(int verbose) { void *handle; diff --git a/platform/linuxbsd/libudev-so_wrap.h b/platform/linuxbsd/libudev-so_wrap.h index dd43fd1191..9b9627877a 100644 --- a/platform/linuxbsd/libudev-so_wrap.h +++ b/platform/linuxbsd/libudev-so_wrap.h @@ -2,8 +2,8 @@ #define DYLIBLOAD_WRAPPER_LIBUDEV // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by /home/hp/Projects/godot/pulse/generate-wrapper.py 0.3 on 2021-02-20 00:08:59 -// flags: /home/hp/Projects/godot/pulse/generate-wrapper.py --include /usr/include/libudev.h --sys-include <libudev.h> --soname libudev.so.1 --init-name libudev --omit-prefix gnu_ --output-header libudev-so_wrap.h --output-implementation libudev-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-12 10:23:01 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/udev/libudev.h --sys-include "thirdparty/linuxbsd_headers/udev/libudev.h" --soname libudev.so.1 --init-name libudev --omit-prefix gnu_ --output-header ./platform/linuxbsd/libudev-so_wrap.h --output-implementation ./platform/linuxbsd/libudev-so_wrap.c // #include <stdint.h> @@ -97,7 +97,7 @@ #define udev_hwdb_unref udev_hwdb_unref_dylibloader_orig_libudev #define udev_hwdb_get_properties_list_entry udev_hwdb_get_properties_list_entry_dylibloader_orig_libudev #define udev_util_encode_string udev_util_encode_string_dylibloader_orig_libudev -#include <libudev.h> +#include "thirdparty/linuxbsd_headers/udev/libudev.h" #undef udev_ref #undef udev_unref #undef udev_new @@ -322,7 +322,7 @@ extern const char* (*udev_device_get_action_dylibloader_wrapper_libudev)(struct extern unsigned long long int (*udev_device_get_seqnum_dylibloader_wrapper_libudev)(struct udev_device*); extern unsigned long long int (*udev_device_get_usec_since_initialized_dylibloader_wrapper_libudev)(struct udev_device*); extern const char* (*udev_device_get_sysattr_value_dylibloader_wrapper_libudev)(struct udev_device*,const char*); -extern int (*udev_device_set_sysattr_value_dylibloader_wrapper_libudev)(struct udev_device*,const char*,const char*); +extern int (*udev_device_set_sysattr_value_dylibloader_wrapper_libudev)(struct udev_device*,const char*, char*); extern int (*udev_device_has_tag_dylibloader_wrapper_libudev)(struct udev_device*,const char*); extern struct udev_monitor* (*udev_monitor_ref_dylibloader_wrapper_libudev)(struct udev_monitor*); extern struct udev_monitor* (*udev_monitor_unref_dylibloader_wrapper_libudev)(struct udev_monitor*); @@ -369,7 +369,7 @@ extern struct udev_list_entry* (*udev_queue_get_queued_list_entry_dylibloader_wr extern struct udev_hwdb* (*udev_hwdb_new_dylibloader_wrapper_libudev)(struct udev*); extern struct udev_hwdb* (*udev_hwdb_ref_dylibloader_wrapper_libudev)(struct udev_hwdb*); extern struct udev_hwdb* (*udev_hwdb_unref_dylibloader_wrapper_libudev)(struct udev_hwdb*); -extern struct udev_list_entry* (*udev_hwdb_get_properties_list_entry_dylibloader_wrapper_libudev)(struct udev_hwdb*,const char*, unsigned); +extern struct udev_list_entry* (*udev_hwdb_get_properties_list_entry_dylibloader_wrapper_libudev)(struct udev_hwdb*,const char*, unsigned int); extern int (*udev_util_encode_string_dylibloader_wrapper_libudev)(const char*, char*, size_t); int initialize_libudev(int verbose); #ifdef __cplusplus diff --git a/platform/linuxbsd/speechd-so_wrap.c b/platform/linuxbsd/speechd-so_wrap.c index 749474e181..c860c686f0 100644 --- a/platform/linuxbsd/speechd-so_wrap.c +++ b/platform/linuxbsd/speechd-so_wrap.c @@ -1,7 +1,7 @@ // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./dynload-wrapper/generate-wrapper.py 0.3 on 2022-04-28 14:34:21 -// flags: ./dynload-wrapper/generate-wrapper.py --sys-include <libspeechd.h> --include /usr/include/speech-dispatcher/libspeechd.h --soname libspeechd.so.2 --init-name speechd --omit-prefix spd_get_client_list --output-header speechd-so_wrap.h --output-implementation speechd-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-12 10:07:46 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/speechd/libspeechd.h --sys-include "thirdparty/linuxbsd_headers/speechd/libspeechd.h" --soname libspeechd.so.2 --init-name speechd --omit-prefix spd_get_client_list --output-header ./platform/linuxbsd/speechd-so_wrap.h --output-implementation ./platform/linuxbsd/speechd-so_wrap.c // #include <stdint.h> @@ -47,9 +47,6 @@ #define spd_set_voice_pitch_all spd_set_voice_pitch_all_dylibloader_orig_speechd #define spd_set_voice_pitch_uid spd_set_voice_pitch_uid_dylibloader_orig_speechd #define spd_get_voice_pitch spd_get_voice_pitch_dylibloader_orig_speechd -#define spd_set_voice_pitch_range spd_set_voice_pitch_range_dylibloader_orig_speechd -#define spd_set_voice_pitch_range_all spd_set_voice_pitch_range_all_dylibloader_orig_speechd -#define spd_set_voice_pitch_range_uid spd_set_voice_pitch_range_uid_dylibloader_orig_speechd #define spd_set_volume spd_set_volume_dylibloader_orig_speechd #define spd_set_volume_all spd_set_volume_all_dylibloader_orig_speechd #define spd_set_volume_uid spd_set_volume_uid_dylibloader_orig_speechd @@ -83,7 +80,7 @@ #define spd_execute_command_wo_mutex spd_execute_command_wo_mutex_dylibloader_orig_speechd #define spd_send_data spd_send_data_dylibloader_orig_speechd #define spd_send_data_wo_mutex spd_send_data_wo_mutex_dylibloader_orig_speechd -#include <libspeechd.h> +#include "thirdparty/linuxbsd_headers/speechd/libspeechd.h" #undef SPDConnectionAddress__free #undef spd_get_default_address #undef spd_open @@ -126,9 +123,6 @@ #undef spd_set_voice_pitch_all #undef spd_set_voice_pitch_uid #undef spd_get_voice_pitch -#undef spd_set_voice_pitch_range -#undef spd_set_voice_pitch_range_all -#undef spd_set_voice_pitch_range_uid #undef spd_set_volume #undef spd_set_volume_all #undef spd_set_volume_uid @@ -206,9 +200,6 @@ int (*spd_set_voice_pitch_dylibloader_wrapper_speechd)( SPDConnection*, signed i int (*spd_set_voice_pitch_all_dylibloader_wrapper_speechd)( SPDConnection*, signed int); int (*spd_set_voice_pitch_uid_dylibloader_wrapper_speechd)( SPDConnection*, signed int, unsigned int); int (*spd_get_voice_pitch_dylibloader_wrapper_speechd)( SPDConnection*); -int (*spd_set_voice_pitch_range_dylibloader_wrapper_speechd)( SPDConnection*, signed int); -int (*spd_set_voice_pitch_range_all_dylibloader_wrapper_speechd)( SPDConnection*, signed int); -int (*spd_set_voice_pitch_range_uid_dylibloader_wrapper_speechd)( SPDConnection*, signed int, unsigned int); int (*spd_set_volume_dylibloader_wrapper_speechd)( SPDConnection*, signed int); int (*spd_set_volume_all_dylibloader_wrapper_speechd)( SPDConnection*, signed int); int (*spd_set_volume_uid_dylibloader_wrapper_speechd)( SPDConnection*, signed int, unsigned int); @@ -589,30 +580,6 @@ int initialize_speechd(int verbose) { fprintf(stderr, "%s\n", error); } } -// spd_set_voice_pitch_range - *(void **) (&spd_set_voice_pitch_range_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_voice_pitch_range"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } -// spd_set_voice_pitch_range_all - *(void **) (&spd_set_voice_pitch_range_all_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_voice_pitch_range_all"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } -// spd_set_voice_pitch_range_uid - *(void **) (&spd_set_voice_pitch_range_uid_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_voice_pitch_range_uid"); - if (verbose) { - error = dlerror(); - if (error != NULL) { - fprintf(stderr, "%s\n", error); - } - } // spd_set_volume *(void **) (&spd_set_volume_dylibloader_wrapper_speechd) = dlsym(handle, "spd_set_volume"); if (verbose) { diff --git a/platform/linuxbsd/speechd-so_wrap.h b/platform/linuxbsd/speechd-so_wrap.h index 8e1c053348..8e0762041a 100644 --- a/platform/linuxbsd/speechd-so_wrap.h +++ b/platform/linuxbsd/speechd-so_wrap.h @@ -2,8 +2,8 @@ #define DYLIBLOAD_WRAPPER_SPEECHD // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./dynload-wrapper/generate-wrapper.py 0.3 on 2022-04-28 14:34:21 -// flags: ./dynload-wrapper/generate-wrapper.py --sys-include <libspeechd.h> --include /usr/include/speech-dispatcher/libspeechd.h --soname libspeechd.so.2 --init-name speechd --omit-prefix spd_get_client_list --output-header speechd-so_wrap.h --output-implementation speechd-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-12 10:07:46 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/speechd/libspeechd.h --sys-include "thirdparty/linuxbsd_headers/speechd/libspeechd.h" --soname libspeechd.so.2 --init-name speechd --omit-prefix spd_get_client_list --output-header ./platform/linuxbsd/speechd-so_wrap.h --output-implementation ./platform/linuxbsd/speechd-so_wrap.c // #include <stdint.h> @@ -49,9 +49,6 @@ #define spd_set_voice_pitch_all spd_set_voice_pitch_all_dylibloader_orig_speechd #define spd_set_voice_pitch_uid spd_set_voice_pitch_uid_dylibloader_orig_speechd #define spd_get_voice_pitch spd_get_voice_pitch_dylibloader_orig_speechd -#define spd_set_voice_pitch_range spd_set_voice_pitch_range_dylibloader_orig_speechd -#define spd_set_voice_pitch_range_all spd_set_voice_pitch_range_all_dylibloader_orig_speechd -#define spd_set_voice_pitch_range_uid spd_set_voice_pitch_range_uid_dylibloader_orig_speechd #define spd_set_volume spd_set_volume_dylibloader_orig_speechd #define spd_set_volume_all spd_set_volume_all_dylibloader_orig_speechd #define spd_set_volume_uid spd_set_volume_uid_dylibloader_orig_speechd @@ -85,7 +82,7 @@ #define spd_execute_command_wo_mutex spd_execute_command_wo_mutex_dylibloader_orig_speechd #define spd_send_data spd_send_data_dylibloader_orig_speechd #define spd_send_data_wo_mutex spd_send_data_wo_mutex_dylibloader_orig_speechd -#include <libspeechd.h> +#include "thirdparty/linuxbsd_headers/speechd/libspeechd.h" #undef SPDConnectionAddress__free #undef spd_get_default_address #undef spd_open @@ -128,9 +125,6 @@ #undef spd_set_voice_pitch_all #undef spd_set_voice_pitch_uid #undef spd_get_voice_pitch -#undef spd_set_voice_pitch_range -#undef spd_set_voice_pitch_range_all -#undef spd_set_voice_pitch_range_uid #undef spd_set_volume #undef spd_set_volume_all #undef spd_set_volume_uid @@ -209,9 +203,6 @@ extern "C" { #define spd_set_voice_pitch_all spd_set_voice_pitch_all_dylibloader_wrapper_speechd #define spd_set_voice_pitch_uid spd_set_voice_pitch_uid_dylibloader_wrapper_speechd #define spd_get_voice_pitch spd_get_voice_pitch_dylibloader_wrapper_speechd -#define spd_set_voice_pitch_range spd_set_voice_pitch_range_dylibloader_wrapper_speechd -#define spd_set_voice_pitch_range_all spd_set_voice_pitch_range_all_dylibloader_wrapper_speechd -#define spd_set_voice_pitch_range_uid spd_set_voice_pitch_range_uid_dylibloader_wrapper_speechd #define spd_set_volume spd_set_volume_dylibloader_wrapper_speechd #define spd_set_volume_all spd_set_volume_all_dylibloader_wrapper_speechd #define spd_set_volume_uid spd_set_volume_uid_dylibloader_wrapper_speechd @@ -287,9 +278,6 @@ extern int (*spd_set_voice_pitch_dylibloader_wrapper_speechd)( SPDConnection*, s extern int (*spd_set_voice_pitch_all_dylibloader_wrapper_speechd)( SPDConnection*, signed int); extern int (*spd_set_voice_pitch_uid_dylibloader_wrapper_speechd)( SPDConnection*, signed int, unsigned int); extern int (*spd_get_voice_pitch_dylibloader_wrapper_speechd)( SPDConnection*); -extern int (*spd_set_voice_pitch_range_dylibloader_wrapper_speechd)( SPDConnection*, signed int); -extern int (*spd_set_voice_pitch_range_all_dylibloader_wrapper_speechd)( SPDConnection*, signed int); -extern int (*spd_set_voice_pitch_range_uid_dylibloader_wrapper_speechd)( SPDConnection*, signed int, unsigned int); extern int (*spd_set_volume_dylibloader_wrapper_speechd)( SPDConnection*, signed int); extern int (*spd_set_volume_all_dylibloader_wrapper_speechd)( SPDConnection*, signed int); extern int (*spd_set_volume_uid_dylibloader_wrapper_speechd)( SPDConnection*, signed int, unsigned int); diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp index d4f82cc81e..428cf3a145 100644 --- a/platform/linuxbsd/x11/display_server_x11.cpp +++ b/platform/linuxbsd/x11/display_server_x11.cpp @@ -1324,6 +1324,8 @@ void DisplayServerX11::delete_sub_window(WindowID p_id) { } #endif + XDestroyWindow(x11_display, wd.x11_xim_window); + XUnmapWindow(x11_display, wd.x11_window); XDestroyWindow(x11_display, wd.x11_window); if (wd.xic) { @@ -1608,7 +1610,7 @@ void DisplayServerX11::window_set_transient(WindowID p_window, WindowID p_parent // a subwindow and its parent are both destroyed. if (!wd_window.no_focus && !wd_window.is_popup && wd_window.focused) { if ((xwa.map_state == IsViewable) && !wd_parent.no_focus && !wd_window.is_popup) { - XSetInputFocus(x11_display, wd_parent.x11_window, RevertToPointerRoot, CurrentTime); + XSetInputFocus(x11_display, wd_parent.x11_window, RevertToParent, CurrentTime); } } } else { @@ -2490,23 +2492,40 @@ void DisplayServerX11::window_set_ime_active(const bool p_active, WindowID p_win ERR_FAIL_COND(!windows.has(p_window)); WindowData &wd = windows[p_window]; - wd.im_active = p_active; - if (!wd.xic) { return; } + if (!wd.focused) { + wd.ime_active = false; + im_text = String(); + im_selection = Vector2i(); + return; + } // Block events polling while changing input focus // because it triggers some event polling internally. if (p_active) { - { - MutexLock mutex_lock(events_mutex); - XSetICFocus(wd.xic); + MutexLock mutex_lock(events_mutex); + + wd.ime_active = true; + + XMapWindow(x11_display, wd.x11_xim_window); + + XWindowAttributes xwa; + XSync(x11_display, False); + XGetWindowAttributes(x11_display, wd.x11_xim_window, &xwa); + if (xwa.map_state == IsViewable) { + XSetInputFocus(x11_display, wd.x11_xim_window, RevertToPointerRoot, CurrentTime); } - window_set_ime_position(wd.im_position, p_window); + XSetICFocus(wd.xic); } else { MutexLock mutex_lock(events_mutex); XUnsetICFocus(wd.xic); + XUnmapWindow(x11_display, wd.x11_xim_window); + wd.ime_active = false; + + im_text = String(); + im_selection = Vector2i(); } } @@ -2516,25 +2535,29 @@ void DisplayServerX11::window_set_ime_position(const Point2i &p_pos, WindowID p_ ERR_FAIL_COND(!windows.has(p_window)); WindowData &wd = windows[p_window]; - wd.im_position = p_pos; - if (!wd.xic) { return; } + if (!wd.focused) { + return; + } - ::XPoint spot; - spot.x = short(p_pos.x); - spot.y = short(p_pos.y); - XVaNestedList preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, nullptr); - - { - // Block events polling during this call - // because it triggers some event polling internally. - MutexLock mutex_lock(events_mutex); - XSetICValues(wd.xic, XNPreeditAttributes, preedit_attr, nullptr); + if (wd.ime_active) { + XWindowAttributes xwa; + XSync(x11_display, False); + XGetWindowAttributes(x11_display, wd.x11_xim_window, &xwa); + if (xwa.map_state == IsViewable) { + XMoveWindow(x11_display, wd.x11_xim_window, p_pos.x, p_pos.y); + } } +} + +Point2i DisplayServerX11::ime_get_selection() const { + return im_selection; +} - XFree(preedit_attr); +String DisplayServerX11::ime_get_text() const { + return im_text; } void DisplayServerX11::cursor_set_shape(CursorShape p_shape) { @@ -2872,6 +2895,16 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, // X11 functions don't know what const is XKeyEvent *xkeyevent = p_event; + if (wd.ime_in_progress) { + return; + } + if (wd.ime_suppress_next_keyup) { + wd.ime_suppress_next_keyup = false; + if (xkeyevent->type != KeyPress) { + return; + } + } + // This code was pretty difficult to write. // The docs stink and every toolkit seems to // do it in a different way. @@ -2895,13 +2928,20 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, KeySym keysym_unicode = 0; // keysym used to find unicode // XLookupString returns keysyms usable as nice keycodes. - char str[256 + 1]; + char str[256] = {}; XKeyEvent xkeyevent_no_mod = *xkeyevent; xkeyevent_no_mod.state &= ~ShiftMask; xkeyevent_no_mod.state &= ~ControlMask; - XLookupString(xkeyevent, str, 256, &keysym_unicode, nullptr); + XLookupString(xkeyevent, str, 255, &keysym_unicode, nullptr); XLookupString(&xkeyevent_no_mod, nullptr, 0, &keysym_keycode, nullptr); + String keysym; + if (xkb_keysym_to_utf32 && xkb_keysym_to_upper) { + KeySym keysym_unicode_nm = 0; // keysym used to find unicode + XLookupString(&xkeyevent_no_mod, nullptr, 0, &keysym_unicode_nm, nullptr); + keysym = String::chr(xkb_keysym_to_utf32(xkb_keysym_to_upper(keysym_unicode_nm))); + } + // Meanwhile, XLookupString returns keysyms useful for unicode. if (!xmbstring) { @@ -2950,13 +2990,18 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, _get_key_modifier_state(xkeyevent->state, k); k->set_window_id(p_window); - k->set_unicode(tmp[i]); - k->set_pressed(keypress); k->set_keycode(keycode); - - k->set_physical_keycode((Key)physical_keycode); + k->set_physical_keycode(physical_keycode); + if (!keysym.is_empty()) { + k->set_key_label(fix_key_label(keysym[0], keycode)); + } else { + k->set_key_label(keycode); + } + if (keypress) { + k->set_unicode(fix_unicode(tmp[i])); + } k->set_echo(false); @@ -2999,7 +3044,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, // KeyMappingX11 also translates keysym to unicode. // It does a binary search on a table to translate // most properly. - unsigned int unicode = keysym_unicode > 0 ? KeyMappingX11::get_unicode_from_keysym(keysym_unicode) : 0; + char32_t unicode = keysym_unicode > 0 ? KeyMappingX11::get_unicode_from_keysym(keysym_unicode) : 0; /* Phase 4, determine if event must be filtered */ @@ -3085,7 +3130,14 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, k->set_keycode(keycode); k->set_physical_keycode((Key)physical_keycode); - k->set_unicode(unicode); + if (!keysym.is_empty()) { + k->set_key_label(fix_key_label(keysym[0], keycode)); + } else { + k->set_key_label(keycode); + } + if (keypress) { + k->set_unicode(fix_unicode(unicode)); + } k->set_echo(p_echo); if (k->get_keycode() == Key::BACKTAB) { @@ -3237,6 +3289,81 @@ void DisplayServerX11::_handle_selection_request_event(XSelectionRequestEvent *p XFlush(x11_display); } +int DisplayServerX11::_xim_preedit_start_callback(::XIM xim, ::XPointer client_data, + ::XPointer call_data) { + DisplayServerX11 *ds = reinterpret_cast<DisplayServerX11 *>(client_data); + WindowID window_id = ds->_get_focused_window_or_popup(); + WindowData &wd = ds->windows[window_id]; + if (wd.ime_active) { + wd.ime_in_progress = true; + } + + return -1; // Allow preedit strings of any length (no limit). +} + +void DisplayServerX11::_xim_preedit_done_callback(::XIM xim, ::XPointer client_data, + ::XPointer call_data) { + DisplayServerX11 *ds = reinterpret_cast<DisplayServerX11 *>(client_data); + WindowID window_id = ds->_get_focused_window_or_popup(); + WindowData &wd = ds->windows[window_id]; + if (wd.ime_active) { + wd.ime_in_progress = false; + wd.ime_suppress_next_keyup = true; + } +} + +void DisplayServerX11::_xim_preedit_draw_callback(::XIM xim, ::XPointer client_data, + ::XIMPreeditDrawCallbackStruct *call_data) { + DisplayServerX11 *ds = reinterpret_cast<DisplayServerX11 *>(client_data); + WindowID window_id = ds->_get_focused_window_or_popup(); + WindowData &wd = ds->windows[window_id]; + + XIMText *xim_text = call_data->text; + if (wd.ime_active) { + if (xim_text != nullptr) { + String changed_text; + if (xim_text->encoding_is_wchar) { + changed_text = String(xim_text->string.wide_char); + } else { + changed_text.parse_utf8(xim_text->string.multi_byte); + } + + if (call_data->chg_length < 0) { + ds->im_text = ds->im_text.substr(0, call_data->chg_first) + changed_text; + } else { + ds->im_text = ds->im_text.substr(0, call_data->chg_first) + changed_text + ds->im_text.substr(call_data->chg_length); + } + + // Find the start and end of the selection. + int start = 0, count = 0; + for (int i = 0; i < xim_text->length; i++) { + if (xim_text->feedback[i] & XIMReverse) { + if (count == 0) { + start = i; + count = 1; + } else { + count++; + } + } + } + if (count > 0) { + ds->im_selection = Point2i(start + call_data->chg_first, count); + } else { + ds->im_selection = Point2i(call_data->caret, 0); + } + } else { + ds->im_text = String(); + ds->im_selection = Point2i(); + } + + OS_Unix::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_OS_IME_UPDATE); + } +} + +void DisplayServerX11::_xim_preedit_caret_callback(::XIM xim, ::XPointer client_data, + ::XIMPreeditCaretCallbackStruct *call_data) { +} + void DisplayServerX11::_xim_destroy_callback(::XIM im, ::XPointer client_data, ::XPointer call_data) { WARN_PRINT("Input method stopped"); @@ -3286,10 +3413,6 @@ void DisplayServerX11::_window_changed(XEvent *event) { if (new_rect == Rect2i(wd.position, wd.size)) { return; } - if (wd.xic) { - // Not portable. - window_set_ime_position(Point2(0, 1)); - } wd.position = new_rect.position; wd.size = new_rect.size; @@ -3637,6 +3760,7 @@ void DisplayServerX11::process_events() { continue; } + bool ime_window_event = false; WindowID window_id = MAIN_WINDOW_ID; // Assign the event to the relevant window @@ -3645,6 +3769,11 @@ void DisplayServerX11::process_events() { window_id = E.key; break; } + if (event.xany.window == E.value.x11_xim_window) { + window_id = E.key; + ime_window_event = true; + break; + } } if (XGetEventData(x11_display, &event.xcookie)) { @@ -3659,6 +3788,9 @@ void DisplayServerX11::process_events() { _refresh_device_info(); } break; case XI_RawMotion: { + if (ime_window_event) { + break; + } XIRawEvent *raw_event = (XIRawEvent *)event_data; int device_id = raw_event->sourceid; @@ -3761,6 +3893,9 @@ void DisplayServerX11::process_events() { #ifdef TOUCH_ENABLED case XI_TouchBegin: case XI_TouchEnd: { + if (ime_window_event) { + break; + } bool is_begin = event_data->evtype == XI_TouchBegin; Ref<InputEventScreenTouch> st; @@ -3791,6 +3926,9 @@ void DisplayServerX11::process_events() { } break; case XI_TouchUpdate: { + if (ime_window_event) { + break; + } HashMap<int, Vector2>::Iterator curr_pos_elem = xi.state.find(index); if (!curr_pos_elem) { // Defensive break; @@ -3817,6 +3955,9 @@ void DisplayServerX11::process_events() { switch (event.type) { case MapNotify: { DEBUG_LOG_X11("[%u] MapNotify window=%lu (%u) \n", frame, event.xmap.window, window_id); + if (ime_window_event) { + break; + } const WindowData &wd = windows[window_id]; @@ -3837,6 +3978,9 @@ void DisplayServerX11::process_events() { case Expose: { DEBUG_LOG_X11("[%u] Expose window=%lu (%u), count='%u' \n", frame, event.xexpose.window, window_id, event.xexpose.count); + if (ime_window_event) { + break; + } windows[window_id].fullscreen = _window_fullscreen_check(window_id); @@ -3845,18 +3989,27 @@ void DisplayServerX11::process_events() { case NoExpose: { DEBUG_LOG_X11("[%u] NoExpose drawable=%lu (%u) \n", frame, event.xnoexpose.drawable, window_id); + if (ime_window_event) { + break; + } windows[window_id].minimized = true; } break; case VisibilityNotify: { DEBUG_LOG_X11("[%u] VisibilityNotify window=%lu (%u), state=%u \n", frame, event.xvisibility.window, window_id, event.xvisibility.state); + if (ime_window_event) { + break; + } windows[window_id].minimized = _window_minimize_check(window_id); } break; case LeaveNotify: { DEBUG_LOG_X11("[%u] LeaveNotify window=%lu (%u), mode='%u' \n", frame, event.xcrossing.window, window_id, event.xcrossing.mode); + if (ime_window_event) { + break; + } if (!mouse_mode_grab) { _send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_EXIT); @@ -3866,6 +4019,9 @@ void DisplayServerX11::process_events() { case EnterNotify: { DEBUG_LOG_X11("[%u] EnterNotify window=%lu (%u), mode='%u' \n", frame, event.xcrossing.window, window_id, event.xcrossing.mode); + if (ime_window_event) { + break; + } if (!mouse_mode_grab) { _send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_ENTER); @@ -3874,18 +4030,14 @@ void DisplayServerX11::process_events() { case FocusIn: { DEBUG_LOG_X11("[%u] FocusIn window=%lu (%u), mode='%u' \n", frame, event.xfocus.window, window_id, event.xfocus.mode); + if (ime_window_event) { + break; + } WindowData &wd = windows[window_id]; last_focused_window = window_id; wd.focused = true; - if (wd.xic) { - // Block events polling while changing input focus - // because it triggers some event polling internally. - MutexLock mutex_lock(events_mutex); - XSetICFocus(wd.xic); - } - // Keep track of focus order for overlapping windows. static unsigned int focus_order = 0; wd.focus_order = ++focus_order; @@ -3925,17 +4077,20 @@ void DisplayServerX11::process_events() { case FocusOut: { DEBUG_LOG_X11("[%u] FocusOut window=%lu (%u), mode='%u' \n", frame, event.xfocus.window, window_id, event.xfocus.mode); - WindowData &wd = windows[window_id]; - - wd.focused = false; - - if (wd.xic) { - // Block events polling while changing input focus - // because it triggers some event polling internally. + if (wd.ime_active && event.xfocus.detail == NotifyInferior) { + break; + } + if (wd.ime_active) { MutexLock mutex_lock(events_mutex); XUnsetICFocus(wd.xic); + XUnmapWindow(x11_display, wd.x11_xim_window); + wd.ime_active = false; + im_text = String(); + im_selection = Vector2i(); + OS_Unix::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_OS_IME_UPDATE); } + wd.focused = false; Input::get_singleton()->release_pressed_events(); _send_window_event(wd, WINDOW_EVENT_FOCUS_OUT); @@ -3971,6 +4126,9 @@ void DisplayServerX11::process_events() { case ConfigureNotify: { DEBUG_LOG_X11("[%u] ConfigureNotify window=%lu (%u), event=%lu, above=%lu, override_redirect=%u \n", frame, event.xconfigure.window, window_id, event.xconfigure.event, event.xconfigure.above, event.xconfigure.override_redirect); + if (event.xconfigure.window == windows[window_id].x11_xim_window) { + break; + } const WindowData &wd = windows[window_id]; @@ -3990,6 +4148,9 @@ void DisplayServerX11::process_events() { case ButtonPress: case ButtonRelease: { + if (ime_window_event) { + break; + } /* exit in case of a mouse button press */ last_timestamp = event.xbutton.time; if (mouse_mode == MOUSE_MODE_CAPTURED) { @@ -4088,6 +4249,9 @@ void DisplayServerX11::process_events() { } break; case MotionNotify: { + if (ime_window_event) { + break; + } // The X11 API requires filtering one-by-one through the motion // notify events, in order to figure out which event is the one // generated by warping the mouse pointer. @@ -4248,7 +4412,9 @@ void DisplayServerX11::process_events() { } break; case SelectionNotify: - + if (ime_window_event) { + break; + } if (event.xselection.target == requested) { Property p = _read_property(x11_display, windows[window_id].x11_window, XInternAtom(x11_display, "PRIMARY", 0)); @@ -4283,7 +4449,9 @@ void DisplayServerX11::process_events() { break; case ClientMessage: - + if (ime_window_event) { + break; + } if ((unsigned int)event.xclient.data.l[0] == (unsigned int)wm_delete) { _send_window_event(windows[window_id], WINDOW_EVENT_CLOSE_REQUEST); } @@ -4693,6 +4861,11 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, V { wd.x11_window = XCreateWindow(x11_display, RootWindow(x11_display, visualInfo.screen), win_rect.position.x, win_rect.position.y, win_rect.size.width > 0 ? win_rect.size.width : 1, win_rect.size.height > 0 ? win_rect.size.height : 1, 0, visualInfo.depth, InputOutput, visualInfo.visual, valuemask, &windowAttributes); + XSetWindowAttributes window_attributes_ime = {}; + window_attributes_ime.event_mask = KeyPressMask | KeyReleaseMask | StructureNotifyMask | ExposureMask; + + wd.x11_xim_window = XCreateWindow(x11_display, wd.x11_window, 0, 0, 1, 1, 0, CopyFromParent, InputOnly, CopyFromParent, CWEventMask, &window_attributes_ime); + // Enable receiving notification when the window is initialized (MapNotify) // so the focus can be set at the right time. if (!wd.no_focus && !wd.is_popup) { @@ -4763,7 +4936,50 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, V // because it triggers some event polling internally. MutexLock mutex_lock(events_mutex); - wd.xic = XCreateIC(xim, XNInputStyle, xim_style, XNClientWindow, wd.x11_window, XNFocusWindow, wd.x11_window, (char *)nullptr); + // Force on-the-spot for the over-the-spot style. + if ((xim_style & XIMPreeditPosition) != 0) { + xim_style &= ~XIMPreeditPosition; + xim_style |= XIMPreeditCallbacks; + } + if ((xim_style & XIMPreeditCallbacks) != 0) { + ::XIMCallback preedit_start_callback; + preedit_start_callback.client_data = (::XPointer)(this); + preedit_start_callback.callback = (::XIMProc)(void *)(_xim_preedit_start_callback); + + ::XIMCallback preedit_done_callback; + preedit_done_callback.client_data = (::XPointer)(this); + preedit_done_callback.callback = (::XIMProc)(_xim_preedit_done_callback); + + ::XIMCallback preedit_draw_callback; + preedit_draw_callback.client_data = (::XPointer)(this); + preedit_draw_callback.callback = (::XIMProc)(_xim_preedit_draw_callback); + + ::XIMCallback preedit_caret_callback; + preedit_caret_callback.client_data = (::XPointer)(this); + preedit_caret_callback.callback = (::XIMProc)(_xim_preedit_caret_callback); + + ::XVaNestedList preedit_attributes = XVaCreateNestedList(0, + XNPreeditStartCallback, &preedit_start_callback, + XNPreeditDoneCallback, &preedit_done_callback, + XNPreeditDrawCallback, &preedit_draw_callback, + XNPreeditCaretCallback, &preedit_caret_callback, + (char *)nullptr); + + wd.xic = XCreateIC(xim, + XNInputStyle, xim_style, + XNClientWindow, wd.x11_xim_window, + XNFocusWindow, wd.x11_xim_window, + XNPreeditAttributes, preedit_attributes, + (char *)nullptr); + XFree(preedit_attributes); + } else { + wd.xic = XCreateIC(xim, + XNInputStyle, xim_style, + XNClientWindow, wd.x11_xim_window, + XNFocusWindow, wd.x11_xim_window, + (char *)nullptr); + } + if (XGetICValues(wd.xic, XNFilterEvents, &im_event_mask, nullptr) != nullptr) { WARN_PRINT("XGetICValues couldn't obtain XNFilterEvents value"); XDestroyIC(wd.xic); @@ -4854,7 +5070,66 @@ DisplayServerX11::WindowID DisplayServerX11::_create_window(WindowMode p_mode, V return id; } +static bool _is_xim_style_supported(const ::XIMStyle &p_style) { + const ::XIMStyle supported_preedit = XIMPreeditCallbacks | XIMPreeditPosition | XIMPreeditNothing | XIMPreeditNone; + const ::XIMStyle supported_status = XIMStatusNothing | XIMStatusNone; + + // Check preedit style is supported + if ((p_style & supported_preedit) == 0) { + return false; + } + + // Check status style is supported + if ((p_style & supported_status) == 0) { + return false; + } + + return true; +} + +static ::XIMStyle _get_best_xim_style(const ::XIMStyle &p_style_a, const ::XIMStyle &p_style_b) { + if (p_style_a == 0) { + return p_style_b; + } + if (p_style_b == 0) { + return p_style_a; + } + + const ::XIMStyle preedit = XIMPreeditArea | XIMPreeditCallbacks | XIMPreeditPosition | XIMPreeditNothing | XIMPreeditNone; + const ::XIMStyle status = XIMStatusArea | XIMStatusCallbacks | XIMStatusNothing | XIMStatusNone; + + ::XIMStyle a = p_style_a & preedit; + ::XIMStyle b = p_style_b & preedit; + if (a != b) { + // Compare preedit styles. + if ((a | b) & XIMPreeditCallbacks) { + return a == XIMPreeditCallbacks ? p_style_a : p_style_b; + } else if ((a | b) & XIMPreeditPosition) { + return a == XIMPreeditPosition ? p_style_a : p_style_b; + } else if ((a | b) & XIMPreeditArea) { + return a == XIMPreeditArea ? p_style_a : p_style_b; + } else if ((a | b) & XIMPreeditNothing) { + return a == XIMPreeditNothing ? p_style_a : p_style_b; + } + } else { + // Preedit styles are the same, compare status styles. + a = p_style_a & status; + b = p_style_b & status; + + if ((a | b) & XIMStatusCallbacks) { + return a == XIMStatusCallbacks ? p_style_a : p_style_b; + } else if ((a | b) & XIMStatusArea) { + return a == XIMStatusArea ? p_style_a : p_style_b; + } else if ((a | b) & XIMStatusNothing) { + return a == XIMStatusNothing ? p_style_a : p_style_b; + } + } + return p_style_a; +} + DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Error &r_error) { + KeyMappingX11::initialize(); + #ifdef DEBUG_ENABLED int dylibloader_verbose = 1; #else @@ -4870,6 +5145,8 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode ERR_FAIL_MSG("Can't load XCursor dynamically."); } + initialize_xkbcommon(dylibloader_verbose); // Optional, used for key_label. + if (initialize_xext(dylibloader_verbose) != 0) { r_error = ERR_UNAVAILABLE; ERR_FAIL_MSG("Can't load Xext dynamically."); @@ -5001,11 +5278,13 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode if (xim_styles) { xim_style = 0L; for (int i = 0; i < xim_styles->count_styles; i++) { - if (xim_styles->supported_styles[i] == - (XIMPreeditNothing | XIMStatusNothing)) { - xim_style = xim_styles->supported_styles[i]; - break; + const ::XIMStyle &style = xim_styles->supported_styles[i]; + + if (!_is_xim_style_supported(style)) { + continue; } + + xim_style = _get_best_xim_style(xim_style, style); } XFree(xim_styles); diff --git a/platform/linuxbsd/x11/display_server_x11.h b/platform/linuxbsd/x11/display_server_x11.h index 437766d953..bfb97ae44c 100644 --- a/platform/linuxbsd/x11/display_server_x11.h +++ b/platform/linuxbsd/x11/display_server_x11.h @@ -78,6 +78,8 @@ #include "dynwrappers/xrandr-so_wrap.h" #include "dynwrappers/xrender-so_wrap.h" +#include "../xkbcommon-so_wrap.h" + typedef struct _xrr_monitor_info { Atom name; Bool primary = false; @@ -135,14 +137,16 @@ class DisplayServerX11 : public DisplayServer { struct WindowData { Window x11_window; + Window x11_xim_window; ::XIC xic; + bool ime_active = false; + bool ime_in_progress = false; + bool ime_suppress_next_keyup = false; Size2i min_size; Size2i max_size; Point2i position; Size2i size; - Point2i im_position; - bool im_active = false; Callable rect_changed_callback; Callable event_callback; Callable input_event_callback; @@ -178,6 +182,9 @@ class DisplayServerX11 : public DisplayServer { unsigned int focus_order = 0; }; + Point2i im_selection; + String im_text; + HashMap<WindowID, WindowData> windows; unsigned int last_mouse_monitor_mask = 0; @@ -200,6 +207,15 @@ class DisplayServerX11 : public DisplayServer { ::Time last_keyrelease_time = 0; ::XIM xim; ::XIMStyle xim_style; + + static int _xim_preedit_start_callback(::XIM xim, ::XPointer client_data, + ::XPointer call_data); + static void _xim_preedit_done_callback(::XIM xim, ::XPointer client_data, + ::XPointer call_data); + static void _xim_preedit_draw_callback(::XIM xim, ::XPointer client_data, + ::XIMPreeditDrawCallbackStruct *call_data); + static void _xim_preedit_caret_callback(::XIM xim, ::XPointer client_data, + ::XIMPreeditCaretCallbackStruct *call_data); static void _xim_destroy_callback(::XIM im, ::XPointer client_data, ::XPointer call_data); @@ -433,6 +449,9 @@ public: virtual void window_set_ime_active(const bool p_active, WindowID p_window = MAIN_WINDOW_ID) override; virtual void window_set_ime_position(const Point2i &p_pos, WindowID p_window = MAIN_WINDOW_ID) override; + virtual Point2i ime_get_selection() const override; + virtual String ime_get_text() const override; + virtual void window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window = MAIN_WINDOW_ID) override; virtual DisplayServer::VSyncMode window_get_vsync_mode(WindowID p_vsync_mode) const override; diff --git a/platform/linuxbsd/x11/dynwrappers/xcursor-so_wrap.c b/platform/linuxbsd/x11/dynwrappers/xcursor-so_wrap.c index 7042a60d47..ecd2c25662 100644 --- a/platform/linuxbsd/x11/dynwrappers/xcursor-so_wrap.c +++ b/platform/linuxbsd/x11/dynwrappers/xcursor-so_wrap.c @@ -1,7 +1,7 @@ // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./generate-wrapper.py 0.3 on 2022-12-02 12:48:06 -// flags: ./generate-wrapper.py --include /usr/include/X11/Xcursor/Xcursor.h --sys-include <X11/Xcursor/Xcursor.h> --soname libXcursor.so.1 --init-name xcursor --output-header xcursor-so_wrap.h --output-implementation xcursor-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-23 15:09:53 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/X11/Xcursor/Xcursor.h --sys-include "thirdparty/linuxbsd_headers/X11/Xcursor/Xcursor.h" --soname libXcursor.so.1 --init-name xcursor --output-header ./platform/linuxbsd/x11/dynwrappers/xcursor-so_wrap.h --output-implementation ./platform/linuxbsd/x11/dynwrappers/xcursor-so_wrap.c // // NOTE: Generated from Xcursor 1.2.0. // This has been handpatched to workaround some issues with the generator that @@ -68,7 +68,7 @@ #define XcursorGetTheme XcursorGetTheme_dylibloader_orig_xcursor #define XcursorGetThemeCore XcursorGetThemeCore_dylibloader_orig_xcursor #define XcursorSetThemeCore XcursorSetThemeCore_dylibloader_orig_xcursor -#include <X11/Xcursor/Xcursor.h> +#include "thirdparty/linuxbsd_headers/X11/Xcursor/Xcursor.h" #undef XcursorImageCreate #undef XcursorImageDestroy #undef XcursorImagesCreate diff --git a/platform/linuxbsd/x11/dynwrappers/xcursor-so_wrap.h b/platform/linuxbsd/x11/dynwrappers/xcursor-so_wrap.h index d00fccffda..dc3684ff09 100644 --- a/platform/linuxbsd/x11/dynwrappers/xcursor-so_wrap.h +++ b/platform/linuxbsd/x11/dynwrappers/xcursor-so_wrap.h @@ -2,8 +2,8 @@ #define DYLIBLOAD_WRAPPER_XCURSOR // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./generate-wrapper.py 0.3 on 2022-12-02 12:48:06 -// flags: ./generate-wrapper.py --include /usr/include/X11/Xcursor/Xcursor.h --sys-include <X11/Xcursor/Xcursor.h> --soname libXcursor.so.1 --init-name xcursor --output-header xcursor-so_wrap.h --output-implementation xcursor-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-23 15:09:53 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/X11/Xcursor/Xcursor.h --sys-include "thirdparty/linuxbsd_headers/X11/Xcursor/Xcursor.h" --soname libXcursor.so.1 --init-name xcursor --output-header ./platform/linuxbsd/x11/dynwrappers/xcursor-so_wrap.h --output-implementation ./platform/linuxbsd/x11/dynwrappers/xcursor-so_wrap.c // // NOTE: Generated from Xcursor 1.2.0. // This has been handpatched to workaround some issues with the generator that @@ -70,7 +70,7 @@ #define XcursorGetTheme XcursorGetTheme_dylibloader_orig_xcursor #define XcursorGetThemeCore XcursorGetThemeCore_dylibloader_orig_xcursor #define XcursorSetThemeCore XcursorSetThemeCore_dylibloader_orig_xcursor -#include <X11/Xcursor/Xcursor.h> +#include "thirdparty/linuxbsd_headers/X11/Xcursor/Xcursor.h" #undef XcursorImageCreate #undef XcursorImageDestroy #undef XcursorImagesCreate diff --git a/platform/linuxbsd/x11/dynwrappers/xext-so_wrap.c b/platform/linuxbsd/x11/dynwrappers/xext-so_wrap.c index c8e87a6b85..e9af9033a3 100644 --- a/platform/linuxbsd/x11/dynwrappers/xext-so_wrap.c +++ b/platform/linuxbsd/x11/dynwrappers/xext-so_wrap.c @@ -1,7 +1,7 @@ // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./generate-wrapper.py 0.3 on 2022-12-02 12:51:55 -// flags: ./generate-wrapper.py --include /usr/include/X11/extensions/Xext.h --sys-include <X11/extensions/Xext.h> --include /usr/include/X11/extensions/shape.h --sys-include <X11/extensions/shape.h> --soname libXext.so.6 --init-name xext --output-header xext-so_wrap.h --output-implementation xext-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-23 15:11:29 +// flags: ../dynload-wrapper/generate-wrapper.py --sys-include "thirdparty/linuxbsd_headers/X11/extensions/Xext.h" --include ./thirdparty/linuxbsd_headers/X11/extensions/shape.h --sys-include "thirdparty/linuxbsd_headers/X11/extensions/shape.h" --soname libXext.so.6 --init-name xext --output-header ./platform/linuxbsd/x11/dynwrappers/xext-so_wrap.h --output-implementation ./platform/linuxbsd/x11/dynwrappers/xext-so_wrap.c // // NOTE: Generated from Xext 1.3.5. // This has been handpatched to workaround some issues with the generator that @@ -12,7 +12,7 @@ #include <stdint.h> // HANDPATCH: Needed for a successful compilation. -#include <X11/Xlib.h> +#include "thirdparty/linuxbsd_headers/X11/Xlib.h" #define XShapeQueryExtension XShapeQueryExtension_dylibloader_orig_xext #define XShapeQueryVersion XShapeQueryVersion_dylibloader_orig_xext @@ -25,8 +25,8 @@ #define XShapeSelectInput XShapeSelectInput_dylibloader_orig_xext #define XShapeInputSelected XShapeInputSelected_dylibloader_orig_xext #define XShapeGetRectangles XShapeGetRectangles_dylibloader_orig_xext -#include <X11/extensions/Xext.h> -#include <X11/extensions/shape.h> +#include "thirdparty/linuxbsd_headers/X11/extensions/Xext.h" +#include "thirdparty/linuxbsd_headers/X11/extensions/shape.h" #undef XShapeQueryExtension #undef XShapeQueryVersion #undef XShapeCombineRegion diff --git a/platform/linuxbsd/x11/dynwrappers/xext-so_wrap.h b/platform/linuxbsd/x11/dynwrappers/xext-so_wrap.h index aee92b593e..bbf23fff34 100644 --- a/platform/linuxbsd/x11/dynwrappers/xext-so_wrap.h +++ b/platform/linuxbsd/x11/dynwrappers/xext-so_wrap.h @@ -2,8 +2,8 @@ #define DYLIBLOAD_WRAPPER_XEXT // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./generate-wrapper.py 0.3 on 2022-12-02 12:51:55 -// flags: ./generate-wrapper.py --include /usr/include/X11/extensions/Xext.h --sys-include <X11/extensions/Xext.h> --include /usr/include/X11/extensions/shape.h --sys-include <X11/extensions/shape.h> --soname libXext.so.6 --init-name xext --output-header xext-so_wrap.h --output-implementation xext-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-23 15:11:29 +// flags: ../dynload-wrapper/generate-wrapper.py --sys-include "thirdparty/linuxbsd_headers/X11/extensions/Xext.h" --include ./thirdparty/linuxbsd_headers/X11/extensions/shape.h --sys-include "thirdparty/linuxbsd_headers/X11/extensions/shape.h" --soname libXext.so.6 --init-name xext --output-header ./platform/linuxbsd/x11/dynwrappers/xext-so_wrap.h --output-implementation ./platform/linuxbsd/x11/dynwrappers/xext-so_wrap.c // // NOTE: Generated from Xext 1.3.5. // This has been handpatched to workaround some issues with the generator that @@ -14,7 +14,7 @@ #include <stdint.h> // HANDPATCH: Needed for a successful compilation. -#include <X11/Xlib.h> +#include "thirdparty/linuxbsd_headers/X11/Xlib.h" #define XShapeQueryExtension XShapeQueryExtension_dylibloader_orig_xext #define XShapeQueryVersion XShapeQueryVersion_dylibloader_orig_xext @@ -27,8 +27,8 @@ #define XShapeSelectInput XShapeSelectInput_dylibloader_orig_xext #define XShapeInputSelected XShapeInputSelected_dylibloader_orig_xext #define XShapeGetRectangles XShapeGetRectangles_dylibloader_orig_xext -#include <X11/extensions/Xext.h> -#include <X11/extensions/shape.h> +#include "thirdparty/linuxbsd_headers/X11/extensions/Xext.h" +#include "thirdparty/linuxbsd_headers/X11/extensions/shape.h" #undef XShapeQueryExtension #undef XShapeQueryVersion #undef XShapeCombineRegion diff --git a/platform/linuxbsd/x11/dynwrappers/xinerama-so_wrap.c b/platform/linuxbsd/x11/dynwrappers/xinerama-so_wrap.c index 85ac80e3f2..ab53b232d6 100644 --- a/platform/linuxbsd/x11/dynwrappers/xinerama-so_wrap.c +++ b/platform/linuxbsd/x11/dynwrappers/xinerama-so_wrap.c @@ -1,7 +1,7 @@ // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./generate-wrapper.py 0.3 on 2022-12-02 12:53:11 -// flags: ./generate-wrapper.py --include /usr/include/X11/extensions/Xinerama.h --sys-include <X11/extensions/Xinerama.h> --soname libXinerama.so.1 --init-name xinerama --output-header xinerama-so_wrap.h --output-implementation xinerama-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-23 15:11:35 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/X11/extensions/Xinerama.h --sys-include "thirdparty/linuxbsd_headers/X11/extensions/Xinerama.h" --soname libXinerama.so.1 --init-name xinerama --output-header ./platform/linuxbsd/x11/dynwrappers/xinerama-so_wrap.h --output-implementation ./platform/linuxbsd/x11/dynwrappers/xinerama-so_wrap.c // // NOTE: Generated from Xinerama 1.1.4. // This has been handpatched to workaround some issues with the generator that @@ -13,7 +13,7 @@ #define XineramaQueryVersion XineramaQueryVersion_dylibloader_orig_xinerama #define XineramaIsActive XineramaIsActive_dylibloader_orig_xinerama #define XineramaQueryScreens XineramaQueryScreens_dylibloader_orig_xinerama -#include <X11/extensions/Xinerama.h> +#include "thirdparty/linuxbsd_headers/X11/extensions/Xinerama.h" #undef XineramaQueryExtension #undef XineramaQueryVersion #undef XineramaIsActive diff --git a/platform/linuxbsd/x11/dynwrappers/xinerama-so_wrap.h b/platform/linuxbsd/x11/dynwrappers/xinerama-so_wrap.h index 9139421cd6..48d5cc44b7 100644 --- a/platform/linuxbsd/x11/dynwrappers/xinerama-so_wrap.h +++ b/platform/linuxbsd/x11/dynwrappers/xinerama-so_wrap.h @@ -2,8 +2,8 @@ #define DYLIBLOAD_WRAPPER_XINERAMA // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./generate-wrapper.py 0.3 on 2022-12-02 12:53:11 -// flags: ./generate-wrapper.py --include /usr/include/X11/extensions/Xinerama.h --sys-include <X11/extensions/Xinerama.h> --soname libXinerama.so.1 --init-name xinerama --output-header xinerama-so_wrap.h --output-implementation xinerama-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-23 15:11:35 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/X11/extensions/Xinerama.h --sys-include "thirdparty/linuxbsd_headers/X11/extensions/Xinerama.h" --soname libXinerama.so.1 --init-name xinerama --output-header ./platform/linuxbsd/x11/dynwrappers/xinerama-so_wrap.h --output-implementation ./platform/linuxbsd/x11/dynwrappers/xinerama-so_wrap.c // // NOTE: Generated from Xinerama 1.1.4. // This has been handpatched to workaround some issues with the generator that @@ -15,7 +15,7 @@ #define XineramaQueryVersion XineramaQueryVersion_dylibloader_orig_xinerama #define XineramaIsActive XineramaIsActive_dylibloader_orig_xinerama #define XineramaQueryScreens XineramaQueryScreens_dylibloader_orig_xinerama -#include <X11/extensions/Xinerama.h> +#include "thirdparty/linuxbsd_headers/X11/extensions/Xinerama.h" #undef XineramaQueryExtension #undef XineramaQueryVersion #undef XineramaIsActive diff --git a/platform/linuxbsd/x11/dynwrappers/xinput2-so_wrap.c b/platform/linuxbsd/x11/dynwrappers/xinput2-so_wrap.c index 5f16bc6111..d37f2b4d94 100644 --- a/platform/linuxbsd/x11/dynwrappers/xinput2-so_wrap.c +++ b/platform/linuxbsd/x11/dynwrappers/xinput2-so_wrap.c @@ -1,7 +1,7 @@ // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./generate-wrapper.py 0.3 on 2022-12-02 12:54:10 -// flags: ./generate-wrapper.py --include /usr/include/X11/extensions/XInput2.h --sys-include <X11/extensions/XInput2.h> --soname libXi.so.6 --init-name xinput2 --output-header xinput2-so_wrap.h --output-implementation xinput2-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-23 15:12:16 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/X11/extensions/XInput2.h --sys-include "thirdparty/linuxbsd_headers/X11/extensions/XInput2.h" --soname libXi.so.6 --init-name xinput2 --output-header ./platform/linuxbsd/x11/dynwrappers/xinput2-so_wrap.h --output-implementation ./platform/linuxbsd/x11/dynwrappers/xinput2-so_wrap.c // // NOTE: Generated from Xi 1.7.10. // This has been handpatched to workaround some issues with the generator that @@ -43,7 +43,7 @@ #define XIBarrierReleasePointers XIBarrierReleasePointers_dylibloader_orig_xinput2 #define XIBarrierReleasePointer XIBarrierReleasePointer_dylibloader_orig_xinput2 #define XIFreeDeviceInfo XIFreeDeviceInfo_dylibloader_orig_xinput2 -#include <X11/extensions/XInput2.h> +#include "thirdparty/linuxbsd_headers/X11/extensions/XInput2.h" #undef XIQueryPointer #undef XIWarpPointer #undef XIDefineCursor diff --git a/platform/linuxbsd/x11/dynwrappers/xinput2-so_wrap.h b/platform/linuxbsd/x11/dynwrappers/xinput2-so_wrap.h index ecb7aa5048..e39661ffb9 100644 --- a/platform/linuxbsd/x11/dynwrappers/xinput2-so_wrap.h +++ b/platform/linuxbsd/x11/dynwrappers/xinput2-so_wrap.h @@ -2,8 +2,8 @@ #define DYLIBLOAD_WRAPPER_XINPUT2 // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./generate-wrapper.py 0.3 on 2022-12-02 12:54:10 -// flags: ./generate-wrapper.py --include /usr/include/X11/extensions/XInput2.h --sys-include <X11/extensions/XInput2.h> --soname libXi.so.6 --init-name xinput2 --output-header xinput2-so_wrap.h --output-implementation xinput2-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-23 15:12:16 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/X11/extensions/XInput2.h --sys-include "thirdparty/linuxbsd_headers/X11/extensions/XInput2.h" --soname libXi.so.6 --init-name xinput2 --output-header ./platform/linuxbsd/x11/dynwrappers/xinput2-so_wrap.h --output-implementation ./platform/linuxbsd/x11/dynwrappers/xinput2-so_wrap.c // // NOTE: Generated from Xi 1.7.10. // This has been handpatched to workaround some issues with the generator that @@ -45,7 +45,7 @@ #define XIBarrierReleasePointers XIBarrierReleasePointers_dylibloader_orig_xinput2 #define XIBarrierReleasePointer XIBarrierReleasePointer_dylibloader_orig_xinput2 #define XIFreeDeviceInfo XIFreeDeviceInfo_dylibloader_orig_xinput2 -#include <X11/extensions/XInput2.h> +#include "thirdparty/linuxbsd_headers/X11/extensions/XInput2.h" #undef XIQueryPointer #undef XIWarpPointer #undef XIDefineCursor diff --git a/platform/linuxbsd/x11/dynwrappers/xlib-so_wrap.c b/platform/linuxbsd/x11/dynwrappers/xlib-so_wrap.c index 12097a2987..a746b6c526 100644 --- a/platform/linuxbsd/x11/dynwrappers/xlib-so_wrap.c +++ b/platform/linuxbsd/x11/dynwrappers/xlib-so_wrap.c @@ -1,7 +1,7 @@ // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./generate-wrapper.py 0.3 on 2022-12-02 12:54:53 -// flags: ./generate-wrapper.py --include /usr/include/X11/Xlib.h --include /usr/include/X11/Xutil.h --include /usr/include/X11/XKBlib.h --sys-include <X11/Xlib.h> --sys-include <X11/Xutil.h> --sys-include <X11/XKBlib.h> --soname libX11.so.6 --init-name xlib --omit-prefix XkbGetDeviceIndicatorState --omit-prefix XkbAddSymInterpret --output-header xlib-so_wrap.h --output-implementation xlib-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-23 15:13:26 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/X11/Xlib.h --include ./thirdparty/linuxbsd_headers/X11/Xutil.h --include ./thirdparty/linuxbsd_headers/X11/XKBlib.h --sys-include "thirdparty/linuxbsd_headers/X11/Xlib.h" --sys-include "thirdparty/linuxbsd_headers/X11/Xutil.h" --sys-include "thirdparty/linuxbsd_headers/X11/XKBlib.h" --soname libX11.so.6 --init-name xlib --omit-prefix XkbGetDeviceIndicatorState --omit-prefix XkbAddSymInterpret --output-header ./platform/linuxbsd/x11/dynwrappers/xlib-so_wrap.h --output-implementation ./platform/linuxbsd/x11/dynwrappers/xlib-so_wrap.c~ // // NOTE: Generated from Xlib 1.6.9. // This has been handpatched to workaround some issues with the generator that @@ -614,9 +614,9 @@ #define XkbApplyVirtualModChanges XkbApplyVirtualModChanges_dylibloader_orig_xlib #define XkbUpdateActionVirtualMods XkbUpdateActionVirtualMods_dylibloader_orig_xlib #define XkbUpdateKeyTypeVirtualMods XkbUpdateKeyTypeVirtualMods_dylibloader_orig_xlib -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/XKBlib.h> +#include "thirdparty/linuxbsd_headers/X11/Xlib.h" +#include "thirdparty/linuxbsd_headers/X11/Xutil.h" +#include "thirdparty/linuxbsd_headers/X11/XKBlib.h" #undef _Xmblen #undef XLoadQueryFont #undef XQueryFont diff --git a/platform/linuxbsd/x11/dynwrappers/xlib-so_wrap.h b/platform/linuxbsd/x11/dynwrappers/xlib-so_wrap.h index 47464078e3..b40a25f601 100644 --- a/platform/linuxbsd/x11/dynwrappers/xlib-so_wrap.h +++ b/platform/linuxbsd/x11/dynwrappers/xlib-so_wrap.h @@ -2,8 +2,8 @@ #define DYLIBLOAD_WRAPPER_XLIB // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./generate-wrapper.py 0.3 on 2022-12-02 12:54:53 -// flags: ./generate-wrapper.py --include /usr/include/X11/Xlib.h --include /usr/include/X11/Xutil.h --include /usr/include/X11/XKBlib.h --sys-include <X11/Xlib.h> --sys-include <X11/Xutil.h> --sys-include <X11/XKBlib.h> --soname libX11.so.6 --init-name xlib --omit-prefix XkbGetDeviceIndicatorState --omit-prefix XkbAddSymInterpret --output-header xlib-so_wrap.h --output-implementation xlib-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-23 15:13:26 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/X11/Xlib.h --include ./thirdparty/linuxbsd_headers/X11/Xutil.h --include ./thirdparty/linuxbsd_headers/X11/XKBlib.h --sys-include "thirdparty/linuxbsd_headers/X11/Xlib.h" --sys-include "thirdparty/linuxbsd_headers/X11/Xutil.h" --sys-include "thirdparty/linuxbsd_headers/X11/XKBlib.h" --soname libX11.so.6 --init-name xlib --omit-prefix XkbGetDeviceIndicatorState --omit-prefix XkbAddSymInterpret --output-header ./platform/linuxbsd/x11/dynwrappers/xlib-so_wrap.h --output-implementation ./platform/linuxbsd/x11/dynwrappers/xlib-so_wrap.c~ // // NOTE: Generated from Xlib 1.6.9. // This has been handpatched to workaround some issues with the generator that @@ -617,9 +617,9 @@ #define XkbApplyVirtualModChanges XkbApplyVirtualModChanges_dylibloader_orig_xlib #define XkbUpdateActionVirtualMods XkbUpdateActionVirtualMods_dylibloader_orig_xlib #define XkbUpdateKeyTypeVirtualMods XkbUpdateKeyTypeVirtualMods_dylibloader_orig_xlib -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#include <X11/XKBlib.h> +#include "thirdparty/linuxbsd_headers/X11/Xlib.h" +#include "thirdparty/linuxbsd_headers/X11/Xutil.h" +#include "thirdparty/linuxbsd_headers/X11/XKBlib.h" #undef _Xmblen #undef XLoadQueryFont #undef XQueryFont diff --git a/platform/linuxbsd/x11/dynwrappers/xrandr-so_wrap.c b/platform/linuxbsd/x11/dynwrappers/xrandr-so_wrap.c index f37f3a9db0..21e30a03de 100644 --- a/platform/linuxbsd/x11/dynwrappers/xrandr-so_wrap.c +++ b/platform/linuxbsd/x11/dynwrappers/xrandr-so_wrap.c @@ -1,7 +1,7 @@ // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./generate-wrapper.py 0.3 on 2022-12-02 12:55:12 -// flags: ./generate-wrapper.py --include /usr/include/X11/extensions/Xrandr.h --sys-include <X11/extensions/Xrandr.h> --soname libXrandr.so.2 --init-name xrandr --output-header xrandr-so_wrap.h --output-implementation xrandr-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-23 15:13:54 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/X11/extensions/Xrandr.h --sys-include "thirdparty/linuxbsd_headers/X11/extensions/Xrandr.h" --soname libXrandr.so.2 --init-name xrandr --output-header ./platform/linuxbsd/x11/dynwrappers/xrandr-so_wrap.h --output-implementation ./platform/linuxbsd/x11/dynwrappers/xrandr-so_wrap.c // // NOTE: Generated from Xrandr 1.5.2. // This has been handpatched to workaround some issues with the generator that @@ -79,7 +79,7 @@ #define XRRSetMonitor XRRSetMonitor_dylibloader_orig_xrandr #define XRRDeleteMonitor XRRDeleteMonitor_dylibloader_orig_xrandr #define XRRFreeMonitors XRRFreeMonitors_dylibloader_orig_xrandr -#include <X11/extensions/Xrandr.h> +#include "thirdparty/linuxbsd_headers/X11/extensions/Xrandr.h" #undef XRRQueryExtension #undef XRRQueryVersion #undef XRRGetScreenInfo diff --git a/platform/linuxbsd/x11/dynwrappers/xrandr-so_wrap.h b/platform/linuxbsd/x11/dynwrappers/xrandr-so_wrap.h index 046d4c7de3..f301234b53 100644 --- a/platform/linuxbsd/x11/dynwrappers/xrandr-so_wrap.h +++ b/platform/linuxbsd/x11/dynwrappers/xrandr-so_wrap.h @@ -2,8 +2,8 @@ #define DYLIBLOAD_WRAPPER_XRANDR // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./generate-wrapper.py 0.3 on 2022-12-02 12:55:12 -// flags: ./generate-wrapper.py --include /usr/include/X11/extensions/Xrandr.h --sys-include <X11/extensions/Xrandr.h> --soname libXrandr.so.2 --init-name xrandr --output-header xrandr-so_wrap.h --output-implementation xrandr-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-23 15:13:54 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/X11/extensions/Xrandr.h --sys-include "thirdparty/linuxbsd_headers/X11/extensions/Xrandr.h" --soname libXrandr.so.2 --init-name xrandr --output-header ./platform/linuxbsd/x11/dynwrappers/xrandr-so_wrap.h --output-implementation ./platform/linuxbsd/x11/dynwrappers/xrandr-so_wrap.c // // NOTE: Generated from Xrandr 1.5.2. // This has been handpatched to workaround some issues with the generator that @@ -81,7 +81,7 @@ #define XRRSetMonitor XRRSetMonitor_dylibloader_orig_xrandr #define XRRDeleteMonitor XRRDeleteMonitor_dylibloader_orig_xrandr #define XRRFreeMonitors XRRFreeMonitors_dylibloader_orig_xrandr -#include <X11/extensions/Xrandr.h> +#include "thirdparty/linuxbsd_headers/X11/extensions/Xrandr.h" #undef XRRQueryExtension #undef XRRQueryVersion #undef XRRGetScreenInfo diff --git a/platform/linuxbsd/x11/dynwrappers/xrender-so_wrap.c b/platform/linuxbsd/x11/dynwrappers/xrender-so_wrap.c index 2d3847e584..5c720bee21 100644 --- a/platform/linuxbsd/x11/dynwrappers/xrender-so_wrap.c +++ b/platform/linuxbsd/x11/dynwrappers/xrender-so_wrap.c @@ -1,7 +1,7 @@ // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./generate-wrapper.py 0.3 on 2022-12-02 12:55:28 -// flags: ./generate-wrapper.py --include /usr/include/X11/extensions/Xrender.h --sys-include <X11/extensions/Xrender.h> --soname libXrender.so.1 --init-name xrender --output-header xrender-so_wrap.h --output-implementation xrender-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-23 15:14:14 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/X11/extensions/Xrender.h --sys-include "thirdparty/linuxbsd_headers/X11/extensions/Xrender.h" --soname libXrender.so.1 --init-name xrender --output-header ./platform/linuxbsd/x11/dynwrappers/xrender-so_wrap.h --output-implementation ./platform/linuxbsd/x11/dynwrappers/xrender-so_wrap.c~ // // NOTE: Generated from Xrender 0.9.10. // This has been handpatched to workaround some issues with the generator that @@ -53,7 +53,7 @@ #define XRenderCreateLinearGradient XRenderCreateLinearGradient_dylibloader_orig_xrender #define XRenderCreateRadialGradient XRenderCreateRadialGradient_dylibloader_orig_xrender #define XRenderCreateConicalGradient XRenderCreateConicalGradient_dylibloader_orig_xrender -#include <X11/extensions/Xrender.h> +#include "thirdparty/linuxbsd_headers/X11/extensions/Xrender.h" #undef XRenderQueryExtension #undef XRenderQueryVersion #undef XRenderQueryFormats diff --git a/platform/linuxbsd/x11/dynwrappers/xrender-so_wrap.h b/platform/linuxbsd/x11/dynwrappers/xrender-so_wrap.h index e873448ec5..29a8430476 100644 --- a/platform/linuxbsd/x11/dynwrappers/xrender-so_wrap.h +++ b/platform/linuxbsd/x11/dynwrappers/xrender-so_wrap.h @@ -2,8 +2,8 @@ #define DYLIBLOAD_WRAPPER_XRENDER // This file is generated. Do not edit! // see https://github.com/hpvb/dynload-wrapper for details -// generated by ./generate-wrapper.py 0.3 on 2022-12-02 12:55:28 -// flags: ./generate-wrapper.py --include /usr/include/X11/extensions/Xrender.h --sys-include <X11/extensions/Xrender.h> --soname libXrender.so.1 --init-name xrender --output-header xrender-so_wrap.h --output-implementation xrender-so_wrap.c +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-23 15:14:14 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/X11/extensions/Xrender.h --sys-include "thirdparty/linuxbsd_headers/X11/extensions/Xrender.h" --soname libXrender.so.1 --init-name xrender --output-header ./platform/linuxbsd/x11/dynwrappers/xrender-so_wrap.h --output-implementation ./platform/linuxbsd/x11/dynwrappers/xrender-so_wrap.c~ // // NOTE: Generated from Xrender 0.9.10. // This has been handpatched to workaround some issues with the generator that @@ -55,7 +55,7 @@ #define XRenderCreateLinearGradient XRenderCreateLinearGradient_dylibloader_orig_xrender #define XRenderCreateRadialGradient XRenderCreateRadialGradient_dylibloader_orig_xrender #define XRenderCreateConicalGradient XRenderCreateConicalGradient_dylibloader_orig_xrender -#include <X11/extensions/Xrender.h> +#include "thirdparty/linuxbsd_headers/X11/extensions/Xrender.h" #undef XRenderQueryExtension #undef XRenderQueryVersion #undef XRenderQueryFormats diff --git a/platform/linuxbsd/x11/key_mapping_x11.cpp b/platform/linuxbsd/x11/key_mapping_x11.cpp index 52b7e865bd..e5eba6ccad 100644 --- a/platform/linuxbsd/x11/key_mapping_x11.cpp +++ b/platform/linuxbsd/x11/key_mapping_x11.cpp @@ -30,1972 +30,1122 @@ #include "key_mapping_x11.h" -/***** SCAN CODE CONVERSION ******/ +void KeyMappingX11::initialize() { + // X11 Keysym to Godot Key map. -struct _XTranslatePair { - KeySym keysym; - Key keycode; -}; + xkeysym_map[XK_Escape] = Key::ESCAPE; + xkeysym_map[XK_Tab] = Key::TAB; + xkeysym_map[XK_ISO_Left_Tab] = Key::BACKTAB; + xkeysym_map[XK_BackSpace] = Key::BACKSPACE; + xkeysym_map[XK_Return] = Key::ENTER; + xkeysym_map[XK_Insert] = Key::INSERT; + xkeysym_map[XK_Delete] = Key::KEY_DELETE; + xkeysym_map[XK_Clear] = Key::KEY_DELETE; + xkeysym_map[XK_Pause] = Key::PAUSE; + xkeysym_map[XK_Print] = Key::PRINT; + xkeysym_map[XK_Home] = Key::HOME; + xkeysym_map[XK_End] = Key::END; + xkeysym_map[XK_Left] = Key::LEFT; + xkeysym_map[XK_Up] = Key::UP; + xkeysym_map[XK_Right] = Key::RIGHT; + xkeysym_map[XK_Down] = Key::DOWN; + xkeysym_map[XK_Prior] = Key::PAGEUP; + xkeysym_map[XK_Next] = Key::PAGEDOWN; + xkeysym_map[XK_Shift_L] = Key::SHIFT; + xkeysym_map[XK_Shift_R] = Key::SHIFT; + xkeysym_map[XK_Shift_Lock] = Key::SHIFT; + xkeysym_map[XK_Control_L] = Key::CTRL; + xkeysym_map[XK_Control_R] = Key::CTRL; + xkeysym_map[XK_Meta_L] = Key::META; + xkeysym_map[XK_Meta_R] = Key::META; + xkeysym_map[XK_Alt_L] = Key::ALT; + xkeysym_map[XK_Alt_R] = Key::ALT; + xkeysym_map[XK_Caps_Lock] = Key::CAPSLOCK; + xkeysym_map[XK_Num_Lock] = Key::NUMLOCK; + xkeysym_map[XK_Scroll_Lock] = Key::SCROLLLOCK; + xkeysym_map[XK_less] = Key::QUOTELEFT; + xkeysym_map[XK_grave] = Key::SECTION; + xkeysym_map[XK_Super_L] = Key::META; + xkeysym_map[XK_Super_R] = Key::META; + xkeysym_map[XK_Menu] = Key::MENU; + xkeysym_map[XK_Hyper_L] = Key::HYPER; + xkeysym_map[XK_Hyper_R] = Key::HYPER; + xkeysym_map[XK_Help] = Key::HELP; + xkeysym_map[XK_KP_Space] = Key::SPACE; + xkeysym_map[XK_KP_Tab] = Key::TAB; + xkeysym_map[XK_KP_Enter] = Key::KP_ENTER; + xkeysym_map[XK_Home] = Key::HOME; + xkeysym_map[XK_Left] = Key::LEFT; + xkeysym_map[XK_Up] = Key::UP; + xkeysym_map[XK_Right] = Key::RIGHT; + xkeysym_map[XK_Down] = Key::DOWN; + xkeysym_map[XK_Prior] = Key::PAGEUP; + xkeysym_map[XK_Next] = Key::PAGEDOWN; + xkeysym_map[XK_End] = Key::END; + xkeysym_map[XK_Begin] = Key::CLEAR; + xkeysym_map[XK_Insert] = Key::INSERT; + xkeysym_map[XK_Delete] = Key::KEY_DELETE; + //xkeysym_map[XK_KP_Equal] + //xkeysym_map[XK_KP_Separator] + xkeysym_map[XK_KP_Decimal] = Key::KP_PERIOD; + xkeysym_map[XK_KP_Delete] = Key::KP_PERIOD; + xkeysym_map[XK_KP_Multiply] = Key::KP_MULTIPLY; + xkeysym_map[XK_KP_Divide] = Key::KP_DIVIDE; + xkeysym_map[XK_KP_Subtract] = Key::KP_SUBTRACT; + xkeysym_map[XK_KP_Add] = Key::KP_ADD; + xkeysym_map[XK_KP_0] = Key::KP_0; + xkeysym_map[XK_KP_1] = Key::KP_1; + xkeysym_map[XK_KP_2] = Key::KP_2; + xkeysym_map[XK_KP_3] = Key::KP_3; + xkeysym_map[XK_KP_4] = Key::KP_4; + xkeysym_map[XK_KP_5] = Key::KP_5; + xkeysym_map[XK_KP_6] = Key::KP_6; + xkeysym_map[XK_KP_7] = Key::KP_7; + xkeysym_map[XK_KP_8] = Key::KP_8; + xkeysym_map[XK_KP_9] = Key::KP_9; + // Same keys but with numlock off. + xkeysym_map[XK_KP_Insert] = Key::INSERT; + xkeysym_map[XK_KP_End] = Key::END; + xkeysym_map[XK_KP_Down] = Key::DOWN; + xkeysym_map[XK_KP_Page_Down] = Key::PAGEDOWN; + xkeysym_map[XK_KP_Left] = Key::LEFT; + // X11 documents this (numpad 5) as "begin of line" but no toolkit seems to interpret it this way. + // On Windows this is emitting Key::Clear so for consistency it will be mapped to Key::Clear + xkeysym_map[XK_KP_Begin] = Key::CLEAR; + xkeysym_map[XK_KP_Right] = Key::RIGHT; + xkeysym_map[XK_KP_Home] = Key::HOME; + xkeysym_map[XK_KP_Up] = Key::UP; + xkeysym_map[XK_KP_Page_Up] = Key::PAGEUP; + xkeysym_map[XK_F1] = Key::F1; + xkeysym_map[XK_F2] = Key::F2; + xkeysym_map[XK_F3] = Key::F3; + xkeysym_map[XK_F4] = Key::F4; + xkeysym_map[XK_F5] = Key::F5; + xkeysym_map[XK_F6] = Key::F6; + xkeysym_map[XK_F7] = Key::F7; + xkeysym_map[XK_F8] = Key::F8; + xkeysym_map[XK_F9] = Key::F9; + xkeysym_map[XK_F10] = Key::F10; + xkeysym_map[XK_F11] = Key::F11; + xkeysym_map[XK_F12] = Key::F12; + xkeysym_map[XK_F13] = Key::F13; + xkeysym_map[XK_F14] = Key::F14; + xkeysym_map[XK_F15] = Key::F15; + xkeysym_map[XK_F16] = Key::F16; + xkeysym_map[XK_F17] = Key::F17; + xkeysym_map[XK_F18] = Key::F18; + xkeysym_map[XK_F19] = Key::F19; + xkeysym_map[XK_F20] = Key::F20; + xkeysym_map[XK_F21] = Key::F21; + xkeysym_map[XK_F22] = Key::F22; + xkeysym_map[XK_F23] = Key::F23; + xkeysym_map[XK_F24] = Key::F24; + xkeysym_map[XK_F25] = Key::F25; + xkeysym_map[XK_F26] = Key::F26; + xkeysym_map[XK_F27] = Key::F27; + xkeysym_map[XK_F28] = Key::F28; + xkeysym_map[XK_F29] = Key::F29; + xkeysym_map[XK_F30] = Key::F30; + xkeysym_map[XK_F31] = Key::F31; + xkeysym_map[XK_F32] = Key::F32; + xkeysym_map[XK_F33] = Key::F33; + xkeysym_map[XK_F34] = Key::F34; + xkeysym_map[XK_F35] = Key::F35; + xkeysym_map[XK_yen] = Key::YEN; + xkeysym_map[XK_section] = Key::SECTION; + // Media keys. + xkeysym_map[XF86XK_Back] = Key::BACK; + xkeysym_map[XF86XK_Forward] = Key::FORWARD; + xkeysym_map[XF86XK_Stop] = Key::STOP; + xkeysym_map[XF86XK_Refresh] = Key::REFRESH; + xkeysym_map[XF86XK_Favorites] = Key::FAVORITES; + xkeysym_map[XF86XK_OpenURL] = Key::OPENURL; + xkeysym_map[XF86XK_HomePage] = Key::HOMEPAGE; + xkeysym_map[XF86XK_Search] = Key::SEARCH; + xkeysym_map[XF86XK_AudioLowerVolume] = Key::VOLUMEDOWN; + xkeysym_map[XF86XK_AudioMute] = Key::VOLUMEMUTE; + xkeysym_map[XF86XK_AudioRaiseVolume] = Key::VOLUMEUP; + xkeysym_map[XF86XK_AudioPlay] = Key::MEDIAPLAY; + xkeysym_map[XF86XK_AudioStop] = Key::MEDIASTOP; + xkeysym_map[XF86XK_AudioPrev] = Key::MEDIAPREVIOUS; + xkeysym_map[XF86XK_AudioNext] = Key::MEDIANEXT; + xkeysym_map[XF86XK_AudioRecord] = Key::MEDIARECORD; + xkeysym_map[XF86XK_Standby] = Key::STANDBY; + // Launch keys. + xkeysym_map[XF86XK_Mail] = Key::LAUNCHMAIL; + xkeysym_map[XF86XK_AudioMedia] = Key::LAUNCHMEDIA; + xkeysym_map[XF86XK_MyComputer] = Key::LAUNCH0; + xkeysym_map[XF86XK_Calculator] = Key::LAUNCH1; + xkeysym_map[XF86XK_Launch0] = Key::LAUNCH2; + xkeysym_map[XF86XK_Launch1] = Key::LAUNCH3; + xkeysym_map[XF86XK_Launch2] = Key::LAUNCH4; + xkeysym_map[XF86XK_Launch3] = Key::LAUNCH5; + xkeysym_map[XF86XK_Launch4] = Key::LAUNCH6; + xkeysym_map[XF86XK_Launch5] = Key::LAUNCH7; + xkeysym_map[XF86XK_Launch6] = Key::LAUNCH8; + xkeysym_map[XF86XK_Launch7] = Key::LAUNCH9; + xkeysym_map[XF86XK_Launch8] = Key::LAUNCHA; + xkeysym_map[XF86XK_Launch9] = Key::LAUNCHB; + xkeysym_map[XF86XK_LaunchA] = Key::LAUNCHC; + xkeysym_map[XF86XK_LaunchB] = Key::LAUNCHD; + xkeysym_map[XF86XK_LaunchC] = Key::LAUNCHE; + xkeysym_map[XF86XK_LaunchD] = Key::LAUNCHF; -static _XTranslatePair _xkeysym_to_keycode[] = { - // misc keys + // Scancode to Godot Key map. + scancode_map[0x09] = Key::ESCAPE; + scancode_map[0x0A] = Key::KEY_1; + scancode_map[0x0B] = Key::KEY_2; + scancode_map[0x0C] = Key::KEY_3; + scancode_map[0x0D] = Key::KEY_4; + scancode_map[0x0E] = Key::KEY_5; + scancode_map[0x0F] = Key::KEY_6; + scancode_map[0x10] = Key::KEY_7; + scancode_map[0x11] = Key::KEY_8; + scancode_map[0x12] = Key::KEY_9; + scancode_map[0x13] = Key::KEY_0; + scancode_map[0x14] = Key::MINUS; + scancode_map[0x15] = Key::EQUAL; + scancode_map[0x16] = Key::BACKSPACE; + scancode_map[0x17] = Key::TAB; + scancode_map[0x18] = Key::Q; + scancode_map[0x19] = Key::W; + scancode_map[0x1A] = Key::E; + scancode_map[0x1B] = Key::R; + scancode_map[0x1C] = Key::T; + scancode_map[0x1D] = Key::Y; + scancode_map[0x1E] = Key::U; + scancode_map[0x1F] = Key::I; + scancode_map[0x20] = Key::O; + scancode_map[0x21] = Key::P; + scancode_map[0x22] = Key::BRACELEFT; + scancode_map[0x23] = Key::BRACERIGHT; + scancode_map[0x24] = Key::ENTER; + scancode_map[0x25] = Key::CTRL; + scancode_map[0x26] = Key::A; + scancode_map[0x27] = Key::S; + scancode_map[0x28] = Key::D; + scancode_map[0x29] = Key::F; + scancode_map[0x2A] = Key::G; + scancode_map[0x2B] = Key::H; + scancode_map[0x2C] = Key::J; + scancode_map[0x2D] = Key::K; + scancode_map[0x2E] = Key::L; + scancode_map[0x2F] = Key::SEMICOLON; + scancode_map[0x30] = Key::APOSTROPHE; + scancode_map[0x31] = Key::SECTION; + scancode_map[0x32] = Key::SHIFT; + scancode_map[0x33] = Key::BACKSLASH; + scancode_map[0x34] = Key::Z; + scancode_map[0x35] = Key::X; + scancode_map[0x36] = Key::C; + scancode_map[0x37] = Key::V; + scancode_map[0x38] = Key::B; + scancode_map[0x39] = Key::N; + scancode_map[0x3A] = Key::M; + scancode_map[0x3B] = Key::COMMA; + scancode_map[0x3C] = Key::PERIOD; + scancode_map[0x3D] = Key::SLASH; + scancode_map[0x3E] = Key::SHIFT; + scancode_map[0x3F] = Key::KP_MULTIPLY; + scancode_map[0x40] = Key::ALT; + scancode_map[0x41] = Key::SPACE; + scancode_map[0x42] = Key::CAPSLOCK; + scancode_map[0x43] = Key::F1; + scancode_map[0x44] = Key::F2; + scancode_map[0x45] = Key::F3; + scancode_map[0x46] = Key::F4; + scancode_map[0x47] = Key::F5; + scancode_map[0x48] = Key::F6; + scancode_map[0x49] = Key::F7; + scancode_map[0x4A] = Key::F8; + scancode_map[0x4B] = Key::F9; + scancode_map[0x4C] = Key::F10; + scancode_map[0x4D] = Key::NUMLOCK; + scancode_map[0x4E] = Key::SCROLLLOCK; + scancode_map[0x4F] = Key::KP_7; + scancode_map[0x50] = Key::KP_8; + scancode_map[0x51] = Key::KP_9; + scancode_map[0x52] = Key::KP_SUBTRACT; + scancode_map[0x53] = Key::KP_4; + scancode_map[0x54] = Key::KP_5; + scancode_map[0x55] = Key::KP_6; + scancode_map[0x56] = Key::KP_ADD; + scancode_map[0x57] = Key::KP_1; + scancode_map[0x58] = Key::KP_2; + scancode_map[0x59] = Key::KP_3; + scancode_map[0x5A] = Key::KP_0; + scancode_map[0x5B] = Key::KP_PERIOD; + scancode_map[0x5E] = Key::QUOTELEFT; + scancode_map[0x5F] = Key::F11; + scancode_map[0x60] = Key::F12; + scancode_map[0x68] = Key::KP_ENTER; + scancode_map[0x69] = Key::CTRL; + scancode_map[0x6A] = Key::KP_DIVIDE; + scancode_map[0x6B] = Key::PRINT; + scancode_map[0x6C] = Key::ALT; + scancode_map[0x6D] = Key::ENTER; + scancode_map[0x6E] = Key::HOME; + scancode_map[0x6F] = Key::UP; + scancode_map[0x70] = Key::PAGEUP; + scancode_map[0x71] = Key::LEFT; + scancode_map[0x72] = Key::RIGHT; + scancode_map[0x73] = Key::END; + scancode_map[0x74] = Key::DOWN; + scancode_map[0x75] = Key::PAGEDOWN; + scancode_map[0x76] = Key::INSERT; + scancode_map[0x77] = Key::KEY_DELETE; + scancode_map[0x79] = Key::VOLUMEMUTE; + scancode_map[0x7A] = Key::VOLUMEDOWN; + scancode_map[0x7B] = Key::VOLUMEUP; + scancode_map[0x7F] = Key::PAUSE; + scancode_map[0x85] = Key::META; + scancode_map[0x86] = Key::META; + scancode_map[0x87] = Key::MENU; + scancode_map[0xBF] = Key::F13; + scancode_map[0xC0] = Key::F14; + scancode_map[0xC1] = Key::F15; + scancode_map[0xC2] = Key::F16; + scancode_map[0xC3] = Key::F17; + scancode_map[0xC4] = Key::F18; + scancode_map[0xC5] = Key::F19; + scancode_map[0xC6] = Key::F20; + scancode_map[0xC7] = Key::F21; + scancode_map[0xC8] = Key::F22; + scancode_map[0xC9] = Key::F23; + scancode_map[0xCA] = Key::F24; + scancode_map[0xCB] = Key::F25; + scancode_map[0xCC] = Key::F26; + scancode_map[0xCD] = Key::F27; + scancode_map[0xCE] = Key::F28; + scancode_map[0xCF] = Key::F29; + scancode_map[0xD0] = Key::F30; + scancode_map[0xD1] = Key::F31; + scancode_map[0xD2] = Key::F32; + scancode_map[0xD3] = Key::F33; + scancode_map[0xD4] = Key::F34; + scancode_map[0xD5] = Key::F35; - { XK_Escape, Key::ESCAPE }, - { XK_Tab, Key::TAB }, - { XK_ISO_Left_Tab, Key::BACKTAB }, - { XK_BackSpace, Key::BACKSPACE }, - { XK_Return, Key::ENTER }, - { XK_Insert, Key::INSERT }, - { XK_Delete, Key::KEY_DELETE }, - { XK_Clear, Key::KEY_DELETE }, - { XK_Pause, Key::PAUSE }, - { XK_Print, Key::PRINT }, - { XK_Home, Key::HOME }, - { XK_End, Key::END }, - { XK_Left, Key::LEFT }, - { XK_Up, Key::UP }, - { XK_Right, Key::RIGHT }, - { XK_Down, Key::DOWN }, - { XK_Prior, Key::PAGEUP }, - { XK_Next, Key::PAGEDOWN }, - { XK_Shift_L, Key::SHIFT }, - { XK_Shift_R, Key::SHIFT }, - { XK_Shift_Lock, Key::SHIFT }, - { XK_Control_L, Key::CTRL }, - { XK_Control_R, Key::CTRL }, - { XK_Meta_L, Key::META }, - { XK_Meta_R, Key::META }, - { XK_Alt_L, Key::ALT }, - { XK_Alt_R, Key::ALT }, - { XK_Caps_Lock, Key::CAPSLOCK }, - { XK_Num_Lock, Key::NUMLOCK }, - { XK_Scroll_Lock, Key::SCROLLLOCK }, - { XK_Super_L, Key::SUPER_L }, - { XK_Super_R, Key::SUPER_R }, - { XK_Menu, Key::MENU }, - { XK_Hyper_L, Key::HYPER_L }, - { XK_Hyper_R, Key::HYPER_R }, - { XK_Help, Key::HELP }, - { XK_KP_Space, Key::SPACE }, - { XK_KP_Tab, Key::TAB }, - { XK_KP_Enter, Key::KP_ENTER }, - { XK_Home, Key::HOME }, - { XK_Left, Key::LEFT }, - { XK_Up, Key::UP }, - { XK_Right, Key::RIGHT }, - { XK_Down, Key::DOWN }, - { XK_Prior, Key::PAGEUP }, - { XK_Next, Key::PAGEDOWN }, - { XK_End, Key::END }, - { XK_Begin, Key::CLEAR }, - { XK_Insert, Key::INSERT }, - { XK_Delete, Key::KEY_DELETE }, - //{ XK_KP_Equal, Key::EQUAL }, - //{ XK_KP_Separator, Key::COMMA }, - { XK_KP_Decimal, Key::KP_PERIOD }, - { XK_KP_Delete, Key::KP_PERIOD }, - { XK_KP_Multiply, Key::KP_MULTIPLY }, - { XK_KP_Divide, Key::KP_DIVIDE }, - { XK_KP_Subtract, Key::KP_SUBTRACT }, - { XK_KP_Add, Key::KP_ADD }, - { XK_KP_0, Key::KP_0 }, - { XK_KP_1, Key::KP_1 }, - { XK_KP_2, Key::KP_2 }, - { XK_KP_3, Key::KP_3 }, - { XK_KP_4, Key::KP_4 }, - { XK_KP_5, Key::KP_5 }, - { XK_KP_6, Key::KP_6 }, - { XK_KP_7, Key::KP_7 }, - { XK_KP_8, Key::KP_8 }, - { XK_KP_9, Key::KP_9 }, - // same keys but with numlock off - { XK_KP_Insert, Key::INSERT }, - { XK_KP_End, Key::END }, - { XK_KP_Down, Key::DOWN }, - { XK_KP_Page_Down, Key::PAGEDOWN }, - { XK_KP_Left, Key::LEFT }, - // X11 documents this (numpad 5) as "begin of line" but no toolkit - // seems to interpret it this way. - // On Windows this is emitting Key::Clear so for consistency it - // will be mapped to Key::Clear - { XK_KP_Begin, Key::CLEAR }, - { XK_KP_Right, Key::RIGHT }, - { XK_KP_Home, Key::HOME }, - { XK_KP_Up, Key::UP }, - { XK_KP_Page_Up, Key::PAGEUP }, - { XK_F1, Key::F1 }, - { XK_F2, Key::F2 }, - { XK_F3, Key::F3 }, - { XK_F4, Key::F4 }, - { XK_F5, Key::F5 }, - { XK_F6, Key::F6 }, - { XK_F7, Key::F7 }, - { XK_F8, Key::F8 }, - { XK_F9, Key::F9 }, - { XK_F10, Key::F10 }, - { XK_F11, Key::F11 }, - { XK_F12, Key::F12 }, - { XK_F13, Key::F13 }, - { XK_F14, Key::F14 }, - { XK_F15, Key::F15 }, - { XK_F16, Key::F16 }, - { XK_F17, Key::F17 }, - { XK_F18, Key::F18 }, - { XK_F19, Key::F19 }, - { XK_F20, Key::F20 }, - { XK_F21, Key::F21 }, - { XK_F22, Key::F22 }, - { XK_F23, Key::F23 }, - { XK_F24, Key::F24 }, - { XK_F25, Key::F25 }, - { XK_F26, Key::F26 }, - { XK_F27, Key::F27 }, - { XK_F28, Key::F28 }, - { XK_F29, Key::F29 }, - { XK_F30, Key::F30 }, - { XK_F31, Key::F31 }, - { XK_F32, Key::F32 }, - { XK_F33, Key::F33 }, - { XK_F34, Key::F34 }, - { XK_F35, Key::F35 }, - - // media keys - { XF86XK_Back, Key::BACK }, - { XF86XK_Forward, Key::FORWARD }, - { XF86XK_Stop, Key::STOP }, - { XF86XK_Refresh, Key::REFRESH }, - { XF86XK_Favorites, Key::FAVORITES }, - { XF86XK_AudioMedia, Key::LAUNCHMEDIA }, - { XF86XK_OpenURL, Key::OPENURL }, - { XF86XK_HomePage, Key::HOMEPAGE }, - { XF86XK_Search, Key::SEARCH }, - { XF86XK_AudioLowerVolume, Key::VOLUMEDOWN }, - { XF86XK_AudioMute, Key::VOLUMEMUTE }, - { XF86XK_AudioRaiseVolume, Key::VOLUMEUP }, - { XF86XK_AudioPlay, Key::MEDIAPLAY }, - { XF86XK_AudioStop, Key::MEDIASTOP }, - { XF86XK_AudioPrev, Key::MEDIAPREVIOUS }, - { XF86XK_AudioNext, Key::MEDIANEXT }, - { XF86XK_AudioRecord, Key::MEDIARECORD }, - - // launch keys - { XF86XK_Mail, Key::LAUNCHMAIL }, - { XF86XK_MyComputer, Key::LAUNCH0 }, - { XF86XK_Calculator, Key::LAUNCH1 }, - { XF86XK_Standby, Key::STANDBY }, - - { XF86XK_Launch0, Key::LAUNCH2 }, - { XF86XK_Launch1, Key::LAUNCH3 }, - { XF86XK_Launch2, Key::LAUNCH4 }, - { XF86XK_Launch3, Key::LAUNCH5 }, - { XF86XK_Launch4, Key::LAUNCH6 }, - { XF86XK_Launch5, Key::LAUNCH7 }, - { XF86XK_Launch6, Key::LAUNCH8 }, - { XF86XK_Launch7, Key::LAUNCH9 }, - { XF86XK_Launch8, Key::LAUNCHA }, - { XF86XK_Launch9, Key::LAUNCHB }, - { XF86XK_LaunchA, Key::LAUNCHC }, - { XF86XK_LaunchB, Key::LAUNCHD }, - { XF86XK_LaunchC, Key::LAUNCHE }, - { XF86XK_LaunchD, Key::LAUNCHF }, - - { 0, Key::NONE } -}; - -struct _TranslatePair { - Key keysym; - unsigned int keycode; -}; - -static _TranslatePair _scancode_to_keycode[] = { - { Key::ESCAPE, 0x09 }, - { Key::KEY_1, 0x0A }, - { Key::KEY_2, 0x0B }, - { Key::KEY_3, 0x0C }, - { Key::KEY_4, 0x0D }, - { Key::KEY_5, 0x0E }, - { Key::KEY_6, 0x0F }, - { Key::KEY_7, 0x10 }, - { Key::KEY_8, 0x11 }, - { Key::KEY_9, 0x12 }, - { Key::KEY_0, 0x13 }, - { Key::MINUS, 0x14 }, - { Key::EQUAL, 0x15 }, - { Key::BACKSPACE, 0x16 }, - { Key::TAB, 0x17 }, - { Key::Q, 0x18 }, - { Key::W, 0x19 }, - { Key::E, 0x1A }, - { Key::R, 0x1B }, - { Key::T, 0x1C }, - { Key::Y, 0x1D }, - { Key::U, 0x1E }, - { Key::I, 0x1F }, - { Key::O, 0x20 }, - { Key::P, 0x21 }, - { Key::BRACELEFT, 0x22 }, - { Key::BRACERIGHT, 0x23 }, - { Key::ENTER, 0x24 }, - { Key::CTRL, 0x25 }, - { Key::A, 0x26 }, - { Key::S, 0x27 }, - { Key::D, 0x28 }, - { Key::F, 0x29 }, - { Key::G, 0x2A }, - { Key::H, 0x2B }, - { Key::J, 0x2C }, - { Key::K, 0x2D }, - { Key::L, 0x2E }, - { Key::SEMICOLON, 0x2F }, - { Key::APOSTROPHE, 0x30 }, - { Key::QUOTELEFT, 0x31 }, - { Key::SHIFT, 0x32 }, - { Key::BACKSLASH, 0x33 }, - { Key::Z, 0x34 }, - { Key::X, 0x35 }, - { Key::C, 0x36 }, - { Key::V, 0x37 }, - { Key::B, 0x38 }, - { Key::N, 0x39 }, - { Key::M, 0x3A }, - { Key::COMMA, 0x3B }, - { Key::PERIOD, 0x3C }, - { Key::SLASH, 0x3D }, - { Key::SHIFT, 0x3E }, - { Key::KP_MULTIPLY, 0x3F }, - { Key::ALT, 0x40 }, - { Key::SPACE, 0x41 }, - { Key::CAPSLOCK, 0x42 }, - { Key::F1, 0x43 }, - { Key::F2, 0x44 }, - { Key::F3, 0x45 }, - { Key::F4, 0x46 }, - { Key::F5, 0x47 }, - { Key::F6, 0x48 }, - { Key::F7, 0x49 }, - { Key::F8, 0x4A }, - { Key::F9, 0x4B }, - { Key::F10, 0x4C }, - { Key::NUMLOCK, 0x4D }, - { Key::SCROLLLOCK, 0x4E }, - { Key::KP_7, 0x4F }, - { Key::KP_8, 0x50 }, - { Key::KP_9, 0x51 }, - { Key::KP_SUBTRACT, 0x52 }, - { Key::KP_4, 0x53 }, - { Key::KP_5, 0x54 }, - { Key::KP_6, 0x55 }, - { Key::KP_ADD, 0x56 }, - { Key::KP_1, 0x57 }, - { Key::KP_2, 0x58 }, - { Key::KP_3, 0x59 }, - { Key::KP_0, 0x5A }, - { Key::KP_PERIOD, 0x5B }, - //{ Key::???, 0x5E }, //NON US BACKSLASH - { Key::F11, 0x5F }, - { Key::F12, 0x60 }, - { Key::KP_ENTER, 0x68 }, - { Key::CTRL, 0x69 }, - { Key::KP_DIVIDE, 0x6A }, - { Key::PRINT, 0x6B }, - { Key::ALT, 0x6C }, - { Key::ENTER, 0x6D }, - { Key::HOME, 0x6E }, - { Key::UP, 0x6F }, - { Key::PAGEUP, 0x70 }, - { Key::LEFT, 0x71 }, - { Key::RIGHT, 0x72 }, - { Key::END, 0x73 }, - { Key::DOWN, 0x74 }, - { Key::PAGEDOWN, 0x75 }, - { Key::INSERT, 0x76 }, - { Key::KEY_DELETE, 0x77 }, - { Key::VOLUMEMUTE, 0x79 }, - { Key::VOLUMEDOWN, 0x7A }, - { Key::VOLUMEUP, 0x7B }, - { Key::PAUSE, 0x7F }, - { Key::SUPER_L, 0x85 }, - { Key::SUPER_R, 0x86 }, - { Key::MENU, 0x87 }, - { Key::F13, 0xBF }, - { Key::F14, 0xC0 }, - { Key::F15, 0xC1 }, - { Key::F16, 0xC2 }, - { Key::F17, 0xC3 }, - { Key::F18, 0xC4 }, - { Key::F19, 0xC5 }, - { Key::F20, 0xC6 }, - { Key::F21, 0xC7 }, - { Key::F22, 0xC8 }, - { Key::F23, 0xC9 }, - { Key::F24, 0xCA }, - { Key::F25, 0xCB }, - { Key::F26, 0xCC }, - { Key::F27, 0xCD }, - { Key::F28, 0xCE }, - { Key::F29, 0xCF }, - { Key::F30, 0xD0 }, - { Key::F31, 0xD1 }, - { Key::F32, 0xD2 }, - { Key::F33, 0xD3 }, - { Key::F34, 0xD4 }, - { Key::F35, 0xD5 }, - { Key::UNKNOWN, 0 } -}; - -Key KeyMappingX11::get_scancode(unsigned int p_code) { - Key keycode = Key::UNKNOWN; - for (int i = 0; _scancode_to_keycode[i].keysym != Key::UNKNOWN; i++) { - if (_scancode_to_keycode[i].keycode == p_code) { - keycode = _scancode_to_keycode[i].keysym; - break; - } + // Godot to scancode map. + for (const KeyValue<unsigned int, Key> &E : scancode_map) { + scancode_map_inv[E.value] = E.key; } - return keycode; + // Keysym to Unicode map, tables taken from FOX toolkit. + xkeysym_unicode_map[0x01A1] = 0x0104; + xkeysym_unicode_map[0x01A2] = 0x02D8; + xkeysym_unicode_map[0x01A3] = 0x0141; + xkeysym_unicode_map[0x01A5] = 0x013D; + xkeysym_unicode_map[0x01A6] = 0x015A; + xkeysym_unicode_map[0x01A9] = 0x0160; + xkeysym_unicode_map[0x01AA] = 0x015E; + xkeysym_unicode_map[0x01AB] = 0x0164; + xkeysym_unicode_map[0x01AC] = 0x0179; + xkeysym_unicode_map[0x01AE] = 0x017D; + xkeysym_unicode_map[0x01AF] = 0x017B; + xkeysym_unicode_map[0x01B1] = 0x0105; + xkeysym_unicode_map[0x01B2] = 0x02DB; + xkeysym_unicode_map[0x01B3] = 0x0142; + xkeysym_unicode_map[0x01B5] = 0x013E; + xkeysym_unicode_map[0x01B6] = 0x015B; + xkeysym_unicode_map[0x01B7] = 0x02C7; + xkeysym_unicode_map[0x01B9] = 0x0161; + xkeysym_unicode_map[0x01BA] = 0x015F; + xkeysym_unicode_map[0x01BB] = 0x0165; + xkeysym_unicode_map[0x01BC] = 0x017A; + xkeysym_unicode_map[0x01BD] = 0x02DD; + xkeysym_unicode_map[0x01BE] = 0x017E; + xkeysym_unicode_map[0x01BF] = 0x017C; + xkeysym_unicode_map[0x01C0] = 0x0154; + xkeysym_unicode_map[0x01C3] = 0x0102; + xkeysym_unicode_map[0x01C5] = 0x0139; + xkeysym_unicode_map[0x01C6] = 0x0106; + xkeysym_unicode_map[0x01C8] = 0x010C; + xkeysym_unicode_map[0x01CA] = 0x0118; + xkeysym_unicode_map[0x01CC] = 0x011A; + xkeysym_unicode_map[0x01CF] = 0x010E; + xkeysym_unicode_map[0x01D0] = 0x0110; + xkeysym_unicode_map[0x01D1] = 0x0143; + xkeysym_unicode_map[0x01D2] = 0x0147; + xkeysym_unicode_map[0x01D5] = 0x0150; + xkeysym_unicode_map[0x01D8] = 0x0158; + xkeysym_unicode_map[0x01D9] = 0x016E; + xkeysym_unicode_map[0x01DB] = 0x0170; + xkeysym_unicode_map[0x01DE] = 0x0162; + xkeysym_unicode_map[0x01E0] = 0x0155; + xkeysym_unicode_map[0x01E3] = 0x0103; + xkeysym_unicode_map[0x01E5] = 0x013A; + xkeysym_unicode_map[0x01E6] = 0x0107; + xkeysym_unicode_map[0x01E8] = 0x010D; + xkeysym_unicode_map[0x01EA] = 0x0119; + xkeysym_unicode_map[0x01EC] = 0x011B; + xkeysym_unicode_map[0x01EF] = 0x010F; + xkeysym_unicode_map[0x01F0] = 0x0111; + xkeysym_unicode_map[0x01F1] = 0x0144; + xkeysym_unicode_map[0x01F2] = 0x0148; + xkeysym_unicode_map[0x01F5] = 0x0151; + xkeysym_unicode_map[0x01F8] = 0x0159; + xkeysym_unicode_map[0x01F9] = 0x016F; + xkeysym_unicode_map[0x01FB] = 0x0171; + xkeysym_unicode_map[0x01FE] = 0x0163; + xkeysym_unicode_map[0x01FF] = 0x02D9; + xkeysym_unicode_map[0x02A1] = 0x0126; + xkeysym_unicode_map[0x02A6] = 0x0124; + xkeysym_unicode_map[0x02A9] = 0x0130; + xkeysym_unicode_map[0x02AB] = 0x011E; + xkeysym_unicode_map[0x02AC] = 0x0134; + xkeysym_unicode_map[0x02B1] = 0x0127; + xkeysym_unicode_map[0x02B6] = 0x0125; + xkeysym_unicode_map[0x02B9] = 0x0131; + xkeysym_unicode_map[0x02BB] = 0x011F; + xkeysym_unicode_map[0x02BC] = 0x0135; + xkeysym_unicode_map[0x02C5] = 0x010A; + xkeysym_unicode_map[0x02C6] = 0x0108; + xkeysym_unicode_map[0x02D5] = 0x0120; + xkeysym_unicode_map[0x02D8] = 0x011C; + xkeysym_unicode_map[0x02DD] = 0x016C; + xkeysym_unicode_map[0x02DE] = 0x015C; + xkeysym_unicode_map[0x02E5] = 0x010B; + xkeysym_unicode_map[0x02E6] = 0x0109; + xkeysym_unicode_map[0x02F5] = 0x0121; + xkeysym_unicode_map[0x02F8] = 0x011D; + xkeysym_unicode_map[0x02FD] = 0x016D; + xkeysym_unicode_map[0x02FE] = 0x015D; + xkeysym_unicode_map[0x03A2] = 0x0138; + xkeysym_unicode_map[0x03A3] = 0x0156; + xkeysym_unicode_map[0x03A5] = 0x0128; + xkeysym_unicode_map[0x03A6] = 0x013B; + xkeysym_unicode_map[0x03AA] = 0x0112; + xkeysym_unicode_map[0x03AB] = 0x0122; + xkeysym_unicode_map[0x03AC] = 0x0166; + xkeysym_unicode_map[0x03B3] = 0x0157; + xkeysym_unicode_map[0x03B5] = 0x0129; + xkeysym_unicode_map[0x03B6] = 0x013C; + xkeysym_unicode_map[0x03BA] = 0x0113; + xkeysym_unicode_map[0x03BB] = 0x0123; + xkeysym_unicode_map[0x03BC] = 0x0167; + xkeysym_unicode_map[0x03BD] = 0x014A; + xkeysym_unicode_map[0x03BF] = 0x014B; + xkeysym_unicode_map[0x03C0] = 0x0100; + xkeysym_unicode_map[0x03C7] = 0x012E; + xkeysym_unicode_map[0x03CC] = 0x0116; + xkeysym_unicode_map[0x03CF] = 0x012A; + xkeysym_unicode_map[0x03D1] = 0x0145; + xkeysym_unicode_map[0x03D2] = 0x014C; + xkeysym_unicode_map[0x03D3] = 0x0136; + xkeysym_unicode_map[0x03D9] = 0x0172; + xkeysym_unicode_map[0x03DD] = 0x0168; + xkeysym_unicode_map[0x03DE] = 0x016A; + xkeysym_unicode_map[0x03E0] = 0x0101; + xkeysym_unicode_map[0x03E7] = 0x012F; + xkeysym_unicode_map[0x03EC] = 0x0117; + xkeysym_unicode_map[0x03EF] = 0x012B; + xkeysym_unicode_map[0x03F1] = 0x0146; + xkeysym_unicode_map[0x03F2] = 0x014D; + xkeysym_unicode_map[0x03F3] = 0x0137; + xkeysym_unicode_map[0x03F9] = 0x0173; + xkeysym_unicode_map[0x03FD] = 0x0169; + xkeysym_unicode_map[0x03FE] = 0x016B; + xkeysym_unicode_map[0x047E] = 0x203E; + xkeysym_unicode_map[0x04A1] = 0x3002; + xkeysym_unicode_map[0x04A2] = 0x300C; + xkeysym_unicode_map[0x04A3] = 0x300D; + xkeysym_unicode_map[0x04A4] = 0x3001; + xkeysym_unicode_map[0x04A5] = 0x30FB; + xkeysym_unicode_map[0x04A6] = 0x30F2; + xkeysym_unicode_map[0x04A7] = 0x30A1; + xkeysym_unicode_map[0x04A8] = 0x30A3; + xkeysym_unicode_map[0x04A9] = 0x30A5; + xkeysym_unicode_map[0x04AA] = 0x30A7; + xkeysym_unicode_map[0x04AB] = 0x30A9; + xkeysym_unicode_map[0x04AC] = 0x30E3; + xkeysym_unicode_map[0x04AD] = 0x30E5; + xkeysym_unicode_map[0x04AE] = 0x30E7; + xkeysym_unicode_map[0x04AF] = 0x30C3; + xkeysym_unicode_map[0x04B0] = 0x30FC; + xkeysym_unicode_map[0x04B1] = 0x30A2; + xkeysym_unicode_map[0x04B2] = 0x30A4; + xkeysym_unicode_map[0x04B3] = 0x30A6; + xkeysym_unicode_map[0x04B4] = 0x30A8; + xkeysym_unicode_map[0x04B5] = 0x30AA; + xkeysym_unicode_map[0x04B6] = 0x30AB; + xkeysym_unicode_map[0x04B7] = 0x30AD; + xkeysym_unicode_map[0x04B8] = 0x30AF; + xkeysym_unicode_map[0x04B9] = 0x30B1; + xkeysym_unicode_map[0x04BA] = 0x30B3; + xkeysym_unicode_map[0x04BB] = 0x30B5; + xkeysym_unicode_map[0x04BC] = 0x30B7; + xkeysym_unicode_map[0x04BD] = 0x30B9; + xkeysym_unicode_map[0x04BE] = 0x30BB; + xkeysym_unicode_map[0x04BF] = 0x30BD; + xkeysym_unicode_map[0x04C0] = 0x30BF; + xkeysym_unicode_map[0x04C1] = 0x30C1; + xkeysym_unicode_map[0x04C2] = 0x30C4; + xkeysym_unicode_map[0x04C3] = 0x30C6; + xkeysym_unicode_map[0x04C4] = 0x30C8; + xkeysym_unicode_map[0x04C5] = 0x30CA; + xkeysym_unicode_map[0x04C6] = 0x30CB; + xkeysym_unicode_map[0x04C7] = 0x30CC; + xkeysym_unicode_map[0x04C8] = 0x30CD; + xkeysym_unicode_map[0x04C9] = 0x30CE; + xkeysym_unicode_map[0x04CA] = 0x30CF; + xkeysym_unicode_map[0x04CB] = 0x30D2; + xkeysym_unicode_map[0x04CC] = 0x30D5; + xkeysym_unicode_map[0x04CD] = 0x30D8; + xkeysym_unicode_map[0x04CE] = 0x30DB; + xkeysym_unicode_map[0x04CF] = 0x30DE; + xkeysym_unicode_map[0x04D0] = 0x30DF; + xkeysym_unicode_map[0x04D1] = 0x30E0; + xkeysym_unicode_map[0x04D2] = 0x30E1; + xkeysym_unicode_map[0x04D3] = 0x30E2; + xkeysym_unicode_map[0x04D4] = 0x30E4; + xkeysym_unicode_map[0x04D5] = 0x30E6; + xkeysym_unicode_map[0x04D6] = 0x30E8; + xkeysym_unicode_map[0x04D7] = 0x30E9; + xkeysym_unicode_map[0x04D8] = 0x30EA; + xkeysym_unicode_map[0x04D9] = 0x30EB; + xkeysym_unicode_map[0x04DA] = 0x30EC; + xkeysym_unicode_map[0x04DB] = 0x30ED; + xkeysym_unicode_map[0x04DC] = 0x30EF; + xkeysym_unicode_map[0x04DD] = 0x30F3; + xkeysym_unicode_map[0x04DE] = 0x309B; + xkeysym_unicode_map[0x04DF] = 0x309C; + xkeysym_unicode_map[0x05AC] = 0x060C; + xkeysym_unicode_map[0x05BB] = 0x061B; + xkeysym_unicode_map[0x05BF] = 0x061F; + xkeysym_unicode_map[0x05C1] = 0x0621; + xkeysym_unicode_map[0x05C2] = 0x0622; + xkeysym_unicode_map[0x05C3] = 0x0623; + xkeysym_unicode_map[0x05C4] = 0x0624; + xkeysym_unicode_map[0x05C5] = 0x0625; + xkeysym_unicode_map[0x05C6] = 0x0626; + xkeysym_unicode_map[0x05C7] = 0x0627; + xkeysym_unicode_map[0x05C8] = 0x0628; + xkeysym_unicode_map[0x05C9] = 0x0629; + xkeysym_unicode_map[0x05CA] = 0x062A; + xkeysym_unicode_map[0x05CB] = 0x062B; + xkeysym_unicode_map[0x05CC] = 0x062C; + xkeysym_unicode_map[0x05CD] = 0x062D; + xkeysym_unicode_map[0x05CE] = 0x062E; + xkeysym_unicode_map[0x05CF] = 0x062F; + xkeysym_unicode_map[0x05D0] = 0x0630; + xkeysym_unicode_map[0x05D1] = 0x0631; + xkeysym_unicode_map[0x05D2] = 0x0632; + xkeysym_unicode_map[0x05D3] = 0x0633; + xkeysym_unicode_map[0x05D4] = 0x0634; + xkeysym_unicode_map[0x05D5] = 0x0635; + xkeysym_unicode_map[0x05D6] = 0x0636; + xkeysym_unicode_map[0x05D7] = 0x0637; + xkeysym_unicode_map[0x05D8] = 0x0638; + xkeysym_unicode_map[0x05D9] = 0x0639; + xkeysym_unicode_map[0x05DA] = 0x063A; + xkeysym_unicode_map[0x05E0] = 0x0640; + xkeysym_unicode_map[0x05E1] = 0x0641; + xkeysym_unicode_map[0x05E2] = 0x0642; + xkeysym_unicode_map[0x05E3] = 0x0643; + xkeysym_unicode_map[0x05E4] = 0x0644; + xkeysym_unicode_map[0x05E5] = 0x0645; + xkeysym_unicode_map[0x05E6] = 0x0646; + xkeysym_unicode_map[0x05E7] = 0x0647; + xkeysym_unicode_map[0x05E8] = 0x0648; + xkeysym_unicode_map[0x05E9] = 0x0649; + xkeysym_unicode_map[0x05EA] = 0x064A; + xkeysym_unicode_map[0x05EB] = 0x064B; + xkeysym_unicode_map[0x05EC] = 0x064C; + xkeysym_unicode_map[0x05ED] = 0x064D; + xkeysym_unicode_map[0x05EE] = 0x064E; + xkeysym_unicode_map[0x05EF] = 0x064F; + xkeysym_unicode_map[0x05F0] = 0x0650; + xkeysym_unicode_map[0x05F1] = 0x0651; + xkeysym_unicode_map[0x05F2] = 0x0652; + xkeysym_unicode_map[0x06A1] = 0x0452; + xkeysym_unicode_map[0x06A2] = 0x0453; + xkeysym_unicode_map[0x06A3] = 0x0451; + xkeysym_unicode_map[0x06A4] = 0x0454; + xkeysym_unicode_map[0x06A5] = 0x0455; + xkeysym_unicode_map[0x06A6] = 0x0456; + xkeysym_unicode_map[0x06A7] = 0x0457; + xkeysym_unicode_map[0x06A8] = 0x0458; + xkeysym_unicode_map[0x06A9] = 0x0459; + xkeysym_unicode_map[0x06AA] = 0x045A; + xkeysym_unicode_map[0x06AB] = 0x045B; + xkeysym_unicode_map[0x06AC] = 0x045C; + xkeysym_unicode_map[0x06AE] = 0x045E; + xkeysym_unicode_map[0x06AF] = 0x045F; + xkeysym_unicode_map[0x06B0] = 0x2116; + xkeysym_unicode_map[0x06B1] = 0x0402; + xkeysym_unicode_map[0x06B2] = 0x0403; + xkeysym_unicode_map[0x06B3] = 0x0401; + xkeysym_unicode_map[0x06B4] = 0x0404; + xkeysym_unicode_map[0x06B5] = 0x0405; + xkeysym_unicode_map[0x06B6] = 0x0406; + xkeysym_unicode_map[0x06B7] = 0x0407; + xkeysym_unicode_map[0x06B8] = 0x0408; + xkeysym_unicode_map[0x06B9] = 0x0409; + xkeysym_unicode_map[0x06BA] = 0x040A; + xkeysym_unicode_map[0x06BB] = 0x040B; + xkeysym_unicode_map[0x06BC] = 0x040C; + xkeysym_unicode_map[0x06BE] = 0x040E; + xkeysym_unicode_map[0x06BF] = 0x040F; + xkeysym_unicode_map[0x06C0] = 0x044E; + xkeysym_unicode_map[0x06C1] = 0x0430; + xkeysym_unicode_map[0x06C2] = 0x0431; + xkeysym_unicode_map[0x06C3] = 0x0446; + xkeysym_unicode_map[0x06C4] = 0x0434; + xkeysym_unicode_map[0x06C5] = 0x0435; + xkeysym_unicode_map[0x06C6] = 0x0444; + xkeysym_unicode_map[0x06C7] = 0x0433; + xkeysym_unicode_map[0x06C8] = 0x0445; + xkeysym_unicode_map[0x06C9] = 0x0438; + xkeysym_unicode_map[0x06CA] = 0x0439; + xkeysym_unicode_map[0x06CB] = 0x043A; + xkeysym_unicode_map[0x06CC] = 0x043B; + xkeysym_unicode_map[0x06CD] = 0x043C; + xkeysym_unicode_map[0x06CE] = 0x043D; + xkeysym_unicode_map[0x06CF] = 0x043E; + xkeysym_unicode_map[0x06D0] = 0x043F; + xkeysym_unicode_map[0x06D1] = 0x044F; + xkeysym_unicode_map[0x06D2] = 0x0440; + xkeysym_unicode_map[0x06D3] = 0x0441; + xkeysym_unicode_map[0x06D4] = 0x0442; + xkeysym_unicode_map[0x06D5] = 0x0443; + xkeysym_unicode_map[0x06D6] = 0x0436; + xkeysym_unicode_map[0x06D7] = 0x0432; + xkeysym_unicode_map[0x06D8] = 0x044C; + xkeysym_unicode_map[0x06D9] = 0x044B; + xkeysym_unicode_map[0x06DA] = 0x0437; + xkeysym_unicode_map[0x06DB] = 0x0448; + xkeysym_unicode_map[0x06DC] = 0x044D; + xkeysym_unicode_map[0x06DD] = 0x0449; + xkeysym_unicode_map[0x06DE] = 0x0447; + xkeysym_unicode_map[0x06DF] = 0x044A; + xkeysym_unicode_map[0x06E0] = 0x042E; + xkeysym_unicode_map[0x06E1] = 0x0410; + xkeysym_unicode_map[0x06E2] = 0x0411; + xkeysym_unicode_map[0x06E3] = 0x0426; + xkeysym_unicode_map[0x06E4] = 0x0414; + xkeysym_unicode_map[0x06E5] = 0x0415; + xkeysym_unicode_map[0x06E6] = 0x0424; + xkeysym_unicode_map[0x06E7] = 0x0413; + xkeysym_unicode_map[0x06E8] = 0x0425; + xkeysym_unicode_map[0x06E9] = 0x0418; + xkeysym_unicode_map[0x06EA] = 0x0419; + xkeysym_unicode_map[0x06EB] = 0x041A; + xkeysym_unicode_map[0x06EC] = 0x041B; + xkeysym_unicode_map[0x06ED] = 0x041C; + xkeysym_unicode_map[0x06EE] = 0x041D; + xkeysym_unicode_map[0x06EF] = 0x041E; + xkeysym_unicode_map[0x06F0] = 0x041F; + xkeysym_unicode_map[0x06F1] = 0x042F; + xkeysym_unicode_map[0x06F2] = 0x0420; + xkeysym_unicode_map[0x06F3] = 0x0421; + xkeysym_unicode_map[0x06F4] = 0x0422; + xkeysym_unicode_map[0x06F5] = 0x0423; + xkeysym_unicode_map[0x06F6] = 0x0416; + xkeysym_unicode_map[0x06F7] = 0x0412; + xkeysym_unicode_map[0x06F8] = 0x042C; + xkeysym_unicode_map[0x06F9] = 0x042B; + xkeysym_unicode_map[0x06FA] = 0x0417; + xkeysym_unicode_map[0x06FB] = 0x0428; + xkeysym_unicode_map[0x06FC] = 0x042D; + xkeysym_unicode_map[0x06FD] = 0x0429; + xkeysym_unicode_map[0x06FE] = 0x0427; + xkeysym_unicode_map[0x06FF] = 0x042A; + xkeysym_unicode_map[0x07A1] = 0x0386; + xkeysym_unicode_map[0x07A2] = 0x0388; + xkeysym_unicode_map[0x07A3] = 0x0389; + xkeysym_unicode_map[0x07A4] = 0x038A; + xkeysym_unicode_map[0x07A5] = 0x03AA; + xkeysym_unicode_map[0x07A7] = 0x038C; + xkeysym_unicode_map[0x07A8] = 0x038E; + xkeysym_unicode_map[0x07A9] = 0x03AB; + xkeysym_unicode_map[0x07AB] = 0x038F; + xkeysym_unicode_map[0x07AE] = 0x0385; + xkeysym_unicode_map[0x07AF] = 0x2015; + xkeysym_unicode_map[0x07B1] = 0x03AC; + xkeysym_unicode_map[0x07B2] = 0x03AD; + xkeysym_unicode_map[0x07B3] = 0x03AE; + xkeysym_unicode_map[0x07B4] = 0x03AF; + xkeysym_unicode_map[0x07B5] = 0x03CA; + xkeysym_unicode_map[0x07B6] = 0x0390; + xkeysym_unicode_map[0x07B7] = 0x03CC; + xkeysym_unicode_map[0x07B8] = 0x03CD; + xkeysym_unicode_map[0x07B9] = 0x03CB; + xkeysym_unicode_map[0x07BA] = 0x03B0; + xkeysym_unicode_map[0x07BB] = 0x03CE; + xkeysym_unicode_map[0x07C1] = 0x0391; + xkeysym_unicode_map[0x07C2] = 0x0392; + xkeysym_unicode_map[0x07C3] = 0x0393; + xkeysym_unicode_map[0x07C4] = 0x0394; + xkeysym_unicode_map[0x07C5] = 0x0395; + xkeysym_unicode_map[0x07C6] = 0x0396; + xkeysym_unicode_map[0x07C7] = 0x0397; + xkeysym_unicode_map[0x07C8] = 0x0398; + xkeysym_unicode_map[0x07C9] = 0x0399; + xkeysym_unicode_map[0x07CA] = 0x039A; + xkeysym_unicode_map[0x07CB] = 0x039B; + xkeysym_unicode_map[0x07CC] = 0x039C; + xkeysym_unicode_map[0x07CD] = 0x039D; + xkeysym_unicode_map[0x07CE] = 0x039E; + xkeysym_unicode_map[0x07CF] = 0x039F; + xkeysym_unicode_map[0x07D0] = 0x03A0; + xkeysym_unicode_map[0x07D1] = 0x03A1; + xkeysym_unicode_map[0x07D2] = 0x03A3; + xkeysym_unicode_map[0x07D4] = 0x03A4; + xkeysym_unicode_map[0x07D5] = 0x03A5; + xkeysym_unicode_map[0x07D6] = 0x03A6; + xkeysym_unicode_map[0x07D7] = 0x03A7; + xkeysym_unicode_map[0x07D8] = 0x03A8; + xkeysym_unicode_map[0x07D9] = 0x03A9; + xkeysym_unicode_map[0x07E1] = 0x03B1; + xkeysym_unicode_map[0x07E2] = 0x03B2; + xkeysym_unicode_map[0x07E3] = 0x03B3; + xkeysym_unicode_map[0x07E4] = 0x03B4; + xkeysym_unicode_map[0x07E5] = 0x03B5; + xkeysym_unicode_map[0x07E6] = 0x03B6; + xkeysym_unicode_map[0x07E7] = 0x03B7; + xkeysym_unicode_map[0x07E8] = 0x03B8; + xkeysym_unicode_map[0x07E9] = 0x03B9; + xkeysym_unicode_map[0x07EA] = 0x03BA; + xkeysym_unicode_map[0x07EB] = 0x03BB; + xkeysym_unicode_map[0x07EC] = 0x03BC; + xkeysym_unicode_map[0x07ED] = 0x03BD; + xkeysym_unicode_map[0x07EE] = 0x03BE; + xkeysym_unicode_map[0x07EF] = 0x03BF; + xkeysym_unicode_map[0x07F0] = 0x03C0; + xkeysym_unicode_map[0x07F1] = 0x03C1; + xkeysym_unicode_map[0x07F2] = 0x03C3; + xkeysym_unicode_map[0x07F3] = 0x03C2; + xkeysym_unicode_map[0x07F4] = 0x03C4; + xkeysym_unicode_map[0x07F5] = 0x03C5; + xkeysym_unicode_map[0x07F6] = 0x03C6; + xkeysym_unicode_map[0x07F7] = 0x03C7; + xkeysym_unicode_map[0x07F8] = 0x03C8; + xkeysym_unicode_map[0x07F9] = 0x03C9; + xkeysym_unicode_map[0x08A1] = 0x23B7; + xkeysym_unicode_map[0x08A2] = 0x250C; + xkeysym_unicode_map[0x08A3] = 0x2500; + xkeysym_unicode_map[0x08A4] = 0x2320; + xkeysym_unicode_map[0x08A5] = 0x2321; + xkeysym_unicode_map[0x08A6] = 0x2502; + xkeysym_unicode_map[0x08A7] = 0x23A1; + xkeysym_unicode_map[0x08A8] = 0x23A3; + xkeysym_unicode_map[0x08A9] = 0x23A4; + xkeysym_unicode_map[0x08AA] = 0x23A6; + xkeysym_unicode_map[0x08AB] = 0x239B; + xkeysym_unicode_map[0x08AC] = 0x239D; + xkeysym_unicode_map[0x08AD] = 0x239E; + xkeysym_unicode_map[0x08AE] = 0x23A0; + xkeysym_unicode_map[0x08AF] = 0x23A8; + xkeysym_unicode_map[0x08B0] = 0x23AC; + xkeysym_unicode_map[0x08BC] = 0x2264; + xkeysym_unicode_map[0x08BD] = 0x2260; + xkeysym_unicode_map[0x08BE] = 0x2265; + xkeysym_unicode_map[0x08BF] = 0x222B; + xkeysym_unicode_map[0x08C0] = 0x2234; + xkeysym_unicode_map[0x08C1] = 0x221D; + xkeysym_unicode_map[0x08C2] = 0x221E; + xkeysym_unicode_map[0x08C5] = 0x2207; + xkeysym_unicode_map[0x08C8] = 0x223C; + xkeysym_unicode_map[0x08C9] = 0x2243; + xkeysym_unicode_map[0x08CD] = 0x21D4; + xkeysym_unicode_map[0x08CE] = 0x21D2; + xkeysym_unicode_map[0x08CF] = 0x2261; + xkeysym_unicode_map[0x08D6] = 0x221A; + xkeysym_unicode_map[0x08DA] = 0x2282; + xkeysym_unicode_map[0x08DB] = 0x2283; + xkeysym_unicode_map[0x08DC] = 0x2229; + xkeysym_unicode_map[0x08DD] = 0x222A; + xkeysym_unicode_map[0x08DE] = 0x2227; + xkeysym_unicode_map[0x08DF] = 0x2228; + xkeysym_unicode_map[0x08EF] = 0x2202; + xkeysym_unicode_map[0x08F6] = 0x0192; + xkeysym_unicode_map[0x08FB] = 0x2190; + xkeysym_unicode_map[0x08FC] = 0x2191; + xkeysym_unicode_map[0x08FD] = 0x2192; + xkeysym_unicode_map[0x08FE] = 0x2193; + xkeysym_unicode_map[0x09E0] = 0x25C6; + xkeysym_unicode_map[0x09E1] = 0x2592; + xkeysym_unicode_map[0x09E2] = 0x2409; + xkeysym_unicode_map[0x09E3] = 0x240C; + xkeysym_unicode_map[0x09E4] = 0x240D; + xkeysym_unicode_map[0x09E5] = 0x240A; + xkeysym_unicode_map[0x09E8] = 0x2424; + xkeysym_unicode_map[0x09E9] = 0x240B; + xkeysym_unicode_map[0x09EA] = 0x2518; + xkeysym_unicode_map[0x09EB] = 0x2510; + xkeysym_unicode_map[0x09EC] = 0x250C; + xkeysym_unicode_map[0x09ED] = 0x2514; + xkeysym_unicode_map[0x09EE] = 0x253C; + xkeysym_unicode_map[0x09EF] = 0x23BA; + xkeysym_unicode_map[0x09F0] = 0x23BB; + xkeysym_unicode_map[0x09F1] = 0x2500; + xkeysym_unicode_map[0x09F2] = 0x23BC; + xkeysym_unicode_map[0x09F3] = 0x23BD; + xkeysym_unicode_map[0x09F4] = 0x251C; + xkeysym_unicode_map[0x09F5] = 0x2524; + xkeysym_unicode_map[0x09F6] = 0x2534; + xkeysym_unicode_map[0x09F7] = 0x252C; + xkeysym_unicode_map[0x09F8] = 0x2502; + xkeysym_unicode_map[0x0AA1] = 0x2003; + xkeysym_unicode_map[0x0AA2] = 0x2002; + xkeysym_unicode_map[0x0AA3] = 0x2004; + xkeysym_unicode_map[0x0AA4] = 0x2005; + xkeysym_unicode_map[0x0AA5] = 0x2007; + xkeysym_unicode_map[0x0AA6] = 0x2008; + xkeysym_unicode_map[0x0AA7] = 0x2009; + xkeysym_unicode_map[0x0AA8] = 0x200A; + xkeysym_unicode_map[0x0AA9] = 0x2014; + xkeysym_unicode_map[0x0AAA] = 0x2013; + xkeysym_unicode_map[0x0AAE] = 0x2026; + xkeysym_unicode_map[0x0AAF] = 0x2025; + xkeysym_unicode_map[0x0AB0] = 0x2153; + xkeysym_unicode_map[0x0AB1] = 0x2154; + xkeysym_unicode_map[0x0AB2] = 0x2155; + xkeysym_unicode_map[0x0AB3] = 0x2156; + xkeysym_unicode_map[0x0AB4] = 0x2157; + xkeysym_unicode_map[0x0AB5] = 0x2158; + xkeysym_unicode_map[0x0AB6] = 0x2159; + xkeysym_unicode_map[0x0AB7] = 0x215A; + xkeysym_unicode_map[0x0AB8] = 0x2105; + xkeysym_unicode_map[0x0ABB] = 0x2012; + xkeysym_unicode_map[0x0ABC] = 0x2329; + xkeysym_unicode_map[0x0ABE] = 0x232A; + xkeysym_unicode_map[0x0AC3] = 0x215B; + xkeysym_unicode_map[0x0AC4] = 0x215C; + xkeysym_unicode_map[0x0AC5] = 0x215D; + xkeysym_unicode_map[0x0AC6] = 0x215E; + xkeysym_unicode_map[0x0AC9] = 0x2122; + xkeysym_unicode_map[0x0ACA] = 0x2613; + xkeysym_unicode_map[0x0ACC] = 0x25C1; + xkeysym_unicode_map[0x0ACD] = 0x25B7; + xkeysym_unicode_map[0x0ACE] = 0x25CB; + xkeysym_unicode_map[0x0ACF] = 0x25AF; + xkeysym_unicode_map[0x0AD0] = 0x2018; + xkeysym_unicode_map[0x0AD1] = 0x2019; + xkeysym_unicode_map[0x0AD2] = 0x201C; + xkeysym_unicode_map[0x0AD3] = 0x201D; + xkeysym_unicode_map[0x0AD4] = 0x211E; + xkeysym_unicode_map[0x0AD6] = 0x2032; + xkeysym_unicode_map[0x0AD7] = 0x2033; + xkeysym_unicode_map[0x0AD9] = 0x271D; + xkeysym_unicode_map[0x0ADB] = 0x25AC; + xkeysym_unicode_map[0x0ADC] = 0x25C0; + xkeysym_unicode_map[0x0ADD] = 0x25B6; + xkeysym_unicode_map[0x0ADE] = 0x25CF; + xkeysym_unicode_map[0x0ADF] = 0x25AE; + xkeysym_unicode_map[0x0AE0] = 0x25E6; + xkeysym_unicode_map[0x0AE1] = 0x25AB; + xkeysym_unicode_map[0x0AE2] = 0x25AD; + xkeysym_unicode_map[0x0AE3] = 0x25B3; + xkeysym_unicode_map[0x0AE4] = 0x25BD; + xkeysym_unicode_map[0x0AE5] = 0x2606; + xkeysym_unicode_map[0x0AE6] = 0x2022; + xkeysym_unicode_map[0x0AE7] = 0x25AA; + xkeysym_unicode_map[0x0AE8] = 0x25B2; + xkeysym_unicode_map[0x0AE9] = 0x25BC; + xkeysym_unicode_map[0x0AEA] = 0x261C; + xkeysym_unicode_map[0x0AEB] = 0x261E; + xkeysym_unicode_map[0x0AEC] = 0x2663; + xkeysym_unicode_map[0x0AED] = 0x2666; + xkeysym_unicode_map[0x0AEE] = 0x2665; + xkeysym_unicode_map[0x0AF0] = 0x2720; + xkeysym_unicode_map[0x0AF1] = 0x2020; + xkeysym_unicode_map[0x0AF2] = 0x2021; + xkeysym_unicode_map[0x0AF3] = 0x2713; + xkeysym_unicode_map[0x0AF4] = 0x2717; + xkeysym_unicode_map[0x0AF5] = 0x266F; + xkeysym_unicode_map[0x0AF6] = 0x266D; + xkeysym_unicode_map[0x0AF7] = 0x2642; + xkeysym_unicode_map[0x0AF8] = 0x2640; + xkeysym_unicode_map[0x0AF9] = 0x260E; + xkeysym_unicode_map[0x0AFA] = 0x2315; + xkeysym_unicode_map[0x0AFB] = 0x2117; + xkeysym_unicode_map[0x0AFC] = 0x2038; + xkeysym_unicode_map[0x0AFD] = 0x201A; + xkeysym_unicode_map[0x0AFE] = 0x201E; + xkeysym_unicode_map[0x0BA3] = 0x003C; + xkeysym_unicode_map[0x0BA6] = 0x003E; + xkeysym_unicode_map[0x0BA8] = 0x2228; + xkeysym_unicode_map[0x0BA9] = 0x2227; + xkeysym_unicode_map[0x0BC0] = 0x00AF; + xkeysym_unicode_map[0x0BC2] = 0x22A5; + xkeysym_unicode_map[0x0BC3] = 0x2229; + xkeysym_unicode_map[0x0BC4] = 0x230A; + xkeysym_unicode_map[0x0BC6] = 0x005F; + xkeysym_unicode_map[0x0BCA] = 0x2218; + xkeysym_unicode_map[0x0BCC] = 0x2395; + xkeysym_unicode_map[0x0BCE] = 0x22A4; + xkeysym_unicode_map[0x0BCF] = 0x25CB; + xkeysym_unicode_map[0x0BD3] = 0x2308; + xkeysym_unicode_map[0x0BD6] = 0x222A; + xkeysym_unicode_map[0x0BD8] = 0x2283; + xkeysym_unicode_map[0x0BDA] = 0x2282; + xkeysym_unicode_map[0x0BDC] = 0x22A2; + xkeysym_unicode_map[0x0BFC] = 0x22A3; + xkeysym_unicode_map[0x0CDF] = 0x2017; + xkeysym_unicode_map[0x0CE0] = 0x05D0; + xkeysym_unicode_map[0x0CE1] = 0x05D1; + xkeysym_unicode_map[0x0CE2] = 0x05D2; + xkeysym_unicode_map[0x0CE3] = 0x05D3; + xkeysym_unicode_map[0x0CE4] = 0x05D4; + xkeysym_unicode_map[0x0CE5] = 0x05D5; + xkeysym_unicode_map[0x0CE6] = 0x05D6; + xkeysym_unicode_map[0x0CE7] = 0x05D7; + xkeysym_unicode_map[0x0CE8] = 0x05D8; + xkeysym_unicode_map[0x0CE9] = 0x05D9; + xkeysym_unicode_map[0x0CEA] = 0x05DA; + xkeysym_unicode_map[0x0CEB] = 0x05DB; + xkeysym_unicode_map[0x0CEC] = 0x05DC; + xkeysym_unicode_map[0x0CED] = 0x05DD; + xkeysym_unicode_map[0x0CEE] = 0x05DE; + xkeysym_unicode_map[0x0CEF] = 0x05DF; + xkeysym_unicode_map[0x0CF0] = 0x05E0; + xkeysym_unicode_map[0x0CF1] = 0x05E1; + xkeysym_unicode_map[0x0CF2] = 0x05E2; + xkeysym_unicode_map[0x0CF3] = 0x05E3; + xkeysym_unicode_map[0x0CF4] = 0x05E4; + xkeysym_unicode_map[0x0CF5] = 0x05E5; + xkeysym_unicode_map[0x0CF6] = 0x05E6; + xkeysym_unicode_map[0x0CF7] = 0x05E7; + xkeysym_unicode_map[0x0CF8] = 0x05E8; + xkeysym_unicode_map[0x0CF9] = 0x05E9; + xkeysym_unicode_map[0x0CFA] = 0x05EA; + xkeysym_unicode_map[0x0DA1] = 0x0E01; + xkeysym_unicode_map[0x0DA2] = 0x0E02; + xkeysym_unicode_map[0x0DA3] = 0x0E03; + xkeysym_unicode_map[0x0DA4] = 0x0E04; + xkeysym_unicode_map[0x0DA5] = 0x0E05; + xkeysym_unicode_map[0x0DA6] = 0x0E06; + xkeysym_unicode_map[0x0DA7] = 0x0E07; + xkeysym_unicode_map[0x0DA8] = 0x0E08; + xkeysym_unicode_map[0x0DA9] = 0x0E09; + xkeysym_unicode_map[0x0DAA] = 0x0E0A; + xkeysym_unicode_map[0x0DAB] = 0x0E0B; + xkeysym_unicode_map[0x0DAC] = 0x0E0C; + xkeysym_unicode_map[0x0DAD] = 0x0E0D; + xkeysym_unicode_map[0x0DAE] = 0x0E0E; + xkeysym_unicode_map[0x0DAF] = 0x0E0F; + xkeysym_unicode_map[0x0DB0] = 0x0E10; + xkeysym_unicode_map[0x0DB1] = 0x0E11; + xkeysym_unicode_map[0x0DB2] = 0x0E12; + xkeysym_unicode_map[0x0DB3] = 0x0E13; + xkeysym_unicode_map[0x0DB4] = 0x0E14; + xkeysym_unicode_map[0x0DB5] = 0x0E15; + xkeysym_unicode_map[0x0DB6] = 0x0E16; + xkeysym_unicode_map[0x0DB7] = 0x0E17; + xkeysym_unicode_map[0x0DB8] = 0x0E18; + xkeysym_unicode_map[0x0DB9] = 0x0E19; + xkeysym_unicode_map[0x0DBA] = 0x0E1A; + xkeysym_unicode_map[0x0DBB] = 0x0E1B; + xkeysym_unicode_map[0x0DBC] = 0x0E1C; + xkeysym_unicode_map[0x0DBD] = 0x0E1D; + xkeysym_unicode_map[0x0DBE] = 0x0E1E; + xkeysym_unicode_map[0x0DBF] = 0x0E1F; + xkeysym_unicode_map[0x0DC0] = 0x0E20; + xkeysym_unicode_map[0x0DC1] = 0x0E21; + xkeysym_unicode_map[0x0DC2] = 0x0E22; + xkeysym_unicode_map[0x0DC3] = 0x0E23; + xkeysym_unicode_map[0x0DC4] = 0x0E24; + xkeysym_unicode_map[0x0DC5] = 0x0E25; + xkeysym_unicode_map[0x0DC6] = 0x0E26; + xkeysym_unicode_map[0x0DC7] = 0x0E27; + xkeysym_unicode_map[0x0DC8] = 0x0E28; + xkeysym_unicode_map[0x0DC9] = 0x0E29; + xkeysym_unicode_map[0x0DCA] = 0x0E2A; + xkeysym_unicode_map[0x0DCB] = 0x0E2B; + xkeysym_unicode_map[0x0DCC] = 0x0E2C; + xkeysym_unicode_map[0x0DCD] = 0x0E2D; + xkeysym_unicode_map[0x0DCE] = 0x0E2E; + xkeysym_unicode_map[0x0DCF] = 0x0E2F; + xkeysym_unicode_map[0x0DD0] = 0x0E30; + xkeysym_unicode_map[0x0DD1] = 0x0E31; + xkeysym_unicode_map[0x0DD2] = 0x0E32; + xkeysym_unicode_map[0x0DD3] = 0x0E33; + xkeysym_unicode_map[0x0DD4] = 0x0E34; + xkeysym_unicode_map[0x0DD5] = 0x0E35; + xkeysym_unicode_map[0x0DD6] = 0x0E36; + xkeysym_unicode_map[0x0DD7] = 0x0E37; + xkeysym_unicode_map[0x0DD8] = 0x0E38; + xkeysym_unicode_map[0x0DD9] = 0x0E39; + xkeysym_unicode_map[0x0DDA] = 0x0E3A; + xkeysym_unicode_map[0x0DDF] = 0x0E3F; + xkeysym_unicode_map[0x0DE0] = 0x0E40; + xkeysym_unicode_map[0x0DE1] = 0x0E41; + xkeysym_unicode_map[0x0DE2] = 0x0E42; + xkeysym_unicode_map[0x0DE3] = 0x0E43; + xkeysym_unicode_map[0x0DE4] = 0x0E44; + xkeysym_unicode_map[0x0DE5] = 0x0E45; + xkeysym_unicode_map[0x0DE6] = 0x0E46; + xkeysym_unicode_map[0x0DE7] = 0x0E47; + xkeysym_unicode_map[0x0DE8] = 0x0E48; + xkeysym_unicode_map[0x0DE9] = 0x0E49; + xkeysym_unicode_map[0x0DEA] = 0x0E4A; + xkeysym_unicode_map[0x0DEB] = 0x0E4B; + xkeysym_unicode_map[0x0DEC] = 0x0E4C; + xkeysym_unicode_map[0x0DED] = 0x0E4D; + xkeysym_unicode_map[0x0DF0] = 0x0E50; + xkeysym_unicode_map[0x0DF1] = 0x0E51; + xkeysym_unicode_map[0x0DF2] = 0x0E52; + xkeysym_unicode_map[0x0DF3] = 0x0E53; + xkeysym_unicode_map[0x0DF4] = 0x0E54; + xkeysym_unicode_map[0x0DF5] = 0x0E55; + xkeysym_unicode_map[0x0DF6] = 0x0E56; + xkeysym_unicode_map[0x0DF7] = 0x0E57; + xkeysym_unicode_map[0x0DF8] = 0x0E58; + xkeysym_unicode_map[0x0DF9] = 0x0E59; + xkeysym_unicode_map[0x0EA1] = 0x3131; + xkeysym_unicode_map[0x0EA2] = 0x3132; + xkeysym_unicode_map[0x0EA3] = 0x3133; + xkeysym_unicode_map[0x0EA4] = 0x3134; + xkeysym_unicode_map[0x0EA5] = 0x3135; + xkeysym_unicode_map[0x0EA6] = 0x3136; + xkeysym_unicode_map[0x0EA7] = 0x3137; + xkeysym_unicode_map[0x0EA8] = 0x3138; + xkeysym_unicode_map[0x0EA9] = 0x3139; + xkeysym_unicode_map[0x0EAA] = 0x313A; + xkeysym_unicode_map[0x0EAB] = 0x313B; + xkeysym_unicode_map[0x0EAC] = 0x313C; + xkeysym_unicode_map[0x0EAD] = 0x313D; + xkeysym_unicode_map[0x0EAE] = 0x313E; + xkeysym_unicode_map[0x0EAF] = 0x313F; + xkeysym_unicode_map[0x0EB0] = 0x3140; + xkeysym_unicode_map[0x0EB1] = 0x3141; + xkeysym_unicode_map[0x0EB2] = 0x3142; + xkeysym_unicode_map[0x0EB3] = 0x3143; + xkeysym_unicode_map[0x0EB4] = 0x3144; + xkeysym_unicode_map[0x0EB5] = 0x3145; + xkeysym_unicode_map[0x0EB6] = 0x3146; + xkeysym_unicode_map[0x0EB7] = 0x3147; + xkeysym_unicode_map[0x0EB8] = 0x3148; + xkeysym_unicode_map[0x0EB9] = 0x3149; + xkeysym_unicode_map[0x0EBA] = 0x314A; + xkeysym_unicode_map[0x0EBB] = 0x314B; + xkeysym_unicode_map[0x0EBC] = 0x314C; + xkeysym_unicode_map[0x0EBD] = 0x314D; + xkeysym_unicode_map[0x0EBE] = 0x314E; + xkeysym_unicode_map[0x0EBF] = 0x314F; + xkeysym_unicode_map[0x0EC0] = 0x3150; + xkeysym_unicode_map[0x0EC1] = 0x3151; + xkeysym_unicode_map[0x0EC2] = 0x3152; + xkeysym_unicode_map[0x0EC3] = 0x3153; + xkeysym_unicode_map[0x0EC4] = 0x3154; + xkeysym_unicode_map[0x0EC5] = 0x3155; + xkeysym_unicode_map[0x0EC6] = 0x3156; + xkeysym_unicode_map[0x0EC7] = 0x3157; + xkeysym_unicode_map[0x0EC8] = 0x3158; + xkeysym_unicode_map[0x0EC9] = 0x3159; + xkeysym_unicode_map[0x0ECA] = 0x315A; + xkeysym_unicode_map[0x0ECB] = 0x315B; + xkeysym_unicode_map[0x0ECC] = 0x315C; + xkeysym_unicode_map[0x0ECD] = 0x315D; + xkeysym_unicode_map[0x0ECE] = 0x315E; + xkeysym_unicode_map[0x0ECF] = 0x315F; + xkeysym_unicode_map[0x0ED0] = 0x3160; + xkeysym_unicode_map[0x0ED1] = 0x3161; + xkeysym_unicode_map[0x0ED2] = 0x3162; + xkeysym_unicode_map[0x0ED3] = 0x3163; + xkeysym_unicode_map[0x0ED4] = 0x11A8; + xkeysym_unicode_map[0x0ED5] = 0x11A9; + xkeysym_unicode_map[0x0ED6] = 0x11AA; + xkeysym_unicode_map[0x0ED7] = 0x11AB; + xkeysym_unicode_map[0x0ED8] = 0x11AC; + xkeysym_unicode_map[0x0ED9] = 0x11AD; + xkeysym_unicode_map[0x0EDA] = 0x11AE; + xkeysym_unicode_map[0x0EDB] = 0x11AF; + xkeysym_unicode_map[0x0EDC] = 0x11B0; + xkeysym_unicode_map[0x0EDD] = 0x11B1; + xkeysym_unicode_map[0x0EDE] = 0x11B2; + xkeysym_unicode_map[0x0EDF] = 0x11B3; + xkeysym_unicode_map[0x0EE0] = 0x11B4; + xkeysym_unicode_map[0x0EE1] = 0x11B5; + xkeysym_unicode_map[0x0EE2] = 0x11B6; + xkeysym_unicode_map[0x0EE3] = 0x11B7; + xkeysym_unicode_map[0x0EE4] = 0x11B8; + xkeysym_unicode_map[0x0EE5] = 0x11B9; + xkeysym_unicode_map[0x0EE6] = 0x11BA; + xkeysym_unicode_map[0x0EE7] = 0x11BB; + xkeysym_unicode_map[0x0EE8] = 0x11BC; + xkeysym_unicode_map[0x0EE9] = 0x11BD; + xkeysym_unicode_map[0x0EEA] = 0x11BE; + xkeysym_unicode_map[0x0EEB] = 0x11BF; + xkeysym_unicode_map[0x0EEC] = 0x11C0; + xkeysym_unicode_map[0x0EED] = 0x11C1; + xkeysym_unicode_map[0x0EEE] = 0x11C2; + xkeysym_unicode_map[0x0EEF] = 0x316D; + xkeysym_unicode_map[0x0EF0] = 0x3171; + xkeysym_unicode_map[0x0EF1] = 0x3178; + xkeysym_unicode_map[0x0EF2] = 0x317F; + xkeysym_unicode_map[0x0EF3] = 0x3181; + xkeysym_unicode_map[0x0EF4] = 0x3184; + xkeysym_unicode_map[0x0EF5] = 0x3186; + xkeysym_unicode_map[0x0EF6] = 0x318D; + xkeysym_unicode_map[0x0EF7] = 0x318E; + xkeysym_unicode_map[0x0EF8] = 0x11EB; + xkeysym_unicode_map[0x0EF9] = 0x11F0; + xkeysym_unicode_map[0x0EFA] = 0x11F9; + xkeysym_unicode_map[0x0EFF] = 0x20A9; + xkeysym_unicode_map[0x13A4] = 0x20AC; + xkeysym_unicode_map[0x13BC] = 0x0152; + xkeysym_unicode_map[0x13BD] = 0x0153; + xkeysym_unicode_map[0x13BE] = 0x0178; + xkeysym_unicode_map[0x20AC] = 0x20AC; } -unsigned int KeyMappingX11::get_xlibcode(Key p_keysym) { - unsigned int code = 0; - for (int i = 0; _scancode_to_keycode[i].keysym != Key::UNKNOWN; i++) { - if (_scancode_to_keycode[i].keysym == p_keysym) { - code = _scancode_to_keycode[i].keycode; - break; +Key KeyMappingX11::get_keycode(KeySym p_keysym) { + if (p_keysym >= 0x20 && p_keysym < 0x7E) { // ASCII, maps 1-1 + if (p_keysym > 0x60 && p_keysym < 0x7B) { // Lowercase ASCII. + return (Key)(p_keysym - 32); + } else { + return (Key)p_keysym; } } - return code; -} - -Key KeyMappingX11::get_keycode(KeySym p_keysym) { - // kinda bruteforce.. could optimize. - - if (p_keysym < 0x100) { // Latin 1, maps 1-1 - return (Key)p_keysym; + const Key *key = xkeysym_map.getptr(p_keysym); + if (key) { + return *key; } + return Key::NONE; +} - // look for special key - for (int idx = 0; _xkeysym_to_keycode[idx].keysym != 0; idx++) { - if (_xkeysym_to_keycode[idx].keysym == p_keysym) { - return _xkeysym_to_keycode[idx].keycode; - } +Key KeyMappingX11::get_scancode(unsigned int p_code) { + const Key *key = scancode_map.getptr(p_code); + if (key) { + return *key; } return Key::NONE; } -KeySym KeyMappingX11::get_keysym(Key p_code) { - // kinda bruteforce.. could optimize. - - if (p_code < Key::END_LATIN1) { // Latin 1, maps 1-1 - return (KeySym)p_code; - } - - // look for special key - for (int idx = 0; _xkeysym_to_keycode[idx].keysym != 0; idx++) { - if (_xkeysym_to_keycode[idx].keycode == p_code) { - return _xkeysym_to_keycode[idx].keysym; - } +unsigned int KeyMappingX11::get_xlibcode(Key p_keysym) { + const unsigned int *key = scancode_map_inv.getptr(p_keysym); + if (key) { + return *key; } - - return (KeySym)Key::NONE; + return 0x00; } -/***** UNICODE CONVERSION ******/ - -// Tables taken from FOX toolkit - -struct _XTranslateUnicodePair { - KeySym keysym; - unsigned int unicode; -}; - -enum { - _KEYSYM_MAX = 759 -}; - -static _XTranslateUnicodePair _xkeysym_to_unicode[_KEYSYM_MAX] = { - { 0x01A1, 0x0104 }, - { 0x01A2, 0x02D8 }, - { 0x01A3, 0x0141 }, - { 0x01A5, 0x013D }, - { 0x01A6, 0x015A }, - { 0x01A9, 0x0160 }, - { 0x01AA, 0x015E }, - { 0x01AB, 0x0164 }, - { 0x01AC, 0x0179 }, - { 0x01AE, 0x017D }, - { 0x01AF, 0x017B }, - { 0x01B1, 0x0105 }, - { 0x01B2, 0x02DB }, - { 0x01B3, 0x0142 }, - { 0x01B5, 0x013E }, - { 0x01B6, 0x015B }, - { 0x01B7, 0x02C7 }, - { 0x01B9, 0x0161 }, - { 0x01BA, 0x015F }, - { 0x01BB, 0x0165 }, - { 0x01BC, 0x017A }, - { 0x01BD, 0x02DD }, - { 0x01BE, 0x017E }, - { 0x01BF, 0x017C }, - { 0x01C0, 0x0154 }, - { 0x01C3, 0x0102 }, - { 0x01C5, 0x0139 }, - { 0x01C6, 0x0106 }, - { 0x01C8, 0x010C }, - { 0x01CA, 0x0118 }, - { 0x01CC, 0x011A }, - { 0x01CF, 0x010E }, - { 0x01D0, 0x0110 }, - { 0x01D1, 0x0143 }, - { 0x01D2, 0x0147 }, - { 0x01D5, 0x0150 }, - { 0x01D8, 0x0158 }, - { 0x01D9, 0x016E }, - { 0x01DB, 0x0170 }, - { 0x01DE, 0x0162 }, - { 0x01E0, 0x0155 }, - { 0x01E3, 0x0103 }, - { 0x01E5, 0x013A }, - { 0x01E6, 0x0107 }, - { 0x01E8, 0x010D }, - { 0x01EA, 0x0119 }, - { 0x01EC, 0x011B }, - { 0x01EF, 0x010F }, - { 0x01F0, 0x0111 }, - { 0x01F1, 0x0144 }, - { 0x01F2, 0x0148 }, - { 0x01F5, 0x0151 }, - { 0x01F8, 0x0159 }, - { 0x01F9, 0x016F }, - { 0x01FB, 0x0171 }, - { 0x01FE, 0x0163 }, - { 0x01FF, 0x02D9 }, - { 0x02A1, 0x0126 }, - { 0x02A6, 0x0124 }, - { 0x02A9, 0x0130 }, - { 0x02AB, 0x011E }, - { 0x02AC, 0x0134 }, - { 0x02B1, 0x0127 }, - { 0x02B6, 0x0125 }, - { 0x02B9, 0x0131 }, - { 0x02BB, 0x011F }, - { 0x02BC, 0x0135 }, - { 0x02C5, 0x010A }, - { 0x02C6, 0x0108 }, - { 0x02D5, 0x0120 }, - { 0x02D8, 0x011C }, - { 0x02DD, 0x016C }, - { 0x02DE, 0x015C }, - { 0x02E5, 0x010B }, - { 0x02E6, 0x0109 }, - { 0x02F5, 0x0121 }, - { 0x02F8, 0x011D }, - { 0x02FD, 0x016D }, - { 0x02FE, 0x015D }, - { 0x03A2, 0x0138 }, - { 0x03A3, 0x0156 }, - { 0x03A5, 0x0128 }, - { 0x03A6, 0x013B }, - { 0x03AA, 0x0112 }, - { 0x03AB, 0x0122 }, - { 0x03AC, 0x0166 }, - { 0x03B3, 0x0157 }, - { 0x03B5, 0x0129 }, - { 0x03B6, 0x013C }, - { 0x03BA, 0x0113 }, - { 0x03BB, 0x0123 }, - { 0x03BC, 0x0167 }, - { 0x03BD, 0x014A }, - { 0x03BF, 0x014B }, - { 0x03C0, 0x0100 }, - { 0x03C7, 0x012E }, - { 0x03CC, 0x0116 }, - { 0x03CF, 0x012A }, - { 0x03D1, 0x0145 }, - { 0x03D2, 0x014C }, - { 0x03D3, 0x0136 }, - { 0x03D9, 0x0172 }, - { 0x03DD, 0x0168 }, - { 0x03DE, 0x016A }, - { 0x03E0, 0x0101 }, - { 0x03E7, 0x012F }, - { 0x03EC, 0x0117 }, - { 0x03EF, 0x012B }, - { 0x03F1, 0x0146 }, - { 0x03F2, 0x014D }, - { 0x03F3, 0x0137 }, - { 0x03F9, 0x0173 }, - { 0x03FD, 0x0169 }, - { 0x03FE, 0x016B }, - { 0x047E, 0x203E }, - { 0x04A1, 0x3002 }, - { 0x04A2, 0x300C }, - { 0x04A3, 0x300D }, - { 0x04A4, 0x3001 }, - { 0x04A5, 0x30FB }, - { 0x04A6, 0x30F2 }, - { 0x04A7, 0x30A1 }, - { 0x04A8, 0x30A3 }, - { 0x04A9, 0x30A5 }, - { 0x04AA, 0x30A7 }, - { 0x04AB, 0x30A9 }, - { 0x04AC, 0x30E3 }, - { 0x04AD, 0x30E5 }, - { 0x04AE, 0x30E7 }, - { 0x04AF, 0x30C3 }, - { 0x04B0, 0x30FC }, - { 0x04B1, 0x30A2 }, - { 0x04B2, 0x30A4 }, - { 0x04B3, 0x30A6 }, - { 0x04B4, 0x30A8 }, - { 0x04B5, 0x30AA }, - { 0x04B6, 0x30AB }, - { 0x04B7, 0x30AD }, - { 0x04B8, 0x30AF }, - { 0x04B9, 0x30B1 }, - { 0x04BA, 0x30B3 }, - { 0x04BB, 0x30B5 }, - { 0x04BC, 0x30B7 }, - { 0x04BD, 0x30B9 }, - { 0x04BE, 0x30BB }, - { 0x04BF, 0x30BD }, - { 0x04C0, 0x30BF }, - { 0x04C1, 0x30C1 }, - { 0x04C2, 0x30C4 }, - { 0x04C3, 0x30C6 }, - { 0x04C4, 0x30C8 }, - { 0x04C5, 0x30CA }, - { 0x04C6, 0x30CB }, - { 0x04C7, 0x30CC }, - { 0x04C8, 0x30CD }, - { 0x04C9, 0x30CE }, - { 0x04CA, 0x30CF }, - { 0x04CB, 0x30D2 }, - { 0x04CC, 0x30D5 }, - { 0x04CD, 0x30D8 }, - { 0x04CE, 0x30DB }, - { 0x04CF, 0x30DE }, - { 0x04D0, 0x30DF }, - { 0x04D1, 0x30E0 }, - { 0x04D2, 0x30E1 }, - { 0x04D3, 0x30E2 }, - { 0x04D4, 0x30E4 }, - { 0x04D5, 0x30E6 }, - { 0x04D6, 0x30E8 }, - { 0x04D7, 0x30E9 }, - { 0x04D8, 0x30EA }, - { 0x04D9, 0x30EB }, - { 0x04DA, 0x30EC }, - { 0x04DB, 0x30ED }, - { 0x04DC, 0x30EF }, - { 0x04DD, 0x30F3 }, - { 0x04DE, 0x309B }, - { 0x04DF, 0x309C }, - { 0x05AC, 0x060C }, - { 0x05BB, 0x061B }, - { 0x05BF, 0x061F }, - { 0x05C1, 0x0621 }, - { 0x05C2, 0x0622 }, - { 0x05C3, 0x0623 }, - { 0x05C4, 0x0624 }, - { 0x05C5, 0x0625 }, - { 0x05C6, 0x0626 }, - { 0x05C7, 0x0627 }, - { 0x05C8, 0x0628 }, - { 0x05C9, 0x0629 }, - { 0x05CA, 0x062A }, - { 0x05CB, 0x062B }, - { 0x05CC, 0x062C }, - { 0x05CD, 0x062D }, - { 0x05CE, 0x062E }, - { 0x05CF, 0x062F }, - { 0x05D0, 0x0630 }, - { 0x05D1, 0x0631 }, - { 0x05D2, 0x0632 }, - { 0x05D3, 0x0633 }, - { 0x05D4, 0x0634 }, - { 0x05D5, 0x0635 }, - { 0x05D6, 0x0636 }, - { 0x05D7, 0x0637 }, - { 0x05D8, 0x0638 }, - { 0x05D9, 0x0639 }, - { 0x05DA, 0x063A }, - { 0x05E0, 0x0640 }, - { 0x05E1, 0x0641 }, - { 0x05E2, 0x0642 }, - { 0x05E3, 0x0643 }, - { 0x05E4, 0x0644 }, - { 0x05E5, 0x0645 }, - { 0x05E6, 0x0646 }, - { 0x05E7, 0x0647 }, - { 0x05E8, 0x0648 }, - { 0x05E9, 0x0649 }, - { 0x05EA, 0x064A }, - { 0x05EB, 0x064B }, - { 0x05EC, 0x064C }, - { 0x05ED, 0x064D }, - { 0x05EE, 0x064E }, - { 0x05EF, 0x064F }, - { 0x05F0, 0x0650 }, - { 0x05F1, 0x0651 }, - { 0x05F2, 0x0652 }, - { 0x06A1, 0x0452 }, - { 0x06A2, 0x0453 }, - { 0x06A3, 0x0451 }, - { 0x06A4, 0x0454 }, - { 0x06A5, 0x0455 }, - { 0x06A6, 0x0456 }, - { 0x06A7, 0x0457 }, - { 0x06A8, 0x0458 }, - { 0x06A9, 0x0459 }, - { 0x06AA, 0x045A }, - { 0x06AB, 0x045B }, - { 0x06AC, 0x045C }, - { 0x06AE, 0x045E }, - { 0x06AF, 0x045F }, - { 0x06B0, 0x2116 }, - { 0x06B1, 0x0402 }, - { 0x06B2, 0x0403 }, - { 0x06B3, 0x0401 }, - { 0x06B4, 0x0404 }, - { 0x06B5, 0x0405 }, - { 0x06B6, 0x0406 }, - { 0x06B7, 0x0407 }, - { 0x06B8, 0x0408 }, - { 0x06B9, 0x0409 }, - { 0x06BA, 0x040A }, - { 0x06BB, 0x040B }, - { 0x06BC, 0x040C }, - { 0x06BE, 0x040E }, - { 0x06BF, 0x040F }, - { 0x06C0, 0x044E }, - { 0x06C1, 0x0430 }, - { 0x06C2, 0x0431 }, - { 0x06C3, 0x0446 }, - { 0x06C4, 0x0434 }, - { 0x06C5, 0x0435 }, - { 0x06C6, 0x0444 }, - { 0x06C7, 0x0433 }, - { 0x06C8, 0x0445 }, - { 0x06C9, 0x0438 }, - { 0x06CA, 0x0439 }, - { 0x06CB, 0x043A }, - { 0x06CC, 0x043B }, - { 0x06CD, 0x043C }, - { 0x06CE, 0x043D }, - { 0x06CF, 0x043E }, - { 0x06D0, 0x043F }, - { 0x06D1, 0x044F }, - { 0x06D2, 0x0440 }, - { 0x06D3, 0x0441 }, - { 0x06D4, 0x0442 }, - { 0x06D5, 0x0443 }, - { 0x06D6, 0x0436 }, - { 0x06D7, 0x0432 }, - { 0x06D8, 0x044C }, - { 0x06D9, 0x044B }, - { 0x06DA, 0x0437 }, - { 0x06DB, 0x0448 }, - { 0x06DC, 0x044D }, - { 0x06DD, 0x0449 }, - { 0x06DE, 0x0447 }, - { 0x06DF, 0x044A }, - { 0x06E0, 0x042E }, - { 0x06E1, 0x0410 }, - { 0x06E2, 0x0411 }, - { 0x06E3, 0x0426 }, - { 0x06E4, 0x0414 }, - { 0x06E5, 0x0415 }, - { 0x06E6, 0x0424 }, - { 0x06E7, 0x0413 }, - { 0x06E8, 0x0425 }, - { 0x06E9, 0x0418 }, - { 0x06EA, 0x0419 }, - { 0x06EB, 0x041A }, - { 0x06EC, 0x041B }, - { 0x06ED, 0x041C }, - { 0x06EE, 0x041D }, - { 0x06EF, 0x041E }, - { 0x06F0, 0x041F }, - { 0x06F1, 0x042F }, - { 0x06F2, 0x0420 }, - { 0x06F3, 0x0421 }, - { 0x06F4, 0x0422 }, - { 0x06F5, 0x0423 }, - { 0x06F6, 0x0416 }, - { 0x06F7, 0x0412 }, - { 0x06F8, 0x042C }, - { 0x06F9, 0x042B }, - { 0x06FA, 0x0417 }, - { 0x06FB, 0x0428 }, - { 0x06FC, 0x042D }, - { 0x06FD, 0x0429 }, - { 0x06FE, 0x0427 }, - { 0x06FF, 0x042A }, - { 0x07A1, 0x0386 }, - { 0x07A2, 0x0388 }, - { 0x07A3, 0x0389 }, - { 0x07A4, 0x038A }, - { 0x07A5, 0x03AA }, - { 0x07A7, 0x038C }, - { 0x07A8, 0x038E }, - { 0x07A9, 0x03AB }, - { 0x07AB, 0x038F }, - { 0x07AE, 0x0385 }, - { 0x07AF, 0x2015 }, - { 0x07B1, 0x03AC }, - { 0x07B2, 0x03AD }, - { 0x07B3, 0x03AE }, - { 0x07B4, 0x03AF }, - { 0x07B5, 0x03CA }, - { 0x07B6, 0x0390 }, - { 0x07B7, 0x03CC }, - { 0x07B8, 0x03CD }, - { 0x07B9, 0x03CB }, - { 0x07BA, 0x03B0 }, - { 0x07BB, 0x03CE }, - { 0x07C1, 0x0391 }, - { 0x07C2, 0x0392 }, - { 0x07C3, 0x0393 }, - { 0x07C4, 0x0394 }, - { 0x07C5, 0x0395 }, - { 0x07C6, 0x0396 }, - { 0x07C7, 0x0397 }, - { 0x07C8, 0x0398 }, - { 0x07C9, 0x0399 }, - { 0x07CA, 0x039A }, - { 0x07CB, 0x039B }, - { 0x07CC, 0x039C }, - { 0x07CD, 0x039D }, - { 0x07CE, 0x039E }, - { 0x07CF, 0x039F }, - { 0x07D0, 0x03A0 }, - { 0x07D1, 0x03A1 }, - { 0x07D2, 0x03A3 }, - { 0x07D4, 0x03A4 }, - { 0x07D5, 0x03A5 }, - { 0x07D6, 0x03A6 }, - { 0x07D7, 0x03A7 }, - { 0x07D8, 0x03A8 }, - { 0x07D9, 0x03A9 }, - { 0x07E1, 0x03B1 }, - { 0x07E2, 0x03B2 }, - { 0x07E3, 0x03B3 }, - { 0x07E4, 0x03B4 }, - { 0x07E5, 0x03B5 }, - { 0x07E6, 0x03B6 }, - { 0x07E7, 0x03B7 }, - { 0x07E8, 0x03B8 }, - { 0x07E9, 0x03B9 }, - { 0x07EA, 0x03BA }, - { 0x07EB, 0x03BB }, - { 0x07EC, 0x03BC }, - { 0x07ED, 0x03BD }, - { 0x07EE, 0x03BE }, - { 0x07EF, 0x03BF }, - { 0x07F0, 0x03C0 }, - { 0x07F1, 0x03C1 }, - { 0x07F2, 0x03C3 }, - { 0x07F3, 0x03C2 }, - { 0x07F4, 0x03C4 }, - { 0x07F5, 0x03C5 }, - { 0x07F6, 0x03C6 }, - { 0x07F7, 0x03C7 }, - { 0x07F8, 0x03C8 }, - { 0x07F9, 0x03C9 }, - { 0x08A1, 0x23B7 }, - { 0x08A2, 0x250C }, - { 0x08A3, 0x2500 }, - { 0x08A4, 0x2320 }, - { 0x08A5, 0x2321 }, - { 0x08A6, 0x2502 }, - { 0x08A7, 0x23A1 }, - { 0x08A8, 0x23A3 }, - { 0x08A9, 0x23A4 }, - { 0x08AA, 0x23A6 }, - { 0x08AB, 0x239B }, - { 0x08AC, 0x239D }, - { 0x08AD, 0x239E }, - { 0x08AE, 0x23A0 }, - { 0x08AF, 0x23A8 }, - { 0x08B0, 0x23AC }, - { 0x08BC, 0x2264 }, - { 0x08BD, 0x2260 }, - { 0x08BE, 0x2265 }, - { 0x08BF, 0x222B }, - { 0x08C0, 0x2234 }, - { 0x08C1, 0x221D }, - { 0x08C2, 0x221E }, - { 0x08C5, 0x2207 }, - { 0x08C8, 0x223C }, - { 0x08C9, 0x2243 }, - { 0x08CD, 0x21D4 }, - { 0x08CE, 0x21D2 }, - { 0x08CF, 0x2261 }, - { 0x08D6, 0x221A }, - { 0x08DA, 0x2282 }, - { 0x08DB, 0x2283 }, - { 0x08DC, 0x2229 }, - { 0x08DD, 0x222A }, - { 0x08DE, 0x2227 }, - { 0x08DF, 0x2228 }, - { 0x08EF, 0x2202 }, - { 0x08F6, 0x0192 }, - { 0x08FB, 0x2190 }, - { 0x08FC, 0x2191 }, - { 0x08FD, 0x2192 }, - { 0x08FE, 0x2193 }, - { 0x09E0, 0x25C6 }, - { 0x09E1, 0x2592 }, - { 0x09E2, 0x2409 }, - { 0x09E3, 0x240C }, - { 0x09E4, 0x240D }, - { 0x09E5, 0x240A }, - { 0x09E8, 0x2424 }, - { 0x09E9, 0x240B }, - { 0x09EA, 0x2518 }, - { 0x09EB, 0x2510 }, - { 0x09EC, 0x250C }, - { 0x09ED, 0x2514 }, - { 0x09EE, 0x253C }, - { 0x09EF, 0x23BA }, - { 0x09F0, 0x23BB }, - { 0x09F1, 0x2500 }, - { 0x09F2, 0x23BC }, - { 0x09F3, 0x23BD }, - { 0x09F4, 0x251C }, - { 0x09F5, 0x2524 }, - { 0x09F6, 0x2534 }, - { 0x09F7, 0x252C }, - { 0x09F8, 0x2502 }, - { 0x0AA1, 0x2003 }, - { 0x0AA2, 0x2002 }, - { 0x0AA3, 0x2004 }, - { 0x0AA4, 0x2005 }, - { 0x0AA5, 0x2007 }, - { 0x0AA6, 0x2008 }, - { 0x0AA7, 0x2009 }, - { 0x0AA8, 0x200A }, - { 0x0AA9, 0x2014 }, - { 0x0AAA, 0x2013 }, - { 0x0AAE, 0x2026 }, - { 0x0AAF, 0x2025 }, - { 0x0AB0, 0x2153 }, - { 0x0AB1, 0x2154 }, - { 0x0AB2, 0x2155 }, - { 0x0AB3, 0x2156 }, - { 0x0AB4, 0x2157 }, - { 0x0AB5, 0x2158 }, - { 0x0AB6, 0x2159 }, - { 0x0AB7, 0x215A }, - { 0x0AB8, 0x2105 }, - { 0x0ABB, 0x2012 }, - { 0x0ABC, 0x2329 }, - { 0x0ABE, 0x232A }, - { 0x0AC3, 0x215B }, - { 0x0AC4, 0x215C }, - { 0x0AC5, 0x215D }, - { 0x0AC6, 0x215E }, - { 0x0AC9, 0x2122 }, - { 0x0ACA, 0x2613 }, - { 0x0ACC, 0x25C1 }, - { 0x0ACD, 0x25B7 }, - { 0x0ACE, 0x25CB }, - { 0x0ACF, 0x25AF }, - { 0x0AD0, 0x2018 }, - { 0x0AD1, 0x2019 }, - { 0x0AD2, 0x201C }, - { 0x0AD3, 0x201D }, - { 0x0AD4, 0x211E }, - { 0x0AD6, 0x2032 }, - { 0x0AD7, 0x2033 }, - { 0x0AD9, 0x271D }, - { 0x0ADB, 0x25AC }, - { 0x0ADC, 0x25C0 }, - { 0x0ADD, 0x25B6 }, - { 0x0ADE, 0x25CF }, - { 0x0ADF, 0x25AE }, - { 0x0AE0, 0x25E6 }, - { 0x0AE1, 0x25AB }, - { 0x0AE2, 0x25AD }, - { 0x0AE3, 0x25B3 }, - { 0x0AE4, 0x25BD }, - { 0x0AE5, 0x2606 }, - { 0x0AE6, 0x2022 }, - { 0x0AE7, 0x25AA }, - { 0x0AE8, 0x25B2 }, - { 0x0AE9, 0x25BC }, - { 0x0AEA, 0x261C }, - { 0x0AEB, 0x261E }, - { 0x0AEC, 0x2663 }, - { 0x0AED, 0x2666 }, - { 0x0AEE, 0x2665 }, - { 0x0AF0, 0x2720 }, - { 0x0AF1, 0x2020 }, - { 0x0AF2, 0x2021 }, - { 0x0AF3, 0x2713 }, - { 0x0AF4, 0x2717 }, - { 0x0AF5, 0x266F }, - { 0x0AF6, 0x266D }, - { 0x0AF7, 0x2642 }, - { 0x0AF8, 0x2640 }, - { 0x0AF9, 0x260E }, - { 0x0AFA, 0x2315 }, - { 0x0AFB, 0x2117 }, - { 0x0AFC, 0x2038 }, - { 0x0AFD, 0x201A }, - { 0x0AFE, 0x201E }, - { 0x0BA3, 0x003C }, - { 0x0BA6, 0x003E }, - { 0x0BA8, 0x2228 }, - { 0x0BA9, 0x2227 }, - { 0x0BC0, 0x00AF }, - { 0x0BC2, 0x22A5 }, - { 0x0BC3, 0x2229 }, - { 0x0BC4, 0x230A }, - { 0x0BC6, 0x005F }, - { 0x0BCA, 0x2218 }, - { 0x0BCC, 0x2395 }, - { 0x0BCE, 0x22A4 }, - { 0x0BCF, 0x25CB }, - { 0x0BD3, 0x2308 }, - { 0x0BD6, 0x222A }, - { 0x0BD8, 0x2283 }, - { 0x0BDA, 0x2282 }, - { 0x0BDC, 0x22A2 }, - { 0x0BFC, 0x22A3 }, - { 0x0CDF, 0x2017 }, - { 0x0CE0, 0x05D0 }, - { 0x0CE1, 0x05D1 }, - { 0x0CE2, 0x05D2 }, - { 0x0CE3, 0x05D3 }, - { 0x0CE4, 0x05D4 }, - { 0x0CE5, 0x05D5 }, - { 0x0CE6, 0x05D6 }, - { 0x0CE7, 0x05D7 }, - { 0x0CE8, 0x05D8 }, - { 0x0CE9, 0x05D9 }, - { 0x0CEA, 0x05DA }, - { 0x0CEB, 0x05DB }, - { 0x0CEC, 0x05DC }, - { 0x0CED, 0x05DD }, - { 0x0CEE, 0x05DE }, - { 0x0CEF, 0x05DF }, - { 0x0CF0, 0x05E0 }, - { 0x0CF1, 0x05E1 }, - { 0x0CF2, 0x05E2 }, - { 0x0CF3, 0x05E3 }, - { 0x0CF4, 0x05E4 }, - { 0x0CF5, 0x05E5 }, - { 0x0CF6, 0x05E6 }, - { 0x0CF7, 0x05E7 }, - { 0x0CF8, 0x05E8 }, - { 0x0CF9, 0x05E9 }, - { 0x0CFA, 0x05EA }, - { 0x0DA1, 0x0E01 }, - { 0x0DA2, 0x0E02 }, - { 0x0DA3, 0x0E03 }, - { 0x0DA4, 0x0E04 }, - { 0x0DA5, 0x0E05 }, - { 0x0DA6, 0x0E06 }, - { 0x0DA7, 0x0E07 }, - { 0x0DA8, 0x0E08 }, - { 0x0DA9, 0x0E09 }, - { 0x0DAA, 0x0E0A }, - { 0x0DAB, 0x0E0B }, - { 0x0DAC, 0x0E0C }, - { 0x0DAD, 0x0E0D }, - { 0x0DAE, 0x0E0E }, - { 0x0DAF, 0x0E0F }, - { 0x0DB0, 0x0E10 }, - { 0x0DB1, 0x0E11 }, - { 0x0DB2, 0x0E12 }, - { 0x0DB3, 0x0E13 }, - { 0x0DB4, 0x0E14 }, - { 0x0DB5, 0x0E15 }, - { 0x0DB6, 0x0E16 }, - { 0x0DB7, 0x0E17 }, - { 0x0DB8, 0x0E18 }, - { 0x0DB9, 0x0E19 }, - { 0x0DBA, 0x0E1A }, - { 0x0DBB, 0x0E1B }, - { 0x0DBC, 0x0E1C }, - { 0x0DBD, 0x0E1D }, - { 0x0DBE, 0x0E1E }, - { 0x0DBF, 0x0E1F }, - { 0x0DC0, 0x0E20 }, - { 0x0DC1, 0x0E21 }, - { 0x0DC2, 0x0E22 }, - { 0x0DC3, 0x0E23 }, - { 0x0DC4, 0x0E24 }, - { 0x0DC5, 0x0E25 }, - { 0x0DC6, 0x0E26 }, - { 0x0DC7, 0x0E27 }, - { 0x0DC8, 0x0E28 }, - { 0x0DC9, 0x0E29 }, - { 0x0DCA, 0x0E2A }, - { 0x0DCB, 0x0E2B }, - { 0x0DCC, 0x0E2C }, - { 0x0DCD, 0x0E2D }, - { 0x0DCE, 0x0E2E }, - { 0x0DCF, 0x0E2F }, - { 0x0DD0, 0x0E30 }, - { 0x0DD1, 0x0E31 }, - { 0x0DD2, 0x0E32 }, - { 0x0DD3, 0x0E33 }, - { 0x0DD4, 0x0E34 }, - { 0x0DD5, 0x0E35 }, - { 0x0DD6, 0x0E36 }, - { 0x0DD7, 0x0E37 }, - { 0x0DD8, 0x0E38 }, - { 0x0DD9, 0x0E39 }, - { 0x0DDA, 0x0E3A }, - { 0x0DDF, 0x0E3F }, - { 0x0DE0, 0x0E40 }, - { 0x0DE1, 0x0E41 }, - { 0x0DE2, 0x0E42 }, - { 0x0DE3, 0x0E43 }, - { 0x0DE4, 0x0E44 }, - { 0x0DE5, 0x0E45 }, - { 0x0DE6, 0x0E46 }, - { 0x0DE7, 0x0E47 }, - { 0x0DE8, 0x0E48 }, - { 0x0DE9, 0x0E49 }, - { 0x0DEA, 0x0E4A }, - { 0x0DEB, 0x0E4B }, - { 0x0DEC, 0x0E4C }, - { 0x0DED, 0x0E4D }, - { 0x0DF0, 0x0E50 }, - { 0x0DF1, 0x0E51 }, - { 0x0DF2, 0x0E52 }, - { 0x0DF3, 0x0E53 }, - { 0x0DF4, 0x0E54 }, - { 0x0DF5, 0x0E55 }, - { 0x0DF6, 0x0E56 }, - { 0x0DF7, 0x0E57 }, - { 0x0DF8, 0x0E58 }, - { 0x0DF9, 0x0E59 }, - { 0x0EA1, 0x3131 }, - { 0x0EA2, 0x3132 }, - { 0x0EA3, 0x3133 }, - { 0x0EA4, 0x3134 }, - { 0x0EA5, 0x3135 }, - { 0x0EA6, 0x3136 }, - { 0x0EA7, 0x3137 }, - { 0x0EA8, 0x3138 }, - { 0x0EA9, 0x3139 }, - { 0x0EAA, 0x313A }, - { 0x0EAB, 0x313B }, - { 0x0EAC, 0x313C }, - { 0x0EAD, 0x313D }, - { 0x0EAE, 0x313E }, - { 0x0EAF, 0x313F }, - { 0x0EB0, 0x3140 }, - { 0x0EB1, 0x3141 }, - { 0x0EB2, 0x3142 }, - { 0x0EB3, 0x3143 }, - { 0x0EB4, 0x3144 }, - { 0x0EB5, 0x3145 }, - { 0x0EB6, 0x3146 }, - { 0x0EB7, 0x3147 }, - { 0x0EB8, 0x3148 }, - { 0x0EB9, 0x3149 }, - { 0x0EBA, 0x314A }, - { 0x0EBB, 0x314B }, - { 0x0EBC, 0x314C }, - { 0x0EBD, 0x314D }, - { 0x0EBE, 0x314E }, - { 0x0EBF, 0x314F }, - { 0x0EC0, 0x3150 }, - { 0x0EC1, 0x3151 }, - { 0x0EC2, 0x3152 }, - { 0x0EC3, 0x3153 }, - { 0x0EC4, 0x3154 }, - { 0x0EC5, 0x3155 }, - { 0x0EC6, 0x3156 }, - { 0x0EC7, 0x3157 }, - { 0x0EC8, 0x3158 }, - { 0x0EC9, 0x3159 }, - { 0x0ECA, 0x315A }, - { 0x0ECB, 0x315B }, - { 0x0ECC, 0x315C }, - { 0x0ECD, 0x315D }, - { 0x0ECE, 0x315E }, - { 0x0ECF, 0x315F }, - { 0x0ED0, 0x3160 }, - { 0x0ED1, 0x3161 }, - { 0x0ED2, 0x3162 }, - { 0x0ED3, 0x3163 }, - { 0x0ED4, 0x11A8 }, - { 0x0ED5, 0x11A9 }, - { 0x0ED6, 0x11AA }, - { 0x0ED7, 0x11AB }, - { 0x0ED8, 0x11AC }, - { 0x0ED9, 0x11AD }, - { 0x0EDA, 0x11AE }, - { 0x0EDB, 0x11AF }, - { 0x0EDC, 0x11B0 }, - { 0x0EDD, 0x11B1 }, - { 0x0EDE, 0x11B2 }, - { 0x0EDF, 0x11B3 }, - { 0x0EE0, 0x11B4 }, - { 0x0EE1, 0x11B5 }, - { 0x0EE2, 0x11B6 }, - { 0x0EE3, 0x11B7 }, - { 0x0EE4, 0x11B8 }, - { 0x0EE5, 0x11B9 }, - { 0x0EE6, 0x11BA }, - { 0x0EE7, 0x11BB }, - { 0x0EE8, 0x11BC }, - { 0x0EE9, 0x11BD }, - { 0x0EEA, 0x11BE }, - { 0x0EEB, 0x11BF }, - { 0x0EEC, 0x11C0 }, - { 0x0EED, 0x11C1 }, - { 0x0EEE, 0x11C2 }, - { 0x0EEF, 0x316D }, - { 0x0EF0, 0x3171 }, - { 0x0EF1, 0x3178 }, - { 0x0EF2, 0x317F }, - { 0x0EF3, 0x3181 }, - { 0x0EF4, 0x3184 }, - { 0x0EF5, 0x3186 }, - { 0x0EF6, 0x318D }, - { 0x0EF7, 0x318E }, - { 0x0EF8, 0x11EB }, - { 0x0EF9, 0x11F0 }, - { 0x0EFA, 0x11F9 }, - { 0x0EFF, 0x20A9 }, - { 0x13A4, 0x20AC }, - { 0x13BC, 0x0152 }, - { 0x13BD, 0x0153 }, - { 0x13BE, 0x0178 }, - { 0x20AC, 0x20AC }, -}; - -unsigned int KeyMappingX11::get_unicode_from_keysym(KeySym p_keysym) { - /* Latin-1 */ - if (p_keysym >= 0x20 && p_keysym <= 0x7e) { +char32_t KeyMappingX11::get_unicode_from_keysym(KeySym p_keysym) { + // Latin-1 + if (p_keysym >= 0x20 && p_keysym <= 0x7E) { return p_keysym; } - if (p_keysym >= 0xa0 && p_keysym <= 0xff) { + if (p_keysym >= 0xA0 && p_keysym <= 0xFF) { return p_keysym; } - // keypad to latin1 is easy - if (p_keysym >= 0xffaa && p_keysym <= 0xffb9) { - return p_keysym - 0xff80; - } - /* Unicode (may be present)*/ - - if ((p_keysym & 0xff000000) == 0x01000000) { - return p_keysym & 0x00ffffff; + // Keypad to Latin-1. + if (p_keysym >= 0xFFAA && p_keysym <= 0xFFB9) { + return p_keysym - 0xFF80; } - int middle, low = 0, high = _KEYSYM_MAX - 1; - do { - middle = (high + low) / 2; - if (_xkeysym_to_unicode[middle].keysym == p_keysym) { - return _xkeysym_to_unicode[middle].unicode; - } - if (_xkeysym_to_unicode[middle].keysym <= p_keysym) { - low = middle + 1; - } else { - high = middle - 1; - } - } while (high >= low); - - return 0; -} - -struct _XTranslateUnicodePairReverse { - unsigned int unicode; - KeySym keysym; -}; - -enum { - _UNICODE_MAX = 750 -}; - -static _XTranslateUnicodePairReverse _unicode_to_xkeysym[_UNICODE_MAX] = { - { 0x0ABD, 0x002E }, - { 0x0BA3, 0x003C }, - { 0x0BA6, 0x003E }, - { 0x0BC6, 0x005F }, - { 0x0BC0, 0x00AF }, - { 0x03C0, 0x0100 }, - { 0x03E0, 0x0101 }, - { 0x01C3, 0x0102 }, - { 0x01E3, 0x0103 }, - { 0x01A1, 0x0104 }, - { 0x01B1, 0x0105 }, - { 0x01C6, 0x0106 }, - { 0x01E6, 0x0107 }, - { 0x02C6, 0x0108 }, - { 0x02E6, 0x0109 }, - { 0x02C5, 0x010A }, - { 0x02E5, 0x010B }, - { 0x01C8, 0x010C }, - { 0x01E8, 0x010D }, - { 0x01CF, 0x010E }, - { 0x01EF, 0x010F }, - { 0x01D0, 0x0110 }, - { 0x01F0, 0x0111 }, - { 0x03AA, 0x0112 }, - { 0x03BA, 0x0113 }, - { 0x03CC, 0x0116 }, - { 0x03EC, 0x0117 }, - { 0x01CA, 0x0118 }, - { 0x01EA, 0x0119 }, - { 0x01CC, 0x011A }, - { 0x01EC, 0x011B }, - { 0x02D8, 0x011C }, - { 0x02F8, 0x011D }, - { 0x02AB, 0x011E }, - { 0x02BB, 0x011F }, - { 0x02D5, 0x0120 }, - { 0x02F5, 0x0121 }, - { 0x03AB, 0x0122 }, - { 0x03BB, 0x0123 }, - { 0x02A6, 0x0124 }, - { 0x02B6, 0x0125 }, - { 0x02A1, 0x0126 }, - { 0x02B1, 0x0127 }, - { 0x03A5, 0x0128 }, - { 0x03B5, 0x0129 }, - { 0x03CF, 0x012A }, - { 0x03EF, 0x012B }, - { 0x03C7, 0x012E }, - { 0x03E7, 0x012F }, - { 0x02A9, 0x0130 }, - { 0x02B9, 0x0131 }, - { 0x02AC, 0x0134 }, - { 0x02BC, 0x0135 }, - { 0x03D3, 0x0136 }, - { 0x03F3, 0x0137 }, - { 0x03A2, 0x0138 }, - { 0x01C5, 0x0139 }, - { 0x01E5, 0x013A }, - { 0x03A6, 0x013B }, - { 0x03B6, 0x013C }, - { 0x01A5, 0x013D }, - { 0x01B5, 0x013E }, - { 0x01A3, 0x0141 }, - { 0x01B3, 0x0142 }, - { 0x01D1, 0x0143 }, - { 0x01F1, 0x0144 }, - { 0x03D1, 0x0145 }, - { 0x03F1, 0x0146 }, - { 0x01D2, 0x0147 }, - { 0x01F2, 0x0148 }, - { 0x03BD, 0x014A }, - { 0x03BF, 0x014B }, - { 0x03D2, 0x014C }, - { 0x03F2, 0x014D }, - { 0x01D5, 0x0150 }, - { 0x01F5, 0x0151 }, - { 0x13BC, 0x0152 }, - { 0x13BD, 0x0153 }, - { 0x01C0, 0x0154 }, - { 0x01E0, 0x0155 }, - { 0x03A3, 0x0156 }, - { 0x03B3, 0x0157 }, - { 0x01D8, 0x0158 }, - { 0x01F8, 0x0159 }, - { 0x01A6, 0x015A }, - { 0x01B6, 0x015B }, - { 0x02DE, 0x015C }, - { 0x02FE, 0x015D }, - { 0x01AA, 0x015E }, - { 0x01BA, 0x015F }, - { 0x01A9, 0x0160 }, - { 0x01B9, 0x0161 }, - { 0x01DE, 0x0162 }, - { 0x01FE, 0x0163 }, - { 0x01AB, 0x0164 }, - { 0x01BB, 0x0165 }, - { 0x03AC, 0x0166 }, - { 0x03BC, 0x0167 }, - { 0x03DD, 0x0168 }, - { 0x03FD, 0x0169 }, - { 0x03DE, 0x016A }, - { 0x03FE, 0x016B }, - { 0x02DD, 0x016C }, - { 0x02FD, 0x016D }, - { 0x01D9, 0x016E }, - { 0x01F9, 0x016F }, - { 0x01DB, 0x0170 }, - { 0x01FB, 0x0171 }, - { 0x03D9, 0x0172 }, - { 0x03F9, 0x0173 }, - { 0x13BE, 0x0178 }, - { 0x01AC, 0x0179 }, - { 0x01BC, 0x017A }, - { 0x01AF, 0x017B }, - { 0x01BF, 0x017C }, - { 0x01AE, 0x017D }, - { 0x01BE, 0x017E }, - { 0x08F6, 0x0192 }, - { 0x01B7, 0x02C7 }, - { 0x01A2, 0x02D8 }, - { 0x01FF, 0x02D9 }, - { 0x01B2, 0x02DB }, - { 0x01BD, 0x02DD }, - { 0x07AE, 0x0385 }, - { 0x07A1, 0x0386 }, - { 0x07A2, 0x0388 }, - { 0x07A3, 0x0389 }, - { 0x07A4, 0x038A }, - { 0x07A7, 0x038C }, - { 0x07A8, 0x038E }, - { 0x07AB, 0x038F }, - { 0x07B6, 0x0390 }, - { 0x07C1, 0x0391 }, - { 0x07C2, 0x0392 }, - { 0x07C3, 0x0393 }, - { 0x07C4, 0x0394 }, - { 0x07C5, 0x0395 }, - { 0x07C6, 0x0396 }, - { 0x07C7, 0x0397 }, - { 0x07C8, 0x0398 }, - { 0x07C9, 0x0399 }, - { 0x07CA, 0x039A }, - { 0x07CB, 0x039B }, - { 0x07CC, 0x039C }, - { 0x07CD, 0x039D }, - { 0x07CE, 0x039E }, - { 0x07CF, 0x039F }, - { 0x07D0, 0x03A0 }, - { 0x07D1, 0x03A1 }, - { 0x07D2, 0x03A3 }, - { 0x07D4, 0x03A4 }, - { 0x07D5, 0x03A5 }, - { 0x07D6, 0x03A6 }, - { 0x07D7, 0x03A7 }, - { 0x07D8, 0x03A8 }, - { 0x07D9, 0x03A9 }, - { 0x07A5, 0x03AA }, - { 0x07A9, 0x03AB }, - { 0x07B1, 0x03AC }, - { 0x07B2, 0x03AD }, - { 0x07B3, 0x03AE }, - { 0x07B4, 0x03AF }, - { 0x07BA, 0x03B0 }, - { 0x07E1, 0x03B1 }, - { 0x07E2, 0x03B2 }, - { 0x07E3, 0x03B3 }, - { 0x07E4, 0x03B4 }, - { 0x07E5, 0x03B5 }, - { 0x07E6, 0x03B6 }, - { 0x07E7, 0x03B7 }, - { 0x07E8, 0x03B8 }, - { 0x07E9, 0x03B9 }, - { 0x07EA, 0x03BA }, - { 0x07EB, 0x03BB }, - { 0x07EC, 0x03BC }, - { 0x07ED, 0x03BD }, - { 0x07EE, 0x03BE }, - { 0x07EF, 0x03BF }, - { 0x07F0, 0x03C0 }, - { 0x07F1, 0x03C1 }, - { 0x07F3, 0x03C2 }, - { 0x07F2, 0x03C3 }, - { 0x07F4, 0x03C4 }, - { 0x07F5, 0x03C5 }, - { 0x07F6, 0x03C6 }, - { 0x07F7, 0x03C7 }, - { 0x07F8, 0x03C8 }, - { 0x07F9, 0x03C9 }, - { 0x07B5, 0x03CA }, - { 0x07B9, 0x03CB }, - { 0x07B7, 0x03CC }, - { 0x07B8, 0x03CD }, - { 0x07BB, 0x03CE }, - { 0x06B3, 0x0401 }, - { 0x06B1, 0x0402 }, - { 0x06B2, 0x0403 }, - { 0x06B4, 0x0404 }, - { 0x06B5, 0x0405 }, - { 0x06B6, 0x0406 }, - { 0x06B7, 0x0407 }, - { 0x06B8, 0x0408 }, - { 0x06B9, 0x0409 }, - { 0x06BA, 0x040A }, - { 0x06BB, 0x040B }, - { 0x06BC, 0x040C }, - { 0x06BE, 0x040E }, - { 0x06BF, 0x040F }, - { 0x06E1, 0x0410 }, - { 0x06E2, 0x0411 }, - { 0x06F7, 0x0412 }, - { 0x06E7, 0x0413 }, - { 0x06E4, 0x0414 }, - { 0x06E5, 0x0415 }, - { 0x06F6, 0x0416 }, - { 0x06FA, 0x0417 }, - { 0x06E9, 0x0418 }, - { 0x06EA, 0x0419 }, - { 0x06EB, 0x041A }, - { 0x06EC, 0x041B }, - { 0x06ED, 0x041C }, - { 0x06EE, 0x041D }, - { 0x06EF, 0x041E }, - { 0x06F0, 0x041F }, - { 0x06F2, 0x0420 }, - { 0x06F3, 0x0421 }, - { 0x06F4, 0x0422 }, - { 0x06F5, 0x0423 }, - { 0x06E6, 0x0424 }, - { 0x06E8, 0x0425 }, - { 0x06E3, 0x0426 }, - { 0x06FE, 0x0427 }, - { 0x06FB, 0x0428 }, - { 0x06FD, 0x0429 }, - { 0x06FF, 0x042A }, - { 0x06F9, 0x042B }, - { 0x06F8, 0x042C }, - { 0x06FC, 0x042D }, - { 0x06E0, 0x042E }, - { 0x06F1, 0x042F }, - { 0x06C1, 0x0430 }, - { 0x06C2, 0x0431 }, - { 0x06D7, 0x0432 }, - { 0x06C7, 0x0433 }, - { 0x06C4, 0x0434 }, - { 0x06C5, 0x0435 }, - { 0x06D6, 0x0436 }, - { 0x06DA, 0x0437 }, - { 0x06C9, 0x0438 }, - { 0x06CA, 0x0439 }, - { 0x06CB, 0x043A }, - { 0x06CC, 0x043B }, - { 0x06CD, 0x043C }, - { 0x06CE, 0x043D }, - { 0x06CF, 0x043E }, - { 0x06D0, 0x043F }, - { 0x06D2, 0x0440 }, - { 0x06D3, 0x0441 }, - { 0x06D4, 0x0442 }, - { 0x06D5, 0x0443 }, - { 0x06C6, 0x0444 }, - { 0x06C8, 0x0445 }, - { 0x06C3, 0x0446 }, - { 0x06DE, 0x0447 }, - { 0x06DB, 0x0448 }, - { 0x06DD, 0x0449 }, - { 0x06DF, 0x044A }, - { 0x06D9, 0x044B }, - { 0x06D8, 0x044C }, - { 0x06DC, 0x044D }, - { 0x06C0, 0x044E }, - { 0x06D1, 0x044F }, - { 0x06A3, 0x0451 }, - { 0x06A1, 0x0452 }, - { 0x06A2, 0x0453 }, - { 0x06A4, 0x0454 }, - { 0x06A5, 0x0455 }, - { 0x06A6, 0x0456 }, - { 0x06A7, 0x0457 }, - { 0x06A8, 0x0458 }, - { 0x06A9, 0x0459 }, - { 0x06AA, 0x045A }, - { 0x06AB, 0x045B }, - { 0x06AC, 0x045C }, - { 0x06AE, 0x045E }, - { 0x06AF, 0x045F }, - { 0x0CE0, 0x05D0 }, - { 0x0CE1, 0x05D1 }, - { 0x0CE2, 0x05D2 }, - { 0x0CE3, 0x05D3 }, - { 0x0CE4, 0x05D4 }, - { 0x0CE5, 0x05D5 }, - { 0x0CE6, 0x05D6 }, - { 0x0CE7, 0x05D7 }, - { 0x0CE8, 0x05D8 }, - { 0x0CE9, 0x05D9 }, - { 0x0CEA, 0x05DA }, - { 0x0CEB, 0x05DB }, - { 0x0CEC, 0x05DC }, - { 0x0CED, 0x05DD }, - { 0x0CEE, 0x05DE }, - { 0x0CEF, 0x05DF }, - { 0x0CF0, 0x05E0 }, - { 0x0CF1, 0x05E1 }, - { 0x0CF2, 0x05E2 }, - { 0x0CF3, 0x05E3 }, - { 0x0CF4, 0x05E4 }, - { 0x0CF5, 0x05E5 }, - { 0x0CF6, 0x05E6 }, - { 0x0CF7, 0x05E7 }, - { 0x0CF8, 0x05E8 }, - { 0x0CF9, 0x05E9 }, - { 0x0CFA, 0x05EA }, - { 0x05AC, 0x060C }, - { 0x05BB, 0x061B }, - { 0x05BF, 0x061F }, - { 0x05C1, 0x0621 }, - { 0x05C2, 0x0622 }, - { 0x05C3, 0x0623 }, - { 0x05C4, 0x0624 }, - { 0x05C5, 0x0625 }, - { 0x05C6, 0x0626 }, - { 0x05C7, 0x0627 }, - { 0x05C8, 0x0628 }, - { 0x05C9, 0x0629 }, - { 0x05CA, 0x062A }, - { 0x05CB, 0x062B }, - { 0x05CC, 0x062C }, - { 0x05CD, 0x062D }, - { 0x05CE, 0x062E }, - { 0x05CF, 0x062F }, - { 0x05D0, 0x0630 }, - { 0x05D1, 0x0631 }, - { 0x05D2, 0x0632 }, - { 0x05D3, 0x0633 }, - { 0x05D4, 0x0634 }, - { 0x05D5, 0x0635 }, - { 0x05D6, 0x0636 }, - { 0x05D7, 0x0637 }, - { 0x05D8, 0x0638 }, - { 0x05D9, 0x0639 }, - { 0x05DA, 0x063A }, - { 0x05E0, 0x0640 }, - { 0x05E1, 0x0641 }, - { 0x05E2, 0x0642 }, - { 0x05E3, 0x0643 }, - { 0x05E4, 0x0644 }, - { 0x05E5, 0x0645 }, - { 0x05E6, 0x0646 }, - { 0x05E7, 0x0647 }, - { 0x05E8, 0x0648 }, - { 0x05E9, 0x0649 }, - { 0x05EA, 0x064A }, - { 0x05EB, 0x064B }, - { 0x05EC, 0x064C }, - { 0x05ED, 0x064D }, - { 0x05EE, 0x064E }, - { 0x05EF, 0x064F }, - { 0x05F0, 0x0650 }, - { 0x05F1, 0x0651 }, - { 0x05F2, 0x0652 }, - { 0x0DA1, 0x0E01 }, - { 0x0DA2, 0x0E02 }, - { 0x0DA3, 0x0E03 }, - { 0x0DA4, 0x0E04 }, - { 0x0DA5, 0x0E05 }, - { 0x0DA6, 0x0E06 }, - { 0x0DA7, 0x0E07 }, - { 0x0DA8, 0x0E08 }, - { 0x0DA9, 0x0E09 }, - { 0x0DAA, 0x0E0A }, - { 0x0DAB, 0x0E0B }, - { 0x0DAC, 0x0E0C }, - { 0x0DAD, 0x0E0D }, - { 0x0DAE, 0x0E0E }, - { 0x0DAF, 0x0E0F }, - { 0x0DB0, 0x0E10 }, - { 0x0DB1, 0x0E11 }, - { 0x0DB2, 0x0E12 }, - { 0x0DB3, 0x0E13 }, - { 0x0DB4, 0x0E14 }, - { 0x0DB5, 0x0E15 }, - { 0x0DB6, 0x0E16 }, - { 0x0DB7, 0x0E17 }, - { 0x0DB8, 0x0E18 }, - { 0x0DB9, 0x0E19 }, - { 0x0DBA, 0x0E1A }, - { 0x0DBB, 0x0E1B }, - { 0x0DBC, 0x0E1C }, - { 0x0DBD, 0x0E1D }, - { 0x0DBE, 0x0E1E }, - { 0x0DBF, 0x0E1F }, - { 0x0DC0, 0x0E20 }, - { 0x0DC1, 0x0E21 }, - { 0x0DC2, 0x0E22 }, - { 0x0DC3, 0x0E23 }, - { 0x0DC4, 0x0E24 }, - { 0x0DC5, 0x0E25 }, - { 0x0DC6, 0x0E26 }, - { 0x0DC7, 0x0E27 }, - { 0x0DC8, 0x0E28 }, - { 0x0DC9, 0x0E29 }, - { 0x0DCA, 0x0E2A }, - { 0x0DCB, 0x0E2B }, - { 0x0DCC, 0x0E2C }, - { 0x0DCD, 0x0E2D }, - { 0x0DCE, 0x0E2E }, - { 0x0DCF, 0x0E2F }, - { 0x0DD0, 0x0E30 }, - { 0x0DD1, 0x0E31 }, - { 0x0DD2, 0x0E32 }, - { 0x0DD3, 0x0E33 }, - { 0x0DD4, 0x0E34 }, - { 0x0DD5, 0x0E35 }, - { 0x0DD6, 0x0E36 }, - { 0x0DD7, 0x0E37 }, - { 0x0DD8, 0x0E38 }, - { 0x0DD9, 0x0E39 }, - { 0x0DDA, 0x0E3A }, - { 0x0DDF, 0x0E3F }, - { 0x0DE0, 0x0E40 }, - { 0x0DE1, 0x0E41 }, - { 0x0DE2, 0x0E42 }, - { 0x0DE3, 0x0E43 }, - { 0x0DE4, 0x0E44 }, - { 0x0DE5, 0x0E45 }, - { 0x0DE6, 0x0E46 }, - { 0x0DE7, 0x0E47 }, - { 0x0DE8, 0x0E48 }, - { 0x0DE9, 0x0E49 }, - { 0x0DEA, 0x0E4A }, - { 0x0DEB, 0x0E4B }, - { 0x0DEC, 0x0E4C }, - { 0x0DED, 0x0E4D }, - { 0x0DF0, 0x0E50 }, - { 0x0DF1, 0x0E51 }, - { 0x0DF2, 0x0E52 }, - { 0x0DF3, 0x0E53 }, - { 0x0DF4, 0x0E54 }, - { 0x0DF5, 0x0E55 }, - { 0x0DF6, 0x0E56 }, - { 0x0DF7, 0x0E57 }, - { 0x0DF8, 0x0E58 }, - { 0x0DF9, 0x0E59 }, - { 0x0ED4, 0x11A8 }, - { 0x0ED5, 0x11A9 }, - { 0x0ED6, 0x11AA }, - { 0x0ED7, 0x11AB }, - { 0x0ED8, 0x11AC }, - { 0x0ED9, 0x11AD }, - { 0x0EDA, 0x11AE }, - { 0x0EDB, 0x11AF }, - { 0x0EDC, 0x11B0 }, - { 0x0EDD, 0x11B1 }, - { 0x0EDE, 0x11B2 }, - { 0x0EDF, 0x11B3 }, - { 0x0EE0, 0x11B4 }, - { 0x0EE1, 0x11B5 }, - { 0x0EE2, 0x11B6 }, - { 0x0EE3, 0x11B7 }, - { 0x0EE4, 0x11B8 }, - { 0x0EE5, 0x11B9 }, - { 0x0EE6, 0x11BA }, - { 0x0EE7, 0x11BB }, - { 0x0EE8, 0x11BC }, - { 0x0EE9, 0x11BD }, - { 0x0EEA, 0x11BE }, - { 0x0EEB, 0x11BF }, - { 0x0EEC, 0x11C0 }, - { 0x0EED, 0x11C1 }, - { 0x0EEE, 0x11C2 }, - { 0x0EF8, 0x11EB }, - { 0x0EFA, 0x11F9 }, - { 0x0AA2, 0x2002 }, - { 0x0AA1, 0x2003 }, - { 0x0AA3, 0x2004 }, - { 0x0AA4, 0x2005 }, - { 0x0AA5, 0x2007 }, - { 0x0AA6, 0x2008 }, - { 0x0AA7, 0x2009 }, - { 0x0AA8, 0x200A }, - { 0x0ABB, 0x2012 }, - { 0x0AAA, 0x2013 }, - { 0x0AA9, 0x2014 }, - { 0x07AF, 0x2015 }, - { 0x0CDF, 0x2017 }, - { 0x0AD0, 0x2018 }, - { 0x0AD1, 0x2019 }, - { 0x0AFD, 0x201A }, - { 0x0AD2, 0x201C }, - { 0x0AD3, 0x201D }, - { 0x0AFE, 0x201E }, - { 0x0AF1, 0x2020 }, - { 0x0AF2, 0x2021 }, - { 0x0AE6, 0x2022 }, - { 0x0AAE, 0x2026 }, - { 0x0AD6, 0x2032 }, - { 0x0AD7, 0x2033 }, - { 0x0AFC, 0x2038 }, - { 0x047E, 0x203E }, - { 0x20A0, 0x20A0 }, - { 0x20A1, 0x20A1 }, - { 0x20A2, 0x20A2 }, - { 0x20A3, 0x20A3 }, - { 0x20A4, 0x20A4 }, - { 0x20A5, 0x20A5 }, - { 0x20A6, 0x20A6 }, - { 0x20A7, 0x20A7 }, - { 0x20A8, 0x20A8 }, - { 0x0EFF, 0x20A9 }, - { 0x20A9, 0x20A9 }, - { 0x20AA, 0x20AA }, - { 0x20AB, 0x20AB }, - { 0x20AC, 0x20AC }, - { 0x0AB8, 0x2105 }, - { 0x06B0, 0x2116 }, - { 0x0AFB, 0x2117 }, - { 0x0AD4, 0x211E }, - { 0x0AC9, 0x2122 }, - { 0x0AB0, 0x2153 }, - { 0x0AB1, 0x2154 }, - { 0x0AB2, 0x2155 }, - { 0x0AB3, 0x2156 }, - { 0x0AB4, 0x2157 }, - { 0x0AB5, 0x2158 }, - { 0x0AB6, 0x2159 }, - { 0x0AB7, 0x215A }, - { 0x0AC3, 0x215B }, - { 0x0AC4, 0x215C }, - { 0x0AC5, 0x215D }, - { 0x0AC6, 0x215E }, - { 0x08FB, 0x2190 }, - { 0x08FC, 0x2191 }, - { 0x08FD, 0x2192 }, - { 0x08FE, 0x2193 }, - { 0x08CE, 0x21D2 }, - { 0x08CD, 0x21D4 }, - { 0x08EF, 0x2202 }, - { 0x08C5, 0x2207 }, - { 0x0BCA, 0x2218 }, - { 0x08D6, 0x221A }, - { 0x08C1, 0x221D }, - { 0x08C2, 0x221E }, - { 0x08DE, 0x2227 }, - { 0x0BA9, 0x2227 }, - { 0x08DF, 0x2228 }, - { 0x0BA8, 0x2228 }, - { 0x08DC, 0x2229 }, - { 0x0BC3, 0x2229 }, - { 0x08DD, 0x222A }, - { 0x0BD6, 0x222A }, - { 0x08BF, 0x222B }, - { 0x08C0, 0x2234 }, - { 0x08C8, 0x2245 }, - { 0x08BD, 0x2260 }, - { 0x08CF, 0x2261 }, - { 0x08BC, 0x2264 }, - { 0x08BE, 0x2265 }, - { 0x08DA, 0x2282 }, - { 0x0BDA, 0x2282 }, - { 0x08DB, 0x2283 }, - { 0x0BD8, 0x2283 }, - { 0x0BFC, 0x22A2 }, - { 0x0BDC, 0x22A3 }, - { 0x0BC2, 0x22A4 }, - { 0x0BCE, 0x22A5 }, - { 0x0BD3, 0x2308 }, - { 0x0BC4, 0x230A }, - { 0x0AFA, 0x2315 }, - { 0x08A4, 0x2320 }, - { 0x08A5, 0x2321 }, - { 0x0ABC, 0x2329 }, - { 0x0ABE, 0x232A }, - { 0x0BCC, 0x2395 }, - { 0x09E2, 0x2409 }, - { 0x09E5, 0x240A }, - { 0x09E9, 0x240B }, - { 0x09E3, 0x240C }, - { 0x09E4, 0x240D }, - { 0x09DF, 0x2422 }, - { 0x09E8, 0x2424 }, - { 0x09F1, 0x2500 }, - { 0x08A6, 0x2502 }, - { 0x09F8, 0x2502 }, - { 0x09EC, 0x250C }, - { 0x09EB, 0x2510 }, - { 0x09ED, 0x2514 }, - { 0x09EA, 0x2518 }, - { 0x09F4, 0x251C }, - { 0x09F5, 0x2524 }, - { 0x09F7, 0x252C }, - { 0x09F6, 0x2534 }, - { 0x09EE, 0x253C }, - { 0x09E1, 0x2592 }, - { 0x0ADF, 0x25A0 }, - { 0x0ACF, 0x25A1 }, - { 0x0AE7, 0x25AA }, - { 0x0AE1, 0x25AB }, - { 0x0ADB, 0x25AC }, - { 0x0AE2, 0x25AD }, - { 0x0AE8, 0x25B2 }, - { 0x0AE3, 0x25B3 }, - { 0x0ADD, 0x25B6 }, - { 0x0ACD, 0x25B7 }, - { 0x0AE9, 0x25BC }, - { 0x0AE4, 0x25BD }, - { 0x0ADC, 0x25C0 }, - { 0x0ACC, 0x25C1 }, - { 0x09E0, 0x25C6 }, - { 0x0ACE, 0x25CB }, - { 0x0BCF, 0x25CB }, - { 0x0ADE, 0x25CF }, - { 0x0AE0, 0x25E6 }, - { 0x0AE5, 0x2606 }, - { 0x0AF9, 0x260E }, - { 0x0ACA, 0x2613 }, - { 0x0AEA, 0x261C }, - { 0x0AEB, 0x261E }, - { 0x0AF8, 0x2640 }, - { 0x0AF7, 0x2642 }, - { 0x0AEC, 0x2663 }, - { 0x0AEE, 0x2665 }, - { 0x0AED, 0x2666 }, - { 0x0AF6, 0x266D }, - { 0x0AF5, 0x266F }, - { 0x0AF3, 0x2713 }, - { 0x0AF4, 0x2717 }, - { 0x0AD9, 0x271D }, - { 0x0AF0, 0x2720 }, - { 0x04A4, 0x3001 }, - { 0x04A1, 0x3002 }, - { 0x04A2, 0x300C }, - { 0x04A3, 0x300D }, - { 0x04DE, 0x309B }, - { 0x04DF, 0x309C }, - { 0x04A7, 0x30A1 }, - { 0x04B1, 0x30A2 }, - { 0x04A8, 0x30A3 }, - { 0x04B2, 0x30A4 }, - { 0x04A9, 0x30A5 }, - { 0x04B3, 0x30A6 }, - { 0x04AA, 0x30A7 }, - { 0x04B4, 0x30A8 }, - { 0x04AB, 0x30A9 }, - { 0x04B5, 0x30AA }, - { 0x04B6, 0x30AB }, - { 0x04B7, 0x30AD }, - { 0x04B8, 0x30AF }, - { 0x04B9, 0x30B1 }, - { 0x04BA, 0x30B3 }, - { 0x04BB, 0x30B5 }, - { 0x04BC, 0x30B7 }, - { 0x04BD, 0x30B9 }, - { 0x04BE, 0x30BB }, - { 0x04BF, 0x30BD }, - { 0x04C0, 0x30BF }, - { 0x04C1, 0x30C1 }, - { 0x04AF, 0x30C3 }, - { 0x04C2, 0x30C4 }, - { 0x04C3, 0x30C6 }, - { 0x04C4, 0x30C8 }, - { 0x04C5, 0x30CA }, - { 0x04C6, 0x30CB }, - { 0x04C7, 0x30CC }, - { 0x04C8, 0x30CD }, - { 0x04C9, 0x30CE }, - { 0x04CA, 0x30CF }, - { 0x04CB, 0x30D2 }, - { 0x04CC, 0x30D5 }, - { 0x04CD, 0x30D8 }, - { 0x04CE, 0x30DB }, - { 0x04CF, 0x30DE }, - { 0x04D0, 0x30DF }, - { 0x04D1, 0x30E0 }, - { 0x04D2, 0x30E1 }, - { 0x04D3, 0x30E2 }, - { 0x04AC, 0x30E3 }, - { 0x04D4, 0x30E4 }, - { 0x04AD, 0x30E5 }, - { 0x04D5, 0x30E6 }, - { 0x04AE, 0x30E7 }, - { 0x04D6, 0x30E8 }, - { 0x04D7, 0x30E9 }, - { 0x04D8, 0x30EA }, - { 0x04D9, 0x30EB }, - { 0x04DA, 0x30EC }, - { 0x04DB, 0x30ED }, - { 0x04DC, 0x30EF }, - { 0x04A6, 0x30F2 }, - { 0x04DD, 0x30F3 }, - { 0x04A5, 0x30FB }, - { 0x04B0, 0x30FC }, - { 0x0EA1, 0x3131 }, - { 0x0EA2, 0x3132 }, - { 0x0EA3, 0x3133 }, - { 0x0EA4, 0x3134 }, - { 0x0EA5, 0x3135 }, - { 0x0EA6, 0x3136 }, - { 0x0EA7, 0x3137 }, - { 0x0EA8, 0x3138 }, - { 0x0EA9, 0x3139 }, - { 0x0EAA, 0x313A }, - { 0x0EAB, 0x313B }, - { 0x0EAC, 0x313C }, - { 0x0EAD, 0x313D }, - { 0x0EAE, 0x313E }, - { 0x0EAF, 0x313F }, - { 0x0EB0, 0x3140 }, - { 0x0EB1, 0x3141 }, - { 0x0EB2, 0x3142 }, - { 0x0EB3, 0x3143 }, - { 0x0EB4, 0x3144 }, - { 0x0EB5, 0x3145 }, - { 0x0EB6, 0x3146 }, - { 0x0EB7, 0x3147 }, - { 0x0EB8, 0x3148 }, - { 0x0EB9, 0x3149 }, - { 0x0EBA, 0x314A }, - { 0x0EBB, 0x314B }, - { 0x0EBC, 0x314C }, - { 0x0EBD, 0x314D }, - { 0x0EBE, 0x314E }, - { 0x0EBF, 0x314F }, - { 0x0EC0, 0x3150 }, - { 0x0EC1, 0x3151 }, - { 0x0EC2, 0x3152 }, - { 0x0EC3, 0x3153 }, - { 0x0EC4, 0x3154 }, - { 0x0EC5, 0x3155 }, - { 0x0EC6, 0x3156 }, - { 0x0EC7, 0x3157 }, - { 0x0EC8, 0x3158 }, - { 0x0EC9, 0x3159 }, - { 0x0ECA, 0x315A }, - { 0x0ECB, 0x315B }, - { 0x0ECC, 0x315C }, - { 0x0ECD, 0x315D }, - { 0x0ECE, 0x315E }, - { 0x0ECF, 0x315F }, - { 0x0ED0, 0x3160 }, - { 0x0ED1, 0x3161 }, - { 0x0ED2, 0x3162 }, - { 0x0ED3, 0x3163 }, - { 0x0EEF, 0x316D }, - { 0x0EF0, 0x3171 }, - { 0x0EF1, 0x3178 }, - { 0x0EF2, 0x317F }, - { 0x0EF4, 0x3184 }, - { 0x0EF5, 0x3186 }, - { 0x0EF6, 0x318D }, - { 0x0EF7, 0x318E } -}; - -KeySym KeyMappingX11::get_keysym_from_unicode(unsigned int p_unicode) { - /* Latin 1 */ - - if (p_unicode >= 0x20 && p_unicode <= 0x7e) { - return p_unicode; + // Unicode (may be present). + if ((p_keysym & 0xFF000000) == 0x01000000) { + return p_keysym & 0x00FFFFFF; } - if (p_unicode >= 0xa0 && p_unicode <= 0xff) { - return p_unicode; + const char32_t *c = xkeysym_unicode_map.getptr(p_keysym); + if (c) { + return *c; } - - int middle, low = 0, high = _UNICODE_MAX - 1; - do { - middle = (high + low) / 2; - if (_unicode_to_xkeysym[middle].keysym == p_unicode) { - return _unicode_to_xkeysym[middle].keysym; - } - if (_unicode_to_xkeysym[middle].keysym <= p_unicode) { - low = middle + 1; - } else { - high = middle - 1; - } - } while (high >= low); - - // if not found, let's hope X understands it as unicode - return p_unicode | 0x01000000; + return 0; } diff --git a/platform/linuxbsd/x11/key_mapping_x11.h b/platform/linuxbsd/x11/key_mapping_x11.h index 2b411e21d2..48beefff4c 100644 --- a/platform/linuxbsd/x11/key_mapping_x11.h +++ b/platform/linuxbsd/x11/key_mapping_x11.h @@ -39,17 +39,30 @@ #include <X11/keysymdef.h> #include "core/os/keyboard.h" +#include "core/templates/hash_map.h" class KeyMappingX11 { + struct HashMapHasherKeys { + static _FORCE_INLINE_ uint32_t hash(const Key p_key) { return hash_fmix32(static_cast<uint32_t>(p_key)); } + static _FORCE_INLINE_ uint32_t hash(const char32_t p_uchar) { return hash_fmix32(p_uchar); } + static _FORCE_INLINE_ uint32_t hash(const unsigned p_key) { return hash_fmix32(p_key); } + static _FORCE_INLINE_ uint32_t hash(const KeySym p_key) { return hash_fmix32(p_key); } + }; + + static inline HashMap<KeySym, Key, HashMapHasherKeys> xkeysym_map; + static inline HashMap<unsigned int, Key, HashMapHasherKeys> scancode_map; + static inline HashMap<Key, unsigned int, HashMapHasherKeys> scancode_map_inv; + static inline HashMap<KeySym, char32_t, HashMapHasherKeys> xkeysym_unicode_map; + KeyMappingX11() {} public: + static void initialize(); + static Key get_keycode(KeySym p_keysym); static unsigned int get_xlibcode(Key p_keysym); static Key get_scancode(unsigned int p_code); - static KeySym get_keysym(Key p_code); - static unsigned int get_unicode_from_keysym(KeySym p_keysym); - static KeySym get_keysym_from_unicode(unsigned int p_unicode); + static char32_t get_unicode_from_keysym(KeySym p_keysym); }; #endif // KEY_MAPPING_X11_H diff --git a/platform/linuxbsd/xkbcommon-so_wrap.c b/platform/linuxbsd/xkbcommon-so_wrap.c new file mode 100644 index 0000000000..601d4c5052 --- /dev/null +++ b/platform/linuxbsd/xkbcommon-so_wrap.c @@ -0,0 +1,859 @@ +// This file is generated. Do not edit! +// see https://github.com/hpvb/dynload-wrapper for details +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-23 15:14:21 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/xkbcommon/xkbcommon.h --sys-include "./thirdparty/linuxbsd_headers/xkbcommon/xkbcommon.h" --soname libxkbcommon.so.0 --init-name xkbcommon --output-header ./platform/linuxbsd/x11/dynwrappers/xkbcommon-so_wrap.h --output-implementation ./platform/linuxbsd/x11/dynwrappers/xkbcommon-so_wrap.c +// +#include <stdint.h> + +#define xkb_keysym_get_name xkb_keysym_get_name_dylibloader_orig_xkbcommon +#define xkb_keysym_from_name xkb_keysym_from_name_dylibloader_orig_xkbcommon +#define xkb_keysym_to_utf8 xkb_keysym_to_utf8_dylibloader_orig_xkbcommon +#define xkb_keysym_to_utf32 xkb_keysym_to_utf32_dylibloader_orig_xkbcommon +#define xkb_utf32_to_keysym xkb_utf32_to_keysym_dylibloader_orig_xkbcommon +#define xkb_keysym_to_upper xkb_keysym_to_upper_dylibloader_orig_xkbcommon +#define xkb_keysym_to_lower xkb_keysym_to_lower_dylibloader_orig_xkbcommon +#define xkb_context_new xkb_context_new_dylibloader_orig_xkbcommon +#define xkb_context_ref xkb_context_ref_dylibloader_orig_xkbcommon +#define xkb_context_unref xkb_context_unref_dylibloader_orig_xkbcommon +#define xkb_context_set_user_data xkb_context_set_user_data_dylibloader_orig_xkbcommon +#define xkb_context_get_user_data xkb_context_get_user_data_dylibloader_orig_xkbcommon +#define xkb_context_include_path_append xkb_context_include_path_append_dylibloader_orig_xkbcommon +#define xkb_context_include_path_append_default xkb_context_include_path_append_default_dylibloader_orig_xkbcommon +#define xkb_context_include_path_reset_defaults xkb_context_include_path_reset_defaults_dylibloader_orig_xkbcommon +#define xkb_context_include_path_clear xkb_context_include_path_clear_dylibloader_orig_xkbcommon +#define xkb_context_num_include_paths xkb_context_num_include_paths_dylibloader_orig_xkbcommon +#define xkb_context_include_path_get xkb_context_include_path_get_dylibloader_orig_xkbcommon +#define xkb_context_set_log_level xkb_context_set_log_level_dylibloader_orig_xkbcommon +#define xkb_context_get_log_level xkb_context_get_log_level_dylibloader_orig_xkbcommon +#define xkb_context_set_log_verbosity xkb_context_set_log_verbosity_dylibloader_orig_xkbcommon +#define xkb_context_get_log_verbosity xkb_context_get_log_verbosity_dylibloader_orig_xkbcommon +#define xkb_context_set_log_fn xkb_context_set_log_fn_dylibloader_orig_xkbcommon +#define xkb_keymap_new_from_names xkb_keymap_new_from_names_dylibloader_orig_xkbcommon +#define xkb_keymap_new_from_file xkb_keymap_new_from_file_dylibloader_orig_xkbcommon +#define xkb_keymap_new_from_string xkb_keymap_new_from_string_dylibloader_orig_xkbcommon +#define xkb_keymap_new_from_buffer xkb_keymap_new_from_buffer_dylibloader_orig_xkbcommon +#define xkb_keymap_ref xkb_keymap_ref_dylibloader_orig_xkbcommon +#define xkb_keymap_unref xkb_keymap_unref_dylibloader_orig_xkbcommon +#define xkb_keymap_get_as_string xkb_keymap_get_as_string_dylibloader_orig_xkbcommon +#define xkb_keymap_min_keycode xkb_keymap_min_keycode_dylibloader_orig_xkbcommon +#define xkb_keymap_max_keycode xkb_keymap_max_keycode_dylibloader_orig_xkbcommon +#define xkb_keymap_key_for_each xkb_keymap_key_for_each_dylibloader_orig_xkbcommon +#define xkb_keymap_key_get_name xkb_keymap_key_get_name_dylibloader_orig_xkbcommon +#define xkb_keymap_key_by_name xkb_keymap_key_by_name_dylibloader_orig_xkbcommon +#define xkb_keymap_num_mods xkb_keymap_num_mods_dylibloader_orig_xkbcommon +#define xkb_keymap_mod_get_name xkb_keymap_mod_get_name_dylibloader_orig_xkbcommon +#define xkb_keymap_mod_get_index xkb_keymap_mod_get_index_dylibloader_orig_xkbcommon +#define xkb_keymap_num_layouts xkb_keymap_num_layouts_dylibloader_orig_xkbcommon +#define xkb_keymap_layout_get_name xkb_keymap_layout_get_name_dylibloader_orig_xkbcommon +#define xkb_keymap_layout_get_index xkb_keymap_layout_get_index_dylibloader_orig_xkbcommon +#define xkb_keymap_num_leds xkb_keymap_num_leds_dylibloader_orig_xkbcommon +#define xkb_keymap_led_get_name xkb_keymap_led_get_name_dylibloader_orig_xkbcommon +#define xkb_keymap_led_get_index xkb_keymap_led_get_index_dylibloader_orig_xkbcommon +#define xkb_keymap_num_layouts_for_key xkb_keymap_num_layouts_for_key_dylibloader_orig_xkbcommon +#define xkb_keymap_num_levels_for_key xkb_keymap_num_levels_for_key_dylibloader_orig_xkbcommon +#define xkb_keymap_key_get_mods_for_level xkb_keymap_key_get_mods_for_level_dylibloader_orig_xkbcommon +#define xkb_keymap_key_get_syms_by_level xkb_keymap_key_get_syms_by_level_dylibloader_orig_xkbcommon +#define xkb_keymap_key_repeats xkb_keymap_key_repeats_dylibloader_orig_xkbcommon +#define xkb_state_new xkb_state_new_dylibloader_orig_xkbcommon +#define xkb_state_ref xkb_state_ref_dylibloader_orig_xkbcommon +#define xkb_state_unref xkb_state_unref_dylibloader_orig_xkbcommon +#define xkb_state_get_keymap xkb_state_get_keymap_dylibloader_orig_xkbcommon +#define xkb_state_update_key xkb_state_update_key_dylibloader_orig_xkbcommon +#define xkb_state_update_mask xkb_state_update_mask_dylibloader_orig_xkbcommon +#define xkb_state_key_get_syms xkb_state_key_get_syms_dylibloader_orig_xkbcommon +#define xkb_state_key_get_utf8 xkb_state_key_get_utf8_dylibloader_orig_xkbcommon +#define xkb_state_key_get_utf32 xkb_state_key_get_utf32_dylibloader_orig_xkbcommon +#define xkb_state_key_get_one_sym xkb_state_key_get_one_sym_dylibloader_orig_xkbcommon +#define xkb_state_key_get_layout xkb_state_key_get_layout_dylibloader_orig_xkbcommon +#define xkb_state_key_get_level xkb_state_key_get_level_dylibloader_orig_xkbcommon +#define xkb_state_serialize_mods xkb_state_serialize_mods_dylibloader_orig_xkbcommon +#define xkb_state_serialize_layout xkb_state_serialize_layout_dylibloader_orig_xkbcommon +#define xkb_state_mod_name_is_active xkb_state_mod_name_is_active_dylibloader_orig_xkbcommon +#define xkb_state_mod_names_are_active xkb_state_mod_names_are_active_dylibloader_orig_xkbcommon +#define xkb_state_mod_index_is_active xkb_state_mod_index_is_active_dylibloader_orig_xkbcommon +#define xkb_state_mod_indices_are_active xkb_state_mod_indices_are_active_dylibloader_orig_xkbcommon +#define xkb_state_key_get_consumed_mods2 xkb_state_key_get_consumed_mods2_dylibloader_orig_xkbcommon +#define xkb_state_key_get_consumed_mods xkb_state_key_get_consumed_mods_dylibloader_orig_xkbcommon +#define xkb_state_mod_index_is_consumed2 xkb_state_mod_index_is_consumed2_dylibloader_orig_xkbcommon +#define xkb_state_mod_index_is_consumed xkb_state_mod_index_is_consumed_dylibloader_orig_xkbcommon +#define xkb_state_mod_mask_remove_consumed xkb_state_mod_mask_remove_consumed_dylibloader_orig_xkbcommon +#define xkb_state_layout_name_is_active xkb_state_layout_name_is_active_dylibloader_orig_xkbcommon +#define xkb_state_layout_index_is_active xkb_state_layout_index_is_active_dylibloader_orig_xkbcommon +#define xkb_state_led_name_is_active xkb_state_led_name_is_active_dylibloader_orig_xkbcommon +#define xkb_state_led_index_is_active xkb_state_led_index_is_active_dylibloader_orig_xkbcommon +#include "./thirdparty/linuxbsd_headers/xkbcommon/xkbcommon.h" +#undef xkb_keysym_get_name +#undef xkb_keysym_from_name +#undef xkb_keysym_to_utf8 +#undef xkb_keysym_to_utf32 +#undef xkb_utf32_to_keysym +#undef xkb_keysym_to_upper +#undef xkb_keysym_to_lower +#undef xkb_context_new +#undef xkb_context_ref +#undef xkb_context_unref +#undef xkb_context_set_user_data +#undef xkb_context_get_user_data +#undef xkb_context_include_path_append +#undef xkb_context_include_path_append_default +#undef xkb_context_include_path_reset_defaults +#undef xkb_context_include_path_clear +#undef xkb_context_num_include_paths +#undef xkb_context_include_path_get +#undef xkb_context_set_log_level +#undef xkb_context_get_log_level +#undef xkb_context_set_log_verbosity +#undef xkb_context_get_log_verbosity +#undef xkb_context_set_log_fn +#undef xkb_keymap_new_from_names +#undef xkb_keymap_new_from_file +#undef xkb_keymap_new_from_string +#undef xkb_keymap_new_from_buffer +#undef xkb_keymap_ref +#undef xkb_keymap_unref +#undef xkb_keymap_get_as_string +#undef xkb_keymap_min_keycode +#undef xkb_keymap_max_keycode +#undef xkb_keymap_key_for_each +#undef xkb_keymap_key_get_name +#undef xkb_keymap_key_by_name +#undef xkb_keymap_num_mods +#undef xkb_keymap_mod_get_name +#undef xkb_keymap_mod_get_index +#undef xkb_keymap_num_layouts +#undef xkb_keymap_layout_get_name +#undef xkb_keymap_layout_get_index +#undef xkb_keymap_num_leds +#undef xkb_keymap_led_get_name +#undef xkb_keymap_led_get_index +#undef xkb_keymap_num_layouts_for_key +#undef xkb_keymap_num_levels_for_key +#undef xkb_keymap_key_get_mods_for_level +#undef xkb_keymap_key_get_syms_by_level +#undef xkb_keymap_key_repeats +#undef xkb_state_new +#undef xkb_state_ref +#undef xkb_state_unref +#undef xkb_state_get_keymap +#undef xkb_state_update_key +#undef xkb_state_update_mask +#undef xkb_state_key_get_syms +#undef xkb_state_key_get_utf8 +#undef xkb_state_key_get_utf32 +#undef xkb_state_key_get_one_sym +#undef xkb_state_key_get_layout +#undef xkb_state_key_get_level +#undef xkb_state_serialize_mods +#undef xkb_state_serialize_layout +#undef xkb_state_mod_name_is_active +#undef xkb_state_mod_names_are_active +#undef xkb_state_mod_index_is_active +#undef xkb_state_mod_indices_are_active +#undef xkb_state_key_get_consumed_mods2 +#undef xkb_state_key_get_consumed_mods +#undef xkb_state_mod_index_is_consumed2 +#undef xkb_state_mod_index_is_consumed +#undef xkb_state_mod_mask_remove_consumed +#undef xkb_state_layout_name_is_active +#undef xkb_state_layout_index_is_active +#undef xkb_state_led_name_is_active +#undef xkb_state_led_index_is_active +#include <dlfcn.h> +#include <stdio.h> +int (*xkb_keysym_get_name_dylibloader_wrapper_xkbcommon)( xkb_keysym_t, char*, size_t); +xkb_keysym_t (*xkb_keysym_from_name_dylibloader_wrapper_xkbcommon)(const char*,enum xkb_keysym_flags); +int (*xkb_keysym_to_utf8_dylibloader_wrapper_xkbcommon)( xkb_keysym_t, char*, size_t); +uint32_t (*xkb_keysym_to_utf32_dylibloader_wrapper_xkbcommon)( xkb_keysym_t); +xkb_keysym_t (*xkb_utf32_to_keysym_dylibloader_wrapper_xkbcommon)( uint32_t); +xkb_keysym_t (*xkb_keysym_to_upper_dylibloader_wrapper_xkbcommon)( xkb_keysym_t); +xkb_keysym_t (*xkb_keysym_to_lower_dylibloader_wrapper_xkbcommon)( xkb_keysym_t); +struct xkb_context* (*xkb_context_new_dylibloader_wrapper_xkbcommon)(enum xkb_context_flags); +struct xkb_context* (*xkb_context_ref_dylibloader_wrapper_xkbcommon)(struct xkb_context*); +void (*xkb_context_unref_dylibloader_wrapper_xkbcommon)(struct xkb_context*); +void (*xkb_context_set_user_data_dylibloader_wrapper_xkbcommon)(struct xkb_context*, void*); +void* (*xkb_context_get_user_data_dylibloader_wrapper_xkbcommon)(struct xkb_context*); +int (*xkb_context_include_path_append_dylibloader_wrapper_xkbcommon)(struct xkb_context*,const char*); +int (*xkb_context_include_path_append_default_dylibloader_wrapper_xkbcommon)(struct xkb_context*); +int (*xkb_context_include_path_reset_defaults_dylibloader_wrapper_xkbcommon)(struct xkb_context*); +void (*xkb_context_include_path_clear_dylibloader_wrapper_xkbcommon)(struct xkb_context*); +unsigned int (*xkb_context_num_include_paths_dylibloader_wrapper_xkbcommon)(struct xkb_context*); +const char* (*xkb_context_include_path_get_dylibloader_wrapper_xkbcommon)(struct xkb_context*, unsigned int); +void (*xkb_context_set_log_level_dylibloader_wrapper_xkbcommon)(struct xkb_context*,enum xkb_log_level); +enum xkb_log_level (*xkb_context_get_log_level_dylibloader_wrapper_xkbcommon)(struct xkb_context*); +void (*xkb_context_set_log_verbosity_dylibloader_wrapper_xkbcommon)(struct xkb_context*, int); +int (*xkb_context_get_log_verbosity_dylibloader_wrapper_xkbcommon)(struct xkb_context*); +void (*xkb_context_set_log_fn_dylibloader_wrapper_xkbcommon)(struct xkb_context*, void*); +struct xkb_keymap* (*xkb_keymap_new_from_names_dylibloader_wrapper_xkbcommon)(struct xkb_context*,struct xkb_rule_names*,enum xkb_keymap_compile_flags); +struct xkb_keymap* (*xkb_keymap_new_from_file_dylibloader_wrapper_xkbcommon)(struct xkb_context*, FILE*,enum xkb_keymap_format,enum xkb_keymap_compile_flags); +struct xkb_keymap* (*xkb_keymap_new_from_string_dylibloader_wrapper_xkbcommon)(struct xkb_context*,const char*,enum xkb_keymap_format,enum xkb_keymap_compile_flags); +struct xkb_keymap* (*xkb_keymap_new_from_buffer_dylibloader_wrapper_xkbcommon)(struct xkb_context*,const char*, size_t,enum xkb_keymap_format,enum xkb_keymap_compile_flags); +struct xkb_keymap* (*xkb_keymap_ref_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*); +void (*xkb_keymap_unref_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*); +char* (*xkb_keymap_get_as_string_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*,enum xkb_keymap_format); +xkb_keycode_t (*xkb_keymap_min_keycode_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*); +xkb_keycode_t (*xkb_keymap_max_keycode_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*); +void (*xkb_keymap_key_for_each_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_keymap_key_iter_t, void*); +const char* (*xkb_keymap_key_get_name_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_keycode_t); +xkb_keycode_t (*xkb_keymap_key_by_name_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*,const char*); +xkb_mod_index_t (*xkb_keymap_num_mods_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*); +const char* (*xkb_keymap_mod_get_name_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_mod_index_t); +xkb_mod_index_t (*xkb_keymap_mod_get_index_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*,const char*); +xkb_layout_index_t (*xkb_keymap_num_layouts_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*); +const char* (*xkb_keymap_layout_get_name_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_layout_index_t); +xkb_layout_index_t (*xkb_keymap_layout_get_index_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*,const char*); +xkb_led_index_t (*xkb_keymap_num_leds_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*); +const char* (*xkb_keymap_led_get_name_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_led_index_t); +xkb_led_index_t (*xkb_keymap_led_get_index_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*,const char*); +xkb_layout_index_t (*xkb_keymap_num_layouts_for_key_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_keycode_t); +xkb_level_index_t (*xkb_keymap_num_levels_for_key_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_keycode_t, xkb_layout_index_t); +size_t (*xkb_keymap_key_get_mods_for_level_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_keycode_t, xkb_layout_index_t, xkb_level_index_t, xkb_mod_mask_t*, size_t); +int (*xkb_keymap_key_get_syms_by_level_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_keycode_t, xkb_layout_index_t, xkb_level_index_t,const xkb_keysym_t**); +int (*xkb_keymap_key_repeats_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_keycode_t); +struct xkb_state* (*xkb_state_new_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*); +struct xkb_state* (*xkb_state_ref_dylibloader_wrapper_xkbcommon)(struct xkb_state*); +void (*xkb_state_unref_dylibloader_wrapper_xkbcommon)(struct xkb_state*); +struct xkb_keymap* (*xkb_state_get_keymap_dylibloader_wrapper_xkbcommon)(struct xkb_state*); +enum xkb_state_component (*xkb_state_update_key_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t,enum xkb_key_direction); +enum xkb_state_component (*xkb_state_update_mask_dylibloader_wrapper_xkbcommon)(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); +int (*xkb_state_key_get_syms_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t,const xkb_keysym_t**); +int (*xkb_state_key_get_utf8_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t, char*, size_t); +uint32_t (*xkb_state_key_get_utf32_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t); +xkb_keysym_t (*xkb_state_key_get_one_sym_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t); +xkb_layout_index_t (*xkb_state_key_get_layout_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t); +xkb_level_index_t (*xkb_state_key_get_level_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t, xkb_layout_index_t); +xkb_mod_mask_t (*xkb_state_serialize_mods_dylibloader_wrapper_xkbcommon)(struct xkb_state*,enum xkb_state_component); +xkb_layout_index_t (*xkb_state_serialize_layout_dylibloader_wrapper_xkbcommon)(struct xkb_state*,enum xkb_state_component); +int (*xkb_state_mod_name_is_active_dylibloader_wrapper_xkbcommon)(struct xkb_state*,const char*,enum xkb_state_component); +int (*xkb_state_mod_names_are_active_dylibloader_wrapper_xkbcommon)(struct xkb_state*,enum xkb_state_component,enum xkb_state_match,...); +int (*xkb_state_mod_index_is_active_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_mod_index_t,enum xkb_state_component); +int (*xkb_state_mod_indices_are_active_dylibloader_wrapper_xkbcommon)(struct xkb_state*,enum xkb_state_component,enum xkb_state_match,...); +xkb_mod_mask_t (*xkb_state_key_get_consumed_mods2_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t,enum xkb_consumed_mode); +xkb_mod_mask_t (*xkb_state_key_get_consumed_mods_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t); +int (*xkb_state_mod_index_is_consumed2_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t, xkb_mod_index_t,enum xkb_consumed_mode); +int (*xkb_state_mod_index_is_consumed_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t, xkb_mod_index_t); +xkb_mod_mask_t (*xkb_state_mod_mask_remove_consumed_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t, xkb_mod_mask_t); +int (*xkb_state_layout_name_is_active_dylibloader_wrapper_xkbcommon)(struct xkb_state*,const char*,enum xkb_state_component); +int (*xkb_state_layout_index_is_active_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_layout_index_t,enum xkb_state_component); +int (*xkb_state_led_name_is_active_dylibloader_wrapper_xkbcommon)(struct xkb_state*,const char*); +int (*xkb_state_led_index_is_active_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_led_index_t); +int initialize_xkbcommon(int verbose) { + void *handle; + char *error; + handle = dlopen("libxkbcommon.so.0", RTLD_LAZY); + if (!handle) { + if (verbose) { + fprintf(stderr, "%s\n", dlerror()); + } + return(1); + } + dlerror(); +// xkb_keysym_get_name + *(void **) (&xkb_keysym_get_name_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keysym_get_name"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keysym_from_name + *(void **) (&xkb_keysym_from_name_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keysym_from_name"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keysym_to_utf8 + *(void **) (&xkb_keysym_to_utf8_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keysym_to_utf8"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keysym_to_utf32 + *(void **) (&xkb_keysym_to_utf32_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keysym_to_utf32"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_utf32_to_keysym + *(void **) (&xkb_utf32_to_keysym_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_utf32_to_keysym"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keysym_to_upper + *(void **) (&xkb_keysym_to_upper_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keysym_to_upper"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keysym_to_lower + *(void **) (&xkb_keysym_to_lower_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keysym_to_lower"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_context_new + *(void **) (&xkb_context_new_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_context_new"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_context_ref + *(void **) (&xkb_context_ref_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_context_ref"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_context_unref + *(void **) (&xkb_context_unref_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_context_unref"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_context_set_user_data + *(void **) (&xkb_context_set_user_data_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_context_set_user_data"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_context_get_user_data + *(void **) (&xkb_context_get_user_data_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_context_get_user_data"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_context_include_path_append + *(void **) (&xkb_context_include_path_append_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_context_include_path_append"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_context_include_path_append_default + *(void **) (&xkb_context_include_path_append_default_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_context_include_path_append_default"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_context_include_path_reset_defaults + *(void **) (&xkb_context_include_path_reset_defaults_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_context_include_path_reset_defaults"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_context_include_path_clear + *(void **) (&xkb_context_include_path_clear_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_context_include_path_clear"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_context_num_include_paths + *(void **) (&xkb_context_num_include_paths_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_context_num_include_paths"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_context_include_path_get + *(void **) (&xkb_context_include_path_get_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_context_include_path_get"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_context_set_log_level + *(void **) (&xkb_context_set_log_level_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_context_set_log_level"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_context_get_log_level + *(void **) (&xkb_context_get_log_level_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_context_get_log_level"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_context_set_log_verbosity + *(void **) (&xkb_context_set_log_verbosity_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_context_set_log_verbosity"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_context_get_log_verbosity + *(void **) (&xkb_context_get_log_verbosity_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_context_get_log_verbosity"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_context_set_log_fn + *(void **) (&xkb_context_set_log_fn_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_context_set_log_fn"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_new_from_names + *(void **) (&xkb_keymap_new_from_names_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_new_from_names"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_new_from_file + *(void **) (&xkb_keymap_new_from_file_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_new_from_file"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_new_from_string + *(void **) (&xkb_keymap_new_from_string_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_new_from_string"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_new_from_buffer + *(void **) (&xkb_keymap_new_from_buffer_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_new_from_buffer"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_ref + *(void **) (&xkb_keymap_ref_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_ref"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_unref + *(void **) (&xkb_keymap_unref_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_unref"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_get_as_string + *(void **) (&xkb_keymap_get_as_string_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_get_as_string"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_min_keycode + *(void **) (&xkb_keymap_min_keycode_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_min_keycode"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_max_keycode + *(void **) (&xkb_keymap_max_keycode_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_max_keycode"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_key_for_each + *(void **) (&xkb_keymap_key_for_each_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_key_for_each"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_key_get_name + *(void **) (&xkb_keymap_key_get_name_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_key_get_name"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_key_by_name + *(void **) (&xkb_keymap_key_by_name_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_key_by_name"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_num_mods + *(void **) (&xkb_keymap_num_mods_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_num_mods"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_mod_get_name + *(void **) (&xkb_keymap_mod_get_name_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_mod_get_name"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_mod_get_index + *(void **) (&xkb_keymap_mod_get_index_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_mod_get_index"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_num_layouts + *(void **) (&xkb_keymap_num_layouts_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_num_layouts"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_layout_get_name + *(void **) (&xkb_keymap_layout_get_name_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_layout_get_name"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_layout_get_index + *(void **) (&xkb_keymap_layout_get_index_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_layout_get_index"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_num_leds + *(void **) (&xkb_keymap_num_leds_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_num_leds"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_led_get_name + *(void **) (&xkb_keymap_led_get_name_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_led_get_name"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_led_get_index + *(void **) (&xkb_keymap_led_get_index_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_led_get_index"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_num_layouts_for_key + *(void **) (&xkb_keymap_num_layouts_for_key_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_num_layouts_for_key"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_num_levels_for_key + *(void **) (&xkb_keymap_num_levels_for_key_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_num_levels_for_key"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_key_get_mods_for_level + *(void **) (&xkb_keymap_key_get_mods_for_level_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_key_get_mods_for_level"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_key_get_syms_by_level + *(void **) (&xkb_keymap_key_get_syms_by_level_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_key_get_syms_by_level"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_keymap_key_repeats + *(void **) (&xkb_keymap_key_repeats_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_keymap_key_repeats"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_new + *(void **) (&xkb_state_new_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_new"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_ref + *(void **) (&xkb_state_ref_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_ref"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_unref + *(void **) (&xkb_state_unref_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_unref"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_get_keymap + *(void **) (&xkb_state_get_keymap_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_get_keymap"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_update_key + *(void **) (&xkb_state_update_key_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_update_key"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_update_mask + *(void **) (&xkb_state_update_mask_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_update_mask"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_key_get_syms + *(void **) (&xkb_state_key_get_syms_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_key_get_syms"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_key_get_utf8 + *(void **) (&xkb_state_key_get_utf8_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_key_get_utf8"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_key_get_utf32 + *(void **) (&xkb_state_key_get_utf32_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_key_get_utf32"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_key_get_one_sym + *(void **) (&xkb_state_key_get_one_sym_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_key_get_one_sym"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_key_get_layout + *(void **) (&xkb_state_key_get_layout_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_key_get_layout"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_key_get_level + *(void **) (&xkb_state_key_get_level_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_key_get_level"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_serialize_mods + *(void **) (&xkb_state_serialize_mods_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_serialize_mods"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_serialize_layout + *(void **) (&xkb_state_serialize_layout_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_serialize_layout"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_mod_name_is_active + *(void **) (&xkb_state_mod_name_is_active_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_mod_name_is_active"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_mod_names_are_active + *(void **) (&xkb_state_mod_names_are_active_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_mod_names_are_active"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_mod_index_is_active + *(void **) (&xkb_state_mod_index_is_active_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_mod_index_is_active"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_mod_indices_are_active + *(void **) (&xkb_state_mod_indices_are_active_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_mod_indices_are_active"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_key_get_consumed_mods2 + *(void **) (&xkb_state_key_get_consumed_mods2_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_key_get_consumed_mods2"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_key_get_consumed_mods + *(void **) (&xkb_state_key_get_consumed_mods_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_key_get_consumed_mods"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_mod_index_is_consumed2 + *(void **) (&xkb_state_mod_index_is_consumed2_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_mod_index_is_consumed2"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_mod_index_is_consumed + *(void **) (&xkb_state_mod_index_is_consumed_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_mod_index_is_consumed"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_mod_mask_remove_consumed + *(void **) (&xkb_state_mod_mask_remove_consumed_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_mod_mask_remove_consumed"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_layout_name_is_active + *(void **) (&xkb_state_layout_name_is_active_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_layout_name_is_active"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_layout_index_is_active + *(void **) (&xkb_state_layout_index_is_active_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_layout_index_is_active"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_led_name_is_active + *(void **) (&xkb_state_led_name_is_active_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_led_name_is_active"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +// xkb_state_led_index_is_active + *(void **) (&xkb_state_led_index_is_active_dylibloader_wrapper_xkbcommon) = dlsym(handle, "xkb_state_led_index_is_active"); + if (verbose) { + error = dlerror(); + if (error != NULL) { + fprintf(stderr, "%s\n", error); + } + } +return 0; +} diff --git a/platform/linuxbsd/xkbcommon-so_wrap.h b/platform/linuxbsd/xkbcommon-so_wrap.h new file mode 100644 index 0000000000..f7e6f4c4cf --- /dev/null +++ b/platform/linuxbsd/xkbcommon-so_wrap.h @@ -0,0 +1,322 @@ +#ifndef DYLIBLOAD_WRAPPER_XKBCOMMON +#define DYLIBLOAD_WRAPPER_XKBCOMMON +// This file is generated. Do not edit! +// see https://github.com/hpvb/dynload-wrapper for details +// generated by ../dynload-wrapper/generate-wrapper.py 0.3 on 2023-01-23 15:14:21 +// flags: ../dynload-wrapper/generate-wrapper.py --include ./thirdparty/linuxbsd_headers/xkbcommon/xkbcommon.h --sys-include "./thirdparty/linuxbsd_headers/xkbcommon/xkbcommon.h" --soname libxkbcommon.so.0 --init-name xkbcommon --output-header ./platform/linuxbsd/x11/dynwrappers/xkbcommon-so_wrap.h --output-implementation ./platform/linuxbsd/x11/dynwrappers/xkbcommon-so_wrap.c +// +#include <stdint.h> + +#define xkb_keysym_get_name xkb_keysym_get_name_dylibloader_orig_xkbcommon +#define xkb_keysym_from_name xkb_keysym_from_name_dylibloader_orig_xkbcommon +#define xkb_keysym_to_utf8 xkb_keysym_to_utf8_dylibloader_orig_xkbcommon +#define xkb_keysym_to_utf32 xkb_keysym_to_utf32_dylibloader_orig_xkbcommon +#define xkb_utf32_to_keysym xkb_utf32_to_keysym_dylibloader_orig_xkbcommon +#define xkb_keysym_to_upper xkb_keysym_to_upper_dylibloader_orig_xkbcommon +#define xkb_keysym_to_lower xkb_keysym_to_lower_dylibloader_orig_xkbcommon +#define xkb_context_new xkb_context_new_dylibloader_orig_xkbcommon +#define xkb_context_ref xkb_context_ref_dylibloader_orig_xkbcommon +#define xkb_context_unref xkb_context_unref_dylibloader_orig_xkbcommon +#define xkb_context_set_user_data xkb_context_set_user_data_dylibloader_orig_xkbcommon +#define xkb_context_get_user_data xkb_context_get_user_data_dylibloader_orig_xkbcommon +#define xkb_context_include_path_append xkb_context_include_path_append_dylibloader_orig_xkbcommon +#define xkb_context_include_path_append_default xkb_context_include_path_append_default_dylibloader_orig_xkbcommon +#define xkb_context_include_path_reset_defaults xkb_context_include_path_reset_defaults_dylibloader_orig_xkbcommon +#define xkb_context_include_path_clear xkb_context_include_path_clear_dylibloader_orig_xkbcommon +#define xkb_context_num_include_paths xkb_context_num_include_paths_dylibloader_orig_xkbcommon +#define xkb_context_include_path_get xkb_context_include_path_get_dylibloader_orig_xkbcommon +#define xkb_context_set_log_level xkb_context_set_log_level_dylibloader_orig_xkbcommon +#define xkb_context_get_log_level xkb_context_get_log_level_dylibloader_orig_xkbcommon +#define xkb_context_set_log_verbosity xkb_context_set_log_verbosity_dylibloader_orig_xkbcommon +#define xkb_context_get_log_verbosity xkb_context_get_log_verbosity_dylibloader_orig_xkbcommon +#define xkb_context_set_log_fn xkb_context_set_log_fn_dylibloader_orig_xkbcommon +#define xkb_keymap_new_from_names xkb_keymap_new_from_names_dylibloader_orig_xkbcommon +#define xkb_keymap_new_from_file xkb_keymap_new_from_file_dylibloader_orig_xkbcommon +#define xkb_keymap_new_from_string xkb_keymap_new_from_string_dylibloader_orig_xkbcommon +#define xkb_keymap_new_from_buffer xkb_keymap_new_from_buffer_dylibloader_orig_xkbcommon +#define xkb_keymap_ref xkb_keymap_ref_dylibloader_orig_xkbcommon +#define xkb_keymap_unref xkb_keymap_unref_dylibloader_orig_xkbcommon +#define xkb_keymap_get_as_string xkb_keymap_get_as_string_dylibloader_orig_xkbcommon +#define xkb_keymap_min_keycode xkb_keymap_min_keycode_dylibloader_orig_xkbcommon +#define xkb_keymap_max_keycode xkb_keymap_max_keycode_dylibloader_orig_xkbcommon +#define xkb_keymap_key_for_each xkb_keymap_key_for_each_dylibloader_orig_xkbcommon +#define xkb_keymap_key_get_name xkb_keymap_key_get_name_dylibloader_orig_xkbcommon +#define xkb_keymap_key_by_name xkb_keymap_key_by_name_dylibloader_orig_xkbcommon +#define xkb_keymap_num_mods xkb_keymap_num_mods_dylibloader_orig_xkbcommon +#define xkb_keymap_mod_get_name xkb_keymap_mod_get_name_dylibloader_orig_xkbcommon +#define xkb_keymap_mod_get_index xkb_keymap_mod_get_index_dylibloader_orig_xkbcommon +#define xkb_keymap_num_layouts xkb_keymap_num_layouts_dylibloader_orig_xkbcommon +#define xkb_keymap_layout_get_name xkb_keymap_layout_get_name_dylibloader_orig_xkbcommon +#define xkb_keymap_layout_get_index xkb_keymap_layout_get_index_dylibloader_orig_xkbcommon +#define xkb_keymap_num_leds xkb_keymap_num_leds_dylibloader_orig_xkbcommon +#define xkb_keymap_led_get_name xkb_keymap_led_get_name_dylibloader_orig_xkbcommon +#define xkb_keymap_led_get_index xkb_keymap_led_get_index_dylibloader_orig_xkbcommon +#define xkb_keymap_num_layouts_for_key xkb_keymap_num_layouts_for_key_dylibloader_orig_xkbcommon +#define xkb_keymap_num_levels_for_key xkb_keymap_num_levels_for_key_dylibloader_orig_xkbcommon +#define xkb_keymap_key_get_mods_for_level xkb_keymap_key_get_mods_for_level_dylibloader_orig_xkbcommon +#define xkb_keymap_key_get_syms_by_level xkb_keymap_key_get_syms_by_level_dylibloader_orig_xkbcommon +#define xkb_keymap_key_repeats xkb_keymap_key_repeats_dylibloader_orig_xkbcommon +#define xkb_state_new xkb_state_new_dylibloader_orig_xkbcommon +#define xkb_state_ref xkb_state_ref_dylibloader_orig_xkbcommon +#define xkb_state_unref xkb_state_unref_dylibloader_orig_xkbcommon +#define xkb_state_get_keymap xkb_state_get_keymap_dylibloader_orig_xkbcommon +#define xkb_state_update_key xkb_state_update_key_dylibloader_orig_xkbcommon +#define xkb_state_update_mask xkb_state_update_mask_dylibloader_orig_xkbcommon +#define xkb_state_key_get_syms xkb_state_key_get_syms_dylibloader_orig_xkbcommon +#define xkb_state_key_get_utf8 xkb_state_key_get_utf8_dylibloader_orig_xkbcommon +#define xkb_state_key_get_utf32 xkb_state_key_get_utf32_dylibloader_orig_xkbcommon +#define xkb_state_key_get_one_sym xkb_state_key_get_one_sym_dylibloader_orig_xkbcommon +#define xkb_state_key_get_layout xkb_state_key_get_layout_dylibloader_orig_xkbcommon +#define xkb_state_key_get_level xkb_state_key_get_level_dylibloader_orig_xkbcommon +#define xkb_state_serialize_mods xkb_state_serialize_mods_dylibloader_orig_xkbcommon +#define xkb_state_serialize_layout xkb_state_serialize_layout_dylibloader_orig_xkbcommon +#define xkb_state_mod_name_is_active xkb_state_mod_name_is_active_dylibloader_orig_xkbcommon +#define xkb_state_mod_names_are_active xkb_state_mod_names_are_active_dylibloader_orig_xkbcommon +#define xkb_state_mod_index_is_active xkb_state_mod_index_is_active_dylibloader_orig_xkbcommon +#define xkb_state_mod_indices_are_active xkb_state_mod_indices_are_active_dylibloader_orig_xkbcommon +#define xkb_state_key_get_consumed_mods2 xkb_state_key_get_consumed_mods2_dylibloader_orig_xkbcommon +#define xkb_state_key_get_consumed_mods xkb_state_key_get_consumed_mods_dylibloader_orig_xkbcommon +#define xkb_state_mod_index_is_consumed2 xkb_state_mod_index_is_consumed2_dylibloader_orig_xkbcommon +#define xkb_state_mod_index_is_consumed xkb_state_mod_index_is_consumed_dylibloader_orig_xkbcommon +#define xkb_state_mod_mask_remove_consumed xkb_state_mod_mask_remove_consumed_dylibloader_orig_xkbcommon +#define xkb_state_layout_name_is_active xkb_state_layout_name_is_active_dylibloader_orig_xkbcommon +#define xkb_state_layout_index_is_active xkb_state_layout_index_is_active_dylibloader_orig_xkbcommon +#define xkb_state_led_name_is_active xkb_state_led_name_is_active_dylibloader_orig_xkbcommon +#define xkb_state_led_index_is_active xkb_state_led_index_is_active_dylibloader_orig_xkbcommon +#include "./thirdparty/linuxbsd_headers/xkbcommon/xkbcommon.h" +#undef xkb_keysym_get_name +#undef xkb_keysym_from_name +#undef xkb_keysym_to_utf8 +#undef xkb_keysym_to_utf32 +#undef xkb_utf32_to_keysym +#undef xkb_keysym_to_upper +#undef xkb_keysym_to_lower +#undef xkb_context_new +#undef xkb_context_ref +#undef xkb_context_unref +#undef xkb_context_set_user_data +#undef xkb_context_get_user_data +#undef xkb_context_include_path_append +#undef xkb_context_include_path_append_default +#undef xkb_context_include_path_reset_defaults +#undef xkb_context_include_path_clear +#undef xkb_context_num_include_paths +#undef xkb_context_include_path_get +#undef xkb_context_set_log_level +#undef xkb_context_get_log_level +#undef xkb_context_set_log_verbosity +#undef xkb_context_get_log_verbosity +#undef xkb_context_set_log_fn +#undef xkb_keymap_new_from_names +#undef xkb_keymap_new_from_file +#undef xkb_keymap_new_from_string +#undef xkb_keymap_new_from_buffer +#undef xkb_keymap_ref +#undef xkb_keymap_unref +#undef xkb_keymap_get_as_string +#undef xkb_keymap_min_keycode +#undef xkb_keymap_max_keycode +#undef xkb_keymap_key_for_each +#undef xkb_keymap_key_get_name +#undef xkb_keymap_key_by_name +#undef xkb_keymap_num_mods +#undef xkb_keymap_mod_get_name +#undef xkb_keymap_mod_get_index +#undef xkb_keymap_num_layouts +#undef xkb_keymap_layout_get_name +#undef xkb_keymap_layout_get_index +#undef xkb_keymap_num_leds +#undef xkb_keymap_led_get_name +#undef xkb_keymap_led_get_index +#undef xkb_keymap_num_layouts_for_key +#undef xkb_keymap_num_levels_for_key +#undef xkb_keymap_key_get_mods_for_level +#undef xkb_keymap_key_get_syms_by_level +#undef xkb_keymap_key_repeats +#undef xkb_state_new +#undef xkb_state_ref +#undef xkb_state_unref +#undef xkb_state_get_keymap +#undef xkb_state_update_key +#undef xkb_state_update_mask +#undef xkb_state_key_get_syms +#undef xkb_state_key_get_utf8 +#undef xkb_state_key_get_utf32 +#undef xkb_state_key_get_one_sym +#undef xkb_state_key_get_layout +#undef xkb_state_key_get_level +#undef xkb_state_serialize_mods +#undef xkb_state_serialize_layout +#undef xkb_state_mod_name_is_active +#undef xkb_state_mod_names_are_active +#undef xkb_state_mod_index_is_active +#undef xkb_state_mod_indices_are_active +#undef xkb_state_key_get_consumed_mods2 +#undef xkb_state_key_get_consumed_mods +#undef xkb_state_mod_index_is_consumed2 +#undef xkb_state_mod_index_is_consumed +#undef xkb_state_mod_mask_remove_consumed +#undef xkb_state_layout_name_is_active +#undef xkb_state_layout_index_is_active +#undef xkb_state_led_name_is_active +#undef xkb_state_led_index_is_active +#ifdef __cplusplus +extern "C" { +#endif +#define xkb_keysym_get_name xkb_keysym_get_name_dylibloader_wrapper_xkbcommon +#define xkb_keysym_from_name xkb_keysym_from_name_dylibloader_wrapper_xkbcommon +#define xkb_keysym_to_utf8 xkb_keysym_to_utf8_dylibloader_wrapper_xkbcommon +#define xkb_keysym_to_utf32 xkb_keysym_to_utf32_dylibloader_wrapper_xkbcommon +#define xkb_utf32_to_keysym xkb_utf32_to_keysym_dylibloader_wrapper_xkbcommon +#define xkb_keysym_to_upper xkb_keysym_to_upper_dylibloader_wrapper_xkbcommon +#define xkb_keysym_to_lower xkb_keysym_to_lower_dylibloader_wrapper_xkbcommon +#define xkb_context_new xkb_context_new_dylibloader_wrapper_xkbcommon +#define xkb_context_ref xkb_context_ref_dylibloader_wrapper_xkbcommon +#define xkb_context_unref xkb_context_unref_dylibloader_wrapper_xkbcommon +#define xkb_context_set_user_data xkb_context_set_user_data_dylibloader_wrapper_xkbcommon +#define xkb_context_get_user_data xkb_context_get_user_data_dylibloader_wrapper_xkbcommon +#define xkb_context_include_path_append xkb_context_include_path_append_dylibloader_wrapper_xkbcommon +#define xkb_context_include_path_append_default xkb_context_include_path_append_default_dylibloader_wrapper_xkbcommon +#define xkb_context_include_path_reset_defaults xkb_context_include_path_reset_defaults_dylibloader_wrapper_xkbcommon +#define xkb_context_include_path_clear xkb_context_include_path_clear_dylibloader_wrapper_xkbcommon +#define xkb_context_num_include_paths xkb_context_num_include_paths_dylibloader_wrapper_xkbcommon +#define xkb_context_include_path_get xkb_context_include_path_get_dylibloader_wrapper_xkbcommon +#define xkb_context_set_log_level xkb_context_set_log_level_dylibloader_wrapper_xkbcommon +#define xkb_context_get_log_level xkb_context_get_log_level_dylibloader_wrapper_xkbcommon +#define xkb_context_set_log_verbosity xkb_context_set_log_verbosity_dylibloader_wrapper_xkbcommon +#define xkb_context_get_log_verbosity xkb_context_get_log_verbosity_dylibloader_wrapper_xkbcommon +#define xkb_context_set_log_fn xkb_context_set_log_fn_dylibloader_wrapper_xkbcommon +#define xkb_keymap_new_from_names xkb_keymap_new_from_names_dylibloader_wrapper_xkbcommon +#define xkb_keymap_new_from_file xkb_keymap_new_from_file_dylibloader_wrapper_xkbcommon +#define xkb_keymap_new_from_string xkb_keymap_new_from_string_dylibloader_wrapper_xkbcommon +#define xkb_keymap_new_from_buffer xkb_keymap_new_from_buffer_dylibloader_wrapper_xkbcommon +#define xkb_keymap_ref xkb_keymap_ref_dylibloader_wrapper_xkbcommon +#define xkb_keymap_unref xkb_keymap_unref_dylibloader_wrapper_xkbcommon +#define xkb_keymap_get_as_string xkb_keymap_get_as_string_dylibloader_wrapper_xkbcommon +#define xkb_keymap_min_keycode xkb_keymap_min_keycode_dylibloader_wrapper_xkbcommon +#define xkb_keymap_max_keycode xkb_keymap_max_keycode_dylibloader_wrapper_xkbcommon +#define xkb_keymap_key_for_each xkb_keymap_key_for_each_dylibloader_wrapper_xkbcommon +#define xkb_keymap_key_get_name xkb_keymap_key_get_name_dylibloader_wrapper_xkbcommon +#define xkb_keymap_key_by_name xkb_keymap_key_by_name_dylibloader_wrapper_xkbcommon +#define xkb_keymap_num_mods xkb_keymap_num_mods_dylibloader_wrapper_xkbcommon +#define xkb_keymap_mod_get_name xkb_keymap_mod_get_name_dylibloader_wrapper_xkbcommon +#define xkb_keymap_mod_get_index xkb_keymap_mod_get_index_dylibloader_wrapper_xkbcommon +#define xkb_keymap_num_layouts xkb_keymap_num_layouts_dylibloader_wrapper_xkbcommon +#define xkb_keymap_layout_get_name xkb_keymap_layout_get_name_dylibloader_wrapper_xkbcommon +#define xkb_keymap_layout_get_index xkb_keymap_layout_get_index_dylibloader_wrapper_xkbcommon +#define xkb_keymap_num_leds xkb_keymap_num_leds_dylibloader_wrapper_xkbcommon +#define xkb_keymap_led_get_name xkb_keymap_led_get_name_dylibloader_wrapper_xkbcommon +#define xkb_keymap_led_get_index xkb_keymap_led_get_index_dylibloader_wrapper_xkbcommon +#define xkb_keymap_num_layouts_for_key xkb_keymap_num_layouts_for_key_dylibloader_wrapper_xkbcommon +#define xkb_keymap_num_levels_for_key xkb_keymap_num_levels_for_key_dylibloader_wrapper_xkbcommon +#define xkb_keymap_key_get_mods_for_level xkb_keymap_key_get_mods_for_level_dylibloader_wrapper_xkbcommon +#define xkb_keymap_key_get_syms_by_level xkb_keymap_key_get_syms_by_level_dylibloader_wrapper_xkbcommon +#define xkb_keymap_key_repeats xkb_keymap_key_repeats_dylibloader_wrapper_xkbcommon +#define xkb_state_new xkb_state_new_dylibloader_wrapper_xkbcommon +#define xkb_state_ref xkb_state_ref_dylibloader_wrapper_xkbcommon +#define xkb_state_unref xkb_state_unref_dylibloader_wrapper_xkbcommon +#define xkb_state_get_keymap xkb_state_get_keymap_dylibloader_wrapper_xkbcommon +#define xkb_state_update_key xkb_state_update_key_dylibloader_wrapper_xkbcommon +#define xkb_state_update_mask xkb_state_update_mask_dylibloader_wrapper_xkbcommon +#define xkb_state_key_get_syms xkb_state_key_get_syms_dylibloader_wrapper_xkbcommon +#define xkb_state_key_get_utf8 xkb_state_key_get_utf8_dylibloader_wrapper_xkbcommon +#define xkb_state_key_get_utf32 xkb_state_key_get_utf32_dylibloader_wrapper_xkbcommon +#define xkb_state_key_get_one_sym xkb_state_key_get_one_sym_dylibloader_wrapper_xkbcommon +#define xkb_state_key_get_layout xkb_state_key_get_layout_dylibloader_wrapper_xkbcommon +#define xkb_state_key_get_level xkb_state_key_get_level_dylibloader_wrapper_xkbcommon +#define xkb_state_serialize_mods xkb_state_serialize_mods_dylibloader_wrapper_xkbcommon +#define xkb_state_serialize_layout xkb_state_serialize_layout_dylibloader_wrapper_xkbcommon +#define xkb_state_mod_name_is_active xkb_state_mod_name_is_active_dylibloader_wrapper_xkbcommon +#define xkb_state_mod_names_are_active xkb_state_mod_names_are_active_dylibloader_wrapper_xkbcommon +#define xkb_state_mod_index_is_active xkb_state_mod_index_is_active_dylibloader_wrapper_xkbcommon +#define xkb_state_mod_indices_are_active xkb_state_mod_indices_are_active_dylibloader_wrapper_xkbcommon +#define xkb_state_key_get_consumed_mods2 xkb_state_key_get_consumed_mods2_dylibloader_wrapper_xkbcommon +#define xkb_state_key_get_consumed_mods xkb_state_key_get_consumed_mods_dylibloader_wrapper_xkbcommon +#define xkb_state_mod_index_is_consumed2 xkb_state_mod_index_is_consumed2_dylibloader_wrapper_xkbcommon +#define xkb_state_mod_index_is_consumed xkb_state_mod_index_is_consumed_dylibloader_wrapper_xkbcommon +#define xkb_state_mod_mask_remove_consumed xkb_state_mod_mask_remove_consumed_dylibloader_wrapper_xkbcommon +#define xkb_state_layout_name_is_active xkb_state_layout_name_is_active_dylibloader_wrapper_xkbcommon +#define xkb_state_layout_index_is_active xkb_state_layout_index_is_active_dylibloader_wrapper_xkbcommon +#define xkb_state_led_name_is_active xkb_state_led_name_is_active_dylibloader_wrapper_xkbcommon +#define xkb_state_led_index_is_active xkb_state_led_index_is_active_dylibloader_wrapper_xkbcommon +extern int (*xkb_keysym_get_name_dylibloader_wrapper_xkbcommon)( xkb_keysym_t, char*, size_t); +extern xkb_keysym_t (*xkb_keysym_from_name_dylibloader_wrapper_xkbcommon)(const char*,enum xkb_keysym_flags); +extern int (*xkb_keysym_to_utf8_dylibloader_wrapper_xkbcommon)( xkb_keysym_t, char*, size_t); +extern uint32_t (*xkb_keysym_to_utf32_dylibloader_wrapper_xkbcommon)( xkb_keysym_t); +extern xkb_keysym_t (*xkb_utf32_to_keysym_dylibloader_wrapper_xkbcommon)( uint32_t); +extern xkb_keysym_t (*xkb_keysym_to_upper_dylibloader_wrapper_xkbcommon)( xkb_keysym_t); +extern xkb_keysym_t (*xkb_keysym_to_lower_dylibloader_wrapper_xkbcommon)( xkb_keysym_t); +extern struct xkb_context* (*xkb_context_new_dylibloader_wrapper_xkbcommon)(enum xkb_context_flags); +extern struct xkb_context* (*xkb_context_ref_dylibloader_wrapper_xkbcommon)(struct xkb_context*); +extern void (*xkb_context_unref_dylibloader_wrapper_xkbcommon)(struct xkb_context*); +extern void (*xkb_context_set_user_data_dylibloader_wrapper_xkbcommon)(struct xkb_context*, void*); +extern void* (*xkb_context_get_user_data_dylibloader_wrapper_xkbcommon)(struct xkb_context*); +extern int (*xkb_context_include_path_append_dylibloader_wrapper_xkbcommon)(struct xkb_context*,const char*); +extern int (*xkb_context_include_path_append_default_dylibloader_wrapper_xkbcommon)(struct xkb_context*); +extern int (*xkb_context_include_path_reset_defaults_dylibloader_wrapper_xkbcommon)(struct xkb_context*); +extern void (*xkb_context_include_path_clear_dylibloader_wrapper_xkbcommon)(struct xkb_context*); +extern unsigned int (*xkb_context_num_include_paths_dylibloader_wrapper_xkbcommon)(struct xkb_context*); +extern const char* (*xkb_context_include_path_get_dylibloader_wrapper_xkbcommon)(struct xkb_context*, unsigned int); +extern void (*xkb_context_set_log_level_dylibloader_wrapper_xkbcommon)(struct xkb_context*,enum xkb_log_level); +extern enum xkb_log_level (*xkb_context_get_log_level_dylibloader_wrapper_xkbcommon)(struct xkb_context*); +extern void (*xkb_context_set_log_verbosity_dylibloader_wrapper_xkbcommon)(struct xkb_context*, int); +extern int (*xkb_context_get_log_verbosity_dylibloader_wrapper_xkbcommon)(struct xkb_context*); +extern void (*xkb_context_set_log_fn_dylibloader_wrapper_xkbcommon)(struct xkb_context*, void*); +extern struct xkb_keymap* (*xkb_keymap_new_from_names_dylibloader_wrapper_xkbcommon)(struct xkb_context*,struct xkb_rule_names*,enum xkb_keymap_compile_flags); +extern struct xkb_keymap* (*xkb_keymap_new_from_file_dylibloader_wrapper_xkbcommon)(struct xkb_context*, FILE*,enum xkb_keymap_format,enum xkb_keymap_compile_flags); +extern struct xkb_keymap* (*xkb_keymap_new_from_string_dylibloader_wrapper_xkbcommon)(struct xkb_context*,const char*,enum xkb_keymap_format,enum xkb_keymap_compile_flags); +extern struct xkb_keymap* (*xkb_keymap_new_from_buffer_dylibloader_wrapper_xkbcommon)(struct xkb_context*,const char*, size_t,enum xkb_keymap_format,enum xkb_keymap_compile_flags); +extern struct xkb_keymap* (*xkb_keymap_ref_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*); +extern void (*xkb_keymap_unref_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*); +extern char* (*xkb_keymap_get_as_string_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*,enum xkb_keymap_format); +extern xkb_keycode_t (*xkb_keymap_min_keycode_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*); +extern xkb_keycode_t (*xkb_keymap_max_keycode_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*); +extern void (*xkb_keymap_key_for_each_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_keymap_key_iter_t, void*); +extern const char* (*xkb_keymap_key_get_name_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_keycode_t); +extern xkb_keycode_t (*xkb_keymap_key_by_name_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*,const char*); +extern xkb_mod_index_t (*xkb_keymap_num_mods_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*); +extern const char* (*xkb_keymap_mod_get_name_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_mod_index_t); +extern xkb_mod_index_t (*xkb_keymap_mod_get_index_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*,const char*); +extern xkb_layout_index_t (*xkb_keymap_num_layouts_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*); +extern const char* (*xkb_keymap_layout_get_name_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_layout_index_t); +extern xkb_layout_index_t (*xkb_keymap_layout_get_index_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*,const char*); +extern xkb_led_index_t (*xkb_keymap_num_leds_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*); +extern const char* (*xkb_keymap_led_get_name_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_led_index_t); +extern xkb_led_index_t (*xkb_keymap_led_get_index_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*,const char*); +extern xkb_layout_index_t (*xkb_keymap_num_layouts_for_key_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_keycode_t); +extern xkb_level_index_t (*xkb_keymap_num_levels_for_key_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_keycode_t, xkb_layout_index_t); +extern size_t (*xkb_keymap_key_get_mods_for_level_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_keycode_t, xkb_layout_index_t, xkb_level_index_t, xkb_mod_mask_t*, size_t); +extern int (*xkb_keymap_key_get_syms_by_level_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_keycode_t, xkb_layout_index_t, xkb_level_index_t,const xkb_keysym_t**); +extern int (*xkb_keymap_key_repeats_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*, xkb_keycode_t); +extern struct xkb_state* (*xkb_state_new_dylibloader_wrapper_xkbcommon)(struct xkb_keymap*); +extern struct xkb_state* (*xkb_state_ref_dylibloader_wrapper_xkbcommon)(struct xkb_state*); +extern void (*xkb_state_unref_dylibloader_wrapper_xkbcommon)(struct xkb_state*); +extern struct xkb_keymap* (*xkb_state_get_keymap_dylibloader_wrapper_xkbcommon)(struct xkb_state*); +extern enum xkb_state_component (*xkb_state_update_key_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t,enum xkb_key_direction); +extern enum xkb_state_component (*xkb_state_update_mask_dylibloader_wrapper_xkbcommon)(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); +extern int (*xkb_state_key_get_syms_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t,const xkb_keysym_t**); +extern int (*xkb_state_key_get_utf8_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t, char*, size_t); +extern uint32_t (*xkb_state_key_get_utf32_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t); +extern xkb_keysym_t (*xkb_state_key_get_one_sym_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t); +extern xkb_layout_index_t (*xkb_state_key_get_layout_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t); +extern xkb_level_index_t (*xkb_state_key_get_level_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t, xkb_layout_index_t); +extern xkb_mod_mask_t (*xkb_state_serialize_mods_dylibloader_wrapper_xkbcommon)(struct xkb_state*,enum xkb_state_component); +extern xkb_layout_index_t (*xkb_state_serialize_layout_dylibloader_wrapper_xkbcommon)(struct xkb_state*,enum xkb_state_component); +extern int (*xkb_state_mod_name_is_active_dylibloader_wrapper_xkbcommon)(struct xkb_state*,const char*,enum xkb_state_component); +extern int (*xkb_state_mod_names_are_active_dylibloader_wrapper_xkbcommon)(struct xkb_state*,enum xkb_state_component,enum xkb_state_match,...); +extern int (*xkb_state_mod_index_is_active_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_mod_index_t,enum xkb_state_component); +extern int (*xkb_state_mod_indices_are_active_dylibloader_wrapper_xkbcommon)(struct xkb_state*,enum xkb_state_component,enum xkb_state_match,...); +extern xkb_mod_mask_t (*xkb_state_key_get_consumed_mods2_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t,enum xkb_consumed_mode); +extern xkb_mod_mask_t (*xkb_state_key_get_consumed_mods_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t); +extern int (*xkb_state_mod_index_is_consumed2_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t, xkb_mod_index_t,enum xkb_consumed_mode); +extern int (*xkb_state_mod_index_is_consumed_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t, xkb_mod_index_t); +extern xkb_mod_mask_t (*xkb_state_mod_mask_remove_consumed_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_keycode_t, xkb_mod_mask_t); +extern int (*xkb_state_layout_name_is_active_dylibloader_wrapper_xkbcommon)(struct xkb_state*,const char*,enum xkb_state_component); +extern int (*xkb_state_layout_index_is_active_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_layout_index_t,enum xkb_state_component); +extern int (*xkb_state_led_name_is_active_dylibloader_wrapper_xkbcommon)(struct xkb_state*,const char*); +extern int (*xkb_state_led_index_is_active_dylibloader_wrapper_xkbcommon)(struct xkb_state*, xkb_led_index_t); +int initialize_xkbcommon(int verbose); +#ifdef __cplusplus +} +#endif +#endif diff --git a/platform/macos/detect.py b/platform/macos/detect.py index 14e6e92bfa..cd46dab4f3 100644 --- a/platform/macos/detect.py +++ b/platform/macos/detect.py @@ -230,7 +230,7 @@ def configure(env: "Environment"): env.Append(LIBS=["pthread", "z"]) if env["opengl3"]: - env.Append(CPPDEFINES=["GLES_ENABLED", "GLES3_ENABLED"]) + env.Append(CPPDEFINES=["GLES3_ENABLED"]) env.Append(LINKFLAGS=["-framework", "OpenGL"]) env.Append(LINKFLAGS=["-rpath", "@executable_path/../Frameworks", "-rpath", "@executable_path"]) diff --git a/platform/macos/display_server_macos.h b/platform/macos/display_server_macos.h index 4873db4b64..fb9bcdfe56 100644 --- a/platform/macos/display_server_macos.h +++ b/platform/macos/display_server_macos.h @@ -69,6 +69,7 @@ public: bool raw = false; Key keycode = Key::NONE; Key physical_keycode = Key::NONE; + Key key_label = Key::NONE; uint32_t unicode = 0; }; @@ -201,8 +202,6 @@ private: Point2i _get_native_screen_position(int p_screen) const; static void _displays_arrangement_changed(CGDirectDisplayID display_id, CGDisplayChangeSummaryFlags flags, void *user_info); - WindowID _get_focused_window_or_popup() const; - static void _dispatch_input_events(const Ref<InputEvent> &p_event); void _dispatch_input_event(const Ref<InputEvent> &p_event); void _push_input(const Ref<InputEvent> &p_event); @@ -229,6 +228,7 @@ public: void get_key_modifier_state(unsigned int p_macos_state, Ref<InputEventWithModifiers> r_state) const; void update_mouse_pos(WindowData &p_wd, NSPoint p_location_in_window); void push_to_key_event_buffer(const KeyEvent &p_event); + void pop_last_key_event(); void update_im_text(const Point2i &p_selection, const String &p_text); void set_last_focused_window(WindowID p_window); bool mouse_process_popups(bool p_close = false); @@ -237,6 +237,7 @@ public: void set_is_resizing(bool p_is_resizing); bool get_is_resizing() const; void reparent_check(WindowID p_window); + WindowID _get_focused_window_or_popup() const; void window_update(WindowID p_window); void window_destroy(WindowID p_window); diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm index d992467042..2832495693 100644 --- a/platform/macos/display_server_macos.mm +++ b/platform/macos/display_server_macos.mm @@ -434,7 +434,8 @@ void DisplayServerMacOS::_process_key_events() { k->set_pressed(ke.pressed); k->set_echo(ke.echo); k->set_keycode(ke.keycode); - k->set_physical_keycode((Key)ke.physical_keycode); + k->set_physical_keycode(ke.physical_keycode); + k->set_key_label(ke.key_label); k->set_unicode(ke.unicode); _push_input(k); @@ -449,6 +450,7 @@ void DisplayServerMacOS::_process_key_events() { k->set_echo(ke.echo); k->set_keycode(Key::NONE); k->set_physical_keycode(Key::NONE); + k->set_key_label(Key::NONE); k->set_unicode(ke.unicode); _push_input(k); @@ -461,7 +463,8 @@ void DisplayServerMacOS::_process_key_events() { k->set_pressed(ke.pressed); k->set_echo(ke.echo); k->set_keycode(ke.keycode); - k->set_physical_keycode((Key)ke.physical_keycode); + k->set_physical_keycode(ke.physical_keycode); + k->set_key_label(ke.key_label); if (i + 1 < key_event_pos && key_event_buffer[i + 1].keycode == Key::NONE) { k->set_unicode(key_event_buffer[i + 1].unicode); @@ -633,6 +636,7 @@ void DisplayServerMacOS::send_event(NSEvent *p_event) { k->set_pressed(true); k->set_keycode(Key::PERIOD); k->set_physical_keycode(Key::PERIOD); + k->set_key_label(Key::PERIOD); k->set_echo([p_event isARepeat]); Input::get_singleton()->parse_input_event(k); @@ -674,6 +678,12 @@ void DisplayServerMacOS::update_mouse_pos(DisplayServerMacOS::WindowData &p_wd, Input::get_singleton()->set_mouse_position(p_wd.mouse_pos); } +void DisplayServerMacOS::pop_last_key_event() { + if (key_event_pos > 0) { + key_event_pos--; + } +} + void DisplayServerMacOS::push_to_key_event_buffer(const DisplayServerMacOS::KeyEvent &p_event) { if (key_event_pos >= key_event_buffer.size()) { key_event_buffer.resize(1 + key_event_pos); @@ -3142,7 +3152,9 @@ ObjectID DisplayServerMacOS::window_get_attached_instance_id(WindowID p_window) void DisplayServerMacOS::gl_window_make_current(DisplayServer::WindowID p_window_id) { #if defined(GLES3_ENABLED) - gl_manager->window_make_current(p_window_id); + if (gl_manager) { + gl_manager->window_make_current(p_window_id); + } #endif } @@ -3449,14 +3461,14 @@ String DisplayServerMacOS::keyboard_get_layout_name(int p_index) const { } Key DisplayServerMacOS::keyboard_get_keycode_from_physical(Key p_keycode) const { - if (p_keycode == Key::PAUSE) { + if (p_keycode == Key::PAUSE || p_keycode == Key::NONE) { return p_keycode; } Key modifiers = p_keycode & KeyModifierMask::MODIFIER_MASK; Key keycode_no_mod = p_keycode & KeyModifierMask::CODE_MASK; - unsigned int macos_keycode = KeyMappingMacOS::unmap_key((Key)keycode_no_mod); - return (Key)(KeyMappingMacOS::remap_key(macos_keycode, 0) | modifiers); + unsigned int macos_keycode = KeyMappingMacOS::unmap_key(keycode_no_mod); + return (Key)(KeyMappingMacOS::remap_key(macos_keycode, 0, false) | modifiers); } void DisplayServerMacOS::process_events() { @@ -3768,6 +3780,8 @@ bool DisplayServerMacOS::mouse_process_popups(bool p_close) { } DisplayServerMacOS::DisplayServerMacOS(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Error &r_error) { + KeyMappingMacOS::initialize(); + Input::get_singleton()->set_event_dispatch_function(_dispatch_input_events); r_error = OK; diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp index 73fbd45400..5c20016aa5 100644 --- a/platform/macos/export/export_plugin.cpp +++ b/platform/macos/export/export_plugin.cpp @@ -2016,8 +2016,8 @@ Error EditorExportPlatformMacOS::run(const Ref<EditorExportPreset> &p_preset, in if (port.is_empty()) { port = "22"; } - Vector<String> extra_args_ssh = p_preset->get("ssh_remote_deploy/extra_args_ssh").operator String().split(" "); - Vector<String> extra_args_scp = p_preset->get("ssh_remote_deploy/extra_args_scp").operator String().split(" "); + Vector<String> extra_args_ssh = p_preset->get("ssh_remote_deploy/extra_args_ssh").operator String().split(" ", false); + Vector<String> extra_args_scp = p_preset->get("ssh_remote_deploy/extra_args_scp").operator String().split(" ", false); const String basepath = dest.path_join("tmp_macos_export"); diff --git a/platform/macos/godot_application.h b/platform/macos/godot_application.h index f41fc2646d..8749c8fbb0 100644 --- a/platform/macos/godot_application.h +++ b/platform/macos/godot_application.h @@ -35,6 +35,7 @@ #import <AppKit/AppKit.h> #import <Foundation/Foundation.h> +#import <IOKit/hidsystem/ev_keymap.h> @interface GodotApplication : NSApplication @end diff --git a/platform/macos/godot_application.mm b/platform/macos/godot_application.mm index 0c282930f4..e3a744caa2 100644 --- a/platform/macos/godot_application.mm +++ b/platform/macos/godot_application.mm @@ -34,7 +34,81 @@ @implementation GodotApplication +- (void)mediaKeyEvent:(int)key state:(BOOL)state repeat:(BOOL)repeat { + Key keycode = Key::NONE; + switch (key) { + case NX_KEYTYPE_SOUND_UP: { + keycode = Key::VOLUMEUP; + } break; + case NX_KEYTYPE_SOUND_DOWN: { + keycode = Key::VOLUMEUP; + } break; + //NX_KEYTYPE_BRIGHTNESS_UP + //NX_KEYTYPE_BRIGHTNESS_DOWN + case NX_KEYTYPE_CAPS_LOCK: { + keycode = Key::CAPSLOCK; + } break; + case NX_KEYTYPE_HELP: { + keycode = Key::HELP; + } break; + case NX_POWER_KEY: { + keycode = Key::STANDBY; + } break; + case NX_KEYTYPE_MUTE: { + keycode = Key::VOLUMEMUTE; + } break; + //NX_KEYTYPE_CONTRAST_UP + //NX_KEYTYPE_CONTRAST_DOWN + //NX_KEYTYPE_LAUNCH_PANEL + //NX_KEYTYPE_EJECT + //NX_KEYTYPE_VIDMIRROR + //NX_KEYTYPE_FAST + //NX_KEYTYPE_REWIND + //NX_KEYTYPE_ILLUMINATION_UP + //NX_KEYTYPE_ILLUMINATION_DOWN + //NX_KEYTYPE_ILLUMINATION_TOGGLE + case NX_KEYTYPE_PLAY: { + keycode = Key::MEDIAPLAY; + } break; + case NX_KEYTYPE_NEXT: { + keycode = Key::MEDIANEXT; + } break; + case NX_KEYTYPE_PREVIOUS: { + keycode = Key::MEDIAPREVIOUS; + } break; + default: { + keycode = Key::NONE; + } break; + } + + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); + if (ds && keycode != Key::NONE) { + DisplayServerMacOS::KeyEvent ke; + + ke.window_id = ds->_get_focused_window_or_popup(); + ke.macos_state = 0; + ke.pressed = state; + ke.echo = repeat; + ke.keycode = keycode; + ke.physical_keycode = keycode; + ke.key_label = keycode; + ke.unicode = 0; + ke.raw = true; + + ds->push_to_key_event_buffer(ke); + } +} + - (void)sendEvent:(NSEvent *)event { + if ([event type] == NSSystemDefined && [event subtype] == 8) { + int keyCode = (([event data1] & 0xFFFF0000) >> 16); + int keyFlags = ([event data1] & 0x0000FFFF); + int keyState = (((keyFlags & 0xFF00) >> 8)) == 0xA; + int keyRepeat = (keyFlags & 0x1); + + [self mediaKeyEvent:keyCode state:keyState repeat:keyRepeat]; + } + DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); if (ds) { if ([event type] == NSEventTypeLeftMouseDown || [event type] == NSEventTypeRightMouseDown || [event type] == NSEventTypeOtherMouseDown) { diff --git a/platform/macos/godot_content_view.h b/platform/macos/godot_content_view.h index e660285e49..0d18ac742a 100644 --- a/platform/macos/godot_content_view.h +++ b/platform/macos/godot_content_view.h @@ -64,6 +64,7 @@ bool mouse_down_control; bool ignore_momentum_scroll; bool last_pen_inverted; + bool ime_suppress_next_keyup; id layer_delegate; } diff --git a/platform/macos/godot_content_view.mm b/platform/macos/godot_content_view.mm index 337aa59a5e..485f80a22e 100644 --- a/platform/macos/godot_content_view.mm +++ b/platform/macos/godot_content_view.mm @@ -185,6 +185,7 @@ DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); if (wd.im_active) { ime_input_event_in_progress = true; + ds->pop_last_key_event(); ds->update_im_text(Point2i(selectedRange.location, selectedRange.length), String::utf8([[marked_text mutableString] UTF8String])); } } @@ -194,6 +195,9 @@ } - (void)unmarkText { + if (ime_input_event_in_progress) { + ime_suppress_next_keyup = true; + } ime_input_event_in_progress = false; [[marked_text mutableString] setString:@""]; @@ -245,8 +249,6 @@ } - (void)insertText:(id)aString replacementRange:(NSRange)replacementRange { - NSEvent *event = [NSApp currentEvent]; - NSString *characters; if ([aString isKindOfClass:[NSAttributedString class]]) { characters = [aString string]; @@ -284,13 +286,14 @@ DisplayServerMacOS::KeyEvent ke; ke.window_id = window_id; - ke.macos_state = [event modifierFlags]; + ke.macos_state = 0; ke.pressed = true; ke.echo = false; ke.raw = false; // IME input event. ke.keycode = Key::NONE; ke.physical_keycode = Key::NONE; - ke.unicode = codepoint; + ke.key_label = Key::NONE; + ke.unicode = fix_unicode(codepoint); ds->push_to_key_event_buffer(ke); } @@ -584,7 +587,7 @@ NSString *characters = [event characters]; NSUInteger length = [characters length]; - if (!wd.im_active && length > 0 && keycode_has_unicode(KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags]))) { + if (!wd.im_active && length > 0 && keycode_has_unicode(KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags], true))) { // Fallback unicode character handler used if IME is not active. Char16String text; text.resize([characters length] + 1); @@ -602,10 +605,11 @@ ke.macos_state = [event modifierFlags]; ke.pressed = true; ke.echo = [event isARepeat]; - ke.keycode = KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags]); + ke.keycode = KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags], false); ke.physical_keycode = KeyMappingMacOS::translate_key([event keyCode]); + ke.key_label = KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags], true); + ke.unicode = fix_unicode(codepoint); ke.raw = true; - ke.unicode = codepoint; ds->push_to_key_event_buffer(ke); } @@ -616,10 +620,11 @@ ke.macos_state = [event modifierFlags]; ke.pressed = true; ke.echo = [event isARepeat]; - ke.keycode = KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags]); + ke.keycode = KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags], false); ke.physical_keycode = KeyMappingMacOS::translate_key([event keyCode]); - ke.raw = false; + ke.key_label = KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags], true); ke.unicode = 0; + ke.raw = false; ds->push_to_key_event_buffer(ke); } @@ -638,56 +643,54 @@ } ignore_momentum_scroll = true; - // Ignore all input if IME input is in progress - if (!ime_input_event_in_progress) { - DisplayServerMacOS::KeyEvent ke; + DisplayServerMacOS::KeyEvent ke; - ke.window_id = window_id; - ke.echo = false; - ke.raw = true; + ke.window_id = window_id; + ke.echo = false; + ke.raw = true; - int key = [event keyCode]; - int mod = [event modifierFlags]; + int key = [event keyCode]; + int mod = [event modifierFlags]; - if (key == 0x36 || key == 0x37) { - if (mod & NSEventModifierFlagCommand) { - mod &= ~NSEventModifierFlagCommand; - ke.pressed = true; - } else { - ke.pressed = false; - } - } else if (key == 0x38 || key == 0x3c) { - if (mod & NSEventModifierFlagShift) { - mod &= ~NSEventModifierFlagShift; - ke.pressed = true; - } else { - ke.pressed = false; - } - } else if (key == 0x3a || key == 0x3d) { - if (mod & NSEventModifierFlagOption) { - mod &= ~NSEventModifierFlagOption; - ke.pressed = true; - } else { - ke.pressed = false; - } - } else if (key == 0x3b || key == 0x3e) { - if (mod & NSEventModifierFlagControl) { - mod &= ~NSEventModifierFlagControl; - ke.pressed = true; - } else { - ke.pressed = false; - } + if (key == 0x36 || key == 0x37) { + if (mod & NSEventModifierFlagCommand) { + mod &= ~NSEventModifierFlagCommand; + ke.pressed = true; } else { - return; + ke.pressed = false; } + } else if (key == 0x38 || key == 0x3c) { + if (mod & NSEventModifierFlagShift) { + mod &= ~NSEventModifierFlagShift; + ke.pressed = true; + } else { + ke.pressed = false; + } + } else if (key == 0x3a || key == 0x3d) { + if (mod & NSEventModifierFlagOption) { + mod &= ~NSEventModifierFlagOption; + ke.pressed = true; + } else { + ke.pressed = false; + } + } else if (key == 0x3b || key == 0x3e) { + if (mod & NSEventModifierFlagControl) { + mod &= ~NSEventModifierFlagControl; + ke.pressed = true; + } else { + ke.pressed = false; + } + } else { + return; + } - ke.macos_state = mod; - ke.keycode = KeyMappingMacOS::remap_key(key, mod); - ke.physical_keycode = KeyMappingMacOS::translate_key(key); - ke.unicode = 0; + ke.macos_state = mod; + ke.keycode = KeyMappingMacOS::remap_key(key, mod, false); + ke.physical_keycode = KeyMappingMacOS::translate_key(key); + ke.key_label = KeyMappingMacOS::remap_key(key, mod, true); + ke.unicode = 0; - ds->push_to_key_event_buffer(ke); - } + ds->push_to_key_event_buffer(ke); } - (void)keyUp:(NSEvent *)event { @@ -696,51 +699,26 @@ return; } - DisplayServerMacOS::WindowData &wd = ds->get_window(window_id); - // Ignore all input if IME input is in progress. - if (!ime_input_event_in_progress) { - NSString *characters = [event characters]; - NSUInteger length = [characters length]; - - // Fallback unicode character handler used if IME is not active. - if (!wd.im_active && length > 0 && keycode_has_unicode(KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags]))) { - Char16String text; - text.resize([characters length] + 1); - [characters getCharacters:(unichar *)text.ptrw() range:NSMakeRange(0, [characters length])]; - - String u32text; - u32text.parse_utf16(text.ptr(), text.length()); - - for (int i = 0; i < u32text.length(); i++) { - const char32_t codepoint = u32text[i]; - DisplayServerMacOS::KeyEvent ke; - - ke.window_id = window_id; - ke.macos_state = [event modifierFlags]; - ke.pressed = false; - ke.echo = [event isARepeat]; - ke.keycode = KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags]); - ke.physical_keycode = KeyMappingMacOS::translate_key([event keyCode]); - ke.raw = true; - ke.unicode = codepoint; + if (ime_suppress_next_keyup) { + ime_suppress_next_keyup = false; + return; + } - ds->push_to_key_event_buffer(ke); - } - } else { - DisplayServerMacOS::KeyEvent ke; + if (!ime_input_event_in_progress) { + DisplayServerMacOS::KeyEvent ke; - ke.window_id = window_id; - ke.macos_state = [event modifierFlags]; - ke.pressed = false; - ke.echo = [event isARepeat]; - ke.keycode = KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags]); - ke.physical_keycode = KeyMappingMacOS::translate_key([event keyCode]); - ke.raw = true; - ke.unicode = 0; + ke.window_id = window_id; + ke.macos_state = [event modifierFlags]; + ke.pressed = false; + ke.echo = [event isARepeat]; + ke.keycode = KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags], false); + ke.physical_keycode = KeyMappingMacOS::translate_key([event keyCode]); + ke.key_label = KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags], true); + ke.unicode = 0; + ke.raw = true; - ds->push_to_key_event_buffer(ke); - } + ds->push_to_key_event_buffer(ke); } } diff --git a/platform/macos/key_mapping_macos.h b/platform/macos/key_mapping_macos.h index 5128005627..1bda4eb406 100644 --- a/platform/macos/key_mapping_macos.h +++ b/platform/macos/key_mapping_macos.h @@ -36,13 +36,15 @@ class KeyMappingMacOS { KeyMappingMacOS() {} - static bool is_numpad_key(unsigned int key); + static bool is_numpad_key(unsigned int p_key); public: + static void initialize(); + // Mappings input. - static Key translate_key(unsigned int key); - static unsigned int unmap_key(Key key); - static Key remap_key(unsigned int key, unsigned int state); + static Key translate_key(unsigned int p_key); + static unsigned int unmap_key(Key p_key); + static Key remap_key(unsigned int p_key, unsigned int p_state, bool p_unicode); // Mapping for menu shortcuts. static String keycode_get_native_string(Key p_keycode); diff --git a/platform/macos/key_mapping_macos.mm b/platform/macos/key_mapping_macos.mm index 478c84e81c..31b71ac1b8 100644 --- a/platform/macos/key_mapping_macos.mm +++ b/platform/macos/key_mapping_macos.mm @@ -33,277 +33,345 @@ #import <Carbon/Carbon.h> #import <Cocoa/Cocoa.h> -bool KeyMappingMacOS::is_numpad_key(unsigned int key) { - static const unsigned int table[] = { - 0x41, /* kVK_ANSI_KeypadDecimal */ - 0x43, /* kVK_ANSI_KeypadMultiply */ - 0x45, /* kVK_ANSI_KeypadPlus */ - 0x47, /* kVK_ANSI_KeypadClear */ - 0x4b, /* kVK_ANSI_KeypadDivide */ - 0x4c, /* kVK_ANSI_KeypadEnter */ - 0x4e, /* kVK_ANSI_KeypadMinus */ - 0x51, /* kVK_ANSI_KeypadEquals */ - 0x52, /* kVK_ANSI_Keypad0 */ - 0x53, /* kVK_ANSI_Keypad1 */ - 0x54, /* kVK_ANSI_Keypad2 */ - 0x55, /* kVK_ANSI_Keypad3 */ - 0x56, /* kVK_ANSI_Keypad4 */ - 0x57, /* kVK_ANSI_Keypad5 */ - 0x58, /* kVK_ANSI_Keypad6 */ - 0x59, /* kVK_ANSI_Keypad7 */ - 0x5b, /* kVK_ANSI_Keypad8 */ - 0x5c, /* kVK_ANSI_Keypad9 */ - 0x5f, /* kVK_JIS_KeypadComma */ - 0x00 - }; - for (int i = 0; table[i] != 0; i++) { - if (key == table[i]) { - return true; - } +#include "core/templates/hash_map.h" +#include "core/templates/hash_set.h" + +struct HashMapHasherKeys { + static _FORCE_INLINE_ uint32_t hash(const Key p_key) { return hash_fmix32(static_cast<uint32_t>(p_key)); } + static _FORCE_INLINE_ uint32_t hash(const char32_t p_uchar) { return hash_fmix32(p_uchar); } + static _FORCE_INLINE_ uint32_t hash(const unsigned p_key) { return hash_fmix32(p_key); } +}; + +HashSet<unsigned int> numpad_keys; +HashMap<unsigned int, Key, HashMapHasherKeys> keysym_map; +HashMap<Key, unsigned int, HashMapHasherKeys> keysym_map_inv; +HashMap<Key, char32_t, HashMapHasherKeys> keycode_map; + +void KeyMappingMacOS::initialize() { + numpad_keys.insert(0x41); //kVK_ANSI_KeypadDecimal + numpad_keys.insert(0x43); //kVK_ANSI_KeypadMultiply + numpad_keys.insert(0x45); //kVK_ANSI_KeypadPlus + numpad_keys.insert(0x47); //kVK_ANSI_KeypadClear + numpad_keys.insert(0x4b); //kVK_ANSI_KeypadDivide + numpad_keys.insert(0x4c); //kVK_ANSI_KeypadEnter + numpad_keys.insert(0x4e); //kVK_ANSI_KeypadMinus + numpad_keys.insert(0x51); //kVK_ANSI_KeypadEquals + numpad_keys.insert(0x52); //kVK_ANSI_Keypad0 + numpad_keys.insert(0x53); //kVK_ANSI_Keypad1 + numpad_keys.insert(0x54); //kVK_ANSI_Keypad2 + numpad_keys.insert(0x55); //kVK_ANSI_Keypad3 + numpad_keys.insert(0x56); //kVK_ANSI_Keypad4 + numpad_keys.insert(0x57); //kVK_ANSI_Keypad5 + numpad_keys.insert(0x58); //kVK_ANSI_Keypad6 + numpad_keys.insert(0x59); //kVK_ANSI_Keypad7 + numpad_keys.insert(0x5b); //kVK_ANSI_Keypad8 + numpad_keys.insert(0x5c); //kVK_ANSI_Keypad9 + numpad_keys.insert(0x5f); //kVK_JIS_KeypadComma + + keysym_map[0x00] = Key::A; + keysym_map[0x01] = Key::S; + keysym_map[0x02] = Key::D; + keysym_map[0x03] = Key::F; + keysym_map[0x04] = Key::H; + keysym_map[0x05] = Key::G; + keysym_map[0x06] = Key::Z; + keysym_map[0x07] = Key::X; + keysym_map[0x08] = Key::C; + keysym_map[0x09] = Key::V; + keysym_map[0x0a] = Key::SECTION; + keysym_map[0x0b] = Key::B; + keysym_map[0x0c] = Key::Q; + keysym_map[0x0d] = Key::W; + keysym_map[0x0e] = Key::E; + keysym_map[0x0f] = Key::R; + keysym_map[0x10] = Key::Y; + keysym_map[0x11] = Key::T; + keysym_map[0x12] = Key::KEY_1; + keysym_map[0x13] = Key::KEY_2; + keysym_map[0x14] = Key::KEY_3; + keysym_map[0x15] = Key::KEY_4; + keysym_map[0x16] = Key::KEY_6; + keysym_map[0x17] = Key::KEY_5; + keysym_map[0x18] = Key::EQUAL; + keysym_map[0x19] = Key::KEY_9; + keysym_map[0x1a] = Key::KEY_7; + keysym_map[0x1b] = Key::MINUS; + keysym_map[0x1c] = Key::KEY_8; + keysym_map[0x1d] = Key::KEY_0; + keysym_map[0x1e] = Key::BRACERIGHT; + keysym_map[0x1f] = Key::O; + keysym_map[0x20] = Key::U; + keysym_map[0x21] = Key::BRACELEFT; + keysym_map[0x22] = Key::I; + keysym_map[0x23] = Key::P; + keysym_map[0x24] = Key::ENTER; + keysym_map[0x25] = Key::L; + keysym_map[0x26] = Key::J; + keysym_map[0x27] = Key::APOSTROPHE; + keysym_map[0x28] = Key::K; + keysym_map[0x29] = Key::SEMICOLON; + keysym_map[0x2a] = Key::BACKSLASH; + keysym_map[0x2b] = Key::COMMA; + keysym_map[0x2c] = Key::SLASH; + keysym_map[0x2d] = Key::N; + keysym_map[0x2e] = Key::M; + keysym_map[0x2f] = Key::PERIOD; + keysym_map[0x30] = Key::TAB; + keysym_map[0x31] = Key::SPACE; + keysym_map[0x32] = Key::QUOTELEFT; + keysym_map[0x33] = Key::BACKSPACE; + keysym_map[0x35] = Key::ESCAPE; + keysym_map[0x36] = Key::META; + keysym_map[0x37] = Key::META; + keysym_map[0x38] = Key::SHIFT; + keysym_map[0x39] = Key::CAPSLOCK; + keysym_map[0x3a] = Key::ALT; + keysym_map[0x3b] = Key::CTRL; + keysym_map[0x3c] = Key::SHIFT; + keysym_map[0x3d] = Key::ALT; + keysym_map[0x3e] = Key::CTRL; + keysym_map[0x40] = Key::F17; + keysym_map[0x41] = Key::KP_PERIOD; + keysym_map[0x43] = Key::KP_MULTIPLY; + keysym_map[0x45] = Key::KP_ADD; + keysym_map[0x47] = Key::NUMLOCK; + keysym_map[0x48] = Key::VOLUMEUP; + keysym_map[0x49] = Key::VOLUMEDOWN; + keysym_map[0x4a] = Key::VOLUMEMUTE; + keysym_map[0x4b] = Key::KP_DIVIDE; + keysym_map[0x4c] = Key::KP_ENTER; + keysym_map[0x4e] = Key::KP_SUBTRACT; + keysym_map[0x4f] = Key::F18; + keysym_map[0x50] = Key::F19; + keysym_map[0x51] = Key::EQUAL; + keysym_map[0x52] = Key::KP_0; + keysym_map[0x53] = Key::KP_1; + keysym_map[0x54] = Key::KP_2; + keysym_map[0x55] = Key::KP_3; + keysym_map[0x56] = Key::KP_4; + keysym_map[0x57] = Key::KP_5; + keysym_map[0x58] = Key::KP_6; + keysym_map[0x59] = Key::KP_7; + keysym_map[0x5a] = Key::F20; + keysym_map[0x5b] = Key::KP_8; + keysym_map[0x5c] = Key::KP_9; + keysym_map[0x5d] = Key::YEN; + keysym_map[0x5e] = Key::UNDERSCORE; + keysym_map[0x5f] = Key::COMMA; + keysym_map[0x60] = Key::F5; + keysym_map[0x61] = Key::F6; + keysym_map[0x62] = Key::F7; + keysym_map[0x63] = Key::F3; + keysym_map[0x64] = Key::F8; + keysym_map[0x65] = Key::F9; + keysym_map[0x66] = Key::JIS_EISU; + keysym_map[0x67] = Key::F11; + keysym_map[0x68] = Key::JIS_KANA; + keysym_map[0x69] = Key::F13; + keysym_map[0x6a] = Key::F16; + keysym_map[0x6b] = Key::F14; + keysym_map[0x6d] = Key::F10; + keysym_map[0x6e] = Key::MENU; + keysym_map[0x6f] = Key::F12; + keysym_map[0x71] = Key::F15; + keysym_map[0x72] = Key::INSERT; + keysym_map[0x73] = Key::HOME; + keysym_map[0x74] = Key::PAGEUP; + keysym_map[0x75] = Key::KEY_DELETE; + keysym_map[0x76] = Key::F4; + keysym_map[0x77] = Key::END; + keysym_map[0x78] = Key::F2; + keysym_map[0x79] = Key::PAGEDOWN; + keysym_map[0x7a] = Key::F1; + keysym_map[0x7b] = Key::LEFT; + keysym_map[0x7c] = Key::RIGHT; + keysym_map[0x7d] = Key::DOWN; + keysym_map[0x7e] = Key::UP; + + for (const KeyValue<unsigned int, Key> &E : keysym_map) { + keysym_map_inv[E.value] = E.key; } - return false; + + keycode_map[Key::ESCAPE] = 0x001B; + keycode_map[Key::TAB] = 0x0009; + keycode_map[Key::BACKTAB] = 0x007F; + keycode_map[Key::BACKSPACE] = 0x0008; + keycode_map[Key::ENTER] = 0x000D; + keycode_map[Key::INSERT] = NSInsertFunctionKey; + keycode_map[Key::KEY_DELETE] = 0x007F; + keycode_map[Key::PAUSE] = NSPauseFunctionKey; + keycode_map[Key::PRINT] = NSPrintScreenFunctionKey; + keycode_map[Key::SYSREQ] = NSSysReqFunctionKey; + keycode_map[Key::CLEAR] = NSClearLineFunctionKey; + keycode_map[Key::HOME] = 0x2196; + keycode_map[Key::END] = 0x2198; + keycode_map[Key::LEFT] = 0x001C; + keycode_map[Key::UP] = 0x001E; + keycode_map[Key::RIGHT] = 0x001D; + keycode_map[Key::DOWN] = 0x001F; + keycode_map[Key::PAGEUP] = 0x21DE; + keycode_map[Key::PAGEDOWN] = 0x21DF; + keycode_map[Key::NUMLOCK] = NSClearLineFunctionKey; + keycode_map[Key::SCROLLLOCK] = NSScrollLockFunctionKey; + keycode_map[Key::F1] = NSF1FunctionKey; + keycode_map[Key::F2] = NSF2FunctionKey; + keycode_map[Key::F3] = NSF3FunctionKey; + keycode_map[Key::F4] = NSF4FunctionKey; + keycode_map[Key::F5] = NSF5FunctionKey; + keycode_map[Key::F6] = NSF6FunctionKey; + keycode_map[Key::F7] = NSF7FunctionKey; + keycode_map[Key::F8] = NSF8FunctionKey; + keycode_map[Key::F9] = NSF9FunctionKey; + keycode_map[Key::F10] = NSF10FunctionKey; + keycode_map[Key::F11] = NSF11FunctionKey; + keycode_map[Key::F12] = NSF12FunctionKey; + keycode_map[Key::F13] = NSF13FunctionKey; + keycode_map[Key::F14] = NSF14FunctionKey; + keycode_map[Key::F15] = NSF15FunctionKey; + keycode_map[Key::F16] = NSF16FunctionKey; + keycode_map[Key::F17] = NSF17FunctionKey; + keycode_map[Key::F18] = NSF18FunctionKey; + keycode_map[Key::F19] = NSF19FunctionKey; + keycode_map[Key::F20] = NSF20FunctionKey; + keycode_map[Key::F21] = NSF21FunctionKey; + keycode_map[Key::F22] = NSF22FunctionKey; + keycode_map[Key::F23] = NSF23FunctionKey; + keycode_map[Key::F24] = NSF24FunctionKey; + keycode_map[Key::F25] = NSF25FunctionKey; + keycode_map[Key::F26] = NSF26FunctionKey; + keycode_map[Key::F27] = NSF27FunctionKey; + keycode_map[Key::F28] = NSF28FunctionKey; + keycode_map[Key::F29] = NSF29FunctionKey; + keycode_map[Key::F30] = NSF30FunctionKey; + keycode_map[Key::F31] = NSF31FunctionKey; + keycode_map[Key::F32] = NSF32FunctionKey; + keycode_map[Key::F33] = NSF33FunctionKey; + keycode_map[Key::F34] = NSF34FunctionKey; + keycode_map[Key::F35] = NSF35FunctionKey; + keycode_map[Key::MENU] = NSMenuFunctionKey; + keycode_map[Key::HELP] = NSHelpFunctionKey; + keycode_map[Key::STOP] = NSStopFunctionKey; + keycode_map[Key::LAUNCH0] = NSUserFunctionKey; + keycode_map[Key::SPACE] = 0x0020; + keycode_map[Key::EXCLAM] = '!'; + keycode_map[Key::QUOTEDBL] = '\"'; + keycode_map[Key::NUMBERSIGN] = '#'; + keycode_map[Key::DOLLAR] = '$'; + keycode_map[Key::PERCENT] = '\%'; + keycode_map[Key::AMPERSAND] = '&'; + keycode_map[Key::APOSTROPHE] = '\''; + keycode_map[Key::PARENLEFT] = '('; + keycode_map[Key::PARENRIGHT] = ')'; + keycode_map[Key::ASTERISK] = '*'; + keycode_map[Key::PLUS] = '+'; + keycode_map[Key::COMMA] = ','; + keycode_map[Key::MINUS] = '-'; + keycode_map[Key::PERIOD] = '.'; + keycode_map[Key::SLASH] = '/'; + keycode_map[Key::KEY_0] = '0'; + keycode_map[Key::KEY_1] = '1'; + keycode_map[Key::KEY_2] = '2'; + keycode_map[Key::KEY_3] = '3'; + keycode_map[Key::KEY_4] = '4'; + keycode_map[Key::KEY_5] = '5'; + keycode_map[Key::KEY_6] = '6'; + keycode_map[Key::KEY_7] = '7'; + keycode_map[Key::KEY_8] = '8'; + keycode_map[Key::KEY_9] = '9'; + keycode_map[Key::COLON] = ':'; + keycode_map[Key::SEMICOLON] = ';'; + keycode_map[Key::LESS] = '<'; + keycode_map[Key::EQUAL] = '='; + keycode_map[Key::GREATER] = '>'; + keycode_map[Key::QUESTION] = '?'; + keycode_map[Key::AT] = '@'; + keycode_map[Key::A] = 'a'; + keycode_map[Key::B] = 'b'; + keycode_map[Key::C] = 'c'; + keycode_map[Key::D] = 'd'; + keycode_map[Key::E] = 'e'; + keycode_map[Key::F] = 'f'; + keycode_map[Key::G] = 'g'; + keycode_map[Key::H] = 'h'; + keycode_map[Key::I] = 'i'; + keycode_map[Key::J] = 'j'; + keycode_map[Key::K] = 'k'; + keycode_map[Key::L] = 'l'; + keycode_map[Key::M] = 'm'; + keycode_map[Key::N] = 'n'; + keycode_map[Key::O] = 'o'; + keycode_map[Key::P] = 'p'; + keycode_map[Key::Q] = 'q'; + keycode_map[Key::R] = 'r'; + keycode_map[Key::S] = 's'; + keycode_map[Key::T] = 't'; + keycode_map[Key::U] = 'u'; + keycode_map[Key::V] = 'v'; + keycode_map[Key::W] = 'w'; + keycode_map[Key::X] = 'x'; + keycode_map[Key::Y] = 'y'; + keycode_map[Key::Z] = 'z'; + keycode_map[Key::BRACKETLEFT] = '['; + keycode_map[Key::BACKSLASH] = '\\'; + keycode_map[Key::BRACKETRIGHT] = ']'; + keycode_map[Key::ASCIICIRCUM] = '^'; + keycode_map[Key::UNDERSCORE] = '_'; + keycode_map[Key::QUOTELEFT] = '`'; + keycode_map[Key::BRACELEFT] = '{'; + keycode_map[Key::BAR] = '|'; + keycode_map[Key::BRACERIGHT] = '}'; + keycode_map[Key::ASCIITILDE] = '~'; } -// Keyboard symbol translation table. -static const Key _macos_to_godot_table[128] = { - /* 00 */ Key::A, - /* 01 */ Key::S, - /* 02 */ Key::D, - /* 03 */ Key::F, - /* 04 */ Key::H, - /* 05 */ Key::G, - /* 06 */ Key::Z, - /* 07 */ Key::X, - /* 08 */ Key::C, - /* 09 */ Key::V, - /* 0a */ Key::SECTION, /* ISO Section */ - /* 0b */ Key::B, - /* 0c */ Key::Q, - /* 0d */ Key::W, - /* 0e */ Key::E, - /* 0f */ Key::R, - /* 10 */ Key::Y, - /* 11 */ Key::T, - /* 12 */ Key::KEY_1, - /* 13 */ Key::KEY_2, - /* 14 */ Key::KEY_3, - /* 15 */ Key::KEY_4, - /* 16 */ Key::KEY_6, - /* 17 */ Key::KEY_5, - /* 18 */ Key::EQUAL, - /* 19 */ Key::KEY_9, - /* 1a */ Key::KEY_7, - /* 1b */ Key::MINUS, - /* 1c */ Key::KEY_8, - /* 1d */ Key::KEY_0, - /* 1e */ Key::BRACERIGHT, - /* 1f */ Key::O, - /* 20 */ Key::U, - /* 21 */ Key::BRACELEFT, - /* 22 */ Key::I, - /* 23 */ Key::P, - /* 24 */ Key::ENTER, - /* 25 */ Key::L, - /* 26 */ Key::J, - /* 27 */ Key::APOSTROPHE, - /* 28 */ Key::K, - /* 29 */ Key::SEMICOLON, - /* 2a */ Key::BACKSLASH, - /* 2b */ Key::COMMA, - /* 2c */ Key::SLASH, - /* 2d */ Key::N, - /* 2e */ Key::M, - /* 2f */ Key::PERIOD, - /* 30 */ Key::TAB, - /* 31 */ Key::SPACE, - /* 32 */ Key::QUOTELEFT, - /* 33 */ Key::BACKSPACE, - /* 34 */ Key::UNKNOWN, - /* 35 */ Key::ESCAPE, - /* 36 */ Key::META, - /* 37 */ Key::META, - /* 38 */ Key::SHIFT, - /* 39 */ Key::CAPSLOCK, - /* 3a */ Key::ALT, - /* 3b */ Key::CTRL, - /* 3c */ Key::SHIFT, - /* 3d */ Key::ALT, - /* 3e */ Key::CTRL, - /* 3f */ Key::UNKNOWN, /* Function */ - /* 40 */ Key::F17, - /* 41 */ Key::KP_PERIOD, - /* 42 */ Key::UNKNOWN, - /* 43 */ Key::KP_MULTIPLY, - /* 44 */ Key::UNKNOWN, - /* 45 */ Key::KP_ADD, - /* 46 */ Key::UNKNOWN, - /* 47 */ Key::NUMLOCK, /* Really KeypadClear... */ - /* 48 */ Key::VOLUMEUP, /* VolumeUp */ - /* 49 */ Key::VOLUMEDOWN, /* VolumeDown */ - /* 4a */ Key::VOLUMEMUTE, /* Mute */ - /* 4b */ Key::KP_DIVIDE, - /* 4c */ Key::KP_ENTER, - /* 4d */ Key::UNKNOWN, - /* 4e */ Key::KP_SUBTRACT, - /* 4f */ Key::F18, - /* 50 */ Key::F19, - /* 51 */ Key::EQUAL, /* KeypadEqual */ - /* 52 */ Key::KP_0, - /* 53 */ Key::KP_1, - /* 54 */ Key::KP_2, - /* 55 */ Key::KP_3, - /* 56 */ Key::KP_4, - /* 57 */ Key::KP_5, - /* 58 */ Key::KP_6, - /* 59 */ Key::KP_7, - /* 5a */ Key::F20, - /* 5b */ Key::KP_8, - /* 5c */ Key::KP_9, - /* 5d */ Key::YEN, /* JIS Yen */ - /* 5e */ Key::UNDERSCORE, /* JIS Underscore */ - /* 5f */ Key::COMMA, /* JIS KeypadComma */ - /* 60 */ Key::F5, - /* 61 */ Key::F6, - /* 62 */ Key::F7, - /* 63 */ Key::F3, - /* 64 */ Key::F8, - /* 65 */ Key::F9, - /* 66 */ Key::UNKNOWN, /* JIS Eisu */ - /* 67 */ Key::F11, - /* 68 */ Key::UNKNOWN, /* JIS Kana */ - /* 69 */ Key::F13, - /* 6a */ Key::F16, - /* 6b */ Key::F14, - /* 6c */ Key::UNKNOWN, - /* 6d */ Key::F10, - /* 6e */ Key::MENU, - /* 6f */ Key::F12, - /* 70 */ Key::UNKNOWN, - /* 71 */ Key::F15, - /* 72 */ Key::INSERT, /* Really Help... */ - /* 73 */ Key::HOME, - /* 74 */ Key::PAGEUP, - /* 75 */ Key::KEY_DELETE, - /* 76 */ Key::F4, - /* 77 */ Key::END, - /* 78 */ Key::F2, - /* 79 */ Key::PAGEDOWN, - /* 7a */ Key::F1, - /* 7b */ Key::LEFT, - /* 7c */ Key::RIGHT, - /* 7d */ Key::DOWN, - /* 7e */ Key::UP, - /* 7f */ Key::UNKNOWN, -}; +bool KeyMappingMacOS::is_numpad_key(unsigned int p_key) { + return numpad_keys.has(p_key); +} // Translates a OS X keycode to a Godot keycode. -Key KeyMappingMacOS::translate_key(unsigned int key) { - if (key >= 128) { - return Key::UNKNOWN; +Key KeyMappingMacOS::translate_key(unsigned int p_key) { + const Key *key = keysym_map.getptr(p_key); + if (key) { + return *key; } - - return _macos_to_godot_table[key]; + return Key::NONE; } // Translates a Godot keycode back to a macOS keycode. -unsigned int KeyMappingMacOS::unmap_key(Key key) { - for (int i = 0; i <= 126; i++) { - if (_macos_to_godot_table[i] == key) { - return i; - } +unsigned int KeyMappingMacOS::unmap_key(Key p_key) { + const unsigned int *key = keysym_map_inv.getptr(p_key); + if (key) { + return *key; } return 127; } -struct _KeyCodeMap { - UniChar kchar; - Key kcode; -}; - -static const _KeyCodeMap _keycodes[55] = { - { '`', Key::QUOTELEFT }, - { '~', Key::ASCIITILDE }, - { '0', Key::KEY_0 }, - { '1', Key::KEY_1 }, - { '2', Key::KEY_2 }, - { '3', Key::KEY_3 }, - { '4', Key::KEY_4 }, - { '5', Key::KEY_5 }, - { '6', Key::KEY_6 }, - { '7', Key::KEY_7 }, - { '8', Key::KEY_8 }, - { '9', Key::KEY_9 }, - { '-', Key::MINUS }, - { '_', Key::UNDERSCORE }, - { '=', Key::EQUAL }, - { '+', Key::PLUS }, - { 'q', Key::Q }, - { 'w', Key::W }, - { 'e', Key::E }, - { 'r', Key::R }, - { 't', Key::T }, - { 'y', Key::Y }, - { 'u', Key::U }, - { 'i', Key::I }, - { 'o', Key::O }, - { 'p', Key::P }, - { '[', Key::BRACELEFT }, - { ']', Key::BRACERIGHT }, - { '{', Key::BRACELEFT }, - { '}', Key::BRACERIGHT }, - { 'a', Key::A }, - { 's', Key::S }, - { 'd', Key::D }, - { 'f', Key::F }, - { 'g', Key::G }, - { 'h', Key::H }, - { 'j', Key::J }, - { 'k', Key::K }, - { 'l', Key::L }, - { ';', Key::SEMICOLON }, - { ':', Key::COLON }, - { '\'', Key::APOSTROPHE }, - { '\"', Key::QUOTEDBL }, - { '\\', Key::BACKSLASH }, - { '#', Key::NUMBERSIGN }, - { 'z', Key::Z }, - { 'x', Key::X }, - { 'c', Key::C }, - { 'v', Key::V }, - { 'b', Key::B }, - { 'n', Key::N }, - { 'm', Key::M }, - { ',', Key::COMMA }, - { '.', Key::PERIOD }, - { '/', Key::SLASH } -}; - // Remap key according to current keyboard layout. -Key KeyMappingMacOS::remap_key(unsigned int key, unsigned int state) { - if (is_numpad_key(key)) { - return translate_key(key); +Key KeyMappingMacOS::remap_key(unsigned int p_key, unsigned int p_state, bool p_unicode) { + if (is_numpad_key(p_key)) { + return translate_key(p_key); } TISInputSourceRef current_keyboard = TISCopyCurrentKeyboardInputSource(); if (!current_keyboard) { - return translate_key(key); + return translate_key(p_key); } CFDataRef layout_data = (CFDataRef)TISGetInputSourceProperty(current_keyboard, kTISPropertyUnicodeKeyLayoutData); if (!layout_data) { - return translate_key(key); + return translate_key(p_key); } const UCKeyboardLayout *keyboard_layout = (const UCKeyboardLayout *)CFDataGetBytePtr(layout_data); + String keysym; UInt32 keys_down = 0; - UniChar chars[4]; - UniCharCount real_length; + UniChar chars[256] = {}; + UniCharCount real_length = 0; OSStatus err = UCKeyTranslate(keyboard_layout, - key, + p_key, kUCKeyActionDisplay, - (state >> 8) & 0xFF, + (p_unicode) ? 0 : (p_state >> 8) & 0xFF, LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, &keys_down, @@ -312,165 +380,26 @@ Key KeyMappingMacOS::remap_key(unsigned int key, unsigned int state) { chars); if (err != noErr) { - return translate_key(key); + return translate_key(p_key); } - for (unsigned int i = 0; i < 55; i++) { - if (_keycodes[i].kchar == chars[0]) { - return _keycodes[i].kcode; - } + keysym = String::utf16((char16_t *)chars, real_length); + if (keysym.is_empty()) { + return translate_key(p_key); } - return translate_key(key); -} - -struct _KeyCodeText { - Key code; - char32_t text; -}; -static const _KeyCodeText _native_keycodes[] = { - /* clang-format off */ - {Key::ESCAPE ,0x001B}, - {Key::TAB ,0x0009}, - {Key::BACKTAB ,0x007F}, - {Key::BACKSPACE ,0x0008}, - {Key::ENTER ,0x000D}, - {Key::INSERT ,NSInsertFunctionKey}, - {Key::KEY_DELETE ,0x007F}, - {Key::PAUSE ,NSPauseFunctionKey}, - {Key::PRINT ,NSPrintScreenFunctionKey}, - {Key::SYSREQ ,NSSysReqFunctionKey}, - {Key::CLEAR ,NSClearLineFunctionKey}, - {Key::HOME ,0x2196}, - {Key::END ,0x2198}, - {Key::LEFT ,0x001C}, - {Key::UP ,0x001E}, - {Key::RIGHT ,0x001D}, - {Key::DOWN ,0x001F}, - {Key::PAGEUP ,0x21DE}, - {Key::PAGEDOWN ,0x21DF}, - {Key::NUMLOCK ,NSClearLineFunctionKey}, - {Key::SCROLLLOCK ,NSScrollLockFunctionKey}, - {Key::F1 ,NSF1FunctionKey}, - {Key::F2 ,NSF2FunctionKey}, - {Key::F3 ,NSF3FunctionKey}, - {Key::F4 ,NSF4FunctionKey}, - {Key::F5 ,NSF5FunctionKey}, - {Key::F6 ,NSF6FunctionKey}, - {Key::F7 ,NSF7FunctionKey}, - {Key::F8 ,NSF8FunctionKey}, - {Key::F9 ,NSF9FunctionKey}, - {Key::F10 ,NSF10FunctionKey}, - {Key::F11 ,NSF11FunctionKey}, - {Key::F12 ,NSF12FunctionKey}, - {Key::F13 ,NSF13FunctionKey}, - {Key::F14 ,NSF14FunctionKey}, - {Key::F15 ,NSF15FunctionKey}, - {Key::F16 ,NSF16FunctionKey}, - {Key::F17 ,NSF17FunctionKey}, - {Key::F18 ,NSF18FunctionKey}, - {Key::F19 ,NSF19FunctionKey}, - {Key::F20 ,NSF20FunctionKey}, - {Key::F21 ,NSF21FunctionKey}, - {Key::F22 ,NSF22FunctionKey}, - {Key::F23 ,NSF23FunctionKey}, - {Key::F24 ,NSF24FunctionKey}, - {Key::F25 ,NSF25FunctionKey}, - {Key::F26 ,NSF26FunctionKey}, - {Key::F27 ,NSF27FunctionKey}, - {Key::F28 ,NSF28FunctionKey}, - {Key::F29 ,NSF29FunctionKey}, - {Key::F30 ,NSF30FunctionKey}, - {Key::F31 ,NSF31FunctionKey}, - {Key::F32 ,NSF32FunctionKey}, - {Key::F33 ,NSF33FunctionKey}, - {Key::F34 ,NSF34FunctionKey}, - {Key::F35 ,NSF35FunctionKey}, - {Key::MENU ,NSMenuFunctionKey}, - {Key::HELP ,NSHelpFunctionKey}, - {Key::STOP ,NSStopFunctionKey}, - {Key::LAUNCH0 ,NSUserFunctionKey}, - {Key::SPACE ,0x0020}, - {Key::EXCLAM ,'!'}, - {Key::QUOTEDBL ,'\"'}, - {Key::NUMBERSIGN ,'#'}, - {Key::DOLLAR ,'$'}, - {Key::PERCENT ,'\%'}, - {Key::AMPERSAND ,'&'}, - {Key::APOSTROPHE ,'\''}, - {Key::PARENLEFT ,'('}, - {Key::PARENRIGHT ,')'}, - {Key::ASTERISK ,'*'}, - {Key::PLUS ,'+'}, - {Key::COMMA ,','}, - {Key::MINUS ,'-'}, - {Key::PERIOD ,'.'}, - {Key::SLASH ,'/'}, - {Key::KEY_0 ,'0'}, - {Key::KEY_1 ,'1'}, - {Key::KEY_2 ,'2'}, - {Key::KEY_3 ,'3'}, - {Key::KEY_4 ,'4'}, - {Key::KEY_5 ,'5'}, - {Key::KEY_6 ,'6'}, - {Key::KEY_7 ,'7'}, - {Key::KEY_8 ,'8'}, - {Key::KEY_9 ,'9'}, - {Key::COLON ,':'}, - {Key::SEMICOLON ,';'}, - {Key::LESS ,'<'}, - {Key::EQUAL ,'='}, - {Key::GREATER ,'>'}, - {Key::QUESTION ,'?'}, - {Key::AT ,'@'}, - {Key::A ,'a'}, - {Key::B ,'b'}, - {Key::C ,'c'}, - {Key::D ,'d'}, - {Key::E ,'e'}, - {Key::F ,'f'}, - {Key::G ,'g'}, - {Key::H ,'h'}, - {Key::I ,'i'}, - {Key::J ,'j'}, - {Key::K ,'k'}, - {Key::L ,'l'}, - {Key::M ,'m'}, - {Key::N ,'n'}, - {Key::O ,'o'}, - {Key::P ,'p'}, - {Key::Q ,'q'}, - {Key::R ,'r'}, - {Key::S ,'s'}, - {Key::T ,'t'}, - {Key::U ,'u'}, - {Key::V ,'v'}, - {Key::W ,'w'}, - {Key::X ,'x'}, - {Key::Y ,'y'}, - {Key::Z ,'z'}, - {Key::BRACKETLEFT ,'['}, - {Key::BACKSLASH ,'\\'}, - {Key::BRACKETRIGHT ,']'}, - {Key::ASCIICIRCUM ,'^'}, - {Key::UNDERSCORE ,'_'}, - {Key::QUOTELEFT ,'`'}, - {Key::BRACELEFT ,'{'}, - {Key::BAR ,'|'}, - {Key::BRACERIGHT ,'}'}, - {Key::ASCIITILDE ,'~'}, - {Key::NONE ,0x0000} - /* clang-format on */ -}; + char32_t c = keysym[0]; + if (p_unicode) { + return fix_key_label(c, translate_key(p_key)); + } else { + return fix_keycode(c, translate_key(p_key)); + } +} String KeyMappingMacOS::keycode_get_native_string(Key p_keycode) { - const _KeyCodeText *kct = &_native_keycodes[0]; - - while (kct->text) { - if (kct->code == p_keycode) { - return String::chr(kct->text); - } - kct++; + const char32_t *key = keycode_map.getptr(p_keycode); + if (key) { + return String::chr(*key); } return String(); } diff --git a/platform/web/display_server_web.cpp b/platform/web/display_server_web.cpp index fdb9d107a7..d71fd60543 100644 --- a/platform/web/display_server_web.cpp +++ b/platform/web/display_server_web.cpp @@ -121,18 +121,25 @@ void DisplayServerWeb::key_callback(int p_pressed, int p_repeat, int p_modifiers // Resume audio context after input in case autoplay was denied. OS_Web::get_singleton()->resume_audio(); + char32_t c = 0x00; + String unicode = String::utf8(key_event.key); + if (unicode.length() == 1) { + c = unicode[0]; + } + + Key keycode = dom_code2godot_scancode(key_event.code, key_event.key, false); + Key scancode = dom_code2godot_scancode(key_event.code, key_event.key, true); + Ref<InputEventKey> ev; ev.instantiate(); ev->set_echo(p_repeat); - ev->set_keycode(dom_code2godot_scancode(key_event.code, key_event.key, false)); - ev->set_physical_keycode(dom_code2godot_scancode(key_event.code, key_event.key, true)); + ev->set_keycode(fix_keycode(c, keycode)); + ev->set_physical_keycode(scancode); + ev->set_key_label(fix_key_label(c, keycode)); + ev->set_unicode(fix_unicode(c)); ev->set_pressed(p_pressed); dom2godot_mod(ev, p_modifiers); - String unicode = String::utf8(key_event.key); - if (unicode.length() == 1) { - ev->set_unicode(unicode[0]); - } Input::get_singleton()->parse_input_event(ev); // Make sure to flush all events so we can call restricted APIs inside the event. diff --git a/platform/web/dom_keys.inc b/platform/web/dom_keys.inc index 5f8d921bfb..e63bd7c69f 100644 --- a/platform/web/dom_keys.inc +++ b/platform/web/dom_keys.inc @@ -32,9 +32,9 @@ // See https://w3c.github.io/uievents-code/#code-value-tables Key dom_code2godot_scancode(EM_UTF8 const p_code[32], EM_UTF8 const p_key[32], bool p_physical) { -#define DOM2GODOT(p_str, p_godot_code) \ - if (memcmp((const void *)p_str, (void *)p_code, strlen(p_str) + 1) == 0) { \ - return Key::p_godot_code; \ +#define DOM2GODOT(p_str, p_godot_code) \ + if (memcmp((const void *)p_str, (void *)(p_physical ? p_key : p_code), strlen(p_str) + 1) == 0) { \ + return Key::p_godot_code; \ } // Numpad section. @@ -70,35 +70,6 @@ Key dom_code2godot_scancode(EM_UTF8 const p_code[32], EM_UTF8 const p_key[32], b DOM2GODOT("NumpadStar", KP_MULTIPLY); // or ASTERISK ? DOM2GODOT("NumpadSubtract", KP_SUBTRACT); - // Printable ASCII. - if (!p_physical) { - uint8_t b0 = (uint8_t)p_key[0]; - uint8_t b1 = (uint8_t)p_key[1]; - uint8_t b2 = (uint8_t)p_key[2]; - if (b1 == 0 && b0 > 0x1F && b0 < 0x7F) { // ASCII. - if (b0 > 0x60 && b0 < 0x7B) { // Lowercase ASCII. - b0 -= 32; - } - return (Key)b0; - } - -#define _U_2BYTES_MASK 0xE0 -#define _U_2BYTES 0xC0 - // Latin-1 codes. - if (b2 == 0 && (b0 & _U_2BYTES_MASK) == _U_2BYTES) { // 2-bytes utf8, only known latin. - uint32_t key = ((b0 & ~_U_2BYTES_MASK) << 6) | (b1 & 0x3F); - if (key >= 0xA0 && key <= 0xDF) { - return (Key)key; - } - if (key >= 0xE0 && key <= 0xFF) { // Lowercase known latin. - key -= 0x20; - return (Key)key; - } - } -#undef _U_2BYTES_MASK -#undef _U_2BYTES - } - // Alphanumeric section. DOM2GODOT("Backquote", QUOTELEFT); DOM2GODOT("Backslash", BACKSLASH); @@ -162,8 +133,8 @@ Key dom_code2godot_scancode(EM_UTF8 const p_code[32], EM_UTF8 const p_key[32], b DOM2GODOT("ControlLeft", CTRL); DOM2GODOT("ControlRight", CTRL); DOM2GODOT("Enter", ENTER); - DOM2GODOT("MetaLeft", SUPER_L); - DOM2GODOT("MetaRight", SUPER_R); + DOM2GODOT("MetaLeft", META); + DOM2GODOT("MetaRight", META); DOM2GODOT("ShiftLeft", SHIFT); DOM2GODOT("ShiftRight", SHIFT); DOM2GODOT("Space", SPACE); @@ -227,6 +198,21 @@ Key dom_code2godot_scancode(EM_UTF8 const p_code[32], EM_UTF8 const p_key[32], b DOM2GODOT("AudioVolumeMute", VOLUMEMUTE); DOM2GODOT("AudioVolumeUp", VOLUMEUP); //DOM2GODOT("WakeUp", UNKNOWN); - return Key::UNKNOWN; + + // Printable ASCII. + uint8_t b0 = (uint8_t)p_key[0]; + uint8_t b1 = (uint8_t)p_key[1]; + if (b0 >= 0x20 && b0 < 0x7F) { // ASCII. + if (b0 > 0x60 && b0 < 0x7B) { // Lowercase ASCII. + b0 -= 32; + } + return (Key)b0; + } else if (b0 == 0xC2 && b1 == 0xA5) { + return Key::YEN; + } else if (b0 == 0xC2 && b1 == 0xA7) { + return Key::SECTION; + } + + return Key::NONE; #undef DOM2GODOT } diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 631543763b..89a7114583 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -1610,6 +1610,58 @@ bool DisplayServerWindows::can_any_window_draw() const { return false; } +Vector2i DisplayServerWindows::ime_get_selection() const { + _THREAD_SAFE_METHOD_ + + DisplayServer::WindowID window_id = _get_focused_window_or_popup(); + const WindowData &wd = windows[window_id]; + if (!wd.ime_active) { + return Vector2i(); + } + + int cursor = ImmGetCompositionStringW(wd.im_himc, GCS_CURSORPOS, nullptr, 0); + + int32_t length = ImmGetCompositionStringW(wd.im_himc, GCS_COMPSTR, nullptr, 0); + wchar_t *string = reinterpret_cast<wchar_t *>(memalloc(length)); + ImmGetCompositionStringW(wd.im_himc, GCS_COMPSTR, string, length); + + int32_t utf32_cursor = 0; + for (int32_t i = 0; i < length / sizeof(wchar_t); i++) { + if ((string[i] & 0xfffffc00) == 0xd800) { + i++; + } + if (i < cursor) { + utf32_cursor++; + } else { + break; + } + } + + memdelete(string); + + return Vector2i(utf32_cursor, 0); +} + +String DisplayServerWindows::ime_get_text() const { + _THREAD_SAFE_METHOD_ + + DisplayServer::WindowID window_id = _get_focused_window_or_popup(); + const WindowData &wd = windows[window_id]; + if (!wd.ime_active) { + return String(); + } + + String ret; + int32_t length = ImmGetCompositionStringW(wd.im_himc, GCS_COMPSTR, nullptr, 0); + wchar_t *string = reinterpret_cast<wchar_t *>(memalloc(length)); + ImmGetCompositionStringW(wd.im_himc, GCS_COMPSTR, string, length); + ret.parse_utf16((char16_t *)string, length / sizeof(wchar_t)); + + memdelete(string); + + return ret; +} + void DisplayServerWindows::window_set_ime_active(const bool p_active, WindowID p_window) { _THREAD_SAFE_METHOD_ @@ -1617,11 +1669,14 @@ void DisplayServerWindows::window_set_ime_active(const bool p_active, WindowID p WindowData &wd = windows[p_window]; if (p_active) { + wd.ime_active = true; ImmAssociateContext(wd.hWnd, wd.im_himc); - + CreateCaret(wd.hWnd, NULL, 1, 1); window_set_ime_position(wd.im_position, p_window); } else { ImmAssociateContext(wd.hWnd, (HIMC)0); + DestroyCaret(); + wd.ime_active = false; } } @@ -1639,7 +1694,7 @@ void DisplayServerWindows::window_set_ime_position(const Point2i &p_pos, WindowI } COMPOSITIONFORM cps; - cps.dwStyle = CFS_FORCE_POSITION; + cps.dwStyle = CFS_POINT; cps.ptCurrentPos.x = wd.im_position.x; cps.ptCurrentPos.y = wd.im_position.y; ImmSetCompositionWindow(himc, &cps); @@ -3353,10 +3408,18 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA windows[window_id].focus_timer_id = 0U; } } break; - case WM_SYSKEYDOWN: case WM_SYSKEYUP: case WM_KEYUP: + if (windows[window_id].ime_suppress_next_keyup) { + windows[window_id].ime_suppress_next_keyup = false; + break; + } + [[fallthrough]]; + case WM_SYSKEYDOWN: case WM_KEYDOWN: { + if (windows[window_id].ime_in_progress) { + break; + } if (wParam == VK_SHIFT) { shift_mem = (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN); } @@ -3402,9 +3465,49 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA key_event_buffer[key_event_pos++] = ke; } break; + case WM_IME_COMPOSITION: { + CANDIDATEFORM cf; + cf.dwIndex = 0; + + cf.dwStyle = CFS_CANDIDATEPOS; + cf.ptCurrentPos.x = windows[window_id].im_position.x; + cf.ptCurrentPos.y = windows[window_id].im_position.y; + ImmSetCandidateWindow(windows[window_id].im_himc, &cf); + + cf.dwStyle = CFS_EXCLUDE; + cf.rcArea.left = windows[window_id].im_position.x; + cf.rcArea.right = windows[window_id].im_position.x; + cf.rcArea.top = windows[window_id].im_position.y; + cf.rcArea.bottom = windows[window_id].im_position.y; + ImmSetCandidateWindow(windows[window_id].im_himc, &cf); + + if (windows[window_id].ime_active) { + SetCaretPos(windows[window_id].im_position.x, windows[window_id].im_position.y); + OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_OS_IME_UPDATE); + } + } break; case WM_INPUTLANGCHANGEREQUEST: { // FIXME: Do something? } break; + case WM_IME_STARTCOMPOSITION: { + if (windows[window_id].ime_active) { + windows[window_id].ime_in_progress = true; + if (key_event_pos > 0) { + key_event_pos--; + } + } + return 0; + } break; + case WM_IME_ENDCOMPOSITION: { + if (windows[window_id].ime_active) { + windows[window_id].ime_in_progress = false; + windows[window_id].ime_suppress_next_keyup = true; + } + return 0; + } break; + case WM_IME_NOTIFY: { + return 0; + } break; case WM_TOUCH: { BOOL bHandled = FALSE; UINT cInputs = LOWORD(wParam); @@ -3513,6 +3616,7 @@ void DisplayServerWindows::_process_activate_event(WindowID p_window_id, WPARAM alt_mem = false; control_mem = false; shift_mem = false; + gr_mem = false; // Restore mouse mode. _set_mouse_mode_impl(mouse_mode); @@ -3556,24 +3660,36 @@ void DisplayServerWindows::_process_key_events() { Ref<InputEventKey> k; k.instantiate(); + Key keycode = KeyMappingWindows::get_keysym(MapVirtualKey((ke.lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK)); + Key key_label = keycode; + Key physical_keycode = KeyMappingWindows::get_scansym((ke.lParam >> 16) & 0xFF, ke.lParam & (1 << 24)); + + static BYTE keyboard_state[256]; + memset(keyboard_state, 0, 256); + wchar_t chars[256] = {}; + UINT extended_code = MapVirtualKey((ke.lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK_EX); + if (!(ke.lParam & (1 << 24)) && ToUnicodeEx(extended_code, (ke.lParam >> 16) & 0xFF, keyboard_state, chars, 255, 4, GetKeyboardLayout(0)) > 0) { + String keysym = String::utf16((char16_t *)chars, 255); + if (!keysym.is_empty()) { + key_label = fix_key_label(keysym[0], keycode); + } + } + k->set_window_id(ke.window_id); k->set_shift_pressed(ke.shift); k->set_alt_pressed(ke.alt); k->set_ctrl_pressed(ke.control); k->set_meta_pressed(ke.meta); k->set_pressed(true); - k->set_keycode((Key)KeyMappingWindows::get_keysym(MapVirtualKey((ke.lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK))); - k->set_physical_keycode((Key)(KeyMappingWindows::get_scansym((ke.lParam >> 16) & 0xFF, ke.lParam & (1 << 24)))); - k->set_unicode(unicode); + k->set_keycode(keycode); + k->set_physical_keycode(physical_keycode); + k->set_key_label(key_label); + k->set_unicode(fix_unicode(unicode)); if (k->get_unicode() && gr_mem) { k->set_alt_pressed(false); k->set_ctrl_pressed(false); } - if (k->get_unicode() < 32) { - k->set_unicode(0); - } - Input::get_singleton()->parse_input_event(k); } else { // Do nothing. @@ -3592,14 +3708,28 @@ void DisplayServerWindows::_process_key_events() { k->set_pressed(ke.uMsg == WM_KEYDOWN); + Key keycode = KeyMappingWindows::get_keysym(ke.wParam); if ((ke.lParam & (1 << 24)) && (ke.wParam == VK_RETURN)) { // Special case for Numpad Enter key. - k->set_keycode(Key::KP_ENTER); - } else { - k->set_keycode((Key)KeyMappingWindows::get_keysym(ke.wParam)); + keycode = Key::KP_ENTER; + } + Key key_label = keycode; + Key physical_keycode = KeyMappingWindows::get_scansym((ke.lParam >> 16) & 0xFF, ke.lParam & (1 << 24)); + + static BYTE keyboard_state[256]; + memset(keyboard_state, 0, 256); + wchar_t chars[256] = {}; + UINT extended_code = MapVirtualKey((ke.lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK_EX); + if (!(ke.lParam & (1 << 24)) && ToUnicodeEx(extended_code, (ke.lParam >> 16) & 0xFF, keyboard_state, chars, 255, 4, GetKeyboardLayout(0)) > 0) { + String keysym = String::utf16((char16_t *)chars, 255); + if (!keysym.is_empty()) { + key_label = fix_key_label(keysym[0], keycode); + } } - k->set_physical_keycode((Key)(KeyMappingWindows::get_scansym((ke.lParam >> 16) & 0xFF, ke.lParam & (1 << 24)))); + k->set_keycode(keycode); + k->set_physical_keycode(physical_keycode); + k->set_key_label(key_label); if (i + 1 < key_event_pos && key_event_buffer[i + 1].uMsg == WM_CHAR) { char32_t unicode = key_event_buffer[i + 1].wParam; @@ -3620,17 +3750,13 @@ void DisplayServerWindows::_process_key_events() { } else { prev_wck = 0; } - k->set_unicode(unicode); + k->set_unicode(fix_unicode(unicode)); } if (k->get_unicode() && gr_mem) { k->set_alt_pressed(false); k->set_ctrl_pressed(false); } - if (k->get_unicode() < 32) { - k->set_unicode(0); - } - k->set_echo((ke.uMsg == WM_KEYDOWN && (ke.lParam & (1 << 30)))); Input::get_singleton()->parse_input_event(k); @@ -3841,7 +3967,7 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode, // IME. wd.im_himc = ImmGetContext(wd.hWnd); - ImmReleaseContext(wd.hWnd, wd.im_himc); + ImmAssociateContext(wd.hWnd, (HIMC)0); wd.im_position = Vector2(); @@ -3935,6 +4061,8 @@ void DisplayServerWindows::tablet_set_current_driver(const String &p_driver) { } DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Error &r_error) { + KeyMappingWindows::initialize(); + drop_events = false; key_event_pos = 0; @@ -4042,7 +4170,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win wc.lpszClassName = L"Engine"; if (!RegisterClassExW(&wc)) { - MessageBox(nullptr, "Failed To Register The Window Class.", "ERROR", MB_OK | MB_ICONEXCLAMATION); + MessageBoxW(nullptr, L"Failed To Register The Window Class.", L"ERROR", MB_OK | MB_ICONEXCLAMATION); r_error = ERR_UNAVAILABLE; return; } @@ -4121,7 +4249,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win // from making the system unresponsive. SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS); DWORD index = 0; - HANDLE handle = AvSetMmThreadCharacteristics("Games", &index); + HANDLE handle = AvSetMmThreadCharacteristicsW(L"Games", &index); if (handle) { AvSetMmThreadPriority(handle, AVRT_PRIORITY_CRITICAL); } diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index ce4b94af59..0d2137d048 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -405,6 +405,9 @@ class DisplayServerWindows : public DisplayServer { // IME HIMC im_himc; Vector2 im_position; + bool ime_active = false; + bool ime_in_progress = false; + bool ime_suppress_next_keyup = false; bool layered_window = false; @@ -592,6 +595,9 @@ public: virtual void window_set_ime_active(const bool p_active, WindowID p_window = MAIN_WINDOW_ID) override; virtual void window_set_ime_position(const Point2i &p_pos, WindowID p_window = MAIN_WINDOW_ID) override; + virtual Point2i ime_get_selection() const override; + virtual String ime_get_text() const override; + virtual void window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window = MAIN_WINDOW_ID) override; virtual DisplayServer::VSyncMode window_get_vsync_mode(WindowID p_vsync_mode) const override; diff --git a/platform/windows/export/export_plugin.cpp b/platform/windows/export/export_plugin.cpp index bf32b16018..4107a8a17e 100644 --- a/platform/windows/export/export_plugin.cpp +++ b/platform/windows/export/export_plugin.cpp @@ -831,8 +831,8 @@ Error EditorExportPlatformWindows::run(const Ref<EditorExportPreset> &p_preset, if (port.is_empty()) { port = "22"; } - Vector<String> extra_args_ssh = p_preset->get("ssh_remote_deploy/extra_args_ssh").operator String().split(" "); - Vector<String> extra_args_scp = p_preset->get("ssh_remote_deploy/extra_args_scp").operator String().split(" "); + Vector<String> extra_args_ssh = p_preset->get("ssh_remote_deploy/extra_args_ssh").operator String().split(" ", false); + Vector<String> extra_args_scp = p_preset->get("ssh_remote_deploy/extra_args_scp").operator String().split(" ", false); const String basepath = dest.path_join("tmp_windows_export"); diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp index 183958cf40..7ae26e6cf4 100644 --- a/platform/windows/joypad_windows.cpp +++ b/platform/windows/joypad_windows.cpp @@ -101,10 +101,12 @@ bool JoypadWindows::is_xinput_device(const GUID *p_guid) { static GUID IID_ValveStreamingGamepad = { MAKELONG(0x28DE, 0x11FF), 0x28DE, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } }; static GUID IID_X360WiredGamepad = { MAKELONG(0x045E, 0x02A1), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } }; static GUID IID_X360WirelessGamepad = { MAKELONG(0x045E, 0x028E), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } }; + static GUID IID_XSWirelessGamepad = { MAKELONG(0x045E, 0x0B13), 0x0000, 0x0000, { 0x00, 0x00, 0x50, 0x49, 0x44, 0x56, 0x49, 0x44 } }; if (memcmp(p_guid, &IID_ValveStreamingGamepad, sizeof(*p_guid)) == 0 || memcmp(p_guid, &IID_X360WiredGamepad, sizeof(*p_guid)) == 0 || - memcmp(p_guid, &IID_X360WirelessGamepad, sizeof(*p_guid)) == 0) + memcmp(p_guid, &IID_X360WirelessGamepad, sizeof(*p_guid)) == 0 || + memcmp(p_guid, &IID_XSWirelessGamepad, sizeof(*p_guid)) == 0) return true; PRAWINPUTDEVICELIST dev_list = nullptr; diff --git a/platform/windows/key_mapping_windows.cpp b/platform/windows/key_mapping_windows.cpp index 86471f188f..d43f74126d 100644 --- a/platform/windows/key_mapping_windows.cpp +++ b/platform/windows/key_mapping_windows.cpp @@ -30,490 +30,386 @@ #include "key_mapping_windows.h" -#include <stdio.h> +#include "core/templates/hash_map.h" // This provides translation from Windows virtual key codes to Godot and back. // See WinUser.h and the below for documentation: // https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes -struct _WinTranslatePair { - Key keysym; - unsigned int keycode; +struct HashMapHasherKeys { + static _FORCE_INLINE_ uint32_t hash(const Key p_key) { return hash_fmix32(static_cast<uint32_t>(p_key)); } + static _FORCE_INLINE_ uint32_t hash(const char32_t p_uchar) { return hash_fmix32(p_uchar); } + static _FORCE_INLINE_ uint32_t hash(const unsigned p_key) { return hash_fmix32(p_key); } }; -static _WinTranslatePair _vk_to_keycode[] = { +HashMap<unsigned int, Key, HashMapHasherKeys> vk_map; +HashMap<unsigned int, Key, HashMapHasherKeys> scansym_map; +HashMap<Key, unsigned int, HashMapHasherKeys> scansym_map_inv; +HashMap<unsigned int, Key, HashMapHasherKeys> scansym_map_ext; + +void KeyMappingWindows::initialize() { // VK_LBUTTON (0x01) // VK_RBUTTON (0x02) // VK_CANCEL (0x03) // VK_MBUTTON (0x04) // VK_XBUTTON1 (0x05) - // VK_XBUTTON2 (0x06) - // We have no mappings for the above, as we only map keyboard buttons here. - + // VK_XBUTTON2 (0x06), We have no mappings for the above;as we only map keyboard buttons here. // 0x07 is undefined. - - { Key::BACKSPACE, VK_BACK }, // (0x08) - { Key::TAB, VK_TAB }, // (0x09) - + vk_map[VK_BACK] = Key::BACKSPACE; // (0x08) + vk_map[VK_TAB] = Key::TAB; // (0x09) // 0x0A-0B are reserved. - - { Key::CLEAR, VK_CLEAR }, // (0x0C) - { Key::ENTER, VK_RETURN }, // (0x0D) - + vk_map[VK_CLEAR] = Key::CLEAR; // (0x0C) + vk_map[VK_RETURN] = Key::ENTER; // (0x0D) // 0x0E-0F are undefined. - - { Key::SHIFT, VK_SHIFT }, // (0x10) - { Key::CTRL, VK_CONTROL }, // (0x11) - { Key::ALT, VK_MENU }, // (0x12) - { Key::PAUSE, VK_PAUSE }, // (0x13) - { Key::CAPSLOCK, VK_CAPITAL }, // (0x14) - - // 0x15-1A are IME keys. We have no mapping. - - { Key::ESCAPE, VK_ESCAPE }, // (0x1B) - - // 0x1C-1F are IME keys. We have no mapping. - - { Key::SPACE, VK_SPACE }, // (0x20) - { Key::PAGEUP, VK_PRIOR }, // (0x21) - { Key::PAGEDOWN, VK_NEXT }, // (0x22) - { Key::END, VK_END }, // (0x23) - { Key::HOME, VK_HOME }, // (0x24) - { Key::LEFT, VK_LEFT }, // (0x25) - { Key::UP, VK_UP }, // (0x26) - { Key::RIGHT, VK_RIGHT }, // (0x27) - { Key::DOWN, VK_DOWN }, // (0x28) - - // VK_SELECT (0x29) - // Old select key, e.g. on Digital Equipment Corporation keyboards. - // Old and uncommon, we have no mapping. - - { Key::PRINT, VK_PRINT }, // (0x2A) - // Old IBM key, modern keyboards use VK_SNAPSHOT. Map to VK_SNAPSHOT. - - // VK_EXECUTE (0x2B) - // Old and uncommon, we have no mapping. - - { Key::PRINT, VK_SNAPSHOT }, // (0x2C) - { Key::INSERT, VK_INSERT }, // (0x2D) - { Key::KEY_DELETE, VK_DELETE }, // (0x2E) - - { Key::HELP, VK_HELP }, // (0x2F) - // Old and uncommon, but we have a mapping. - - { Key::KEY_0, (0x30) }, // 0 key. - { Key::KEY_1, (0x31) }, // 1 key. - { Key::KEY_2, (0x32) }, // 2 key. - { Key::KEY_3, (0x33) }, // 3 key. - { Key::KEY_4, (0x34) }, // 4 key. - { Key::KEY_5, (0x35) }, // 5 key. - { Key::KEY_6, (0x36) }, // 6 key. - { Key::KEY_7, (0x37) }, // 7 key. - { Key::KEY_8, (0x38) }, // 8 key. - { Key::KEY_9, (0x39) }, // 9 key. + vk_map[VK_SHIFT] = Key::SHIFT; // (0x10) + vk_map[VK_CONTROL] = Key::CTRL; // (0x11) + vk_map[VK_MENU] = Key::ALT; // (0x12) + vk_map[VK_PAUSE] = Key::PAUSE; // (0x13) + vk_map[VK_CAPITAL] = Key::CAPSLOCK; // (0x14) + // 0x15-1A are IME keys. + vk_map[VK_ESCAPE] = Key::ESCAPE; // (0x1B) + // 0x1C-1F are IME keys. + vk_map[VK_SPACE] = Key::SPACE; // (0x20) + vk_map[VK_PRIOR] = Key::PAGEUP; // (0x21) + vk_map[VK_NEXT] = Key::PAGEDOWN; // (0x22) + vk_map[VK_END] = Key::END; // (0x23) + vk_map[VK_HOME] = Key::HOME; // (0x24) + vk_map[VK_LEFT] = Key::LEFT; // (0x25) + vk_map[VK_UP] = Key::UP; // (0x26) + vk_map[VK_RIGHT] = Key::RIGHT; // (0x27) + vk_map[VK_DOWN] = Key::DOWN; // (0x28) + // VK_SELECT (0x29), Old select key; e.g. on Digital Equipment Corporation keyboards. + vk_map[VK_PRINT] = Key::PRINT; // (0x2A), Old IBM key; modern keyboards use VK_SNAPSHOT. + // VK_EXECUTE (0x2B), Old and uncommon. + vk_map[VK_SNAPSHOT] = Key::PRINT; // (0x2C) + vk_map[VK_INSERT] = Key::INSERT; // (0x2D) + vk_map[VK_DELETE] = Key::KEY_DELETE; // (0x2E) + vk_map[VK_HELP] = Key::HELP; // (0x2F) + vk_map[0x30] = Key::KEY_0; // 0 key. + vk_map[0x31] = Key::KEY_1; // 1 key. + vk_map[0x32] = Key::KEY_2; // 2 key. + vk_map[0x33] = Key::KEY_3; // 3 key. + vk_map[0x34] = Key::KEY_4; // 4 key. + vk_map[0x35] = Key::KEY_5; // 5 key. + vk_map[0x36] = Key::KEY_6; // 6 key. + vk_map[0x37] = Key::KEY_7; // 7 key. + vk_map[0x38] = Key::KEY_8; // 8 key. + vk_map[0x39] = Key::KEY_9; // 9 key. // 0x3A-40 are undefined. - { Key::A, (0x41) }, // A key. - { Key::B, (0x42) }, // B key. - { Key::C, (0x43) }, // C key. - { Key::D, (0x44) }, // D key. - { Key::E, (0x45) }, // E key. - { Key::F, (0x46) }, // F key. - { Key::G, (0x47) }, // G key. - { Key::H, (0x48) }, // H key. - { Key::I, (0x49) }, // I key - { Key::J, (0x4A) }, // J key. - { Key::K, (0x4B) }, // K key. - { Key::L, (0x4C) }, // L key. - { Key::M, (0x4D) }, // M key. - { Key::N, (0x4E) }, // N key. - { Key::O, (0x4F) }, // O key. - { Key::P, (0x50) }, // P key. - { Key::Q, (0x51) }, // Q key. - { Key::R, (0x52) }, // R key. - { Key::S, (0x53) }, // S key. - { Key::T, (0x54) }, // T key. - { Key::U, (0x55) }, // U key. - { Key::V, (0x56) }, // V key. - { Key::W, (0x57) }, // W key. - { Key::X, (0x58) }, // X key. - { Key::Y, (0x59) }, // Y key. - { Key::Z, (0x5A) }, // Z key. - - { (Key)KeyModifierMask::META, VK_LWIN }, // (0x5B) - { (Key)KeyModifierMask::META, VK_RWIN }, // (0x5C) - { Key::MENU, VK_APPS }, // (0x5D) + vk_map[0x41] = Key::A; // A key. + vk_map[0x42] = Key::B; // B key. + vk_map[0x43] = Key::C; // C key. + vk_map[0x44] = Key::D; // D key. + vk_map[0x45] = Key::E; // E key. + vk_map[0x46] = Key::F; // F key. + vk_map[0x47] = Key::G; // G key. + vk_map[0x48] = Key::H; // H key. + vk_map[0x49] = Key::I; // I key + vk_map[0x4A] = Key::J; // J key. + vk_map[0x4B] = Key::K; // K key. + vk_map[0x4C] = Key::L; // L key. + vk_map[0x4D] = Key::M; // M key. + vk_map[0x4E] = Key::N; // N key. + vk_map[0x4F] = Key::O; // O key. + vk_map[0x50] = Key::P; // P key. + vk_map[0x51] = Key::Q; // Q key. + vk_map[0x52] = Key::R; // R key. + vk_map[0x53] = Key::S; // S key. + vk_map[0x54] = Key::T; // T key. + vk_map[0x55] = Key::U; // U key. + vk_map[0x56] = Key::V; // V key. + vk_map[0x57] = Key::W; // W key. + vk_map[0x58] = Key::X; // X key. + vk_map[0x59] = Key::Y; // Y key. + vk_map[0x5A] = Key::Z; // Z key. + vk_map[VK_LWIN] = (Key)Key::META; // (0x5B) + vk_map[VK_RWIN] = (Key)Key::META; // (0x5C) + vk_map[VK_APPS] = Key::MENU; // (0x5D) // 0x5E is reserved. - { Key::STANDBY, VK_SLEEP }, // (0x5F) - { Key::KP_0, VK_NUMPAD0 }, // (0x60) - { Key::KP_1, VK_NUMPAD1 }, // (0x61) - { Key::KP_2, VK_NUMPAD2 }, // (0x62) - { Key::KP_3, VK_NUMPAD3 }, // (0x63) - { Key::KP_4, VK_NUMPAD4 }, // (0x64) - { Key::KP_5, VK_NUMPAD5 }, // (0x65) - { Key::KP_6, VK_NUMPAD6 }, // (0x66) - { Key::KP_7, VK_NUMPAD7 }, // (0x67) - { Key::KP_8, VK_NUMPAD8 }, // (0x68) - { Key::KP_9, VK_NUMPAD9 }, // (0x69) - { Key::KP_MULTIPLY, VK_MULTIPLY }, // (0x6A) - { Key::KP_ADD, VK_ADD }, // (0x6B) - { Key::KP_PERIOD, VK_SEPARATOR }, // (0x6C) - // VK_SEPERATOR (key 0x6C) is not found on US keyboards. - // It is used on some Brazilian and Far East keyboards. - // We don't have a direct mapping, map to period. - { Key::KP_SUBTRACT, VK_SUBTRACT }, // (0x6D) - { Key::KP_PERIOD, VK_DECIMAL }, // (0x6E) - { Key::KP_DIVIDE, VK_DIVIDE }, // (0x6F) - { Key::F1, VK_F1 }, // (0x70) - { Key::F2, VK_F2 }, // (0x71) - { Key::F3, VK_F3 }, // (0x72) - { Key::F4, VK_F4 }, // (0x73) - { Key::F5, VK_F5 }, // (0x74) - { Key::F6, VK_F6 }, // (0x75) - { Key::F7, VK_F7 }, // (0x76) - { Key::F8, VK_F8 }, // (0x77) - { Key::F9, VK_F9 }, // (0x78) - { Key::F10, VK_F10 }, // (0x79) - { Key::F11, VK_F11 }, // (0x7A) - { Key::F12, VK_F12 }, // (0x7B) - { Key::F13, VK_F13 }, // (0x7C) - { Key::F14, VK_F14 }, // (0x7D) - { Key::F15, VK_F15 }, // (0x7E) - { Key::F16, VK_F16 }, // (0x7F) - { Key::F17, VK_F17 }, // (0x80) - { Key::F18, VK_F18 }, // (0x81) - { Key::F19, VK_F19 }, // (0x82) - { Key::F20, VK_F20 }, // (0x83) - { Key::F21, VK_F21 }, // (0x84) - { Key::F22, VK_F22 }, // (0x85) - { Key::F23, VK_F23 }, // (0x86) - { Key::F24, VK_F24 }, // (0x87) + vk_map[VK_SLEEP] = Key::STANDBY; // (0x5F) + vk_map[VK_NUMPAD0] = Key::KP_0; // (0x60) + vk_map[VK_NUMPAD1] = Key::KP_1; // (0x61) + vk_map[VK_NUMPAD2] = Key::KP_2; // (0x62) + vk_map[VK_NUMPAD3] = Key::KP_3; // (0x63) + vk_map[VK_NUMPAD4] = Key::KP_4; // (0x64) + vk_map[VK_NUMPAD5] = Key::KP_5; // (0x65) + vk_map[VK_NUMPAD6] = Key::KP_6; // (0x66) + vk_map[VK_NUMPAD7] = Key::KP_7; // (0x67) + vk_map[VK_NUMPAD8] = Key::KP_8; // (0x68) + vk_map[VK_NUMPAD9] = Key::KP_9; // (0x69) + vk_map[VK_MULTIPLY] = Key::KP_MULTIPLY; // (0x6A) + vk_map[VK_ADD] = Key::KP_ADD; // (0x6B) + vk_map[VK_SEPARATOR] = Key::KP_PERIOD; // (0x6C) + vk_map[VK_SUBTRACT] = Key::KP_SUBTRACT; // (0x6D) + vk_map[VK_DECIMAL] = Key::KP_PERIOD; // (0x6E) + vk_map[VK_DIVIDE] = Key::KP_DIVIDE; // (0x6F) + vk_map[VK_F1] = Key::F1; // (0x70) + vk_map[VK_F2] = Key::F2; // (0x71) + vk_map[VK_F3] = Key::F3; // (0x72) + vk_map[VK_F4] = Key::F4; // (0x73) + vk_map[VK_F5] = Key::F5; // (0x74) + vk_map[VK_F6] = Key::F6; // (0x75) + vk_map[VK_F7] = Key::F7; // (0x76) + vk_map[VK_F8] = Key::F8; // (0x77) + vk_map[VK_F9] = Key::F9; // (0x78) + vk_map[VK_F10] = Key::F10; // (0x79) + vk_map[VK_F11] = Key::F11; // (0x7A) + vk_map[VK_F12] = Key::F12; // (0x7B) + vk_map[VK_F13] = Key::F13; // (0x7C) + vk_map[VK_F14] = Key::F14; // (0x7D) + vk_map[VK_F15] = Key::F15; // (0x7E) + vk_map[VK_F16] = Key::F16; // (0x7F) + vk_map[VK_F17] = Key::F17; // (0x80) + vk_map[VK_F18] = Key::F18; // (0x81) + vk_map[VK_F19] = Key::F19; // (0x82) + vk_map[VK_F20] = Key::F20; // (0x83) + vk_map[VK_F21] = Key::F21; // (0x84) + vk_map[VK_F22] = Key::F22; // (0x85) + vk_map[VK_F23] = Key::F23; // (0x86) + vk_map[VK_F24] = Key::F24; // (0x87) // 0x88-8F are reserved for UI navigation. - { Key::NUMLOCK, VK_NUMLOCK }, // (0x90) - { Key::SCROLLLOCK, VK_SCROLL }, // (0x91) - - { Key::EQUAL, VK_OEM_NEC_EQUAL }, // (0x92) - // OEM NEC PC-9800 numpad '=' key. - - // 0x93-96 are OEM specific (e.g. used by Fujitsu/OASYS), we have no mappings. + vk_map[VK_NUMLOCK] = Key::NUMLOCK; // (0x90) + vk_map[VK_SCROLL] = Key::SCROLLLOCK; // (0x91) + vk_map[VK_OEM_NEC_EQUAL] = Key::EQUAL; // (0x92), OEM NEC PC-9800 numpad '=' key. + // 0x93-96 are OEM specific (e.g. used by Fujitsu/OASYS); // 0x97-9F are unassigned. - - { Key::SHIFT, VK_LSHIFT }, // (0xA0) - { Key::SHIFT, VK_RSHIFT }, // (0xA1) - { Key::CTRL, VK_LCONTROL }, // (0xA2) - { Key::CTRL, VK_RCONTROL }, // (0xA3) - { Key::MENU, VK_LMENU }, // (0xA4) - { Key::MENU, VK_RMENU }, // (0xA5) - - { Key::BACK, VK_BROWSER_BACK }, // (0xA6) - { Key::FORWARD, VK_BROWSER_FORWARD }, // (0xA7) - { Key::REFRESH, VK_BROWSER_REFRESH }, // (0xA8) - { Key::STOP, VK_BROWSER_STOP }, // (0xA9) - { Key::SEARCH, VK_BROWSER_SEARCH }, // (0xAA) - { Key::FAVORITES, VK_BROWSER_FAVORITES }, // (0xAB) - { Key::HOMEPAGE, VK_BROWSER_HOME }, // (0xAC) - { Key::VOLUMEMUTE, VK_VOLUME_MUTE }, // (0xAD) - { Key::VOLUMEDOWN, VK_VOLUME_DOWN }, // (0xAE) - { Key::VOLUMEUP, VK_VOLUME_UP }, // (0xAF) - { Key::MEDIANEXT, VK_MEDIA_NEXT_TRACK }, // (0xB0) - { Key::MEDIAPREVIOUS, VK_MEDIA_PREV_TRACK }, // (0xB1) - { Key::MEDIASTOP, VK_MEDIA_STOP }, // (0xB2) - - { Key::MEDIAPLAY, VK_MEDIA_PLAY_PAUSE }, // (0xB3) - // Media button play/pause toggle. - // Map to media play (there is no other 'play' mapping on Windows). - - { Key::LAUNCHMAIL, VK_LAUNCH_MAIL }, // (0xB4) - { Key::LAUNCHMEDIA, VK_LAUNCH_MEDIA_SELECT }, // (0xB5) - { Key::LAUNCH0, VK_LAUNCH_APP1 }, // (0xB6) - { Key::LAUNCH1, VK_LAUNCH_APP2 }, // (0xB7) - + vk_map[VK_LSHIFT] = Key::SHIFT; // (0xA0) + vk_map[VK_RSHIFT] = Key::SHIFT; // (0xA1) + vk_map[VK_LCONTROL] = Key::CTRL; // (0xA2) + vk_map[VK_RCONTROL] = Key::CTRL; // (0xA3) + vk_map[VK_LMENU] = Key::MENU; // (0xA4) + vk_map[VK_RMENU] = Key::MENU; // (0xA5) + vk_map[VK_BROWSER_BACK] = Key::BACK; // (0xA6) + vk_map[VK_BROWSER_FORWARD] = Key::FORWARD; // (0xA7) + vk_map[VK_BROWSER_REFRESH] = Key::REFRESH; // (0xA8) + vk_map[VK_BROWSER_STOP] = Key::STOP; // (0xA9) + vk_map[VK_BROWSER_SEARCH] = Key::SEARCH; // (0xAA) + vk_map[VK_BROWSER_FAVORITES] = Key::FAVORITES; // (0xAB) + vk_map[VK_BROWSER_HOME] = Key::HOMEPAGE; // (0xAC) + vk_map[VK_VOLUME_MUTE] = Key::VOLUMEMUTE; // (0xAD) + vk_map[VK_VOLUME_DOWN] = Key::VOLUMEDOWN; // (0xAE) + vk_map[VK_VOLUME_UP] = Key::VOLUMEUP; // (0xAF) + vk_map[VK_MEDIA_NEXT_TRACK] = Key::MEDIANEXT; // (0xB0) + vk_map[VK_MEDIA_PREV_TRACK] = Key::MEDIAPREVIOUS; // (0xB1) + vk_map[VK_MEDIA_STOP] = Key::MEDIASTOP; // (0xB2) + vk_map[VK_MEDIA_PLAY_PAUSE] = Key::MEDIAPLAY; // (0xB3), Media button play/pause toggle. + vk_map[VK_LAUNCH_MAIL] = Key::LAUNCHMAIL; // (0xB4) + vk_map[VK_LAUNCH_MEDIA_SELECT] = Key::LAUNCHMEDIA; // (0xB5) + vk_map[VK_LAUNCH_APP1] = Key::LAUNCH0; // (0xB6) + vk_map[VK_LAUNCH_APP2] = Key::LAUNCH1; // (0xB7) // 0xB8-B9 are reserved. - - { Key::SEMICOLON, VK_OEM_1 }, // (0xBA) - // Misc. character, can vary by keyboard/region. - // Windows 2000/XP: For US standard keyboards, the ';:' key. - - { Key::EQUAL, VK_OEM_PLUS }, // (0xBB) - // Windows 2000/XP: For any country/region, the '+' key. - { Key::COMMA, VK_OEM_COMMA }, // (0xBC) - // Windows 2000/XP: For any country/region, the ',' key. - { Key::MINUS, VK_OEM_MINUS }, // (0xBD) - // Windows 2000/XP: For any country/region, the '-' key. - { Key::PERIOD, VK_OEM_PERIOD }, // (0xBE) - // Windows 2000/XP: For any country/region, the '.' key. - - { Key::SLASH, VK_OEM_2 }, // (0xBF) - // Windows 2000/XP: For US standard keyboards, the '/?' key. - - { Key::QUOTELEFT, VK_OEM_3 }, // (0xC0) - // Windows 2000/XP: For US standard keyboards, the '`~' key. - + vk_map[VK_OEM_1] = Key::SEMICOLON; // (0xBA), Misc. character;can vary by keyboard/region. For US standard keyboards;the ';:' key. + vk_map[VK_OEM_PLUS] = Key::EQUAL; // (0xBB) + vk_map[VK_OEM_COMMA] = Key::COMMA; // (0xBC) + vk_map[VK_OEM_MINUS] = Key::MINUS; // (0xBD) + vk_map[VK_OEM_PERIOD] = Key::PERIOD; // (0xBE) + vk_map[VK_OEM_2] = Key::SLASH; // (0xBF), For US standard keyboards;the '/?' key. + vk_map[VK_OEM_3] = Key::QUOTELEFT; // (0xC0), For US standard keyboards;the '`~' key. // 0xC1-D7 are reserved. 0xD8-DA are unassigned. - // TODO: 0xC3-DA may be used for old gamepads? Maybe we want to support this? See WinUser.h. - - { Key::BRACKETLEFT, VK_OEM_4 }, // (0xDB) - // Misc. character, can vary by keyboard/region. - // Windows 2000/XP: For US standard keyboards, the '[{' key. - - { Key::BACKSLASH, VK_OEM_5 }, // (0xDC) - // Misc. character, can vary by keyboard/region. - // Windows 2000/XP: For US standard keyboards, the '\|' key. - - { Key::BRACKETRIGHT, VK_OEM_6 }, // (0xDD) - // Misc. character, can vary by keyboard/region. - // Windows 2000/XP: For US standard keyboards, the ']}' key. - - { Key::APOSTROPHE, VK_OEM_7 }, // (0xDE) - // Misc. character, can vary by keyboard/region. - // Windows 2000/XP: For US standard keyboards, single quote/double quote. - + // 0xC3-DA may be used for old gamepads? Maybe we want to support this? See WinUser.h. + vk_map[VK_OEM_4] = Key::BRACKETLEFT; // (0xDB), For US standard keyboards;the '[{' key. + vk_map[VK_OEM_5] = Key::BACKSLASH; // (0xDC), For US standard keyboards;the '\|' key. + vk_map[VK_OEM_6] = Key::BRACKETRIGHT; // (0xDD), For US standard keyboards;the ']}' key. + vk_map[VK_OEM_7] = Key::APOSTROPHE; // (0xDE), For US standard keyboards;single quote/double quote. // VK_OEM_8 (0xDF) - // Misc. character, can vary by keyboard/region. We have no mapping. - - // 0xE0 is reserved. 0xE1 is OEM specific, we have no mapping. - - // VK_OEM_102 (0xE2) - // Either angle bracket or backslash key on the RT 102-key keyboard. - // Old and uncommon, we have no mapping. - - { Key::HELP, VK_ICO_HELP }, // (0xE3) - // OEM (ICO) help key. Map to help. - - // 0xE4 is OEM (e.g. ICO) specific, we have no mapping. - - // VK_PROCESSKEY (0xE5) - // For IME, we have no mapping. - - { Key::CLEAR, VK_ICO_CLEAR }, // (0xE6) - // OEM (ICO) clear key. Map to clear. - - // VK_PACKET (0xE7) - // Used to pass Unicode characters as if they were keystrokes. - // See Win32 API docs. We have no mapping. - - // 0xE8 is unassigned, 0xE9-F5 are OEM (Nokia/Ericsson) specific, we have no mappings. - - { Key::ESCAPE, VK_ATTN }, // (0xF6) - // Old IBM 'ATTN' key used on midrange computers, e.g. AS/400, map to Escape. - - { Key::TAB, VK_CRSEL }, // (0xF7) - // Old IBM 3270 'CrSel' (cursor select) key, used to select data fields, map to Tab. - - // VK_EXSEL (0xF7) - // Old IBM 3270 extended selection key. No mapping. - - // VK_EREOF (0xF8) - // Old IBM 3270 erase to end of field key. No mapping. - - { Key::MEDIAPLAY, VK_PLAY }, // (0xFA) - // Old IBM 3270 'Play' key. Map to media play. - - // VK_ZOOM (0xFB) - // Old IBM 3290 'Zoom' key. No mapping. - - // VK_NONAME (0xFC) - // Reserved. No mapping. - - // VK_PA1 (0xFD) - // Old IBM 3270 PA1 key. No mapping. - - { Key::CLEAR, VK_OEM_CLEAR }, // (0xFE) - // OEM specific clear key. Unclear how it differs from normal clear. Map to clear. - - { Key::UNKNOWN, 0 } -}; + // 0xE0 is reserved. 0xE1 is OEM specific. + vk_map[VK_OEM_102] = Key::BAR; // (0xE2), Either angle bracket or backslash key on the RT 102-key keyboard. + vk_map[VK_ICO_HELP] = Key::HELP; // (0xE3) + // 0xE4 is OEM (e.g. ICO) specific. + // VK_PROCESSKEY (0xE5), For IME. + vk_map[VK_ICO_CLEAR] = Key::CLEAR; // (0xE6) + // VK_PACKET (0xE7), Used to pass Unicode characters as if they were keystrokes. + // 0xE8 is unassigned. + // 0xE9-F5 are OEM (Nokia/Ericsson) specific. + vk_map[VK_ATTN] = Key::ESCAPE; // (0xF6), Old IBM 'ATTN' key used on midrange computers ;e.g. AS/400. + vk_map[VK_CRSEL] = Key::TAB; // (0xF7), Old IBM 3270 'CrSel' (cursor select) key; used to select data fields. + // VK_EXSEL (0xF7), Old IBM 3270 extended selection key. + // VK_EREOF (0xF8), Old IBM 3270 erase to end of field key. + vk_map[VK_PLAY] = Key::MEDIAPLAY; // (0xFA), Old IBM 3270 'Play' key. + // VK_ZOOM (0xFB), Old IBM 3290 'Zoom' key. + // VK_NONAME (0xFC), Reserved. + // VK_PA1 (0xFD), Old IBM 3270 PA1 key. + vk_map[VK_OEM_CLEAR] = Key::CLEAR; // (0xFE), OEM specific clear key. Unclear how it differs from normal clear. + + scansym_map[0x00] = Key::PAUSE; + scansym_map[0x01] = Key::ESCAPE; + scansym_map[0x02] = Key::KEY_1; + scansym_map[0x03] = Key::KEY_2; + scansym_map[0x04] = Key::KEY_3; + scansym_map[0x05] = Key::KEY_4; + scansym_map[0x06] = Key::KEY_5; + scansym_map[0x07] = Key::KEY_6; + scansym_map[0x08] = Key::KEY_7; + scansym_map[0x09] = Key::KEY_8; + scansym_map[0x0A] = Key::KEY_9; + scansym_map[0x0B] = Key::KEY_0; + scansym_map[0x0C] = Key::MINUS; + scansym_map[0x0D] = Key::EQUAL; + scansym_map[0x0E] = Key::BACKSPACE; + scansym_map[0x0F] = Key::TAB; + scansym_map[0x10] = Key::Q; + scansym_map[0x11] = Key::W; + scansym_map[0x12] = Key::E; + scansym_map[0x13] = Key::R; + scansym_map[0x14] = Key::T; + scansym_map[0x15] = Key::Y; + scansym_map[0x16] = Key::U; + scansym_map[0x17] = Key::I; + scansym_map[0x18] = Key::O; + scansym_map[0x19] = Key::P; + scansym_map[0x1A] = Key::BRACELEFT; + scansym_map[0x1B] = Key::BRACERIGHT; + scansym_map[0x1C] = Key::ENTER; + scansym_map[0x1D] = Key::CTRL; + scansym_map[0x1E] = Key::A; + scansym_map[0x1F] = Key::S; + scansym_map[0x20] = Key::D; + scansym_map[0x21] = Key::F; + scansym_map[0x22] = Key::G; + scansym_map[0x23] = Key::H; + scansym_map[0x24] = Key::J; + scansym_map[0x25] = Key::K; + scansym_map[0x26] = Key::L; + scansym_map[0x27] = Key::SEMICOLON; + scansym_map[0x28] = Key::APOSTROPHE; + scansym_map[0x29] = Key::QUOTELEFT; + scansym_map[0x2A] = Key::SHIFT; + scansym_map[0x2B] = Key::BACKSLASH; + scansym_map[0x2C] = Key::Z; + scansym_map[0x2D] = Key::X; + scansym_map[0x2E] = Key::C; + scansym_map[0x2F] = Key::V; + scansym_map[0x30] = Key::B; + scansym_map[0x31] = Key::N; + scansym_map[0x32] = Key::M; + scansym_map[0x33] = Key::COMMA; + scansym_map[0x34] = Key::PERIOD; + scansym_map[0x35] = Key::SLASH; + scansym_map[0x36] = Key::SHIFT; + scansym_map[0x37] = Key::KP_MULTIPLY; + scansym_map[0x38] = Key::ALT; + scansym_map[0x39] = Key::SPACE; + scansym_map[0x3A] = Key::CAPSLOCK; + scansym_map[0x3B] = Key::F1; + scansym_map[0x3C] = Key::F2; + scansym_map[0x3D] = Key::F3; + scansym_map[0x3E] = Key::F4; + scansym_map[0x3F] = Key::F5; + scansym_map[0x40] = Key::F6; + scansym_map[0x41] = Key::F7; + scansym_map[0x42] = Key::F8; + scansym_map[0x43] = Key::F9; + scansym_map[0x44] = Key::F10; + scansym_map[0x45] = Key::NUMLOCK; + scansym_map[0x46] = Key::SCROLLLOCK; + scansym_map[0x47] = Key::KP_7; + scansym_map[0x48] = Key::KP_8; + scansym_map[0x49] = Key::KP_9; + scansym_map[0x4A] = Key::KP_SUBTRACT; + scansym_map[0x4B] = Key::KP_4; + scansym_map[0x4C] = Key::KP_5; + scansym_map[0x4D] = Key::KP_6; + scansym_map[0x4E] = Key::KP_ADD; + scansym_map[0x4F] = Key::KP_1; + scansym_map[0x50] = Key::KP_2; + scansym_map[0x51] = Key::KP_3; + scansym_map[0x52] = Key::KP_0; + scansym_map[0x53] = Key::KP_PERIOD; + scansym_map[0x57] = Key::SECTION; + scansym_map[0x57] = Key::F11; + scansym_map[0x58] = Key::F12; + scansym_map[0x5B] = Key::META; + scansym_map[0x5C] = Key::META; + scansym_map[0x5D] = Key::MENU; + scansym_map[0x64] = Key::F13; + scansym_map[0x65] = Key::F14; + scansym_map[0x66] = Key::F15; + scansym_map[0x67] = Key::F16; + scansym_map[0x68] = Key::F17; + scansym_map[0x69] = Key::F18; + scansym_map[0x6A] = Key::F19; + scansym_map[0x6B] = Key::F20; + scansym_map[0x6C] = Key::F21; + scansym_map[0x6D] = Key::F22; + scansym_map[0x6E] = Key::F23; + // scansym_map[0x71] = Key::JIS_KANA; + // scansym_map[0x72] = Key::JIS_EISU; + scansym_map[0x76] = Key::F24; + + for (const KeyValue<unsigned int, Key> &E : scansym_map) { + scansym_map_inv[E.value] = E.key; + } -static _WinTranslatePair _scancode_to_keycode[] = { - { Key::ESCAPE, 0x01 }, - { Key::KEY_1, 0x02 }, - { Key::KEY_2, 0x03 }, - { Key::KEY_3, 0x04 }, - { Key::KEY_4, 0x05 }, - { Key::KEY_5, 0x06 }, - { Key::KEY_6, 0x07 }, - { Key::KEY_7, 0x08 }, - { Key::KEY_8, 0x09 }, - { Key::KEY_9, 0x0A }, - { Key::KEY_0, 0x0B }, - { Key::MINUS, 0x0C }, - { Key::EQUAL, 0x0D }, - { Key::BACKSPACE, 0x0E }, - { Key::TAB, 0x0F }, - { Key::Q, 0x10 }, - { Key::W, 0x11 }, - { Key::E, 0x12 }, - { Key::R, 0x13 }, - { Key::T, 0x14 }, - { Key::Y, 0x15 }, - { Key::U, 0x16 }, - { Key::I, 0x17 }, - { Key::O, 0x18 }, - { Key::P, 0x19 }, - { Key::BRACELEFT, 0x1A }, - { Key::BRACERIGHT, 0x1B }, - { Key::ENTER, 0x1C }, - { Key::CTRL, 0x1D }, - { Key::A, 0x1E }, - { Key::S, 0x1F }, - { Key::D, 0x20 }, - { Key::F, 0x21 }, - { Key::G, 0x22 }, - { Key::H, 0x23 }, - { Key::J, 0x24 }, - { Key::K, 0x25 }, - { Key::L, 0x26 }, - { Key::SEMICOLON, 0x27 }, - { Key::APOSTROPHE, 0x28 }, - { Key::QUOTELEFT, 0x29 }, - { Key::SHIFT, 0x2A }, - { Key::BACKSLASH, 0x2B }, - { Key::Z, 0x2C }, - { Key::X, 0x2D }, - { Key::C, 0x2E }, - { Key::V, 0x2F }, - { Key::B, 0x30 }, - { Key::N, 0x31 }, - { Key::M, 0x32 }, - { Key::COMMA, 0x33 }, - { Key::PERIOD, 0x34 }, - { Key::SLASH, 0x35 }, - { Key::SHIFT, 0x36 }, - { Key::PRINT, 0x37 }, - { Key::ALT, 0x38 }, - { Key::SPACE, 0x39 }, - { Key::CAPSLOCK, 0x3A }, - { Key::F1, 0x3B }, - { Key::F2, 0x3C }, - { Key::F3, 0x3D }, - { Key::F4, 0x3E }, - { Key::F5, 0x3F }, - { Key::F6, 0x40 }, - { Key::F7, 0x41 }, - { Key::F8, 0x42 }, - { Key::F9, 0x43 }, - { Key::F10, 0x44 }, - { Key::NUMLOCK, 0x45 }, - { Key::SCROLLLOCK, 0x46 }, - { Key::HOME, 0x47 }, - { Key::UP, 0x48 }, - { Key::PAGEUP, 0x49 }, - { Key::KP_SUBTRACT, 0x4A }, - { Key::LEFT, 0x4B }, - { Key::KP_5, 0x4C }, - { Key::RIGHT, 0x4D }, - { Key::KP_ADD, 0x4E }, - { Key::END, 0x4F }, - { Key::DOWN, 0x50 }, - { Key::PAGEDOWN, 0x51 }, - { Key::INSERT, 0x52 }, - { Key::KEY_DELETE, 0x53 }, - { Key::F11, 0x57 }, - { Key::F12, 0x58 }, - { Key::META, 0x5B }, - { Key::META, 0x5C }, - { Key::MENU, 0x5D }, - { Key::F13, 0x64 }, - { Key::F14, 0x65 }, - { Key::F15, 0x66 }, - { Key::F16, 0x67 }, - { Key::F17, 0x68 }, - { Key::F18, 0x69 }, - { Key::F19, 0x6A }, - { Key::F20, 0x6B }, - { Key::F21, 0x6C }, - { Key::F22, 0x6D }, - { Key::F23, 0x6E }, - { Key::F24, 0x76 }, - { Key::UNKNOWN, 0 } -}; + scansym_map_ext[0x09] = Key::MENU; + scansym_map_ext[0x10] = Key::MEDIAPREVIOUS; + scansym_map_ext[0x19] = Key::MEDIANEXT; + scansym_map_ext[0x1C] = Key::KP_ENTER; + scansym_map_ext[0x20] = Key::VOLUMEMUTE; + scansym_map_ext[0x21] = Key::LAUNCH1; + scansym_map_ext[0x22] = Key::MEDIAPLAY; + scansym_map_ext[0x24] = Key::MEDIASTOP; + scansym_map_ext[0x2E] = Key::VOLUMEDOWN; + scansym_map_ext[0x30] = Key::VOLUMEUP; + scansym_map_ext[0x32] = Key::HOMEPAGE; + scansym_map_ext[0x35] = Key::KP_DIVIDE; + scansym_map_ext[0x37] = Key::PRINT; + scansym_map_ext[0x3A] = Key::KP_ADD; + scansym_map_ext[0x45] = Key::NUMLOCK; + scansym_map_ext[0x47] = Key::HOME; + scansym_map_ext[0x48] = Key::UP; + scansym_map_ext[0x49] = Key::PAGEUP; + scansym_map_ext[0x4A] = Key::KP_SUBTRACT; + scansym_map_ext[0x4B] = Key::LEFT; + scansym_map_ext[0x4C] = Key::KP_5; + scansym_map_ext[0x4D] = Key::RIGHT; + scansym_map_ext[0x4E] = Key::KP_ADD; + scansym_map_ext[0x4F] = Key::END; + scansym_map_ext[0x50] = Key::DOWN; + scansym_map_ext[0x51] = Key::PAGEDOWN; + scansym_map_ext[0x52] = Key::INSERT; + scansym_map_ext[0x53] = Key::KEY_DELETE; + scansym_map_ext[0x5D] = Key::MENU; + scansym_map_ext[0x5F] = Key::STANDBY; + scansym_map_ext[0x65] = Key::SEARCH; + scansym_map_ext[0x66] = Key::FAVORITES; + scansym_map_ext[0x67] = Key::REFRESH; + scansym_map_ext[0x68] = Key::STOP; + scansym_map_ext[0x69] = Key::FORWARD; + scansym_map_ext[0x6A] = Key::BACK; + scansym_map_ext[0x6B] = Key::LAUNCH0; + scansym_map_ext[0x6C] = Key::LAUNCHMAIL; + scansym_map_ext[0x6D] = Key::LAUNCHMEDIA; + scansym_map_ext[0x78] = Key::MEDIARECORD; +} Key KeyMappingWindows::get_keysym(unsigned int p_code) { - for (int i = 0; _vk_to_keycode[i].keysym != Key::UNKNOWN; i++) { - if (_vk_to_keycode[i].keycode == p_code) { - return _vk_to_keycode[i].keysym; - } + const Key *key = vk_map.getptr(p_code); + if (key) { + return *key; } - return Key::UNKNOWN; } unsigned int KeyMappingWindows::get_scancode(Key p_keycode) { - for (int i = 0; _scancode_to_keycode[i].keysym != Key::UNKNOWN; i++) { - if (_scancode_to_keycode[i].keysym == p_keycode) { - return _scancode_to_keycode[i].keycode; - } + const unsigned int *key = scansym_map_inv.getptr(p_keycode); + if (key) { + return *key; } - return 0; } Key KeyMappingWindows::get_scansym(unsigned int p_code, bool p_extended) { - Key keycode = Key::UNKNOWN; - for (int i = 0; _scancode_to_keycode[i].keysym != Key::UNKNOWN; i++) { - if (_scancode_to_keycode[i].keycode == p_code) { - keycode = _scancode_to_keycode[i].keysym; - break; - } - } - if (p_extended) { - switch (keycode) { - case Key::ENTER: { - keycode = Key::KP_ENTER; - } break; - case Key::SLASH: { - keycode = Key::KP_DIVIDE; - } break; - case Key::CAPSLOCK: { - keycode = Key::KP_ADD; - } break; - default: - break; - } - } else { - switch (keycode) { - case Key::NUMLOCK: { - keycode = Key::PAUSE; - } break; - case Key::HOME: { - keycode = Key::KP_7; - } break; - case Key::UP: { - keycode = Key::KP_8; - } break; - case Key::PAGEUP: { - keycode = Key::KP_9; - } break; - case Key::LEFT: { - keycode = Key::KP_4; - } break; - case Key::RIGHT: { - keycode = Key::KP_6; - } break; - case Key::END: { - keycode = Key::KP_1; - } break; - case Key::DOWN: { - keycode = Key::KP_2; - } break; - case Key::PAGEDOWN: { - keycode = Key::KP_3; - } break; - case Key::INSERT: { - keycode = Key::KP_0; - } break; - case Key::KEY_DELETE: { - keycode = Key::KP_PERIOD; - } break; - case Key::PRINT: { - keycode = Key::KP_MULTIPLY; - } break; - default: - break; + const Key *key = scansym_map_ext.getptr(p_code); + if (key) { + return *key; } } - - return keycode; + const Key *key = scansym_map.getptr(p_code); + if (key) { + return *key; + } + return Key::NONE; } bool KeyMappingWindows::is_extended_key(unsigned int p_code) { diff --git a/platform/windows/key_mapping_windows.h b/platform/windows/key_mapping_windows.h index ef5bec2b76..a98aa7ed68 100644 --- a/platform/windows/key_mapping_windows.h +++ b/platform/windows/key_mapping_windows.h @@ -41,6 +41,8 @@ class KeyMappingWindows { KeyMappingWindows() {} public: + static void initialize(); + static Key get_keysym(unsigned int p_code); static unsigned int get_scancode(Key p_keycode); static Key get_scansym(unsigned int p_code, bool p_extended); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 130c5f7b97..08299d9b98 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -210,6 +210,8 @@ void OS_Windows::initialize() { } else if (!dwrite2_init) { print_verbose("Unable to load IDWriteFactory2, automatic system font fallback is disabled."); } + + FileAccessWindows::initialize(); } void OS_Windows::delete_main_loop() { @@ -252,6 +254,8 @@ void OS_Windows::finalize() { } void OS_Windows::finalize_core() { + FileAccessWindows::finalize(); + timeEndPeriod(1); memdelete(process_map); |