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

Public Member Functions

boolean matches (Configuration config)
 
String getName ()
 
String getTypeName ()
 
int getTypeID ()
 
String getPortTypeName ()
 
String toString ()
 
void update ()
 
String toListText (String tab)
 
String toText (String tab)
 
String buttonsToText (String tab)
 
String slidersToText (String tab)
 
List< ControlInputgetInputs ()
 
int getNumberOfSliders ()
 
ControlSlider getSlider (final int i_sliderNumb)
 
ControlSlider getSlider (final String i_sliderName)
 
void setTolerance (final float i_tolerance)
 
int getNumberOfButtons ()
 
ControlButton getButton (final int i_buttonNumb)
 
ControlButton getButton (final String i_buttonName)
 
ControlHat getHat (final int i_hatNumb)
 
ControlHat getHat (final String i_hatName)
 
void open ()
 
void close ()
 
int getNumberOfRumblers ()
 
void rumble (final float i_intensity, final int i_id)
 
void rumble (final float i_intensity)
 
void plug (final Object i_object, final String i_methodName, final int i_eventType, final int i_input)
 
void plug (final String i_methodName, final int i_eventType, final int i_input)
 
void plug (final Object i_object, final String i_methodName, final int i_eventType, final String i_input)
 
void plug (final String i_methodName, final int i_eventType, final String i_input)
 
boolean equals (Object d)
 
int compareTo (ControlDevice d)
 

Public Attributes

boolean available = true
 
- 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"
 

Protected Member Functions

void updateRelative ()
 

Package Functions

 ControlDevice (final Controller i_controller, final PApplet i_parent)
 

Private Member Functions

void setupDevice ()
 

Private Attributes

final Controller controller
 
final PApplet parent
 
final List< ControlSlidersliders = new ArrayList<ControlSlider>()
 
final List< ControlButtonbuttons = new ArrayList<ControlButton>()
 
Rumbler[] rumblers = new Rumbler[0]
 
final Map< String, ControlInputinputNameMap
 
final List< ControlInputinputs = new ArrayList<ControlInput>()
 
boolean open = false
 
final String name
 

Detailed Description

The device class is for the communication with your input devices. A device consists of buttons and sliders, sliders can be grouped to sticks.

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
Peter Lager & Christian Riekoff

Constructor & Destructor Documentation

org.gamecontrolplus.ControlDevice.ControlDevice ( final Controller  i_controller,
final PApplet  i_parent 
)
package

Initializes a new device by the given Controller

Parameters
i_controller

Member Function Documentation

String org.gamecontrolplus.ControlDevice.buttonsToText ( String  tab)

Get a text description of the buttons on this device

Parameters
tab
void org.gamecontrolplus.ControlDevice.close ( )

Use this method to close a device. A closed device does not to be updated to get values.

ControlButton org.gamecontrolplus.ControlDevice.getButton ( final int  i_buttonNumb)

Use this method to get a Button based on its position in the list of inputs. Use the buttonsToText method to see what buttons are available for a device.

Parameters
i_buttonNameint, the number of the button to return
Returns
ControlButton, the Button corresponding to the given number
ControlButton org.gamecontrolplus.ControlDevice.getButton ( final String  i_buttonName)

Use this method to get a Button based on its name. The name could be the system-dependent name or the name specified in a device configuration. Use the buttonsToText method to see what buttons are available for a device.

Parameters
i_buttonNameString, the name of the button to return
Returns
ControlButton, the Button corresponding to the given name or null if not found.
ControlHat org.gamecontrolplus.ControlDevice.getHat ( final int  i_hatNumb)

Use this method to get a Hat based on its position in the list of inputs. Use the buttonsToText method to see what hats are available for a device.

Parameters
i_buttonNameString, the name of the button to return
Returns
ControlHat, the Hat corresponding to the given name or null if not found.
ControlHat org.gamecontrolplus.ControlDevice.getHat ( final String  i_hatName)

Use this method to get a Hat based on its name. The name could be the system-dependent name or the name specified in a device configuration. Use the buttonsToText method to see what hats are available for a device.

Parameters
i_hatNameString, the name of the hat to return
Returns
ControlHat, the Hat corresponding to the given name or null if not found.
List<ControlInput> org.gamecontrolplus.ControlDevice.getInputs ( )

Get a list of all inputs for this device

int org.gamecontrolplus.ControlDevice.getNumberOfButtons ( )

Returns the number of buttons of the device.

Returns
int, the number of buttons available for a device
int org.gamecontrolplus.ControlDevice.getNumberOfSliders ( )

Returns the number of sliders of the device.

Returns
the number of sliders on this device
String org.gamecontrolplus.ControlDevice.getPortTypeName ( )

Get the name of the connection type e.g. USB, network etc.

ControlSlider org.gamecontrolplus.ControlDevice.getSlider ( final int  i_sliderNumb)

Use this method to get a Slider based on its position in the list of inputs. Use printSliders to see what sliders are available for a device.

Parameters
i_sliderNumbint, the number of the slider to return
Returns
ControllSlider, the Slider corresponding to the given number
ControlSlider org.gamecontrolplus.ControlDevice.getSlider ( final String  i_sliderName)

Use this method to get a Slider based on its name. The name could be the system-dependent name or the name specified in a device configuration. Use printSliders to see what sliders are available for a device.

Parameters
i_sliderNameString, the name of the slider to return
Returns
ControllSlider, the Slider corresponding to the given name or null if not found.
int org.gamecontrolplus.ControlDevice.getTypeID ( )

Get the name for the type of device e.g. Gamepad, Mouse

Returns
String org.gamecontrolplus.ControlDevice.getTypeName ( )

Get the name for the type of device e.g. Gamepad, Mouse

Returns
boolean org.gamecontrolplus.ControlDevice.matches ( Configuration  config)

If available will attempt to match this device to the required configuration. If a match occurs then

  1. the user defined keys are added to the device
  2. the config count is incremented
  3. the device is marked as unavailable for future matches
  4. the device is opened
Parameters
config
Returns
void org.gamecontrolplus.ControlDevice.open ( )

Use this method to open a device. A device is automatically opened by default, so you only need to call this when you have closed it with the close method.

void org.gamecontrolplus.ControlDevice.plug ( final Object  i_object,
final String  i_methodName,
final int  i_eventType,
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 a device the method name, the event type you want to react on and the button. If your method is inside a class you have to give the plug a reference to it.

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_inputint: the number of the button that triggers the plug
void org.gamecontrolplus.ControlDevice.plug ( final String  i_methodName,
final int  i_eventType,
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 a device the method name, the event type you want to react on and the button. If your method is inside a class you have to give the plug a reference to it.

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_inputint: the number of the button that triggers the plug
void org.gamecontrolplus.ControlDevice.plug ( final Object  i_object,
final String  i_methodName,
final int  i_eventType,
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 a device the method name, the event type you want to react on and the button. If your method is inside a class you have to give the plug a reference to it.

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_inputString: the name of the button that triggers the plug
void org.gamecontrolplus.ControlDevice.plug ( final String  i_methodName,
final int  i_eventType,
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 a device the method name, the event type you want to react on and the button. If your method is inside a class you have to give the plug a reference to it.

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_inputString: the name of the button that triggers the plug
void org.gamecontrolplus.ControlDevice.setTolerance ( final float  i_tolerance)

Tolerance is minimum under which the input is set to zero. Use this method to set the tolerance for all sliders of the device.

Parameters
i_tolerancefloat, the new tolerance for the device
void org.gamecontrolplus.ControlDevice.setupDevice ( )
private

Loads the available Sliders, Sticks and Buttons for a device

String org.gamecontrolplus.ControlDevice.slidersToText ( String  tab)

Get a text description of the sliders on this device

Parameters
tab
String org.gamecontrolplus.ControlDevice.toListText ( String  tab)

Get a short text description for this device

Parameters
tab
String org.gamecontrolplus.ControlDevice.toString ( )

Returns the String representation of a device

Returns
String, the String representation of a device
String org.gamecontrolplus.ControlDevice.toText ( String  tab)

Get a detailed text description for this device

Parameters
tab
void org.gamecontrolplus.ControlDevice.update ( )

This method is called on every thread loop

void org.gamecontrolplus.ControlDevice.updateRelative ( )
protected

This method is called before each frame to update the controller values

Member Data Documentation

boolean org.gamecontrolplus.ControlDevice.available = true

This is used to show the device is available for selection by matching with a configurations file.

final List<ControlButton> org.gamecontrolplus.ControlDevice.buttons = new ArrayList<ControlButton>()
private

list containing the buttons on the device

final Controller org.gamecontrolplus.ControlDevice.controller
private

The JInput controller instance for this device

final Map<String, ControlInput> org.gamecontrolplus.ControlDevice.inputNameMap
private
Initial value:
=
new HashMap<String, ControlInput>()

to map the device generated input names and Controller inputs

final List<ControlInput> org.gamecontrolplus.ControlDevice.inputs = new ArrayList<ControlInput>()
private

A List with the buttons and sliders available by the device

final String org.gamecontrolplus.ControlDevice.name
private

The name of the device.

boolean org.gamecontrolplus.ControlDevice.open = false
private

true if the device has been opened. Only opened devices are updated before a frame.

final PApplet org.gamecontrolplus.ControlDevice.parent
private

Instance to the PApplet where gcp is running

Rumbler [] org.gamecontrolplus.ControlDevice.rumblers = new Rumbler[0]
private

list containing the rumblers on the device

final List<ControlSlider> org.gamecontrolplus.ControlDevice.sliders = new ArrayList<ControlSlider>()
private

list containing the sliders on the device