summaryrefslogtreecommitdiffstats
path: root/apps/plugins/rockboy/sys_rockbox.c
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2006-09-26 19:25:20 +0000
committerDave Chapman <dave@dchapman.com>2006-09-26 19:25:20 +0000
commit181dab41379e743a87319a975385f6caa3521230 (patch)
tree717df53ecc6635dc84d6588bce787284ef5935cb /apps/plugins/rockboy/sys_rockbox.c
parent8d145f6d0d46804c411363bf9a948e3791cb9199 (diff)
downloadrockbox-181dab41379e743a87319a975385f6caa3521230.tar.gz
rockbox-181dab41379e743a87319a975385f6caa3521230.zip
Use the absolute wheel position driver for Rockboy. Mappings are: top = UP, top-right = A, right = RIGHT, bottom-right = START, bottom = DOWN, bottom-left = SELECT, left = LEFT and top-left = B. Based on patch #5424 by Anton Romanov
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11067 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/rockboy/sys_rockbox.c')
-rw-r--r--apps/plugins/rockboy/sys_rockbox.c77
1 files changed, 71 insertions, 6 deletions
diff --git a/apps/plugins/rockboy/sys_rockbox.c b/apps/plugins/rockboy/sys_rockbox.c
index 975a399965..4d4eb4b9d2 100644
--- a/apps/plugins/rockboy/sys_rockbox.c
+++ b/apps/plugins/rockboy/sys_rockbox.c
@@ -69,6 +69,20 @@ void joy_close(void)
}
unsigned int oldbuttonstate = 0, newbuttonstate,holdbutton;
+#ifdef HAVE_WHEEL_POSITION
+int oldwheel = -1, wheel;
+
+static int wheelmap[8] = {
+ PAD_UP, /* Top */
+ PAD_A, /* Top-right */
+ PAD_RIGHT, /* Right */
+ PAD_START, /* Bottom-right */
+ PAD_DOWN, /* Bottom */
+ PAD_SELECT, /* Bottom-left */
+ PAD_LEFT, /* Left */
+ PAD_B /* Top-left */
+};
+#endif
int released, pressed;
@@ -87,6 +101,44 @@ void ev_poll(void)
if (pressed & BUTTON_ON)
fb.mode=(fb.mode+1)%4;
#endif
+
+#ifdef HAVE_WHEEL_POSITION
+ /* Get the current wheel position - 0..95 or -1 for untouched */
+ wheel = rb->wheel_status();
+
+ /* Convert to number from 0 to 7 - clockwise from top */
+ if ( wheel > 0 ){
+ wheel += 6;
+ wheel /= 12;
+ if ( wheel > 7 ) wheel = 0;
+ }
+
+ if ( wheel != oldwheel ) {
+ if (oldwheel >= 0) {
+ ev.type = EV_RELEASE;
+ ev.code = wheelmap[oldwheel];
+ ev_postevent(&ev);
+ }
+
+ if (wheel >= 0) {
+ ev.type = EV_PRESS;
+ ev.code = wheelmap[wheel];
+ ev_postevent(&ev);
+ }
+ }
+
+ oldwheel = wheel;
+ if(released) {
+ ev.type = EV_RELEASE;
+ if ( released & (~BUTTON_SELECT) ) { ev.code=PAD_B; ev_postevent(&ev); }
+ if ( released & BUTTON_SELECT ) { ev.code=PAD_A; ev_postevent(&ev); }
+ }
+ if(pressed) { /* button press */
+ ev.type = EV_PRESS;
+ if ( pressed & (~BUTTON_SELECT) ) { ev.code=PAD_B; ev_postevent(&ev); }
+ if ( pressed & BUTTON_SELECT ) { ev.code=PAD_A; ev_postevent(&ev); }
+ }
+#else
if(released) {
ev.type = EV_RELEASE;
if(released & ROCKBOY_PAD_LEFT) { ev.code=PAD_LEFT; ev_postevent(&ev); }
@@ -120,19 +172,32 @@ void ev_poll(void)
ev.code=PAD_SELECT;
ev_postevent(&ev);
}
+#endif
+#if CONFIG_KEYPAD == IPOD_4G_PAD
+ if(rb->button_hold()) {
+#else
if(pressed & options.MENU) {
+#endif
#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
(CONFIG_KEYPAD == IRIVER_H300_PAD) || \
(CONFIG_KEYPAD == IPOD_4G_PAD)
- if (do_user_menu() == USER_MENU_QUIT)
+#ifdef HAVE_WHEEL_POSITION
+ rb->wheel_send_events(true);
+#endif
+ if (do_user_menu() == USER_MENU_QUIT)
+#endif
+ {
+ die("");
+ cleanshut=1;
+ }
+#ifdef HAVE_WHEEL_POSITION
+ rb->wheel_send_events(false);
#endif
- {
- die("");
- cleanshut=1;
- }
}
+#if CONFIG_KEYPAD != IPOD_4G_PAD
}
-
+
+#endif
}
void vid_setpal(int i, int r, int g, int b)