Skip to content

Getting Started

Ralph Niemitz edited this page Mar 30, 2018 · 3 revisions

Installation

  • First download the latest release from this page
  • Now you have to put the JAR files in your project's module path
  • Make your module-info.java require de.ralleytn.simple.input
  • Done!

What you need to know

This library only supports mice, keyboards and gamepads/joysticks at the moment. Gamepads and joysticks will be treated as one and the same through the Gamepad class to make things easier. Any other device will be inaccessible when using this library.

The main class of this library is the DeviceManager. Before you can use the library you have to call its create method. And when you are done using it, call its destroy method.

A device is not listening from the get go. You have to call the startListening method for every device that you want to listen to. To stop listening you call the stopListening method. DeviceManager.destroy will call stopListening for every device. Every device uses its own daemon thread to listen to input events.

For every type of device there is a class that extends Device and represents the device itself, An interface that extends DevieListener to provide the methods that will be fired when input events occur, An adapter class that implements the listener class and leaves the method bodies empty, a class that extends DeviceEvent and methods in the DeviceManager to retrieve all devices of that type and to add and remove listeners to/from all devices of that type.

Related