chrismaltby / gb-studio

A quick and easy to use drag and drop retro game creator for your favourite handheld video game system
https://www.gbstudio.dev
MIT License
8.56k stars 471 forks source link

Keyboard support via link port and emulation #1617

Open Q-Bert-Reynolds opened 2 weeks ago

Q-Bert-Reynolds commented 2 weeks ago

Is your feature request related to a problem? Please describe. Text entry on a GameBoy is slow and playing music is hard. It would be a lot cooler if I could just plug a PS/2 keyboard into the link port, use the insideGadget's USB keyboard adapter, or leverage the power of emulators to expand the number of buttons available to the GameBoy.

Describe the solution you'd like Enable keyboard support on the settings page. More keybindings are available in the attach script to button event. A new scene in Sample Project that includes typing your character's name.

Describe alternatives you've considered I made my own scene editor and game engine for GameBoy. It has keyboard support, but I'm tired of building it, and it's not as easy to use as GB Studio.

Additional context I've already written a serial interface that supports PS/2 and USB keyboards. I just need to convert it for use with GBDK and add the editor bits and you'll be able to make GB Studio games that support keyboards on real hardware. What I'm less sure about is the emulation side. I'm thinking it will be a lot easier to emulate insideGadget's USB adapter since it sends 8 bit packets and the PS/2 keyboards send 11, but I haven't really looked into it.

chrismaltby commented 2 weeks ago

Very cool, this sounds like it should be an engine plugin rather than within the core itself (could add it to the official repo I'm working on https://github.com/gb-studio-dev/gb-studio-plugins). It might be possible to do this already without any core changes but if there are changes needed happy to help make this work

Q-Bert-Reynolds commented 2 weeks ago

I can see the serial interrupt as an engine plugin and the keybinding stuff as an events plugin, but I'm assuming I'd have to edit this bit in GameBoyCore.js to get it to work in web builds.

Q-Bert-Reynolds commented 2 weeks ago

Holup. Are there two different emulators? One for builds one for the play button? I see Binjgb in appData/wasm and js-emulator in appData.

chrismaltby commented 2 weeks ago

Ah, good point on extending the emulator I don’t think we’ve got plugins support for doing that yet but there probably should be. On the two emulators, pretty sure we’re just using Binjgb everywhere now, might be able to delete the other one

pau-tomas commented 2 weeks ago

Yeah. No reason to have the old emulator now. Binjgb is compiled to wasm but I wonder if a javascript wrapper could access the right memory addresses.

Maybe the way is to add support to Workboy to upstream Binjgb via PR. Similar to what Sameboy does here.

Q-Bert-Reynolds commented 2 weeks ago

I may be a bit obsessed with the WorkBoy. Tried recreating it at one point. Got as far as a 3D model, some kicad files, and a cursory read through of the disassembled WorkBoy rom. One day.

pau-tomas commented 2 weeks ago

I just found the post with that image on Reddit and was thinking "I wonder what happened with this project?" :D

maxoakland commented 2 weeks ago

That's a fascinating idea