~mil/sxmo-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
4 3

[PATCH svkbd] adding dead spacing between keys to prevent misclicks and adapting keyboard layout to a less rigid grid (all aimed to reduce typos)

Details
Message ID
<20210608163020.1703080-1-proycon@anaproy.nl>
DKIM signature
missing
Download raw message
Patch: +24 -12
We had a discussion on IRC about the need to improve the keyboard layout
so we have less misclicks and typos. This is a first attempt at a less
rigid square grid, more like key placement on a real keyboard (and other
virtual keyboards). This first attempt does not lose any keys (in fact,
we gain one).

One important new function is dead spacing between the keys.  Also, the
space bar is bigger again.

See a screenshot: https://download.anaproy.nl/svkbd0.3.1.png

This patch is applied in the dev0.3.1 branch of
https://git.sr.ht/~proycon/svkbd/ , once we have feedback and processed
comments we can take it upstream to suckless.

---
 config.def.h         |  2 ++
 layout.mobile-intl.h | 18 ++++++++++--------
 svkbd.c              | 16 ++++++++++++----
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/config.def.h b/config.def.h
index 7b0025d..21e9f49 100644
--- a/config.def.h
+++ b/config.def.h
@@ -4,6 +4,8 @@ static double overlay_delay = 1.0; //in seconds
static double repeat_delay = 0.75; //in seconds, will not work on keys with overlays
static int scan_rate = 50; //scan rate in microseconds, affects key repetition rate
static int heightfactor = 14; //one row of keys takes up 1/x of the screen height
static int xspacing = 3;
static int yspacing = 3;
static const char *defaultfonts[] = {
	"DejaVu Sans:bold:size=22"
};
diff --git a/layout.mobile-intl.h b/layout.mobile-intl.h
index 780e6c9..326de05 100644
--- a/layout.mobile-intl.h
+++ b/layout.mobile-intl.h
@@ -1,4 +1,4 @@
#define KEYS 55
#define KEYS 57

static Key keys_en[KEYS] = {
	{ "Esc", "", XK_Escape, 1 },
@@ -12,9 +12,11 @@ static Key keys_en[KEYS] = {
	{ "8", "*", XK_8, 1 },
	{ "9", "(", XK_9, 1 },
	{ "0", ")", XK_0, 1 },
	{ "⌫", 0, XK_BackSpace, 1 },

	{ 0 }, /* New row */

	{ "↹", 0, XK_Tab, 0.5 },
	{ 0, 0, XK_q, 1 },
	{ 0, 0, XK_w, 1 },
	{ 0, 0, XK_e, 1 },
@@ -25,10 +27,11 @@ static Key keys_en[KEYS] = {
	{ 0, 0, XK_i, 1 },
	{ 0, 0, XK_o, 1 },
	{ 0, 0, XK_p, 1 },
	{ "'", "\"", XK_apostrophe, 1 },
	{ "-", "_", XK_minus, 1 },

	{ 0 }, /* New row */

	{ "^", 0, XK_Control_L, 1 },
	{ 0, 0, XK_a, 1 },
	{ 0, 0, XK_s, 1 },
	{ 0, 0, XK_d, 1 },
@@ -38,11 +41,12 @@ static Key keys_en[KEYS] = {
	{ 0, 0, XK_j, 1 },
	{ 0, 0, XK_k, 1 },
	{ 0, 0, XK_l, 1 },
	{ "/", "?", XK_slash, 1 },
	{ "Tab", 0, XK_Tab, 1 },
	{ ";", ":", XK_colon, 1 },
	{ "'", "\"", XK_apostrophe, 1 },

	{ 0 }, /* New row */

	{ "⇧", 0, XK_Shift_L, 1.5 },
	{ 0, 0, XK_z, 1 },
	{ 0, 0, XK_x, 1 },
	{ 0, 0, XK_c, 1 },
@@ -52,14 +56,12 @@ static Key keys_en[KEYS] = {
	{ 0, 0, XK_m, 1 },
	{ ",", "<", XK_comma, 1 },
	{ ".", ">", XK_period, 1 },
	{ "⌫Bksp", 0, XK_BackSpace, 2 },
	{ "/", "?", XK_slash, 1 },

	{ 0 }, /* New row */
	{ "↺", 0, XK_Cancel, 1},
	{ "Shift", 0, XK_Shift_L, 2 },
	{ "Ctrl", 0, XK_Control_L, 1 },
	{ "Alt", 0, XK_Alt_L, 1 },
	{ "", 0, XK_space, 2 },
	{ "", 0, XK_space, 4 },
	{ "↓", 0, XK_Down, 1 },
	{ "↑", 0, XK_Up, 1 },
	{ "↲ Enter", 0, XK_Return, 2 },
diff --git a/svkbd.c b/svkbd.c
index 0ad1836..9d85b52 100644
--- a/svkbd.c
+++ b/svkbd.c
@@ -47,7 +47,7 @@ typedef struct {
	char *label;
	char *label2;
	KeySym keysym;
	unsigned int width;
	double width;
	KeySym modifier;
	int x, y, w, h;
	Bool pressed;
@@ -307,11 +307,16 @@ void
drawkeyboard(void)
{
	int i;
	int row = 0;

	drw_setscheme(drw, scheme[SchemeNorm]);
	drw_rect(drw, 0, 0, ww, wh, 1, 1);
	drw_map(drw, win, 0, 0, ww, wh);
	for (i = 0; i < numkeys; i++) {
		if (keys[i].keysym != 0)
			drawkey(&keys[i]);
	}
	drw_map(drw, win, 0, 0, ww, wh);
}

void
@@ -946,18 +951,21 @@ void
updatekeys(void)
{
	int i, j;
	int x = 0, y = 0, h, base, r = rows;
	double base;
	int x = 0, y = 0, h, r = rows;

	h = (wh - 1) / rows;
	for (i = 0; i < numkeys; i++, r--) {
		for (j = i, base = 0; j < numkeys && keys[j].keysym != 0; j++)
			base += keys[j].width;
		for (x = 0; i < numkeys && keys[i].keysym != 0; i++) {
			keys[i].x = x;
			keys[i].y = y;
			keys[i].x = x + xspacing;
			keys[i].y = y + yspacing;
			keys[i].w = keys[i].width * ww / base;
			keys[i].h = r == 1 ? wh - y - 1 : h;
			x += keys[i].w;
			keys[i].w = keys[i].w - (xspacing * 2);
			keys[i].h = keys[i].h - (yspacing * 2);
		}
		if (base != 0)
			keys[i - 1].w = ww - 1 - keys[i - 1].x;
--
2.32.0
Details
Message ID
<20210608192127.GA21135@mail.hallyn.com>
In-Reply-To
<20210608163020.1703080-1-proycon@anaproy.nl> (view parent)
DKIM signature
missing
Download raw message
That looks nice.  Yes the too rigid grid felt like it was making me
miss keys.  : on the main page is a big plus too.

On Tue, Jun 08, 2021 at 06:30:21PM +0200, Maarten van Gompel wrote:
> We had a discussion on IRC about the need to improve the keyboard layout
> so we have less misclicks and typos. This is a first attempt at a less
> rigid square grid, more like key placement on a real keyboard (and other
> virtual keyboards). This first attempt does not lose any keys (in fact,
> we gain one).
> 
> One important new function is dead spacing between the keys.  Also, the
> space bar is bigger again.
> 
> See a screenshot: https://download.anaproy.nl/svkbd0.3.1.png
> 
> This patch is applied in the dev0.3.1 branch of
> https://git.sr.ht/~proycon/svkbd/ , once we have feedback and processed
> comments we can take it upstream to suckless.
> 
> ---
>  config.def.h         |  2 ++
>  layout.mobile-intl.h | 18 ++++++++++--------
>  svkbd.c              | 16 ++++++++++++----
>  3 files changed, 24 insertions(+), 12 deletions(-)
> 
> diff --git a/config.def.h b/config.def.h
> index 7b0025d..21e9f49 100644
> --- a/config.def.h
> +++ b/config.def.h
> @@ -4,6 +4,8 @@ static double overlay_delay = 1.0; //in seconds
>  static double repeat_delay = 0.75; //in seconds, will not work on keys with overlays
>  static int scan_rate = 50; //scan rate in microseconds, affects key repetition rate
>  static int heightfactor = 14; //one row of keys takes up 1/x of the screen height
> +static int xspacing = 3;
> +static int yspacing = 3;
>  static const char *defaultfonts[] = {
>  	"DejaVu Sans:bold:size=22"
>  };
> diff --git a/layout.mobile-intl.h b/layout.mobile-intl.h
> index 780e6c9..326de05 100644
> --- a/layout.mobile-intl.h
> +++ b/layout.mobile-intl.h
> @@ -1,4 +1,4 @@
> -#define KEYS 55
> +#define KEYS 57
> 
>  static Key keys_en[KEYS] = {
>  	{ "Esc", "", XK_Escape, 1 },
> @@ -12,9 +12,11 @@ static Key keys_en[KEYS] = {
>  	{ "8", "*", XK_8, 1 },
>  	{ "9", "(", XK_9, 1 },
>  	{ "0", ")", XK_0, 1 },
> +	{ "⌫", 0, XK_BackSpace, 1 },
> 
>  	{ 0 }, /* New row */
> 
> +	{ "↹", 0, XK_Tab, 0.5 },
>  	{ 0, 0, XK_q, 1 },
>  	{ 0, 0, XK_w, 1 },
>  	{ 0, 0, XK_e, 1 },
> @@ -25,10 +27,11 @@ static Key keys_en[KEYS] = {
>  	{ 0, 0, XK_i, 1 },
>  	{ 0, 0, XK_o, 1 },
>  	{ 0, 0, XK_p, 1 },
> -	{ "'", "\"", XK_apostrophe, 1 },
> +	{ "-", "_", XK_minus, 1 },
> 
>  	{ 0 }, /* New row */
> 
> +	{ "^", 0, XK_Control_L, 1 },
>  	{ 0, 0, XK_a, 1 },
>  	{ 0, 0, XK_s, 1 },
>  	{ 0, 0, XK_d, 1 },
> @@ -38,11 +41,12 @@ static Key keys_en[KEYS] = {
>  	{ 0, 0, XK_j, 1 },
>  	{ 0, 0, XK_k, 1 },
>  	{ 0, 0, XK_l, 1 },
> -	{ "/", "?", XK_slash, 1 },
> -	{ "Tab", 0, XK_Tab, 1 },
> +	{ ";", ":", XK_colon, 1 },
> +	{ "'", "\"", XK_apostrophe, 1 },
> 
>  	{ 0 }, /* New row */
> 
> +	{ "⇧", 0, XK_Shift_L, 1.5 },
>  	{ 0, 0, XK_z, 1 },
>  	{ 0, 0, XK_x, 1 },
>  	{ 0, 0, XK_c, 1 },
> @@ -52,14 +56,12 @@ static Key keys_en[KEYS] = {
>  	{ 0, 0, XK_m, 1 },
>  	{ ",", "<", XK_comma, 1 },
>  	{ ".", ">", XK_period, 1 },
> -	{ "⌫Bksp", 0, XK_BackSpace, 2 },
> +	{ "/", "?", XK_slash, 1 },
> 
>  	{ 0 }, /* New row */
>  	{ "↺", 0, XK_Cancel, 1},
> -	{ "Shift", 0, XK_Shift_L, 2 },
> -	{ "Ctrl", 0, XK_Control_L, 1 },
>  	{ "Alt", 0, XK_Alt_L, 1 },
> -	{ "", 0, XK_space, 2 },
> +	{ "", 0, XK_space, 4 },
>  	{ "↓", 0, XK_Down, 1 },
>  	{ "↑", 0, XK_Up, 1 },
>  	{ "↲ Enter", 0, XK_Return, 2 },
> diff --git a/svkbd.c b/svkbd.c
> index 0ad1836..9d85b52 100644
> --- a/svkbd.c
> +++ b/svkbd.c
> @@ -47,7 +47,7 @@ typedef struct {
>  	char *label;
>  	char *label2;
>  	KeySym keysym;
> -	unsigned int width;
> +	double width;
>  	KeySym modifier;
>  	int x, y, w, h;
>  	Bool pressed;
> @@ -307,11 +307,16 @@ void
>  drawkeyboard(void)
>  {
>  	int i;
> +	int row = 0;
> 
> +	drw_setscheme(drw, scheme[SchemeNorm]);
> +	drw_rect(drw, 0, 0, ww, wh, 1, 1);
> +	drw_map(drw, win, 0, 0, ww, wh);
>  	for (i = 0; i < numkeys; i++) {
>  		if (keys[i].keysym != 0)
>  			drawkey(&keys[i]);
>  	}
> +	drw_map(drw, win, 0, 0, ww, wh);
>  }
> 
>  void
> @@ -946,18 +951,21 @@ void
>  updatekeys(void)
>  {
>  	int i, j;
> -	int x = 0, y = 0, h, base, r = rows;
> +	double base;
> +	int x = 0, y = 0, h, r = rows;
> 
>  	h = (wh - 1) / rows;
>  	for (i = 0; i < numkeys; i++, r--) {
>  		for (j = i, base = 0; j < numkeys && keys[j].keysym != 0; j++)
>  			base += keys[j].width;
>  		for (x = 0; i < numkeys && keys[i].keysym != 0; i++) {
> -			keys[i].x = x;
> -			keys[i].y = y;
> +			keys[i].x = x + xspacing;
> +			keys[i].y = y + yspacing;
>  			keys[i].w = keys[i].width * ww / base;
>  			keys[i].h = r == 1 ? wh - y - 1 : h;
>  			x += keys[i].w;
> +			keys[i].w = keys[i].w - (xspacing * 2);
> +			keys[i].h = keys[i].h - (yspacing * 2);
>  		}
>  		if (base != 0)
>  			keys[i - 1].w = ww - 1 - keys[i - 1].x;
> --
> 2.32.0
Anjandev Momi
Details
Message ID
<87k0n413rw.fsf@mail.utoronto.ca>
In-Reply-To
<20210608163020.1703080-1-proycon@anaproy.nl> (view parent)
DKIM signature
pass
Download raw message
I just tried out the dev0.3.1 branch and the keyboard is muuuuuch
better. I am mistyping a lot less and typing alot faster. I think we
should include this in the 1.5.0 release if that's ok with you proycon.

Cheers!
Anjandev Momi
--
w:] www.momi.ca
pgp:] https://momi.ca/publickey.txt
Details
Message ID
<20210608211431.sritvbngi3wf72vl@worker.anaproy.lxd>
In-Reply-To
<87k0n413rw.fsf@mail.utoronto.ca> (view parent)
DKIM signature
missing
Download raw message
On 21-06-08 04:48, Anjandev Momi wrote:
> I just tried out the dev0.3.1 branch and the keyboard is muuuuuch
> better. I am mistyping a lot less and typing alot faster. I think we
> should include this in the 1.5.0 release if that's ok with you proycon.

Yes, agreed, let's test it for a bit, possibly augment where necessary,
and I'll take it upstream to suckless at the end of the of the week?

--

Maarten van Gompel (proycon)
https://proycon.anaproy.nl
Details
Message ID
<20210613203204.zyuwhdcqncle5zhu@worker.anaproy.lxd>
In-Reply-To
<20210608192127.GA21135@mail.hallyn.com> (view parent)
DKIM signature
missing
Download raw message
Thanks for the feedback, I submitted it upstream to suckless now, pending review there..

--

Maarten van Gompel (proycon)
https://proycon.anaproy.nl
Reply to thread Export thread (mbox)