summaryrefslogtreecommitdiffstats
path: root/uisimulator/x11
diff options
context:
space:
mode:
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 @@
#include "button.h"
#include "kernel.h"
#include "debug.h"
+#include "backlight.h"
#include "misc.h"
#include "X11/keysym.h"
@@ -47,7 +48,7 @@ static long lastbtn; /* Last valid button status */
/* mostly copied from real button.c */
void button_read (void);
-void button_tick(void)
+static void button_tick(void)
{
static int tick = 0;
static int count = 0;
@@ -117,6 +118,13 @@ void button_tick(void)
queue_post(&button_queue, BUTTON_REPEAT | btn, NULL);
else
queue_post(&button_queue, btn, NULL);
+#ifdef HAVE_REMOTE_LCD
+ if(btn & BUTTON_REMOTE)
+ remote_backlight_on();
+ else
+#endif
+ backlight_on();
+
}
}
else
@@ -276,6 +284,7 @@ long button_get_w_tmo(int ticks)
void button_init(void)
{
+ tick_add_task(button_tick);
}
int 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 @@
*
****************************************************************************/
+#include <stddef.h>
#include "kernel.h"
#include "thread.h"
+#include "debug.h"
+
+static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
int set_irq_level (int level)
{
@@ -91,6 +95,54 @@ void switch_thread (void)
yield ();
}
+void sim_tick_tasks(void)
+{
+ int i;
+
+ /* Run through the list of tick tasks */
+ for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
+ {
+ if(tick_funcs[i])
+ {
+ tick_funcs[i]();
+ }
+ }
+}
+
+int tick_add_task(void (*f)(void))
+{
+ int i;
+
+ /* Add a task if there is room */
+ for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
+ {
+ if(tick_funcs[i] == NULL)
+ {
+ tick_funcs[i] = f;
+ return 0;
+ }
+ }
+ DEBUGF("Error! tick_add_task(): out of tasks");
+ return -1;
+}
+
+int tick_remove_task(void (*f)(void))
+{
+ int i;
+
+ /* Remove a task if it is there */
+ for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
+ {
+ if(tick_funcs[i] == f)
+ {
+ tick_funcs[i] = NULL;
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
void mutex_init(struct mutex *m)
{
(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 @@
#endif
long current_tick = 0;
-extern void button_tick(void);
+extern void sim_tick_tasks(void);
static void msleep(int msec)
{
@@ -59,10 +59,8 @@ static void update_tick_thread()
+ (now.tv_usec - start.tv_usec) / (1000000/HZ);
if (new_tick > current_tick)
{
+ sim_tick_tasks();
current_tick = new_tick;
- button_tick(); /* Dirty call to button.c. This should probably
- * be implemented as a tick task the same way
- * as on the target. */
}
}
}