From 1817773ede93ba7ad867c1309f5c23fd7043957a Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 28 Sep 2011 19:09:38 +0000 Subject: Change X11 event loop initialization git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3991 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/arch/sim/src/Makefile | 17 ++++++++++++----- nuttx/arch/sim/src/up_internal.h | 14 +------------- nuttx/arch/sim/src/up_touchscreen.c | 9 ++------- nuttx/arch/sim/src/up_x11eventloop.c | 25 +++++++++++++++++++------ nuttx/configs/sim/README.txt | 12 ++++++++++++ 5 files changed, 46 insertions(+), 31 deletions(-) (limited to 'nuttx') diff --git a/nuttx/arch/sim/src/Makefile b/nuttx/arch/sim/src/Makefile index 0213a69dc..b3ed39a2c 100644 --- a/nuttx/arch/sim/src/Makefile +++ b/nuttx/arch/sim/src/Makefile @@ -88,18 +88,25 @@ SRCS = $(ASRCS) $(CSRCS) $(HOSTSRCS) OBJS = $(AOBJS) $(COBJS) $(HOSTOBJS) LDFLAGS = $(ARCHSCRIPT) + +# Determine which standard libraries will need to be linked in + ifeq ($(CONFIG_SIM_X11FB),y) - STDLIBS = -lX11 -lXext -lc -else - STDLIBS = -lc + STDLIBS += -lX11 -lXext +ifeq ($(CONFIG_SIM_TOUCHSCREEN),y) + STDLIBS += -lpthread endif +endif + ifeq ($(CONFIG_FS_FAT),y) -STDLIBS += -lz +STDLIBS += -lz endif +STDLIBS += -lc + LINKOBJS = up_head$(OBJEXT) LINKLIBS = -LDPATHS = $(addprefix -L$(TOPDIR)/,$(dir $(LINKLIBS))) +LDPATHS = $(addprefix -L$(TOPDIR)/,$(dir $(LINKLIBS))) LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(LINKLIBS)))) all: up_head$(OBJEXT) libarch$(LIBEXT) diff --git a/nuttx/arch/sim/src/up_internal.h b/nuttx/arch/sim/src/up_internal.h index 71a2380e2..2a1d9372a 100644 --- a/nuttx/arch/sim/src/up_internal.h +++ b/nuttx/arch/sim/src/up_internal.h @@ -63,18 +63,6 @@ # endif #endif -#ifdef CONFIG_SIM_TOUCHSCREEN -# ifndef CONFIG_SIM_EVLOOPPRIORITY -# define CONFIG_SIM_EVLOOPPRIORITY 50 -# endif -# ifndef CONFIG_SIM_EVLOOPSTACKSIZE -# define CONFIG_SIM_EVLOOPSTACKSIZE 4096 -# endif -#else -# undef CONFIG_SIM_EVLOOPPRIORITY -# undef CONFIG_SIM_EVLOOPSTACKSIZE -#endif - /* Context Switching Definitions ******************************************/ /* Storage order: %ebx, $esi, %edi, %ebp, sp, and return PC */ @@ -174,7 +162,7 @@ extern int up_x11cmap(unsigned short first, unsigned short len, #ifdef CONFIG_SIM_X11FB #ifdef CONFIG_SIM_TOUCHSCREEN -extern int up_x11eventloop(int argc, char *argv[]); +extern int up_x11eventloop(void); #endif #endif diff --git a/nuttx/arch/sim/src/up_touchscreen.c b/nuttx/arch/sim/src/up_touchscreen.c index 38e893128..a4c6be1cb 100644 --- a/nuttx/arch/sim/src/up_touchscreen.c +++ b/nuttx/arch/sim/src/up_touchscreen.c @@ -58,7 +58,6 @@ #include -#include "os_internal.h" #include "up_internal.h" /**************************************************************************** @@ -107,7 +106,6 @@ struct up_dev_s bool penchange; /* An unreported event is buffered */ sem_t devsem; /* Manages exclusive access to this structure */ sem_t waitsem; /* Used to wait for the availability of data */ - pid_t eventloop; /* PID of the eventloop */ struct up_sample_s sample; /* Last sampled touch point data */ @@ -631,7 +629,7 @@ int up_simtouchscreen(int minor) /* Debug-only sanity checks */ - DEBUGASSERT(minor >= 0 && minor < 100 && priv->eventloop == 0); + DEBUGASSERT(minor >= 0 && minor < 100); /* Initialize the touchscreen device driver instance */ @@ -641,15 +639,12 @@ int up_simtouchscreen(int minor) /* Start the X11 event loop */ - ret = KERNEL_THREAD("evloop", CONFIG_SIM_EVLOOPPRIORITY, - CONFIG_SIM_EVLOOPSTACKSIZE, - (main_t)up_x11eventloop, (const char **)NULL); + ret = up_x11eventloop(); if (ret < 0) { idbg("Failed to start event loop: %d\n", ret); goto errout_with_priv; } - priv->eventloop = ret; /* Register the device as an input device */ diff --git a/nuttx/arch/sim/src/up_x11eventloop.c b/nuttx/arch/sim/src/up_x11eventloop.c index d28a03ab9..a21f895c9 100644 --- a/nuttx/arch/sim/src/up_x11eventloop.c +++ b/nuttx/arch/sim/src/up_x11eventloop.c @@ -38,6 +38,8 @@ ****************************************************************************/ #include +#include + #include /**************************************************************************** @@ -68,6 +70,8 @@ extern int up_tcleave(int x, int y, int buttons); extern Display *g_display; extern Window g_window; +pthread_t g_eventloop; + /**************************************************************************** * Private Variables ****************************************************************************/ @@ -108,15 +112,11 @@ static int up_buttonmap(int state) return ret; } -/**************************************************************************** - * Public Functions - ***************************************************************************/ - /**************************************************************************** * Name: up_x11eventloop ***************************************************************************/ -int up_x11eventloop(int argc, char *argv[]) +static void *up_x11eventthread(void *arg) { XEvent event; int ret; @@ -164,5 +164,18 @@ int up_x11eventloop(int argc, char *argv[]) break; } } - return 0; + return NULL; } + +/**************************************************************************** + * Name: up_x11eventloop + ***************************************************************************/ + +int up_x11eventloop(void) +{ + /* Start the X11 event loop */ + + return pthread_create(&g_eventloop, 0, up_x11eventthread, 0); +} + + diff --git a/nuttx/configs/sim/README.txt b/nuttx/configs/sim/README.txt index 64258a6cb..3a9348d1c 100644 --- a/nuttx/configs/sim/README.txt +++ b/nuttx/configs/sim/README.txt @@ -266,6 +266,18 @@ nx11 CONFIG_INPUT=y CONFIG_SIM_TOUCHSCREEN=y + Then you must also have some application logic that will call + up_simtouchscreen(0) to register the touchscreen driver. + + NOTES: + 1. If you do not have this call, the build will mysteriously + fail claiming that is can't find up_tcenter(0 and up_tcleave(). + That is a consequence of the crazy way that the simulation is + built and can only be eliminated by call up_simtouchscreen(0) + from your application. + + 2. You must first call + X11 Build Issues ---------------- To get the system to compile under various X11 installations -- cgit v1.2.3