Game Control Plus  1.2.2
 All Classes Namespaces Functions Variables Pages
org.gamecontrolplus.ControlIO Class Reference
Inheritance diagram for org.gamecontrolplus.ControlIO:

Public Member Functions

void dispose ()
 
String deviceListToText (String tab)
 
String devicesToText (String tab)
 
int getNumberOfDevices ()
 
List< ControlDevicegetDevices ()
 
ControlDevice getDevice (final int i_deviceNumber)
 
ControlDevice getDevice (final String i_deviceName)
 
ControlDevice getConfiguredDevice ()
 
void setConfiguredDevice (ControlDevice configuredDevice)
 
ControlDevice getMatchedDevice (final String filename)
 
ControlIO filter (int filter)
 
ControlDevice getMatchedDeviceSilent (final String filename)
 
ControlDevice getMatchedDevice (final Configuration config)
 
ControlDevice getMatchedDeviceSilent (final Configuration config)
 
void finishedConfig (ControlDevice dev)
 
void pre ()
 
void run ()
 
void plug (final Object i_object, final String i_methodName, final int i_eventType, final int i_intputDevice, final int i_input)
 
void plug (final String i_methodName, final int i_eventType, final int i_intputDevice, final int i_input)
 
void plug (final Object i_object, final String i_methodName, final int i_eventType, final String i_intputDevice, final String i_input)
 
void plug (final String i_methodName, final int i_eventType, final String i_intputDevice, final String i_input)
 

Static Public Member Functions

static ControlIO getInstance (final PApplet i_parent)
 

Private Member Functions

 ControlIO (final PApplet i_parent)
 
ControlDevice findDevice (final Configuration config)
 

Private Attributes

ControlDevice configuredDevice = null
 
final ControllerEnvironment environment
 
final PApplet parent
 
final List< ControlDevicedevices = new ArrayList<ControlDevice>()
 
int device_filter = GCP.ANY
 
final Thread thread
 
boolean active = true
 

Static Private Attributes

static ControlIO instance
 

Additional Inherited Members

- Public Attributes inherited from org.gamecontrolplus.gui.KConstants
final float INPUT_UI_HEIGHT = 24
 
final float DESC_UI_HEIGHT = 30
 
final float ELEMENT_UI_GAP = 4
 
final float INPUT_UI_LENGTH = 220
 
final float DESC_UI_LENGTH = 300
 
final float TEXTFIELD_GAP = 4
 
final float INICATOR_D = 12
 
final float CONNECTOR_SIZE_R = 10
 
final float CONNECTOR_SIZE_R2 = CONNECTOR_SIZE_R * CONNECTOR_SIZE_R
 
final float CONNECTOR_SIZE_D = 2 * CONNECTOR_SIZE_R
 
final int INPUT = 0x01
 
final int DESC = 0x02
 
final float FONT_SIZE = 12
 
final int PANEL_WIDTH = 320
 
final int PANEL_HEIGHT = 280
 
final int UI_BUTTON = 0x01
 
final int UI_COOLIEHAT = 0x02
 
final int UI_SLIDER = 0x03
 
final int UI_DESCRIPTOR = 0x04
 
final int[] UI_E_BACK = new int[] { 0, 0xFFFFD0D0, 0xFFD0FFD0, 0xFFD0D0FF, 0xFFFFD0D0 }
 
final int BACKGROUND = 0xFFF0FFF0
 
final int PANEL = 0xFF208020
 
final int BORDER = 0xFF4040A0
 
final int CONNECTION = 0xFF8080A0
 
final int HIGHLIGHT = 0xFFFF40FF
 
final int NAME_AREA = 0xFFC8C8FF
 
final int CONNECTOR = 0xFFFFC0FF
 
final int TEXTFILL = 0xFF000080
 
final int PRESSED = 0xFFFF3030
 
final int RELEASED = 0xFF802020
 
final int SLIDER_CURSOR = 0xFFFF4040
 
int WORKING = 0
 
int CANCELLED = 1
 
int FINISHED = 2
 
int NOT_OVER = 0x0000
 
int OVER_CONNECTOR = 0x0100
 
int ON_PRESS = 0
 
int ON_RELEASE = 1
 
int WHILE_PRESS = 2
 
int BUTTON_TYPE = 1
 
int HAT_TYPE = 2
 
int SLIDER_TYPE = 3
 
String SEPARATOR = "\t"
 

Detailed Description

ControllIO is the base class for using controllers in Processing. It provides methods to retrieve information about the connected devices and to get the input data from them.
To get a ControllIO object you to use the getInstance() Method. To get started you should use the deviceListToText(...) or the devicesToText(...) to see if what control devices you have attached and their details.

To react on button events you can plug methods, that are called when a button is pressed, released or while a button is pressed.

Author
Christian Riekoff & Peter Lager

Constructor & Destructor Documentation

org.gamecontrolplus.ControlIO.ControlIO ( final PApplet  i_parent)
private

Private constructor for singleton class.
Initialises the ControllIO instance

Parameters
i_parent

Member Function Documentation

String org.gamecontrolplus.ControlIO.deviceListToText ( String  tab)

Creates a formatted text string listing the devices available to the the sketch.

Parameters
tabthe indentation string
String org.gamecontrolplus.ControlIO.devicesToText ( String  tab)

Creates a formatted string of all available devices detailing all input controls (buttons, hats and sliders) for each device.

Parameters
tabthe indentation string
void org.gamecontrolplus.ControlIO.dispose ( )

dispose method called by PApplet after closing. The update thread is deactivated here

ControlIO org.gamecontrolplus.ControlIO.filter ( int  filter)

This sets the filter to apply to the next getMatchedDevice/getMatchedDeviceSilent method to be called. The filter is single use only and will be clear after the next search for a matched device.
Examples

// Filter
 GCP.KEYBOARD;              keyboards only
 GCP.KEYBOARD | GCP.MOUSE   keyboards or mice only
 ~GCP.STICK                 anything but joysticks
 ~(GCP.GAMEPAD | GCP.MOUSE) anything but gamepads and mice
 

Look in the GCP class for a full list of filter constants but beware JInput does not always report the device correctly, it reported my Logitech Master MX2 mouse as a keyboard. So use cautiously.

Parameters
filterfilter to use
Returns
this ControlIO singleton object
void org.gamecontrolplus.ControlIO.finishedConfig ( ControlDevice  dev)

THIS METHOD WILL NO LONGER BE NEEDED IN THE UPDATED VERSION Used internally to signal when a configuration has finished.

Parameters
devthe configured device or null if the configuration was cancelled.
ControlDevice org.gamecontrolplus.ControlIO.getConfiguredDevice ( )
Returns
the configuredDevice
ControlDevice org.gamecontrolplus.ControlIO.getDevice ( final int  i_deviceNumber)

Use this method to get a Device based on its number. This method will 'open' the device so that you can use it.
Use printDevices to see what devices are available on your system.

Parameters
i_deviceNumberint, number of the device to open
Returns
ControllDevice, the device corresponding to the given number or name
ControlDevice org.gamecontrolplus.ControlIO.getDevice ( final String  i_deviceName)

Use this method to get a Device based on its name. This method will 'open' the device so that you can use it.
Use printDevices to see what devices are available on your system.

Parameters
i_deviceNameString, name of the device to open
List<ControlDevice> org.gamecontrolplus.ControlIO.getDevices ( )

Get the list of USB devices connected. This will not 'open' or 'close' any of the devices for you.

ControlDevice org.gamecontrolplus.ControlIO.getMatchedDevice ( final String  filename)

Find and return the ControlDevice that matches the configuration described in the specified file.
If an exact match can't be found give the user an option to configure another device.

Parameters
filenamethe name of the configuration file
Returns
the device or null if no device is configured.
ControlDevice org.gamecontrolplus.ControlIO.getMatchedDevice ( final Configuration  config)

Find and return the ControlDevice that matches the specified configuration.
If an exact match can't be found give the user an option to configure another device.

Parameters
configthe configuration to match
Returns
the device or null if no device is configured.
ControlDevice org.gamecontrolplus.ControlIO.getMatchedDeviceSilent ( final String  filename)

Find and return the ControlDevice that matches the configuration described in the specified file.
The user is not given the chance to configure another device if an exact match is not found, in this situation the method returns null.

Parameters
filenamethe name of the configuration file
Returns
the device or null if no device is configured.
ControlDevice org.gamecontrolplus.ControlIO.getMatchedDeviceSilent ( final Configuration  config)

Find and return the ControlDevice that matches the specified configuration.
The user is not given the chance to configure another device if an exact match is not found, in this situation the method returns null.

Parameters
configthe configuration to match
Returns
the device or null if no device is configured.
int org.gamecontrolplus.ControlIO.getNumberOfDevices ( )

Returns the number of available Devices

Returns
the number of available devices
void org.gamecontrolplus.ControlIO.plug ( final Object  i_object,
final String  i_methodName,
final int  i_eventType,
final int  i_intputDevice,
final int  i_input 
)

Plug is a handy method to handle incoming button events. To create a plug you have to implement a method that reacts on the events. To plug a method you need to give ControllIO the method name, the event type you want to react on and the device and button. If your method is inside a class you have to give ControllIO a reference to it.

If you want to handle the events of a simple button, you only have to implement a method without parameters. To react on the events of a hat you method needs to receive two float values, so that ProControl Plus can send you the x and y values of the hat.

Parameters
i_objectObject: the object with the method to plug
i_methodNameString: the name of the method that has to be plugged
i_eventTypeconstant: can be ControllIO.ON_PRESS, ControllIO.ON_RELEASE or ControllIO.WHILE_PRESS
i_intputDeviceint: the number of the device that triggers the plug
i_inputint: the number of the button that triggers the plug
void org.gamecontrolplus.ControlIO.plug ( final String  i_methodName,
final int  i_eventType,
final int  i_intputDevice,
final int  i_input 
)

Plug is a handy method to handle incoming button events. To create a plug you have to implement a method that reacts on the events. To plug a method you need to give ControllIO the method name, the event type you want to react on and the device and button. If your method is inside a class you have to give ControllIO a reference to it.

If you want to handle the events of a simple button, you only have to implement a method without parameters. To react on the events of a hat you method needs to receive two float values, so that ProControl Plus can send you the x and y values of the hat.

Parameters
i_methodNameString: the name of the method that has to be plugged
i_eventTypeconstant: can be ControllIO.ON_PRESS, ControllIO.ON_RELEASE or ControllIO.WHILE_PRESS
i_intputDeviceint: the number of the device that triggers the plug
i_inputint: the number of the button that triggers the plug
void org.gamecontrolplus.ControlIO.plug ( final Object  i_object,
final String  i_methodName,
final int  i_eventType,
final String  i_intputDevice,
final String  i_input 
)

Plug is a handy method to handle incoming button events. To create a plug you have to implement a method that reacts on the events. To plug a method you need to give ControllIO the method name, the event type you want to react on and the device and button. If your method is inside a class you have to give ControllIO a reference to it.

If you want to handle the events of a simple button, you only have to implement a method without parameters. To react on the events of a hat you method needs to receive two float values, so that ProControl Plus can send you the x and y values of the hat.

Parameters
i_objectObject: the object with the method to plug
i_methodNameString: the name of the method that has to be plugged
i_eventTypeconstant: can be ControllIO.ON_PRESS, ControllIO.ON_RELEASE or ControllIO.WHILE_PRESS
i_intputDeviceString: the name of the device that triggers the plug
i_inputString: the name of the input that triggers the plug. Can be system name or name from the configuration file.
void org.gamecontrolplus.ControlIO.plug ( final String  i_methodName,
final int  i_eventType,
final String  i_intputDevice,
final String  i_input 
)

Plug is a handy method to handle incoming button events. To create a plug you have to implement a method that reacts on the events. To plug a method you need to give ControllIO the method name, the event type you want to react on and the device and button. If your method is inside a class you have to give ControllIO a reference to it.

If you want to handle the events of a simple button, you only have to implement a method without parameters. To react on the events of a hat you method needs to receive two float values, so that ProControl Plus can send you the x and y values of the hat.

Parameters
i_methodNameString: the name of the method that has to be plugged
i_eventTypeconstant: can be ControllIO.ON_PRESS, ControllIO.ON_RELEASE or ControllIO.WHILE_PRESS
i_intputDeviceString: the name of the device that triggers the plug
i_inputString: the name of the input that triggers the plug. Can be system name or name from the configuration file.
void org.gamecontrolplus.ControlIO.pre ( )

Updates the devices, to get the actual data before a new frame is drawn

void org.gamecontrolplus.ControlIO.run ( )

Controllers are now polled in a separate thread to get independent from the framerate of the sketch

void org.gamecontrolplus.ControlIO.setConfiguredDevice ( ControlDevice  configuredDevice)
Parameters
configuredDevicethe configuredDevice to set

Member Data Documentation

boolean org.gamecontrolplus.ControlIO.active = true
private

Indicates whether the thread is active.

ControlDevice org.gamecontrolplus.ControlIO.configuredDevice = null
private

Used internally to identify the configured device

int org.gamecontrolplus.ControlIO.device_filter = GCP.ANY
private

Device filter to be used for the next method call to getMatchedDevice or getMatchedDeviceSilent. It is reset to any device after one use.

final List<ControlDevice> org.gamecontrolplus.ControlIO.devices = new ArrayList<ControlDevice>()
private

List of the available devices

final ControllerEnvironment org.gamecontrolplus.ControlIO.environment
private

REMOVE IN NEXT VERSION True when the library is being used to configure a device. Set to false when done. Holds the environment of JInput

ControlIO org.gamecontrolplus.ControlIO.instance
staticprivate

Ensures that there only exists one instance of ControllIO

final PApplet org.gamecontrolplus.ControlIO.parent
private

Instance to the PApplet where ProControl Plus is running

final Thread org.gamecontrolplus.ControlIO.thread
private

Thread to keep the devices updated and process any plugs created.