LIJI32 / SameBoy

Game Boy and Game Boy Color emulator written in C
https://sameboy.github.io/
Other
1.62k stars 205 forks source link

Feature request: PS/2 keyboard emulation #235

Closed jkotlinski closed 4 years ago

jkotlinski commented 4 years ago

This feature would allow Little Sound Dj to be played like a piano (and might open up other exciting interaction possibilities in the future)

lpla commented 4 years ago

Probably you are interested in this: https://github.com/tommitytom/RetroPlug

It uses SameBoy.

jkotlinski commented 4 years ago

I am aware of RetroPlug, but PS/2 keyboard emulation is something else and interesting in other ways :-) Thanks for the heads-up, though.

On Mon, 9 Mar 2020 at 12:15, Leopoldo Pla notifications@github.com wrote:

Probably you are interested in this: https://github.com/tommitytom/RetroPlug

It uses SameBoy.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/LIJI32/SameBoy/issues/235?email_source=notifications&email_token=AAY34O7F5ZUNMAEXWTI7Z6DRGTFUZA5CNFSM4LEGNAQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOGVT7I#issuecomment-596466173, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAY34O7NW65IZ44EVGKJQRTRGTFUZANCNFSM4LEGNAQQ .

LIJI32 commented 4 years ago

How exactly does this thing work? Is there any documentation on it? Is it done over serial or is it a port in the cartridge itself?

jkotlinski commented 4 years ago

Hi! There used to be documentation, unfortunately it is long lost. But it’s a matter of translating keypresses to PS/2 scancodes, then truncate to 8-bit and forward to GB serial port. Anyway, you could probably disregard or downprio this feature. It might be added to Retroboy and that already satisfies my needs.

On Wed, 8 Apr 2020 at 18:19, Lior Halphon notifications@github.com wrote:

How exactly does this thing work? Is there any documentation on it? Is it done over serial or is it a port in the cartridge itself?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/LIJI32/SameBoy/issues/235#issuecomment-611053938, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAY34O6HVR3OKIE5XVAFLRTRLSPZLANCNFSM4LEGNAQQ .

lpla commented 4 years ago

FYI, Arduinoboy code used for it LSDJ Keyboard mode is here: https://github.com/trash80/Arduinoboy/blob/b5f46e70167209e7b8f4f4a61e5b54ff50bcc3c0/Arduinoboy/Mode_LSDJ_Keyboard.ino#L218

PS2 keyboard emulation in a Teensy is done by using PS2Keyboard library in this line: https://github.com/trash80/Arduinoboy/blob/b5f46e70167209e7b8f4f4a61e5b54ff50bcc3c0/Arduinoboy/Mode_LSDJ_Keyboard.ino#L47

Library here: https://www.pjrc.com/teensy/td_libs_PS2Keyboard.html

jkotlinski commented 4 years ago

Since I am satisfied by RetroPlug support, I will close this issue so you can focus on more important things :-) If anyone disagrees, let me know and I will reopen.

Q-Bert-Reynolds commented 7 months ago

I'd like to revive this feature request. LSDJ is not the only GameBoy title that supports PS/2 keyboards. It's just the only one anyone has ever heard of, and I'm pretty sure lack of emulator support is the only thing keeping more from being made.

I added PS/2 keyboard support (as well as USB keyboard support via InsideGadgets' adapter) to my baseball RPG as well as to the Everdrive's GBOS. It was a huge pain without emulator support, and it'd be really cool to make improvements and add keyboard support to other things without going through that again.

The adapters have no logic in them. They just wire link port pins directly to PS/2 pins. PS/2 interface only has only one data line (for both sending and receiving data), so it just gets mapped to the GameBoy's receive data line. Clock is provided by the keyboard. The keyboard sends 11 bits per clock pulse, so it's a bit more complicated that just waiting for an interrupt. Once you've received the first 8 bits, you have to force another transfer (with the external clock), poll for the remaining 3 bits, stop the transfer (again using the external clock), sanity check your start/stop/parity bits, then ask for another transfer with the external clock. Relevant code is here.

I have no clue how to implement this myself, but SameBoy is my preferred emulator for development, and I've written enough C and Objective-C to be dangerous, so if no one takes this up, I'll eventually hack something together based on the WorkBoy code. Given the shitty assembly code you probably just looked at, I'm sure you don't want that, so pretty please reconsider reopening this 4-year-old feature request.