summaryrefslogtreecommitdiff
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
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
-rw-r--r--apps/plugins/rockboy/rockboy.c4
-rw-r--r--apps/plugins/rockboy/sys_rockbox.c77
2 files changed, 75 insertions, 6 deletions
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)
170 170
171 rb->lcd_setfont(0); 171 rb->lcd_setfont(0);
172 172
173#ifdef HAVE_WHEEL_POSITION
174 rb->wheel_send_events(false);
175#endif
176
173#if defined(HAVE_LCD_COLOR) 177#if defined(HAVE_LCD_COLOR)
174 rb->lcd_set_foreground(LCD_WHITE); 178 rb->lcd_set_foreground(LCD_WHITE);
175 rb->lcd_set_background(LCD_BLACK); 179 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)
69} 69}
70 70
71unsigned int oldbuttonstate = 0, newbuttonstate,holdbutton; 71unsigned int oldbuttonstate = 0, newbuttonstate,holdbutton;
72#ifdef HAVE_WHEEL_POSITION
73int oldwheel = -1, wheel;
74
75static int wheelmap[8] = {
76 PAD_UP, /* Top */
77 PAD_A, /* Top-right */
78 PAD_RIGHT, /* Right */
79 PAD_START, /* Bottom-right */
80 PAD_DOWN, /* Bottom */
81 PAD_SELECT, /* Bottom-left */
82 PAD_LEFT, /* Left */
83 PAD_B /* Top-left */
84};
85#endif
72 86
73int released, pressed; 87int released, pressed;
74 88
@@ -87,6 +101,44 @@ void ev_poll(void)
87 if (pressed & BUTTON_ON) 101 if (pressed & BUTTON_ON)
88 fb.mode=(fb.mode+1)%4; 102 fb.mode=(fb.mode+1)%4;
89#endif 103#endif
104
105#ifdef HAVE_WHEEL_POSITION
106 /* Get the current wheel position - 0..95 or -1 for untouched */
107 wheel = rb->wheel_status();
108
109 /* Convert to number from 0 to 7 - clockwise from top */
110 if ( wheel > 0 ){
111 wheel += 6;
112 wheel /= 12;
113 if ( wheel > 7 ) wheel = 0;
114 }
115
116 if ( wheel != oldwheel ) {
117 if (oldwheel >= 0) {
118 ev.type = EV_RELEASE;
119 ev.code = wheelmap[oldwheel];
120 ev_postevent(&ev);
121 }
122
123 if (wheel >= 0) {
124 ev.type = EV_PRESS;
125 ev.code = wheelmap[wheel];
126 ev_postevent(&ev);
127 }
128 }
129
130 oldwheel = wheel;
131 if(released) {
132 ev.type = EV_RELEASE;
133 if ( released & (~BUTTON_SELECT) ) { ev.code=PAD_B; ev_postevent(&ev); }
134 if ( released & BUTTON_SELECT ) { ev.code=PAD_A; ev_postevent(&ev); }
135 }
136 if(pressed) { /* button press */
137 ev.type = EV_PRESS;
138 if ( pressed & (~BUTTON_SELECT) ) { ev.code=PAD_B; ev_postevent(&ev); }
139 if ( pressed & BUTTON_SELECT ) { ev.code=PAD_A; ev_postevent(&ev); }
140 }
141#else
90 if(released) { 142 if(released) {
91 ev.type = EV_RELEASE; 143 ev.type = EV_RELEASE;
92 if(released & ROCKBOY_PAD_LEFT) { ev.code=PAD_LEFT; ev_postevent(&ev); } 144 if(released & ROCKBOY_PAD_LEFT) { ev.code=PAD_LEFT; ev_postevent(&ev); }
@@ -120,19 +172,32 @@ void ev_poll(void)
120 ev.code=PAD_SELECT; 172 ev.code=PAD_SELECT;
121 ev_postevent(&ev); 173 ev_postevent(&ev);
122 } 174 }
175#endif
176#if CONFIG_KEYPAD == IPOD_4G_PAD
177 if(rb->button_hold()) {
178#else
123 if(pressed & options.MENU) { 179 if(pressed & options.MENU) {
180#endif
124#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \ 181#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
125 (CONFIG_KEYPAD == IRIVER_H300_PAD) || \ 182 (CONFIG_KEYPAD == IRIVER_H300_PAD) || \
126 (CONFIG_KEYPAD == IPOD_4G_PAD) 183 (CONFIG_KEYPAD == IPOD_4G_PAD)
127 if (do_user_menu() == USER_MENU_QUIT) 184#ifdef HAVE_WHEEL_POSITION
185 rb->wheel_send_events(true);
186#endif
187 if (do_user_menu() == USER_MENU_QUIT)
188#endif
189 {
190 die("");
191 cleanshut=1;
192 }
193#ifdef HAVE_WHEEL_POSITION
194 rb->wheel_send_events(false);
128#endif 195#endif
129 {
130 die("");
131 cleanshut=1;
132 }
133 } 196 }
197#if CONFIG_KEYPAD != IPOD_4G_PAD
134 } 198 }
135 199
200#endif
136} 201}
137 202
138void vid_setpal(int i, int r, int g, int b) 203void vid_setpal(int i, int r, int g, int b)