Hello, Guest the thread was called2.2k times and contains 56 replays

last post from LGB-Z at the

Xemu Windows to MEGA65 keyboard mapping

  • Btw, if someone donate me a Mac, I promise I will present a better keymap ;-P ;-P


    This has to be enough! :D

    Ok, how I can press the keys and receive the SDL2 scan symbols? ;-P OK. Seriously. Hopefully I'll have time to finish the keyboard remapper GUI part, so then everybody can do his own beloved layout on any platform ;)

  • Hopefully I'll have time to finish the keyboard remapper GUI part, so then everybody can do his own beloved layout on any platform ;)

    That would be great! :thumbsup:


    By the way: a very big compliment for your Xemu! It's a great emu and I use it very often. Great work! :thumbup:

    ... great work will be. :) Hopefully. But I'm trying it to become that :)

  • Ok, I had an initial sniff of SDL and keys on a mac keyboard. Don't have any full answer yet, just some hints.


    This project has some header file which has this darwin_scancode_table[] array which maps beween mac keyboard and sdl keycodes:


    https://github.com/native-tool…events/scancodes_darwin.h


    In there, I see two entries for SDL_SCANCODE_KP_ENTER:


    /* 52 */ SDL_SCANCODE_KP_ENTER, /* keyboard enter on portables */
    /* 76 */ SDL_SCANCODE_KP_ENTER, /* keypad enter on external keyboards, fn-return on portables */


    Hmm, it seems odd that they'd map two unique scancodes to the same sdl-scancode. At a guess, it seems to be the scancode behaviour of a mac with a proper external keyboard versus a macbook with its more minimal keyset (and the need for more fn-key-combo tricks to make up for missing keys).


    As for what xemu should do about this, at this stage, not sure, I'm still mulling it over and coming to terms with it all :)


    Oh, and oddly, if I simply press the enter key on my macbook, I see inside xemu's hid_key_event(), it sees this sdl scancode:


    /* 36 */ SDL_SCANCODE_RETURN,


    This surprises me, as the comments in the code earlier seem to suggest that a 'portable' (macbook) should report the enter key as darwin scancode 52 (and not 36).

  • This is kinda complicated topic, it can even vary between OS versions (on the same OS) and different keyboards. Surely, the very basic keys should be the same, but actually what SDL 'sees' are more like the product of OS itself, and not the physical keys, as of course an app cannot easily access the hardware directly, only via the OS. I'm not even sure what happens, if someone has different keyboard layout set in its OS, will the scan codes change as well? Or only the higher level key (not scan) codes, as SDL has both of them (though for some reason would be hard to explain now, I stick with scan codes currently).

  • I appreciate your emulator very much! I use it together with a MEGA prototype for testing and application programming.

    Working on a MAC, I had to edit a keymap.cfg file, because the default file is suitable for a PC keyboard, but less practicable for a MAC keyboard.

    But I had problems, to find PC keynames for some keys.

    I wanted, for example, to map the circumflex ^ key to the back-arrow key of the MEGA65 (same position on the keyboard) and tried:

    LARROW ^

    but this resulted in an error emu_name=[LARROW] host_key=<^>: Unknown host keyname

    LARROW Circumflex

    didn't work either.

    Where can I find the correct host keynames?

  • All key names (for "host") actually SDL2 scancodes, so they are not Xemu specific but SDL2. It's important to note, that it's scancode based system. ie you cannot do a mapping where a "hostkey" is shifted, but the emulated key is not shifted or vice versa, maybe with different modifier keys, since it's a single "key is pressed, so" kind of theory, which simply cannot handle the situation of the modifier key even not in theory (ie, just imagine what would happen if you press SHIFT+something, Xemu would pass the SHIFT as well for the emulated machine, so you see the assigned key is also shifted then, as the host key is). But it's kinda natural since the base idea behind this, that it's simply a key-to-key mapping, including shift-ctrl-commodore .... etc.


    But to finally answer to your question :) Indeed, it's a bit hard to get to know what the actual SDL2 scancode names are ... Probably you need to check in SDL2 source code itself, like here:


    https://hg.libsdl.org/SDL/file…src/events/SDL_keyboard.c


    Starting at line saying: "static const char *SDL_scancode_names[SDL_NUM_SCANCODES] = {"


    A relative trivial thing I can do (within some minutes of work today, for example, tell me, if you're interested, since otherwise not so useful generic thing for most of the users ...), to give an option in Xemu to turn on OSD-display for the HID-keyboard layer so you'll see the pressed "scancode names" you can use.


    Surely, the REAL solution is still the included keymap editor functionality of Xemu, which I had still no time to finish but I've already started once [upon a time ...] :(

  • One option with a OSD Display which shows the scancodes would be very apreciated.

    Of course with the ability to turn on or off. ;-)

  • OK, done, well, ... kind of :) In the "dev" branch only though. UI menu "Display" has a new option to toggle this feature on/off, it's off by default. As usual, all the master and devel branch builds are automatically built so can be downloaded (without manual compilation) at the usual place (though, do not forget to use 'devel' since it's the dev(el) branch ...): https://github.lgb.hu/xemu/

  • Thank you very much! The OSD display will help a lot.

    I think, I've found the problem of the circumflex key.

    It is the unshifted key left of the '1' key on GERMAN keyboards.

    ASCII keyboards have the backtick/tilde key there and that is probably the name I should use in the keymap file.

    I tried:

    LARROW `

    It doesn't give an error message, but has no effect. The key is dead and cannot be used in the emulator.

    It is also not possible to map other any key to the backtick key.

  • Btw if you can find out some better Mac default, I can include that as the default. I have no Mac, so I cannot tell what is problematic or not there ...... The sight problem that included Xemu kbd mapping (for being a little more fun, hehe) is _not_ based on names like config files, but constants which are not the very same. Well yeah, SDL2 can be a kind of tricky sometimes ...

  • Thank you very much! The OSD display will help a lot.

    I think, I've found the problem of the circumflex key.

    It is the unshifted key left of the '1' key on GERMAN keyboards.

    ASCII keyboards have the backtick/tilde key there and that is probably the name I should use in the keymap file.

    Keep in mind that Commodore has 2 keys that always differs from ASCII/DIN -> english pound sign and ^ not meant as accent here but as to the power of.. like in 2^3 (two to the power of 3)

  • Thank you very much! The OSD display will help a lot.

    I think, I've found the problem of the circumflex key.

    It is the unshifted key left of the '1' key on GERMAN keyboards.

    ASCII keyboards have the backtick/tilde key there and that is probably the name I should use in the keymap file.

    Keep in mind that Commodore has 2 keys that always differs from ASCII/DIN -> english pound sign and ^ not meant as accent here but as to the power of.. like in 2^3 (two to the power of 3)

    I was workin on a positional mapping, not a symbolic mapping.

    So I don't care about the circumflex ^ itself.

    I just wanted to map the left most key in the numeric row to the Commodore/MEGA65 key in the left most position of the numeric row.

    On the MEGA65 the key is labelled as back arrow.

    ASCII PC keyboards have a backtick/Tilde label there.

    German keyboards have a circumflex/degree symbol there.

    So I wanted just, that that this key on the PC or MAC keyboard produces a backarrow.

    But it cannot be mapped alltogether in the keymap.cfg file. It remains dead.

  • Btw if you can find out some better Mac default, I can include that as the default. I have no Mac, so I cannot tell what is problematic or not there ...... The sight problem that included Xemu kbd mapping (for being a little more fun, hehe) is _not_ based on names like config files, but constants which are not the very same. Well yeah, SDL2 can be a kind of tricky sometimes ...

    Yes, it's tricky;) But I do my best and send you the MAC optimised keymap.cfg, when it's finished.

  • Btw if you can find out some better Mac default, I can include that as the default. I have no Mac, so I cannot tell what is problematic or not there ...... The sight problem that included Xemu kbd mapping (for being a little more fun, hehe) is _not_ based on names like config files, but constants which are not the very same. Well yeah, SDL2 can be a kind of tricky sometimes ...

    Yes, it's tricky;) But I do my best and send you the MAC optimised keymap.cfg, when it's finished.

    Yeah, and then I need to figure out the constant values for those names, what I meant :-O anyway, it should be OK to be extracted from the SDL2 source that way, in principle. I always thought this is a bit overcomplicated in SDL2 how it's handled. Anyway ...