Page 1 of 1
More exposed keyboard interface
Posted: Sat Oct 17, 2020 5:03 pm
by kliepatsch
Currently, the input stream from the keyboard is simplified by the KERNAL in a way that is optimized for text-based applications. By that I mean each keypress is only registered once (unless the key is held down for a while). This is nice for many applications.
However, for games and other interactive cases (e.g. using the keyboard as a musical keyboard) it would be really nice to access data on which keys are actually held down (at the same time). Because I currently do not find a way to do this, I am asking if this could be made possible in the future? As I understand it, the routines that do the keyboard handling, are currently located entirely in ROM and not available for modification without replacing the ROM.
I understand that for most games, a controller with arrow keys seems sufficient. But I suspect that opening the keyboard interface up would greatly benefit the X16, since a broader range of applications will be made possible.
All the best, Carl
More exposed keyboard interface
Posted: Mon Nov 09, 2020 12:23 pm
by izb
Bumping this with a related query...
Does the keyboard scanning work in the same way as the C64? If I wanted to write my own keyboard scanning routine, would it have the same rollover issues as the C64?.. or does the X16 ROM do things its own special way?
More exposed keyboard interface
Posted: Thu Nov 12, 2020 3:32 pm
by paulscottrobson
Yes and no. I think it fakes it. The keyboard is a standard PS/2 one ; a PS/2 keyboard (or a USB with an adaptor) sends a stream of serial data most of which is 'this key up' 'that key down' messages. So you can take those and build a grid like on a C64 regarding which keys are pressed and which are not. That grid should be accurate, and not have faux keys that are caused by multiple keys allowing paths through because there aren't diodes across the keys.
To get a definitive answer you'd have to look at the ROM code.
More exposed keyboard interface
Posted: Thu Nov 12, 2020 5:37 pm
by TomXP411
On 11/9/2020 at 4:23 AM, izb said:
Bumping this with a related query...
Does the keyboard scanning work in the same way as the C64? If I wanted to write my own keyboard scanning routine, would it have the same rollover issues as the C64?.. or does the X16 ROM do things its own special way?
No. This computer uses a PS/2 keyboard, so keyboard scanning is nothing like the 64. It’s essentially the same as the keyboard handling in DOS.
PS/2 is event based, rather than state based, so you need to read the PS/2 bus as the data comes in. The KERNAL stashes the key presses in the buffer, but you could theoretically place them in a state table that records the up/down state of each key.
More exposed keyboard interface
Posted: Sat Aug 07, 2021 9:27 am
by kliepatsch
As I understand, this request has been addressed, according to the programmer's reference guide:
https://github.com/commanderx16/x16-docs/blob/master/Commander X16 Programmer's Reference Guide.md#custom-keyboard-scan-code-handler I am, however, uncertain as to which emulator version this applies to. I'd suspect the not yet released R39. In a quick test, I couldn't get the example to run on my official R38 emulator
@Stefan ?
More exposed keyboard interface
Posted: Sat Aug 07, 2021 10:15 am
by Stefan
56 minutes ago, kliepatsch said:
As I understand, this request has been addressed, according to the programmer's reference guide:
https://github.com/commanderx16/x16-docs/blob/master/Commander X16 Programmer's Reference Guide.md#custom-keyboard-scan-code-handler I am, however, uncertain as to which emulator version this applies to. I'd suspect the not yet released R39. In a quick test, I couldn't get the example to run on my official R38 emulator
That function is only supported in the Kernal master branch on Github, what is expected to become R39.
BTW: I'm using a custom key handler in the X16 Edit pre-R39 version. It adds support for the END and DELETE keys and also the numerical keypad keys. That works very well, I would say. As you may see, the key handler is similar to a custom interrupt handler.