summaryrefslogtreecommitdiffstats
path: root/apps/plugins/invadrox.c
diff options
context:
space:
mode:
authorTomer Shalev <shalev.tomer@gmail.com>2009-12-12 10:07:37 +0000
committerTomer Shalev <shalev.tomer@gmail.com>2009-12-12 10:07:37 +0000
commitbe7170c89c373d40d4fd5c8f0c2e7961d73dbb4e (patch)
tree7d8374c6e38806ff2ac8ed33f3118c5a86a623ab /apps/plugins/invadrox.c
parent703468f0a64a146b7265631c03bb1473a4151740 (diff)
downloadrockbox-be7170c89c373d40d4fd5c8f0c2e7961d73dbb4e.tar.gz
rockbox-be7170c89c373d40d4fd5c8f0c2e7961d73dbb4e.tar.bz2
rockbox-be7170c89c373d40d4fd5c8f0c2e7961d73dbb4e.zip
Invadrox: Add support for both touchscreen and buttons control of the game.
- Add buttons support for Cowon D2 - Introduce some mighty #ifdef hell :-( git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23941 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/invadrox.c')
-rw-r--r--apps/plugins/invadrox.c55
1 files changed, 33 insertions, 22 deletions
diff --git a/apps/plugins/invadrox.c b/apps/plugins/invadrox.c
index 1bd80f0c36..9aa8efeecb 100644
--- a/apps/plugins/invadrox.c
+++ b/apps/plugins/invadrox.c
@@ -157,6 +157,9 @@ PLUGIN_HEADER
#elif CONFIG_KEYPAD == COWOND2_PAD
#define QUIT BUTTON_POWER
+#define LEFT BUTTON_MINUS
+#define RIGHT BUTTON_PLUS
+#define FIRE BUTTON_MENU
#elif CONFIG_KEYPAD == IAUDIO67_PAD
@@ -197,18 +200,32 @@ CONFIG_KEYPAD == MROBE500_PAD
#endif
#ifdef HAVE_TOUCHSCREEN
-#ifndef QUIT
-#define QUIT BUTTON_TOPLEFT
-#endif
-#ifndef LEFT
-#define LEFT BUTTON_MIDLEFT
-#endif
-#ifndef RIGHT
-#define RIGHT BUTTON_MIDRIGHT
+
+#define TOUCHSCREEN_QUIT BUTTON_TOPLEFT
+#define TOUCHSCREEN_LEFT (BUTTON_MIDLEFT | BUTTON_BOTTOMLEFT)
+#define TOUCHSCREEN_RIGHT (BUTTON_MIDRIGHT | BUTTON_BOTTOMRIGHT)
+#define TOUCHSCREEN_FIRE (BUTTON_CENTER | BUTTON_BOTTOMMIDDLE)
+
+#ifdef RC_QUIT
+#define ACTION_QUIT (QUIT | TOUCHSCREEN_QUIT | RC_QUIT)
+#else
+#define ACTION_QUIT (QUIT | TOUCHSCREEN_QUIT)
#endif
-#ifndef FIRE
-#define FIRE BUTTON_CENTER
+#define ACTION_LEFT (LEFT | TOUCHSCREEN_LEFT)
+#define ACTION_RIGHT (RIGHT | TOUCHSCREEN_RIGHT)
+#define ACTION_FIRE (FIRE | TOUCHSCREEN_FIRE)
+
+#else
+
+#ifdef RC_QUIT
+#define ACTION_QUIT (QUIT | RC_QUIT)
+#else
+#define ACTION_QUIT QUIT
#endif
+#define ACTION_LEFT LEFT
+#define ACTION_RIGHT RIGHT
+#define ACTION_FIRE FIRE
+
#endif
#ifndef UNUSED
@@ -1650,17 +1667,17 @@ inline bool handle_buttons(void)
pressed = newbuttonstate & ~oldbuttonstate;
oldbuttonstate = newbuttonstate;
if (pressed) {
- if (pressed & LEFT) {
+ if (pressed & ACTION_LEFT) {
if (ship_acc > -1) {
ship_acc--;
}
}
- if (pressed & RIGHT) {
+ if (pressed & ACTION_RIGHT) {
if (ship_acc < 1) {
ship_acc++;
}
}
- if (pressed & FIRE) {
+ if (pressed & ACTION_FIRE) {
if (fire == S_IDLE) {
/* Fire shot */
fire_x = ship_x + SHIP_WIDTH / 2;
@@ -1669,24 +1686,18 @@ inline bool handle_buttons(void)
/* TODO: play fire sound */
}
}
-#ifdef RC_QUIT
- if (pressed & RC_QUIT) {
- rb->splash(HZ * 1, "Quit");
- return true;
- }
-#endif
- if (pressed & QUIT) {
+ if (pressed & ACTION_QUIT) {
rb->splash(HZ * 1, "Quit");
return true;
}
}
if (released) {
- if ((released & LEFT)) {
+ if ((released & ACTION_LEFT)) {
if (ship_acc < 1) {
ship_acc++;
}
}
- if ((released & RIGHT)) {
+ if ((released & ACTION_RIGHT)) {
if (ship_acc > -1) {
ship_acc--;
}