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

Public Member Functions

boolean up ()
 
boolean down ()
 
boolean left ()
 
boolean right ()
 
int getPos ()
 
float getX ()
 
float getY ()
 
String toText (String tab)
 
void plug (final Object i_object, final String i_methodName, final int i_eventType)
 
- Public Member Functions inherited from org.gamecontrolplus.ControlButton
void plug (final Object i_object, final String i_methodName, final int i_eventType)
 
void plug (final String i_methodName, final int i_eventType)
 
String toText (String tab)
 
- Public Member Functions inherited from org.gamecontrolplus.ControlInput
String getName ()
 
float getValue ()
 
float getTolerance ()
 
void setTolerance (final float i_tolerance)
 
float getMultiplier ()
 
void setMultiplier (final float i_multiplier)
 

Protected Member Functions

void callPlugs (final List< Plug > i_plugList)
 
- Protected Member Functions inherited from org.gamecontrolplus.ControlButton
void callPlugs (final List< Plug > i_plugList)
 

Package Functions

 ControlHat (final Component i_component, final PApplet i_parent)
 
void update ()
 
- Package Functions inherited from org.gamecontrolplus.ControlButton
 ControlButton (final Component i_component, final PApplet i_parent)
 
- Package Functions inherited from org.gamecontrolplus.ControlInput
 ControlInput (final Component i_component)
 

Private Attributes

float x = 0
 
float y = 0
 
boolean up
 
boolean down
 
boolean left
 
boolean right
 
float change = 1
 
float diagonalChange = DIAGONAL_FACTOR
 

Static Private Attributes

static final int OFF = 0
 
static final int UP_LEFT = 1
 
static final int UP = 2
 
static final int UP_RIGHT = 3
 
static final int RIGHT = 4
 
static final int DOWN_RIGHT = 5
 
static final int DOWN = 6
 
static final int DOWN_LEFT = 7
 
static final int LEFT = 8
 
static float DIAGONAL_FACTOR = (float)Math.sin(PConstants.HALF_PI/2)
 

Related Functions

(Note that these are not member functions.)

String getName ()
 

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"
 
- Protected Attributes inherited from org.gamecontrolplus.ControlButton
final List< PlugonPressPlugs = new ArrayList<Plug>()
 
final List< PlugonReleasePlugs = new ArrayList<Plug>()
 
final List< PlugwhilePressPlugs = new ArrayList<Plug>()
 
- Protected Attributes inherited from org.gamecontrolplus.ControlInput
float actualValue = 0f
 
float tolerance = 0f
 
float multiplier = 1f
 
final String actualName
 
int inputType
 
- Package Attributes inherited from org.gamecontrolplus.ControlInput
final Component component
 

Detailed Description

A ControlHat is a special button, that can be found on joypads and the top of joysticks for example. It is not only on or off but does also has a direction.

Author
Christian Riekoff & Peter Lager

Constructor & Destructor Documentation

org.gamecontrolplus.ControlHat.ControlHat ( final Component  i_component,
final PApplet  i_parent 
)
package

Initializes a new ControllCrossButton.

Parameters
i_component

Member Function Documentation

boolean org.gamecontrolplus.ControlHat.down ( )

See if the hat is press in the down direction

int org.gamecontrolplus.ControlHat.getPos ( )

Get position value
1 - NW, 2 - N, 3 - NE, 4 - E, 5 - SE, 6 - S, 7 - SW, 8 - W and 0 at rest.

Returns
float org.gamecontrolplus.ControlHat.getX ( )

The current x value of the hat.

Returns
float, the x value of the hat
float org.gamecontrolplus.ControlHat.getY ( )

The current y value of the hat.

Returns
float, the y value of the hat
boolean org.gamecontrolplus.ControlHat.left ( )

See if the hat is press in the left direction

void org.gamecontrolplus.ControlHat.plug ( final Object  i_object,
final String  i_methodName,
final int  i_eventType 
)

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 button the method name and the event type you want to react on. If your method is inside a class you have to give the plug 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
boolean org.gamecontrolplus.ControlHat.right ( )

See if the hat is press in the right direction

boolean org.gamecontrolplus.ControlHat.up ( )

See if the hat is press in the up direction

void org.gamecontrolplus.ControlHat.update ( )
packagevirtual

This method is called before each frame to update the button state.

Reimplemented from org.gamecontrolplus.ControlButton.

Friends And Related Function Documentation

String getName ( )
related

Returns the name of the cooliehat .

Returns
String, the name of the input element application

Member Data Documentation

final int org.gamecontrolplus.ControlHat.DOWN = 6
staticprivate

Standard value for down HAT position

final int org.gamecontrolplus.ControlHat.DOWN_LEFT = 7
staticprivate

Standard value for down-left HAT position

final int org.gamecontrolplus.ControlHat.DOWN_RIGHT = 5
staticprivate

Standard value for down-right HAT position

final int org.gamecontrolplus.ControlHat.LEFT = 8
staticprivate

Standard value for left HAT position

final int org.gamecontrolplus.ControlHat.OFF = 0
staticprivate

Standard value for center HAT position

final int org.gamecontrolplus.ControlHat.RIGHT = 4
staticprivate

Standard value for right HAT position

final int org.gamecontrolplus.ControlHat.UP = 2
staticprivate

Standard value for up HAT position

final int org.gamecontrolplus.ControlHat.UP_LEFT = 1
staticprivate

Standard value for up-left HAT position

final int org.gamecontrolplus.ControlHat.UP_RIGHT = 3
staticprivate

Standard value for up-right HAT position