Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epoxy
GitHub Repository: epoxy/proj11
Path: blob/master/SLICK_HOME/src/org/newdawn/slick/command/ControllerControl.java
1456 views
1
package org.newdawn.slick.command;
2
3
/**
4
* A control describing input provided from a controller. This allows controls to be
5
* mapped to game pad inputs.
6
*
7
* @author joverton
8
*/
9
abstract class ControllerControl implements Control {
10
/** Indicates a button was pressed */
11
protected static final int BUTTON_EVENT = 0;
12
/** Indicates left was pressed */
13
protected static final int LEFT_EVENT = 1;
14
/** Indicates right was pressed */
15
protected static final int RIGHT_EVENT = 2;
16
/** Indicates up was pressed */
17
protected static final int UP_EVENT = 3;
18
/** Indicates down was pressed */
19
protected static final int DOWN_EVENT = 4;
20
21
/** The type of event we're looking for */
22
private int event;
23
/** The index of the button we're waiting for */
24
private int button;
25
/** The index of the controller we're waiting on */
26
private int controllerNumber;
27
28
/**
29
* Create a new controller control
30
*
31
* @param controllerNumber The index of the controller to react to
32
* @param event The event to react to
33
* @param button The button index to react to on a BUTTON event
34
*/
35
protected ControllerControl(int controllerNumber, int event, int button) {
36
this.event = event;
37
this.button = button;
38
this.controllerNumber = controllerNumber;
39
}
40
41
/**
42
* @see java.lang.Object#equals(java.lang.Object)
43
*/
44
public boolean equals(Object o) {
45
if(o == null)
46
return false;
47
if(!(o instanceof ControllerControl))
48
return false;
49
50
ControllerControl c = (ControllerControl)o;
51
52
return c.controllerNumber == controllerNumber && c.event == event && c.button == button;
53
}
54
55
/**
56
* @see java.lang.Object#hashCode()
57
*/
58
public int hashCode() {
59
return event + button + controllerNumber;
60
}
61
}
62
63