wpesrc: Convert from utf32 to support other keys
authorOlivier CrĂȘte <olivier.crete@collabora.com>
Mon, 11 Apr 2022 20:56:19 +0000 (15:56 -0500)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 12 Apr 2022 11:52:34 +0000 (11:52 +0000)
This makes all of the non-letter keys work.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2156>

subprojects/gst-plugins-bad/ext/wpe/gstwpevideosrc.cpp

index 693a859..3de0e96 100644 (file)
@@ -586,10 +586,18 @@ gst_wpe_video_src_event (GstBaseSrc * base_src, GstEvent * event)
         if (gst_navigation_event_parse_key_event (event, &key)) {
           /* FIXME: This is wrong... The GstNavigation API should pass
              hardware-level information, not high-level keysym strings */
-          uint32_t keysym =
-              (uint32_t) xkb_keysym_from_name (key, XKB_KEYSYM_NO_FLAGS);
+         gunichar *unichar;
+         glong items_written;
+         uint32_t keysym;
           struct wpe_input_keyboard_event wpe_event = { 0 };
 
+          unichar = g_utf8_to_ucs4_fast (key, -1, &items_written);
+          if (items_written == 1)
+            keysym = (uint32_t) xkb_utf32_to_keysym (*unichar);
+          else
+            keysym =
+              (uint32_t) xkb_keysym_from_name (key, XKB_KEYSYM_NO_FLAGS);
+
           wpe_event.key_code = keysym;
           wpe_event.pressed =
               gst_navigation_event_get_type (event) ==