Try using the Wii remote with Java

This time I would like to use the Wii remote controller in Java.

There are few Japanese documents and they are old, so I hope you can use them as new documents.


It will not work unless you pair the Wii remote with your PC as a Bluetooth device. Be sure to pair before executing.


Windows 10 Home Edition Eclipse 4.6 Java 1.8

Library procurement

We will proceed as a normal project, not as Maven.

WiiuseJ Wiiusej at

Project setup

Put wiiuse.dll and WiiUseJ.dll for Windows and and for Mac users in the resource folder.

Play with the library

Find the Wii remote for the time being

If a Wii remote is found, the wiimote variable will contain the Wii remote object.

import com.github.awvalenti.wiiusej.WiiusejNativeLibraryLoadingException;

import wiiusej.WiiUseApiManager;
import wiiusej.Wiimote;

public class MainAccessPoint {
	private Wiimote wiimote;
	private Wiimote[] wiimotes;
	public MainAccessPoint() throws InterruptedException {
		try {
			System.out.println("Finding wiimotes...");
			while(wiimotes == null) {
				/*2019/8/5 There was a mistake. getWiimotes(1);Not getWiimotes(1, true);was. Also, WiiUseApiManager was statically accessed.*/
				wiimotes = WiiUseApiManager.getWiimotes(1, true);
				if(wiimotes != null && wiimotes.length > 0) {
					wiimote = wiimotes[0];
					System.out.println("Wii remote control found. Id: " + wiimote.getId());
				wiimotes = null;
		} catch (WiiusejNativeLibraryLoadingException e) {
	public static void main(String args[]) throws InterruptedException {
		MainAccessPoint main = new MainAccessPoint();

Try changing the LED

Specify boolean in order from the left from the first argument.


wiimote.setLeds(true, false, false, false);

Register the listener on the Wii remote controller

Register the following listeners in wiimote.


import wiiusej.values.GForce;
import wiiusej.wiiusejevents.physicalevents.ExpansionEvent;
import wiiusej.wiiusejevents.physicalevents.IREvent;
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
import wiiusej.wiiusejevents.utils.WiimoteListener;
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.ClassicControllerRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.DisconnectionEvent;
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.GuitarHeroRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.NunchukInsertedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.NunchukRemovedEvent;
import wiiusej.wiiusejevents.wiiuseapievents.StatusEvent;

public class Listener implements WiimoteListener {

    public Listener() {

    //Ignite when the button is pressed. You can tell which button it is by the method name.
    public void onButtonsEvent(WiimoteButtonsEvent arg0) {
        if(arg0.isButtonHomeJustPressed()) {

        } else if(arg0.isButtonHomeJustReleased()) {

        } else if(arg0.isButtonPlusJustPressed()) {

        } else if(arg0.isButtonPlusJustReleased()) {

        } else if(arg0.isButtonMinusJustPressed()) {

        } else if(arg0.isButtonMinusJustReleased()) {

        } else if(arg0.isButtonOneJustPressed()) {

        } else if(arg0.isButtonOneJustReleased()) {

        } else if(arg0.isButtonTwoJustPressed()) {

        } else if(arg0.isButtonTwoJustReleased()) {

        } else if(arg0.isButtonAJustPressed()) {

        } else if(arg0.isButtonAJustReleased()) {

        } else if(arg0.isButtonBJustPressed()) {

        } else if(arg0.isButtonBJustReleased()) {

        } else if(arg0.isButtonRightJustPressed()) {

        } else if(arg0.isButtonRightJustReleased()) {

        } else if(arg0.isButtonLeftJustPressed()) {

        } else if(arg0.isButtonLeftJustReleased()) {

        } else if(arg0.isButtonUpJustPressed()) {

        } else if(arg0.isButtonUpJustReleased()) {

        } else if(arg0.isButtonDownJustPressed()) {

        } else if(arg0.isButtonDownJustReleased()) {


    //Ignite when the Wii remote controller moves.
    public void onMotionSensingEvent(MotionSensingEvent arg0) {
        //The value of the 3-axis accelerometer is 1 to-It will be returned in the range of 1.
        GForce force = arg0.getGforce();
        System.out.println("X: " + force.getX());
        System.out.println("Y: " + force.getY());
        System.out.println("Z: " + force.getZ());

    @Override public void onStatusEvent(StatusEvent arg0) {}
    @Override public void onDisconnectionEvent(DisconnectionEvent arg0) {}
    @Override public void onClassicControllerInsertedEvent(ClassicControllerInsertedEvent arg0) {}
    @Override public void onClassicControllerRemovedEvent(ClassicControllerRemovedEvent arg0) {}
    @Override public void onExpansionEvent(ExpansionEvent arg0) {}
    @Override public void onGuitarHeroInsertedEvent(GuitarHeroInsertedEvent arg0) {}
    @Override public void onGuitarHeroRemovedEvent(GuitarHeroRemovedEvent arg0) {}
    @Override public void onIrEvent(IREvent arg0) {}
    @Override public void onNunchukInsertedEvent(NunchukInsertedEvent arg0) {}
    @Override public void onNunchukRemovedEvent(NunchukRemovedEvent arg0) {}


Register listener to wiimote

wiimote.addWiiMoteEventListeners(new Listener());

Enable motion listener

You need to write the following code to get the motion.


I will add it when I find out something. If you have any questions, please leave a comment.

Recommended Posts

Try using the Wii remote with Java
Try using Redis with Java (jar)
Try using the Stream API in Java
Try accessing the dataset from Java using JZOS
Try using the COTOHA API parsing in Java
Try using RocksDB in Java
Try using GloVe with Deeplearning4j
Try using view_component with rails
Try DB connection with Java
Try implementing the Eratosthenes sieve using the Java standard library
Try gRPC with Java, Maven
Using Mapper with Java (Spring)
Try global hooking in Java using the JNativeHook library
[Java] Try editing the elements of the Json string using the library
I tried using the CameraX library with Android Java Fragment
Java comparison using the compareTo () method
Follow the link with Selenium (Java)
Using Java with AWS Lambda-Eclipse Preparation
[Java] Try to implement using generics
Try using the messaging system Pulsar
Html5 development with Java using TeaVM
Try using IBM Java method tracing
Using proxy service with Java crawling
Try using Hyperledger Iroha's Java SDK
[Java] Where did you try using java?
Try Hello World with the minimum configuration of Heroku Java spring-boot
Is the version of Elasticsearch you are using compatible with Java 11?
Check the operation using jetty with Maven.
Using Java with AWS Lambda-Implementation-Check CloudWatch Arguments
Try using the service on Android Oreo
Using Java with AWS Lambda-Implementation-Stop / Launch EC2
Using JupyterLab + Java with WSL on Windows 10
Let's try WebSocket with Java and javascript!
Study Java Try using Scanner or Map
Try using JSON format API in Java
Try using Spring Boot with VS Code
Try calling the CORBA service in Java 11+
Game development with two people using java 2
I tried using OpenCV with Java + Tomcat
Game development with two people using java 1
Try using JobScheduler's REST-API --Java RestClient implementation--
Try managing Java libraries with AWS CodeArtifact
Try using the Emotion API from Android
Game development with two people using java 3
[Java] Get the date with the LocalDateTime class
Try remote debugging of Java with Remote Containers in Visual Studio Code Insiders
Try using Firebase Cloud Functions on Android (Java)
Try using JobScheduler's REST-API --Java RestClient Test class-
Try using libGDX
Try adding text to an image in Scala using the Java standard library
Using templates on the classpath with Apache Velocity
Interact with LINE Message API using Lambda (Java)
[LeJOS] Let's control the EV3 motor with Java
ChatWork4j for using the ChatWork API in Java
Try using powermock-mockito2-2.0.2
Try using GraalVM
[Java] Set the time from the browser with jsoup
Try Java 8 Stream
Try using jmockit 1.48
Understanding the MVC framework with server-side Java 1/4 View
Try using sql-migrate