GoodSign2017 / mochadoom

A pure Java Doom source port
GNU General Public License v3.0
0 stars 1 forks source link

WASD movement by keyboard layout #2

Open Fabrice-leterme opened 7 years ago

Fabrice-leterme commented 7 years ago

WASD movement should change according to the keyboard layout,

for example WASD for me would be ZQSD.

GoodSign2017 commented 7 years ago

Hm... Can you express this in more detail please?

Try to include some of these clarifications:

Fabrice-leterme commented 7 years ago

download ![420px-romanian-keyboard-layout]

(https://cloud.githubusercontent.com/assets/2257439/25749153/d0c9fcfa-31ad-11e7-8535-076ae85c2d0d.png)

this is what I mean. other ports handle it pretty well

GoodSign2017 commented 7 years ago

Okay, so it is about physical layout. I got it, but it may take time to bear an idea how to implement it in Java.

There is one significant difference between Java and platforms targeted by other source ports. On native platforms, the application can operate on the keyboard directly or through a layer that operates directly, or through a system-specific API, that operates directly. As Java is ideally platform-independent, neither of the way available. It should be possible using native library, but this is not really Java way.

What Java allows to get is not raw keycode from keyboard, but a letter, or a digit, or a symbol and/or modifier(s) like shift, ctrl and so on. It does map it to some internal java-ish integer value, but it has absolutely no relation to position on the keyboard.

The current implementation done for compatibility with vanilla DOOM default.cfg is very tricky: it emulates a set of keycodes of standard DOS keyboard interface, based on what we can get from Java the most raw way possible.

I will think more about it. I think, there should be some way in Java to try to acquire the layout of physical keyboard. If I'll find that way, I may add precalculated tables for various layouts to map them to DOS key codes.