Hatari keyboard and keymap

A forum about the Hatari ST/STE/Falcon emulator - the current version is v2.3.0

Moderators: simonsunnyboy, thothy, Moderator Team

Post Reply
Faucon2001
Atari Super Hero
Atari Super Hero
Posts: 909
Joined: Sat Oct 26, 2013 11:19 pm
Location: France
Contact:

Hatari keyboard and keymap

Post by Faucon2001 »

I am trying to configure Hatari for my keyboard using the keymap file, but it's not satisfactory.
I am using a PC spanish keyboard, and many keys are not recognized.
Most of the keys can be configured, excepted a few important ones, especially accents.
I am seeing on the console the symbolic code for the key pressed, but can't attribute many key to an atari key. it doesn't work
Also some keys have the same symbolic code. For example ` ^ [ key and ' " { key have the same symbolic code 1073741824

Finally, I need to set different atari keys for normal, shift and Alt, and dead keys for ` ' ^ " and I don't see a way to do it.

Is there a way to fully configure each key of the keyboard, like Keyedit does in Mint?
Philippe

Firebee, Falcon CT60, STE, BeeKey, BeePi.
My photography http://phil-67.deviantart.com/
EasyAraMint, BeeKey and BeePi https://sites.google.com/site/beebox68k/
ThorstenOtto
Atari God
Atari God
Posts: 1648
Joined: Sun Aug 03, 2014 5:54 pm

Re: Hatari keyboard and keymap

Post by ThorstenOtto »

I think there is not much you can do about it. If the TOS you are using does not recognize the scancodes, then it won't help to configure Hatari to send them. Best thing that you can try is to use something like accent3 https://www.atari-forum.com/viewtopic.p ... 84#p420784
User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2433
Joined: Sun Jul 31, 2011 1:11 pm

Re: Hatari keyboard and keymap

Post by Eero Tamminen »

EmuTOS supports many different (builtin) keymaps, so that might be best thing to do testing with.

As to Hatari configuration, there are some helper tools to check what key codes libSDL provides to Hatari, and what they are inside the emulation:
https://git.tuxfamily.org/hatari/hatari ... sts/keymap
ThorstenOtto
Atari God
Atari God
Posts: 1648
Joined: Sun Aug 03, 2014 5:54 pm

Re: Hatari keyboard and keymap

Post by ThorstenOtto »

Btw, that keymapping is rather bogus with SDL2. The sym you get from the SDL for eg. an "y" on a german keyboard is 0x79, with is just the ascii code of y. But it is larger than KBD_MAX_SCANCODE (0x72) and thus cannot be remapped. Also,the tool only prints the hexadecimal value, while the parser only accepts decimal values. It would help to make the parser also accept hexadecimal values, by using strtol() instead of atoi().
Faucon2001
Atari Super Hero
Atari Super Hero
Posts: 909
Joined: Sat Oct 26, 2013 11:19 pm
Location: France
Contact:

Re: Hatari keyboard and keymap

Post by Faucon2001 »

I am testing my spanish keyboard with spanish TOS 2.06 in order to have most of the similar keys.
I have tried Accent3.prg and it works for one key : grave and circumflex accent ( sym 27 according to http://eerott.mbnet.fi/hatari/img/st-keymap.png)
I can map it to sym 26 to match my keyboard, but sym 40 has exactly the same SDL code of 1073741824, and this key on my PC keyboard is acute accent , which I need also.
Eero, I don't know how to build from source (sorry I just know GFA), but I have been using your ST-keymap and --trace keymap to find the symbolic SDL code, so I guess it's what your helper tool does.

How do you choose a builtin keymap with emutos?
Philippe

Firebee, Falcon CT60, STE, BeeKey, BeePi.
My photography http://phil-67.deviantart.com/
EasyAraMint, BeeKey and BeePi https://sites.google.com/site/beebox68k/
User avatar
sporniket
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 114
Joined: Fri Feb 16, 2018 5:39 pm

Re: Hatari keyboard and keymap

Post by sporniket »

Hi, on a french forum, I had described how to patch manually a ROM to get a bepo-ish layout : https://www.yaronet.com/topics/191967-t ... avier-bepo

Nowadays, I would write a small TSR program in auto folder to use Keytbl ( https://freemint.github.io/tos.hyp/en/x ... tml#Keytbl ) with the proper table (because I guess the area I patched was the default KEYTAB https://freemint.github.io/tos.hyp/en/x ... tml#KEYTAB structure)
Faucon2001
Atari Super Hero
Atari Super Hero
Posts: 909
Joined: Sat Oct 26, 2013 11:19 pm
Location: France
Contact:

Re: Hatari keyboard and keymap

Post by Faucon2001 »

Thanks sporkinet. Wow, this is a tedious work !
I would definitely prefer, as you suggested, a way to use Keytbl under plain TOS, as this works very well under mint and also I have an uncommon setup : I am a French guy using a Spanish keyboard and who prefers an English TOS ;-)
Philippe

Firebee, Falcon CT60, STE, BeeKey, BeePi.
My photography http://phil-67.deviantart.com/
EasyAraMint, BeeKey and BeePi https://sites.google.com/site/beebox68k/
ThorstenOtto
Atari God
Atari God
Posts: 1648
Joined: Sun Aug 03, 2014 5:54 pm

Re: Hatari keyboard and keymap

Post by ThorstenOtto »

Faucon2001 wrote: Fri Oct 08, 2021 11:46 am ( sym 27 according to http://eerott.mbnet.fi/hatari/img/st-keymap.png)
You can also use http://tho-otto.de/keyboards/ if that helps. Those keyboards are generated using the key table files from mint.
sym 40 has exactly the same SDL code of 1073741824
and this key on my PC keyboard is acute accent , which I need also.
If you get the same sym from SDL for different keys, then something seems to be wrong with SDL ;)
Eero, I don't know how to build from source (sorry I just know GFA)
Just run "make" in the tests/keymap directory. It is standalone, and you don't have to configure or build Hatari for this.

How do you choose a builtin keymap with emutos?
Except for the greek and russian versions of emutos, there is nothing you can choose. There is only one keyboard table compiled in, depending on the language version. The one for spanish is in https://github.com/emutos/emutos/blob/m ... /keyb_es.h and should be identical to the one used in freemint https://github.com/freemint/freemint/bl ... panish.src

Note that none of these define any deadkeys, although both emutos and mint support those. If you think that should be changed feel free to post any patches ;) Preferably as patch to the mint keyboard table file, since the new mktbl tool can be used to convert that to other formats.
ThorstenOtto
Atari God
Atari God
Posts: 1648
Joined: Sun Aug 03, 2014 5:54 pm

Re: Hatari keyboard and keymap

Post by ThorstenOtto »

Faucon2001 wrote: Fri Oct 08, 2021 1:31 pm using a Spanish keyboard and who prefers an English TOS ;-)
No wonder that you have problems ;) The english version of TOS has the either the uk or us layout builtin. I'm not sure whether that can easily be changed, since both settings are derived from the same Makefile/environment variable.
Faucon2001
Atari Super Hero
Atari Super Hero
Posts: 909
Joined: Sat Oct 26, 2013 11:19 pm
Location: France
Contact:

Re: Hatari keyboard and keymap

Post by Faucon2001 »

Well, I like complicated stuff ;-)
With the Spanish TOS it doesn’t work better, and the keys with the same symbolic code are still there.
I am surprised than there is not an easy way to setup a keyboard on Hatari.
Philippe

Firebee, Falcon CT60, STE, BeeKey, BeePi.
My photography http://phil-67.deviantart.com/
EasyAraMint, BeeKey and BeePi https://sites.google.com/site/beebox68k/
User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2433
Joined: Sun Jul 31, 2011 1:11 pm

Re: Hatari keyboard and keymap

Post by Eero Tamminen »

Faucon2001 wrote: Fri Oct 08, 2021 4:52 pm With the Spanish TOS it doesn’t work better, and the keys with the same symbolic code are still there.
I am surprised than there is not an easy way to setup a keyboard on Hatari.
There are multiple steps of interpretation that need to be done:
* OS kernel: Keyboard HW => OS scancode
* SDL2: OS scancode => SDL2 scancode / keycode
* Hatari: SDL2 scancode / keycode => ST scancode (inserted to emulated IKBD)
* TOS: ST scancode => character visible on screen

Info may be lost in any of these steps, if given conversion step does not support given scancode, but the main problem is TOS key mapping.

EmuTOS should support setting language and keyboard mapping separately, so that you can get Spanish keyboard layout with English language, but you may need to build your own EmuTOS image for that.
User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2433
Joined: Sun Jul 31, 2011 1:11 pm

Re: Hatari keyboard and keymap

Post by Eero Tamminen »

ThorstenOtto wrote: Fri Oct 08, 2021 11:36 am Btw, that keymapping is rather bogus with SDL2. The sym you get from the SDL for eg. an "y" on a german keyboard is 0x79, with is just the ascii code of y. But it is larger than KBD_MAX_SCANCODE (0x72) and thus cannot be remapped.
I sent a potential fix for that issue to the Hatari mailing list: https://listengine.tuxfamily.org/lists. ... reads.html

Testing of that would be appreciated.
ThorstenOtto wrote: Fri Oct 08, 2021 11:36 am Also,the tool only prints the hexadecimal value, while the parser only accepts decimal values. It would help to make the parser also accept hexadecimal values, by using strtol() instead of atoi().
I pushed a commit changing the tool to show both symbolic and scancode values, both in hex & decimal. But the keymap tracing is actually enough to debug the values (and Faucon2001 was already using that).
User avatar
Eero Tamminen
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2433
Joined: Sun Jul 31, 2011 1:11 pm

Re: Hatari keyboard and keymap

Post by Eero Tamminen »

Eero Tamminen wrote: Sat Oct 09, 2021 10:53 pm EmuTOS should support setting language and keyboard mapping separately, so that you can get Spanish keyboard layout with English language, but you may need to build your own EmuTOS image for that.
According to EmuTOS doc: https://raw.githubusercontent.com/emuto ... ountry.txt

And Hatari NVRAM info: https://git.tuxfamily.org/hatari/hatari ... on/nvram.c

With 512K version of EmuTOS, it should be enough to set NVRAM bytes 20 & 21, to specify language and keyboard layout. Only for the smaller EmuTOS variants you need to change sources to achieve that.
vinz6751
Atari User
Atari User
Posts: 37
Joined: Sat Nov 15, 2014 10:35 am
Location: France
Contact:

Re: Hatari keyboard and keymap

Post by vinz6751 »

Hello,

I had problems last year too with Hatari not handling correctly the French keyboard, for example { which requires shift alt. I improved it so you can map SDL keys with modifiers to Atari keys with modifiers. With this change, all keys on the French ST keyboard worked, I showed it in this (crappy) video: https://www.youtube.com/watch?v=4qWL23X77aI
I think the same would work with the Spanish keyboard, provided you wrote a correct mapping file (there is a new format for it).

That is in https://github.com/vinz6751/hatari/blob ... bd-support
but you'd have to build from sources because this hasn't been merged to the mainstream hatari.

Building from hatari and EmuTOS from sources is pretty easy on linux, a bit less straightforward on Windows.
Ping me if you're interested in trying that out !


Vinz
ThorstenOtto
Atari God
Atari God
Posts: 1648
Joined: Sun Aug 03, 2014 5:54 pm

Re: Hatari keyboard and keymap

Post by ThorstenOtto »

Building EmuTOS on windows (or macOS) is the same as on linux (provided you installed the correct compiler toolchain), because it does not need any third-party libraries. You only need bash & make for this (either cygwin, or msys2).
Faucon2001
Atari Super Hero
Atari Super Hero
Posts: 909
Joined: Sat Oct 26, 2013 11:19 pm
Location: France
Contact:

Re: Hatari keyboard and keymap

Post by Faucon2001 »

vinz6751 wrote: Sun Oct 10, 2021 7:47 am I had problems last year too with Hatari not handling correctly the French keyboard, for example { which requires shift alt. I improved it so you can map SDL keys with modifiers to Atari keys with modifiers. With this change, all keys on the French ST keyboard worked, I showed it in this (crappy) video: https://www.youtube.com/watch?v=4qWL23X77aI
I think the same would work with the Spanish keyboard, provided you wrote a correct mapping file (there is a new format for it).
Great !!! It sounds like what I need.
What is the new format for the keycap file? Is it explained with the sources ?
That is in https://github.com/vinz6751/hatari/blob ... bd-support
but you'd have to build from sources because this hasn't been merged to the mainstream hatari.
Building Hatari on Linux is not an issue, but the link seems to be dead.
Philippe

Firebee, Falcon CT60, STE, BeeKey, BeePi.
My photography http://phil-67.deviantart.com/
EasyAraMint, BeeKey and BeePi https://sites.google.com/site/beebox68k/
User avatar
sporniket
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 114
Joined: Fri Feb 16, 2018 5:39 pm

Re: Hatari keyboard and keymap

Post by sporniket »

Faucon2001 wrote: Sun Oct 10, 2021 3:28 pm
That is in https://github.com/vinz6751/hatari/blob ... bd-support
but you'd have to build from sources because this hasn't been merged to the mainstream hatari.
Building Hatari on Linux is not an issue, but the link seems to be dead.
replace 'blob' by 'tree' to get the branch : https://github.com/vinz6751/hatari/tree ... bd-support

there seems to be another branch on the same subject : https://github.com/vinz6751/hatari/tree ... b-support2

Now, I guess that you should look into the latest commits of each branch to grasp the interesting part.
vinz6751
Atari User
Atari User
Posts: 37
Joined: Sat Nov 15, 2014 10:35 am
Location: France
Contact:

Re: Hatari keyboard and keymap

Post by vinz6751 »

Sorry not sure why the link didn't work, I copied it from github.
Here's a better one.
https://github.com/vinz6751/hatari/tree ... b-support2

And look in doc/keymap-sample.txt for explanations on the format and
doc/fr/clavier-exemple.txt
for instructions in French, this is a keymap for French keyboards.
Faucon2001
Atari Super Hero
Atari Super Hero
Posts: 909
Joined: Sat Oct 26, 2013 11:19 pm
Location: France
Contact:

Re: Hatari keyboard and keymap

Post by Faucon2001 »

Thank you very much !! It works !
I spent quite some time to build the Keymap file, not an easy task, but now 100% of my keyboard is mapped.
The only grey area is about the dead keys. I have 4 dead keys on a Spanish keyboard ´¨`^ and accent3.prg recognise only `^¨. The acute accent is missing. Anyway, I have mapped AltGr E as é and I am done.

Could you merge your branch with the main one ? that's a big step forward for keyboard configuration.
Philippe

Firebee, Falcon CT60, STE, BeeKey, BeePi.
My photography http://phil-67.deviantart.com/
EasyAraMint, BeeKey and BeePi https://sites.google.com/site/beebox68k/
vinz6751
Atari User
Atari User
Posts: 37
Joined: Sat Nov 15, 2014 10:35 am
Location: France
Contact:

Re: Hatari keyboard and keymap

Post by vinz6751 »

Thank you, I'm glad it helped you :)
I can't merge this to the hatari repo, I have no rights to do so, I submitted the patch at the beginning of the year then lot interest when asked to salami slice it, but Eero has endeavoured to do it and is now working on it, making some refinements in the process that should make keymap files a bit friendlier. So chances are that it will be merged in hatari in the next few weeks or few months :)
Post Reply

Return to “Hatari”