summaryrefslogtreecommitdiff
path: root/firmware/target/hosted/sdl
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-07-06 15:11:56 +0000
committerThomas Martitz <kugel@rockbox.org>2010-07-06 15:11:56 +0000
commit31b5c471aeec6040ca69e3bea59c0825e2a6fc9d (patch)
tree628d7638a50ab226d5164f495d14d56ed2b51a1f /firmware/target/hosted/sdl
parent9da707955dcdefa1b7a55348937eb706a08039b5 (diff)
downloadrockbox-31b5c471aeec6040ca69e3bea59c0825e2a6fc9d.tar.gz
rockbox-31b5c471aeec6040ca69e3bea59c0825e2a6fc9d.zip
Rockbox as an application: Add an 320x240 SDL application target.
It still works mostly like the simulator. There's also some minor left overs from the sim, but it does not define SIMULATOR. It installs into the current (build) dir, and you need to run it with '--root .' (because it looks for ./.rockbox and not ./simdisk/rockbox) as options. That's one of the few kludges left that should be resolved soon'ish. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27310 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/hosted/sdl')
-rw-r--r--firmware/target/hosted/sdl/app/adc-target.h25
-rw-r--r--firmware/target/hosted/sdl/app/backlight-target.h25
-rw-r--r--firmware/target/hosted/sdl/app/button-application.c29
-rw-r--r--firmware/target/hosted/sdl/app/button-target.h68
-rw-r--r--firmware/target/hosted/sdl/app/i2c-target.h25
-rw-r--r--firmware/target/hosted/sdl/app/usb-target.h25
-rw-r--r--firmware/target/hosted/sdl/button-sdl.c4
-rw-r--r--firmware/target/hosted/sdl/buttonmap.h43
-rw-r--r--firmware/target/hosted/sdl/key_to_touch-sdl.c96
-rw-r--r--firmware/target/hosted/sdl/sim-ui-defines.h7
-rw-r--r--firmware/target/hosted/sdl/system-target.h1
11 files changed, 346 insertions, 2 deletions
diff --git a/firmware/target/hosted/sdl/app/adc-target.h b/firmware/target/hosted/sdl/app/adc-target.h
new file mode 100644
index 0000000000..f8069be6f5
--- /dev/null
+++ b/firmware/target/hosted/sdl/app/adc-target.h
@@ -0,0 +1,25 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 by Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef __ADC_TARGET_H__
23#define __ADC_TARGET_H__
24
25#endif /* __ADC_TARGET_H__ */
diff --git a/firmware/target/hosted/sdl/app/backlight-target.h b/firmware/target/hosted/sdl/app/backlight-target.h
new file mode 100644
index 0000000000..f753e7c1dd
--- /dev/null
+++ b/firmware/target/hosted/sdl/app/backlight-target.h
@@ -0,0 +1,25 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 by Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef __BACKLIGHT_TARGET_H__
23#define __BACKLIGHT_TARGET_H__
24
25#endif /* __BACKLIGHT_TARGET_H__ */
diff --git a/firmware/target/hosted/sdl/app/button-application.c b/firmware/target/hosted/sdl/app/button-application.c
new file mode 100644
index 0000000000..a27f769718
--- /dev/null
+++ b/firmware/target/hosted/sdl/app/button-application.c
@@ -0,0 +1,29 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ***************************************************9*************************/
21
22
23#include "button.h"
24
25int key_to_button(int keyboard_key)
26{
27 (void)keyboard_key;
28 return BUTTON_NONE;
29}
diff --git a/firmware/target/hosted/sdl/app/button-target.h b/firmware/target/hosted/sdl/app/button-target.h
new file mode 100644
index 0000000000..54ae3a2fae
--- /dev/null
+++ b/firmware/target/hosted/sdl/app/button-target.h
@@ -0,0 +1,68 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Rob Purchase
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef _BUTTON_TARGET_H_
23#define _BUTTON_TARGET_H_
24
25#include <stdbool.h>
26#include "config.h"
27/*
28
29#define HAS_BUTTON_HOLD
30
31bool button_hold(void);
32*/
33void button_init_device(void);
34int button_read_device(int *data);
35
36/* Main unit's buttons */
37#define BUTTON_POWER 0x00000001
38#define BUTTON_PLUS 0x00000002
39#define BUTTON_MINUS 0x00000004
40#define BUTTON_MENU 0x00000008
41
42/* Compatibility hacks for flipping. Needs a somewhat better fix. */
43#define BUTTON_LEFT BUTTON_MIDLEFT
44#define BUTTON_RIGHT BUTTON_MIDRIGHT
45#define BUTTON_UP BUTTON_TOPMIDDLE
46#define BUTTON_DOWN BUTTON_BOTTOMMIDDLE
47
48/* Touch Screen Area Buttons */
49#define BUTTON_TOPLEFT 0x00000010
50#define BUTTON_TOPMIDDLE 0x00000020
51#define BUTTON_TOPRIGHT 0x00000040
52#define BUTTON_MIDLEFT 0x00000080
53#define BUTTON_CENTER 0x00000100
54#define BUTTON_MIDRIGHT 0x00000200
55#define BUTTON_BOTTOMLEFT 0x00000400
56#define BUTTON_BOTTOMMIDDLE 0x00000800
57#define BUTTON_BOTTOMRIGHT 0x00001000
58
59#define BUTTON_MAIN 0x1FFF
60
61/* No remote */
62#define BUTTON_REMOTE 0
63
64/* Software power-off */
65#define POWEROFF_BUTTON BUTTON_POWER
66#define POWEROFF_COUNT 10
67
68#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/hosted/sdl/app/i2c-target.h b/firmware/target/hosted/sdl/app/i2c-target.h
new file mode 100644
index 0000000000..89f0436b9e
--- /dev/null
+++ b/firmware/target/hosted/sdl/app/i2c-target.h
@@ -0,0 +1,25 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 by Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef __I2C_TARGET_H__
23#define __I2C_TARGET_H__
24
25#endif /* __I2C_TARGET_H__ */
diff --git a/firmware/target/hosted/sdl/app/usb-target.h b/firmware/target/hosted/sdl/app/usb-target.h
new file mode 100644
index 0000000000..10e04677f9
--- /dev/null
+++ b/firmware/target/hosted/sdl/app/usb-target.h
@@ -0,0 +1,25 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 by Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef __USB_TARGET_H__
23#define __USB_TARGET_H__
24
25#endif /* __USB_TARGET_H__ */
diff --git a/firmware/target/hosted/sdl/button-sdl.c b/firmware/target/hosted/sdl/button-sdl.c
index 8b236c19f1..837c16c2ea 100644
--- a/firmware/target/hosted/sdl/button-sdl.c
+++ b/firmware/target/hosted/sdl/button-sdl.c
@@ -31,10 +31,8 @@
31#include "misc.h" 31#include "misc.h"
32#include "button-sdl.h" 32#include "button-sdl.h"
33#include "backlight.h" 33#include "backlight.h"
34#ifdef SIMULATOR
35#include "sim_tasks.h" 34#include "sim_tasks.h"
36#include "buttonmap.h" 35#include "buttonmap.h"
37#endif
38#include "debug.h" 36#include "debug.h"
39 37
40#ifdef HAVE_TOUCHSCREEN 38#ifdef HAVE_TOUCHSCREEN
@@ -139,6 +137,7 @@ bool gui_message_loop(void)
139 x = event.button.x; 137 x = event.button.x;
140 y = event.button.y; 138 y = event.button.y;
141 } 139 }
140#ifdef SIMULATOR
142 if ( background ) { 141 if ( background ) {
143 xybutton = xy2button( event.button.x, event.button.y ); 142 xybutton = xy2button( event.button.x, event.button.y );
144 if( xybutton ) { 143 if( xybutton ) {
@@ -146,6 +145,7 @@ bool gui_message_loop(void)
146 break; 145 break;
147 } 146 }
148 } 147 }
148#endif
149#ifdef HAVE_TOUCHSCREEN 149#ifdef HAVE_TOUCHSCREEN
150 touchscreen_event(event.button.x, event.button.y); 150 touchscreen_event(event.button.x, event.button.y);
151#endif 151#endif
diff --git a/firmware/target/hosted/sdl/buttonmap.h b/firmware/target/hosted/sdl/buttonmap.h
new file mode 100644
index 0000000000..e90b8a40d4
--- /dev/null
+++ b/firmware/target/hosted/sdl/buttonmap.h
@@ -0,0 +1,43 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 by Fred Bauer
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef __BUTTONMAP_H__
23#define __BUTTONMAP_H__
24/* Button maps: simulated key, x, y, radius, name */
25/* Run sim with --mapping to get coordinates */
26/* or --debugbuttons to check */
27/* The First matching button is returned */
28struct button_map {
29 int button, x, y, radius;
30 char *description;
31};
32
33extern struct button_map bm[];
34
35int xy2button( int x, int y);
36
37/* for the sim, these function is implemented in uisimulator/buttonmap/ *.c */
38int key_to_button(int keyboard_button);
39#ifdef HAVE_TOUCHSCREEN
40int key_to_touch(int keyboard_button, unsigned int mouse_coords);
41#endif
42
43#endif /* __BUTTONMAP_H__ */
diff --git a/firmware/target/hosted/sdl/key_to_touch-sdl.c b/firmware/target/hosted/sdl/key_to_touch-sdl.c
new file mode 100644
index 0000000000..90518c7c7e
--- /dev/null
+++ b/firmware/target/hosted/sdl/key_to_touch-sdl.c
@@ -0,0 +1,96 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 Jonathan Gordon
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22
23#include <stdio.h>
24#include <SDL.h>
25#include "button.h"
26#include "buttonmap.h"
27#include "touchscreen.h"
28
29int key_to_touch(int keyboard_button, unsigned int mouse_coords)
30{
31 int new_btn = BUTTON_NONE;
32 switch (keyboard_button)
33 {
34 case BUTTON_TOUCHSCREEN:
35 switch (touchscreen_get_mode())
36 {
37 case TOUCHSCREEN_POINT:
38 new_btn = BUTTON_TOUCHSCREEN;
39 break;
40 case TOUCHSCREEN_BUTTON:
41 {
42 static const int touchscreen_buttons[3][3] = {
43 {BUTTON_TOPLEFT, BUTTON_TOPMIDDLE, BUTTON_TOPRIGHT},
44 {BUTTON_MIDLEFT, BUTTON_CENTER, BUTTON_MIDRIGHT},
45 {BUTTON_BOTTOMLEFT, BUTTON_BOTTOMMIDDLE, BUTTON_BOTTOMRIGHT},
46 };
47 int px_x = ((mouse_coords&0xffff0000)>>16);
48 int px_y = ((mouse_coords&0x0000ffff));
49 new_btn = touchscreen_buttons[px_y/(LCD_HEIGHT/3)][px_x/(LCD_WIDTH/3)];
50 break;
51 }
52 }
53 break;
54 case SDLK_KP7:
55 case SDLK_7:
56 new_btn = BUTTON_TOPLEFT;
57 break;
58 case SDLK_KP8:
59 case SDLK_8:
60 case SDLK_UP:
61 new_btn = BUTTON_TOPMIDDLE;
62 break;
63 case SDLK_KP9:
64 case SDLK_9:
65 new_btn = BUTTON_TOPRIGHT;
66 break;
67 case SDLK_KP4:
68 case SDLK_u:
69 case SDLK_LEFT:
70 new_btn = BUTTON_MIDLEFT;
71 break;
72 case SDLK_KP5:
73 case SDLK_i:
74 new_btn = BUTTON_CENTER;
75 break;
76 case SDLK_KP6:
77 case SDLK_o:
78 case SDLK_RIGHT:
79 new_btn = BUTTON_MIDRIGHT;
80 break;
81 case SDLK_KP1:
82 case SDLK_j:
83 new_btn = BUTTON_BOTTOMLEFT;
84 break;
85 case SDLK_KP2:
86 case SDLK_k:
87 case SDLK_DOWN:
88 new_btn = BUTTON_BOTTOMMIDDLE;
89 break;
90 case SDLK_KP3:
91 case SDLK_l:
92 new_btn = BUTTON_BOTTOMRIGHT;
93 break;
94 }
95 return new_btn;
96}
diff --git a/firmware/target/hosted/sdl/sim-ui-defines.h b/firmware/target/hosted/sdl/sim-ui-defines.h
index 567a618fc3..926356dd9f 100644
--- a/firmware/target/hosted/sdl/sim-ui-defines.h
+++ b/firmware/target/hosted/sdl/sim-ui-defines.h
@@ -397,6 +397,13 @@
397#define UI_LCD_POSX 101 397#define UI_LCD_POSX 101
398#define UI_LCD_POSY 195 398#define UI_LCD_POSY 195
399 399
400#elif defined(APPLICATION)
401#define UI_TITLE "Rockbox"
402#define UI_LCD_POSX 0
403#define UI_LCD_POSY 0
404#define UI_WIDTH LCD_WIDTH
405#define UI_HEIGHT LCD_HEIGHT
406
400#elif defined(SIMULATOR) 407#elif defined(SIMULATOR)
401#error no UI defines 408#error no UI defines
402#endif 409#endif
diff --git a/firmware/target/hosted/sdl/system-target.h b/firmware/target/hosted/sdl/system-target.h
new file mode 100644
index 0000000000..31194fc33a
--- /dev/null
+++ b/firmware/target/hosted/sdl/system-target.h
@@ -0,0 +1 @@
#include "system-sdl.h"