More exposed keyboard interface

If you have feature requests, this is the place to post them. Please note your idea may already be something we have already discussed and decided against, or something we are working on privately, and we cannot be held responsible for any similarities in such instance. Whilst we cannot respond to every suggestion, your idea will be read and responded to where possible. Thank you for your input!
Post Reply
User avatar
kliepatsch
Posts: 247
Joined: Thu Oct 08, 2020 9:54 pm

More exposed keyboard interface

Post 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

izb
Posts: 31
Joined: Thu May 21, 2020 10:04 am

More exposed keyboard interface

Post 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?

paulscottrobson
Posts: 305
Joined: Tue Sep 22, 2020 6:43 pm

More exposed keyboard interface

Post 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.

TomXP411
Posts: 1781
Joined: Tue May 19, 2020 8:49 pm

More exposed keyboard interface

Post 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. 

User avatar
kliepatsch
Posts: 247
Joined: Thu Oct 08, 2020 9:54 pm

More exposed keyboard interface

Post 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 ?

Stefan
Posts: 454
Joined: Thu Aug 20, 2020 8:59 am

More exposed keyboard interface

Post 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. 

Post Reply