• Please review our updated Terms and Rules here

The quest for a small keyboard driver

davide78

Experienced Member
Joined
Oct 2, 2019
Messages
74
Location
Italy
I have this Amstrad PC5086 XT clone I thinker with. I am Italian, so I need to type accented letters from time to time, and thus to load an appropriate driver to support international keyboard layouts. PC-DOS keyb.com eats up 6K of precious memory, so I searched around for a more memory efficient solution. mKEYB by Tom Ehlert is a very small keyboard driver, with a resident size of 500-700 bytes, depending on the keyboard. Unfortunately, it requires a 80286 or better machine. Since the source code is GPL'ed, I modified it to work also on machines with an 8088 or 8086 CPU. The new code is available at https://github.com/davidebreso/mkeyb, and the executable is attached to this post, toghether with some incomplete documentation.

How it works​

mKEYB is so small because it relies on the BIOS to do most of the work. It should work on any machine where the BIOS keyboard routines uses INT 15,4F to allow for keyboard translation, and implements the INT 16,5 service (Keyboard buffer write). All the required functionalities are usually present in AT, PS/2 and later class machines. This is not the case for XT machines, where different BIOSes implement different subsets of the above functionalities. The current code works on my machine, an Amstrad PC5086 with an enhanced 101 keys keyboard. Consider it untested on anything else. I would like to continue working on it to improve compatiblity, but I don't have any other machine to test the driver. So I ask anyone that is interested to download the driver, test it and report back here. Suggestion on how to improve the code are also very welcome, I am anything but an expert on dos drivers.

How to use it​

Code:
mkeyb /?
gives you a help screen, and
Code:
mkeyb /l
lists all available keyboard layouts. Try first to run it with the layout code and no other switches, e.g.
Code:
mkeyb it
for italian. If everything works, congratulations! Your BIOS support all the required functionalities and you can enjoy your ~700 bytes driver. If not, see below for some hints.

The driver loads but the keyboard remains with the default US layout: your BIOS do not use INT 15,4F to allow for layout translation. Try with the /9 switch:
Code:
mkeyb it /9
This switch installs a new handler for INT9 (keyboard interrupt on XTs) that calls INT 15,4F to translate the layout. The handler should work on any machine
with a keyboard controller that is compatible with the 8255 PPI of the original IBM PC and XT: data buffer at port 60h and status register at port 61h. If your machine uses a keyboard controller that answers on different ports, the handler will most likely hang your keyboard.

The driver loads, some keys works but others do not (nothing happens when I press them): yout BIOS do not implement the INT 16,5 service to insert a new keystroke in the keyboard buffer. Try with the /G switch:
Code:
mkeyb it /G
This switch installs a new handler for INT 16 (keyboard services) with the required functionality. You may need to combine /G with /9:
Code:
mkeyb it /9 /G

Something else happens: please report back here, we may find a solution (or maybe not 😅 )

To uninstall the driver you can use
Code:
mkeyb /u
or
Code:
mkeyb us
(US keyboards do not need a driver)

Known limitations​

  • as remarked above, the INT 9 handler is written for controllers compatible with the 8255 PPI, and may have unpredictable results with non-standard keyboard controllers
  • the layouts are for 101/102 keys enhanced keyboards. They may not be accurate for 83 keys keyboard
  • there is no autodetect of the BIOS functionalites: you have to specify the /9 and/or /G switch if you need them
I am in contact with Tom Ehlert, the original author of mKEYB, and he gave me some ideas on how to autodetect the BIOS functionalities. I may implement autodetection at some point, when I have some free time to work on the code. For 83 keys layout and non-standard controllers I need help from other users: I don't have any other machine nor keyboard to test the driver. I did some experiments with PCem, but I don't know how reliable the results can be.
 

Attachments

  • mkeyb047.zip
    14.5 KB · Views: 2
Nice work.

Back in 1991 I used "KEYBIT Lite" with my first PC
8088/10MHz/Hercules Mono ... My C64 died and it was an ... upgrade!

I found the latest version here with source code included :

 
Thank you @noppa. I will take a look at the source code of keybit lite, there may be something useful to improve mKEYB
 
An updated version of mKEYB is released on github:


It adds autodetection of the BIOS functionalities, so the /9 and /G switches are not needed anymore. They are still available if autodetection fails.

Next item in the TODO list is to add layouts for XT style 83 keys keyboards.
 
Version 0.49 of mKEYB is released on github:


As you may know, PC keyboards came in two flavours: "standard" keyboards with 83 or 84 keys, common on XT class machines, and "enhanced" keyboards with 101 or 102 keys, common on AT, PS2 and later machines.

The new release of mKEYB supports both keyboard types. An enhanced keyboard layout is available for all languages. For Italian there is also a custom layout for the standard keyboard. mKEYB can autodetect the keyboard type and selects the appropriate keyboard layout, if available for the language. If the standard keyboard layout is not available for the selected language, mKEYB patches the enhanced keyboard layout to use Ctrl+Alt instead of AltGr (not available on standard keyboards). This pached layout may not be completely accurate.

The /E switch forces an enhanced keyboard layout, while /S forces a standard keyboard layout.
 
Version 0.50 is out


This release adds the Turkish Q and F layouts to the list of available keyboard. I would like to thank github users @fritzmueller @cardpuncher and @bitigchi that contributed and verified the layouts.

Other improvements are a better support for the AltGr+Shift key modifier, and improved uninstall and autodetect routines. The executable is compressed with UPX, a modern and open-source compressor for executables.
 
Version 0.52 of mKEYB is out on github:


This release is built with Open Watcom v2. Source code can be compiled with either Borland's BCC/TASM (on a DOS machine or emulator), or with Open Watcom's WCC/WASM, on modern systems. With Open Watcom you get a bigger executable but a smaller resident memory footprint.

New functionalities:
  • German 84 keys layouts, tweaks and cleanups thanks to @Korkman:
    • Add: german 84-key layout (gr and gr2)
    • Change: section sign now cp850 compliant
    • Add: superscript 2 and 3 for enhanced layout
    • Bonus key: Ctrl-Alt-4: cp437 section sign (backup for affected users)
    • Bonus key: Ctrl-Alt-Dash = Pipe, unavailable on 84-key german layout
  • Option /M to install the driver in low memory
Bugfix: fix incorrect behaviour of CTRL key in QWERTZ and AZERTY layouts
 
Back
Top