News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

Emulatotor key mapping.

Started by RobertM, 15:09, 13 December 22

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

RobertM

I am sure I have been trough this several times before.
Once again I have a CPC 6128 and I want to develop using an emulator (and the real machine).
So I have reached the point of absolute insanity that goes with the common CPC emulators.
Now don't get me wrong. I understand and appreciate all the hard work and time that goes into these emulators. But Why my God Why, build an aircraft with no wings???
So firstly WinAPE - I love it, I loved it years ago. It has all the features I want to develop in ASM!!! Years ago I had a deal breaker of an issue and that very issue still exists today.
The key-mapping can only be changed PER KEY and NOT PER SYMBOL. So if I want to use a windows keyboard with the windows layout then I CAN'T because I cant separate the mapping from the "2" from the mapping of the "@" or " - a deal breaker then and a deal breaker now - so in the bin again.
So next, Caprice - a long long long history and even today "caprice forever" and I'm Running Caprice64 and after forever and ever and a really long time one would expect to find how to use one of the most significant changes in early retro computing history - the copy key!!!
I can actually use the copy key feature with (CPC) hardware mapping which is also why WinAPE went in the bin. Then If I use the normal PC key mapping then I can't find a way to use the copy key feature. I have searched and searched using so many different terms , looking directly for this feature and then searching for some form of manual that tells you more than how to compile and install the application.
RTFM!!!! Can we expect a manual that is so so complex that it briefly explains how to use one of the most central features of the device it emulates - perhaps two whole sentences.
So I am hoping someone can tell me of an emulator that is USEFUL for developing for a CPC 6128 (Classic) for BASIC and ASM and allows me to use a PC keyboard layout because I have several systems THAT ARE NOT CPC and using a different mapping on different machines is so frustrating that it's enough to turn me completely off something I once enjoyed. The only thing positional I wan about mapping is the position of the chair my ass is on. If my ass in on a chair in front of a windows PC then I want windows mapping, if my ass is on a chair in front of a specie then I want specie mapping, if my ass is on a chair in front of a CPC then I want CPC mapping or in the end I am trying to work out why my specie keys aren't working on my CPC and that really &%*&(& you up when your trying to debug.
If I am developing with a Windows CPC emulator then I am also using different apps that of course use the windows key mapping. I get to the point that I am using CPC key locations in other windows apps - it's just absolute insanity.
Typists don't look at the keys and most experienced coders are typists. I took a typists course in the 1970's because I wanted to be a programmer - jokes aside about me being a "sissy" boy for doing a girls class - why the hell don't coders learn to type.
And I can tell where all the keys are from where my ass is.
I mean! do people get into a back end loader and look for the keyboard? Do people who work in back end loaders sit down at there computer and look for the hydraulic control levers? You should be able to tell where the keys are from where your ass is.

RobertM

I will add that so many people have searched for a manual for Caprice that it is now a well advertised hook for malware downloads. That's pretty much the death knell for any software products - but as I said why build a plane without wings.

roudoudou

most of the time, emulator authors are mapping a physical keyboard disregarding YOUR mapping because there is at least 3 possible output mappings on CPC (british, french and spanish)

mapping a real keyboard to a ROM mapping is possible if you have another approach to programming, that's what Megachur did with CPCemuPower but only from french hosted keyboard to french/british map. And you have to set the emulated keyboard

maybe emulators are lacking a good old setup.exe ?

My pronouns are RASM and ACE

Fessor

A workaround would be to use a hex editor to change the key mapping in the ROM of the 6128. The tables for the Matrix can be found from address 0x1f80 upwards in OS6128.ROM.

Sykobee (Briggsy)

I appreciate the key-for-key mapping that the emulators have - and I'd use them if I had a custom keyboard with that layout (not out of the question with replaceable keycaps, if someone was to get a set made with the CPC layout and colours).

But it would be nice to have a translation layer between modern layouts and the CPC layout.

(hey, at least it isn't the awful Spectrum keyboard layout!)

andycadley

At one point there were a bunch of KEY definitions circulating (maybe in a thread here?) that you could run from BASIC to map more closely to the key layout on a standard PC keyboard (and they could easily be pasted into the auto type thing in WinAPE).

Fundamentally the emulator itself can't do this because it's job is faking hardware and the CPC hardware itself only knows about KEY codes, not what symbols they represent (that's entirely a software thing handled by the firmware).

Prodatron

#6
@RobertM: If an emulator would do the mapping like you wish it, it wouldn't be a real usable emulator anymore, at least not for low level programming.

On the CPC you have single physical keys, and these are mapped 1:1 on single physical keys of your PC.

As soon as you write low level stuff, which is just using the key matrix code (0-79) and not the symbol/ascii char (0-255), defined in the CPC rom, you will get problems if the emu is mapping the keys in the way you like. It would be impossible to map the real "hardware" matrix signals in the correct way.

If you want to have a correct mapping in CPC-OS in the emulator you have to patch your ROM or run a CPC basic program, which redefines the Keys, and that's it.

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

eto

Quote from: andycadley on 23:47, 13 December 22Fundamentally the emulator itself can't do this because it's job is faking hardware and the CPC hardware itself only knows about KEY codes, not what symbols they represent (that's entirely a software thing handled by the firmware).

The emulator already has to map keyboard-keys to CPC keycodes. If that would be customisable, everybody could adapt the mappings to their personal preferences.

Btw: Tiny.js is perfectly mapping the keyboard keys to the right CPC keycodes.

andycadley

Quote from: eto on 00:09, 14 December 22
Quote from: andycadley on 23:47, 13 December 22Fundamentally the emulator itself can't do this because it's job is faking hardware and the CPC hardware itself only knows about KEY codes, not what symbols they represent (that's entirely a software thing handled by the firmware).

The emulator already has to map keyboard-keys to CPC keycodes. If that would be customisable, everybody could adapt the mappings to their personal preferences.

Btw: Tiny.js is perfectly mapping the keyboard keys to the right CPC keycodes.
But they do, that only gets you so far though.

For example, the emulator maps the PC SHIFT key onto the CPC SHIFT key, so pressing SHIFT works as expected. Makes sense. And it maps the PC 8 key onto the CPC 8 key, So pressing 8 gives you a 8, still makes sense.

Then you press SHIFT + 8 on the PC, which would normally give you a *. The emulator dutifully sends SHIFT and 8 key codes to the CPC and the firmware maps that onto (.

The only way to avoid this is to change the key mappings in the firmware. Either by running a bunch of KEY commands or by altering the firmware ROM so the default key definitions match the PC instead. It's not like the emulator chooses not to send the key code for *, because there is no such thing.

martin464

Yes this emulator also perfectly maps keys (except i couldn't find "copy" yet)
https://digitonaut.com/retro/amstrad_cpc/emulator.php?type=cpc6128

So it can be done and I too wish WinApe would fix its mappings
there should be a software layer between the pc keyboard and the emulated one that does translation

I also wish Winape had a better debugger. One that showed the binary value of registers and also let you navigate quickly to recently used addresses. And right-click and set PC without having to type it
But in saying all this I have to admit i'm the most guilty person for not putting that final polish on their code.. and moving on to other projects. Winape is still awesome
The other day I used basic print command to dump some data to a text file on pc, then manipulate the output in vba then back into winape assembler as defb's!
CPC 464 - 212387 K31-4Z

"One essential object is to choose that arrangement which shall tend to reduce to a minimum the time necessary for completing the calculation." Ada Lovelace

andycadley

Quote from: martin464 on 10:17, 14 December 22So it can be done and I too wish WinApe would fix its mappings
there should be a software layer between the pc keyboard and the emulated one that does translation

There is. It's the CPC firmware. And it has to be to not break things in weird ways. Presumably these emulators have a modified firmware ROM, which you could probably just use in WinAPE.

eto

Quote from: andycadley on 10:06, 14 December 22The only way to avoid this is to change the key mappings in the firmware. Either by running a bunch of KEY commands or by altering the firmware ROM so the default key definitions match the PC instead. It's not like the emulator chooses not to send the key code for *, because there is no such thing.
You can send different keycodes if the SHIFT or CONTROL key is pressed.

For a typical UK setup it would look like this:

PC        => CPC keycodes       => output

8         => key code 40       => 8 will appear
SHIFT + 8 => key codes 21 + 29 => * will appear


Btw: shift+8 is not always * on a PC. German keyboards have it next to the RETURN key. If there is such a mapping feature, I can change the mapping for my keyboard easily:

SHIFT + "+" => key codes 21 + 29 are sent to the CPC => * will appear
And if it's a Spanish CPC, I need  to send other keycodes to the CPC as it has its * on a different key.

Having such a mapping imho would be the better and more flexible choice than changing values in the ROM.

Of course we still need a key for key mapping for those games, that are using one of the keys that can have different positions (e.g. Z, A, W, Y), but for programming and text editing, such a mapping would be a relief.





eto

Quote from: andycadley on 10:31, 14 December 22Presumably these emulators have a modified firmware ROM, which you could probably just use in WinAPE.

No it doesn't have a modified ROM. It's just mapping the PC input intelligently to the keycodes.

If I switch my keyboard language to German, then SHIFT + "+" will return * and if I switch it to UK SHIFT + 8 will return '*". 

If I press Z on my (German) Keyboard, it will also output Z as long as my setting is German. When I switch to UK, the same key will output "Y".



andycadley

You can do it that way, but it will break software in weird ways. 

Imagine if a game used 7,8,9,0 and shift for L,U,D,R and Fire respectively. The player hits Up and Fire, the emulator decides they're trying to type a * and so generates a completely different set of key presses and the player thinks the game is broken.

Or someone tries to remap the keyboard in BASIC using KEY commands. Only weird stuff happens because something is already intercepting and changing key mappings outside of the machine.

If the point of the emulator is purely for typing in BASIC programs then sure, it'll work mostly, but otherwise it's a bad solution to an already solvable problem.

Sykobee (Briggsy)

So it seems what is required is a custom ROM (one per keyboard layout - UK, US, DE, FR, ES, with PC and Mac variants) for emulators.

But surely it would also be better for the emulator itself to map the key presses to entirely different CPC key press combinations. The emulator is already doing a lot of mapping to display the CPC video and play the audio and emulate a disk, there's no difference with the input device mappings. But then we get key number issues - there are times when we want the key location to matter, not what the key is - software that uses the key codes, not the firmware-provided characters.

I guess the ROMs could be used in all emulators, whereas each emulator would need to be coded to handle the second option, possibly using a function key to switch between mapping and direct methods depending on what you need at the time.

andycadley

ROMs would probably be the nicest solution. Using something like WinAPE's paste function to just run a user generated set of KEY commands to remap the keyboard within BASIC would probably be the next best solution (and a bit more flexible in terms of letting user's customize to their liking).

Fudging emulators to try and map the keyboard sounds like a good idea, but in practice creates more problems than it solves.

Or someone could make a PC keyboard with a proper CPC layout.  :laugh:

roudoudou

I would buy such a qwerty keyboard for sure
My pronouns are RASM and ACE

eto

Quote from: andycadley on 10:51, 14 December 22Imagine if a game used 7,8,9,0 and shift for L,U,D,R and Fire respectively.

Of course there will be cases, where a game would use a key that is mapped. I guess your example is hypothetical but that's not even required: e.g. any game that is using the keycode of the W-key will not properly work on a French system.

However this only matters if you are not using Joystick (emulation). And for those cases, that's why I think that...
Quote from: eto on 10:35, 14 December 22Of course we still need a key for key mapping
It's relatively few code to include a mapping or just use a key-for-key-mapping. When you play a game with keyboard control, just check that checkbox and you are set.

Quote from: andycadley on 10:51, 14 December 22but otherwise it's a bad solution to an already solvable problem.
We probably have different opinions what a bad solution is. I get your point, that the available option is acceptable for you. To me, patching ROMs with a hex editor is a workaround, as no user friendly solution exists. It's great to know about that option, and I would still prefer a config-file and the option to switch back to a direct key mapping if needed for a particular game.




eto

Quote from: Sykobee (Briggsy) on 11:02, 14 December 22So it seems what is required is a custom ROM (one per keyboard layout - UK, US, DE, FR, ES, with PC and Mac variants) for emulators.
and per system: 464,664,6128 and Plus. (664 might not be required)

Fessor

Quote from: andycadley on 11:09, 14 December 22Or someone could make a PC keyboard with a proper CPC layout.  :laugh:

That can be done at https://www.wasdkeyboards.com/

martin464

On the plus side (shift plus?) if all you're doing is prototyping stuff in basic intending to port it all to machine code... it's motivating to get to that point in the project you don't need basic anymore ! 
CPC 464 - 212387 K31-4Z

"One essential object is to choose that arrangement which shall tend to reduce to a minimum the time necessary for completing the calculation." Ada Lovelace

roudoudou

#21
based on Offset remapping routines, i'm proud to annonce that AceDL will support physical mapping and true mapping (on supported languages)

i made French, British, German and Spanish keyboards, every keyz are mapped and can be used with any CPC firmware, so spanish will get their N tilde, german their "B" and everyone the § key too...

obviously if spanish/french use a UK firmware the accents wont be in the ROM but mapped as they are supposed to be

do no hesitate to answer this topic about the Layout your are using (i mean, a standard layout on your PC/Mac)

will give a look for Mac user (because Mac is his own standard ;D )

My pronouns are RASM and ACE

OffseT

#22
Nice work. 😀

But I was just wondering, why did you need to handle specific keyboard layout presets?
Don't you have the ability to make it totally dynamic?

I mean, original ACE MorphOS version (and I guess Haiku too) can automatically remap any combinaison of keyboard layout for any firmware.
Not feasible on Winux?

roudoudou

Quote from: OffseT on 15:35, 07 October 23I was just wondering, why did you need to handle specific keyboard layout presets?
Don't you have the ability to make it totally dynamic?

Original ACE version works with any combinaison of keyboard layouts and firmwares.
Not feasible on Linux/Windows?
Not now because SDL cant get the value of all keyboard keyz + the code we get is only without shift/altGr

But this drawback makes the code very simpler ;D

If i found an alter-native method to get the mapping, it will be possible to upgrade the code and making it generic

in the meantime, i will make progress on other functionnalities
My pronouns are RASM and ACE

OffseT

OK, so a SDL limitation. :(
Poor Belgian, Greek and Mac users then. :D

Powered by SMFPacks Menu Editor Mod