我正试着用java安装我的ds4控制器,然后和他一起做一些事情(是的,控制器是通过蓝牙连接的,我禁用了steam或ds4windows),但问题是:如果我尝试这样做:
for (int i = 0; i < Controllers.getControllers().size; i++) {
System.out.println(Controllers.getControllers().get(i).getName());
}
我只是得到一个错误:
Exception in thread "main" java.lang.IllegalArgumentException: key cannot be null.
at com.badlogic.gdx.utils.ObjectMap.locateKey(ObjectMap.java:128)
at com.badlogic.gdx.utils.ObjectMap.containsKey(ObjectMap.java:268)
at com.badlogic.gdx.controllers.Controllers.initialize(Controllers.java:84)
at com.badlogic.gdx.controllers.Controllers.getControllers(Controllers.java:48)
at de.Jan.Controller.DS4.<init>(DS4.java:38)
at de.Jan.Controller.DS4.main(DS4.java:44)
我的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven- 4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.Jan.Controller</groupId>
<artifactId>Controller</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/uk.co.electronstudio.sdl2gdx/sdl2gdx -->
<dependency>
<groupId>uk.co.electronstudio.sdl2gdx</groupId>
<artifactId>sdl2gdx</artifactId>
<version>1.0.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.badlogicgames.gdx/gdx-controllers -->
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-controllers</artifactId>
<version>1.9.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.badlogicgames.gdx/gdx -->
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx</artifactId>
<version>1.9.12</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jitpack.io</id> <!-- JitPack allows github repo to be used as a maven repo -->
<url>https://jitpack.io</url> <!-- For documentation: http://jitpack.io/ -->
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
为什么会出现这个错误?我需要额外的图书馆吗?
暂无答案!
目前还没有任何答案,快来回答吧!