summaryrefslogtreecommitdiff
path: root/uisimulator/x11
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-11-21 23:55:39 +0000
committerJens Arnold <amiconn@rockbox.org>2005-11-21 23:55:39 +0000
commitb51f7dfc9b507ab9db12fe90b2ddad708f435e06 (patch)
treeefcef3411689401da21795d700a0741f8ab1072b /uisimulator/x11
parente68680ac310adb8373c9f3a5194466766d64cf37 (diff)
downloadrockbox-b51f7dfc9b507ab9db12fe90b2ddad708f435e06.tar.gz
rockbox-b51f7dfc9b507ab9db12fe90b2ddad708f435e06.zip
Backlight handling: * Added 'Caption Backlight' and 'Backlight On When Charging' for the iriver remote LCD. * Enabled the backlight code for the simulator, and prepared backlight simulation. It's only a stub atm, writing messages to the console window. * Added tick task handling to the simulators for this to work. * Code cleanup in backlight.c, less dead code.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8034 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/x11')
-rw-r--r--uisimulator/x11/button-x11.c11
-rw-r--r--uisimulator/x11/kernel.c52
-rw-r--r--uisimulator/x11/thread.c6
3 files changed, 64 insertions, 5 deletions
diff --git a/uisimulator/x11/button-x11.c b/uisimulator/x11/button-x11.c
index b2d8ab6c7a..e037867caf 100644
--- a/uisimulator/x11/button-x11.c
+++ b/uisimulator/x11/button-x11.c
@@ -21,6 +21,7 @@
21#include "button.h" 21#include "button.h"
22#include "kernel.h" 22#include "kernel.h"
23#include "debug.h" 23#include "debug.h"
24#include "backlight.h"
24#include "misc.h" 25#include "misc.h"
25 26
26#include "X11/keysym.h" 27#include "X11/keysym.h"
@@ -47,7 +48,7 @@ static long lastbtn; /* Last valid button status */
47/* mostly copied from real button.c */ 48/* mostly copied from real button.c */
48void button_read (void); 49void button_read (void);
49 50
50void button_tick(void) 51static void button_tick(void)
51{ 52{
52 static int tick = 0; 53 static int tick = 0;
53 static int count = 0; 54 static int count = 0;
@@ -117,6 +118,13 @@ void button_tick(void)
117 queue_post(&button_queue, BUTTON_REPEAT | btn, NULL); 118 queue_post(&button_queue, BUTTON_REPEAT | btn, NULL);
118 else 119 else
119 queue_post(&button_queue, btn, NULL); 120 queue_post(&button_queue, btn, NULL);
121#ifdef HAVE_REMOTE_LCD
122 if(btn & BUTTON_REMOTE)
123 remote_backlight_on();
124 else
125#endif
126 backlight_on();
127
120 } 128 }
121 } 129 }
122 else 130 else
@@ -276,6 +284,7 @@ long button_get_w_tmo(int ticks)
276 284
277void button_init(void) 285void button_init(void)
278{ 286{
287 tick_add_task(button_tick);
279} 288}
280 289
281int button_status(void) 290int button_status(void)
diff --git a/uisimulator/x11/kernel.c b/uisimulator/x11/kernel.c
index 7405fec52f..25f2df220c 100644
--- a/uisimulator/x11/kernel.c
+++ b/uisimulator/x11/kernel.c
@@ -17,8 +17,12 @@
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19 19
20#include <stddef.h>
20#include "kernel.h" 21#include "kernel.h"
21#include "thread.h" 22#include "thread.h"
23#include "debug.h"
24
25static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
22 26
23int set_irq_level (int level) 27int set_irq_level (int level)
24{ 28{
@@ -91,6 +95,54 @@ void switch_thread (void)
91 yield (); 95 yield ();
92} 96}
93 97
98void sim_tick_tasks(void)
99{
100 int i;
101
102 /* Run through the list of tick tasks */
103 for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
104 {
105 if(tick_funcs[i])
106 {
107 tick_funcs[i]();
108 }
109 }
110}
111
112int tick_add_task(void (*f)(void))
113{
114 int i;
115
116 /* Add a task if there is room */
117 for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
118 {
119 if(tick_funcs[i] == NULL)
120 {
121 tick_funcs[i] = f;
122 return 0;
123 }
124 }
125 DEBUGF("Error! tick_add_task(): out of tasks");
126 return -1;
127}
128
129int tick_remove_task(void (*f)(void))
130{
131 int i;
132
133 /* Remove a task if it is there */
134 for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
135 {
136 if(tick_funcs[i] == f)
137 {
138 tick_funcs[i] = NULL;
139 return 0;
140 }
141 }
142
143 return -1;
144}
145
94void mutex_init(struct mutex *m) 146void mutex_init(struct mutex *m)
95{ 147{
96 (void)m; 148 (void)m;
diff --git a/uisimulator/x11/thread.c b/uisimulator/x11/thread.c
index f3fe868fbc..6d9139c35d 100644
--- a/uisimulator/x11/thread.c
+++ b/uisimulator/x11/thread.c
@@ -30,7 +30,7 @@
30#endif 30#endif
31 31
32long current_tick = 0; 32long current_tick = 0;
33extern void button_tick(void); 33extern void sim_tick_tasks(void);
34 34
35static void msleep(int msec) 35static void msleep(int msec)
36{ 36{
@@ -59,10 +59,8 @@ static void update_tick_thread()
59 + (now.tv_usec - start.tv_usec) / (1000000/HZ); 59 + (now.tv_usec - start.tv_usec) / (1000000/HZ);
60 if (new_tick > current_tick) 60 if (new_tick > current_tick)
61 { 61 {
62 sim_tick_tasks();
62 current_tick = new_tick; 63 current_tick = new_tick;
63 button_tick(); /* Dirty call to button.c. This should probably
64 * be implemented as a tick task the same way
65 * as on the target. */
66 } 64 }
67 } 65 }
68} 66}