mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-07-13 22:44:33 +02:00
Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
1577b2f742 | |||
9bbc8d4a99 | |||
dfae590264 | |||
7fe983af16 | |||
acf38cf46e | |||
7af52d695d | |||
f446bf9147 | |||
e29b029308 | |||
12c0d67f41 | |||
5de2fcc39d | |||
a10b504cda | |||
14f0f0824b | |||
f9bf42129a | |||
0cd0d5e1a1 | |||
1843e60a74 | |||
a2cacb7e25 | |||
dbe1e01fe9 | |||
c1b95f2700 | |||
9d6696fb23 | |||
f540cf36fa | |||
b974877be4 | |||
6d34f5af59 | |||
22ff01fb8b | |||
28c24749ba | |||
cc73ab2c7c |
1
Makefile
1
Makefile
@ -48,5 +48,6 @@ install: all
|
||||
mkdir -p ${DESTDIR}${PREFIX}/bin
|
||||
cp -f ${NAME}-${LAYOUT} ${DESTDIR}${PREFIX}/bin
|
||||
chmod 755 ${DESTDIR}${PREFIX}/bin/${NAME}-${LAYOUT}
|
||||
mkdir -p "${DESTDIR}${MANPREFIX}/man1"
|
||||
sed "s/VERSION/${VERSION}/g" < ${MAN1} > ${DESTDIR}${MANPREFIX}/man1/${MAN1}
|
||||
chmod 644 ${DESTDIR}${MANPREFIX}/man1/${MAN1}
|
||||
|
@ -1,4 +1,4 @@
|
||||
VERSION = 0.8.1
|
||||
VERSION = 0.11
|
||||
CFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=700
|
||||
PREFIX = /usr/local
|
||||
MANPREFIX = ${PREFIX}/share/man
|
||||
|
18
drw.c
18
drw.c
@ -20,30 +20,12 @@ drwsurf_resize(struct drwsurf *ds, uint32_t w, uint32_t h, uint32_t s) {
|
||||
setup_buffer(ds);
|
||||
}
|
||||
|
||||
static void surface_frame_callback(void *data, struct wl_callback *cb,
|
||||
uint32_t time);
|
||||
|
||||
static struct wl_callback_listener frame_listener = {.done =
|
||||
surface_frame_callback};
|
||||
|
||||
void
|
||||
drwsurf_flip(struct drwsurf *ds) {
|
||||
ds->cb = wl_surface_frame(ds->surf);
|
||||
wl_callback_add_listener(ds->cb, &frame_listener, (void *)ds);
|
||||
|
||||
wl_surface_attach(ds->surf, ds->buf, 0, 0);
|
||||
wl_surface_commit(ds->surf);
|
||||
}
|
||||
|
||||
void
|
||||
surface_frame_callback(void *data, struct wl_callback *cb, uint32_t time) {
|
||||
struct drwsurf *ds = (struct drwsurf *)data;
|
||||
wl_callback_destroy(cb);
|
||||
ds->cb = NULL;
|
||||
|
||||
drwsurf_flip(ds);
|
||||
}
|
||||
|
||||
void
|
||||
drw_draw_text(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h, const char *label) {
|
||||
|
1
drw.h
1
drw.h
@ -15,7 +15,6 @@ struct drwsurf {
|
||||
struct wl_surface *surf;
|
||||
struct wl_buffer *buf;
|
||||
struct wl_shm *shm;
|
||||
struct wl_callback *cb;
|
||||
unsigned char *pool_data;
|
||||
|
||||
cairo_t *cairo;
|
||||
|
133
keyboard.c
133
keyboard.c
@ -45,11 +45,49 @@ kbd_get_rows(struct layout *l) {
|
||||
return rows + 1;
|
||||
}
|
||||
|
||||
void
|
||||
kbd_init(struct kbd *kb, struct layout *layouts, char *layer_names_list) {
|
||||
enum layout_id *
|
||||
kbd_init_layers(char *layer_names_list) {
|
||||
enum layout_id *layers;
|
||||
uint8_t numlayers = 0;
|
||||
bool found;
|
||||
char *s;
|
||||
int i;
|
||||
bool found;
|
||||
|
||||
layers = malloc(MAX_LAYERS * sizeof(enum layout_id));
|
||||
s = strtok(layer_names_list, ",");
|
||||
while (s != NULL) {
|
||||
if (numlayers + 1 == MAX_LAYERS) {
|
||||
fprintf(stderr, "too many layers specified");
|
||||
exit(3);
|
||||
}
|
||||
found = false;
|
||||
for (i = 0; i < NumLayouts - 1; i++) {
|
||||
if (layouts[i].name && strcmp(layouts[i].name, s) == 0) {
|
||||
fprintf(stderr, "layer #%d = %s\n", numlayers + 1, s);
|
||||
layers[numlayers++] = i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
fprintf(stderr, "No such layer: %s\n", s);
|
||||
exit(3);
|
||||
}
|
||||
s = strtok(NULL, ",");
|
||||
}
|
||||
layers[numlayers] = NumLayouts; // mark the end of the sequence
|
||||
if (numlayers == 0) {
|
||||
fprintf(stderr, "No layers defined\n");
|
||||
exit(3);
|
||||
}
|
||||
|
||||
return layers;
|
||||
}
|
||||
|
||||
void
|
||||
kbd_init(struct kbd *kb, struct layout *layouts,
|
||||
char *layer_names_list, char *landscape_layer_names_list) {
|
||||
int i;
|
||||
|
||||
fprintf(stderr, "Initializing keyboard\n");
|
||||
|
||||
@ -61,36 +99,10 @@ kbd_init(struct kbd *kb, struct layout *layouts, char *layer_names_list) {
|
||||
|
||||
kb->layer_index = 0;
|
||||
|
||||
if (layer_names_list) {
|
||||
uint8_t numlayers = 0;
|
||||
kb->layers = malloc(MAX_LAYERS * sizeof(enum layout_id));
|
||||
s = strtok(layer_names_list, ",");
|
||||
while (s != NULL) {
|
||||
if (numlayers + 1 == MAX_LAYERS) {
|
||||
fprintf(stderr, "too many layers specified");
|
||||
exit(3);
|
||||
}
|
||||
found = false;
|
||||
for (i = 0; i < NumLayouts - 1; i++) {
|
||||
if (kb->layouts[i].name && strcmp(kb->layouts[i].name, s) == 0) {
|
||||
fprintf(stderr, "layer #%d = %s\n", numlayers + 1, s);
|
||||
kb->layers[numlayers++] = i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
fprintf(stderr, "No such layer: %s\n", s);
|
||||
exit(3);
|
||||
}
|
||||
s = strtok(NULL, ",");
|
||||
}
|
||||
kb->layers[numlayers] = NumLayouts; // mark the end of the sequence
|
||||
if (numlayers == 0) {
|
||||
fprintf(stderr, "No layers defined\n");
|
||||
exit(3);
|
||||
}
|
||||
}
|
||||
if (layer_names_list)
|
||||
kb->layers = kbd_init_layers(layer_names_list);
|
||||
if (landscape_layer_names_list)
|
||||
kb->landscape_layers = kbd_init_layers(landscape_layer_names_list);
|
||||
|
||||
i = 0;
|
||||
enum layout_id lid = kb->layers[0];
|
||||
@ -122,16 +134,23 @@ kbd_init_layout(struct layout *l, uint32_t width, uint32_t height) {
|
||||
|
||||
struct key *k = l->keys;
|
||||
double rowlength = kbd_get_row_length(k);
|
||||
double rowwidth = 0.0;
|
||||
while (k->type != Last) {
|
||||
if (k->type == EndRow) {
|
||||
y += l->keyheight;
|
||||
x = 0;
|
||||
rowwidth = 0.0;
|
||||
rowlength = kbd_get_row_length(k + 1);
|
||||
} else if (k->width > 0) {
|
||||
k->x = x;
|
||||
k->y = y;
|
||||
k->w = ((double)width / rowlength) * k->width;
|
||||
x += k->w;
|
||||
rowwidth += k->width;
|
||||
if (x < (rowwidth / rowlength) * (double)width) {
|
||||
k->w++;
|
||||
x++;
|
||||
}
|
||||
}
|
||||
k->h = l->keyheight;
|
||||
k++;
|
||||
@ -207,6 +226,8 @@ kbd_release_key(struct kbd *kb, uint32_t time) {
|
||||
kbd_draw_layout(kb);
|
||||
kb->last_swipe = NULL;
|
||||
}
|
||||
|
||||
drwsurf_flip(kb->surf);
|
||||
}
|
||||
|
||||
void
|
||||
@ -230,12 +251,14 @@ kbd_motion_key(struct kbd *kb, uint32_t time, uint32_t x, uint32_t y) {
|
||||
} else {
|
||||
kbd_unpress_key(kb, time);
|
||||
}
|
||||
|
||||
drwsurf_flip(kb->surf);
|
||||
}
|
||||
|
||||
void
|
||||
kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
||||
if ((kb->compose == 1) && (k->type != Compose) && (k->type != Mod) &&
|
||||
(k->layout)) {
|
||||
if ((kb->compose == 1) && (k->type != Compose) && (k->type != Mod) &&
|
||||
(k->type != NextLayer) && (k->layout)) {
|
||||
kb->compose++;
|
||||
if (kb->debug)
|
||||
fprintf(stderr, "showing compose %d\n", kb->compose);
|
||||
@ -297,8 +320,30 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
||||
}
|
||||
break;
|
||||
case NextLayer:
|
||||
// switch to the next layout in the layer sequence
|
||||
kb->layer_index++;
|
||||
if ((kb->mods & Ctrl) || (kb->mods & Alt) || (kb->mods & AltGr) || ((bool)kb->compose)) {
|
||||
// with modifiers: switch to the first layer
|
||||
kb->layer_index = 0;
|
||||
kb->mods = 0;
|
||||
} else if ((kb->mods & Shift) || (kb->mods & CapsLock)) {
|
||||
// with modifiers: switch to the previous layout in the layer sequence
|
||||
if (kb->layer_index > 0) {
|
||||
kb->layer_index--;
|
||||
} else {
|
||||
size_t layercount = 0;
|
||||
for (size_t i = 0; layercount == 0; i++) {
|
||||
if (kb->landscape) {
|
||||
if (kb->landscape_layers[i] == NumLayouts) layercount = i;
|
||||
} else {
|
||||
if (kb->layers[i] == NumLayouts) layercount = i;
|
||||
}
|
||||
}
|
||||
kb->layer_index = layercount - 1;
|
||||
}
|
||||
kb->mods = 0;
|
||||
} else {
|
||||
// normal behaviour: switch to the next layout in the layer sequence
|
||||
kb->layer_index++;
|
||||
}
|
||||
enum layout_id layer;
|
||||
if (kb->landscape) {
|
||||
layer = kb->landscape_layers[kb->layer_index];
|
||||
@ -313,6 +358,10 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
||||
layer = kb->layers[kb->layer_index];
|
||||
}
|
||||
}
|
||||
if ((bool)kb->compose) {
|
||||
kb->compose = 0;
|
||||
kbd_draw_key(kb, k, Unpress);
|
||||
}
|
||||
kbd_switch_layout(kb, &kb->layouts[layer]);
|
||||
break;
|
||||
case BackLayer:
|
||||
@ -336,6 +385,8 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
drwsurf_flip(kb->surf);
|
||||
}
|
||||
|
||||
void
|
||||
@ -440,14 +491,14 @@ kbd_resize(struct kbd *kb, struct layout *layouts, uint8_t layoutcount) {
|
||||
void
|
||||
draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||
uint32_t height, uint32_t border, Color color) {
|
||||
drw_fill_rectangle(ds, color, x + border, y + border, width - border,
|
||||
height - border);
|
||||
drw_fill_rectangle(ds, color, x + border, y + border, width - (border * 2),
|
||||
height - (border * 2));
|
||||
}
|
||||
void
|
||||
draw_over_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||
uint32_t height, uint32_t border, Color color) {
|
||||
drw_over_rectangle(ds, color, x + border, y + border, width - border,
|
||||
height - border);
|
||||
drw_over_rectangle(ds, color, x + border, y + border, width - (border * 2),
|
||||
height - (border * 2));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -115,7 +115,8 @@ void draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||
void draw_over_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||
uint32_t height, uint32_t border, Color color);
|
||||
|
||||
void kbd_init(struct kbd *kb, struct layout *layouts, char *layer_names_list);
|
||||
void kbd_init(struct kbd *kb, struct layout *layouts,
|
||||
char *layer_names_list, char *landscape_layer_names_list);
|
||||
void kbd_init_layout(struct layout *l, uint32_t width, uint32_t height);
|
||||
struct key *kbd_get_key(struct kbd *kb, uint32_t x, uint32_t y);
|
||||
void kbd_unpress_key(struct kbd *kb, uint32_t time);
|
||||
|
114
layout.mobintl.h
114
layout.mobintl.h
@ -5,11 +5,8 @@
|
||||
/* how tall the keyboard should be by default (can be overriden) */
|
||||
#define KBD_PIXEL_LANDSCAPE_HEIGHT 120
|
||||
|
||||
/* if your layout leaves an empty margin, increase this to fix it */
|
||||
#define KBD_PIXEL_OVERSCAN_WIDTH 5
|
||||
|
||||
/* spacing between keys */
|
||||
#define KBD_KEY_BORDER 2
|
||||
/* spacing around each key */
|
||||
#define KBD_KEY_BORDER 1
|
||||
|
||||
/* layout declarations */
|
||||
enum layout_id {
|
||||
@ -218,7 +215,7 @@ static struct key keys_full[] = {
|
||||
{"", "", 0.5, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"z", "Z", 1.0, Code, KEY_Z, &layouts[ComposeZ]},
|
||||
{"x", "X", 1.0, Code, KEY_X, &layouts[ComposeX]},
|
||||
{"c", "C", 1.0, Code, KEY_C, &layouts[ComposeC]},
|
||||
@ -278,7 +275,7 @@ static struct key keys_special[] = {
|
||||
{"Del", "Del", 1.0, Code, KEY_DELETE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"⇧", "⇧", 2.0, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 2.0, Mod, Shift, .scheme = 1},
|
||||
{";", ":", 1.0, Code, KEY_SEMICOLON},
|
||||
{"/", ">", 1.0, Code, KEY_SLASH},
|
||||
{"<", "«", 1.0, Code, KEY_COMMA, 0, AltGr},
|
||||
@ -327,7 +324,7 @@ static struct key keys_simple[] = {
|
||||
{"'", "\"", 0.5, Code, KEY_APOSTROPHE, &layouts[ComposeBracket]},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"z", "Z", 1.0, Code, KEY_Z, &layouts[ComposeZ]},
|
||||
{"x", "X", 1.0, Code, KEY_X, &layouts[ComposeX]},
|
||||
{"c", "C", 1.0, Code, KEY_C, &layouts[ComposeC]},
|
||||
@ -350,8 +347,9 @@ static struct key keys_simple[] = {
|
||||
};
|
||||
|
||||
static struct key keys_dialer[] = {
|
||||
{"Esc", "Esc", 1.0, Code, KEY_ESC, .scheme = 1},
|
||||
{"⌫", "⌫", 1.0, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"Esc", "Esc", 1.0, Code, KEY_ESC},
|
||||
{"+","+", 1.0, Code, KEY_KPPLUS},
|
||||
{"⌫", "⌫", 1.0, Code, KEY_BACKSPACE},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"1", "1", 1.0, Code, KEY_1},
|
||||
{"2", "2", 1.0, Code, KEY_2},
|
||||
@ -401,7 +399,7 @@ static struct key keys_simplegrid[] = {
|
||||
{"'", "\"", 1.0, Code, KEY_APOSTROPHE, &layouts[ComposeBracket]},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"⇧", "⇧", 1.0, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.0, Mod, Shift, .scheme = 1},
|
||||
{"z", "Z", 1.0, Code, KEY_Z, &layouts[ComposeZ]},
|
||||
{"x", "X", 1.0, Code, KEY_X, &layouts[ComposeX]},
|
||||
{"c", "C", 1.0, Code, KEY_C, &layouts[ComposeC]},
|
||||
@ -467,7 +465,7 @@ static struct key keys_cyrillic[] = {
|
||||
{"ж", "Ж", 1.0, Code, KEY_SEMICOLON},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"я", "Я", 1.0, Code, KEY_Z},
|
||||
{"ч", "Ч", 1.0, Code, KEY_X, &layouts[ComposeCyrChe]},
|
||||
{"c", "С", 1.0, Code, KEY_C},
|
||||
@ -512,9 +510,9 @@ static struct key keys_arabic[] = {
|
||||
{"غ", "إ", 1.0, Code, KEY_Y},
|
||||
{"ع", "`", 1.0, Code, KEY_U},
|
||||
{"ه", "", 1.0, Code, KEY_I},
|
||||
{"ج", ";", 1.0, Code, KEY_O},
|
||||
{"خ", ";", 1.0, Code, KEY_O},
|
||||
{"ح", "", 1.0, Code, KEY_P},
|
||||
{"خ", "<", 1.0, Code, KEY_LEFTBRACE},
|
||||
{"ج", "<", 1.0, Code, KEY_LEFTBRACE},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"ش", "ـِ", 1.0, Code, KEY_A},
|
||||
@ -545,7 +543,7 @@ static struct key keys_arabic[] = {
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"Abc", "Abc", 1.0, NextLayer, .scheme = 1},
|
||||
{"⇧", "⇧", 1.0, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.0, Mod, Shift, .scheme = 1},
|
||||
{"Cmp", "Cmp", 1.0, Compose, .scheme = 1},
|
||||
{"", "", 5.0, Code, KEY_SPACE},
|
||||
{"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme = 1},
|
||||
@ -605,7 +603,7 @@ static struct key keys_georgian[] = {
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"Abc", "Abc", 1.0, NextLayer, .scheme = 1},
|
||||
{"⇧", "⇧", 1.0, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.0, Mod, Shift, .scheme = 1},
|
||||
{"Cmp", "Cmp", 1.0, Compose, .scheme = 1},
|
||||
{"", "", 5.0, Code, KEY_SPACE},
|
||||
{"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme = 1},
|
||||
@ -656,7 +654,7 @@ static struct key keys_persian[] = {
|
||||
{"گ", "؛", 1.0, Code, KEY_APOSTROPHE},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"ظ", "ك", 1.0, Code, KEY_Z},
|
||||
{"ط", "ـٓ", 1.0, Code, KEY_X},
|
||||
{"ژ", ">", 1.0, Code, KEY_BACKSLASH},
|
||||
@ -720,7 +718,7 @@ static struct key keys_greek[] = {
|
||||
{"΄", "¨", 1.0, Code, KEY_SEMICOLON},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"ζ", "Ζ", 1.0, Code, KEY_Z},
|
||||
{"χ", "Χ", 1.0, Code, KEY_X},
|
||||
{"ψ", "Ψ", 1.0, Code, KEY_C},
|
||||
@ -757,7 +755,7 @@ static struct key keys_compose_a[] = {
|
||||
{"α", "Α", 1.0, Copy, 0x03B1, 0, 0x0391},
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -785,7 +783,7 @@ static struct key keys_compose_e[] = {
|
||||
{"ǝ", "Ə", 1.0, Copy, 0x0259, 0, 0x018F},
|
||||
{"", "", 8.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -806,7 +804,7 @@ static struct key keys_compose_y[] = {
|
||||
{"", "", 0.0, EndRow},
|
||||
{"υ", "Υ", 1.0, Copy, 0x03C5, 0, 0x03A5},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -834,7 +832,7 @@ static struct key keys_compose_u[] = {
|
||||
{"υ", "Υ", 1.0, Copy, 0x03C5, 0, 0x03A5},
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -863,7 +861,7 @@ static struct key keys_compose_o[] = {
|
||||
{"ω", "Ο", 1.0, Copy, 0x03C9, 0, 0x03A9},
|
||||
{"", "", 8.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -892,7 +890,7 @@ static struct key keys_compose_i[] = {
|
||||
{"η", "Η", 1.0, Copy, 0x03B7, 0, 0x0397},
|
||||
{"", "", 8.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -928,7 +926,7 @@ static struct key keys_emoji[] = {
|
||||
{"😒", "👀", 1.0, Copy, 0x1f612, 0, 0x1f440},
|
||||
{"😓", "💀", 1.0, Copy, 0x1f613, 0, 0x1f480},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.0, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.0, Mod, Shift, .scheme = 1},
|
||||
{"😛", "😜", 1.0, Copy, 0x1f61b, 0, 0x1f61c},
|
||||
{"😮", "😝", 1.0, Copy, 0x1f62e, 0, 0x1f61d},
|
||||
{"😟", "😞", 1.0, Copy, 0x1f61f, 0, 0x1f61e},
|
||||
@ -1003,7 +1001,7 @@ static struct key keys_landscape[] = {
|
||||
{"-", "_", 0.5, Code, KEY_MINUS, &layouts[ComposeBracket], .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"z", "Z", 1.0, Code, KEY_Z, &layouts[ComposeZ]},
|
||||
{"x", "X", 1.0, Code, KEY_X, &layouts[ComposeX]},
|
||||
{"c", "C", 1.0, Code, KEY_C, &layouts[ComposeC]},
|
||||
@ -1035,7 +1033,7 @@ static struct key keys_compose_w[] = {
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1057,7 +1055,7 @@ static struct key keys_compose_r[] = {
|
||||
{"ρ", "Ρ", 1.0, Copy, 0x03C1, 0, 0x03A1},
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1081,7 +1079,7 @@ static struct key keys_compose_t[] = {
|
||||
{"θ", "Θ", 1.0, Copy, 0x03B8, 0, 0x0398},
|
||||
{"", "", 8.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1100,7 +1098,7 @@ static struct key keys_compose_p[] = {
|
||||
{"π", "Π", 1.0, Copy, 0x03C0, 0, 0x03A0},
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1125,7 +1123,7 @@ static struct key keys_compose_s[] = {
|
||||
{"ς", "Σ", 1.0, Copy, 0x03C2, 0, 0x03A3},
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1147,7 +1145,7 @@ static struct key keys_compose_d[] = {
|
||||
{"δ", "Δ", 1.0, Copy, 0x03B4, 0, 0x0394},
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1166,7 +1164,7 @@ static struct key keys_compose_f[] = {
|
||||
{"φ", "Φ", 1.0, Copy, 0x03C6, 0, 0x03A6},
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1187,7 +1185,7 @@ static struct key keys_compose_g[] = {
|
||||
{"γ", "Γ", 1.0, Copy, 0x03B3, 0, 0x0393},
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1208,7 +1206,7 @@ static struct key keys_compose_h[] = {
|
||||
{"η", "Η", 1.0, Copy, 0x03B7, 0, 0x0397},
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1227,7 +1225,7 @@ static struct key keys_compose_j[] = {
|
||||
{"", "", 0.0, EndRow},
|
||||
{"", "", 10.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1248,7 +1246,7 @@ static struct key keys_compose_k[] = {
|
||||
{"κ", "Κ", 1.0, Copy, 0x03BA, 0, 0x039A},
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1270,7 +1268,7 @@ static struct key keys_compose_l[] = {
|
||||
{"λ", "Λ", 1.0, Copy, 0x03BB, 0, 0x039B},
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1292,7 +1290,7 @@ static struct key keys_compose_z[] = {
|
||||
{"ζ", "Ζ", 1.0, Copy, 0x03B6, 0, 0x0396},
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1312,7 +1310,7 @@ static struct key keys_compose_x[] = {
|
||||
{"ξ", "Ξ", 1.0, Copy, 0x03BE, 0, 0x039E},
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1336,7 +1334,7 @@ static struct key keys_compose_c[] = {
|
||||
{"χ", "Χ", 1.0, Copy, 0x03C7, 0, 0x03A7},
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1354,7 +1352,7 @@ static struct key keys_compose_v[] = {
|
||||
{"", "", 0.0, EndRow},
|
||||
{"", "", 10.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1373,7 +1371,7 @@ static struct key keys_compose_b[] = {
|
||||
{"β", "Β", 1.0, Copy, 0x03B2, 0, 0x0392},
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1397,7 +1395,7 @@ static struct key keys_compose_n[] = {
|
||||
{"ν", "Ν", 1.0, Copy, 0x03BD, 0, 0x039D},
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1416,7 +1414,7 @@ static struct key keys_compose_m[] = {
|
||||
{"μ", "Μ", 1.0, Copy, 0x03BC, 0, 0x039C},
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1435,7 +1433,7 @@ static struct key keys_compose_cyr_i[] = {
|
||||
{"", "", 8.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1453,7 +1451,7 @@ static struct key keys_compose_cyr_j[] = {
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1471,7 +1469,7 @@ static struct key keys_compose_cyr_e[] = {
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1489,7 +1487,7 @@ static struct key keys_compose_cyr_u[] = {
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1507,7 +1505,7 @@ static struct key keys_compose_cyr_l[] = {
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1525,7 +1523,7 @@ static struct key keys_compose_cyr_n[] = {
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1544,7 +1542,7 @@ static struct key keys_compose_cyr_che[] = {
|
||||
{"", "", 8.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1563,7 +1561,7 @@ static struct key keys_compose_cyr_tse[] = {
|
||||
{"", "", 8.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1581,7 +1579,7 @@ static struct key keys_compose_cyr_g[] = {
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1599,7 +1597,7 @@ static struct key keys_compose_cyr_k[] = {
|
||||
{"", "", 9.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"", "", 7, Pad},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -1626,7 +1624,7 @@ static struct key keys_compose_math[] = {
|
||||
{"", "", 0.0, EndRow},
|
||||
{"", "", 10.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 2, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 2, Mod, Shift, .scheme = 1},
|
||||
{"+", "+", 1, Code, KEY_EQUAL, 0, Shift},
|
||||
{"/", "/", 1, Code, KEY_SLASH},
|
||||
{"*", "*", 1, Code, KEY_8, 0, Shift},
|
||||
@ -1658,7 +1656,7 @@ static struct key keys_compose_punctuation[] = {
|
||||
{"", "", 0.0, EndRow},
|
||||
{"", "", 10.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 2, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 2, Mod, Shift, .scheme = 1},
|
||||
{"…", "…", 1, Copy, 0x2026, 0, 0x2026},
|
||||
{":", ":", 1, Code, KEY_SEMICOLON, 0, Shift},
|
||||
{";", ";", 1, Code, KEY_SEMICOLON, 0},
|
||||
@ -1691,7 +1689,7 @@ static struct key keys_compose_bracket[] = {
|
||||
{"\"", "\"", 1, Code, KEY_APOSTROPHE, 0, Shift},
|
||||
{"'", "'", 1, Code, KEY_APOSTROPHE},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 2, Mod, Shift, .scheme = 1},
|
||||
{"⇧", "⇫", 2, Mod, Shift, .scheme = 1},
|
||||
{"", "", 8, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"Abc", "Abc", 1.0, BackLayer},
|
||||
|
252
main.c
252
main.c
@ -5,6 +5,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/signalfd.h>
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
#include <wayland-client.h>
|
||||
#include <wchar.h>
|
||||
@ -251,25 +253,29 @@ static void
|
||||
display_handle_geometry(void *data, struct wl_output *wl_output, int x, int y,
|
||||
int physical_width, int physical_height, int subpixel,
|
||||
const char *make, const char *model, int transform) {
|
||||
if (transform % 2 == 0 && keyboard.landscape) {
|
||||
keyboard.landscape = false;
|
||||
height = normal_height;
|
||||
} else if (transform % 2 != 0 && !keyboard.landscape) {
|
||||
keyboard.landscape = true;
|
||||
height = landscape_height;
|
||||
} else {
|
||||
return; // no changes
|
||||
// Swap width and height on rotated displays
|
||||
if (transform % 2 != 0) {
|
||||
int tmp = physical_width;
|
||||
physical_width = physical_height;
|
||||
physical_height = tmp;
|
||||
}
|
||||
|
||||
bool landscape = physical_width > physical_height;
|
||||
if (landscape == keyboard.landscape) return;
|
||||
keyboard.landscape = landscape;
|
||||
|
||||
enum layout_id layer;
|
||||
if (keyboard.landscape) {
|
||||
layer = keyboard.landscape_layers[0];
|
||||
height = landscape_height;
|
||||
} else {
|
||||
layer = keyboard.layers[0];
|
||||
height = normal_height;
|
||||
}
|
||||
|
||||
keyboard.layout = &keyboard.layouts[layer];
|
||||
keyboard.prevlayout = keyboard.layout;
|
||||
keyboard.layer_index = 0;
|
||||
|
||||
if (layer_surface) {
|
||||
zwlr_layer_surface_v1_set_size(layer_surface, 0, height);
|
||||
@ -328,11 +334,15 @@ handle_global_remove(void *data, struct wl_registry *registry, uint32_t name) {}
|
||||
void
|
||||
layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *surface,
|
||||
uint32_t serial, uint32_t w, uint32_t h) {
|
||||
keyboard.w = w + KBD_PIXEL_OVERSCAN_WIDTH;
|
||||
keyboard.h = h;
|
||||
kbd_resize(&keyboard, layouts, NumLayouts);
|
||||
if (keyboard.w != w || keyboard.h != h) {
|
||||
keyboard.w = w;
|
||||
keyboard.h = h;
|
||||
kbd_resize(&keyboard, layouts, NumLayouts);
|
||||
}
|
||||
|
||||
zwlr_layer_surface_v1_ack_configure(surface, serial);
|
||||
|
||||
drwsurf_flip(&draw_surf);
|
||||
}
|
||||
|
||||
void
|
||||
@ -349,19 +359,39 @@ usage(char *argv0) {
|
||||
"layers]\n",
|
||||
argv0);
|
||||
fprintf(stderr, "Options:\n");
|
||||
fprintf(stderr, " -D - Enable debug\n");
|
||||
fprintf(stderr, " -o - Print pressed keys to standard output\n");
|
||||
fprintf(stderr, " -O - Print intersected keys to standard output\n");
|
||||
fprintf(stderr, " -l - Comma separated list of layers\n");
|
||||
fprintf(stderr, " -H [int] - Height in pixels\n");
|
||||
fprintf(stderr, " -L [int] - Landscape height in pixels\n");
|
||||
fprintf(stderr, " -D - Enable debug\n");
|
||||
fprintf(stderr, " -o - Print pressed keys to standard output\n");
|
||||
fprintf(stderr, " -O - Print intersected keys to standard output\n");
|
||||
fprintf(stderr, " -H [int] - Height in pixels\n");
|
||||
fprintf(stderr, " -L [int] - Landscape height in pixels\n");
|
||||
fprintf(stderr, " --fn [font] - Set font (e.g: DejaVu Sans 20)\n");
|
||||
fprintf(stderr, " --hidden - Start hidden (send SIGUSR2 to show)\n");
|
||||
fprintf(stderr, " --hidden - Start hidden (send SIGUSR2 to show)\n");
|
||||
fprintf(stderr, " --bg [rrggbb|aa] - Set color of background\n");
|
||||
fprintf(stderr, " --fg [rrggbb|aa] - Set color of keys\n");
|
||||
fprintf(stderr, " --fg-sp [rrggbb|aa] - Set color of special keys\n");
|
||||
fprintf(stderr, " --press [rrggbb|aa] - Set color of pressed keys\n");
|
||||
fprintf(stderr, " --press-sp [rrggbb|aa] - Set color of pressed special keys\n");
|
||||
fprintf(stderr, " --swipe [rrggbb|aa] - Set color of swiped keys\n");
|
||||
fprintf(stderr, " --swipe-sp [rrggbb|aa] - Set color of swiped special keys\n");
|
||||
fprintf(stderr, " --text [rrggbb|aa] - Set color of text on keys\n");
|
||||
fprintf(stderr, " --text-sp [rrggbb|aa] - Set color of text on special keys\n");
|
||||
fprintf(stderr, " --list-layers - Print the list of available layers\n");
|
||||
fprintf(stderr, " -l - Comma separated list of layers\n");
|
||||
fprintf(stderr, " --landscape-layers - Comma separated list of landscape layers\n");
|
||||
}
|
||||
|
||||
void
|
||||
hide(int sigint) {
|
||||
signal(SIGUSR1, hide);
|
||||
list_layers() {
|
||||
int i;
|
||||
for (i = 0; i < NumLayouts - 1; i++) {
|
||||
if (layouts[i].name) {
|
||||
puts(layouts[i].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
hide() {
|
||||
if (!layer_surface) {
|
||||
return;
|
||||
}
|
||||
@ -369,17 +399,11 @@ hide(int sigint) {
|
||||
zwlr_layer_surface_v1_destroy(layer_surface);
|
||||
wl_surface_destroy(draw_surf.surf);
|
||||
layer_surface = NULL;
|
||||
if (draw_surf.cb) {
|
||||
wl_callback_destroy(draw_surf.cb);
|
||||
draw_surf.cb = NULL;
|
||||
}
|
||||
|
||||
hidden = true;
|
||||
}
|
||||
|
||||
void
|
||||
show(int sigint) {
|
||||
signal(SIGUSR2, show);
|
||||
show() {
|
||||
if (layer_surface) {
|
||||
return;
|
||||
}
|
||||
@ -387,7 +411,6 @@ show(int sigint) {
|
||||
wl_display_sync(display);
|
||||
|
||||
draw_surf.surf = wl_compositor_create_surface(compositor);
|
||||
;
|
||||
layer_surface = zwlr_layer_shell_v1_get_layer_surface(
|
||||
layer_shell, draw_surf.surf, wl_output, layer, namespace);
|
||||
|
||||
@ -400,31 +423,46 @@ show(int sigint) {
|
||||
wl_surface_commit(draw_surf.surf);
|
||||
|
||||
wl_display_roundtrip(display);
|
||||
kbd_resize(&keyboard, layouts, NumLayouts);
|
||||
drwsurf_flip(&draw_surf);
|
||||
|
||||
hidden = false;
|
||||
}
|
||||
|
||||
void
|
||||
toggle_visibility(int sigint) {
|
||||
signal(SIGRTMIN, toggle_visibility);
|
||||
|
||||
if (hidden) {
|
||||
show(sigint);
|
||||
} else {
|
||||
hide(sigint);
|
||||
}
|
||||
toggle_visibility() {
|
||||
if (hidden) show();
|
||||
else hide();
|
||||
}
|
||||
|
||||
void
|
||||
pipewarn(int sigint) {
|
||||
pipewarn() {
|
||||
fprintf(stderr, "wvkbd: cannot pipe data out.\n");
|
||||
}
|
||||
|
||||
void
|
||||
set_kbd_colors(uint8_t * bgra, char * hex) {
|
||||
// bg, fg, text, high, swipe
|
||||
int length = strlen(hex);
|
||||
if (length == 6 || length == 8) {
|
||||
char subhex[2];
|
||||
memcpy(subhex, hex, 2);
|
||||
bgra[2] = (int)strtol(subhex, NULL, 16);
|
||||
memcpy(subhex, hex+2, 2);
|
||||
bgra[1] = (int)strtol(subhex, NULL, 16);
|
||||
memcpy(subhex, hex+4, 2);
|
||||
bgra[0] = (int)strtol(subhex, NULL, 16);
|
||||
if (length == 8) {
|
||||
memcpy(subhex, hex+6, 2);
|
||||
bgra[3] = (int)strtol(subhex, NULL, 16);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
/* parse command line arguments */
|
||||
char *layer_names_list = NULL;
|
||||
char *layer_names_list = NULL, *landscape_layer_names_list = NULL;
|
||||
const char *fc_font_pattern = NULL;
|
||||
height = normal_height = KBD_PIXEL_HEIGHT;
|
||||
landscape_height = KBD_PIXEL_LANDSCAPE_HEIGHT;
|
||||
@ -432,6 +470,8 @@ main(int argc, char **argv) {
|
||||
char *tmp;
|
||||
if ((tmp = getenv("WVKBD_LAYERS")))
|
||||
layer_names_list = estrdup(tmp);
|
||||
if ((tmp = getenv("WVKBD_LANDSCAPE_LAYERS")))
|
||||
landscape_layer_names_list = estrdup(tmp);
|
||||
if ((tmp = getenv("WVKBD_HEIGHT")))
|
||||
normal_height = atoi(tmp);
|
||||
if ((tmp = getenv("WVKBD_LANDSCAPE_HEIGHT")))
|
||||
@ -443,7 +483,6 @@ main(int argc, char **argv) {
|
||||
keyboard.scheme = scheme;
|
||||
keyboard.layer_index = 0;
|
||||
keyboard.scheme1 = scheme1;
|
||||
keyboard.scheme1 = scheme1;
|
||||
|
||||
int i;
|
||||
for (i = 1; argv[i]; i++) {
|
||||
@ -461,6 +500,69 @@ main(int argc, char **argv) {
|
||||
if (layer_names_list)
|
||||
free(layer_names_list);
|
||||
layer_names_list = estrdup(argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-landscape-layers")) ||
|
||||
(!strcmp(argv[i], "--landscape-layers"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
if (landscape_layer_names_list)
|
||||
free(landscape_layer_names_list);
|
||||
landscape_layer_names_list = estrdup(argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-bg")) || (!strcmp(argv[i], "--bg"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme.bg.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-fg")) || (!strcmp(argv[i], "--fg"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme.fg.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-fg-sp")) || (!strcmp(argv[i], "--fg-sp"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme1.fg.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-press")) || (!strcmp(argv[i], "--press"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme.high.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-press-sp")) || (!strcmp(argv[i], "--press-sp"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme1.high.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-swipe")) || (!strcmp(argv[i], "--swipe"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme.swipe.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-swipe-sp")) || (!strcmp(argv[i], "--swipe-sp"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme1.swipe.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-text")) || (!strcmp(argv[i], "--text"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme.text.bgra, argv[++i]);
|
||||
} else if ((!strcmp(argv[i], "-text-sp")) || (!strcmp(argv[i], "--text-sp"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
set_kbd_colors(keyboard.scheme1.text.bgra, argv[++i]);
|
||||
} else if (!strcmp(argv[i], "-H")) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
@ -476,6 +578,10 @@ main(int argc, char **argv) {
|
||||
} else if (!strcmp(argv[i], "-D")) {
|
||||
keyboard.debug = true;
|
||||
} else if ((!strcmp(argv[i], "-fn")) || (!strcmp(argv[i], "--fn"))) {
|
||||
if (i >= argc - 1) {
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
fc_font_pattern = estrdup(argv[++i]);
|
||||
} else if (!strcmp(argv[i], "-o")) {
|
||||
keyboard.print = true;
|
||||
@ -484,6 +590,10 @@ main(int argc, char **argv) {
|
||||
} else if ((!strcmp(argv[i], "-hidden")) ||
|
||||
(!strcmp(argv[i], "--hidden"))) {
|
||||
hidden = true;
|
||||
} else if ((!strcmp(argv[i], "-list-layers")) ||
|
||||
(!strcmp(argv[i], "--list-layers"))) {
|
||||
list_layers();
|
||||
exit(0);
|
||||
} else {
|
||||
fprintf(stderr, "Invalid argument: %s\n", argv[i]);
|
||||
usage(argv[0]);
|
||||
@ -526,40 +636,56 @@ main(int argc, char **argv) {
|
||||
die("failed to init virtual keyboard_manager\n");
|
||||
}
|
||||
|
||||
kbd_init(&keyboard, (struct layout *)&layouts, layer_names_list);
|
||||
kbd_init(&keyboard, (struct layout *)&layouts,
|
||||
layer_names_list, landscape_layer_names_list);
|
||||
|
||||
draw_ctx.font_description =
|
||||
pango_font_description_from_string(fc_font_pattern);
|
||||
|
||||
if (!hidden) {
|
||||
draw_surf.surf = wl_compositor_create_surface(compositor);
|
||||
if (!hidden) show();
|
||||
|
||||
layer_surface = zwlr_layer_shell_v1_get_layer_surface(
|
||||
layer_shell, draw_surf.surf, wl_output, layer, namespace);
|
||||
struct pollfd fds[2];
|
||||
int WAYLAND_FD = 0;
|
||||
int SIGNAL_FD = 1;
|
||||
fds[WAYLAND_FD].events = POLLIN;
|
||||
fds[SIGNAL_FD].events = POLLIN;
|
||||
|
||||
zwlr_layer_surface_v1_set_size(layer_surface, 0, height);
|
||||
zwlr_layer_surface_v1_set_anchor(layer_surface, anchor);
|
||||
zwlr_layer_surface_v1_set_exclusive_zone(layer_surface, height);
|
||||
zwlr_layer_surface_v1_set_keyboard_interactivity(layer_surface, false);
|
||||
zwlr_layer_surface_v1_add_listener(layer_surface, &layer_surface_listener,
|
||||
NULL);
|
||||
wl_surface_commit(draw_surf.surf);
|
||||
|
||||
wl_display_roundtrip(display);
|
||||
drwsurf_flip(&draw_surf);
|
||||
fds[WAYLAND_FD].fd = wl_display_get_fd(display);
|
||||
if (fds[WAYLAND_FD].fd == -1) {
|
||||
die("Failed to get wayland_fd: %d\n", errno);
|
||||
}
|
||||
|
||||
signal(SIGUSR1, hide);
|
||||
signal(SIGUSR2, show);
|
||||
signal(SIGPIPE, pipewarn);
|
||||
signal(SIGRTMIN, toggle_visibility);
|
||||
sigset_t signal_mask;
|
||||
sigemptyset(&signal_mask);
|
||||
sigaddset(&signal_mask, SIGUSR1);
|
||||
sigaddset(&signal_mask, SIGUSR2);
|
||||
sigaddset(&signal_mask, SIGRTMIN);
|
||||
sigaddset(&signal_mask, SIGPIPE);
|
||||
if (sigprocmask(SIG_BLOCK, &signal_mask, NULL) == -1) {
|
||||
die("Failed to disable handled signals: %d\n", errno);
|
||||
}
|
||||
|
||||
fds[SIGNAL_FD].fd = signalfd(-1, &signal_mask, 0);
|
||||
if (fds[SIGNAL_FD].fd == -1) {
|
||||
die("Failed to get signalfd: %d\n", errno);
|
||||
}
|
||||
|
||||
while (run_display) {
|
||||
while (wl_display_dispatch(display) != -1 && layer_surface) {
|
||||
}
|
||||
wl_display_roundtrip(display);
|
||||
while (run_display && !layer_surface) {
|
||||
sleep(1);
|
||||
wl_display_flush(display);
|
||||
poll(fds, 2, -1);
|
||||
|
||||
if (fds[WAYLAND_FD].revents & POLLIN)
|
||||
wl_display_dispatch(display);
|
||||
|
||||
if (fds[SIGNAL_FD].revents & POLLIN) {
|
||||
struct signalfd_siginfo si;
|
||||
|
||||
if (read(fds[SIGNAL_FD].fd, &si, sizeof(si)) != sizeof(si))
|
||||
fprintf(stderr, "Signal read error: %d", errno);
|
||||
else if (si.ssi_signo == SIGUSR1) hide();
|
||||
else if (si.ssi_signo == SIGUSR2) show();
|
||||
else if (si.ssi_signo == SIGRTMIN) toggle_visibility();
|
||||
else if (si.ssi_signo == SIGPIPE) pipewarn();
|
||||
}
|
||||
}
|
||||
|
||||
|
BIN
wvkbd-mobintl
Executable file
BIN
wvkbd-mobintl
Executable file
Binary file not shown.
Reference in New Issue
Block a user