简体   繁体   English

J 在树莓派上输入

[英]JInput on RaspberryPi

I am trying to get JInput working on a raspeberryPi.我正在尝试让 JInput 在 raspeberryPi 上工作。 I know it is not ideal to use JInput without an ide, but the Raspberry Pi is too slow to work with most of them.我知道在没有 ide 的情况下使用 JInput 并不理想,但 Raspberry Pi 的速度太慢,无法与其中的大多数一起使用。 I have managed to sucessfully compile and run my program from the command line on windows. However, on the pi i am having trouble.我已经成功地从 windows 上的命令行编译并运行了我的程序。但是,在 pi 上我遇到了麻烦。 The pi is running raspbian, java version 1.7.0_40 with hotspot client vm build 24.0-b56. pi 正在运行 raspbian,java 版本 1.7.0_40,热点客户端 vm build 24.0-b56。 I have set up the file structure as so:我已经将文件结构设置为:

lib/dist库/分区
-jinput-test.jar -jinput-test.jar
-jinput.jar -jinput.jar
-Controller -控制器
--.dll, .so files --.dll,.so文件
--LinuxEnvironmentPlugin.java --Linux环境插件.java
bin垃圾桶
src来源

I am using the command我正在使用命令

java -Djava.library.path=lib/dist/Controller -Djinput.plugins=net.java.games.input.LinuxEnvironmentPlugin -cp bin:lib/dist/jinput.jar:lib/dist/Controller Main

to try and run.尝试运行。

However, i get但是,我得到

"INFO: Failed to load library:" /libjinput-linux64.so: /libjinput-linux64.so: wrong ELF class: ELFCLASSS64" “信息:无法加载库:”/libjinput-linux64.so:/libjinput-linux64.so:错误的 ELF class:ELFCLASSS64”

This is where I am confused.这就是我感到困惑的地方。 Why is it trying to use the 64 bit file.为什么要尝试使用 64 位文件。 The rasperry Pi has a ARM version 6 processor, which only works with 32 bit.树莓派有一个 ARM 版本 6 处理器,它只适用于 32 位。 So why is it looking for the 64 bit file in the first place?那么为什么它首先要寻找 64 位文件呢? I have also tried running with the -d32 option but that doesn't help.我也尝试过使用 -d32 选项运行,但这没有帮助。

You need a native shared library (JNI) built for the Pi (ARM). 您需要为Pi(ARM)构建的本机共享库(JNI)。 Fortunately, there are pre-built raspbian packages for JInput that include the required native library: 幸运的是,有一些针对JInput的预先构建的raspbian软件包,其中包括所需的本机库:

  • sudo apt-get install libjinput-java libjinput-java-doc libjinput-jni 须藤apt-get install libjinput-java libjinput-java-doc libjinput-jni

You should also add uinput to the end of /etc/modules so the controller gets detected. 您还应该在/ etc / modules的末尾添加uinput,以便检测到控制器。 If you want a nice GUI to test the controller try also installing: 如果您想要一个好的GUI来测试控制器,请尝试另外安装:

  • sudo apt-get install jstest-gtk 须藤apt-get install jstest-gtk

you can instal Jinput by 您可以通过安装Jinput

  • sudo apt-get install libjinput-java libjinput-java-doc libjinput-jni 须藤apt-get install libjinput-java libjinput-java-doc libjinput-jni

then find these file on your raspberry pi after installation 然后在安装后在树莓派上找到这些文件

  • jinput-20100502.jar jinput-20100502.jar
  • jinput.jar jinput.jar
  • jinput-test.jar jinput-Test.jar的
  • libjinput-linux.so libjinput-linux.so
  • libjinput.so libjinput.so

make a new directory called (let's say) lib in your working directory (a you can name it as you wish) copy all the files above to the directory lib you just made. 在您的工作目录(可以随意命名)中创建一个名为(例如)lib的新目录,将上述所有文件复制到您刚才创建的目录lib中。 then compile the java file by this way : 然后通过这种方式编译java文件:

  • sudo javac -cp "/usr/share/java/jinput.jar" Example.java sudo javac -cp“ /usr/share/java/jinput.jar” Example.java

then run it by this way : 然后通过这种方式运行它:

  • sudo java -Djava.library.path=./lib -cp ./lib/*:. 须藤java -Djava.library.path =。/ lib -cp ./lib/* :. Example

if you make the Example.java from netbeans, remove the package info line at the top. 如果从netbeans中创建Example.java,请删除顶部的软件包信息行。 it should work. 它应该工作。

• Implemented a workaround. • 实施变通办法。
• Wanted to implement joystick jogging on my Raspberry Pi, Processing3 GUI on a Grbl CNC machine, but hit the JInput <==> ARM incompatibility. • 想在我的 Raspberry Pi 上实现操纵杆慢跑,在 Grbl CNC 机器上实现 Processing3 GUI,但遇到了 JInput <==> ARM 不兼容问题。 Believe Quark is right in asserting that no ARM compatible JInput exists.相信 Quark 断言不存在 ARM 兼容的 JInput 是正确的。 This is in contradiction to the StackOverFlow thread JInput on RaspberryPi .这与RaspberryPi 上的 StackOverFlow 线程 JInput相矛盾。 Tried Albert's extended apt-get: but no-joy Tried 2021-05-07-raspios-buster-arm64 from https://qengineering.eu/install-raspberry-64-os.html , but processing would not start.尝试了 Albert 的扩展 apt-get:但没有乐趣 从https://qengineering.eu/install-raspberry-64-os.html尝试了 2021-05-07-raspios-buster-arm64,但处理无法开始。 Went back to 32bit raspbian.回到 32 位树莓派。
• Workaround was to add a second Arduino Uno with a USB host shield and run the Logetech 3D Pro joystick off the shield. • 解决方法是添加第二个 Arduino Uno 和 USB 主机防护罩,然后从防护罩上运行 Logetech 3D Pro 操纵杆。 Modified the Arduino USB Host Shield Library 2.0 le3dp sketch to have all output include an identifying preamble (J0Y) which allows the processing serialEvent to identify which USB port belongs to the Grbl Arduino and which is the joystick Arduino. Working code is at https://github.com/TPMoyer/Grbl4P and https://github.com/TPMoyer/LE3DP_4_Grbl4P Modified the Arduino USB Host Shield Library 2.0 le3dp sketch to have all output include an identifying preamble (J0Y) which allows the processing serialEvent to identify which USB port belongs to the Grbl Arduino and which is the joystick Arduino. Working code is at https:/ /github.com/TPMoyer/Grbl4Phttps://github.com/TPMoyer/LE3DP_4_Grbl4P

this puts the jar files in /usr/share/java/ which needs to be added to the CLASSPATH. 这会将jar文件放在/ usr / share / java /中,该文件需要添加到CLASSPATH中。 I am still looking for the .so files which need to be added to the LD_LIBRARY_PATH 我仍在寻找需要添加到LD_LIBRARY_PATH的.so文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM