Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Gameduino mbed nRF2401A
Fork of Gameduino_Invaders_game by
Diff: joystick.h
- Revision:
- 4:bb78bedae411
- Parent:
- 2:20a89dc286d5
diff -r 9b01f67c7e15 -r bb78bedae411 joystick.h
--- a/joystick.h Fri Dec 21 13:53:46 2012 +0000
+++ b/joystick.h Sat Oct 26 22:34:08 2013 +0000
@@ -13,6 +13,14 @@
//#include "WProgram.h"
#include "arduino.h"
+
+#define STICK_LEFT_BIT 0x01
+#define STICK_RIGHT_BIT 0x02
+#define STICK_UP_BIT 0x04
+#define STICK_DOWN_BIT 0x08
+#define ANALOG_STICK_BIT 0x80
+#define STICK_INFO_MASK (ANALOG_STICK_BIT)
+
class Joystick {
byte buttons; // State of buttons, packed into a byte
byte prev; // State of the buttons on previous read
@@ -29,7 +37,6 @@
// Return "true" if analog X/Y position is available
bool hasAnalogStick();
-
// Digital joystick functions
enum button_name {
buttonA = 0x01,
@@ -49,10 +56,10 @@
bool changed(byte n) { return bool((buttons^prev)&n); }
// Joystick up/down/left/right (or analog stick)
- bool left() { return (dpad&0x01)!=0; }
- bool right() { return (dpad&0x02)!=0; }
- bool up() { return (dpad&0x04)!=0; }
- bool down() { return (dpad&0x08)!=0; }
+ bool left() { return (dpad&STICK_LEFT_BIT)!=0; }
+ bool right() { return (dpad&STICK_RIGHT_BIT)!=0; }
+ bool up() { return (dpad&STICK_UP_BIT)!=0; }
+ bool down() { return (dpad&STICK_DOWN_BIT)!=0; }
// Analog joystick functions
