Adds support for Android

This commit is contained in:
Markil3
2020-12-18 17:14:16 -07:00
parent 8a6487f3bb
commit 126a2e844d
32 changed files with 599 additions and 34 deletions

1
android/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

57
android/build.gradle Normal file
View File

@@ -0,0 +1,57 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
}
}
apply plugin: 'com.android.application'
repositories {
jcenter()
google()
}
android {
compileSdkVersion 29
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "markil3.controller"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
api(project(":desktop")) {
exclude module: "jme3-lwjgl3"
exclude module: "jme3-desktop"
exclude module: "slf4j-simple"
}
implementation "uk.uuid.slf4j:slf4j-android:1.7.30-0"
implementation "${jme3.g}:jme3-android:${jme3.version}"
implementation "${jme3.g}:jme3-android-native:${jme3.version}"
implementation "androidx.appcompat:appcompat:1.1.0"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.0.9"
}

21
android/proguard-rules.pro vendored Normal file
View File

@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -0,0 +1,28 @@
package markil3.controller;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest
{
@Test
public void useAppContext()
{
// Context of the app under test.
Context appContext =
InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("markil3.jmecontrollerconfig", appContext.getPackageName());
}
}

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="markil3.jmecontrollerconfig">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.JMEControllerConfig">
<activity
android:name="markil3.controller.MainActivity"
android:configChanges="screenSize|orientation|screenLayout|navigation"
android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,73 @@
package markil3.controller;
import android.content.res.Configuration;
import android.os.Bundle;
import com.jme3.app.AndroidHarness;
import com.jme3.system.AppSettings;
import java.util.logging.Level;
import java.util.logging.LogManager;
public class MainActivity extends AndroidHarness
{
/*
* Note that you can ignore the errors displayed in this file, the android
* project will build regardless. Install the 'Android' plugin under
* Tools->Plugins->Available Plugins to get error checks and code completion
* for the Android project files.
*/
public MainActivity()
{
/*
* Set the default logging level (default=Level.INFO, Level.ALL=All
* Debug Info)
*/
LogManager.getLogManager().getLogger("").setLevel(Level.INFO);
this.appClass = Main.class.getName();
// Set the desired EGL configuration
eglBitsPerPixel = 24;
eglAlphaBits = 0;
eglDepthBits = 16;
eglSamples = 0;
eglStencilBits = 0;
// Set the maximum framerate
// (default = -1 for unlimited)
frameRate = -1;
// Set the maximum resolution dimension
// (the smaller side, height or width, is set automatically
// to maintain the original device screen aspect ratio)
// (default = -1 to match device screen resolution)
// maxResolutionDimension = -1;
// Set input configuration settings
joystickEventsEnabled = true;
keyEventsEnabled = true;
mouseEventsEnabled = true;
// Set application exit settings
finishOnAppStop = true;
handleExitHook = false;
exitDialogTitle = "Do you want to exit?";
exitDialogMessage =
"Use your home key to bring this app into the background " +
"or exit to terminate it.";
// Set splash screen resource id, if used
// (default = 0, no splash screen)
// For example, if the image file name is "splash"...
// splashPicID = R.drawable.splash;
splashPicID = 0;
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
this.setImmersive(true);
}
}

View File

@@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

View File

@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1,10 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.JMEControllerConfig" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryDark">@color/purple_700</item>
<item name="colorAccent">@color/teal_200</item>
<!-- Customize your theme here. -->
</style>
</resources>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>

View File

@@ -0,0 +1,3 @@
<resources>
<string name="app_name">JMEControllerConfig</string>
</resources>

View File

@@ -0,0 +1,10 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.JMEControllerConfig" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryDark">@color/purple_700</item>
<item name="colorAccent">@color/teal_200</item>
<!-- Customize your theme here. -->
</style>
</resources>

View File

@@ -0,0 +1,19 @@
package markil3.controller;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest
{
@Test
public void addition_isCorrect()
{
assertEquals(4, 2 + 2);
}
}

View File

@@ -160,18 +160,38 @@ public class Main extends SimpleApplication implements ActionListener
@Override
public void initialize()
{
final File[] possibleGameDirs =
new File[]{new File(System.getProperty("user.dir")),
new File(System.getProperty("user.home")),
JmeSystem.getStorageFolder(
JmeSystem.StorageFolderType.External)};
int i, l;
if (GAME_FOLDER == null)
{
GAME_FOLDER = new File(System.getProperty("user.dir"));
for (i = 0, l = possibleGameDirs.length; i < l; i++)
{
GAME_FOLDER = possibleGameDirs[i];
if (!GAME_FOLDER.isDirectory())
{
if (!GAME_FOLDER.mkdir())
{
logger.warn("Cannot make " + GAME_FOLDER);
continue;
}
}
if (!GAME_FOLDER.canWrite())
{
logger.warn("Cannot write to " + GAME_FOLDER);
continue;
}
break;
}
if (i == l)
{
throw new RuntimeException(
"Could not create game directory folder.");
}
}
}
/*
* Add custom joystick mappings before the input manager is loaded.
*/
@@ -184,19 +204,23 @@ public class Main extends SimpleApplication implements ActionListener
{
this.calibrateButton =
GUIUtils.createButton(this.getAssetManager(), this.guiFont,
"calibrate", "Calibrate Gamepad");
this.calibrateButton.setLocalTranslation((this.getCamera().getWidth() -
((BitmapText) this.calibrateButton.getChild(1)).getLineWidth() -
10) / 2F, this.getCamera().getHeight(), 0);
this.getContext().getTouchInput() != null, "calibrate",
"Calibrate Gamepad");
}
@Override
public void simpleUpdate(float tpf)
{
JoystickPreviewScreen screen = this.getStateManager().getState(JoystickPreviewScreen.class);
JoystickPreviewScreen screen =
this.getStateManager().getState(JoystickPreviewScreen.class);
if (this.calibrateButton.getParent() == null && screen != null)
{
this.guiNode.attachChild(this.calibrateButton);
this.calibrateButton.setLocalTranslation(
(this.getCamera().getWidth() -
((BitmapText) this.calibrateButton.getChild(1))
.getLineWidth() - 10) / 2F,
this.getCamera().getHeight(), 0);
this.inputManager.addListener(this, screen.CLICK_MAPPING);
}
else if (this.calibrateButton.getParent() != null && screen == null)
@@ -210,17 +234,43 @@ public class Main extends SimpleApplication implements ActionListener
public void onAction(String name, boolean isPressed, float tpf)
{
String buttonId;
JoystickPreviewScreen screen = this.getStateManager().getState(JoystickPreviewScreen.class);
JoystickPreviewScreen screen =
this.getStateManager().getState(JoystickPreviewScreen.class);
if (screen != null && name.equals(screen.CLICK_MAPPING))
{
buttonId = GUIUtils.handleButtonPress(this.calibrateButton,
this.getInputManager().getCursorPosition(),
isPressed);
this.getInputManager().getCursorPosition(), isPressed);
if (!isPressed && "calibrate".equals(buttonId))
{
this.getStateManager().detach(screen);
this.getStateManager().attach(new CalibrateInputScreen(CALIBRATION_FILE));
this.getStateManager()
.attach(new CalibrateInputScreen(CALIBRATION_FILE));
}
}
}
@Override
public void restart()
{
super.restart();
this.enqueue(() -> {
JoystickPreviewScreen previewScreen = this.getStateManager()
.getState(JoystickPreviewScreen.class);
CalibrateInputScreen calibrateScreen =
this.getStateManager().getState(CalibrateInputScreen.class);
if (previewScreen != null)
{
previewScreen.resize();
}
if (calibrateScreen != null)
{
calibrateScreen.resize();
}
this.calibrateButton.setLocalTranslation(
(this.getCamera().getWidth() -
((BitmapText) this.calibrateButton.getChild(1))
.getLineWidth() - 10) / 2F,
this.getCamera().getHeight(), 0);
});
}
}

15
gradle.properties Normal file
View File

@@ -0,0 +1,15 @@
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Fri Dec 18 13:35:19 MST 2020
android.enableJetifier=true
android.useAndroidX=true

View File

@@ -181,7 +181,7 @@ public class CalibrateInputScreen extends BaseAppState
this.introCont.attachChild(text);
this.startButton =
GUIUtils.createButton(app.getAssetManager(), this.guiFont,
GUIUtils.createButton(app.getAssetManager(), this.guiFont, app.getContext().getTouchInput() != null,
"start", "Start");
// this.startButton.addClickCommands(this);
this.introCont.attachChild(this.startButton);
@@ -193,16 +193,16 @@ public class CalibrateInputScreen extends BaseAppState
"on the controller you want to calibrate."));
this.skipButton =
GUIUtils.createButton(app.getAssetManager(), this.guiFont,
GUIUtils.createButton(app.getAssetManager(), this.guiFont, app.getContext().getTouchInput() != null,
"skip", "Skip");
this.cancelButton =
GUIUtils.createButton(app.getAssetManager(), this.guiFont,
GUIUtils.createButton(app.getAssetManager(), this.guiFont, app.getContext().getTouchInput() != null,
"cancel", "Cancel");
this.introCont.attachChild(this.cancelButton);
this.restartButton =
GUIUtils.createButton(app.getAssetManager(), this.guiFont,
GUIUtils.createButton(app.getAssetManager(), this.guiFont, app.getContext().getTouchInput() != null,
"close", "Close Application");
this.gui.attachChild(this.introCont);

View File

@@ -42,18 +42,24 @@ public class GUIUtils
* to trigger events.
* @param assets - The application asset manager.
* @param guiFont - The font to use for the button.
* @param isMobile - Whether or not the mobile size increase should be used.
* @param id - The button ID. This is used to identify which button was
* pressed later on.
* @param content - The text that will display in the button.
* @return A node containing the button elements.
*/
public static Node createButton(AssetManager assets, BitmapFont guiFont,
String id, String content)
boolean isMobile, String id, String content)
{
final float MOBILE_SIZE = 30F;
BitmapText buttonText;
Geometry buttonBackground;
Node button = new Node();
buttonText = guiFont.createLabel(content);
if (isMobile)
{
buttonText.setSize(MOBILE_SIZE);
}
buttonText.setUserData(BUTTON_ID, id);
buttonText.setBox(new Rectangle(0, 0, buttonText.getLineWidth(),
buttonText.getLineHeight()));
@@ -78,7 +84,7 @@ public class GUIUtils
/**
* Call this method from a mouse listener to search the provided node for
* any buttons created with
* {@link #createButton(AssetManager, BitmapFont, String, String)} and
* {@link #createButton(AssetManager, BitmapFont, boolean, String, String)} and
* returns their ID.
* @param gui - The GUI to search.
* @param cursor - The position of the mouse cursor.
@@ -112,7 +118,7 @@ public class GUIUtils
results = new CollisionResults();
ray = new Ray(new Vector3f(cursor.x, cursor.y, 0),
new Vector3f(cursor.x, cursor.y, 1));
new Vector3f(0, 0, 1));
gui.collideWith(ray, results);
for (CollisionResult result : results)
{

View File

@@ -689,6 +689,7 @@ public class JoystickPreviewScreen extends BaseAppState
{
this.gamepadHeaders[i] = GUIUtils.createButton(
this.getApplication().getAssetManager(), this.guiFont,
this.getApplication().getContext().getTouchInput() != null,
"gamepad" + i, "Gamepad " +
this.getApplication().getInputManager()
.getJoysticks()[i].getJoyId());
@@ -741,6 +742,7 @@ public class JoystickPreviewScreen extends BaseAppState
*/
private void setLabels(Joystick joy)
{
int offset = this.getApplication().getContext().getTouchInput() != null ? 10: 0;
/*
* Removes the old labels.
*/
@@ -761,9 +763,11 @@ public class JoystickPreviewScreen extends BaseAppState
/*
* The name of the gamepad.
*/
this.labels[joy.getJoyId()][0] = this.guiFont.createLabel(
"Gamepad " + joy.getJoyId() + ": " + joy.getName());
this.labels[joy.getJoyId()][0].setLocalTranslation(20, -25, 0);
// this.labels[joy.getJoyId()][0] = this.guiFont.createLabel(
// "Gamepad " + joy.getJoyId() + ": " + joy.getName());
this.labels[joy.getJoyId()][0] =
this.guiFont.createLabel(joy.getName());
this.labels[joy.getJoyId()][0].setLocalTranslation(20, -25 - offset, 0);
this.gamepadCont[joy.getJoyId()]
.attachChild(this.labels[joy.getJoyId()][0]);
/*
@@ -771,11 +775,12 @@ public class JoystickPreviewScreen extends BaseAppState
* index of the axis, its given name, its logical ID after
* joystick remapping has occurred, and the axis index again.
* TODO - Whenever I add the " Gamepad X: " part to the previous
* label, this one displays all funky.
* label, this one displays all funky. Also, the lag gets really
* bad.
*/
this.labels[joy.getJoyId()][1] = this.guiFont
.createLabel("Axis Index: Axis Name (logical ID, axis ID)");
this.labels[joy.getJoyId()][1].setLocalTranslation(20, -50, 0);
this.labels[joy.getJoyId()][1].setLocalTranslation(20, -50 - offset, 0);
this.gamepadCont[joy.getJoyId()]
.attachChild(this.labels[joy.getJoyId()][1]);
/*
@@ -793,7 +798,7 @@ public class JoystickPreviewScreen extends BaseAppState
(i) + ": " + axis.getName() + " (" +
axis.getLogicalId() + ", " +
axis.getAxisId() + "): ");
label.setLocalTranslation(20, -25 * (i + 3), 0);
label.setLocalTranslation(20, -25 * (i + 3) - offset, 0);
this.labels[joy.getJoyId()][i * 2 + 1] = label;
/*
@@ -835,7 +840,7 @@ public class JoystickPreviewScreen extends BaseAppState
this.labels[joy.getJoyId()][firstButtonIndex].setLocalTranslation(
this.getScreenSize().x -
this.labels[joy.getJoyId()][firstButtonIndex]
.getLineWidth(), -50, 0);
.getLineWidth(), -50 - offset, 0);
this.gamepadCont[joy.getJoyId()]
.attachChild(this.labels[joy.getJoyId()][firstButtonIndex]);
@@ -855,7 +860,7 @@ public class JoystickPreviewScreen extends BaseAppState
BitmapText label2 = this.guiFont.createLabel("false");
label2.setLocalTranslation(
this.getScreenSize().x - label2.getLineWidth(),
-25 * (i + 3), 0);
-25 * (i + 3) - offset, 0);
/*
* The name and information for the button.
@@ -914,7 +919,7 @@ public class JoystickPreviewScreen extends BaseAppState
for (int i = 0, l = this.gamepadHeaders.length; i < l; i++)
{
button = this.gamepadHeaders[i];
button.setLocalTranslation(128 * i, 0, 0);
button.setLocalTranslation((this.getApplication().getContext().getTouchInput() != null ? 192 : 128) * i, 0, 0);
}
}
if (this.gamepadView != null)

View File

@@ -7,6 +7,7 @@
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user guide at https://docs.gradle.org/4.4.1/userguide/multi_project_builds.html
*/
include ':jmecontrollerconfig'
/*
// To declare projects as part of a multi-project build use the 'include' method
@@ -19,3 +20,4 @@ rootProject.name = 'JMEControllerConfig'
include "library"
include "desktop"
include "desktopLegacy"
include "android"