Giter Site home page Giter Site logo

keyboard mapping about virtualc64web HOT 18 CLOSED

vc64web avatar vc64web commented on May 27, 2024
keyboard mapping

from virtualc64web.

Comments (18)

dirkwhoffmann avatar dirkwhoffmann commented on May 27, 2024 2

problem 3: well this one we could repair ... should we ?

Yes, yes, yes. Having Y and Z switched is the most annoying thing in most C64 emulators.

VC64mac distinguishes between symbolic and positional key mapping. In symbolic mapping, key characters are evaluated ("Y") whereas in positional mapping, key codes are evaluated (#XXX). Symbolic mapping is more important than positional mapping (and the default in VC64mac). I think this should be supported. For everything else, there is the virtual keyboard.

from virtualc64web.

mithrendal avatar mithrendal commented on May 27, 2024

keyboard test prg 😎
https://csdb.dk/release/?id=98411

virtualc64web test result firefox mac german keyboard ....
grafik

gray keys are not yet reachable ... that is you can not type them by any combination of keys ... effectively unmappedπŸ™Š

from virtualc64web.

mithrendal avatar mithrendal commented on May 27, 2024

virtualc64web test result iOS safari german keyboard (brand: Anker....)

DA8E83A6-1FF7-4148-A275-54D2013BBFB3

problem 1: the anker bluetooth keyboard does not emit a keydown for the function keys in safari iOS
problem 2: some keys are not reachable in macOS and iOS
problem 3: keys are mapped according to their position on the 64 keyboard ... that makes Y and Z swapped

from virtualc64web.

dirkwhoffmann avatar dirkwhoffmann commented on May 27, 2024

VirtualC64web needs a virtual keyboard 😎.

from virtualc64web.

mithrendal avatar mithrendal commented on May 27, 2024

yes I see it too and iOS needs a touch screen based joystick emulation ...😎 tons off work though ... but if we make it clever then we can reuse all the stuff we have yet to implement when we make the vAmigaweb edition ...

from virtualc64web.

mithrendal avatar mithrendal commented on May 27, 2024

there are some on the web ...

this one is huge ... over 100 kb ... too big for my taste ...
https://mottie.github.io/Keyboard/

this tiny one here is nice ... only 14 kb ... maybe a candidate ?
https://github.com/mBut/jquery.mlkeyboard/

And a bootstrap3.3 conversation of it here https://github.com/eamigo86/jquery.keyboard

or we can do on our own one ...

from virtualc64web.

dirkwhoffmann avatar dirkwhoffmann commented on May 27, 2024

this tiny one here is nice ... maybe a candidate ?

Yes, that one is very nice πŸ₯°. Hopefully, it's easy to change it into a C64 keyboard, but I guess the code isn't too complicated.

from virtualc64web.

mithrendal avatar mithrendal commented on May 27, 2024

I played with some virtual keyboards. Some are nice. Based on your good experience in developing an own Moira CPU core instead of taking the musashi. I decided to develop our own keyboard now. From the ground up. The goal is the same ...it should give us the best user experience regardless which device will be used. 🀀

from virtualc64web.

mithrendal avatar mithrendal commented on May 27, 2024

BADC3EC0-4ACC-45D2-B6E6-99FC2C8F127C

On restore the core complains with an assertion πŸ™‰ and stops working

@dirkwhoffmann do you have an idea whats wrong with pressing restore?

the commodore key are right shift is still unmapped πŸ™ˆ

All other keys are working with vc64webs brand new toy β€žthe handcrafted virtual keyboardβ€œ short HVK. 😎

On small devices (like iphone portrait mode) the keyboard turns automatically into a scrollable β€žtouchbarβ€œ This way the keys stay still big enough to read and type on...

On large screens it centers automatically and scrolling is gone.

Published to https://dirkwhoffmann.github.io/virtualc64web/

One more thing... the keyboard supports
light and darkmode 🀀

from virtualc64web.

mithrendal avatar mithrendal commented on May 27, 2024

grafik

the commodore key was easy ... it was just an mapping error

only left ... the following two problematic keys ...

right shift - how what are the correct two key codes ?
restore - gives the following

wasm_key ( 9, 9, 1 ) 
Assertion failed: row < 8, at: C64/Computer/Keyboard.cpp,129,pressKey

is the key code 9,9 wrong ? It is the second last in the following code

       // Second physical key row
            [7, 2], [7, 6], [1, 1], [1, 6], [2, 1], [2, 6], [3, 1], [3, 6],
            [4, 1], [4, 6], [5, 1], [5, 6], [6, 1], [6, 6], [9, 9], [0, 5] /* f3 */,

I copied that code from the mac version ... and translated it into javascript ... file is vC64keymap.js

from virtualc64web.

dirkwhoffmann avatar dirkwhoffmann commented on May 27, 2024

is the key code 9,9 wrong ? It is the second last in the following code

It purposely produces an assertion failure to prevent anybody from trying to translate Restore to a key code πŸ˜…. Thing is, the restore key does not have a key code. This key is directly bound to the NMI line of the processor. You need to call a special API method to press it:

//! @brief    Presses the restore key.
 void pressRestoreKey();

Key codes of both shift keys are here:

//! @brief    Checks if the shift lock key is held down.
bool shiftLockIsHoldDown() { return shiftLock; }

//! @brief    Checks if the left shift key is currently pressed.
bool leftShiftIsPressed() { return keyIsPressed(1,7); }

//! @brief    Checks if the right shift key is currently pressed.
bool rightShiftIsPressed() { return keyIsPressed(6,4); }

from virtualc64web.

dirkwhoffmann avatar dirkwhoffmann commented on May 27, 2024

BTW, I like the idea of implementing the virtual keyboard from ground up.

from virtualc64web.

mithrendal avatar mithrendal commented on May 27, 2024

grafik

HVK (handcrafted virtual keyboard passed all tests now) πŸ˜ŽπŸ‘πŸΏ

from virtualc64web.

mithrendal avatar mithrendal commented on May 27, 2024

lets review the problems ...

problem 1: the anker bluetooth keyboard does not emit a keydown for the function keys in safari iOS
problem 2: some keys are not reachable in macOS and iOS
problem 3: keys are mapped according to their position on the 64 keyboard ... that makes Y and Z swapped

problem 1 -- one picture says it all I think
grafik

they just dont like function keys .... the virtual keyboard heals this

problem 2: see the cmd key desaster https://github.com/dirkwhoffmann/virtualc64web/issues/32 ... the virtual keyboard heals this

problem 3: well this one we could repair ... should we ?

from virtualc64web.

mithrendal avatar mithrendal commented on May 27, 2024

I did set up a symbolic key map in vC64keymap.js, which has priority over positional mapping ...

function translateKey(keycode, key)
{
    console.log('keycode='+keycode + ', key='+key);
    var mapindex;
    var sym_key = symbolic_map[key];
    if(sym_key!== undefined)
    {//if there is a symbolic mapping ... use it instead of the positional mapping
        mapindex=key_translation_map[ sym_key ];
    } 
    else
    {//when there is no symbolic mapping fall back to positional mapping
        mapindex=key_translation_map[ keycode ];
    }
    c64code=c64keymap[mapindex];
    return c64code;
}

symbolic_map = {
    z: 'KeyZ',
    y: 'KeyY'
}

only two keys are in it ... we could add more ... Is this the way to go ? Or do you mean a setting in a config panel which toggles between symbolic and positional mapping ?

pushed to gh-pages 😎

from virtualc64web.

dirkwhoffmann avatar dirkwhoffmann commented on May 27, 2024

Is this the way to go ?

Yes, I think this is a fruitful approach. You might want to add keys such as "!","(",")" etc. These keys need a more sophisticated translation though, because they require to press the C64 shift key as well.

from virtualc64web.

mithrendal avatar mithrendal commented on May 27, 2024

Ok now I see ... when I ported
https://github.com/dirkwhoffmann/virtualc64/blob/master/OSX/MacGUI/C64Key.swift
to javascript some weeks ago I wasn't carefully and rushed through it ... in order to get quick results ... so I missed out this function

  // Translates a character to a list of corresponding C64 keys
    // This function is used for symbolically mapping Mac keys to C64 keys
    static func translate(char: String?) -> [C64Key] {
        
        if char == nil { return [] }
        
        switch char! {
            
        // First row of C64 keyboard
        case "ΓΌ": return [C64Key.leftArrow]
        case "1": return [C64Key.digit1]
        case "!": return [C64Key.digit1, C64Key.shift]

I have to carefully redo the porting of this swift class to javascript ...

from virtualc64web.

mithrendal avatar mithrendal commented on May 27, 2024

I think I finished the symbolic mapping ... I ported the translate function ... Maybe it would be wise in a later version to use the c++ version instead of porting ...

from virtualc64web.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.