-/* $OpenBSD: wskbd.c,v 1.109 2021/10/22 04:59:31 anton Exp $ */
+/* $OpenBSD: wskbd.c,v 1.110 2021/12/30 06:55:11 anton Exp $ */
/* $NetBSD: wskbd.c,v 1.80 2005/05/04 01:52:16 augustss Exp $ */
/*
int wskbd_do_open(struct wskbd_softc *, struct wseventvar *);
int wskbd_do_ioctl(struct device *, u_long, caddr_t, int, struct proc *);
+void wskbd_set_keymap(struct wskbd_softc *, struct wscons_keymap *, int);
+
int (*wskbd_get_backlight)(struct wskbd_backlight *);
int (*wskbd_set_backlight)(struct wskbd_backlight *);
}
#endif
for (;;) {
- if (wskbd_load_keymap(&sc->id->t_keymap, layout, &sc->sc_map,
- &sc->sc_maplen) == 0)
+ struct wscons_keymap *map;
+ int maplen;
+
+ if (wskbd_load_keymap(&sc->id->t_keymap, layout, &map,
+ &maplen) == 0) {
+ wskbd_set_keymap(sc, map, maplen);
break;
+ }
#if NWSMUX > 0
if (layout == sc->id->t_keymap.layout)
panic("cannot load keymap");
error = copyin(umdp->map, buf, len);
if (error == 0) {
- wskbd_init_keymap(umdp->maplen,
- &sc->sc_map, &sc->sc_maplen);
- memcpy(sc->sc_map, buf, len);
+ struct wscons_keymap *map;
+
+ map = wskbd_init_keymap(umdp->maplen);
+ memcpy(map, buf, len);
+ wskbd_set_keymap(sc, map, umdp->maplen);
/* drop the variant bits handled by the map */
enc = KB_USER | (KB_VARIANT(sc->id->t_keymap.layout) &
KB_HANDLEDBYWSKBD);
} else if (sc->id->t_keymap.layout & KB_NOENCODING) {
return (0);
} else {
+ struct wscons_keymap *map;
+ int maplen;
+
error = wskbd_load_keymap(&sc->id->t_keymap, enc,
- &sc->sc_map, &sc->sc_maplen);
+ &map, &maplen);
if (error)
return (error);
+ wskbd_set_keymap(sc, map, maplen);
}
wskbd_update_layout(sc->id, enc);
#if NWSMUX > 0
}
#endif
}
+
+void
+wskbd_set_keymap(struct wskbd_softc *sc, struct wscons_keymap *map, int maplen)
+{
+ free(sc->sc_map, M_DEVBUF, sc->sc_maplen * sizeof(*sc->sc_map));
+ sc->sc_map = map;
+ sc->sc_maplen = maplen;
+}
-/* $OpenBSD: wskbdutil.c,v 1.18 2019/01/31 18:01:14 millert Exp $ */
+/* $OpenBSD: wskbdutil.c,v 1.19 2021/12/30 06:55:11 anton Exp $ */
/* $NetBSD: wskbdutil.c,v 1.7 1999/12/21 11:59:13 drochner Exp $ */
/*-
}
}
-void
-wskbd_init_keymap(int newlen, struct wscons_keymap **map, int *maplen)
+struct wscons_keymap *
+wskbd_init_keymap(int maplen)
{
+ struct wscons_keymap *map;
int i;
- if (newlen != *maplen) {
- if (*maplen > 0)
- free(*map, M_DEVBUF,
- *maplen * sizeof(struct wscons_keymap));
- *maplen = newlen;
- *map = mallocarray(newlen, sizeof(struct wscons_keymap),
- M_DEVBUF, M_WAITOK);
- }
-
- for (i = 0; i < *maplen; i++) {
- (*map)[i].command = KS_voidSymbol;
- (*map)[i].group1[0] = KS_voidSymbol;
- (*map)[i].group1[1] = KS_voidSymbol;
- (*map)[i].group2[0] = KS_voidSymbol;
- (*map)[i].group2[1] = KS_voidSymbol;
+ map = mallocarray(maplen, sizeof(*map), M_DEVBUF, M_WAITOK);
+ for (i = 0; i < maplen; i++) {
+ map[i].command = KS_voidSymbol;
+ map[i].group1[0] = KS_voidSymbol;
+ map[i].group1[1] = KS_voidSymbol;
+ map[i].group2[0] = KS_voidSymbol;
+ map[i].group2[1] = KS_voidSymbol;
}
+ return map;
}
int
}
}
- wskbd_init_keymap(i + 1, map, maplen);
+ *map = wskbd_init_keymap(i + 1);
+ *maplen = i + 1;
for (s = stack_ptr - 1; s >= 0; s--) {
mp = stack[s];
-/* $OpenBSD: wsksymvar.h,v 1.9 2021/09/20 17:32:39 anton Exp $ */
+/* $OpenBSD: wsksymvar.h,v 1.10 2021/12/30 06:55:11 anton Exp $ */
/* $NetBSD: wsksymvar.h,v 1.8.4.1 2000/07/07 09:50:21 hannken Exp $ */
/*-
*/
void wskbd_get_mapentry(const struct wskbd_mapdata *, int,
struct wscons_keymap *);
-void wskbd_init_keymap(int, struct wscons_keymap **, int *);
+struct wscons_keymap *wskbd_init_keymap(int);
int wskbd_load_keymap(const struct wskbd_mapdata *, kbd_t,
struct wscons_keymap **, int *);
keysym_t wskbd_compose_value(keysym_t *);