ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

User avatar
pgimeno
Top Contributor
Posts: 669
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 246 times
Been thanked: 208 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by pgimeno »

_paul_ wrote: Thu Nov 18, 2021 6:01 am Using Notepad, if I press the [1] key on the keyboard, a single character “a” appears in Notepad. If I then release the [1] key, the character “b” appears in Notepad.

So pressing and releasing the [1] key resuls in “ab”.
Thanks, so indeed it's what I suspected: the release of a physical key causes another logical key to be *pressed*, not released as the blog says.

I've started with the patch, but the way the code is written is fragile and it will need a rewrite of some parts to make it more robust, otherwise I can't guarantee that it will be stable enough.
User avatar
_paul_
Posts: 63
Joined: Mon Aug 31, 2020 4:44 pm
Has thanked: 11 times
Been thanked: 12 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by _paul_ »

Chris23235 wrote: Thu Nov 18, 2021 3:24 pm
AmintaMister wrote: Thu Nov 18, 2021 3:09 pm
Chris23235 wrote: Thu Nov 18, 2021 8:59 am Wouldn't it be easier to use something like this?

https://www.hackster.io/news/a-zx-spect ... 5b0ceb6339
It will work out of the box in MISTer?
As it is working as a standard USB keyboard it should work out of the box.
Won't it have the same limitation as trying to use the Recreated ZX Spectrum in standard USB keyboard mode? The ZX Spectrum keyboard is not exactly a standard US 101 keyboard layout. With the mapping I get on the Recreated Spectrum in standard USB mode the special characters are not where they should be and getting to the E (extended) commands on the keyboard is not possible.
User avatar
pgimeno
Top Contributor
Posts: 669
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 246 times
Been thanked: 208 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by pgimeno »

MiSTer_Kirk wrote: Thu Nov 18, 2021 2:25 pm The beauty of the Mister is that we can finally ditch that god-awful rubber keyboard, and use a modern keyboard, with modern cherry switches. I use a Razor Blackwidow, it's got lovely clicky blue switches, and soooo much better to use than a speccy keyboard.
You haven't typed much on a Spectrum right? ;) Having Ctrl as Symbol Shift is cumbersome in comparison with the real symbol shift in a rubber keyboard. All keys are too far apart for what has always been a single-hand key entry, and the muscle memory doesn't work well in these circumstances.

Right, I'm not happy with the rubber keyboard either, that's why I had a dK'Tronics keyboard when my membrane died instead of trying to find a new membrane. But it's a problem for me if the keyboard layout is not consistent with the Spectrum's.
User avatar
pgimeno
Top Contributor
Posts: 669
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 246 times
Been thanked: 208 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by pgimeno »

_paul_ wrote: Thu Nov 18, 2021 4:42 pm Won't it have the same limitation as trying to use the Recreated ZX Spectrum in standard USB keyboard mode?
Not if each of the keyboard keys has a 1:1 mapping to a PC key instead of trying to do clever things. For the MiSTer, Symbol Shift should be mapped to Ctrl, and Caps Shift to LShift.
MiSTer_Kirk
Posts: 210
Joined: Thu Feb 04, 2021 11:42 pm
Has thanked: 18 times
Been thanked: 46 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by MiSTer_Kirk »

pgimeno wrote: Thu Nov 18, 2021 4:50 pm You haven't typed much on a Spectrum right?
I have owned a 16k ZX Spectrum, upgraded to 48k back in the 80s, since xmas 1982. When I got it, all I had was a couple of C&VG magazines which had spectrum listings in to type-in. That was it, I had no tape deck, or games at xmas 82. It wasn't until Jan 83 that I was able to get a tape deck, and some tapes. After using a BBC Micro, at my school, which had a proper full-travel keyboard, the spectrum keyboard was atrocious. Typing in listings, I kept trying to "Type" the words, only to forget that they were single press keys, and the words would appear automatically. I hated it back then, and still hate it.
I know it was a budget conscious decision by Sinclair to keep the costs down, and it has it's charm. And, I still think the overall design of the ZX Spectrum is still THE best, most iconic design ever. But playing games on that keyboard really sucked.
Those dK'Tronics keyboards were, at that time, out of my budget. I remember seeing them in magazine ads, but nobody I knew had one, so it wasn't on my radar. I see, on eBay, those dK'Tronics keyboards are getting more money today than they were back then. Mad.
User avatar
pgimeno
Top Contributor
Posts: 669
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 246 times
Been thanked: 208 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by pgimeno »

My Recreated will take a while to arrive because brexit, so I can't test myself for now, but here's an untested core. Please check if it works as expected.

I tried my best to keep the normal keys that didn't conflict with the Recreated working, but it was a hell to isolate those without breaking anything so I've finally given up: if you have both the PC keyboard and the Recreated keyboard connected, the extra keys in the PC keyboard like the arrows won't work when in Recreated mode, so you need to use caps+5,6,7,8 etc.
Attachments
ZX-Spectrum-recr.rbf
(3.03 MiB) Downloaded 230 times
User avatar
_paul_
Posts: 63
Joined: Mon Aug 31, 2020 4:44 pm
Has thanked: 11 times
Been thanked: 12 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by _paul_ »

pgimeno wrote: Thu Nov 18, 2021 9:06 pm My Recreated will take a while to arrive because brexit, so I can't test myself for now, but here's an untested core. Please check if it works as expected.

I tried my best to keep the normal keys that didn't conflict with the Recreated working, but it was a hell to isolate those without breaking anything so I've finally given up: if you have both the PC keyboard and the Recreated keyboard connected, the extra keys in the PC keyboard like the arrows won't work when in Recreated mode, so you need to use caps+5,6,7,8 etc.
Had a go at this but in my first pass it seems to behave the same as the original core? And the arrow keys on the PC keyboard work fine, can you check if you shared the correct (modified) core?
User avatar
pgimeno
Top Contributor
Posts: 669
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 246 times
Been thanked: 208 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by pgimeno »

Yes, I've verified it to be sure. You need to go to the menu and set the Keyboard option to Recreated ZX. Take into account that this patch is not Recreated-specific, but should be applicable to the current core so that the default is the normal keyboard.

My Recreated arrived today, my wife was hiding that as a surprise :) I've checked it and it seems to work fine. Here's a simple BASIC program you can try to check that all key press/release combinations work:

Code: Select all

10 LET a=254
20 PRINT IN (a*256+254);"  "
30 LET a=a+a+255
40 IF a>0 THEN GO TO 20
50 PRINT AT 0,0;: GO TO 10
I've noticed that the Recreated keyboard does NOT include ghosting support. I'm not sure if that's good or bad. I'll look into adding an option to the core next.

Attached is the complete patch. Now the problem is that I'm not in GitHub, so this patch can't be merged into the core unless someone submits a PR with the patch for me.
Attachments
ZX-Spectrum-recreated.patch.zip
(3.78 KiB) Downloaded 218 times
User avatar
_paul_
Posts: 63
Joined: Mon Aug 31, 2020 4:44 pm
Has thanked: 11 times
Been thanked: 12 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by _paul_ »

pgimeno wrote: Fri Nov 19, 2021 11:46 am Yes, I've verified it to be sure. You need to go to the menu and set the Keyboard option to Recreated ZX. Take into account that this patch is not Recreated-specific, but should be applicable to the current core so that the default is the normal keyboard.
...
Sorry, completely missed the keyboard selection option, I had assumed you had simply created an alternate "Recreated" core as a PoC.

It works brilliantly, many thanks for doing this!!
Hetzen
Posts: 141
Joined: Thu Oct 14, 2021 1:55 pm
Has thanked: 72 times
Been thanked: 43 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by Hetzen »

So what do I need to do with this .patch file? I've got one of these keyboards incoming based on the back of this thread.
User avatar
pgimeno
Top Contributor
Posts: 669
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 246 times
Been thanked: 208 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by pgimeno »

Hetzen wrote: Tue Nov 30, 2021 10:19 pm So what do I need to do with this .patch file? I've got one of these keyboards incoming based on the back of this thread.
You need to grab the core from this post: viewtopic.php?p=37717#p37717 then install (copy) it in the _Computer folder of the SD card.

The patch file is for submitting the changes to GitHub.
Hetzen
Posts: 141
Joined: Thu Oct 14, 2021 1:55 pm
Has thanked: 72 times
Been thanked: 43 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by Hetzen »

Thank you, I appreciate that. Looking forward to getting that nostalgic RSI when it arrives.
User avatar
pgimeno
Top Contributor
Posts: 669
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 246 times
Been thanked: 208 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by pgimeno »

Hetzen wrote: Wed Dec 01, 2021 12:02 am Thank you, I appreciate that. Looking forward to getting that nostalgic RSI when it arrives.
Well, after having tried it for a while now, I can say that the experience was superb! And I'm now convinced that it's the right approach for replicating classic computers. Adding emulation hardware to it may seem like a closer replication on the surface, but in the end it loses in flexibility. The Recreated ZX creators did it right, by making only a keyboard and not a full computer. I just wish the same approach was used for other computers, like the C64, instead of having all-in-one solutions devoted to a single computer like the Ultimate 64. I'd love to have a recreated C64 USB keyboard, a QL USB keyboard and so on.

On the technical side, I have to "scold" the creators of the Recreated ZX for choosing to make shift+key combinations part of the protocol, which is a shame, but not a horribly big issue. At least they did use a unique mapping for each key.

Also many thanks to _paul_ for getting me started, by posting the link to zx81keyboardadventure.com explaining the protocol.
User avatar
pgimeno
Top Contributor
Posts: 669
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 246 times
Been thanked: 208 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by pgimeno »

I've just reviewed some posts in GitHub. Apparently there isn't much interest in adding support for the Recreated keyboard: https://github.com/MiSTer-devel/ZX-Spec ... -711439558 (and it seems I'm not the first person to write a patch).

I don't agree with Sorgelig's argument though, as many cores get support for controllers that match the device they are for, like spinner controls for certain arcade cores. (Edit: or the 2600daptor for... guess what) ;)
Hetzen
Posts: 141
Joined: Thu Oct 14, 2021 1:55 pm
Has thanked: 72 times
Been thanked: 43 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by Hetzen »

pgimeno wrote: Wed Dec 01, 2021 12:59 am Well, after having tried it for a while now, I can say that the experience was superb! And I'm now convinced that it's the right approach for replicating classic computers. Adding emulation hardware to it may seem like a closer replication on the surface, but in the end it loses in flexibility. The Recreated ZX creators did it right, by making only a keyboard and not a full computer. I just wish the same approach was used for other computers, like the C64, instead of having all-in-one solutions devoted to a single computer like the Ultimate 64. I'd love to have a recreated C64 USB keyboard, a QL USB keyboard and so on.
That's good to hear, because I agree with you 100%, the emulation doesn't stop at the code. I'm currently looking at mechanical keyboards that would cover the 8bit/16bit era to build a case around. The Spectrum needs those printed overlays to make any sense of the way it worked. Like you, I'd put the C64/Vic20/Pet in that category too.
Hetzen
Posts: 141
Joined: Thu Oct 14, 2021 1:55 pm
Has thanked: 72 times
Been thanked: 43 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by Hetzen »

pgimeno wrote: Wed Dec 01, 2021 1:57 am I've just reviewed some posts in GitHub. Apparently there isn't much interest in adding support for the Recreated keyboard: https://github.com/MiSTer-devel/ZX-Spec ... -711439558 (and it seems I'm not the first person to write a patch).

I don't agree with Sorgelig's argument though, as many cores get support for controllers that match the device they are for, like spinner controls for certain arcade cores.
I don't understand that. Is it a control thing about the code? If someone makes a solution I guess it's hard to bug fix with multiple authors.
cathrynmataga
Posts: 109
Joined: Fri Aug 06, 2021 5:30 pm
Has thanked: 140 times
Been thanked: 18 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by cathrynmataga »

Is it possible to go the other way, and get the ZX Spectrum Recreated people to add a mapping that matches what the Mister Spectrum cores use? Those guys might be motivated since they'll want to sell keyboards.
User avatar
pgimeno
Top Contributor
Posts: 669
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 246 times
Been thanked: 208 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by pgimeno »

It's likely that they won't. https://www.eurogamer.net/articles/2016 ... x-spectrum

I'm not sure but I think that it's no longer for sale. It's been out of stock every time I checked, for a long time. I got mine from eBay, used.

From the way it works (having to unlock the standard keyboard mode with a code in their page, having a custom special mapping) it seems clear that by design they don't want people to use it for anything else but their app, and that they took every precaution they could against it being adapted for use with other emulators (but people managed to do it anyway).
rhester72
Top Contributor
Posts: 1107
Joined: Thu Jun 11, 2020 2:31 am
Has thanked: 13 times
Been thanked: 169 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by rhester72 »

I am VERY confused.

Why does Sorg have a problem with this, but not the C64 Maxi interface over USB?
User avatar
Chris23235
Top Contributor
Posts: 841
Joined: Sun May 24, 2020 8:45 pm
Has thanked: 106 times
Been thanked: 167 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by Chris23235 »

If you have access to a ZX Spectrum (or an empty replica case) and a soldering iron you can convert the Speccy to an USB keyboard relatively easy.

https://www.instructables.com/ZX-Spectr ... rd-Part-1/
User avatar
pgimeno
Top Contributor
Posts: 669
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 246 times
Been thanked: 208 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by pgimeno »

I couldn't find these connectors anywhere though. Any references/links? Edit: Oops, I didn't see the link in the article.

Also, I guess the software needs to produce the same keyboard layout as MiSTer (SHIFT for caps shift, CTRL for symbol shift). If not, then it will need to be customized.
User avatar
pgimeno
Top Contributor
Posts: 669
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 246 times
Been thanked: 208 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by pgimeno »

Okay, so as I said in an earlier post, I wasn't happy about the lack of ghosting in the Recreated keyboard (or in the core in general), so I've added it to the core as an option. I must say that I'm somewhat perplexed that the Recreated keyboard does not suffer from ghosting.

To avoid clobbering the menus too much, I've used the Keyboard option for both purposes, so it cycles between four choices: Normal, Ghosting, Recreated ZX, Rec.+Ghosting.

In addition to that, this version also fixes an out-of-specs issue with the TZX loader, where the duration of the leading tone of the standard blocks was a fixed value instead of depending on bit 7 of the first byte in the block. You know, ~5s of leading tone, header data, 1s pause, ~2s of leading tone, payload.

As always, the patch is included. The license mandates me to distribute the source code; I hope that including only the patch suffices, as it's otherwise identical to the GitHub version.

Edit: Note that most PC keyboards will suffer from key jamming, which will mask the ghosting. Also if you make your own USB keyboard using the link posted by Chris23235, you'll get ghosting for free due to the membrane design :)

Edit2: Removed attachments because of an important bug, see viewtopic.php?p=39308#p39308 for the fixed core.
caffeinekid
Posts: 75
Joined: Wed Nov 04, 2020 10:03 am
Has thanked: 21 times
Been thanked: 14 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by caffeinekid »

Great fixes and additions. I hope this will be added to the official repo... I can't understand why it wouldn't be.
Hetzen
Posts: 141
Joined: Thu Oct 14, 2021 1:55 pm
Has thanked: 72 times
Been thanked: 43 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by Hetzen »

Just had a chance to load and use this. So far it's working really well. Thank you. Great work!
Higgy
Posts: 83
Joined: Mon May 25, 2020 9:37 am
Has thanked: 4 times
Been thanked: 27 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by Higgy »

If you don't have access to Minimus then you can use cheap Arduino Pro Micro's.
The project info is on these pages:
https://mrpjevans.com/building-the-zx-r ... -part-two/

Nice thing with this one is you have keyboard mapping via a switch, so you get PC style and Spectrum layout.
I was using this method for some years until I fixed the broken Spectrum (ram chips!) the keyboard came from.
akeley
Top Contributor
Posts: 1303
Joined: Mon May 25, 2020 7:54 pm
Has thanked: 416 times
Been thanked: 399 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by akeley »

pgimeno wrote: Fri Dec 03, 2021 11:04 pm Note that most PC keyboards will suffer from key jamming, which will mask the ghosting.
Whoa, I had never heard about that before! And I've played quite a lot of PC games using KB+M.

Coincidentially, I was playing Renegade on teh ZX core yesterday using keyboard (instead of my usual DS4-as-Kempston) and could not execute the jump kick-right move (left one was fine). My keys were W/S for Up/Down, O/P for left right and ] for Hit. Could it be because of that "jamming" issue?
User avatar
pgimeno
Top Contributor
Posts: 669
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 246 times
Been thanked: 208 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by pgimeno »

akeley wrote: Tue Dec 07, 2021 7:40 pm Coincidentially, I was playing Renegade on teh ZX core yesterday using keyboard (instead of my usual DS4-as-Kempston) and could not execute the jump kick-right move (left one was fine). My keys were W/S for Up/Down, O/P for left right and ] for Hit. Could it be because of that "jamming" issue?
If it involves three keys, then most probably, yes. You can try to find a combo of keys that you can press at the same time with that keyboard without any jamming. Can't offer advice on that as it's different with every keyboard.

I guess MAME chose Ctrl, Alt and Shift as preferred buttons mainly for that reason - they are usually separate buttons and don't suffer from jamming.
User avatar
_paul_
Posts: 63
Joined: Mon Aug 31, 2020 4:44 pm
Has thanked: 11 times
Been thanked: 12 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by _paul_ »

pgimeno wrote: Fri Dec 03, 2021 11:04 pm Okay, so as I said in an earlier post, I wasn't happy about the lack of ghosting in the Recreated keyboard (or in the core in general), so I've added it to the core as an option. I must say that I'm somewhat perplexed that the Recreated keyboard does not suffer from ghosting.
….
I may well be missing something but the tzx version does not work for me; I get this screen.
Attachments
1D3C32DA-B080-4438-A22A-7979294C6E65.jpeg
1D3C32DA-B080-4438-A22A-7979294C6E65.jpeg (152.42 KiB) Viewed 12999 times
Hetzen
Posts: 141
Joined: Thu Oct 14, 2021 1:55 pm
Has thanked: 72 times
Been thanked: 43 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by Hetzen »

Did you change the keyboard type in the core menu?
User avatar
pgimeno
Top Contributor
Posts: 669
Joined: Thu Jun 11, 2020 9:44 am
Has thanked: 246 times
Been thanked: 208 times

Re: ZX Spectrum Recreated Would Work as Bluetooth Keyboard With MiSTer?

Unread post by pgimeno »

_paul_ wrote: Fri Dec 10, 2021 7:51 pm I may well be missing something but the tzx version does not work for me; I get this screen.
Sorry but I have absolutely no idea where that may be coming from. It looks like a test pattern of some sort; maybe it's not detecting boot.rom correctly for you and boots from a built-in test ROM that displays that pattern? I haven't found any evidence of such ROM though.
Post Reply