Fix de-neo layout

- Add possibility to specify layout variant with -k <layout>-<variant>
- Add ISO_Level5_Shift and ISO_Level5_Lock to modifier keys
pull/75/head
Flakebi 2020-10-16 22:46:56 +02:00 committed by Andri Yngvason
parent 41f30bf7ca
commit 98d703bfa8
3 changed files with 22 additions and 6 deletions

View File

@ -39,6 +39,6 @@ struct keyboard {
struct intset key_state;
};
int keyboard_init(struct keyboard* self, const char* layout);
int keyboard_init(struct keyboard* self, const char* layout, const char* variant);
void keyboard_destroy(struct keyboard* self);
void keyboard_feed(struct keyboard* self, xkb_keysym_t symbol, bool is_pressed);

View File

@ -149,7 +149,7 @@ void keyboard_dump_lookup_table(const struct keyboard* self)
keyboard__dump_entry(self, &self->lookup_table[i]);
}
int keyboard_init(struct keyboard* self, const char* layout)
int keyboard_init(struct keyboard* self, const char* layout, const char* variant)
{
self->context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
if (!self->context)
@ -161,6 +161,7 @@ int keyboard_init(struct keyboard* self, const char* layout)
struct xkb_rule_names rule_names = {
.layout = layout,
.model = "pc105",
.variant = variant,
};
self->keymap = xkb_keymap_new_from_names(self->context, &rule_names, 0);
@ -321,6 +322,8 @@ static bool keyboard_symbol_is_mod(xkb_keysym_t symbol)
case XKB_KEY_Super_R:
case XKB_KEY_Hyper_L:
case XKB_KEY_Hyper_R:
case XKB_KEY_ISO_Level5_Shift:
case XKB_KEY_ISO_Level5_Lock:
return true;
}

View File

@ -98,6 +98,7 @@ struct wayvnc {
struct pixman_region16 current_damage;
const char* kb_layout;
const char* kb_variant;
uint32_t damage_area_sum;
uint32_t n_frames_captured;
@ -684,7 +685,7 @@ int wayvnc_usage(FILE* stream, int rc)
"\n"
" -C,--config=<path> Select a config file.\n"
" -o,--output=<name> Select output to capture.\n"
" -k,--keyboard=<layout> Select keyboard layout.\n"
" -k,--keyboard=<layout>[-<variant>] Select keyboard layout with an optional variant.\n"
" -s,--seat=<name> Select seat by name.\n"
" -r,--render-cursor Enable overlay cursor rendering.\n"
" -f,--max-fps=<fps> Set the rate limit (default 30).\n"
@ -762,6 +763,18 @@ static void start_performance_ticker(struct wayvnc* self)
aml_unref(ticker);
}
void parse_keyboard_option(struct wayvnc* self, char* arg)
{
// Find optional variant, separated by -
char* index = strchr(arg, '-');
if (index != NULL) {
self->kb_variant = index + 1;
// layout needs to be 0-terminated, replace the - by 0
*index = 0;
}
self->kb_layout = arg;
}
int show_version(void)
{
printf("wayvnc: %s\n", wayvnc_version);
@ -815,7 +828,7 @@ int main(int argc, char* argv[])
output_name = optarg;
break;
case 'k':
self.kb_layout = optarg;
parse_keyboard_option(&self, optarg);
break;
case 's':
seat_name = optarg;
@ -914,7 +927,7 @@ int main(int argc, char* argv[])
zwp_virtual_keyboard_manager_v1_create_virtual_keyboard(
self.keyboard_manager, self.selected_seat->wl_seat);
keyboard_init(&self.keyboard_backend, self.kb_layout);
keyboard_init(&self.keyboard_backend, self.kb_layout, self.kb_variant);
self.pointer_backend.vnc = self.nvnc;
self.pointer_backend.output = self.selected_output;