private void KeymapCallback(void *data, wl_keyboard *proxy, wl_keyboard_keymap_format format, int fd, uint size) { if (format != wl_keyboard_keymap_format.XkbV1) { Libc.close(fd); throw new NotImplementedException("Only xkbcommon compatible keymaps are currently supported."); } var kbdStr = Libc.mmap(null, size, Libc.PROT_READ, Libc.MAP_PRIVATE, fd, 0); if (kbdStr == null) { Libc.close(fd); return; } var newKeymap = XkbCommon.xkb_keymap_new_from_string(_xkbContext, kbdStr, XkbCommon.XKB_KEYMAP_FORMAT_TEXT_V1); Libc.munmap(kbdStr, size); Libc.close(fd); if (newKeymap == null) { throw new OpenWindowException("Failed to create xkb keymap."); } var newState = XkbCommon.xkb_state_new(newKeymap); if (newState == null) { XkbCommon.xkb_keymap_unref(newKeymap); throw new OpenWindowException("Failed to create xkb state."); } if (_xkbKeymap != null) { XkbCommon.xkb_keymap_unref(_xkbKeymap); } if (_xkbState != null) { XkbCommon.xkb_state_unref(_xkbState); } _xkbKeymap = newKeymap; _xkbState = newState; UpdateKeymap(); }
public static extern int xkb_state_led_name_is_active(xkb_state *state, byte *name);
public static extern void xkb_state_unref(xkb_state *state);
public static extern int xkb_state_mod_name_is_active(xkb_state *state, byte *name, xkb_state_component type);
public static extern int xkb_state_key_get_utf8(xkb_state *state, uint key, byte *buffer, int size);
public static extern int xkb_state_key_get_utf32(xkb_state *state, uint key);
public static extern uint xkb_state_key_get_one_sym(xkb_state *state, uint key);
public static extern xkb_state_component xkb_state_update_mask(xkb_state *state, uint depressed_mods, uint latched_mods, uint locked_mods, uint depressed_layout, uint latched_layout, uint locked_layout);
public static extern xkb_state_component xkb_state_update_key(xkb_state *state, uint key, wl_keyboard_key_state down);