|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--stamp.peripheral.hid.Joystick
This class provides an interface to standard analog joystick -- the kind used for PC games that plugs into a DB-15 connector (game port).
The joystick potentiometers are read using CPU.rcTime(). This code is written for the rcTime() capacitor to be connected to Vdd; the joystick pots connect between the pin/cap connection and Vss (ground).
Usage:
joystick controller = new joystick(CPU.pin0, CPU.pin1, CPU.pin1, CPU.pin2);
| Field Summary | |
static int |
BTN_X
|
static int |
BTN_XY
|
static int |
BTN_Y
|
| Constructor Summary | |
Joystick(int xPotPin,
int yPotPin,
int xSwitchPin,
int ySwitchPin)
Creates analog joystick object. |
|
| Method Summary | |
int |
buttons()
Reads X and Y buttons on joystick. |
boolean |
buttonX()
Reads X button on joystick. |
boolean |
buttonY()
Reads Y button on joystick. |
int |
rawX()
Reads raw X value from joystick. |
int |
rawY()
Reads raw Y value from joystick. |
int |
scaleX()
Reads and scales X value from joystick. |
int |
scaleY()
Reads and scales Y value from joystick. |
void |
setXDiv(int divisor)
Sets divisor for scaled X pot value -- scaleX = rawX * multiplierX / divisorX |
void |
setXMult(int multiplier)
Sets multiplier for scaled X pot value -- scaleX = rawX * multiplierX / divisorX |
void |
setXScale(int multiplier,
int divisor)
Sets multiplier and divisor for scaled X pot value -- scaleX = rawX * multiplierX / divisorX |
void |
setYDiv(int divisor)
Sets divisor for scaled Y pot value -- scaleY = rawY * multiplierY / divisorY |
void |
setYMult(int multiplier)
Sets multiplier for scaled Y pot value -- scaleY = rawY * multiplierY / divisorY |
void |
setYScale(int multiplier,
int divisor)
Sets multiplier and divisor for scaled X pot value -- scaleY = rawY * multiplierY / divisorY |
| Methods inherited from class java.lang.Object |
equals |
| Field Detail |
public static final int BTN_X
public static final int BTN_Y
public static final int BTN_XY
| Constructor Detail |
public Joystick(int xPotPin,
int yPotPin,
int xSwitchPin,
int ySwitchPin)
xPotPin - X pot input pin (DB-15 pin 3)yPotPin - y pot input pin (DB-15 pin 6)xSwitchPin - X switch input pin (DB-15 pin 2)ySwitchPin - Y switch input pin (DB-15 pin 7)| Method Detail |
public int rawX()
public int rawY()
public void setXMult(int multiplier)
multiplier - Scale multiplierpublic void setXDiv(int divisor)
divisor - Scale divisorpublic void setYMult(int multiplier)
multiplier - Scale multiplierpublic void setYDiv(int divisor)
divisor - Scale divisor
public void setXScale(int multiplier,
int divisor)
multiplier - Scale multiplierdivisor - Scale divisor
public void setYScale(int multiplier,
int divisor)
multiplier - Scale multiplierdivisor - Scale divisorpublic int scaleX()
public int scaleY()
public boolean buttonX()
public boolean buttonY()
public int buttons()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||