summaryrefslogtreecommitdiff
path: root/firmware/drivers/button.c
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2003-12-20 10:00:37 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2003-12-20 10:00:37 +0000
commita5e1d06354fe1cb1dc12edd45b7f9ccb632df3e4 (patch)
tree8ae4aa3cec2e4697289153b641787c495ab8f19d /firmware/drivers/button.c
parent2a8386106b48e94051fe26659b95876cb442e71d (diff)
downloadrockbox-a5e1d06354fe1cb1dc12edd45b7f9ccb632df3e4.zip
rockbox-a5e1d06354fe1cb1dc12edd45b7f9ccb632df3e4.tar.gz
rockbox-a5e1d06354fe1cb1dc12edd45b7f9ccb632df3e4.tar.bz2
rockbox-a5e1d06354fe1cb1dc12edd45b7f9ccb632df3e4.tar.xz
Upside Down option for display (and buttons) now wired into the display settings menu, persistence, simulator stubs
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4168 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/button.c')
-rw-r--r--firmware/drivers/button.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index c0cd046..cfe98e2 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -34,6 +34,9 @@
struct event_queue button_queue;
long last_keypress;
+#ifdef HAVE_RECORDER_KEYPAD
+static bool flipped; /* bottons can be flipped to match the LCD flip */
+#endif
/* how often we check to see if a button is pressed */
#define POLL_FREQUENCY HZ/20
@@ -212,6 +215,47 @@ void button_init()
#endif
queue_init(&button_queue);
tick_add_task(button_tick);
+ last_keypress = current_tick;
+ flipped = false;
+}
+
+
+/*
+ * set the flip attribute
+ * better only call this when the queue is empty
+ */
+void button_set_flip(bool flip)
+{
+ flipped = flip;
+}
+
+
+/*
+ * helper function to swap UP/DOWN, LEFT/RIGHT, F1/F3
+ */
+static int button_flip(int button)
+{
+ int newbutton;
+
+ newbutton = button &
+ ~(BUTTON_UP | BUTTON_DOWN
+ | BUTTON_LEFT | BUTTON_RIGHT
+ | BUTTON_F1 | BUTTON_F3);
+
+ if (button & BUTTON_UP)
+ newbutton |= BUTTON_DOWN;
+ if (button & BUTTON_DOWN)
+ newbutton |= BUTTON_UP;
+ if (button & BUTTON_LEFT)
+ newbutton |= BUTTON_RIGHT;
+ if (button & BUTTON_RIGHT)
+ newbutton |= BUTTON_LEFT;
+ if (button & BUTTON_F1)
+ newbutton |= BUTTON_F3;
+ if (button & BUTTON_F3)
+ newbutton |= BUTTON_F1;
+
+ return newbutton;
}
/*
@@ -276,6 +320,9 @@ static int button_read(void)
#endif
}
}
+
+ if (btn && flipped)
+ return button_flip(btn); /* swap upside down */
return btn;
}