Skip to content

MusaKapan/JController

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JController

Author: Musa Kapan

Credits: Endolf for jinput which this API is based upon.

Super basic implementation of jinput for Dualshock4 controllers with an event driven endpoint for easy implementation.

How to use

First make sure you have the .dll files in your javapath.

public static void main(String[] args) {

    //Step 1: configure the connected controllers

    Controllers.getInstance().setup();
    if (Controllers.getInstance().getActiveControllers().length == 0) {
        System.out.println("No controllers found. Test application will exit.");
        System.exit(0);
    }

    //Step 2: select a controller from the configured ones and attach a listener to it

    ControllerWrapper controller = Controllers.getInstance().getActiveControllers()[0];
    controller.setListener(new InputEventListener() {
        @Override
        public void buttonPressed(InputEvent evt) {

        }

        @Override
        public void buttonReleased(InputEvent evt) {
            System.out.println("Button released: "+evt);
        }

        @Override
        public void analogMoved(InputEvent evt, float x, float y) {

        }

        @Override
        public void sliderPressed(InputEvent evt, float intensity) {

        }
    });

    //Step 3: start the controller thread to process inputs

    Controllers.getInstance().getThread().start();
}

Also works in Processing 3.4

Simply copy JController.jar from out/artifacts/JController_jar/ and put in the code/ folder in your sketch's directory.

TODO

  • Controller configuration (deadzone, etc)
  • XBOX 360 controller support
  • dynamic component detection

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published