Rename all uses of 'scancode' to 'native_key' where relevant

This commit is contained in:
Benoit de Chezelles 2019-10-16 02:25:20 +02:00
parent 2b6dde2ac5
commit 7f2b98fad7
18 changed files with 75 additions and 75 deletions

View File

@ -328,7 +328,7 @@ format_text(const char *src) {
static const char*
safe_name_for_scancode(unsigned int scancode) {
const char *ans = _glfwPlatformGetScancodeName(scancode);
const char *ans = _glfwPlatformGetNativeKeyName(scancode);
if (!ans) return "<noname>";
if ((1 <= ans[0] && ans[0] <= 31) || ans[0] == 127) ans = "<cc>";
return ans;
@ -341,7 +341,7 @@ static int translateKey(unsigned int key, bool apply_keymap)
{
if (apply_keymap) {
// Look for the effective key name after applying any keyboard layouts/mappings
const char *name_chars = _glfwPlatformGetScancodeName(key);
const char *name_chars = _glfwPlatformGetNativeKeyName(key);
uint32_t name = 0;
if (name_chars) {
for (int i = 0; i < 4; i++) {
@ -1896,7 +1896,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode UNUSED)
updateCursorMode(window);
}
const char* _glfwPlatformGetScancodeName(int scancode)
const char* _glfwPlatformGetNativeKeyName(int scancode)
{
UInt32 deadKeyState = 0;
UniChar characters[8];
@ -1923,7 +1923,7 @@ const char* _glfwPlatformGetScancodeName(int scancode)
return _glfw.ns.keyName;
}
int _glfwPlatformGetKeyScancode(int key)
int _glfwPlatformGetNativeKeyForKey(int key)
{
return _glfw.ns.scancodes[key];
}

View File

@ -171,7 +171,7 @@ def generate_wrappers(glfw_header):
int32_t glfwGetX11Window(GLFWwindow* window)
void glfwSetPrimarySelectionString(GLFWwindow* window, const char* string)
const char* glfwGetPrimarySelectionString(GLFWwindow* window, void)
int glfwGetXKBScancode(const char* key_name, int case_sensitive)
int glfwGetNativeKeyForName(const char* key_name, int case_sensitive)
void glfwRequestWaylandFrameEvent(GLFWwindow *handle, unsigned long long id, GLFWwaylandframecallbackfunc callback)
unsigned long long glfwDBusUserNotify(const char *app_name, const char* icon, const char *summary, const char *body, \
const char *action_text, int32_t timeout, GLFWDBusnotificationcreatedfun callback, void *data)

10
glfw/glfw3.h vendored
View File

@ -1565,7 +1565,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow*,double,double,int);
* This is the function pointer type for key callbacks. A keyboard
* key callback function has the following signature:
* @code
* void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
* void function_name(GLFWwindow* window, int key, int native_key, int action, int mods)
* @endcode
* The semantics of this function are that the key that is interacted with on the
* keyboard is reported, and the text, if any generated by the key is reported.
@ -4237,15 +4237,15 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value);
*/
GLFWAPI const char* glfwGetKeyName(int key, int native_key);
/*! @brief Returns the platform-specific scancode of the specified key.
/*! @brief Returns the platform-specific identifier of the specified key.
*
* This function returns the platform-specific scancode of the specified key.
* This function returns the platform-specific identifier of the specified key.
*
* If the key is `GLFW_KEY_UNKNOWN` or does not exist on the keyboard this
* method will return `-1`.
*
* @param[in] key Any [named key](@ref keys).
* @return The platform-specific scancode for the key, or `-1` if an
* @return The platform-specific identifier for the key, or `-1` if an
* [error](@ref error_handling) occurred.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
@ -4259,7 +4259,7 @@ GLFWAPI const char* glfwGetKeyName(int key, int native_key);
*
* @ingroup input
*/
GLFWAPI int glfwGetKeyScancode(int key); // FIXME: s/Scancode/NativeKey ? (and fix doc above)
GLFWAPI int glfwGetNativeKeyForKey(int key);
/*! @brief Returns the last reported state of a keyboard key for the specified
* window.

2
glfw/ibus_glfw.c vendored
View File

@ -407,7 +407,7 @@ key_event_processed(DBusMessage *msg, const char* errmsg, void *data) {
failed = true;
} else {
glfw_dbus_get_args(msg, "Failed to get IBUS handled key from reply", DBUS_TYPE_BOOLEAN, &handled, DBUS_TYPE_INVALID);
debug("IBUS processed scancode: 0x%x release: %d handled: %u\n", ev->glfw_ev.scancode, is_release, handled);
debug("IBUS processed native_key: 0x%x release: %d handled: %u\n", ev->glfw_ev.native_key, is_release, handled);
}
glfw_xkb_key_from_ime(ev, handled ? true : false, failed);
free(ev);

8
glfw/input.c vendored
View File

@ -769,13 +769,13 @@ GLFWAPI const char* glfwGetKeyName(int key, int native_key)
return NULL;
}
native_key = _glfwPlatformGetKeyScancode(key);
native_key = _glfwPlatformGetNativeKeyForKey(key);
}
return _glfwPlatformGetScancodeName(native_key);
return _glfwPlatformGetNativeKeyName(native_key);
}
GLFWAPI int glfwGetKeyScancode(int key)
GLFWAPI int glfwGetNativeKeyForKey(int key)
{
_GLFW_REQUIRE_INIT_OR_RETURN(-1);
@ -785,7 +785,7 @@ GLFWAPI int glfwGetKeyScancode(int key)
return GLFW_RELEASE;
}
return _glfwPlatformGetKeyScancode(key);
return _glfwPlatformGetNativeKeyForKey(key);
}
GLFWAPI int glfwGetKey(GLFWwindow* handle, int key)

5
glfw/internal.h vendored
View File

@ -640,9 +640,8 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, GLFWCursorShape shape
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor);
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor);
// FIXME: s/Scancode/NativeKey ?
const char* _glfwPlatformGetScancodeName(int native_key);
int _glfwPlatformGetKeyScancode(int key);
const char* _glfwPlatformGetNativeKeyName(int native_key);
int _glfwPlatformGetNativeKeyForKey(int key);
void _glfwPlatformFreeMonitor(_GLFWmonitor* monitor);
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos);

4
glfw/null_window.c vendored
View File

@ -307,12 +307,12 @@ const char* _glfwPlatformGetClipboardString(void)
return NULL;
}
const char* _glfwPlatformGetScancodeName(int scancode UNUSED)
const char* _glfwPlatformGetNativeKeyName(int native_key UNUSED)
{
return "";
}
int _glfwPlatformGetKeyScancode(int key UNUSED)
int _glfwPlatformGetNativeKeyForKey(int key UNUSED)
{
return -1;
}

4
glfw/window.c vendored
View File

@ -57,9 +57,9 @@ void _glfwInputWindowFocus(_GLFWwindow* window, bool focused)
{
if (window->keys[key] == GLFW_PRESS)
{
const int scancode = _glfwPlatformGetKeyScancode(key);
const int native_key = _glfwPlatformGetNativeKeyForKey(key);
GLFWkeyevent ev;
_glfwInitializeKeyEvent(&ev, key, scancode, GLFW_RELEASE, 0);
_glfwInitializeKeyEvent(&ev, key, native_key, GLFW_RELEASE, 0);
_glfwInputKeyboard(window, &ev);
}
}

8
glfw/wl_window.c vendored
View File

@ -1269,12 +1269,12 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode UNUSED)
_glfwPlatformSetCursor(window, window->wl.currentCursor);
}
const char* _glfwPlatformGetScancodeName(int scancode)
const char* _glfwPlatformGetNativeKeyName(int native_key)
{
return glfw_xkb_keysym_name(scancode);
return glfw_xkb_keysym_name(native_key);
}
int _glfwPlatformGetKeyScancode(int key)
int _glfwPlatformGetNativeKeyForKey(int key)
{
return glfw_xkb_sym_for_key(key);
}
@ -2032,7 +2032,7 @@ GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* handle)
return window->wl.surface;
}
GLFWAPI int glfwGetXKBScancode(const char* keyName, bool caseSensitive) {
GLFWAPI int glfwGetNativeKeyForName(const char* keyName, bool caseSensitive) {
return glfw_xkb_keysym_from_name(keyName, caseSensitive);
}

6
glfw/x11_window.c vendored
View File

@ -2586,13 +2586,13 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
XFlush(_glfw.x11.display);
}
const char* _glfwPlatformGetScancodeName(int native_key) // FIXME: s/Scancode/NativeKey ?
const char* _glfwPlatformGetNativeKeyName(int native_key)
{
return glfw_xkb_keysym_name(native_key);
}
int _glfwPlatformGetKeyScancode(int key) // FIXME: rename _glfwPlatformGetNativeKeyForKey ?
int _glfwPlatformGetNativeKeyForKey(int key) // FIXME: rename _glfwPlatformGetNativeKeyForKey ?
{
return glfw_xkb_sym_for_key(key);
}
@ -2871,7 +2871,7 @@ GLFWAPI Window glfwGetX11Window(GLFWwindow* handle)
return window->x11.handle;
}
GLFWAPI int glfwGetXKBScancode(const char* keyName, bool caseSensitive) { // FIXME: s/Scancode/Keycode ?
GLFWAPI int glfwGetNativeKeyForName(const char* keyName, bool caseSensitive) {
return glfw_xkb_keysym_from_name(keyName, caseSensitive);
}

8
glfw/xkb_glfw.c vendored
View File

@ -437,11 +437,11 @@ glfw_xkb_update_modifiers(_GLFWXKBData *xkb, xkb_mod_mask_t depressed, xkb_mod_m
}
bool
glfw_xkb_should_repeat(_GLFWXKBData *xkb, xkb_keycode_t xkb_keycode) {
glfw_xkb_should_repeat(_GLFWXKBData *xkb, xkb_keycode_t keycode) {
#ifdef _GLFW_WAYLAND
xkb_keycode += 8;
keycode += 8;
#endif
return xkb_keymap_key_repeats(xkb->keymap, xkb_keycode);
return xkb_keymap_key_repeats(xkb->keymap, keycode);
}
@ -658,7 +658,7 @@ glfw_xkb_handle_key_event(_GLFWwindow *window, _GLFWXKBData *xkb, xkb_keycode_t
ibus_ev.window_id = window->id;
ibus_ev.ibus_keysym = syms[0];
if (ibus_process_key(&ibus_ev, &xkb->ibus)) {
debug("↳ to IBUS: scancode: 0x%x keysym: 0x%x (%s) %s\n", ibus_ev.ibus_keycode, ibus_ev.ibus_keysym, glfw_xkb_keysym_name(ibus_ev.ibus_keysym), format_mods(ibus_ev.glfw_ev.mods));
debug("↳ to IBUS: keycode: 0x%x keysym: 0x%x (%s) %s\n", ibus_ev.ibus_keycode, ibus_ev.ibus_keysym, glfw_xkb_keysym_name(ibus_ev.ibus_keysym), format_mods(ibus_ev.glfw_ev.mods));
} else {
_glfwInputKeyboard(window, &glfw_ev);
}

4
glfw/xkb_glfw.h vendored
View File

@ -87,10 +87,10 @@ void glfw_xkb_release(_GLFWXKBData *xkb);
bool glfw_xkb_create_context(_GLFWXKBData *xkb);
bool glfw_xkb_compile_keymap(_GLFWXKBData *xkb, const char *map_str);
void glfw_xkb_update_modifiers(_GLFWXKBData *xkb, xkb_mod_mask_t depressed, xkb_mod_mask_t latched, xkb_mod_mask_t locked, xkb_layout_index_t base_group, xkb_layout_index_t latched_group, xkb_layout_index_t locked_group);
bool glfw_xkb_should_repeat(_GLFWXKBData *xkb, xkb_keycode_t scancode);
bool glfw_xkb_should_repeat(_GLFWXKBData *xkb, xkb_keycode_t keycode);
const char* glfw_xkb_keysym_name(xkb_keysym_t sym);
xkb_keysym_t glfw_xkb_sym_for_key(int key);
void glfw_xkb_handle_key_event(_GLFWwindow *window, _GLFWXKBData *xkb, xkb_keycode_t scancode, int action);
void glfw_xkb_handle_key_event(_GLFWwindow *window, _GLFWXKBData *xkb, xkb_keycode_t keycode, int action);
int glfw_xkb_keysym_from_name(const char *name, bool case_sensitive);
void glfw_xkb_update_ime_state(_GLFWwindow *w, _GLFWXKBData *xkb, int which, int a, int b, int c, int d);
void glfw_xkb_key_from_ime(_GLFWIBUSKeyEvent *ev, bool handled_by_ime, bool failed);

View File

@ -512,27 +512,27 @@ class Boss:
if t is not None:
return t.active_window
def dispatch_special_key(self, key, scancode, action, mods):
def dispatch_special_key(self, key, native_key, action, mods):
# Handles shortcuts, return True if the key was consumed
key_action = get_shortcut(self.keymap, mods, key, scancode)
key_action = get_shortcut(self.keymap, mods, key, native_key)
if key_action is None:
sequences = get_shortcut(self.opts.sequence_map, mods, key, scancode)
sequences = get_shortcut(self.opts.sequence_map, mods, key, native_key)
if sequences:
self.pending_sequences = sequences
set_in_sequence_mode(True)
return True
else:
self.current_key_press_info = key, scancode, action, mods
self.current_key_press_info = key, native_key, action, mods
return self.dispatch_action(key_action)
def process_sequence(self, key, scancode, action, mods):
def process_sequence(self, key, native_key, action, mods):
if not self.pending_sequences:
set_in_sequence_mode(False)
remaining = {}
matched_action = None
for seq, key_action in self.pending_sequences.items():
if shortcut_matches(seq[0], mods, key, scancode):
if shortcut_matches(seq[0], mods, key, native_key):
seq = seq[1:]
if seq:
remaining[seq] = key_action

6
kitty/glfw-wrapper.c generated
View File

@ -245,8 +245,8 @@ load_glfw(const char* path) {
*(void **) (&glfwGetKeyName_impl) = dlsym(handle, "glfwGetKeyName");
if (glfwGetKeyName_impl == NULL) fail("Failed to load glfw function glfwGetKeyName with error: %s", dlerror());
*(void **) (&glfwGetKeyScancode_impl) = dlsym(handle, "glfwGetKeyScancode");
if (glfwGetKeyScancode_impl == NULL) fail("Failed to load glfw function glfwGetKeyScancode with error: %s", dlerror());
*(void **) (&glfwGetNativeKeyForKey_impl) = dlsym(handle, "glfwGetNativeKeyForKey");
if (glfwGetNativeKeyForKey_impl == NULL) fail("Failed to load glfw function glfwGetNativeKeyForKey with error: %s", dlerror());
*(void **) (&glfwGetKey_impl) = dlsym(handle, "glfwGetKey");
if (glfwGetKey_impl == NULL) fail("Failed to load glfw function glfwGetKey with error: %s", dlerror());
@ -401,7 +401,7 @@ load_glfw(const char* path) {
*(void **) (&glfwGetPrimarySelectionString_impl) = dlsym(handle, "glfwGetPrimarySelectionString");
*(void **) (&glfwGetXKBScancode_impl) = dlsym(handle, "glfwGetXKBScancode");
*(void **) (&glfwGetNativeKeyForName_impl) = dlsym(handle, "glfwGetNativeKeyForName");
*(void **) (&glfwRequestWaylandFrameEvent_impl) = dlsym(handle, "glfwRequestWaylandFrameEvent");

18
kitty/glfw-wrapper.h generated
View File

@ -971,8 +971,8 @@ typedef struct GLFWkeyevent
// The [keyboard key](@ref keys) that was pressed or released.
int key;
// The system-specific scancode of the key.
int scancode;
// The native key identifier of the key.
int native_key;
// The event action. Either `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`.
int action;
@ -1325,7 +1325,7 @@ typedef void (* GLFWscrollfun)(GLFWwindow*,double,double,int);
* This is the function pointer type for key callbacks. A keyboard
* key callback function has the following signature:
* @code
* void function_name(GLFWwindow* window, int key, int scancode, int action, int mods)
* void function_name(GLFWwindow* window, int key, int native_key, int action, int mods)
* @endcode
* The semantics of this function are that the key that is interacted with on the
* keyboard is reported, and the text, if any generated by the key is reported.
@ -1889,9 +1889,9 @@ typedef const char* (*glfwGetKeyName_func)(int, int);
glfwGetKeyName_func glfwGetKeyName_impl;
#define glfwGetKeyName glfwGetKeyName_impl
typedef int (*glfwGetKeyScancode_func)(int);
glfwGetKeyScancode_func glfwGetKeyScancode_impl;
#define glfwGetKeyScancode glfwGetKeyScancode_impl
typedef int (*glfwGetNativeKeyForKey_func)(int);
glfwGetNativeKeyForKey_func glfwGetNativeKeyForKey_impl;
#define glfwGetNativeKeyForKey glfwGetNativeKeyForKey_impl
typedef int (*glfwGetKey_func)(GLFWwindow*, int);
glfwGetKey_func glfwGetKey_impl;
@ -2113,9 +2113,9 @@ typedef const char* (*glfwGetPrimarySelectionString_func)(GLFWwindow*);
glfwGetPrimarySelectionString_func glfwGetPrimarySelectionString_impl;
#define glfwGetPrimarySelectionString glfwGetPrimarySelectionString_impl
typedef int (*glfwGetXKBScancode_func)(const char*, int);
glfwGetXKBScancode_func glfwGetXKBScancode_impl;
#define glfwGetXKBScancode glfwGetXKBScancode_impl
typedef int (*glfwGetNativeKeyForName_func)(const char*, int);
glfwGetNativeKeyForName_func glfwGetNativeKeyForName_impl;
#define glfwGetNativeKeyForName glfwGetNativeKeyForName_impl
typedef void (*glfwRequestWaylandFrameEvent_func)(GLFWwindow*, unsigned long long, GLFWwaylandframecallbackfunc);
glfwRequestWaylandFrameEvent_func glfwRequestWaylandFrameEvent_impl;

View File

@ -451,7 +451,7 @@ toggle_maximized_for_os_window(OSWindow *w) {
#ifdef __APPLE__
static int
filter_option(int key UNUSED, int mods, unsigned int scancode UNUSED, unsigned long flags) {
filter_option(int key UNUSED, int mods, unsigned int native_key UNUSED, unsigned long flags) {
if ((mods == GLFW_MOD_ALT) || (mods == (GLFW_MOD_ALT | GLFW_MOD_SHIFT))) {
if (OPT(macos_option_as_alt) == 3) return 1;
if (cocoa_alt_option_key_pressed(flags)) return 1;
@ -830,9 +830,9 @@ glfw_get_physical_dpi(PYNOARG) {
static PyObject*
glfw_get_key_name(PyObject UNUSED *self, PyObject *args) {
int key, scancode;
if (!PyArg_ParseTuple(args, "ii", &key, &scancode)) return NULL;
return Py_BuildValue("s", glfwGetKeyName(key, scancode));
int key, native_key;
if (!PyArg_ParseTuple(args, "ii", &key, &native_key)) return NULL;
return Py_BuildValue("s", glfwGetKeyName(key, native_key));
}
static PyObject*

View File

@ -26,7 +26,7 @@ key_to_bytes(int glfw_key, bool smkx, bool extended, int mods, int action) {
#define SPECIAL_INDEX(key) ((key & 0x7f) | ( (mods & 0xF) << 7))
#define IS_ALT_MODS(mods) (mods == GLFW_MOD_ALT || mods == (GLFW_MOD_ALT | GLFW_MOD_SHIFT))
typedef struct { int mods, scancode; } NativeKey;
typedef struct { int mods, native_key; } NativeKey;
static NativeKey *native_special_keys = NULL;
static size_t native_special_keys_capacity = 0, native_special_keys_count = 0;
@ -39,7 +39,7 @@ set_special_key_combo(int glfw_key, int mods, bool is_native) {
if (native_special_keys == NULL) fatal("Out of memory");
}
native_special_keys[native_special_keys_count].mods = mods;
native_special_keys[native_special_keys_count++].scancode = glfw_key;
native_special_keys[native_special_keys_count++].native_key = glfw_key;
} else {
uint16_t key = key_map[glfw_key];
if (key != UINT8_MAX) {
@ -96,7 +96,7 @@ is_ascii_control_char(char c) {
}
static inline bool
check_if_special(int key, int mods, int scancode) {
check_if_special(int key, int mods, int native_key) {
uint16_t qkey = (0 <= key && key < (ssize_t)arraysz(key_map)) ? key_map[key] : UINT8_MAX;
bool special = false;
if (qkey != UINT8_MAX) {
@ -104,7 +104,8 @@ check_if_special(int key, int mods, int scancode) {
special = needs_special_handling[qkey];
}
for (size_t i = 0; !special && i < native_special_keys_count; i++) {
if (scancode == native_special_keys[i].scancode && mods == native_special_keys[i].mods) special = true;
if (native_key == native_special_keys[i].native_key && mods == native_special_keys[i].mods)
special = true;
}
return special;
}
@ -123,11 +124,11 @@ update_ime_position(OSWindow *os_window, Window* w, Screen *screen) {
void
on_key_input(GLFWkeyevent *ev) {
Window *w = active_window();
int action = ev->action, scancode = ev->scancode, key = ev->key, mods = ev->mods;
int action = ev->action, native_key = ev->native_key, key = ev->key, mods = ev->mods;
const char *text = ev->text ? ev->text : "";
debug("on_key_input: glfw key: %d native_code: 0x%x action: %s mods: 0x%x text: '%s' state: %d ",
key, scancode,
debug("on_key_input: glfw key: %d native_key: 0x%x action: %s mods: 0x%x text: '%s' state: %d ",
key, native_key,
(action == GLFW_RELEASE ? "RELEASE" : (action == GLFW_PRESS ? "PRESS" : "REPEAT")),
mods, text, ev->ime_state);
if (!w) { debug("no active window, ignoring\n"); return; }
@ -161,13 +162,13 @@ on_key_input(GLFWkeyevent *ev) {
if (
action != GLFW_RELEASE &&
key != GLFW_KEY_LEFT_SHIFT && key != GLFW_KEY_RIGHT_SHIFT && key != GLFW_KEY_LEFT_ALT && key != GLFW_KEY_RIGHT_ALT && key != GLFW_KEY_LEFT_CONTROL && key != GLFW_KEY_RIGHT_CONTROL
) call_boss(process_sequence, "iiii", key, scancode, action, mods);
) call_boss(process_sequence, "iiii", key, native_key, action, mods);
return;
}
bool has_text = text[0] && !is_ascii_control_char(text[0]);
if (action == GLFW_PRESS || action == GLFW_REPEAT) {
if (check_if_special(key, mods, scancode)) {
PyObject *ret = PyObject_CallMethod(global_state.boss, "dispatch_special_key", "iiii", key, scancode, action, mods);
if (check_if_special(key, mods, native_key)) {
PyObject *ret = PyObject_CallMethod(global_state.boss, "dispatch_special_key", "iiii", key, native_key, action, mods);
if (ret == NULL) { PyErr_Print(); }
else {
bool consumed = ret == Py_True;
@ -228,9 +229,9 @@ PYWRAP1(key_for_native_key_name) {
int case_sensitive = 0;
PA("s|p", &name, &case_sensitive);
#ifndef __APPLE__
if (glfwGetXKBScancode) { // if this function is called before GLFW is initialized glfwGetXKBScancode will be NULL
int scancode = glfwGetXKBScancode(name, case_sensitive);
if (scancode) return Py_BuildValue("i", scancode);
if (glfwGetNativeKeyForName) { // if this function is called before GLFW is initialized glfwGetNativeKeyForName will be NULL
int native_key = glfwGetNativeKeyForName(name, case_sensitive);
if (native_key) return Py_BuildValue("i", native_key);
}
#endif
Py_RETURN_NONE;

View File

@ -264,7 +264,7 @@ def key_to_bytes(key, smkx, extended, mods, action):
return bytes(data)
def interpret_key_event(key, scancode, mods, window, action):
def interpret_key_event(key, native_key, mods, window, action):
screen = window.screen
if (
action == defines.GLFW_PRESS or
@ -275,17 +275,17 @@ def interpret_key_event(key, scancode, mods, window, action):
return b''
def get_shortcut(keymap, mods, key, scancode):
def get_shortcut(keymap, mods, key, native_key):
mods &= 0b1111
ans = keymap.get((mods, False, key))
if ans is None:
ans = keymap.get((mods, True, scancode))
ans = keymap.get((mods, True, native_key))
return ans
def shortcut_matches(s, mods, key, scancode):
def shortcut_matches(s, mods, key, native_key):
mods &= 0b1111
q = scancode if s[1] else key
q = native_key if s[1] else key
return s[0] & 0b1111 == mods & 0b1111 and s[2] == q