Support libgdx 1.9.14

This commit is contained in:
Izumi Kawashima 2022-11-23 23:36:23 +09:00
parent 559f71246d
commit d7bfc2643d
4 changed files with 85 additions and 4 deletions

View File

@ -6,7 +6,7 @@ allprojects {
group = 'org.mapsforge'
version = 'master-SNAPSHOT'
ext.gdxVersion = "1.9.13"
ext.gdxVersion = "1.9.14"
ext.gwtVersion = "2.8.2"
ext.slf4jVersion = "1.7.28"

View File

@ -53,10 +53,73 @@ public class DefaultGwtInput implements Input {
long currentEventTimeStamp;
final CanvasElement canvas;
boolean hasFocus = true;
final GwtApplicationConfiguration config;
GwtAccelerometer accelerometer;
GwtGyroscope gyroscope;
public DefaultGwtInput(CanvasElement canvas) {
public DefaultGwtInput(CanvasElement canvas, GwtApplicationConfiguration config) {
this.canvas = canvas;
this.config = config;
if (config.useAccelerometer && GwtFeaturePolicy.allowsFeature(GwtAccelerometer.PERMISSION)) {
if (GwtApplication.agentInfo().isFirefox()) {
setupAccelerometer();
} else {
GwtPermissions.queryPermission(GwtAccelerometer.PERMISSION, new GwtPermissions.GwtPermissionResult() {
@Override
public void granted() {
setupAccelerometer();
}
@Override
public void denied() {
}
@Override
public void prompt() {
setupAccelerometer();
}
});
}
}
if (config.useGyroscope) {
if (GwtApplication.agentInfo().isFirefox()) {
setupGyroscope();
} else {
GwtPermissions.queryPermission(GwtGyroscope.PERMISSION, new GwtPermissions.GwtPermissionResult() {
@Override
public void granted() {
setupGyroscope();
}
@Override
public void denied() {
}
@Override
public void prompt() {
setupGyroscope();
}
});
}
}
hookEvents();
// backwards compatibility: backspace was caught in older versions
setCatchKey(Keys.BACKSPACE, true);
}
void setupAccelerometer () {
if (GwtAccelerometer.isSupported() && GwtFeaturePolicy.allowsFeature(GwtAccelerometer.PERMISSION)) {
if (accelerometer == null) accelerometer = GwtAccelerometer.getInstance();
if (!accelerometer.activated()) accelerometer.start();
}
}
void setupGyroscope () {
if (GwtGyroscope.isSupported() && GwtFeaturePolicy.allowsFeature(GwtGyroscope.PERMISSION)) {
if (gyroscope == null) gyroscope = GwtGyroscope.getInstance();
if (!gyroscope.activated()) gyroscope.start();
}
}
public void reset() {

View File

@ -179,12 +179,12 @@ public abstract class GwtApplication implements EntryPoint, Application {
lastWidth = graphics.getWidth();
lastHeight = graphics.getHeight();
Gdx.app = this;
Gdx.audio = new DefaultGwtAudio();
Gdx.audio = createAudio();
Gdx.graphics = graphics;
Gdx.gl20 = graphics.getGL20();
Gdx.gl = Gdx.gl20;
Gdx.files = new GwtFiles(preloader);
this.input = new DefaultGwtInput(graphics.canvas);
this.input = createInput(graphics.canvas, this.config);
Gdx.input = this.input;
this.net = new GwtNet(config);
Gdx.net = this.net;
@ -597,6 +597,14 @@ public abstract class GwtApplication implements EntryPoint, Application {
}
}
protected GwtAudio createAudio() {
return new DefaultGwtAudio();
}
protected DefaultGwtInput createInput(CanvasElement canvas, GwtApplicationConfiguration config) {
return new DefaultGwtInput(canvas, config);
}
/**
* LoadingListener interface main purpose is to do some things before or after {@link GwtApplication#setupLoop()}
*/

View File

@ -184,6 +184,11 @@ public class GwtGraphics implements Graphics {
return canvas.getHeight();
}
@Override
public float getBackBufferScale() {
return 0;
}
@Override
public int getSafeInsetLeft() {
return 0;
@ -537,6 +542,11 @@ public class GwtGraphics implements Graphics {
public void setVSync(boolean vsync) {
}
@Override
public void setForegroundFPS(int fps) {
}
@Override
public float getDensity() {
return 96.0f / 160;