Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ checkstyle = "13.3.0"
jacoco = "0.8.12"
lwjgl3 = "3.4.1"
angle = "2026-05-09"
libjglios = "0.6"
libjglios = "0.7"
saferalloc = "0.0.10"
nifty = "1.4.3"
spotbugs = "4.9.8"
Expand Down
30 changes: 8 additions & 22 deletions jme3-ios/src/main/java/com/jme3/input/ios/IosInputHandler.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.jme3.input.ios;

import com.jme3.input.RawInputListener;
import com.jme3.input.KeyInput;
import com.jme3.input.MouseInput;
import com.jme3.input.TouchInput;
import com.jme3.input.event.InputEvent;
Expand All @@ -15,6 +14,8 @@
import java.util.logging.Logger;
import org.ngengine.libjglios.core.LibJGLIOSInputBridge;

import static org.ngengine.libjglios.sdl3.SDL3.SDL_GetKeyFromScancode;

public class IosInputHandler implements TouchInput {
private static final Logger logger = Logger.getLogger(IosInputHandler.class.getName());

Expand Down Expand Up @@ -49,7 +50,7 @@ private int toJmeMouseButton(int sdlButton) {
}
private int width = 0;
private int height = 0;
private final int[] nativeIntData = new int[4];
private final int[] nativeIntData = new int[5];
private final float[] nativeFloatData = new float[4];

public IosInputHandler() {
Expand Down Expand Up @@ -277,27 +278,18 @@ void dispatchBridgeEvent(int[] intData, float[] floatData, long time) {
break;
case LibJGLIOSInputBridge.EVENT_KEY:
IosJoyInput.dispatchKeyboardInput();
int sdlKey = SDL_GetKeyFromScancode(intData[1], intData[4], true);
char keyChar = sdlKey > 0 && sdlKey <= Character.MAX_VALUE && !Character.isISOControl((char) sdlKey)
? (char) sdlKey
: '\0';
KeyInputEvent key = new KeyInputEvent(
IosSdlKeyMap.toJmeKeyCode(intData[1]),
'\0',
keyChar,
intData[2] != 0,
intData[3] != 0);
key.setTime(time);
addEvent(key);
break;
case LibJGLIOSInputBridge.EVENT_TEXT_INPUT:
if (!isSingleCharTextInput(intData[1])) {
break;
}
IosJoyInput.dispatchKeyboardInput();
KeyInputEvent text = new KeyInputEvent(
KeyInput.KEY_UNKNOWN,
(char) intData[1],
true,
false);
text.setTime(time);
addEvent(text);
break;
case LibJGLIOSInputBridge.EVENT_GAMEPAD_ADDED:
case LibJGLIOSInputBridge.EVENT_GAMEPAD_REMOVED:
case LibJGLIOSInputBridge.EVENT_GAMEPAD_AXIS:
Expand Down Expand Up @@ -352,10 +344,4 @@ private float mouseDeltaY(float value) {
private boolean isNormalized(float value) {
return value >= 0f && value <= 1f;
}

private boolean isSingleCharTextInput(int codePoint) {
return codePoint > 0
&& codePoint <= Character.MAX_VALUE
&& !Character.isSurrogate((char) codePoint);
}
}
39 changes: 7 additions & 32 deletions jme3-lwjgl3/src/main/java/com/jme3/input/lwjgl/SdlKeyInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ public void initialize() {
if (!context.isRenderable()) {
return;
}
// Text input events are delivered through SDL_EVENT_TEXT_INPUT.
SDL_StartTextInput(context.getWindowHandle());
initialized = true;
LOGGER.fine("SDL keyboard created.");
}
Expand All @@ -78,7 +76,8 @@ public void resetContext() {
if (!context.isRenderable()) {
return;
}
SDL_StartTextInput(context.getWindowHandle());
// nothing to do here

}

public void onSDLEvent(SDL_Event event) {
Expand All @@ -90,34 +89,13 @@ public void onSDLEvent(SDL_Event event) {
}

final int jmeKey = SdlKeyMap.toJmeKeyCode(key.scancode());
final KeyInputEvent keyEvent = new KeyInputEvent(jmeKey, '\0', key.down(), key.repeat());
final int sdlKey = SDL_GetKeyFromScancode(key.scancode(), key.mod(), true);
final char keyChar = sdlKey > 0 && sdlKey <= Character.MAX_VALUE && !Character.isISOControl((char) sdlKey)
? (char) sdlKey
: '\0';
final KeyInputEvent keyEvent = new KeyInputEvent(jmeKey, keyChar, key.down(), key.repeat());
keyEvent.setTime(key.timestamp());
keyInputEvents.add(keyEvent);
return;
}

if (type == SDL_EVENT_TEXT_INPUT) {
if (event.text().windowID() != context.getWindowId()) {
return;
}

final String text = event.text().textString();
if (text == null || text.isEmpty()) {
return;
}

for (int i = 0; i < text.length(); i++) {
final char keyChar = text.charAt(i);
final long time = event.text().timestamp();

KeyInputEvent pressed = new KeyInputEvent(KeyInput.KEY_UNKNOWN, keyChar, true, false);
pressed.setTime(time);
keyInputEvents.add(pressed);

KeyInputEvent released = new KeyInputEvent(KeyInput.KEY_UNKNOWN, keyChar, false, false);
released.setTime(time);
keyInputEvents.add(released);
}
}
}

Expand Down Expand Up @@ -146,9 +124,6 @@ public void update() {

@Override
public void destroy() {
if (context.isRenderable()) {
SDL_StopTextInput(context.getWindowHandle());
}
keyInputEvents.clear();
initialized = false;
LOGGER.fine("SDL keyboard destroyed.");
Expand Down
Loading