Re: [hackers] [svkbd][PATCH] this patch fixes uppercase in armenian (and perhaps some other) layouts. svkbd was previously registering a key in one modification (xorg accepts up to 4 modifications). with this patch svkbd registers 2 modifications - upper and lower case. function tmp_remap changed in a way that if the key is not found in a current layout, it is temporary added to it. for cyrillic layout uppercase (when shift is pressed) letters were showing anyway, because those are somehow found (modified) by xorg. but for armenian layout that did not work. now works.

From: նորայր <norayr_AT_arnet.am>
Date: Wed, 13 Dec 2023 16:30:17 +0400

also no need to know armenian to test.
just run ./svkbd-mobile-intl and type lowercase and uppercase in armenian layout.

do that for the patched version and you'll see the difference.

for some reason on sxmo/postmarketos i have to restart the device in order to run a newer binary. though i think i checked that when i remove the keyboard with a gesture, the process gets killed. and if i replace the binary and get the keyboard with a gesture again, it should run the newer binary. but maybe something changed now, because last time i was testing it, i had to restart the device. this is irrelevant to svkbd, i just think of how you will test it, in case you will test it on sxmo/postmarketos the restart might be needed.

On Wed, 13 Dec 2023 16:21:04 +0400
նորայր <norayr_AT_arnet.am> wrote:

> ok let me try to explain this very simply.
> some time ago i have added armenian and dvorak layouts.
> i have noticed that in dvorak and all other layouts uppercase characters work.
> while you don't have to do any extra effort for that. let's say:
>
> ```
> { 0, 0, XK_a, 1 },
> { 0, 0, XK_o, 1 },
> { 0, 0, XK_e, 1 },
> { 0, 0, XK_u, 1 },
> { 0, 0, XK_i, 1 },
> { 0, 0, XK_d, 1 },
> ```
>
> notice that layout describes only the lowercase variant, and the uppercase works automagically.
>
> same with cyrillic:
>
> ```
> { "й", 0, XK_Cyrillic_shorti, 1 },
> { "ц", 0, XK_Cyrillic_tse, 1 },
> { "у", 0, XK_Cyrillic_u, 1 },
> { "к", 0, XK_Cyrillic_ka, 1 },
> { "е", 0, XK_Cyrillic_ie, 1 },
> ```
>
> one doesn't even have to specify the uppercase variant.
> my guess is that the conversion is done by Xorg automatically for some layouts. i don't know why and how.
>
> however this approach didn't work with armenian layout (i guess it won't work with many other layouts), so i had to specify both uppercase and lowercase variants:
>
> ```
> { "ճ", "Ճ", XK_Armenian_tche, 1 },
> { "փ", "Փ", XK_Armenian_pyur, 1 },
> { "բ", "Բ", XK_Armenian_ben, 1 },
> { "ս", "Ս", XK_Armenian_se, 1 },
> { "մ", "Մ", XK_Armenian_men, 1 },
> { "ո", "Ո", XK_Armenian_vo, 1 },
> { "ւ", "Ւ", XK_Armenian_vyun, 1 },
> ```
>
> though i have had specified the uppercase letters, they were painted on the keyboard, but didn't work.
>
> now with this patch (see the commit message for more details) uppercase letters work.
> my guess is this will fix the behaviour not only for armenian, but for many other layouts for which Xorg doesn't have a method to get the uppercase symbol automatically for some reason.
> my guess is that cyrillic and latin are for some reason handled differently by xorg than the majority of other character sets.
>
> and one more detail, though this commit fixes almost every letter in armenian layout, one thing still don't work. namely, this line:
> { "՝","՜", XK_Armenian_exclam, 1 },
>
> for some reason only the second character described in this line ("՜") gets printed whether the shift is pressed or not. i will try to understand why this doesn't work some other day.
>
> but the commit fixes everything. i have this fix for a year already and i need to recompile svkbd every time after update, and restart the device, so if this is applied, it will simplify my life a lot.
>
> so to stress it again: this is not only relevant to armenian layout.
>
>
>
>
> On Sun, 3 Dec 2023 21:48:09 +0100
> Hiltjo Posthuma <hiltjo_AT_codemadness.org> wrote:
>
> > On Sun, Dec 03, 2023 at 08:22:04PM +0400, norayr chilingarian wrote:
> > > ---
> > > svkbd.c | 11 ++++++++++-
> > > 1 file changed, 10 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/svkbd.c b/svkbd.c
> > > index e4dbd15..cce2463 100644
> > > --- a/svkbd.c
> > > +++ b/svkbd.c
> > > _AT_@ -481,9 +481,18 @@ press(Key *k, KeySym buttonmod)
> > > int
> > > tmp_remap(KeySym keysym)
> > > {
> > > - XChangeKeyboardMapping(dpy, tmp_keycode, 1, &keysym, 1);
> > > + /* map lower and upper case of keysym to the temporary keycode */
> > > + KeySym syms[2];
> > > + XConvertCase(keysym, &syms[0], &syms[1]);
> > > +
> > > + /* if keysym is capital letter then swap upper and lower case */
> > > + if (keysym == syms[1])
> > > + syms[1] = syms[0], syms[0] = keysym;
> > > +
> > > + XChangeKeyboardMapping(dpy, tmp_keycode, syms[0] == syms[1] ? 1 : 2, syms, 1);
> > > XSync(dpy, False);
> > >
> > > + printdbg("Temorary map keysym %ld (%ld, %ld) to keycode %d\n", keysym, syms[0], syms[1], tmp_keycode);
> > > return tmp_keycode;
> > > }
> > >
> > > --
> > > 2.41.0
> > >
> > >
> >
> > Thanks for the patch,
> >
> > I'm not a svkbd user right now and also not Armenian.
> >
> > Can anyone test this and report if it makes sense?
> >
> > Thanks,
> >
> > --
> > Kind regards,
> > Hiltjo
> >
>
>
> --
> There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies.
>
> -- C.A.R. Hoare
>


-- 
There are two ways of constructing a software design.  One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies.
-- C.A.R. Hoare

Received on Wed Dec 13 2023 - 13:30:17 CET

This archive was generated by hypermail 2.3.0 : Wed Dec 13 2023 - 13:36:33 CET