mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-07-13 22:44:33 +02:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
aa65896fbf | |||
bddf05e0fc | |||
564eb4536a | |||
2de12a90e4 | |||
c541c7dbd6 | |||
780a83dba5 | |||
6abc005124 |
@ -66,7 +66,12 @@ Wvkbd has an output mode `-o` that will echo its output to standard output. This
|
||||
audio/haptic feedback, a feature explicitly out of scope for wvkbd. To achieve this, simply pipe wvkbd's output through the external tool
|
||||
[clickclack](https://git.sr.ht/~proycon/clickclack):
|
||||
|
||||
`$ wvkbd-mobileintl -l simple,special,emoji -o | clickclack -V -f keypress.wav`
|
||||
`$ wvkbd-mobintl -l simple,special,emoji -o | clickclack -V -f keypress.wav`
|
||||
|
||||
Another output mode, `-O` will let the keyboard output keys which are swiped over. It can be used by an external program, such as [swipeGuess](https://git.sr.ht/~earboxer/swipeGuess) to get swipe-typing support.
|
||||
|
||||
`$ wvkbd-mobintl -O | swipeGuess.sh words.txt | completelyTypeWord.sh`
|
||||
|
||||
|
||||
## Contribute
|
||||
|
||||
@ -80,6 +85,7 @@ possible.
|
||||
## Related projects
|
||||
|
||||
* [clickclack](https://git.sr.ht/~proycon/clickclack) - Audio/haptic feedback (standalone)
|
||||
* [swipeGuess](https://git.sr.ht/~earboxer/swipeGuess) - Word-completion for swipe-typing
|
||||
* [Sxmo](https://sxmo.org) - A hackable mobile interface environment for Linux phones that adopted wvkbd as its keyboard
|
||||
* [svkbd](https://tools.suckless.org/x/svkbd/) - A similar project as wvkbd but for X11 rather than Wayland
|
||||
* [squeekboard](https://gitlab.gnome.org/World/Phosh/squeekboard) - The virtual keyboard developed for the Librem5 (used
|
||||
|
@ -8,6 +8,7 @@ struct clr_scheme scheme = {
|
||||
.bg = {.bgra = {15, 15, 15, 225}},
|
||||
.fg = {.bgra = {45, 45, 45, 225}},
|
||||
.high = {.bgra = {100, 100, 100, 225}},
|
||||
.swipe = {.bgra = {100, 255, 100, 64}},
|
||||
.text = {.color = UINT32_MAX},
|
||||
};
|
||||
struct clr_scheme scheme1 = {
|
||||
@ -15,13 +16,14 @@ struct clr_scheme scheme1 = {
|
||||
.bg = {.bgra = {15, 15, 15, 225}},
|
||||
.fg = {.bgra = {32, 32, 32, 225}},
|
||||
.high = {.bgra = {100, 100, 100, 225}},
|
||||
.swipe = {.bgra = {100, 255, 100, 64}},
|
||||
.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, SimpleGrid, Nav, Dialer, Cyrillic, Arabic,
|
||||
Special, Emoji, Simple, SimpleGrid, Nav, Dialer, Cyrillic, Arabic, Georgian,
|
||||
NumLayouts // signals the last item, may not be omitted
|
||||
};
|
||||
|
||||
|
23
drw.c
23
drw.c
@ -69,11 +69,15 @@ drw_draw_text(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
}
|
||||
|
||||
void
|
||||
drw_fill_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h) {
|
||||
drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h, bool over) {
|
||||
cairo_save(d->cairo);
|
||||
|
||||
cairo_set_operator(d->cairo, CAIRO_OPERATOR_SOURCE);
|
||||
if (over) {
|
||||
cairo_set_operator(d->cairo, CAIRO_OPERATOR_OVER);
|
||||
} else {
|
||||
cairo_set_operator(d->cairo, CAIRO_OPERATOR_SOURCE);
|
||||
}
|
||||
|
||||
cairo_rectangle(d->cairo, x, y, w, h);
|
||||
cairo_set_source_rgba(
|
||||
@ -81,11 +85,24 @@ drw_fill_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);
|
||||
}
|
||||
|
||||
void
|
||||
drw_fill_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h) {
|
||||
drw_do_rectangle(d, color, x, y, w, h, false);
|
||||
}
|
||||
|
||||
void
|
||||
drw_over_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h) {
|
||||
drw_do_rectangle(d, color, x, y, w, h, true);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
setup_buffer(struct drwsurf *drwsurf) {
|
||||
int stride = drwsurf->width * 4;
|
||||
|
4
drw.h
4
drw.h
@ -31,8 +31,12 @@ typedef union {
|
||||
uint32_t color;
|
||||
} Color;
|
||||
|
||||
void drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h, bool fill);
|
||||
void drw_fill_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h);
|
||||
void drw_over_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h);
|
||||
|
||||
void drw_draw_text(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
uint32_t w, uint32_t h, const char *label);
|
||||
|
108
keyboard.c
108
keyboard.c
@ -166,26 +166,67 @@ 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;
|
||||
|
||||
if (kb->last_press) {
|
||||
kbd_draw_key(kb, kb->last_press, false);
|
||||
if (kb->last_press->type == Copy) {
|
||||
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 (kb->last_press->type == Copy) {
|
||||
zwp_virtual_keyboard_v1_key(kb->vkbd, time, 127, // COMP key
|
||||
WL_KEYBOARD_KEY_STATE_RELEASED);
|
||||
} else {
|
||||
zwp_virtual_keyboard_v1_key(kb->vkbd, time, kb->last_press->code,
|
||||
WL_KEYBOARD_KEY_STATE_RELEASED);
|
||||
}
|
||||
kb->last_press = NULL;
|
||||
|
||||
if (kb->compose >= 2) {
|
||||
kb->compose = 0;
|
||||
kbd_switch_layout(kb, kb->prevlayout);
|
||||
if ((kb->mods & Shift) == Shift)
|
||||
kb->mods ^= Shift;
|
||||
} else if ((kb->mods & Shift) == Shift) {
|
||||
kb->mods ^= Shift;
|
||||
} else if (unlatch_shift) {
|
||||
kbd_draw_layout(kb);
|
||||
} else {
|
||||
kbd_draw_key(kb, kb->last_press, Unpress);
|
||||
}
|
||||
|
||||
kb->last_press = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void kbd_release_key(struct kbd *kb, uint32_t time) {
|
||||
kbd_unpress_key(kb, time);
|
||||
if (kb->print_intersect && kb->last_swipe) {
|
||||
printf("\n");
|
||||
// Important so autocompleted words get typed in time
|
||||
fflush(stdout);
|
||||
kbd_draw_layout(kb);
|
||||
kb->last_swipe = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
if (kb->last_press) {
|
||||
kbd_unpress_key(kb, time);
|
||||
// Redraw last press as a swipe.
|
||||
kbd_draw_key(kb, kb->last_swipe, Swipe);
|
||||
}
|
||||
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)) {
|
||||
kbd_print_key_stdout(kb, intersect_key);
|
||||
kb->last_swipe = intersect_key;
|
||||
kbd_draw_key(kb, kb->last_swipe, Swipe);
|
||||
}
|
||||
} else {
|
||||
kbd_unpress_key(kb, time);
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,11 +253,11 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
||||
} else {
|
||||
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
|
||||
}
|
||||
kb->last_press = k;
|
||||
kbd_draw_key(kb, k, true);
|
||||
kb->last_swipe = kb->last_press = k;
|
||||
kbd_draw_key(kb, k, Press);
|
||||
zwp_virtual_keyboard_v1_key(kb->vkbd, time, kb->last_press->code,
|
||||
WL_KEYBOARD_KEY_STATE_PRESSED);
|
||||
if (kb->print)
|
||||
if (kb->print || kb->print_intersect)
|
||||
kbd_print_key_stdout(kb, k);
|
||||
if (kb->compose) {
|
||||
if (kb->debug)
|
||||
@ -229,7 +270,11 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
||||
if (k->code == Shift) {
|
||||
kbd_draw_layout(kb);
|
||||
}
|
||||
kbd_draw_key(kb, k, kb->mods & k->code);
|
||||
if (kb->mods & k->code) {
|
||||
kbd_draw_key(kb, k, Press);
|
||||
} else {
|
||||
kbd_draw_key(kb, k, Unpress);
|
||||
}
|
||||
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
|
||||
break;
|
||||
case Layout:
|
||||
@ -243,7 +288,11 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
||||
} else {
|
||||
kb->compose = 0;
|
||||
}
|
||||
kbd_draw_key(kb, k, (bool)kb->compose);
|
||||
if ((bool)kb->compose) {
|
||||
kbd_draw_key(kb, k, Press);
|
||||
} else {
|
||||
kbd_draw_key(kb, k, Unpress);
|
||||
}
|
||||
break;
|
||||
case NextLayer:
|
||||
// switch to the next layout in the layer sequence
|
||||
@ -271,15 +320,15 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
|
||||
break;
|
||||
case Copy:
|
||||
// copy code as unicode chr by setting a temporary keymap
|
||||
kb->last_press = k;
|
||||
kbd_draw_key(kb, k, true);
|
||||
kb->last_swipe = kb->last_press = k;
|
||||
kbd_draw_key(kb, k, Press);
|
||||
if (kb->debug)
|
||||
fprintf(stderr, "pressing copy key\n");
|
||||
create_and_upload_keymap(kb, kb->layout->keymap_name, k->code, k->code_mod);
|
||||
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
|
||||
zwp_virtual_keyboard_v1_key(kb->vkbd, time, 127, // COMP key
|
||||
WL_KEYBOARD_KEY_STATE_PRESSED);
|
||||
if (kb->print)
|
||||
if (kb->print || kb->print_intersect)
|
||||
kbd_print_key_stdout(kb, k);
|
||||
break;
|
||||
default:
|
||||
@ -327,15 +376,24 @@ kbd_print_key_stdout(struct kbd *kb, struct key *k) {
|
||||
}
|
||||
|
||||
void
|
||||
kbd_draw_key(struct kbd *kb, struct key *k, bool pressed) {
|
||||
kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type) {
|
||||
struct drwsurf *d = kb->surf;
|
||||
const char *label = (kb->mods & Shift) ? k->shift_label : k->label;
|
||||
if (kb->debug)
|
||||
fprintf(stderr, "Draw key +%d+%d %dx%d -> %s\n", k->x, k->y, k->w, k->h,
|
||||
label);
|
||||
struct clr_scheme *scheme = (k->scheme == 0) ? &(kb->scheme) : &(kb->scheme1);
|
||||
Color *fill = pressed ? &scheme->high : &scheme->fg;
|
||||
draw_inset(d, k->x, k->y, k->w, k->h, KBD_KEY_BORDER, *fill);
|
||||
switch (type) {
|
||||
case Unpress:
|
||||
draw_inset(d, k->x, k->y, k->w, k->h, KBD_KEY_BORDER, scheme->fg);
|
||||
break;
|
||||
case Press:
|
||||
draw_inset(d, k->x, k->y, k->w, k->h, KBD_KEY_BORDER, scheme->high);
|
||||
break;
|
||||
case Swipe:
|
||||
draw_over_inset(d, k->x, k->y, k->w, k->h, KBD_KEY_BORDER, scheme->swipe);
|
||||
break;
|
||||
}
|
||||
drw_draw_text(d, scheme->text, k->x, k->y, k->w, k->h, label);
|
||||
}
|
||||
|
||||
@ -343,7 +401,6 @@ void
|
||||
kbd_draw_layout(struct kbd *kb) {
|
||||
struct drwsurf *d = kb->surf;
|
||||
struct key *next_key = kb->layout->keys;
|
||||
bool pressed = false;
|
||||
if (kb->debug)
|
||||
fprintf(stderr, "Draw layout");
|
||||
|
||||
@ -354,8 +411,11 @@ kbd_draw_layout(struct kbd *kb) {
|
||||
next_key++;
|
||||
continue;
|
||||
}
|
||||
pressed = next_key->type == Mod && kb->mods & next_key->code;
|
||||
kbd_draw_key(kb, next_key, pressed);
|
||||
if (next_key->type == Mod && kb->mods & next_key->code) {
|
||||
kbd_draw_key(kb, next_key, Press);
|
||||
} else {
|
||||
kbd_draw_key(kb, next_key, Unpress);
|
||||
}
|
||||
next_key++;
|
||||
}
|
||||
}
|
||||
@ -380,6 +440,12 @@ draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||
drw_fill_rectangle(ds, color, x + border, y + border, width - border,
|
||||
height - border);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
create_and_upload_keymap(struct kbd *kb, const char *name, uint32_t comp_unichr,
|
||||
|
15
keyboard.h
15
keyboard.h
@ -41,10 +41,17 @@ enum key_modifier_type {
|
||||
AltGr = 128,
|
||||
};
|
||||
|
||||
enum key_draw_type {
|
||||
Unpress = 0,
|
||||
Press,
|
||||
Swipe,
|
||||
};
|
||||
|
||||
struct clr_scheme {
|
||||
Color fg;
|
||||
Color bg;
|
||||
Color high;
|
||||
Color swipe;
|
||||
Color text;
|
||||
};
|
||||
|
||||
@ -85,11 +92,13 @@ struct kbd {
|
||||
struct clr_scheme scheme1;
|
||||
|
||||
bool print;
|
||||
bool print_intersect;
|
||||
uint32_t w, h, s;
|
||||
bool landscape;
|
||||
uint8_t mods;
|
||||
uint8_t compose;
|
||||
struct key *last_press;
|
||||
struct key *last_swipe;
|
||||
struct layout *prevlayout;
|
||||
size_t layer_index;
|
||||
|
||||
@ -103,14 +112,18 @@ struct kbd {
|
||||
|
||||
void draw_inset(struct drwsurf *ds, uint32_t x, uint32_t y, uint32_t width,
|
||||
uint32_t height, uint32_t border, Color color);
|
||||
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_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);
|
||||
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_press_key(struct kbd *kb, struct key *k, uint32_t time);
|
||||
void kbd_print_key_stdout(struct kbd *kb, struct key *k);
|
||||
void kbd_draw_key(struct kbd *kb, struct key *k, bool pressed);
|
||||
void kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type);
|
||||
void kbd_draw_layout(struct kbd *kb);
|
||||
void kbd_resize(struct kbd *kb, struct layout *layouts, uint8_t layoutcount);
|
||||
uint8_t kbd_get_rows(struct layout *l);
|
||||
|
1468
keymap.mobintl.h
1468
keymap.mobintl.h
File diff suppressed because it is too large
Load Diff
@ -21,6 +21,7 @@ enum layout_id {
|
||||
Dialer,
|
||||
Cyrillic,
|
||||
Arabic,
|
||||
Georgian,
|
||||
Emoji,
|
||||
Nav,
|
||||
Landscape,
|
||||
@ -66,7 +67,7 @@ enum layout_id {
|
||||
};
|
||||
|
||||
static struct key keys_full[], keys_special[], keys_simple[], keys_simplegrid[],
|
||||
keys_cyrillic[], keys_arabic[], keys_emoji[], keys_nav[], keys_landscape[],
|
||||
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[],
|
||||
@ -88,6 +89,7 @@ static struct layout layouts[NumLayouts] = {
|
||||
[Cyrillic] = {keys_cyrillic, "cyrillic", "cyrillic"},
|
||||
[Dialer] = {keys_dialer, "latin", "dialer"},
|
||||
[Arabic] = {keys_arabic, "arabic", "arabic"},
|
||||
[Georgian] = {keys_georgian, "georgian", "georgian"},
|
||||
[Emoji] = {keys_emoji, "latin", "emoji"},
|
||||
[Nav] = {keys_nav, "latin", "nav"},
|
||||
[Landscape] = {keys_landscape, "latin", "landscape"},
|
||||
@ -363,8 +365,8 @@ static struct key keys_dialer[] = {
|
||||
{"0", "0", 1.0, Code, KEY_0},
|
||||
{"#", "#", 1.0, Code, KEY_NUMERIC_POUND},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme = 1}
|
||||
,
|
||||
{"Abc", "Abc", 1.0, NextLayer, .scheme = 1},
|
||||
{"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme = 1},
|
||||
|
||||
/* end of layout */
|
||||
{"", "", 0.0, Last},
|
||||
@ -548,6 +550,66 @@ static struct key keys_arabic[] = {
|
||||
{"", "", 0.0, Last},
|
||||
};
|
||||
|
||||
static struct key keys_georgian[] = {
|
||||
{"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},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"ქ", "Q", 1.0, Code, KEY_Q},
|
||||
{"წ", "ჭ", 1.0, Code, KEY_W},
|
||||
{"ე", "E", 1.0, Code, KEY_E},
|
||||
{"რ", "ღ", 1.0, Code, KEY_R},
|
||||
{"ტ", "თ", 1.0, Code, KEY_T},
|
||||
{"ყ", "Y", 1.0, Code, KEY_Y},
|
||||
{"უ", "U", 1.0, Code, KEY_U},
|
||||
{"ი", "I", 1.0, Code, KEY_I},
|
||||
{"ო", "O", 1.0, Code, KEY_O},
|
||||
{"პ", "P", 1.0, Code, KEY_P},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"ა", "A", 1.0, Code, KEY_A},
|
||||
{"ს", "შ", 1.0, Code, KEY_S},
|
||||
{"დ", "D", 1.0, Code, KEY_D},
|
||||
{"ფ", "F", 1.0, Code, KEY_F},
|
||||
{"გ", "G", 1.0, Code, KEY_G},
|
||||
{"ჰ", "H", 1.0, Code, KEY_H},
|
||||
{"ჯ", "ჟ", 1.0, Code, KEY_J},
|
||||
{"კ", "K", 1.0, Code, KEY_K},
|
||||
{"ლ", "L", 1.0, Code, KEY_L},
|
||||
{";", ":", 1.0, Code, KEY_SEMICOLON},
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"ზ", "ძ", 1.0, Code, KEY_Z},
|
||||
{"ხ", "X", 1.0, Code, KEY_X},
|
||||
{"ც", "ჩ", 1.0, Code, KEY_C},
|
||||
{"ვ", "V", 1.0, Code, KEY_V},
|
||||
{"ბ", "B", 1.0, Code, KEY_B},
|
||||
{"ნ", "N", 1.0, Code, KEY_N},
|
||||
{"მ", "M", 1.0, Code, KEY_M},
|
||||
{",", "<", 1.0, Code, KEY_COMMA},
|
||||
{".", ">", 1.0, Code, KEY_DOT},
|
||||
{"⌫", "⌫", 1.0, Code, KEY_BACKSPACE, .scheme = 1},
|
||||
|
||||
{"", "", 0.0, EndRow},
|
||||
|
||||
{"Abc", "Abc", 1.0, NextLayer, .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},
|
||||
|
||||
/* end of layout */
|
||||
{"", "", 0.0, Last},
|
||||
};
|
||||
|
||||
static struct key keys_compose_a[] = {
|
||||
{"à", "À", 1.0, Copy, 0x00E0, 0, 0x00C0},
|
||||
{"á", "Á", 1.0, Copy, 0x00E1, 0, 0x00C1},
|
||||
@ -691,8 +753,8 @@ static struct key keys_compose_i[] = {
|
||||
{"ī", "Ī", 1.0, Copy, 0x012B, 0, 0x012A},
|
||||
{"ĭ", "Ĭ", 1.0, Copy, 0x012D, 0, 0x012C},
|
||||
{"į", "Į", 1.0, Copy, 0x012F, 0, 0x012E},
|
||||
{"ı", "I", 1.0, Copy, 0x0150, 0, 0x0049},
|
||||
{"i", "İ", 1.0, Copy, 0x0069, 0, 0x0152},
|
||||
{"ı", "I", 1.0, Copy, 0x0131, 0, 0x0049},
|
||||
{"i", "İ", 1.0, Copy, 0x0069, 0, 0x0130},
|
||||
{"", "", 0.0, EndRow},
|
||||
{"ι", "Ι", 1.0, Copy, 0x03B9, 0, 0x0399},
|
||||
{"η", "Η", 1.0, Copy, 0x03B7, 0, 0x0397},
|
||||
|
29
main.c
29
main.c
@ -42,6 +42,7 @@ static uint32_t anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM |
|
||||
/* application state */
|
||||
static bool run_display = true;
|
||||
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;
|
||||
|
||||
@ -159,13 +160,18 @@ wl_touch_down(void *data, struct wl_touch *wl_touch, uint32_t serial,
|
||||
void
|
||||
wl_touch_up(void *data, struct wl_touch *wl_touch, uint32_t serial,
|
||||
uint32_t time, int32_t id) {
|
||||
kbd_unpress_key(&keyboard, time);
|
||||
kbd_release_key(&keyboard, time);
|
||||
}
|
||||
|
||||
void
|
||||
wl_touch_motion(void *data, struct wl_touch *wl_touch, uint32_t time,
|
||||
int32_t id, wl_fixed_t x, wl_fixed_t y) {
|
||||
kbd_unpress_key(&keyboard, time);
|
||||
uint32_t touch_x, touch_y;
|
||||
|
||||
touch_x = wl_fixed_to_int(x);
|
||||
touch_y = wl_fixed_to_int(y);
|
||||
|
||||
kbd_motion_key(&keyboard, time, touch_x, touch_y);
|
||||
}
|
||||
|
||||
void
|
||||
@ -199,18 +205,24 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, uint32_t time,
|
||||
cur_x = wl_fixed_to_int(surface_x);
|
||||
cur_y = wl_fixed_to_int(surface_y);
|
||||
|
||||
kbd_unpress_key(&keyboard, time);
|
||||
if (cur_press) {
|
||||
kbd_motion_key(&keyboard, time, cur_x, cur_y);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
wl_pointer_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
|
||||
uint32_t time, uint32_t button, uint32_t state) {
|
||||
struct key *next_key;
|
||||
bool press = state == WL_POINTER_BUTTON_STATE_PRESSED;
|
||||
cur_press = state == WL_POINTER_BUTTON_STATE_PRESSED;
|
||||
|
||||
kbd_unpress_key(&keyboard, time);
|
||||
if (cur_press) {
|
||||
kbd_unpress_key(&keyboard, time);
|
||||
} else {
|
||||
kbd_release_key(&keyboard, time);
|
||||
}
|
||||
|
||||
if (press && cur_x >= 0 && cur_y >= 0) {
|
||||
if (cur_press && cur_x >= 0 && cur_y >= 0) {
|
||||
next_key = kbd_get_key(&keyboard, cur_x, cur_y);
|
||||
if (next_key) {
|
||||
kbd_press_key(&keyboard, next_key, time);
|
||||
@ -335,7 +347,8 @@ usage(char *argv0) {
|
||||
argv0);
|
||||
fprintf(stderr, "Options:\n");
|
||||
fprintf(stderr, " -D - Enable debug\n");
|
||||
fprintf(stderr, " -o - Print press keys to standard output\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");
|
||||
@ -445,6 +458,8 @@ main(int argc, char **argv) {
|
||||
fc_font_pattern = estrdup(argv[++i]);
|
||||
} else if (!strcmp(argv[i], "-o")) {
|
||||
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 {
|
||||
|
Reference in New Issue
Block a user