From 181dab41379e743a87319a975385f6caa3521230 Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Tue, 26 Sep 2006 19:25:20 +0000 Subject: 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 --- apps/plugins/rockboy/rockboy.c | 4 ++ apps/plugins/rockboy/sys_rockbox.c | 77 +++++++++++++++++++++++++++++++++++--- 2 files changed, 75 insertions(+), 6 deletions(-) (limited to 'apps/plugins') diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c index 47af58c975..3b26d935e6 100644 --- a/apps/plugins/rockboy/rockboy.c +++ b/apps/plugins/rockboy/rockboy.c @@ -170,6 +170,10 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) rb->lcd_setfont(0); +#ifdef HAVE_WHEEL_POSITION + rb->wheel_send_events(false); +#endif + #if defined(HAVE_LCD_COLOR) rb->lcd_set_foreground(LCD_WHITE); rb->lcd_set_background(LCD_BLACK); 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) -- cgit v1.2.3