mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-03-13 02:42:47 +01:00
WIP refacto keyboard.c
This commit is contained in:
parent
ff92a92086
commit
e73316bd7c
2
Makefile
2
Makefile
@ -9,7 +9,7 @@ PKGS = wayland-client xkbcommon pangocairo
|
|||||||
WVKBD_SOURCES += $(wildcard $(SRC)/*.c)
|
WVKBD_SOURCES += $(wildcard $(SRC)/*.c)
|
||||||
WVKBD_HEADERS += $(wildcard $(SRC)/*.h)
|
WVKBD_HEADERS += $(wildcard $(SRC)/*.h)
|
||||||
|
|
||||||
CFLAGS += -std=gnu99 -Wall -g -DWITH_WAYLAND_SHM -DLAYOUT=\"layout.${LAYOUT}.h\"
|
CFLAGS += -std=gnu99 -Wall -g -DWITH_WAYLAND_SHM -DLAYOUT=\"layout.${LAYOUT}.h\" -DKEYMAP=\"keymap.${LAYOUT}.h\"
|
||||||
CFLAGS += $(shell pkg-config --cflags $(PKGS))
|
CFLAGS += $(shell pkg-config --cflags $(PKGS))
|
||||||
LDFLAGS =$(shell pkg-config --libs $(PKGS)) -lm -lutil -lrt
|
LDFLAGS =$(shell pkg-config --libs $(PKGS)) -lm -lutil -lrt
|
||||||
|
|
||||||
|
26
config.def.h
26
config.def.h
@ -3,5 +3,31 @@
|
|||||||
|
|
||||||
static const char *default_font = "Monospace 15";
|
static const char *default_font = "Monospace 15";
|
||||||
|
|
||||||
|
struct clr_scheme scheme = {
|
||||||
|
/* colors */
|
||||||
|
.bg = {.bgra = {15, 15, 15, 225}},
|
||||||
|
.fg = {.bgra = {45, 45, 45, 225}},
|
||||||
|
.high = {.bgra = {100, 100, 100, 225}},
|
||||||
|
.text = {.color = UINT32_MAX},
|
||||||
|
};
|
||||||
|
struct clr_scheme scheme1 = {
|
||||||
|
/* colors */
|
||||||
|
.bg = {.bgra = {15, 15, 15, 225}},
|
||||||
|
.fg = {.bgra = {32, 32, 32, 225}},
|
||||||
|
.high = {.bgra = {100, 100, 100, 225}},
|
||||||
|
.text = {.color = UINT32_MAX},
|
||||||
|
};
|
||||||
|
|
||||||
|
/* layers is an ordered list of layouts, used to cycle through */
|
||||||
|
static enum layout_id layers[] = {
|
||||||
|
Full, //First layout is the default layout on startup
|
||||||
|
Special,
|
||||||
|
Emoji,
|
||||||
|
Simple,
|
||||||
|
Cyrillic,
|
||||||
|
Arabic,
|
||||||
|
NumLayouts //signals the last item, may not be omitted
|
||||||
|
};
|
||||||
|
|
||||||
#endif // config_def_h_INCLUDED
|
#endif // config_def_h_INCLUDED
|
||||||
|
|
||||||
|
@ -13,6 +13,11 @@
|
|||||||
fprintf(stderr, __VA_ARGS__); \
|
fprintf(stderr, __VA_ARGS__); \
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
#ifndef KEYMAP
|
||||||
|
#error "make sure to define KEYMAP"
|
||||||
|
#endif
|
||||||
|
#include KEYMAP
|
||||||
|
|
||||||
void
|
void
|
||||||
kbd_switch_layout(struct kbd *kb, struct layout *l) {
|
kbd_switch_layout(struct kbd *kb, struct layout *l) {
|
||||||
kb->prevlayout = kb->layout;
|
kb->prevlayout = kb->layout;
|
||||||
|
@ -9,8 +9,6 @@
|
|||||||
/* spacing between keys */
|
/* spacing between keys */
|
||||||
#define KBD_KEY_BORDER 2
|
#define KBD_KEY_BORDER 2
|
||||||
|
|
||||||
#include "keymap.mobintl.h"
|
|
||||||
|
|
||||||
/* layout declarations */
|
/* layout declarations */
|
||||||
enum layout_id {
|
enum layout_id {
|
||||||
Full = 0,
|
Full = 0,
|
||||||
@ -61,17 +59,6 @@ enum layout_id {
|
|||||||
NumLayouts,
|
NumLayouts,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* layers is an ordered list of layouts, used to cycle through */
|
|
||||||
static enum layout_id layers[] = {
|
|
||||||
Full, //First layout is the default layout on startup
|
|
||||||
Special,
|
|
||||||
Emoji,
|
|
||||||
Simple,
|
|
||||||
Cyrillic,
|
|
||||||
Arabic,
|
|
||||||
NumLayouts //signals the last item, may not be omitted
|
|
||||||
};
|
|
||||||
|
|
||||||
static struct key keys_full[], keys_special[], keys_simple[], keys_cyrillic[],
|
static struct key keys_full[], keys_special[], keys_simple[], keys_cyrillic[],
|
||||||
keys_arabic[],
|
keys_arabic[],
|
||||||
keys_emoji[],
|
keys_emoji[],
|
||||||
@ -138,28 +125,6 @@ static struct layout layouts[NumLayouts] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* keyboard settings */
|
|
||||||
static struct kbd keyboard = {
|
|
||||||
/* default layout */
|
|
||||||
.layers = (enum layout_id *) &layers,
|
|
||||||
.layer_index = 0,
|
|
||||||
.scheme =
|
|
||||||
{
|
|
||||||
/* colors */
|
|
||||||
.bg = {.bgra = {15, 15, 15, 225}},
|
|
||||||
.fg = {.bgra = {45, 45, 45, 225}},
|
|
||||||
.high = {.bgra = {100, 100, 100, 225}},
|
|
||||||
.text = {.color = UINT32_MAX},
|
|
||||||
},
|
|
||||||
.scheme1 =
|
|
||||||
{
|
|
||||||
/* colors */
|
|
||||||
.bg = {.bgra = {15, 15, 15, 225}},
|
|
||||||
.fg = {.bgra = {32, 32, 32, 225}},
|
|
||||||
.high = {.bgra = {100, 100, 100, 225}},
|
|
||||||
.text = {.color = UINT32_MAX},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
/* key layouts
|
/* key layouts
|
||||||
*
|
*
|
||||||
|
10
main.c
10
main.c
@ -8,7 +8,6 @@
|
|||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include "drw.h"
|
|
||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
@ -42,6 +41,7 @@ static uint32_t anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM |
|
|||||||
/* application state */
|
/* application state */
|
||||||
static bool run_display = true;
|
static bool run_display = true;
|
||||||
static int cur_x = -1, cur_y = -1;
|
static int cur_x = -1, cur_y = -1;
|
||||||
|
static struct kbd keyboard;
|
||||||
|
|
||||||
/* event handler prototypes */
|
/* event handler prototypes */
|
||||||
static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
|
static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
|
||||||
@ -333,6 +333,14 @@ main(int argc, char **argv) {
|
|||||||
if ((tmp = getenv("WVKBD_HEIGHT")))
|
if ((tmp = getenv("WVKBD_HEIGHT")))
|
||||||
height = atoi(tmp);
|
height = atoi(tmp);
|
||||||
|
|
||||||
|
/* keyboard settings */
|
||||||
|
keyboard.layers = (enum layout_id *) &layers;
|
||||||
|
keyboard.scheme = scheme;
|
||||||
|
keyboard.layer_index = 0;
|
||||||
|
keyboard.scheme1 = scheme1;
|
||||||
|
keyboard.scheme1 = scheme1;
|
||||||
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (i = 1; argv[i]; i++) {
|
for (i = 1; argv[i]; i++) {
|
||||||
if ((!strcmp(argv[i], "-v")) || (!strcmp(argv[i], "--version"))) {
|
if ((!strcmp(argv[i], "-v")) || (!strcmp(argv[i], "--version"))) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user