Skip to content

Keyboard Mapping inconsistency between lwjgl2 and 3 #942

@MeFisto94

Description

@MeFisto94

This issue might need further testing because I think this was different on Windows than on the linux I am currently seeing this bug. It probably also only affects non-english people but certainly those with a german (QWERTZ) layout. The problem is that lwjgl3 doesn't seem to care about to local keyboard layout and treat it as if it was an us-layout causing confusion.

package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;

/**
 * Small Testcase for (at least) german keyboards: Behavior on "y" is different from lwjgl2 to lwjgl3 (3 doesn't seem
 * to respect the local keyboard mapping)
 * @author normenhansen
 */
public class Main extends SimpleApplication implements ActionListener {

    public static void main(String[] args) {
        Main app = new Main();
        app.start();
    }

    @Override
    public void simpleInitApp() {
        inputManager.addMapping("y", new KeyTrigger(KeyInput.KEY_Y));
        inputManager.addMapping("z", new KeyTrigger(KeyInput.KEY_Z));
        inputManager.addListener(this, "y", "z");
    }

    @Override
    public void onAction(String name, boolean isPressed, float tpf) {
        System.out.println(name + ": " + isPressed);
    }
}

Run this once with lwjgl2 and once with lwjgl3 and in 3 when you press y you actually see "z" printed and vice-versa.

For convenience I've added a slightly modified version of Stephens "BasicGame-on-Gradle" so that it works with the commandline, you just need to comment out lwjgl3 and execute ./gradlew run:
(Gradle doesn't automatically add run otherwise and the mainclass is also a different property)

apply plugin: 'java'
apply plugin: 'application'

// select one source-code option
//sourceCompatibility = '1.6'
//sourceCompatibility = '1.7'
sourceCompatibility = '1.8'

gradle.projectsEvaluated {
    tasks.withType(JavaCompile) {
        options.compilerArgs << '-Xdiags:verbose'
        options.compilerArgs << '-Xlint:unchecked'
        options.deprecation = true
        options.encoding = 'UTF-8'
    }
    tasks.withType(JavaExec) {
        args = []
        classpath sourceSets.main.runtimeClasspath
        //debug true
        enableAssertions true
        jvmArgs '-XX:+UseConcMarkSweepGC'
        //jvmArgs '-XX:+UseG1GC', '-XX:MaxGCPauseMillis=10'
    }
}

// select one version of the Engine
//ext.jmonkeyengineVersion = '3.1.0-stable' // from jcenter
//ext.jmonkeyengineVersion = '3.2.0-stable' // from jcenter
ext.jmonkeyengineVersion = '3.2.1-stable' // from jcenter
//ext.jmonkeyengineVersion = '3.2.1-SNAPSHOT' // from mavenLocal

// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
    mainClassName = 'mygame.Main'
}

repositories {
    //mavenLocal()
    jcenter()
    //maven { url 'http://nifty-gui.sourceforge.net/nifty-maven-repo' }
    //maven { url 'https://dl.bintray.com/stephengold/org.jmonkeyengine' }
    //google()
    //mavenCentral()
    // Read more about repositories here:
    //   https://docs.gradle.org/current/userguide/dependency_management.html#sec:repositories
}

dependencies {
    // You can read more about how to add dependencies here:
    //   https://docs.gradle.org/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies

    // from jcenter (or mavenLocal) repositories:
    compile "org.jmonkeyengine:jme3-core:$jmonkeyengineVersion"
    runtime "org.jmonkeyengine:jme3-blender:$jmonkeyengineVersion"
    //compile "org.jmonkeyengine:jme3-bullet:$jmonkeyengineVersion"
    //runtime "org.jmonkeyengine:jme3-bullet-native:$jmonkeyengineVersion"
    runtime "org.jmonkeyengine:jme3-desktop:$jmonkeyengineVersion"
    //compile "org.jmonkeyengine:jme3-effects:$jmonkeyengineVersion"
    //runtime "org.jmonkeyengine:jme3-jogg:$jmonkeyengineVersion"
    //compile "org.jmonkeyengine:jme3-jogl:$jmonkeyengineVersion"
    //compile "org.jmonkeyengine:jme3-networking:$jmonkeyengineVersion"
    //compile "org.jmonkeyengine:jme3-niftygui:$jmonkeyengineVersion"
    runtime "org.jmonkeyengine:jme3-plugins:$jmonkeyengineVersion"
    //compile "org.jmonkeyengine:jme3-terrain:$jmonkeyengineVersion"

    // select one version of LWJGL (from jcenter or mavenLocal)
    //runtime "org.jmonkeyengine:jme3-lwjgl:$jmonkeyengineVersion"
    runtime "org.jmonkeyengine:jme3-lwjgl3:$jmonkeyengineVersion"

    // from stephengold's bintray repositories:
    //runtime 'org.jmonkeyengine:jme3-testdata:3.1.0-stable'
}

// cleanup tasks
clean { dependsOn 'cleanDLLs', 'cleanSOs' }
task cleanDLLs(type: Delete) {
    delete fileTree(dir: '.', include: '*.dll')
}
task cleanSOs(type: Delete) {
    delete fileTree(dir: '.', include: '*.so')
}

I am not sure if this issue isn't within lwjgl3 itself though or rather our "configuration". Maybe it's also already fixed upstream and we just need a newer version

Metadata

Metadata

Assignees

No one assigned

    Labels

    Contribution welcomebugSomething that is supposed to work, but doesn't. More severe than a "defect".

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions