QL Keyboard to PS/2

Nagging hardware related question? Post here!
User avatar
Peter
QL Wafer Drive
Posts: 1987
Joined: Sat Jan 22, 2011 8:47 am

Re: QL Keyboard to PS/2

Post by Peter »

lostcarpark wrote:There are ways that source code can be common across multiple microcontrollers, so perhaps code could be shared even if boards can't be.
Yes in theory, but my experience is that it won't happen in practice as it costs too much time.
I was also tempted myself to use a different controller than Stephan, but decided for his one. Makes collaboration easier and is more fun in the end.


Maskenlos
Over Heated PSU
Posts: 140
Joined: Sat Nov 03, 2018 12:14 pm

Re: QL Keyboard to PS/2

Post by Maskenlos »

Dear Lostcarpark,

thanks for your interest in this small project. As you have already and QL to USB converter programmed it should not be to difficult. The Matrix scanning routine should be running already, all you need is the PS/2 scan code table and the PS/2 library.

PS/2 Scan code table are all round in the net. Should be rather easy to find.

The PS/2 library I use in this project is public domain and can be find here: https://github.com/Harvie/ps2dev/blob/m ... c/ps2dev.h

I am pretty sure there are more PS/2 libraries out there and probably there are better ones as well. But for my first attempts I used this one and it seems to be OK.

Sorry for not being ready to share my code. I still want to make some improvements, e.g. the missing space function when pressing two arrow keys together. As mentioned earlier in this thread I will share the code with the community soon or later. I guess more soon.

Cheers,

Stephan


User avatar
lostcarpark
ROM Dongle
Posts: 25
Joined: Thu Feb 19, 2015 6:08 pm
Contact:

Re: QL Keyboard to PS/2

Post by lostcarpark »

Maskenlos wrote:As you have already and QL to USB converter programmed it should not be to difficult. The Matrix scanning routine should be running already, all you need is the PS/2 scan code table and the PS/2 library.
Yes, I'm pretty happy with my QL key grid scanning. I would like to make it more modular, and separate the USB sending logic, so a PS/2 module can be added alongside without everything being too entangled.
Maskenlos wrote:PS/2 Scan code table are all round in the net. Should be rather easy to find.
Yes, I've found plenty of detail on that, and I've a fairly good picture of the signals that are sent at this point.
Maskenlos wrote:The PS/2 library I use in this project is public domain and can be find here: https://github.com/Harvie/ps2dev/blob/m ... c/ps2dev.h
That's actually really useful. I was looking at writing my own library, but if there's one available I can use it could save a ton of time.


Maskenlos
Over Heated PSU
Posts: 140
Joined: Sat Nov 03, 2018 12:14 pm

Re: QL Keyboard to PS/2

Post by Maskenlos »

Hi all,

as announced kindly find attached the schematics and the *.ino.hex files to directly load into the Atmega 328P. Two versions are available, with and w/o boot loader. As I never used the version with boot loader would be happy if someone conforms it working.
So far only German keyboard layout, sorry, UK will follow soon. but do not expect it during this weekend.

Any question or support needed? Post here!

Note: PC zip-File

Best regards,

Stephan
Attachments
Ql2PS2v1.zip
(39.38 KiB) Downloaded 79 times


User avatar
Peter
QL Wafer Drive
Posts: 1987
Joined: Sat Jan 22, 2011 8:47 am

Re: QL Keyboard to PS/2

Post by Peter »

Hi Stephan,

many thanks for the update. I have successfully tested it with my new QL baseboard also. Appears to work fine under SMSQ/E and Minerva. Just no autorepeat under QDOS Classic. Most likely due to leaving the autorepeat function to the OS itself. This is a minor issue.

Great job! Thanks for allowing me to use your matrix keyboard software for the new QL mainboard. Other microcontrollers may be more "in style", but I like the philosophy of a little 8 bit microcontroller as coprocessor for the 68K CPU. This is much more aligned with the QL philosophy than a "coprocessor" which is far superior to the main CPU.

Peter


Derek_Stewart
Font of All Knowledge
Posts: 3957
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: QL Keyboard to PS/2

Post by Derek_Stewart »

Hi,

Since both SMSQ/E and Minerva support different Language options, could the language selection not be left to the operating system?


Regards,

Derek
Maskenlos
Over Heated PSU
Posts: 140
Joined: Sat Nov 03, 2018 12:14 pm

Re: QL Keyboard to PS/2

Post by Maskenlos »

Hi,

this should be possible but need adaption of the operating system. The fundamental problem is that there are keys which show different characters in normal and extended mode. e.g.

UK QL has a key with "Pound" and "~" on it were a PS/2 Keyboard as no similar key. This needs special handling and translation of PS/2 scan codes.

BTW: I finished the UK Keyboard code for the adapter and shared already to some community members for testing purpose. So it ready for Peters baseboard or for those how only want to build such an adapter to implement the Q68 to a QL housing. Joystick support works also well! But I guess there is only very limited interest.

Stephan


Derek_Stewart
Font of All Knowledge
Posts: 3957
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: QL Keyboard to PS/2

Post by Derek_Stewart »

Hi,

I little silly question, if the QL Base is flashed with the German keyboard layout and the operating is SMSQ/E and the operating system keyboard and language is changed to another language with: LANG_USE and KBD_TABLE commands, to something like French, how does the QL Base react?


Regards,

Derek
User avatar
Peter
QL Wafer Drive
Posts: 1987
Joined: Sat Jan 22, 2011 8:47 am

Re: QL Keyboard to PS/2

Post by Peter »

My hope would be, that maybe some European keyboards are closer to the German one in this regard than the British.
But that is just hoping. Could be that a few keys still need special treatment.

By the way, QLbase and Stephans stand-alone circuit are almost identical. The only difference is an additional jumper on QLbase which could be used to distinguish two countries (but not more) which is currently not supported. And the LED, which I forgot to include on the small converter PCB but not the QLbase board.


Maskenlos
Over Heated PSU
Posts: 140
Joined: Sat Nov 03, 2018 12:14 pm

Re: QL Keyboard to PS/2

Post by Maskenlos »

if the QL Base is flashed with the German keyboard layout and the operating is SMSQ/E and the operating system keyboard and language is changed to another language with: LANG_USE and KBD_TABLE commands, to something like French, how does the QL Base react?
Most of the keys will work as expected some will not. They main reason is the difference between QL Keyboard layout and PS/2 Keyboard layout. Lets make an example: On the German QL Keyboard you have on a single Key "\" and "^". Where as on a PS/2 Keyboard these are 2 different keys. To generate these characters a PS/2 Keyboard will do the following for "^"

Send 0x0E to make = Press,
Send 0xF0, 0x0E to break the key = release

Very simple. But on the QL Keyboard you press shift and the "\" "^" Key you have to first "break" the shift by send
0xF0, 0x12
and then send the code for "^".

Even worse with the "\" what you have to do, here in decimal, directly from the source code:

keyboard.write(224); // send "up"
keyboard.write(17); // send "ALT" - up + ALT = Make "ALT GR" = (E011)
keyboard.write(78); // send "ß"
keyboard.write(240); // send break
keyboard.write(78); // send "ß"
keyboard.write(224); // send "up"
keyboard.write(240); // send break
keyboard.write(17); // send "ALT" Break ALT - GR = (E0F011)

German Keyboard is easy in this manner, it has only one key which needs special attention. UK Keyboard already 5. I have no idea how it is with the other keyboards. If there is a need of other drivers, I am willing to adapt them.


Hope this helps to better understand.

Stephan


Post Reply