diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2010-08-26 11:43:51 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2010-08-26 11:43:51 +0000 |
commit | aaa1636a8b17ab9ad1e5026c490ca1066280284a (patch) | |
tree | d3ab4701aae8639b949b4ec24f9f8da09b0f4cd9 /firmware/target/hosted | |
parent | 1d613bee0fd4b3bb6266a7ad93aade2aaeb3705c (diff) | |
download | rockbox-aaa1636a8b17ab9ad1e5026c490ca1066280284a.tar.gz 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.c | 56 | ||||
-rw-r--r-- | firmware/target/hosted/sdl/app/button-target.h | 37 | ||||
-rw-r--r-- | firmware/target/hosted/sdl/button-sdl.c | 18 | ||||
-rw-r--r-- | firmware/target/hosted/sdl/key_to_touch-sdl.c | 9 |
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 @@ | |||
20 | ***************************************************9*************************/ | 20 | ***************************************************9*************************/ |
21 | 21 | ||
22 | 22 | ||
23 | #include <stdio.h> | ||
24 | #include <SDL.h> | ||
23 | #include "button.h" | 25 | #include "button.h" |
26 | #include "buttonmap.h" | ||
24 | 27 | ||
25 | int key_to_button(int keyboard_key) | 28 | int key_to_button(int keyboard_key) |
26 | { | 29 | { |
27 | (void)keyboard_key; | 30 | int new_btn = BUTTON_NONE; |
28 | return BUTTON_NONE; | 31 | switch (keyboard_key) |
32 | { | ||
33 | case SDLK_KP7: | ||
34 | new_btn = BUTTON_TOPLEFT; | ||
35 | break; | ||
36 | case SDLK_KP8: | ||
37 | new_btn = BUTTON_TOPMIDDLE; | ||
38 | break; | ||
39 | case SDLK_KP9: | ||
40 | new_btn = BUTTON_TOPRIGHT; | ||
41 | break; | ||
42 | case SDLK_KP4: | ||
43 | case SDLK_LEFT: | ||
44 | new_btn = BUTTON_MIDLEFT; | ||
45 | break; | ||
46 | case SDLK_KP5: | ||
47 | new_btn = BUTTON_CENTER; | ||
48 | break; | ||
49 | case SDLK_KP6: | ||
50 | case SDLK_RIGHT: | ||
51 | new_btn = BUTTON_MIDRIGHT; | ||
52 | break; | ||
53 | case SDLK_KP1: | ||
54 | new_btn = BUTTON_BOTTOMLEFT; | ||
55 | break; | ||
56 | case SDLK_KP2: | ||
57 | case SDLK_DOWN: | ||
58 | new_btn = BUTTON_BOTTOMMIDDLE; | ||
59 | break; | ||
60 | case SDLK_KP3: | ||
61 | new_btn = BUTTON_BOTTOMRIGHT; | ||
62 | break; | ||
63 | #ifdef HAVE_SCROLLWHEEL | ||
64 | case SDL_BUTTON_WHEELUP: | ||
65 | new_btn = BUTTON_SCROLL_BACK; | ||
66 | break; | ||
67 | case SDL_BUTTON_WHEELDOWN: | ||
68 | new_btn = BUTTON_SCROLL_FWD; | ||
69 | break; | ||
70 | #endif | ||
71 | case SDL_BUTTON_RIGHT: | ||
72 | new_btn = BUTTON_MIDLEFT; | ||
73 | break; | ||
74 | case SDL_BUTTON_MIDDLE: | ||
75 | new_btn = BUTTON_MIDRIGHT; | ||
76 | break; | ||
77 | default: | ||
78 | break; | ||
79 | } | ||
80 | return new_btn; | ||
29 | } | 81 | } |
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); | |||
34 | int button_read_device(int *data); | 34 | int button_read_device(int *data); |
35 | 35 | ||
36 | /* Main unit's buttons */ | 36 | /* Main unit's buttons */ |
37 | #define BUTTON_POWER 0x00000001 | 37 | #define BUTTON_UP 0x00000001 |
38 | #define BUTTON_PLUS 0x00000002 | 38 | #define BUTTON_DOWN 0x00000002 |
39 | #define BUTTON_MINUS 0x00000004 | 39 | #define BUTTON_LEFT 0x00000004 |
40 | #define BUTTON_MENU 0x00000008 | 40 | #define BUTTON_RIGHT 0x00000008 |
41 | 41 | #define BUTTON_SELECT 0x00000010 | |
42 | /* Compatibility hacks for flipping. Needs a somewhat better fix. */ | 42 | #define BUTTON_MENU 0x00000020 |
43 | #define BUTTON_LEFT BUTTON_MIDLEFT | 43 | #define BUTTON_BACK 0x00000040 |
44 | #define BUTTON_RIGHT BUTTON_MIDRIGHT | 44 | #define BUTTON_SCROLL_FWD 0x00000100 |
45 | #define BUTTON_UP BUTTON_TOPMIDDLE | 45 | #define BUTTON_SCROLL_BACK 0x00000200 |
46 | #define BUTTON_DOWN BUTTON_BOTTOMMIDDLE | ||
47 | 46 | ||
48 | /* Touch Screen Area Buttons */ | 47 | /* Touch Screen Area Buttons */ |
49 | #define BUTTON_TOPLEFT 0x00000010 | 48 | #define BUTTON_TOPLEFT 0x00001000 |
50 | #define BUTTON_TOPMIDDLE 0x00000020 | 49 | #define BUTTON_TOPMIDDLE 0x00002000 |
51 | #define BUTTON_TOPRIGHT 0x00000040 | 50 | #define BUTTON_TOPRIGHT 0x00004000 |
52 | #define BUTTON_MIDLEFT 0x00000080 | 51 | #define BUTTON_MIDLEFT 0x00008000 |
53 | #define BUTTON_CENTER 0x00000100 | 52 | #define BUTTON_CENTER 0x00010000 |
54 | #define BUTTON_MIDRIGHT 0x00000200 | 53 | #define BUTTON_MIDRIGHT 0x00020000 |
55 | #define BUTTON_BOTTOMLEFT 0x00000400 | 54 | #define BUTTON_BOTTOMLEFT 0x00040000 |
56 | #define BUTTON_BOTTOMMIDDLE 0x00000800 | 55 | #define BUTTON_BOTTOMMIDDLE 0x00080000 |
57 | #define BUTTON_BOTTOMRIGHT 0x00001000 | 56 | #define BUTTON_BOTTOMRIGHT 0x00100000 |
58 | 57 | ||
59 | #define BUTTON_MAIN 0x1FFF | 58 | #define BUTTON_MAIN 0x1FFF |
60 | 59 | ||
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) | |||
112 | if(button_up) { | 112 | if(button_up) { |
113 | switch ( event->button ) | 113 | switch ( event->button ) |
114 | { | 114 | { |
115 | #ifdef HAVE_SCROLLWHEEL | ||
116 | case SDL_BUTTON_WHEELUP: | ||
117 | case SDL_BUTTON_WHEELDOWN: | ||
118 | #endif | ||
119 | case SDL_BUTTON_MIDDLE: | ||
120 | case SDL_BUTTON_RIGHT: | ||
121 | button_event( event->button, false ); | ||
122 | break; | ||
115 | /* The scrollwheel button up events are ignored as they are queued immediately */ | 123 | /* The scrollwheel button up events are ignored as they are queued immediately */ |
116 | case SDL_BUTTON_LEFT: | 124 | case SDL_BUTTON_LEFT: |
117 | case SDL_BUTTON_MIDDLE: | ||
118 | if ( mapping && background ) { | 125 | if ( mapping && background ) { |
119 | printf(" { SDLK_, %d, %d, %d, \"\" },\n", x, y, | 126 | printf(" { SDLK_, %d, %d, %d, \"\" },\n", x, y, |
120 | (int)sqrt( SQUARE(x-(int)event->x) + SQUARE(y-(int)event->y)) | 127 | (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) | |||
137 | { | 144 | { |
138 | #ifdef HAVE_SCROLLWHEEL | 145 | #ifdef HAVE_SCROLLWHEEL |
139 | case SDL_BUTTON_WHEELUP: | 146 | case SDL_BUTTON_WHEELUP: |
140 | button_event( SDLK_UP, true ); | ||
141 | break; | ||
142 | case SDL_BUTTON_WHEELDOWN: | 147 | case SDL_BUTTON_WHEELDOWN: |
143 | button_event( SDLK_DOWN, true ); | ||
144 | break; | ||
145 | #endif | 148 | #endif |
146 | case SDL_BUTTON_LEFT: | ||
147 | case SDL_BUTTON_MIDDLE: | 149 | case SDL_BUTTON_MIDDLE: |
150 | case SDL_BUTTON_RIGHT: | ||
151 | button_event( event->button, true ); | ||
152 | break; | ||
153 | case SDL_BUTTON_LEFT: | ||
148 | if ( mapping && background ) { | 154 | if ( mapping && background ) { |
149 | x = event->x; | 155 | x = event->x; |
150 | y = event->y; | 156 | 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) | |||
51 | } | 51 | } |
52 | } | 52 | } |
53 | break; | 53 | break; |
54 | #ifndef CONFIG_PLATFORM | ||
54 | case SDLK_KP7: | 55 | case SDLK_KP7: |
55 | case SDLK_7: | 56 | case SDLK_7: |
56 | new_btn = BUTTON_TOPLEFT; | 57 | new_btn = BUTTON_TOPLEFT; |
@@ -58,6 +59,9 @@ int key_to_touch(int keyboard_button, unsigned int mouse_coords) | |||
58 | case SDLK_KP8: | 59 | case SDLK_KP8: |
59 | case SDLK_8: | 60 | case SDLK_8: |
60 | case SDLK_UP: | 61 | case SDLK_UP: |
62 | #ifdef HAVE_SCROLLWHEEL | ||
63 | case SDL_BUTTON_WHEELDOWN: | ||
64 | #endif | ||
61 | new_btn = BUTTON_TOPMIDDLE; | 65 | new_btn = BUTTON_TOPMIDDLE; |
62 | break; | 66 | break; |
63 | case SDLK_KP9: | 67 | case SDLK_KP9: |
@@ -71,6 +75,7 @@ int key_to_touch(int keyboard_button, unsigned int mouse_coords) | |||
71 | break; | 75 | break; |
72 | case SDLK_KP5: | 76 | case SDLK_KP5: |
73 | case SDLK_i: | 77 | case SDLK_i: |
78 | case SDL_BUTTON_MIDDLE: | ||
74 | new_btn = BUTTON_CENTER; | 79 | new_btn = BUTTON_CENTER; |
75 | break; | 80 | break; |
76 | case SDLK_KP6: | 81 | case SDLK_KP6: |
@@ -84,6 +89,9 @@ int key_to_touch(int keyboard_button, unsigned int mouse_coords) | |||
84 | break; | 89 | break; |
85 | case SDLK_KP2: | 90 | case SDLK_KP2: |
86 | case SDLK_k: | 91 | case SDLK_k: |
92 | #ifdef HAVE_SCROLLWHEEL | ||
93 | case SDL_BUTTON_WHEELDOWN: | ||
94 | #endif | ||
87 | case SDLK_DOWN: | 95 | case SDLK_DOWN: |
88 | new_btn = BUTTON_BOTTOMMIDDLE; | 96 | new_btn = BUTTON_BOTTOMMIDDLE; |
89 | break; | 97 | break; |
@@ -91,6 +99,7 @@ int key_to_touch(int keyboard_button, unsigned int mouse_coords) | |||
91 | case SDLK_l: | 99 | case SDLK_l: |
92 | new_btn = BUTTON_BOTTOMRIGHT; | 100 | new_btn = BUTTON_BOTTOMRIGHT; |
93 | break; | 101 | break; |
102 | #endif | ||
94 | } | 103 | } |
95 | return new_btn; | 104 | return new_btn; |
96 | } | 105 | } |