Skip to content

Commit

Permalink
add raw-keymap/offset_on_explicit option
Browse files Browse the repository at this point in the history
If set to false, the offset is not applied to any explicitly-listed raw
key mappings. Fixes #30
  • Loading branch information
r-c-f committed Feb 1, 2022
1 parent baa9578 commit cb76790
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ using a hardware keyboard,
- add them to the `[raw-keymap]` section as `server = client` pair,
- repeat for any keys that don't work right.

The offset functionality is enabled through `raw-keymap/offset`, though it
can also be disabled for explicit mappings by setting `raw-keymap/offset_on_explicit`
to `false`.

#### Screensaver

Expand Down
4 changes: 3 additions & 1 deletion src/wl_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static bool local_mod_init(struct wlContext *wl_ctx, char *keymap_str) {

static void load_raw_keymap(struct wlContext *ctx)
{
bool offset_on_explicit;
char **key, **val, *endstr;
int i, count, offset, lkey, rkey;
key = NULL;
Expand Down Expand Up @@ -75,6 +76,7 @@ static void load_raw_keymap(struct wlContext *ctx)
/* initialize key state tracking now that the size is known */
ctx->input.key_press_state = xcalloc(ctx->input.key_count, sizeof(*ctx->input.key_press_state));
/* and second pass -- store any actually mappings, apply offset */
offset_on_explicit = configTryBool("raw-keymap/offset_on_explicit", true);
for (i = 0; i < count; ++i) {
errno = 0;
lkey = strtol(key[i], &endstr, 0);
Expand All @@ -84,7 +86,7 @@ static void load_raw_keymap(struct wlContext *ctx)
rkey = strtol(val[i], &endstr, 0);
if (errno || endstr == val[i])
continue;
ctx->input.raw_keymap[lkey] = rkey + offset;
ctx->input.raw_keymap[lkey] = rkey + offset_on_explicit ? offset : 0;
logDbg("set raw key map: %d = %d", lkey, ctx->input.raw_keymap[lkey]);
}

Expand Down

0 comments on commit cb76790

Please sign in to comment.