Different to the emulated keyboard mode, the natural keyboard mode tries to minimize the differences of key mappings between the host computer and the emulated TI system.
Selecting the natural mode
Apply this setting in mame.ini:
Alternatively, you can add a command line switch:
mame ti99_4a -natural ...
You will notice that the characters in the TI emulation actually match those on your keyboard. No more searching!
There are some points to consider, though. To put it short, I never use the natural mode, it is unusable.
How does it work?
In the emulated mode, the keyboard is an arrangement of input switches; it is completetly left to the emulated system which keystroke delivers which character. In fact, the TI keyboard is technically a switch matrix, and the keys are polled by activating a row and then listening which column indicates a pressed key. That way, we can also sense when CTRL, FCTN, SHIFT or AlphaLock are pressed.
In this "natural" mode, MAME gets the character from the host keyboard driver after it went through all mappings on the PC side, in particular, language-based keyboard arrangements. The host keyboard driver, for example, delivers "5", "%", or "½" as a character (earlier ASCII, nowadays Unicode), depending on whether you pressed that key alone, with Shift, or with AltGr. This character is read by MAME, but in order to make the percent sign appear in the emulation, it must pretend that the emulated keyboard had a pressed 5 and a pressed Shift key.
This is done in the emulation using a lookup table. On my keyboard (QWERTZ), the hash sign (#) is left from the return key, together with the single quote ('). So when I type hash, this will be found in the table row of ("3", "#", "F3"). This means that when a "3" is found, it is that key without modifier (Shift or FCTN), when a "#" is found, it is that key with Shift, and when a "F3" is found, it is that key with FCTN. You may remember that FCTN-3 is ERASE, and this means the ERASE key sequence is triggered when you press the F3 key. In fact, all FCTN-n keys are mapped to Fn (1..10) on the PC keyboard with the natural mode.
What happens when we type the ½ character (AltGr-5)? Or the ß on the German keyboard? Those characters are not part of the TI character set, so they could be just ignored. This would, however, mean that you find some keys that seem to be dead, while others are working. The MAME developers decided to replace the unknown character by another character or even a character sequence.
- © -> (C) (three characters)
- ß -> ss
- æ -> ae
- ½ -> 1/2
Isn't this the solution?
Great - this means that we can translate those PC keys, and we'll get the matching key sequences in MAME? So this is the solution?
It's not, #1
You may have noticed that the natural keyboard feels "laggy"; characters appear after you typed them.
In the ½ case, we saw that instead of one character, three separate characters are sent into the emulation. And this raises another concern: Will the TI be able to process them in time? How fast should this sequence be sent?
Hence, the characters are first posted into a queue, and then read from that queue in a predefined rate (50 ms interval, i.e. 20 characters/second). The Enter key is even slower, read after 200ms. You cannot speed up this rate because the natural keyboard is a general part of the MAME framework and not TI-specific. It must allow for much slower systems to safely read the keys.
It is simply impossible to play a game that requires fast reactions on the keyboard if all your inputs are queued and read by a static rate. If you don't believe it, try to play "TI Invaders" with the natural keyboard.
It's not, #2
Since MAME gets the translated keystrokes from the PC keyboard driver as a sequence of characters, we cannot sense keystrokes that do not represent some character. For example, the modifier keys (Shift, Ctrl, Alt) do not produce a character by themselves. Thus, they cannot be sensed by the natural keyboard - there is just nothing coming in. Programs in the emulated TI that scan the keyboard for those keys will simply not work.
Even worse, the PC does not define characters for Ctrl combinations, e.g. for Ctrl-A. Again, when you press Ctrl-A, the natural keyboard does not receive any character, so it cannot translate it for the emulated TI. None of the Ctrl-x combinations work with the natural keyboard.
The AlphaLock issue
The natural mode has its own version of the AlphaLock issue: AlphaLock (in the emulation, not ShiftLock) must be in the release state when starting the emulation. The reason is that the Alpha Lock state cannot be changed in natural keyboard mode. Instead, the case is controlled by the PC keyboard and its Caps Lock state. If Alpha Lock is on (from the last emulation run with emulated keyboard), all characters appear as upper case, regardless of the Caps Lock setting.
Unless you plan to write a lot of text with no special characters, and no application of Ctrl sequences, do not use the natural keyboard. Even if it seems to be the right thing at first sight - you can use your keyboard and immediately find the proper keys -, it will give you more headaches than you'd expect. Learning to type blindly on the emulated keyboard will quickly prove to be the easier and safer way.