mirror of
https://github.com/jjsullivan5196/wvkbd.git
synced 2025-03-13 10:52:47 +01:00
Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
ca53099c9d | ||
|
29639c28d5 | ||
|
745a0b6f53 | ||
|
c742b58f51 | ||
|
97efb1de74 | ||
|
125664afd5 | ||
|
6041473421 | ||
|
9cc8931b46 | ||
|
7d195c8217 | ||
|
d5db545dcc | ||
|
7d677d23b7 | ||
|
fe3257450a | ||
|
1852b3ab06 | ||
|
9d130e7fd2 |
15
Makefile
15
Makefile
@ -10,9 +10,10 @@ PKGS = wayland-client xkbcommon pangocairo
|
||||
WVKBD_SOURCES += $(wildcard $(SRC)/*.c)
|
||||
WVKBD_HEADERS += $(wildcard $(SRC)/*.h)
|
||||
|
||||
PKG_CONFIG ?= pkg-config
|
||||
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
|
||||
CFLAGS += $(shell $(PKG_CONFIG) --cflags $(PKGS))
|
||||
LDFLAGS += $(shell $(PKG_CONFIG) --libs $(PKGS)) -lm -lutil -lrt
|
||||
|
||||
WAYLAND_HEADERS = $(wildcard proto/*.xml)
|
||||
|
||||
@ -20,9 +21,12 @@ HDRS = $(WAYLAND_HEADERS:.xml=-client-protocol.h)
|
||||
WAYLAND_SRC = $(HDRS:.h=.c)
|
||||
SOURCES = $(WVKBD_SOURCES) $(WAYLAND_SRC)
|
||||
|
||||
SCDOC=scdoc
|
||||
DOCS = wvkbd.1
|
||||
|
||||
OBJECTS = $(SOURCES:.c=.o)
|
||||
|
||||
all: ${BIN}
|
||||
all: ${BIN} ${DOCS}
|
||||
|
||||
config.h:
|
||||
cp config.def.h config.h
|
||||
@ -39,11 +43,14 @@ wvkbd-${LAYOUT}: config.h $(OBJECTS) layout.${LAYOUT}.h
|
||||
$(CC) -o wvkbd-${LAYOUT} $(OBJECTS) $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJECTS) $(HDRS) $(WAYLAND_SRC) ${BIN}
|
||||
rm -f $(OBJECTS) $(HDRS) $(WAYLAND_SRC) ${BIN} ${DOCS}
|
||||
|
||||
format:
|
||||
clang-format -i $(WVKBD_SOURCES) $(WVKBD_HEADERS)
|
||||
|
||||
%: %.scd
|
||||
$(SCDOC) < $< > $@
|
||||
|
||||
install: all
|
||||
mkdir -p ${DESTDIR}${PREFIX}/bin
|
||||
cp -f ${NAME}-${LAYOUT} ${DESTDIR}${PREFIX}/bin
|
||||
|
@ -1,6 +1,6 @@
|
||||
# wvkbd - On-screen keyboard for wlroots that sucks less
|
||||
|
||||
<img src="https://raw.githubusercontent.com/proycon/wvkbd/master/contrib/wvkbd-mobintl.jpg" width=300 /> <img src="https://raw.githubusercontent.com/proycon/wvkbd/master/contrib/wvkbd-mobintl-cyrillic.jpg" width=300 />
|
||||
<img src="https://raw.githubusercontent.com/jjsullivan5196/wvkbd/master/contrib/wvkbd-mobintl.jpg" width=300 /> <img src="https://raw.githubusercontent.com/jjsullivan5196/wvkbd/master/contrib/wvkbd-mobintl-cyrillic.jpg" width=300 />
|
||||
|
||||
This project aims to deliver a minimal but practically usable implementation of a wlroots on-screen
|
||||
keyboard in legible C. This will **only** be a keyboard, not a feedback buzzer,
|
||||
@ -25,7 +25,7 @@ new features.
|
||||
- Automatic portrait/landscape detection and subsequent layout switching
|
||||
|
||||
|
||||
<img src="https://raw.githubusercontent.com/proycon/wvkbd/master/contrib/wvkbd-mobintl-landscape.jpg" width=640 />
|
||||
<img src="https://raw.githubusercontent.com/jjsullivan5196/wvkbd/master/contrib/wvkbd-mobintl-landscape.jpg" width=640 />
|
||||
|
||||
There are some areas that still need work:
|
||||
|
||||
@ -42,6 +42,8 @@ You'll need the following developer packages
|
||||
- wayland-client
|
||||
- xkbcommon
|
||||
|
||||
You also need [scdoc](https://git.sr.ht/~sircmpwn/scdoc/) to generate the documentation.
|
||||
|
||||
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
|
||||
|
@ -1,4 +1,4 @@
|
||||
VERSION = 0.15
|
||||
VERSION = 0.16.1
|
||||
CFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=700
|
||||
PREFIX = /usr/local
|
||||
MANPREFIX = ${PREFIX}/share/man
|
||||
|
2
drw.c
2
drw.c
@ -99,6 +99,8 @@ drw_do_rectangle(struct drwsurf *d, Color color, uint32_t x, uint32_t y,
|
||||
cairo_set_source_rgba(d->cairo, 0, 0, 0, 0.9);
|
||||
cairo_set_line_width(d->cairo, 1.0);
|
||||
cairo_stroke(d->cairo);
|
||||
|
||||
cairo_restore(d->cairo);
|
||||
}
|
||||
else {
|
||||
cairo_rectangle(d->cairo, x, y, w, h);
|
||||
|
27
keyboard.c
27
keyboard.c
@ -3,6 +3,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/mman.h>
|
||||
#include <ctype.h>
|
||||
#include "keyboard.h"
|
||||
#include "drw.h"
|
||||
#include "os-compatibility.h"
|
||||
@ -276,13 +277,23 @@ kbd_get_layer_index(struct kbd *kb, struct layout *l)
|
||||
void
|
||||
kbd_unpress_key(struct kbd *kb, uint32_t time)
|
||||
{
|
||||
bool unlatch_shift = false;
|
||||
bool unlatch_shift, unlatch_ctrl, unlatch_alt, unlatch_super, unlatch_altgr;
|
||||
unlatch_shift = unlatch_ctrl = unlatch_alt = unlatch_super = unlatch_altgr = false;
|
||||
|
||||
if (kb->last_press) {
|
||||
unlatch_shift = (kb->mods & Shift) == Shift;
|
||||
unlatch_ctrl = (kb->mods & Ctrl) == Ctrl;
|
||||
unlatch_alt = (kb->mods & Alt) == Alt;
|
||||
unlatch_super = (kb->mods & Super) == Super;
|
||||
unlatch_altgr = (kb->mods & AltGr) == AltGr;
|
||||
|
||||
if (unlatch_shift) {
|
||||
kb->mods ^= Shift;
|
||||
if (unlatch_shift) kb->mods ^= Shift;
|
||||
if (unlatch_ctrl) kb->mods ^= Ctrl;
|
||||
if (unlatch_alt) kb->mods ^= Alt;
|
||||
if (unlatch_super) kb->mods ^= Super;
|
||||
if (unlatch_altgr) kb->mods ^= AltGr;
|
||||
|
||||
if (unlatch_shift||unlatch_ctrl||unlatch_alt||unlatch_super||unlatch_altgr) {
|
||||
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
|
||||
}
|
||||
|
||||
@ -304,7 +315,7 @@ kbd_unpress_key(struct kbd *kb, uint32_t time)
|
||||
if (kb->compose >= 2) {
|
||||
kb->compose = 0;
|
||||
kbd_switch_layout(kb, kb->last_abc_layout, kb->last_abc_index);
|
||||
} else if (unlatch_shift) {
|
||||
} else if (unlatch_shift||unlatch_ctrl||unlatch_alt||unlatch_super||unlatch_altgr) {
|
||||
kbd_draw_layout(kb);
|
||||
} else {
|
||||
kbd_draw_key(kb, kb->last_press, Unpress);
|
||||
@ -418,7 +429,7 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time)
|
||||
break;
|
||||
case Mod:
|
||||
kb->mods ^= k->code;
|
||||
if (k->code == Shift) {
|
||||
if ((k->code == Shift) || (k->code == CapsLock)) {
|
||||
kbd_draw_layout(kb);
|
||||
} else {
|
||||
if (kb->mods & k->code) {
|
||||
@ -527,7 +538,8 @@ kbd_print_key_stdout(struct kbd *kb, struct key *k)
|
||||
}
|
||||
|
||||
if (!handled) {
|
||||
if ((kb->mods & Shift) || (kb->mods & CapsLock))
|
||||
if ((kb->mods & Shift) ||
|
||||
((kb->mods & CapsLock) & (strlen(k->label) == 1 && isalpha(k->label[0]))))
|
||||
printf("%s", k->shift_label);
|
||||
else if (!(kb->mods & Ctrl) && !(kb->mods & Alt) && !(kb->mods & Super))
|
||||
printf("%s", k->label);
|
||||
@ -551,7 +563,8 @@ kbd_clear_last_popup(struct kbd *kb)
|
||||
void
|
||||
kbd_draw_key(struct kbd *kb, struct key *k, enum key_draw_type type)
|
||||
{
|
||||
const char *label = (kb->mods & Shift) ? k->shift_label : k->label;
|
||||
const char *label = ((kb->mods & Shift)||((kb->mods & CapsLock) &&
|
||||
strlen(k->label) == 1 && isalpha(k->label[0]))) ? 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);
|
||||
|
36
main.c
36
main.c
@ -65,7 +65,7 @@ static struct drw draw_ctx;
|
||||
static struct drwsurf draw_surf, popup_draw_surf;
|
||||
|
||||
/* layer surface parameters */
|
||||
static uint32_t layer = ZWLR_LAYER_SHELL_V1_LAYER_TOP;
|
||||
static uint32_t layer = ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY;
|
||||
static uint32_t anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM |
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
||||
@ -132,6 +132,7 @@ static void layer_surface_configure(void *data,
|
||||
static void layer_surface_closed(void *data,
|
||||
struct zwlr_layer_surface_v1 *surface);
|
||||
static void flip_landscape();
|
||||
static void show();
|
||||
|
||||
/* event handlers */
|
||||
static const struct wl_pointer_listener pointer_listener = {
|
||||
@ -560,12 +561,7 @@ flip_landscape()
|
||||
if (current_output) {
|
||||
keyboard.landscape = current_output->w > current_output->h;
|
||||
} else if (wl_outputs_size) {
|
||||
for (int i = 0; i < wl_outputs_size; i += 1) {
|
||||
if (wl_outputs[i].w > wl_outputs[i].h) {
|
||||
keyboard.landscape = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
keyboard.landscape = wl_outputs[0].w > wl_outputs[0].h;
|
||||
}
|
||||
|
||||
enum layout_id layer;
|
||||
@ -583,10 +579,25 @@ flip_landscape()
|
||||
keyboard.last_abc_layout = keyboard.layout;
|
||||
keyboard.last_abc_index = 0;
|
||||
|
||||
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);
|
||||
if (layer_surface && previous_landscape != keyboard.landscape) {
|
||||
if (popup_xdg_popup) {
|
||||
xdg_popup_destroy(popup_xdg_popup);
|
||||
popup_xdg_popup = NULL;
|
||||
}
|
||||
if (popup_xdg_surface) {
|
||||
xdg_surface_destroy(popup_xdg_surface);
|
||||
popup_xdg_surface = NULL;
|
||||
}
|
||||
if (popup_draw_surf.surf) {
|
||||
wl_surface_destroy(popup_draw_surf.surf);
|
||||
popup_draw_surf.surf = NULL;
|
||||
}
|
||||
|
||||
zwlr_layer_surface_v1_destroy(layer_surface);
|
||||
layer_surface = NULL;
|
||||
wl_surface_destroy(draw_surf.surf);
|
||||
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1031,6 +1042,9 @@ main(int argc, char **argv)
|
||||
die("virtual_keyboard_manager not available\n");
|
||||
}
|
||||
|
||||
// A second round-trip to receive wl_outputs events
|
||||
wl_display_roundtrip(display);
|
||||
|
||||
empty_region = wl_compositor_create_region(compositor);
|
||||
popup_xdg_positioner = xdg_wm_base_create_positioner(wm_base);
|
||||
|
||||
|
76
wvkbd.1
76
wvkbd.1
@ -1,76 +0,0 @@
|
||||
.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--landscape-layers\fR
|
||||
.RS 4
|
||||
comma separated list of layers used in landscape mode
|
||||
.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>.
|
129
wvkbd.1.scd
Normal file
129
wvkbd.1.scd
Normal file
@ -0,0 +1,129 @@
|
||||
wvkbd(1)
|
||||
|
||||
# NAME
|
||||
|
||||
wvkbd - on-screen virtual keyboard for wayland compositors using wlroots
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
wvkbd-mobintl [OPTIONS]...
|
||||
|
||||
*NOTE*: Your binary may have a different suffix depending on which layout you compiled.
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
This project aims to deliver a minimal but practically usable implementation of
|
||||
a wlroots on-screen keyboard in legible C. This will _only_ be a keyboard, not
|
||||
a feedback buzzer, led blinker, or anything that requires more than what's
|
||||
needed to input text quickly. The end product should be a static codebase that
|
||||
can be patched to add new features.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
*-D*
|
||||
enable debug mode.
|
||||
|
||||
*-o*
|
||||
print pressed keys to standard output.
|
||||
|
||||
*-O*
|
||||
print intersected keys to standard output.
|
||||
|
||||
*-l* _layers_
|
||||
comma separated list of layers in vertical/portrait mode.
|
||||
|
||||
*--landscape-layers* _layers_
|
||||
comma separated list of layers used in horizontal/landscape mode.
|
||||
|
||||
*--list-layers*
|
||||
prints a list of all available layers.
|
||||
|
||||
*-H* _pixels_
|
||||
Height of the keyboard in pixels, for vertical/portrait mode.
|
||||
|
||||
*-L* _pixels_
|
||||
Height of the keyboard in pixels, for horizontal/landscape mode
|
||||
|
||||
*--fn* _font_
|
||||
set font and size (e.g. DejaVu Sans 20)
|
||||
|
||||
*--hidden*
|
||||
Start hidden (send SIGUSR2 to show).
|
||||
|
||||
*--alpha* _int_
|
||||
Set alpha value (i.e. transparency) for all colors [0-255]
|
||||
|
||||
*--bg* _rrggbb|aa_
|
||||
Set color of background
|
||||
|
||||
*--fg* _rrggbb|aa_
|
||||
Set color of keys
|
||||
|
||||
*--fg-sp* _rrggbb|aa_
|
||||
Set color of special keys
|
||||
|
||||
*--press* _rrggbb|aa_
|
||||
Set color of pressed keys
|
||||
|
||||
*--press-sp* _rrggbb|aa_
|
||||
Set color of pressed special keys
|
||||
|
||||
*--swipe* _rrggbb|aa_
|
||||
Set color of swiped keys
|
||||
|
||||
*--swipe-sp* _rrggbb|aa_
|
||||
Set color of swiped special keys
|
||||
|
||||
*--text* _rrggbb|aa_
|
||||
Set color text on keys
|
||||
|
||||
*--text-sp* _rrggbb|aa_
|
||||
Set color text on special keys
|
||||
|
||||
*--version*
|
||||
Print version information
|
||||
|
||||
*-h*, *--help*
|
||||
Print usage help
|
||||
|
||||
|
||||
# SIGNALS
|
||||
|
||||
You can send signals to wvkbd to hide/show it (e.g. using _kill_(1) with _-s_):
|
||||
|
||||
*SIGUSR1*
|
||||
Hide the keyboard.
|
||||
|
||||
*SIGUSR2*
|
||||
Show the keyboard
|
||||
|
||||
*SIGRTMIN*
|
||||
Toggle visibility
|
||||
|
||||
# COMPOSE BUTTON
|
||||
|
||||
The default mobile international layout features a Compose button (*Cmp*)
|
||||
which, when combined with another key, opens up a layout that offers variants
|
||||
for that key. This is similar to functionality that other keyboards implemented
|
||||
using a *long press* (wvkbd has no such notion, holding a key will repeat
|
||||
it like on a physical keyboard).
|
||||
|
||||
For example, press Cmp + a to access variants with diacritics like á,à,â,ä, etc..
|
||||
|
||||
Most layouts also feature the following that are less obvious:
|
||||
|
||||
- Press Cmp and . to access more punctuation
|
||||
- Press Cmp and - or , to access 'mathematical' symbols (+,-,=,etc)
|
||||
- Press Cmp and ' or 0 or 9 to access more brackets and quotes
|
||||
- Press Cmp and q to access emojis
|
||||
|
||||
Last, but not least, pressing Cmp + space or Cmp + ⌨ or Cmp + Abc opens up an
|
||||
index that allows you to immediately jump to any layout by name, even layouts
|
||||
not explicitly added to your layers on startup.
|
||||
|
||||
# AUTHORS
|
||||
|
||||
Created by John Sullivan <jsullivan@csumb.edu>, maintained by the Sxmo project
|
||||
<https://sxmo.org> 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>.
|
Loading…
x
Reference in New Issue
Block a user