mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-07-16 13:59:53 +02:00
Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
97fad52ee9 | |||
c3afabcdce | |||
cc81e74997 | |||
11d6924a13 | |||
7be30a6a56 | |||
94ca075563 | |||
88bbdb0c64 | |||
6ab0361d80 | |||
c8bd29ecd1 | |||
aa258a01dd | |||
e6c7d0ff2a | |||
07b9f293c0 | |||
1b7f5c4968 | |||
0a680c0a7a | |||
a8ba3c02a9 | |||
b77f0582fc | |||
35ac0d1d72 | |||
718d2bdff3 | |||
fc0da6aa18 | |||
c27f876634 | |||
f74fe9a182 | |||
de4b4dcd2e | |||
849f4600e9 | |||
78d2667818 | |||
905a0d100a |
5
Makefile
5
Makefile
@ -3,6 +3,7 @@ include config.mk
|
||||
NAME=wvkbd
|
||||
BIN=${NAME}-${LAYOUT}
|
||||
SRC=.
|
||||
MAN1 = ${NAME}.1
|
||||
|
||||
PKGS = wayland-client xkbcommon pangocairo
|
||||
|
||||
@ -11,7 +12,7 @@ WVKBD_HEADERS += $(wildcard $(SRC)/*.h)
|
||||
|
||||
CFLAGS += -std=gnu99 -Wall -g -DWITH_WAYLAND_SHM -DLAYOUT=\"layout.${LAYOUT}.h\" -DKEYMAP=\"keymap.${LAYOUT}.h\"
|
||||
CFLAGS += $(shell pkg-config --cflags $(PKGS))
|
||||
LDFLAGS =$(shell pkg-config --libs $(PKGS)) -lm -lutil -lrt
|
||||
LDFLAGS += $(shell pkg-config --libs $(PKGS)) -lm -lutil -lrt
|
||||
|
||||
WAYLAND_HEADERS = $(wildcard proto/*.xml)
|
||||
|
||||
@ -47,3 +48,5 @@ install: all
|
||||
mkdir -p ${DESTDIR}${PREFIX}/bin
|
||||
cp -f ${NAME}-${LAYOUT} ${DESTDIR}${PREFIX}/bin
|
||||
chmod 755 ${DESTDIR}${PREFIX}/bin/${NAME}-${LAYOUT}
|
||||
sed "s/VERSION/${VERSION}/g" < ${MAN1} > ${DESTDIR}${MANPREFIX}/man1/${MAN1}
|
||||
chmod 644 ${DESTDIR}${MANPREFIX}/man1/${MAN1}
|
||||
|
25
README.md
25
README.md
@ -21,7 +21,7 @@ new features.
|
||||
- Support for 'Copy' keys which are not on the keymap
|
||||
- Emoji support
|
||||
- Compose key for character variants (e.g. diacritics)
|
||||
- Show/hide keyboard on signals (SIGUSR1 = hide, SIGUSR2 = show)
|
||||
- Show/hide keyboard on signals (SIGUSR1 = hide, SIGUSR2 = show, SIGRTMIN = toggle)
|
||||
- Automatic portrait/landscape detection and subsequent layout switching
|
||||
|
||||
|
||||
@ -37,7 +37,8 @@ There are some areas that still need work:
|
||||
|
||||
You'll need the following developer packages
|
||||
|
||||
- pangocairo
|
||||
- cairo
|
||||
- pango
|
||||
- wayland-client
|
||||
- xkbcommon
|
||||
|
||||
@ -46,7 +47,7 @@ Make any customizations you would like in `config.def.h` and run `make`
|
||||
The default set of layouts is called `mobintl` *(mobile international)*, which groups various layouts aimed at mobile devices
|
||||
and also attempts to accommodate various international users. The resulting binary is called `wvkbd-mobintl`.
|
||||
|
||||
You can, however, define your own layouts by copying and and modifying `layout.mobintl.h` and `keymap.mobintl.h`
|
||||
You can, however, define your own layouts by copying and modifying `layout.mobintl.h` and `keymap.mobintl.h`
|
||||
(replace `mobintl` for something like `yourlayout`). Then make your layout set using `make LAYOUT=yourlayout`, and
|
||||
the resulting binary will be `wvkbd-yourlayout`
|
||||
|
||||
@ -59,8 +60,8 @@ want a subset of the available layers, you can define which wants you want and i
|
||||
them using the `-l` parameter. This takes takes a ordered comma separated list of
|
||||
layout names that are defined in your layout set.
|
||||
|
||||
The keyboard can be hidden by sending it a `SIGUSR1` signal and shown again by sending it `SIGUSR2`. This saves some
|
||||
start up time and may be appropriate in some low-resource environments.
|
||||
The keyboard can be hidden by sending it a `SIGUSR1` signal, shown again by sending it `SIGUSR2` or toggled by sending it `SIGRTMIN`.
|
||||
This saves some start up time and may be appropriate in some low-resource environments.
|
||||
|
||||
Wvkbd has an output mode `-o` that will echo its output to standard output. This facility can be used if users want
|
||||
audio/haptic feedback, a feature explicitly out of scope for wvkbd. To achieve this, simply pipe wvkbd's output through the external tool
|
||||
@ -75,11 +76,17 @@ Another output mode, `-O` will let the keyboard output keys which are swiped ove
|
||||
|
||||
## Contribute
|
||||
|
||||
Any contributions are welcome, please tell me what I did wrong in issues or
|
||||
PRs. I could also use some nice branding if that tickles your fancy.
|
||||
Any contributions are welcome, there are two ways to contribute, the first one is **preferred**:
|
||||
|
||||
For code contributions, all I ask for now is you run `make format` (requires
|
||||
`clang-format`) before opening a PR and include as much relevant detail as
|
||||
1. [Sourcehut](https://git.sr.ht/~proycon/wvkbd) - Submit your patches using `git mail` to [~mil/sxmo-devel@lists.sr.ht](mailto:~mil/sxmo-devel@lists.sr.ht), follow [these contribution guidelines](https://sxmo.org/contribute/). Questions can also be asked on Sxmo's [mailing lists](https://sxmo.org/support/).
|
||||
2. [Github](https://github.com/jjsullivan5196/wvkbd/) - Submit a pull request or open an issue *(legacy method)*
|
||||
|
||||
This project was started by [John Sullivan](https://jsullivan.cc/) and is
|
||||
currently being maintained by the [Sxmo](https://sxmo.org) project, whose
|
||||
maintainers will ensure both git remotes are kept in sync at all times.
|
||||
|
||||
For code contributions, please run `make format` (requires `clang-format`)
|
||||
before sending a patch (opening a PR) and include as much relevant detail as
|
||||
possible.
|
||||
|
||||
## Related projects
|
||||
|
18
config.def.h
18
config.def.h
@ -2,20 +2,21 @@
|
||||
#define config_def_h_INCLUDED
|
||||
|
||||
static const char *default_font = "Monospace 14";
|
||||
static const int transparency = 225;
|
||||
|
||||
struct clr_scheme scheme = {
|
||||
/* colors */
|
||||
.bg = {.bgra = {15, 15, 15, 225}},
|
||||
.fg = {.bgra = {45, 45, 45, 225}},
|
||||
.high = {.bgra = {100, 100, 100, 225}},
|
||||
.bg = {.bgra = {15, 15, 15, transparency}},
|
||||
.fg = {.bgra = {45, 45, 45, transparency}},
|
||||
.high = {.bgra = {100, 100, 100, transparency}},
|
||||
.swipe = {.bgra = {100, 255, 100, 64}},
|
||||
.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}},
|
||||
.bg = {.bgra = {15, 15, 15, transparency}},
|
||||
.fg = {.bgra = {32, 32, 32, transparency}},
|
||||
.high = {.bgra = {100, 100, 100, transparency}},
|
||||
.swipe = {.bgra = {100, 255, 100, 64}},
|
||||
.text = {.color = UINT32_MAX},
|
||||
};
|
||||
@ -23,14 +24,15 @@ struct clr_scheme scheme1 = {
|
||||
/* 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, SimpleGrid, Nav, Dialer, Cyrillic, Arabic, Georgian,
|
||||
Special, Emoji, Simple, SimpleGrid, Nav, Dialer,
|
||||
Cyrillic, Arabic, Persian, Greek, Georgian,
|
||||
NumLayouts // signals the last item, may not be omitted
|
||||
};
|
||||
|
||||
/* layers is an ordered list of layouts, used to cycle through */
|
||||
static enum layout_id landscape_layers[] = {
|
||||
Landscape, // First layout is the default layout on startup
|
||||
Special, Emoji, Nav,
|
||||
Special, Emoji, Nav, Greek,
|
||||
NumLayouts // signals the last item, may not be omitted
|
||||
};
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
VERSION = 0.2
|
||||
VERSION = 0.8.1
|
||||
CFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=700
|
||||
PREFIX = /usr/local
|
||||
MANPREFIX = ${PREFIX}/share/man
|
||||
LAYOUT = mobintl
|
||||
|
1
drw.c
1
drw.c
@ -85,7 +85,6 @@ drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
color.bgra[0] / (double)255, color.bgra[3] / (double)255);
|
||||
cairo_fill(d->cairo);
|
||||
|
||||
|
||||
cairo_restore(d->cairo);
|
||||
|
||||
wl_surface_damage(d->surf, x, y, w, h);
|
||||
|
29
keyboard.c
29
keyboard.c
@ -166,17 +166,17 @@ kbd_get_key(struct kbd *kb, uint32_t x, uint32_t y) {
|
||||
|
||||
void
|
||||
kbd_unpress_key(struct kbd *kb, uint32_t time) {
|
||||
bool unlatch_shift = false;
|
||||
bool unlatch_shift = false;
|
||||
|
||||
if (kb->last_press) {
|
||||
unlatch_shift = (kb->mods & Shift) == Shift;
|
||||
unlatch_shift = (kb->mods & Shift) == Shift;
|
||||
|
||||
if (unlatch_shift) {
|
||||
kb->mods ^= Shift;
|
||||
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
|
||||
}
|
||||
if (unlatch_shift) {
|
||||
kb->mods ^= Shift;
|
||||
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
|
||||
}
|
||||
|
||||
if (kb->last_press->type == Copy) {
|
||||
if (kb->last_press->type == Copy) {
|
||||
zwp_virtual_keyboard_v1_key(kb->vkbd, time, 127, // COMP key
|
||||
WL_KEYBOARD_KEY_STATE_RELEASED);
|
||||
} else {
|
||||
@ -190,14 +190,15 @@ kbd_unpress_key(struct kbd *kb, uint32_t time) {
|
||||
} else if (unlatch_shift) {
|
||||
kbd_draw_layout(kb);
|
||||
} else {
|
||||
kbd_draw_key(kb, kb->last_press, Unpress);
|
||||
}
|
||||
kbd_draw_key(kb, kb->last_press, Unpress);
|
||||
}
|
||||
|
||||
kb->last_press = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void kbd_release_key(struct kbd *kb, uint32_t time) {
|
||||
void
|
||||
kbd_release_key(struct kbd *kb, uint32_t time) {
|
||||
kbd_unpress_key(kb, time);
|
||||
if (kb->print_intersect && kb->last_swipe) {
|
||||
printf("\n");
|
||||
@ -208,7 +209,8 @@ void kbd_release_key(struct kbd *kb, uint32_t time) {
|
||||
}
|
||||
}
|
||||
|
||||
void kbd_motion_key(struct kbd *kb, uint32_t time, uint32_t x, uint32_t y) {
|
||||
void
|
||||
kbd_motion_key(struct kbd *kb, uint32_t time, uint32_t x, uint32_t y) {
|
||||
// Output intersecting keys
|
||||
// (for external 'swiping'-based accelerators).
|
||||
if (kb->print_intersect) {
|
||||
@ -220,7 +222,7 @@ void kbd_motion_key(struct kbd *kb, uint32_t time, uint32_t x, uint32_t y) {
|
||||
struct key *intersect_key;
|
||||
intersect_key = kbd_get_key(kb, x, y);
|
||||
if (intersect_key &&
|
||||
(! kb->last_swipe || intersect_key->label != kb->last_swipe->label)) {
|
||||
(!kb->last_swipe || intersect_key->label != kb->last_swipe->label)) {
|
||||
kbd_print_key_stdout(kb, intersect_key);
|
||||
kb->last_swipe = intersect_key;
|
||||
kbd_draw_key(kb, kb->last_swipe, Swipe);
|
||||
@ -411,7 +413,8 @@ kbd_draw_layout(struct kbd *kb) {
|
||||
next_key++;
|
||||
continue;
|
||||
}
|
||||
if (next_key->type == Mod && kb->mods & next_key->code) {
|
||||
if ((next_key->type == Mod && kb->mods & next_key->code) ||
|
||||
(next_key->type == Compose && kb->compose)) {
|
||||
kbd_draw_key(kb, next_key, Press);
|
||||
} else {
|
||||
kbd_draw_key(kb, next_key, Unpress);
|
||||
|
2935
keymap.mobintl.h
2935
keymap.mobintl.h
File diff suppressed because it is too large
Load Diff
179
layout.mobintl.h
179
layout.mobintl.h
@ -1,5 +1,4 @@
|
||||
/* constants */
|
||||
|
||||
/* how tall the keyboard should be by default (can be overriden) */
|
||||
#define KBD_PIXEL_HEIGHT 240
|
||||
|
||||
@ -21,6 +20,8 @@ enum layout_id {
|
||||
Dialer,
|
||||
Cyrillic,
|
||||
Arabic,
|
||||
Persian,
|
||||
Greek,
|
||||
Georgian,
|
||||
Emoji,
|
||||
Nav,
|
||||
@ -67,18 +68,19 @@ enum layout_id {
|
||||
};
|
||||
|
||||
static struct key keys_full[], keys_special[], keys_simple[], keys_simplegrid[],
|
||||
keys_cyrillic[], keys_arabic[], keys_georgian[], keys_emoji[], keys_nav[], keys_landscape[],
|
||||
keys_compose_a[], keys_compose_e[], keys_compose_y[], keys_compose_u[],
|
||||
keys_compose_i[], keys_compose_o[], keys_compose_w[], keys_compose_r[],
|
||||
keys_compose_t[], keys_compose_p[], keys_compose_s[], keys_compose_d[],
|
||||
keys_compose_f[], keys_compose_g[], keys_compose_h[], keys_compose_j[],
|
||||
keys_compose_k[], keys_compose_l[], keys_compose_z[], keys_compose_x[],
|
||||
keys_compose_c[], keys_compose_v[], keys_compose_b[], keys_compose_n[],
|
||||
keys_compose_m[], keys_compose_math[], keys_compose_punctuation[],
|
||||
keys_compose_bracket[], keys_compose_cyr_i[], keys_compose_cyr_j[],
|
||||
keys_compose_cyr_e[], keys_compose_cyr_u[], keys_compose_cyr_l[],
|
||||
keys_compose_cyr_n[], keys_compose_cyr_tse[], keys_compose_cyr_che[],
|
||||
keys_compose_cyr_g[], keys_compose_cyr_k[], keys_dialer[];
|
||||
keys_cyrillic[], keys_arabic[], keys_persian[], keys_georgian[], keys_greek[],
|
||||
keys_emoji[], keys_nav[], keys_landscape[], keys_compose_a[],
|
||||
keys_compose_e[], keys_compose_y[], keys_compose_u[], keys_compose_i[],
|
||||
keys_compose_o[], keys_compose_w[], keys_compose_r[], keys_compose_t[],
|
||||
keys_compose_p[], keys_compose_s[], keys_compose_d[], keys_compose_f[],
|
||||
keys_compose_g[], keys_compose_h[], keys_compose_j[], keys_compose_k[],
|
||||
keys_compose_l[], keys_compose_z[], keys_compose_x[], keys_compose_c[],
|
||||
keys_compose_v[], keys_compose_b[], keys_compose_n[], keys_compose_m[],
|
||||
keys_compose_math[], keys_compose_punctuation[], keys_compose_bracket[],
|
||||
keys_compose_cyr_i[], keys_compose_cyr_j[], keys_compose_cyr_e[],
|
||||
keys_compose_cyr_u[], keys_compose_cyr_l[], keys_compose_cyr_n[],
|
||||
keys_compose_cyr_tse[], keys_compose_cyr_che[], keys_compose_cyr_g[],
|
||||
keys_compose_cyr_k[], keys_dialer[];
|
||||
|
||||
static struct layout layouts[NumLayouts] = {
|
||||
[Full] = {keys_full, "latin", "full"}, // second parameter is the keymap name
|
||||
@ -90,6 +92,8 @@ static struct layout layouts[NumLayouts] = {
|
||||
[Dialer] = {keys_dialer, "latin", "dialer"},
|
||||
[Arabic] = {keys_arabic, "arabic", "arabic"},
|
||||
[Georgian] = {keys_georgian, "georgian", "georgian"},
|
||||
[Persian] = {keys_persian, "persian", "persian"},
|
||||
[Greek] = {keys_greek, "greek", "greek"},
|
||||
[Emoji] = {keys_emoji, "latin", "emoji"},
|
||||
[Nav] = {keys_nav, "latin", "nav"},
|
||||
[Landscape] = {keys_landscape, "latin", "landscape"},
|
||||
@ -336,7 +340,7 @@ static struct key keys_simple[] = {
|
||||
|
||||
{"Abc", "Abc", 1.0, NextLayer, .scheme = 1},
|
||||
{"Ctr", "Ctr", 1.0, Mod, Ctrl, .scheme = 1},
|
||||
{",", "'", 1.0, Code, KEY_COMMA, &layouts[ComposeMath]},
|
||||
{"-", "_", 1.0, Code, KEY_MINUS, &layouts[ComposeMath]},
|
||||
{"", "", 4.0, Code, KEY_SPACE},
|
||||
{".", "?", 1.0, Code, KEY_DOT, &layouts[ComposePunctuation]},
|
||||
{"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme = 1},
|
||||
@ -411,7 +415,7 @@ static struct key keys_simplegrid[] = {
|
||||
|
||||
{"Abc", "Abc", 1.0, NextLayer, .scheme = 1},
|
||||
{"Ctr", "Ctr", 1.0, Mod, Ctrl, .scheme = 1},
|
||||
{",", "'", 1.0, Code, KEY_COMMA, &layouts[ComposeMath]},
|
||||
{"-", "_", 1.0, Code, KEY_MINUS, &layouts[ComposeMath]},
|
||||
{"Cmp", "Cmp", 1.0, Compose, .scheme = 1},
|
||||
{"", "", 3.0, Code, KEY_SPACE},
|
||||
{".", "?", 1.0, Code, KEY_DOT, &layouts[ComposePunctuation]},
|
||||
@ -610,6 +614,134 @@ static struct key keys_georgian[] = {
|
||||
{"", "", 0.0, Last},
|
||||
};
|
||||
|
||||
static struct key keys_persian[] = {
|
||||
{"۱", "|", 1.0, Code, KEY_1},
|
||||
{"۲", "٬", 1.0, Code, KEY_2},
|
||||
{"۳", "#", 1.0, Code, KEY_3},
|
||||
{"۴", "﷼", 1.0, Code, KEY_4},
|
||||
{"۵", "٪", 1.0, Code, KEY_5},
|
||||
{"۶", "×", 1.0, Code, KEY_6},
|
||||
{"۷", "/", 1.0, Code, KEY_7},
|
||||
{"۸", "*", 1.0, Code, KEY_8},
|
||||
{"۹", ")", 1.0, Code, KEY_9},
|
||||
{"۰", "(", 1.0, Code, KEY_0},
|
||||
{"-", "_", 1.0, Code, KEY_MINUS},
|
||||
{"=", "+", 1.0, Code, KEY_EQUAL},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"ض", "ﹿ", 1.0, Code, KEY_Q},
|
||||
{"ص", "ـٌ", 1.0, Code, KEY_W},
|
||||
{"ث", "ـٍ", 1.0, Code, KEY_E},
|
||||
{"ق", "ـً", 1.0, Code, KEY_R},
|
||||
{"ف", "ـُ", 1.0, Code, KEY_T},
|
||||
{"غ", "ـِ", 1.0, Code, KEY_Y},
|
||||
{"ع", "ـَ", 1.0, Code, KEY_U},
|
||||
{"ه", "ﹽ", 1.0, Code, KEY_I},
|
||||
{"خ", "]", 1.0, Code, KEY_O},
|
||||
{"ح", "[", 1.0, Code, KEY_P},
|
||||
{"ج", "}", 1.0, Code, KEY_LEFTBRACE},
|
||||
{"چ", "{", 1.0, Code, KEY_RIGHTBRACE},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"ش", "ؤ", 1.0, Code, KEY_A},
|
||||
{"س", "ئ", 1.0, Code, KEY_S},
|
||||
{"ی", "ي", 1.0, Code, KEY_D},
|
||||
{"ب", "إ", 1.0, Code, KEY_F},
|
||||
{"ل", "أ", 1.0, Code, KEY_G},
|
||||
{"ا", "آ", 1.0, Code, KEY_H},
|
||||
{"ت", "ة", 1.0, Code, KEY_J},
|
||||
{"ن", "»", 1.0, Code, KEY_K},
|
||||
{"م", "«", 1.0, Code, KEY_L},
|
||||
{"ک", ":", 1.0, Code, KEY_SEMICOLON},
|
||||
{"گ", "؛", 1.0, Code, KEY_APOSTROPHE},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"ظ", "ك", 1.0, Code, KEY_Z},
|
||||
{"ط", "ـٓ", 1.0, Code, KEY_X},
|
||||
{"ژ", ">", 1.0, Code, KEY_BACKSLASH},
|
||||
{"ز", "<", 1.0, Code, KEY_C},
|
||||
{"ر", "ـٰ", 1.0, Code, KEY_V},
|
||||
{"ذ", "⇑", 1.0, Code, KEY_B},
|
||||
{"د", "ـٔ", 1.0, Code, KEY_N},
|
||||
{"پ", "ء", 1.0, Code, KEY_M},
|
||||
{"و", "\\", 1.0, Code, KEY_COMMA},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"Abc", "Abc", 1.0, NextLayer, .scheme = 1},
|
||||
{"Cmp", "Cmp", 1.0, Compose, .scheme = 1},
|
||||
{".", "،", 1.0, Code, KEY_DOT},
|
||||
{"", "", 4.0, Code, KEY_SPACE},
|
||||
{"⥣", "↥", 1.0, Code, KEY_GRAVE},
|
||||
{"؟", "!", 1.0, Code, KEY_SLASH},
|
||||
{"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme = 1},
|
||||
|
||||
/* end of layout */
|
||||
{"", "", 0.0, Last},
|
||||
};
|
||||
|
||||
static struct key keys_greek[] = {
|
||||
{"1", "!", 1.0, Code, KEY_1},
|
||||
{"2", "@", 1.0, Code, KEY_2},
|
||||
{"3", "#", 1.0, Code, KEY_3},
|
||||
{"4", "$", 1.0, Code, KEY_4},
|
||||
{"5", "%", 1.0, Code, KEY_5},
|
||||
{"6", "^", 1.0, Code, KEY_6},
|
||||
{"7", "&", 1.0, Code, KEY_7},
|
||||
{"8", "*", 1.0, Code, KEY_8},
|
||||
{"9", "(", 1.0, Code, KEY_9},
|
||||
{"0", ")", 1.0, Code, KEY_0},
|
||||
{"-", "_", 1.0, Code, KEY_MINUS},
|
||||
{"=", "+", 1.0, Code, KEY_EQUAL},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{";", ":", 1.0, Code, KEY_Q},
|
||||
{"ς", "Σ", 1.0, Code, KEY_W},
|
||||
{"ε", "Ε", 1.0, Code, KEY_E},
|
||||
{"ρ", "Ρ", 1.0, Code, KEY_R},
|
||||
{"τ", "Τ", 1.0, Code, KEY_T},
|
||||
{"υ", "Υ", 1.0, Code, KEY_Y},
|
||||
{"θ", "Θ", 1.0, Code, KEY_U},
|
||||
{"ι", "Ι", 1.0, Code, KEY_I},
|
||||
{"ο", "Ο", 1.0, Code, KEY_O},
|
||||
{"π", "Π", 1.0, Code, KEY_P},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"α", "A", 1.0, Code, KEY_A},
|
||||
{"σ", "Σ", 1.0, Code, KEY_S},
|
||||
{"δ", "Δ", 1.0, Code, KEY_D},
|
||||
{"φ", "Φ", 1.0, Code, KEY_F},
|
||||
{"γ", "Γ", 1.0, Code, KEY_G},
|
||||
{"η", "Η", 1.0, Code, KEY_H},
|
||||
{"ξ", "Ξ", 1.0, Code, KEY_J},
|
||||
{"κ", "Κ", 1.0, Code, KEY_K},
|
||||
{"λ", "Λ", 1.0, Code, KEY_L},
|
||||
{"΄", "¨", 1.0, Code, KEY_SEMICOLON},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"⇧", "⇧", 1.5, Mod, Shift, .scheme = 1},
|
||||
{"ζ", "Ζ", 1.0, Code, KEY_Z},
|
||||
{"χ", "Χ", 1.0, Code, KEY_X},
|
||||
{"ψ", "Ψ", 1.0, Code, KEY_C},
|
||||
{"ω", "Ω", 1.0, Code, KEY_V},
|
||||
{"β", "Β", 1.0, Code, KEY_B},
|
||||
{"ν", "Ν", 1.0, Code, KEY_N},
|
||||
{"μ", "Μ", 1.0, Code, KEY_M},
|
||||
{"/", "\\", 1.0, Code, KEY_SLASH},
|
||||
{"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"Abc", "Abc", 1.5, NextLayer, .scheme = 1},
|
||||
{",", "'", 1.0, Code, KEY_COMMA},
|
||||
{"", "", 5, Code, KEY_SPACE},
|
||||
{".", "\"", 1.0, Code, KEY_DOT},
|
||||
{"Enter", "Enter", 2, Code, KEY_ENTER, .scheme = 1},
|
||||
|
||||
/* end of layout */
|
||||
{"", "", 0.0, Last},
|
||||
};
|
||||
|
||||
static struct key keys_compose_a[] = {
|
||||
{"à", "À", 1.0, Copy, 0x00E0, 0, 0x00C0},
|
||||
{"á", "Á", 1.0, Copy, 0x00E1, 0, 0x00C1},
|
||||
@ -697,7 +829,7 @@ static struct key keys_compose_u[] = {
|
||||
{"ŭ", "Ŭ", 1.0, Copy, 0x016D, 0, 0x016C},
|
||||
{"ů", "Ů", 1.0, Copy, 0x016F, 0, 0x016E},
|
||||
{"ű", "Ű", 1.0, Copy, 0x0171, 0, 0x0170},
|
||||
{"ų", "Ų", 1.0, Copy, 0x0172, 0, 0x0173},
|
||||
{"ų", "Ų", 1.0, Copy, 0x0173, 0, 0x0172},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"υ", "Υ", 1.0, Copy, 0x03C5, 0, 0x03A5},
|
||||
{"", "", 9.0, Pad},
|
||||
@ -724,7 +856,7 @@ static struct key keys_compose_o[] = {
|
||||
{"ø", "Ø", 1.0, Copy, 0x00F8, 0, 0x00D8},
|
||||
{"ō", "Ō", 1.0, Copy, 0x014D, 0, 0x014C},
|
||||
{"ŏ", "Ŏ", 1.0, Copy, 0x014F, 0, 0x014E},
|
||||
{"ő", "Ő", 1.0, Copy, 0x0150, 0, 0x0151},
|
||||
{"ő", "Ő", 1.0, Copy, 0x0151, 0, 0x0150},
|
||||
{"œ", "Œ", 1.0, Copy, 0x0153, 0, 0x0152},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"ο", "Ο", 1.0, Copy, 0x03BF, 0, 0x039F},
|
||||
@ -821,7 +953,7 @@ static struct key keys_emoji[] = {
|
||||
|
||||
static struct key keys_nav[] = {
|
||||
{"Esc", "Esc", 1.0, Code, KEY_ESC, .scheme = 1},
|
||||
{"", "", 1.0, Code, KEY_SPACE, .scheme = 1},
|
||||
{"⌫", "⌫", 1.0, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"↑", "↑", 1.0, Code, KEY_UP, .scheme = 1},
|
||||
{"⇈", "⇈", 1.0, Code, KEY_PAGEUP, .scheme = 1},
|
||||
{"", "", 0.0, EndRow},
|
||||
@ -833,7 +965,7 @@ static struct key keys_nav[] = {
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"Sym", "Sym", 1.0, NextLayer, .scheme = 1},
|
||||
{"⌫", "⌫", 1.0, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
{"", "", 1.0, Code, KEY_SPACE, .scheme = 1},
|
||||
{"↓", "↓", 1.0, Code, KEY_DOWN, .scheme = 1},
|
||||
{"⇊", "⇊", 1.0, Code, KEY_PAGEDOWN, .scheme = 1},
|
||||
{"", "", 0.0, Last},
|
||||
@ -1495,17 +1627,17 @@ static struct key keys_compose_math[] = {
|
||||
{"", "", 10.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 2, Mod, Shift, .scheme = 1},
|
||||
{"-", "-", 1, Code, KEY_MINUS},
|
||||
{"+", "+", 1, Code, KEY_EQUAL, 0, Shift},
|
||||
{"/", "/", 1, Code, KEY_SLASH},
|
||||
{"*", "*", 1, Code, KEY_8, 0, Shift},
|
||||
{"=", "=", 1, Code, KEY_EQUAL},
|
||||
{"_", "_", 1, Code, KEY_MINUS, 0, Shift},
|
||||
{"—", "—", 1, Copy, 0x2014, 0, 0x2014},
|
||||
{"", "", 2, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"Abc", "Abc", 1.0, BackLayer},
|
||||
{"Ctr", "Ctr", 1.0, Mod, Ctrl, .scheme = 1},
|
||||
{",", "'", 1.0, Code, KEY_COMMA, &layouts[ComposeMath]},
|
||||
{"-", "-", 1, Code, KEY_MINUS},
|
||||
{"", "", 4.0, Code, KEY_SPACE},
|
||||
{".", "?", 1.0, Code, KEY_DOT, &layouts[ComposePunctuation]},
|
||||
{"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme = 1},
|
||||
@ -1527,13 +1659,14 @@ static struct key keys_compose_punctuation[] = {
|
||||
{"", "", 10.0, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"⇧", "⇧", 2, Mod, Shift, .scheme = 1},
|
||||
{"", "", 1, Pad},
|
||||
{"…", "…", 1, Copy, 0x2026, 0, 0x2026},
|
||||
{":", ":", 1, Code, KEY_SEMICOLON, 0, Shift},
|
||||
{";", ";", 1, Code, KEY_SEMICOLON, 0},
|
||||
{"!", "!", 1, Code, KEY_1, 0, Shift},
|
||||
{"?", "?", 1, Code, KEY_DOT, 0, Shift},
|
||||
{",", ",", 1, Code, KEY_COMMA},
|
||||
{"", "", 2, Pad},
|
||||
{"·", "·", 1, Copy, 0x2027, 0, 0x2027},
|
||||
{"", "", 1, Pad},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"Abc", "Abc", 1.0, BackLayer},
|
||||
{"Ctr", "Ctr", 1.0, Mod, Ctrl, .scheme = 1},
|
||||
|
45
main.c
45
main.c
@ -45,6 +45,7 @@ static int cur_x = -1, cur_y = -1;
|
||||
static bool cur_press = false;
|
||||
static struct kbd keyboard;
|
||||
static uint32_t height, normal_height, landscape_height;
|
||||
static bool hidden = false;
|
||||
|
||||
/* event handler prototypes */
|
||||
static void wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
|
||||
@ -270,9 +271,11 @@ display_handle_geometry(void *data, struct wl_output *wl_output, int x, int y,
|
||||
keyboard.layout = &keyboard.layouts[layer];
|
||||
keyboard.prevlayout = keyboard.layout;
|
||||
|
||||
zwlr_layer_surface_v1_set_size(layer_surface, 0, height);
|
||||
zwlr_layer_surface_v1_set_exclusive_zone(layer_surface, height);
|
||||
wl_surface_commit(draw_surf.surf);
|
||||
if (layer_surface) {
|
||||
zwlr_layer_surface_v1_set_size(layer_surface, 0, height);
|
||||
zwlr_layer_surface_v1_set_exclusive_zone(layer_surface, height);
|
||||
wl_surface_commit(draw_surf.surf);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -370,6 +373,8 @@ hide(int sigint) {
|
||||
wl_callback_destroy(draw_surf.cb);
|
||||
draw_surf.cb = NULL;
|
||||
}
|
||||
|
||||
hidden = true;
|
||||
}
|
||||
|
||||
void
|
||||
@ -396,6 +401,24 @@ show(int sigint) {
|
||||
|
||||
wl_display_roundtrip(display);
|
||||
drwsurf_flip(&draw_surf);
|
||||
|
||||
hidden = false;
|
||||
}
|
||||
|
||||
void
|
||||
toggle_visibility(int sigint) {
|
||||
signal(SIGRTMIN, toggle_visibility);
|
||||
|
||||
if (hidden) {
|
||||
show(sigint);
|
||||
} else {
|
||||
hide(sigint);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pipewarn(int sigint) {
|
||||
fprintf(stderr, "wvkbd: cannot pipe data out.\n");
|
||||
}
|
||||
|
||||
int
|
||||
@ -422,12 +445,10 @@ main(int argc, char **argv) {
|
||||
keyboard.scheme1 = scheme1;
|
||||
keyboard.scheme1 = scheme1;
|
||||
|
||||
bool starthidden = false;
|
||||
|
||||
int i;
|
||||
for (i = 1; argv[i]; i++) {
|
||||
if ((!strcmp(argv[i], "-v")) || (!strcmp(argv[i], "--version"))) {
|
||||
printf("wvkbd-%s", VERSION);
|
||||
printf("wvkbd-%s\n", VERSION);
|
||||
exit(0);
|
||||
} else if ((!strcmp(argv[i], "-h")) || (!strcmp(argv[i], "--help"))) {
|
||||
usage(argv[0]);
|
||||
@ -460,8 +481,9 @@ main(int argc, char **argv) {
|
||||
keyboard.print = true;
|
||||
} else if (!strcmp(argv[i], "-O")) {
|
||||
keyboard.print_intersect = true;
|
||||
} else if ((!strcmp(argv[i], "-hidden")) || (!strcmp(argv[i], "--hidden"))) {
|
||||
starthidden = true;
|
||||
} else if ((!strcmp(argv[i], "-hidden")) ||
|
||||
(!strcmp(argv[i], "--hidden"))) {
|
||||
hidden = true;
|
||||
} else {
|
||||
fprintf(stderr, "Invalid argument: %s\n", argv[i]);
|
||||
usage(argv[0]);
|
||||
@ -509,8 +531,7 @@ main(int argc, char **argv) {
|
||||
draw_ctx.font_description =
|
||||
pango_font_description_from_string(fc_font_pattern);
|
||||
|
||||
|
||||
if (!starthidden) {
|
||||
if (!hidden) {
|
||||
draw_surf.surf = wl_compositor_create_surface(compositor);
|
||||
|
||||
layer_surface = zwlr_layer_shell_v1_get_layer_surface(
|
||||
@ -521,7 +542,7 @@ main(int argc, char **argv) {
|
||||
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);
|
||||
NULL);
|
||||
wl_surface_commit(draw_surf.surf);
|
||||
|
||||
wl_display_roundtrip(display);
|
||||
@ -530,6 +551,8 @@ main(int argc, char **argv) {
|
||||
|
||||
signal(SIGUSR1, hide);
|
||||
signal(SIGUSR2, show);
|
||||
signal(SIGPIPE, pipewarn);
|
||||
signal(SIGRTMIN, toggle_visibility);
|
||||
|
||||
while (run_display) {
|
||||
while (wl_display_dispatch(display) != -1 && layer_surface) {
|
||||
|
71
wvkbd.1
Normal file
71
wvkbd.1
Normal file
@ -0,0 +1,71 @@
|
||||
.TH "wvkbd" "1" "2022-03-12"
|
||||
.P
|
||||
.SH NAME
|
||||
.P
|
||||
wvkbd - on-screen keyboard for wlroots
|
||||
.P
|
||||
.SH SYNOPSIS
|
||||
.P
|
||||
wvkbd-mobintl [OPTION]...
|
||||
.P
|
||||
.SH DESCRIPTION
|
||||
.P
|
||||
wvkbd is an on-screen keyboard for wlroots that sucks less.
|
||||
.P
|
||||
.SH OPTIONS
|
||||
.P
|
||||
\fB-D\fR
|
||||
.RS 4
|
||||
enable debug
|
||||
.P
|
||||
.RE
|
||||
\fB-o\fR
|
||||
.RS 4
|
||||
print pressed keys to standard output
|
||||
.P
|
||||
.RE
|
||||
\fB-O\fR
|
||||
.RS 4
|
||||
print intersected keys to standard output
|
||||
.P
|
||||
.RE
|
||||
\fB-l\fR
|
||||
.RS 4
|
||||
comma separated list of layers
|
||||
.P
|
||||
.RE
|
||||
\fB-H\fR \fIPX\fR
|
||||
.RS 4
|
||||
height in pixels
|
||||
.P
|
||||
.RE
|
||||
\fB-L\fR \fIPX\fR
|
||||
.RS 4
|
||||
landscape height in pixels
|
||||
.P
|
||||
.RE
|
||||
\fB--fn\fR \fIFONT\fR
|
||||
.RS 4
|
||||
set font (e.g: DejaVu Sans 20)
|
||||
.P
|
||||
.RE
|
||||
\fB--hidden\fR
|
||||
.RS 4
|
||||
start hidden (send SIGUSR2 to show, SIGUSR1 to hide, SIGRTMIN to toggle)
|
||||
.P
|
||||
.RE
|
||||
\fB-v\fR, \fB--version\fR
|
||||
.RS 4
|
||||
print version
|
||||
.P
|
||||
.RE
|
||||
\fB-h\fR, \fB--help\fR
|
||||
.RS 4
|
||||
show help
|
||||
.P
|
||||
.RE
|
||||
.SH AUTHORS
|
||||
.P
|
||||
Created by John Sullivan <jsullivan@csumb.edu>, maintained by the Sxmo project in
|
||||
collaboration with other open source contributors. For more information about wvkbd development, see
|
||||
<https://git.sr.ht/~proycon/wvkbd> or <https://github.com/jjsullivan5196/wvkbd>.
|
Reference in New Issue
Block a user