1
0
mirror of git://git.suckless.org/svkbd synced 2024-12-17 19:54:45 +00:00

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

This commit is contained in:
Maarten van Gompel 2021-06-13 22:27:59 +02:00 committed by Hiltjo Posthuma
parent 2306b8eb40
commit 2a84ae50f9
3 changed files with 24 additions and 12 deletions

View File

@ -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"
};

View File

@ -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 },
{ "-", "_", XK_minus, 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_slash, 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 },
{ "", 0, XK_BackSpace, 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 },

16
svkbd.c
View File

@ -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;