From: Po Lu Date: Sun, 9 Jan 2022 04:32:57 +0000 (+0000) Subject: Make caps lock work on Haiku X-Git-Tag: emacs-29.0.90~3188 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=97f41faf093280079f8cf409ee8604869964b9d9;p=emacs.git Make caps lock work on Haiku * src/haiku_support.cc (map_caps): (map_caps_shift): New functions. (DispatchMessage): Map keys with the appropriate map if caps lock is on. --- diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 47a6af92f61..03d5dad7699 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -178,6 +178,40 @@ map_shift (uint32_t kc, uint32_t *ch) key_map_lock.Unlock (); } +static void +map_caps (uint32_t kc, uint32_t *ch) +{ + if (!key_map_lock.Lock ()) + gui_abort ("Failed to lock keymap"); + if (!key_map) + get_key_map (&key_map, &key_chars); + if (!key_map) + return; + if (kc >= 128) + return; + + int32_t m = key_map->caps_map[kc]; + map_key (key_chars, m, ch); + key_map_lock.Unlock (); +} + +static void +map_caps_shift (uint32_t kc, uint32_t *ch) +{ + if (!key_map_lock.Lock ()) + gui_abort ("Failed to lock keymap"); + if (!key_map) + get_key_map (&key_map, &key_chars); + if (!key_map) + return; + if (kc >= 128) + return; + + int32_t m = key_map->caps_shift_map[kc]; + map_key (key_chars, m, ch); + key_map_lock.Unlock (); +} + static void map_normal (uint32_t kc, uint32_t *ch) { @@ -605,9 +639,19 @@ public: BUnicodeChar::FromUTF8 (msg->GetString ("bytes")); if ((mods & B_SHIFT_KEY) && rq.kc >= 0) - map_shift (rq.kc, &rq.unraw_mb_char); + { + if (mods & B_CAPS_LOCK) + map_caps_shift (rq.kc, &rq.unraw_mb_char); + else + map_shift (rq.kc, &rq.unraw_mb_char); + } else if (rq.kc >= 0) - map_normal (rq.kc, &rq.unraw_mb_char); + { + if (mods & B_CAPS_LOCK) + map_caps (rq.kc, &rq.unraw_mb_char); + else + map_normal (rq.kc, &rq.unraw_mb_char); + } haiku_write (msg->what == B_KEY_DOWN ? KEY_DOWN : KEY_UP, &rq); }