Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyPressedPreferNative: More performat key input #829

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Commits on Oct 15, 2024

  1. KeyPressedPreferNative: More performat key input

    On windows, `Gdx.input.isKeyPressed` uses lwjgl's event system
    for fetching key inputs. This event-based system sometimes
    lags due to OS issues, so beatoraja had problem getting key state
    ASAP. When pressing multiple keys, some keys were registered
    later than other keys.
    
    This commit fixes the issue by utilizing Windows's `GetAsyncKeyState`
    function for fetching current keyboard state itself. Note that this
    function will poll key state regardless of whether the window is
    focused or not, so this could be documented.
    
    Reference: previous libgdx input polling system (from LWJGL2)
    
    https://github.com/LWJGL/lwjgl/blob/master/src/java/org/lwjgl/opengl/WindowsKeyboard.java
    phu54321 committed Oct 15, 2024
    Configuration menu
    Copy the full SHA
    8fc25ce View commit details
    Browse the repository at this point in the history

Commits on Oct 21, 2024

  1. Configuration menu
    Copy the full SHA
    0bef0f0 View commit details
    Browse the repository at this point in the history

Commits on Oct 22, 2024

  1. perf(KeyPressedPreferNative): Use GetForegroundWindow instead of Disp…

    …lay.isActive()
    
    Display.isActive() requires a global lock on the display object, so it frequently stalls, resulting in less-than-optimal gaming experience.
    
    To make things lock-free, we again use JNA to implement `Display.isActive()` ourselves.
    
    Note that this code is coded for lwjgl2 backend the beatoraja currently uses. To maximize modularity, All input-specific code are
    confined in KeyPressedPreferNative class only.
    phu54321 committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    ced418f View commit details
    Browse the repository at this point in the history
  2. fix(KeyPressedPreferNative): Fix Alt+F4

    Alt+F4 should kill the application.
    phu54321 committed Oct 22, 2024
    Configuration menu
    Copy the full SHA
    07a460c View commit details
    Browse the repository at this point in the history

Commits on Oct 26, 2024

  1. perf(KeyPressedPreferNative): fix slow polling of fn keys

    Calling `Gdx.input.isKeyPressed` acquires lock of global some opengl mutex,
    so it takes quite a considerable amount of time.
    
    Filter out excessive calls with GetAsyncKeyState.
    phu54321 committed Oct 26, 2024
    Configuration menu
    Copy the full SHA
    af89460 View commit details
    Browse the repository at this point in the history
  2. perf(KeyPressedPreferNative): Replaced JNA with JNI inside lwjgls.

    lwjgl already has implemented multiple JNIs for Windows APIs we need.
    Since JNI is much faster than JNA, with a
    help of various reflection help we use those
    native methods instead of maintaining our own
    c++/java JNI build native systems.
    
    - Corollary: removed JNA dependencies
    phu54321 committed Oct 26, 2024
    Configuration menu
    Copy the full SHA
    a548fb9 View commit details
    Browse the repository at this point in the history