Exemplo n.º 1
0
        private void KeyboardKeyCallback(void *data, wl_keyboard *proxy, uint serial, uint time, uint lsc, wl_keyboard_key_state state)
        {
            if (lsc >= WaylandKeyMaps.LinuxToOwScanCode.Length)
            {
                return;
            }

            var osc = WaylandKeyMaps.LinuxToOwScanCode[lsc];

            SetKey(osc, state == wl_keyboard_key_state.Pressed);

            if (state == wl_keyboard_key_state.Released)
            {
                return;
            }

            // this returns zero if the key press generates more than 1 character in UTF32
            var utf32 = XkbCommon.xkb_state_key_get_utf32(_xkbState, lsc + 8);

            if (utf32 != 0)
            {
                SendCharacter(utf32);
            }
            else
            {
                var strBufSize = XkbCommon.xkb_state_key_get_utf8(_xkbState, lsc + 8, null, 0);
                if (strBufSize == 0)
                {
                    return;
                }

                byte *strBuf = stackalloc byte[strBufSize];
                XkbCommon.xkb_state_key_get_utf8(_xkbState, lsc + 8, strBuf, strBufSize);

                // We send text in UTF-32 i.e. no more than 32 bits at a time
                var offset = 0;
                while (ReadUtf32FromUtf8(strBuf, ref offset, out utf32))
                {
                    SendCharacter(utf32);
                }
            }
        }
Exemplo n.º 2
0
 public static extern xkb_state_component xkb_state_update_key(xkb_state *state, uint key, wl_keyboard_key_state down);