summaryrefslogtreecommitdiffstats
path: root/firmware/target/hosted
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-08-26 11:43:51 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-08-26 11:43:51 +0000
commitaaa1636a8b17ab9ad1e5026c490ca1066280284a (patch)
treed3ab4701aae8639b949b4ec24f9f8da09b0f4cd9 /firmware/target/hosted
parent1d613bee0fd4b3bb6266a7ad93aade2aaeb3705c (diff)
downloadrockbox-aaa1636a8b17ab9ad1e5026c490ca1066280284a.tar.gz
rockbox-aaa1636a8b17ab9ad1e5026c490ca1066280284a.tar.bz2
rockbox-aaa1636a8b17ab9ad1e5026c490ca1066280284a.zip
Move to a proper sdl key config instead of using the d2 pad. make the mouse wheel work, middle click is "select" and right click is "back"
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27891 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/hosted')
-rw-r--r--firmware/target/hosted/sdl/app/button-application.c56
-rw-r--r--firmware/target/hosted/sdl/app/button-target.h37
-rw-r--r--firmware/target/hosted/sdl/button-sdl.c18
-rw-r--r--firmware/target/hosted/sdl/key_to_touch-sdl.c9
4 files changed, 93 insertions, 27 deletions
diff --git a/firmware/target/hosted/sdl/app/button-application.c b/firmware/target/hosted/sdl/app/button-application.c
index a27f769718..3f31933951 100644
--- a/firmware/target/hosted/sdl/app/button-application.c
+++ b/firmware/target/hosted/sdl/app/button-application.c
@@ -20,10 +20,62 @@
***************************************************9*************************/
+#include <stdio.h>
+#include <SDL.h>
#include "button.h"
+#include "buttonmap.h"
int key_to_button(int keyboard_key)
{
- (void)keyboard_key;
- return BUTTON_NONE;
+ int new_btn = BUTTON_NONE;
+ switch (keyboard_key)
+ {
+ 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:
+ case SDLK_LEFT:
+ new_btn = BUTTON_MIDLEFT;
+ break;
+ case SDLK_KP5:
+ new_btn = BUTTON_CENTER;
+ break;
+ case SDLK_KP6:
+ case SDLK_RIGHT:
+ new_btn = BUTTON_MIDRIGHT;
+ break;
+ case SDLK_KP1:
+ new_btn = BUTTON_BOTTOMLEFT;
+ break;
+ case SDLK_KP2:
+ case SDLK_DOWN:
+ new_btn = BUTTON_BOTTOMMIDDLE;
+ break;
+ case SDLK_KP3:
+ new_btn = BUTTON_BOTTOMRIGHT;
+ break;
+#ifdef HAVE_SCROLLWHEEL
+ case SDL_BUTTON_WHEELUP:
+ new_btn = BUTTON_SCROLL_BACK;
+ break;
+ case SDL_BUTTON_WHEELDOWN:
+ new_btn = BUTTON_SCROLL_FWD;
+ break;
+#endif
+ case SDL_BUTTON_RIGHT:
+ new_btn = BUTTON_MIDLEFT;
+ break;
+ case SDL_BUTTON_MIDDLE:
+ new_btn = BUTTON_MIDRIGHT;
+ break;
+ default:
+ break;
+ }
+ return new_btn;
}
diff --git a/firmware/target/hosted/sdl/app/button-target.h b/firmware/target/hosted/sdl/app/button-target.h
index 54ae3a2fae..5295315e2e 100644
--- a/firmware/target/hosted/sdl/app/button-target.h
+++ b/firmware/target/hosted/sdl/app/button-target.h
@@ -34,27 +34,26 @@ void button_init_device(void);
int button_read_device(int *data);
/* Main unit's buttons */
-#define BUTTON_POWER 0x00000001
-#define BUTTON_PLUS 0x00000002
-#define BUTTON_MINUS 0x00000004
-#define BUTTON_MENU 0x00000008
-
-/* Compatibility hacks for flipping. Needs a somewhat better fix. */
-#define BUTTON_LEFT BUTTON_MIDLEFT
-#define BUTTON_RIGHT BUTTON_MIDRIGHT
-#define BUTTON_UP BUTTON_TOPMIDDLE
-#define BUTTON_DOWN BUTTON_BOTTOMMIDDLE
+#define BUTTON_UP 0x00000001
+#define BUTTON_DOWN 0x00000002
+#define BUTTON_LEFT 0x00000004
+#define BUTTON_RIGHT 0x00000008
+#define BUTTON_SELECT 0x00000010
+#define BUTTON_MENU 0x00000020
+#define BUTTON_BACK 0x00000040
+#define BUTTON_SCROLL_FWD 0x00000100
+#define BUTTON_SCROLL_BACK 0x00000200
/* Touch Screen Area Buttons */
-#define BUTTON_TOPLEFT 0x00000010
-#define BUTTON_TOPMIDDLE 0x00000020
-#define BUTTON_TOPRIGHT 0x00000040
-#define BUTTON_MIDLEFT 0x00000080
-#define BUTTON_CENTER 0x00000100
-#define BUTTON_MIDRIGHT 0x00000200
-#define BUTTON_BOTTOMLEFT 0x00000400
-#define BUTTON_BOTTOMMIDDLE 0x00000800
-#define BUTTON_BOTTOMRIGHT 0x00001000
+#define BUTTON_TOPLEFT 0x00001000
+#define BUTTON_TOPMIDDLE 0x00002000
+#define BUTTON_TOPRIGHT 0x00004000
+#define BUTTON_MIDLEFT 0x00008000
+#define BUTTON_CENTER 0x00010000
+#define BUTTON_MIDRIGHT 0x00020000
+#define BUTTON_BOTTOMLEFT 0x00040000
+#define BUTTON_BOTTOMMIDDLE 0x00080000
+#define BUTTON_BOTTOMRIGHT 0x00100000
#define BUTTON_MAIN 0x1FFF
diff --git a/firmware/target/hosted/sdl/button-sdl.c b/firmware/target/hosted/sdl/button-sdl.c
index ee16e55fd1..519ac8d7c5 100644
--- a/firmware/target/hosted/sdl/button-sdl.c
+++ b/firmware/target/hosted/sdl/button-sdl.c
@@ -112,9 +112,16 @@ static void mouse_event(SDL_MouseButtonEvent *event, bool button_up)
if(button_up) {
switch ( event->button )
{
+#ifdef HAVE_SCROLLWHEEL
+ case SDL_BUTTON_WHEELUP:
+ case SDL_BUTTON_WHEELDOWN:
+#endif
+ case SDL_BUTTON_MIDDLE:
+ case SDL_BUTTON_RIGHT:
+ button_event( event->button, false );
+ break;
/* The scrollwheel button up events are ignored as they are queued immediately */
case SDL_BUTTON_LEFT:
- case SDL_BUTTON_MIDDLE:
if ( mapping && background ) {
printf(" { SDLK_, %d, %d, %d, \"\" },\n", x, y,
(int)sqrt( SQUARE(x-(int)event->x) + SQUARE(y-(int)event->y))
@@ -137,14 +144,13 @@ static void mouse_event(SDL_MouseButtonEvent *event, bool button_up)
{
#ifdef HAVE_SCROLLWHEEL
case SDL_BUTTON_WHEELUP:
- button_event( SDLK_UP, true );
- break;
case SDL_BUTTON_WHEELDOWN:
- button_event( SDLK_DOWN, true );
- break;
#endif
- case SDL_BUTTON_LEFT:
case SDL_BUTTON_MIDDLE:
+ case SDL_BUTTON_RIGHT:
+ button_event( event->button, true );
+ break;
+ case SDL_BUTTON_LEFT:
if ( mapping && background ) {
x = event->x;
y = event->y;
diff --git a/firmware/target/hosted/sdl/key_to_touch-sdl.c b/firmware/target/hosted/sdl/key_to_touch-sdl.c
index 90518c7c7e..a63df18ff5 100644
--- a/firmware/target/hosted/sdl/key_to_touch-sdl.c
+++ b/firmware/target/hosted/sdl/key_to_touch-sdl.c
@@ -51,6 +51,7 @@ int key_to_touch(int keyboard_button, unsigned int mouse_coords)
}
}
break;
+#ifndef CONFIG_PLATFORM
case SDLK_KP7:
case SDLK_7:
new_btn = BUTTON_TOPLEFT;
@@ -58,6 +59,9 @@ int key_to_touch(int keyboard_button, unsigned int mouse_coords)
case SDLK_KP8:
case SDLK_8:
case SDLK_UP:
+#ifdef HAVE_SCROLLWHEEL
+ case SDL_BUTTON_WHEELDOWN:
+#endif
new_btn = BUTTON_TOPMIDDLE;
break;
case SDLK_KP9:
@@ -71,6 +75,7 @@ int key_to_touch(int keyboard_button, unsigned int mouse_coords)
break;
case SDLK_KP5:
case SDLK_i:
+ case SDL_BUTTON_MIDDLE:
new_btn = BUTTON_CENTER;
break;
case SDLK_KP6:
@@ -84,6 +89,9 @@ int key_to_touch(int keyboard_button, unsigned int mouse_coords)
break;
case SDLK_KP2:
case SDLK_k:
+#ifdef HAVE_SCROLLWHEEL
+ case SDL_BUTTON_WHEELDOWN:
+#endif
case SDLK_DOWN:
new_btn = BUTTON_BOTTOMMIDDLE;
break;
@@ -91,6 +99,7 @@ int key_to_touch(int keyboard_button, unsigned int mouse_coords)
case SDLK_l:
new_btn = BUTTON_BOTTOMRIGHT;
break;
+#endif
}
return new_btn;
}