Re: [hatari-devel] Proposal: use Atari keyboard with Hatari

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hello,


I have a proof of concept for this now. I can use the ATARI's keyboard and mouse in Hatari :) I think this can help for people who want to build a "fake" Atari using an old  Atari keyboard and a raspberry pie!

I recorded a small demo video (81 seconds) which you can watch here

https://youtu.be/r-ojz6_FO3E


Here's what I did:

* create a module external_ikbd.c which opens the serial port (9600bps) and runs 2 threads, one for getting data from the serial and put in an "inbound" circular buffer, the other thread for sending data from an "outbound" circular buffer to the serial port.

* adapt main.c so it calls the initialization code of that module

* adapt acia.c so to

  * check the "inbound" buffer and fake reception of that byte into the keyboard ACIA

  * write the data that the ACIA would sent to "outbound" circular buffer


It has the following limitations:

* I haven't disabled the PC's keyboard and mouse handling. So you can use both the PC and the Atari keyboard mouse. But if you use both at the same time, multiple-byte IKBD packets will get corrupt and can lead to unexpected effects in the TOS.

* I added a config switch but it's hardcoded, there is no UI to configure it.

* The serial port handling is linux-specific.

* There is no error handling of what happens on the serial port.


I have some questions:

1 What's your view on this change ? Any chance you would ever accept to merge that in hatari ? I think using keyboard/mouse is ok because you can hardly loose data in case something goes wrong. It's not like using a DMA device through a serial line with all the trouble that Nicolas mentioned.

2 I would like to add configuration. I found that there is a good looking pythonui in addition to the SDL one. Why is that ? Is one of them going to be retired / would I need to support both ?

3 It works on linux only. I think I can make it work with anything that support struct termios (like the RS-232 emulation does). Should I refactor to make this RS232 more reusable (it currently uses some static variables) or it's better to keep the external ikbd stuff a completely a separate implementation ?


Kind regards


Vinz


On 30/12/2020 15:12, Vincent Barrilliot wrote:
Hi,


Thank you Laurent for the insight. Indeed I did not consider these situations !

But I think the situation is different (I mean simpler) than with a floppy because there is no hard coupling between the keyboard and the computer (e.g. no DMA involved, they use "different" clocks etc.). In the worst case we can have overruns if hatari runs too slow, but that could happen as well on real hardware if ACIA interrupts are masked and I guess/hope that TOS handles it.

I think baud speed is not a big problem, we just need to inject the received byte from the remote IKBD into the ACIA's data register, rather than build it up using the bit-shift register. Same for sending Atari->IKBD.

I'll look at the MIDI implementation because it must be doing something similar.

Anyway, I'll try it for fun I'll how far I get:)

Kind regards


Vincent


Le 29/12/2020 à 17:32, Nicolas Pomarède a écrit :
Le 28/12/2020 à 15:41, Vincent Barrilliot a écrit :
Dear Hatari developers,


I have an STf which I don't use much. I'd like to add an option to Hatari so that instead of emulating the IKBD we would simply use that of a real ST through serial ports, so to get the feeling of using a real ST but with all advantages of Hatari.

For this want to I connect the ST to the PC using serial port, then I run a program on the Hatari that hooks into $118 and transfers all the IKBD's traffic to the PC's serial port (I've left MIDI out of the picture for now, as the 19200 line wouldn't keep up with the MIDI's 31250bps). Of course the ST becomes unusable from that point because the TOS doesn't get any IKBD or MIDI event anymore.

Then I need to update Hatari, the configuration GUI etc.


  I would like to know:

* what you think about this idea

* (so that if I ever submit a patch achieving that you'll agree to merge it in)

* if you have any advice to give me for doing that, pitfalls, things to be cautious about etc.

I think I know the ikbd.c well now. I still have my patch to submit to improve keyboard support, in particular for characters requiring key combinations on either the PC and/or the Atari but there are other things in progress so I'm waiting for a better moment to bring that subject again.

Kind regards


Vinz

Hi

I think there will be similar issue when doing this than when trying to access a real floppy drive from Hatari (which was requested by some users)

The problem is that you're not sure that Hatari will always run in real time ; if you pause hatari, then your "real" keyboard will loose some bytes that can't be transfered to the emulated acia. Same problem if hatari slows down (for example emulating a falcon with not enough cpu on the host side) or if you press alt+x to go in fast mode : you won't have the same baud speed under emulation as the real HW expects.

In the end, I'm not sure this kind of patch to mix real atari HW with emulated atari machines will work correctly.

you can of course try it on your side and see what results you get, but it's not sure this can be merged into hatari if it imply too much specific changes.

Nicolas







Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/