summaryrefslogtreecommitdiffstats
path: root/uisimulator
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2008-04-15 10:35:11 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2008-04-15 10:35:11 +0000
commit5b5a626bb6ba54ccdcd90741cea5f9cbd0f79553 (patch)
tree0bf60b83aad534757330162ad4f683f142955ccb /uisimulator
parent50851794a6bdd585ce70ecb430b1f798fb90936b (diff)
downloadrockbox-5b5a626bb6ba54ccdcd90741cea5f9cbd0f79553.tar.gz
rockbox-5b5a626bb6ba54ccdcd90741cea5f9cbd0f79553.tar.bz2
rockbox-5b5a626bb6ba54ccdcd90741cea5f9cbd0f79553.zip
Setup the touchpads to have two modes - stylus and button - and set them in button mode by default.
in button mode the touchpad is split into a 3x3 grid for 9 seperate buttons which can be used by the action system like real buttons. Unify the keymap file for the touchpads in button mode. the target keymap file only needs to worry about real buttons. (As these ports mature each screen will need to be fixed seperatly to be able to use stylus mode (the lists can already but don't change mode just yet.) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17114 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator')
-rw-r--r--uisimulator/sdl/button.c118
-rw-r--r--uisimulator/sdl/uisdl.c6
2 files changed, 74 insertions, 50 deletions
diff --git a/uisimulator/sdl/button.c b/uisimulator/sdl/button.c
index 15764da900..6672a4164e 100644
--- a/uisimulator/sdl/button.c
+++ b/uisimulator/sdl/button.c
@@ -32,6 +32,15 @@ static intptr_t button_data; /* data value from last message dequeued */
#ifdef HAVE_TOUCHPAD
static int mouse_coords = 0;
+static enum touchpad_mode touchpad_mode = TOUCHPAD_POINT;
+void touchpad_set_mode(enum touchpad_mode mode)
+{
+ touchpad_mode = mode;
+}
+enum touchpad_mode touchpad_get_mode(void)
+{
+ return touchpad_mode;
+}
#endif
/* how long until repeat kicks in */
#define REPEAT_START 6
@@ -111,9 +120,53 @@ void button_event(int key, bool pressed)
#ifdef HAVE_TOUCHPAD
case BUTTON_TOUCHPAD:
- new_btn = BUTTON_TOUCHPAD;
data = mouse_coords;
+ switch (touchpad_mode)
+ {
+ case TOUCHPAD_POINT:
+ new_btn = BUTTON_TOUCHPAD;
+ break;
+ case TOUCHPAD_BUTTON:
+ {
+ static int touchpad_buttons[3][3] = {
+ {BUTTON_TOPLEFT, BUTTON_TOPMIDDLE, BUTTON_TOPRIGHT},
+ {BUTTON_MIDLEFT, BUTTON_CENTER, BUTTON_MIDRIGHT},
+ {BUTTON_BOTTOMLEFT, BUTTON_BOTTOMMIDDLE, BUTTON_BOTTOMRIGHT},
+ };
+ int px_x = ((data&0xffff0000)>>16), px_y = ((data&0x0000ffff));
+ new_btn = touchpad_buttons[px_y/(LCD_HEIGHT/3)][px_x/(LCD_WIDTH/3)];
+ break;
+ }
+ }
break;
+ case SDLK_KP7:
+ new_btn = BUTTON_TOPLEFT;
+ break;
+ case SDLK_KP8:
+ new_btn = BUTTON_TOPMIDDLE;
+ break;
+ case SDLK_KP9:
+ new_btn = BUTTON_TOPRIGHT;
+ break;
+ case SDLK_KP4:
+ new_btn = BUTTON_MIDLEFT;
+ break;
+ case SDLK_KP5:
+ new_btn = BUTTON_CENTER;
+ break;
+ case SDLK_KP6:
+ new_btn = BUTTON_MIDRIGHT;
+ break;
+ case SDLK_KP1:
+ new_btn = BUTTON_BOTTOMLEFT;
+ break;
+ case SDLK_KP2:
+ new_btn = BUTTON_BOTTOMMIDDLE;
+ break;
+ case SDLK_KP3:
+ new_btn = BUTTON_BOTTOMRIGHT;
+ break;
+
#endif
case SDLK_u:
if (!pressed)
@@ -665,43 +718,34 @@ void button_event(int key, bool pressed)
break;
#elif CONFIG_KEYPAD == MROBE500_PAD
- case SDLK_KP4:
+ case SDLK_F9:
+ new_btn = BUTTON_RC_HEART;
+ break;
+ case SDLK_F10:
+ new_btn = BUTTON_RC_MODE;
+ break;
+ case SDLK_F11:
+ new_btn = BUTTON_RC_VOL_DOWN;
+ break;
+ case SDLK_F12:
+ new_btn = BUTTON_RC_VOL_UP;
+ break;
case SDLK_LEFT:
new_btn = BUTTON_LEFT;
break;
- case SDLK_KP6:
case SDLK_RIGHT:
new_btn = BUTTON_RIGHT;
break;
- case SDLK_KP8:
case SDLK_UP:
new_btn = BUTTON_RC_PLAY;
break;
- case SDLK_KP2:
case SDLK_DOWN:
new_btn = BUTTON_RC_DOWN;
break;
- case SDLK_KP_PLUS:
case SDLK_F8:
- new_btn = BUTTON_POWER;
- break;
case SDLK_ESCAPE:
new_btn = BUTTON_POWER;
break;
- case SDLK_KP_ENTER:
- case SDLK_RETURN:
- case SDLK_a:
- new_btn = BUTTON_RC_VOL_UP;
- break;
- case SDLK_KP5:
- case SDLK_SPACE:
- new_btn = BUTTON_RC_HEART;
- break;
- case SDLK_KP_PERIOD:
- case SDLK_INSERT:
- new_btn = BUTTON_RC_MODE;
- break;
-
#elif CONFIG_KEYPAD == MROBE100_PAD
case SDLK_KP1:
new_btn = BUTTON_DISPLAY;
@@ -739,37 +783,16 @@ void button_event(int key, bool pressed)
break;
#elif CONFIG_KEYPAD == COWOND2_PAD
- case SDLK_KP4:
- case SDLK_LEFT:
- new_btn = BUTTON_LEFT;
- break;
- case SDLK_KP6:
- case SDLK_RIGHT:
- new_btn = BUTTON_RIGHT;
- break;
- case SDLK_KP8:
- case SDLK_UP:
- new_btn = BUTTON_UP;
- break;
- case SDLK_KP2:
- case SDLK_DOWN:
- new_btn = BUTTON_DOWN;
- break;
- case SDLK_KP3:
+ case SDLK_ESCAPE:
new_btn = BUTTON_POWER;
break;
- case SDLK_KP5:
- case SDLK_KP_ENTER:
- case SDLK_RETURN:
- new_btn = BUTTON_SELECT;
- break;
case SDLK_KP_PLUS:
new_btn = BUTTON_PLUS;
break;
case SDLK_KP_MINUS:
new_btn = BUTTON_MINUS;
break;
- case SDLK_KP9:
+ case SDLK_KP_ENTER:
new_btn = BUTTON_MENU;
break;
#else
@@ -977,11 +1000,6 @@ void mouse_tick_task(void)
if (debug_wps)
printf("Mouse at: (%d, %d)\n", x, y);
}
- else if (lastbtn == BUTTON_TOUCHPAD)
- {
- button_event(BUTTON_TOUCHPAD, false);
- mouse_coords = 0;
- }
}
#endif
void button_init(void)
diff --git a/uisimulator/sdl/uisdl.c b/uisimulator/sdl/uisdl.c
index 09210926b5..28aaf59f82 100644
--- a/uisimulator/sdl/uisdl.c
+++ b/uisimulator/sdl/uisdl.c
@@ -83,6 +83,12 @@ void gui_message_loop(void)
printf("Mouse at: (%d, %d)\n", event.button.x, event.button.y);
}
break;
+#else
+ case SDL_MOUSEBUTTONUP:
+ sim_enter_irq_handler();
+ button_event(BUTTON_TOUCHPAD, false);
+ sim_exit_irq_handler();
+ break;
#endif
case SDL_QUIT:
done = true;