Commit graph

76 commits

Author SHA1 Message Date
Richard Acayan
d3d28a310d core: graphics: update scale when layout changes
With the new layout switching, the size of the layout can change. The
scale depends on the size of the layout. Update the graphics scale when
the layout changes.
2024-09-30 22:14:48 -04:00
Richard Acayan
e5d0716c0f core: button: add support for layout switching keys 2024-09-30 22:14:47 -04:00
Richard Acayan
71ca235a09 core: graphics: add label metadata for layout switching keys
Add properties for these labels so they can be used in keys that switch
the layout.
2024-09-30 22:12:59 -04:00
Richard Acayan
317a11d17c wayland: surface: inline trivial methods 2024-09-30 22:11:18 -04:00
Richard Acayan
0b985cefdb core: move scaling of input positions into core
The core may need to control the scale of the input positions to layout
positions, such as when the layout is changed. Handle the scaling of
input positions in the button of the keyboard.
2024-09-30 22:08:53 -04:00
Richard Acayan
0fa318ca7e core: layout: use built-in uppercase function for shift modifier
There are uppercase symbols outside the Latin alphabet. Use the built-in
uppercase function for displaying uppercase text due to the shift key.
2024-09-30 22:05:06 -04:00
Richard Acayan
0206b82a94 core: config: remove stray print statement
This print statement was for debugging, but configuration works properly
now. Remove the stray statement.
2024-09-30 22:05:06 -04:00
Richard Acayan
57265544ab core: layout: omit bottom row when explicitly disabled by main layout
The main layout (e.g. latn_bone.xml and latn_neo2.xml) may disable the
bottom row by adding a property to the XML keyboard tag. Omit the bottom
row when this is the case.
2024-09-26 19:36:51 -04:00
Richard Acayan
1391589ce0 core: layout: resize bottom row according to main layout
In the Unexpected Keyboard, the bottom row always has the width of the
main layout despite being defined with a width of 10 units. Resize the
bottom row according to the main layout to improve layouts like
arab_pc.xml and numeric.xml.
2024-09-26 19:32:38 -04:00
Richard Acayan
253575febd core: layout: separate layout file parsing into new struct
Some fields in the layout can be abandoned when parsing is complete. The
code for opening and parsing a file is partially duplicated for the main
layout and bottom row. Separate the parsing into a new struct to make
the individual results easier to work with.
2024-09-26 17:19:43 -04:00
Richard Acayan
81aae23fe7 wayland: keyboard: assign static key codes for some keys
Some applications like Waydroid and Klavaro (with the Enter key) ignore
the keyboard layout and expect a key code from the Linux input UAPI.
Assign static key codes for keys on the QWERTY layout so some keys can
still work with these applications.
2024-09-25 19:53:13 -04:00
Richard Acayan
e8a3995710 wayland: buffer: add comments to outline some non-trivial functions 2024-09-20 21:23:06 -04:00
Richard Acayan
fd4b9dcf12 Cargo.toml: update dependencies 2024-09-04 21:45:59 -04:00
Richard Acayan
f3ba955ae4 core: add meta key
Some applications have features (like typing Unicode codepoints in foot)
that can only be used with key presses. Add a Meta key to allow the user
to always send a keypress.
2024-09-04 21:45:57 -04:00
Richard Acayan
0ebf6a8d5b wayland: truncate scaled width and height on configure
When a configure event is emitted, the updated graphical dimensions are
sent unscaled. Currently, the application applies fractional scaling to
the dimensions by truncating the scale to an integer. This is incorrect,
as scales could be fractional and the compositor would expect the
fractional scale to be applied to the width and height. Truncate the
width and height after scaling instead of truncating the scale to reduce
the right and bottom seams to 0-1 pixels.
2024-08-26 18:20:25 -04:00
Richard Acayan
e17e4f31f5 core: graphics: finish supporting glyphs extending past font descent
Extend the height of the label when a glyph goes past the descent.

Also truncate the bitmap when the height is final.

Also remove statements added for debugging.
2024-08-19 23:14:08 -04:00
Richard Acayan
6027469c08 Cargo.toml: bump to version 1.1.0 2024-08-19 21:52:41 -04:00
Richard Acayan
3016dff2bd Cargo.toml: update dependencies to latest version 2024-08-19 21:49:42 -04:00
Richard Acayan
70775b8350 core: graphics: adjust size for glyphs outside regular vertical bounds
Some glyphs, specifically some Arabic text, may have a top that is
higher than the ascent value of the font, or a bottom that is lower than
the descent value of the font. For glyphs that fit inside the area, the
ascent and descent should be used for aligning with the top or bottom of
a key respectively. For glyphs that do not, align the top and bottom of
the text with the top and bottom of the key.
2024-08-19 21:47:39 -04:00
Richard Acayan
8ae15780b7 add license, readme, and gitignore 2024-08-12 23:14:39 -04:00
Richard Acayan
ad9096e6b7 core: layout: remove unreachable statement
This statement is the source of a warning because the statement above it
is already a catch-all. Remove it.
2024-08-12 19:19:18 -04:00
Richard Acayan
cec38887b1 wayland: keyboard: remove keysym sanitizing
The NoSymbol and XF86Fn keysyms are already filtered out because they
are not available and because the function key is a keysym modifier.
Remove the sanitizing.
2024-08-12 19:16:33 -04:00
Richard Acayan
63ee5a86a6 core: button: only draw the modifier key when pressed
When one modifier key is released, only the same key is drawn, even if
there are other identical modifier keys. Be consistent with this
optimization, and only draw the exact key that was pressed when a
modifier key is pressed.
2024-08-12 19:16:33 -04:00
Richard Acayan
1992b22ca1 core: button: only emit modifier keys that do not change the layout
Most future modifier keys will be accents that wouldn't be represented
with an actual key press. Only emit modifier keys as key presses if they
are of the other type (Ctrl, Alt, Shift).
2024-08-12 19:16:33 -04:00
Richard Acayan
ba9137d1f1 wayland: keyboard: skip adding unavailable keys to the keymap
Keys are unsupported if they have no name, or if xkeysym uses a
different format for their name (e.g. XF86Fn). Skip key symbols that
have no name and can't be added to the text keymap.

To support this, set the availability of each keysym before updating the
keymap.
2024-08-12 19:16:33 -04:00
Richard Acayan
79fa68e990 Cargo.toml: bump to version 1.0.0 2024-08-09 22:30:46 -04:00
Richard Acayan
71bee9f7ed core: actually add configuration code
This was meant to be included with the YAML configuration support, but
was not. Add it now.
2024-08-09 22:29:40 -04:00
Richard Acayan
d884e71d86 add yaml configuration
Example:

	%YAML 1.2
	---
	longpress_ms: 600
	repeat_ms: 25

	layout: latn_qwerty_us.xml

	wayland:
	  height: 185
2024-08-08 17:51:56 -04:00
Richard Acayan
7d36dfaf89 rename rust crate
The original name of the Rust crate is specifically the name of the Rust
implementation. Rename it to the project name.
2024-08-07 22:40:20 -04:00
Richard Acayan
32f3fee405 add sxmo target
The SXMO (sway) environment expects that the on-screen keyboard does not
handle visibility by itself. Add a new target that ignores the program's
own show/hide requests and shows the keyboard on startup.
2024-08-07 21:36:23 -04:00
Richard Acayan
cefc4ddc79 wayland: keyboard: add input method v1 support
Unfortunately, it is still not possible to emit keys in KDE Plasma.
2024-08-07 19:25:48 -04:00
Richard Acayan
5ac0295e3a wayland: keyboard: allow running without input emitting protocols 2024-08-07 19:25:41 -04:00
Richard Acayan
c5c5fa4a49 core: layout: update key capability according to new key value 2024-08-07 19:25:34 -04:00
Richard Acayan
50bb5dd106 core: layout: treat insert key value as non-text 2024-08-05 18:33:16 -04:00
Richard Acayan
c262b744aa core: layout: modify tab with fn to a literal tab character 2024-08-05 18:26:35 -04:00
Richard Acayan
3bb02196db core: button: allow dragging to a text-only key part 2024-08-05 18:26:35 -04:00
Richard Acayan
fc829a96c4 core: button: emit key presses as text when available 2024-08-05 18:26:35 -04:00
Richard Acayan
399ab9deba core: layout: set the spacebar text as whitespace
If the key value can emit text, it should put the text to be emitted in
the text field. It should not put any special symbol for the key label,
and it should instead be a special case in the display_label() method.
2024-08-05 18:26:35 -04:00
Richard Acayan
db2a8cdeab core: button: add keyboard method to insert text 2024-08-05 18:26:35 -04:00
Richard Acayan
8f7e9dfe7a core: button: update supported keys on startup 2024-08-05 18:26:35 -04:00
Richard Acayan
619b0232b5 wayland: update support for text insertion according to input method 2024-08-05 18:26:35 -04:00
Richard Acayan
c459405318 core: layout: store availability of text insertion 2024-08-05 18:26:35 -04:00
Richard Acayan
c152dc8468 core: layout: store keysym availability 2024-08-05 18:26:35 -04:00
Richard Acayan
adf71ed2c8 core: button: add supported keys querying to keyboard trait 2024-08-05 18:26:35 -04:00
Richard Acayan
d3a17813c0 wayland: keyboard: track input method done events 2024-08-05 18:26:35 -04:00
Richard Acayan
551381f0b6 core: button: inline accessor for modifier state 2024-08-05 18:26:35 -04:00
Richard Acayan
00e55c9566 core: layout: drop display_symbol function
The display_label function supersedes the old display_symbol function.
Drop the old one.
2024-08-05 18:26:17 -04:00
Richard Acayan
22a93d2efe core: button: latch modifier keys when another normal key is pressed 2024-07-31 17:46:28 -04:00
Richard Acayan
498caa149f core: layout: use uppercase label when pressing shift 2024-07-31 17:01:29 -04:00
Richard Acayan
b378240a38 wayland: ignore errors when reading socket
On Phosh, the EWOULDBLOCK error may be emitted when reading from the
Wayland socket, which is not fatal. Ignore errors encountered while
reading, as fatal errors would be emitted by other operations in the
main loop.
2024-07-30 17:27:44 -04:00