arch/sim: Make eventloop as an internal variable to simplify up_idle.
This commit is contained in:
parent
28d7061550
commit
14a82f40d2
@ -85,6 +85,7 @@ static const struct ajoy_lowerhalf_s g_ajoylower =
|
|||||||
|
|
||||||
/* Driver state data */
|
/* Driver state data */
|
||||||
|
|
||||||
|
static int g_eventloop;
|
||||||
static bool g_ajoy_valid; /* True: Sample data is valid */
|
static bool g_ajoy_valid; /* True: Sample data is valid */
|
||||||
static struct ajoy_sample_s g_ajoy_sample; /* Last sample data */
|
static struct ajoy_sample_s g_ajoy_sample; /* Last sample data */
|
||||||
static ajoy_buttonset_t g_ajoy_buttons; /* Last buttons set */
|
static ajoy_buttonset_t g_ajoy_buttons; /* Last buttons set */
|
||||||
@ -196,12 +197,17 @@ int sim_ajoy_initialize(void)
|
|||||||
* Name: up_buttonevent
|
* Name: up_buttonevent
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int up_buttonevent(int x, int y, int buttons)
|
void up_buttonevent(int x, int y, int buttons)
|
||||||
{
|
{
|
||||||
ajoy_buttonset_t changed;
|
ajoy_buttonset_t changed;
|
||||||
ajoy_buttonset_t pressed;
|
ajoy_buttonset_t pressed;
|
||||||
ajoy_buttonset_t released;
|
ajoy_buttonset_t released;
|
||||||
|
|
||||||
|
if (g_eventloop == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Same the positional data */
|
/* Same the positional data */
|
||||||
|
|
||||||
g_ajoy_sample.as_x = x;
|
g_ajoy_sample.as_x = x;
|
||||||
@ -248,6 +254,4 @@ int up_buttonevent(int x, int y, int buttons)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,12 @@ void up_idle(void)
|
|||||||
up_devconloop();
|
up_devconloop();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_SIM_TOUCHSCREEN) || defined(CONFIG_SIM_AJOYSTICK)
|
||||||
|
/* Drive the X11 event loop */
|
||||||
|
|
||||||
|
up_x11events();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NET_ETHERNET) && defined(CONFIG_SIM_NETDEV)
|
#if defined(CONFIG_NET_ETHERNET) && defined(CONFIG_SIM_NETDEV)
|
||||||
/* Run the network if enabled */
|
/* Run the network if enabled */
|
||||||
|
|
||||||
@ -148,15 +154,6 @@ void up_idle(void)
|
|||||||
#ifdef CONFIG_SIM_X11FB
|
#ifdef CONFIG_SIM_X11FB
|
||||||
if (g_x11initialized)
|
if (g_x11initialized)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_SIM_TOUCHSCREEN) || defined(CONFIG_SIM_AJOYSTICK)
|
|
||||||
/* Drive the X11 event loop */
|
|
||||||
|
|
||||||
if (g_eventloop)
|
|
||||||
{
|
|
||||||
up_x11events();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Update the display periodically */
|
/* Update the display periodically */
|
||||||
|
|
||||||
g_x11refresh += 1000000 / CLK_TCK;
|
g_x11refresh += 1000000 / CLK_TCK;
|
||||||
|
@ -199,9 +199,6 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_SIM_X11FB
|
#ifdef CONFIG_SIM_X11FB
|
||||||
extern int g_x11initialized;
|
extern int g_x11initialized;
|
||||||
#if defined(CONFIG_SIM_TOUCHSCREEN) || defined(CONFIG_SIM_AJOYSTICK)
|
|
||||||
extern volatile int g_eventloop;
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
@ -300,21 +297,17 @@ int up_x11cmap(unsigned short first, unsigned short len,
|
|||||||
|
|
||||||
/* up_touchscreen.c *********************************************************/
|
/* up_touchscreen.c *********************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_SIM_TOUCHSCREEN
|
||||||
int sim_tsc_initialize(int minor);
|
int sim_tsc_initialize(int minor);
|
||||||
void sim_tsc_uninitialize(void);
|
void sim_tsc_uninitialize(void);
|
||||||
|
|
||||||
/* up_eventloop.c ***********************************************************/
|
|
||||||
|
|
||||||
#if defined(CONFIG_SIM_X11FB) && \
|
|
||||||
(defined(CONFIG_SIM_TOUCHSCREEN) || defined(CONFIG_SIM_AJOYSTICK))
|
|
||||||
void up_x11events(void);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* up_eventloop.c ***********************************************************/
|
/* up_eventloop.c ***********************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_SIM_X11FB) && \
|
#if defined(CONFIG_SIM_X11FB) && \
|
||||||
(defined(CONFIG_SIM_TOUCHSCREEN) || defined(CONFIG_SIM_AJOYSTICK))
|
(defined(CONFIG_SIM_TOUCHSCREEN) || defined(CONFIG_SIM_AJOYSTICK))
|
||||||
int up_buttonevent(int x, int y, int buttons);
|
void up_x11events(void);
|
||||||
|
void up_buttonevent(int x, int y, int buttons);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* up_ajoystick.c ***********************************************************/
|
/* up_ajoystick.c ***********************************************************/
|
||||||
|
@ -108,6 +108,7 @@ struct up_sample_s
|
|||||||
|
|
||||||
struct up_dev_s
|
struct up_dev_s
|
||||||
{
|
{
|
||||||
|
int eventloop;
|
||||||
volatile uint8_t nwaiters; /* Number of threads waiting for touchscreen data */
|
volatile uint8_t nwaiters; /* Number of threads waiting for touchscreen data */
|
||||||
uint8_t id; /* Current touch point ID */
|
uint8_t id; /* Current touch point ID */
|
||||||
uint8_t minor; /* Minor device number */
|
uint8_t minor; /* Minor device number */
|
||||||
@ -650,7 +651,7 @@ int sim_tsc_initialize(int minor)
|
|||||||
|
|
||||||
/* Enable X11 event processing from the IDLE loop */
|
/* Enable X11 event processing from the IDLE loop */
|
||||||
|
|
||||||
g_eventloop = 1;
|
priv->eventloop = 1;
|
||||||
|
|
||||||
/* And return success */
|
/* And return success */
|
||||||
|
|
||||||
@ -691,7 +692,7 @@ void sim_tsc_uninitialize(void)
|
|||||||
* done in close() using a reference count).
|
* done in close() using a reference count).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
g_eventloop = 0;
|
priv->eventloop = 0;
|
||||||
|
|
||||||
/* Un-register the device */
|
/* Un-register the device */
|
||||||
|
|
||||||
@ -714,11 +715,16 @@ void sim_tsc_uninitialize(void)
|
|||||||
* Name: up_buttonevent
|
* Name: up_buttonevent
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int up_buttonevent(int x, int y, int buttons)
|
void up_buttonevent(int x, int y, int buttons)
|
||||||
{
|
{
|
||||||
FAR struct up_dev_s *priv = (FAR struct up_dev_s *)&g_simtouchscreen;
|
FAR struct up_dev_s *priv = (FAR struct up_dev_s *)&g_simtouchscreen;
|
||||||
bool pendown; /* true: pen is down */
|
bool pendown; /* true: pen is down */
|
||||||
|
|
||||||
|
if (priv->eventloop == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
iinfo("x=%d y=%d buttons=%02x\n", x, y, buttons);
|
iinfo("x=%d y=%d buttons=%02x\n", x, y, buttons);
|
||||||
iinfo("contact=%d nwaiters=%d\n", priv->sample.contact, priv->nwaiters);
|
iinfo("contact=%d nwaiters=%d\n", priv->sample.contact, priv->nwaiters);
|
||||||
|
|
||||||
@ -736,7 +742,7 @@ int up_buttonevent(int x, int y, int buttons)
|
|||||||
|
|
||||||
if (priv->sample.contact == CONTACT_NONE)
|
if (priv->sample.contact == CONTACT_NONE)
|
||||||
{
|
{
|
||||||
return OK;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Not yet reported */
|
/* Not yet reported */
|
||||||
@ -772,5 +778,4 @@ int up_buttonevent(int x, int y, int buttons)
|
|||||||
/* Notify any waiters that new touchscreen data is available */
|
/* Notify any waiters that new touchscreen data is available */
|
||||||
|
|
||||||
up_notify(priv);
|
up_notify(priv);
|
||||||
return OK;
|
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
extern int up_buttonevent(int x, int y, int buttons);
|
extern void up_buttonevent(int x, int y, int buttons);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
@ -55,8 +55,6 @@ extern int up_buttonevent(int x, int y, int buttons);
|
|||||||
|
|
||||||
extern Display *g_display;
|
extern Display *g_display;
|
||||||
|
|
||||||
volatile int g_eventloop;
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -107,7 +105,7 @@ void up_x11events(void)
|
|||||||
|
|
||||||
/* Check if there are any pending, queue X11 events. */
|
/* Check if there are any pending, queue X11 events. */
|
||||||
|
|
||||||
if (XPending(g_display) > 0)
|
if (g_display && XPending(g_display) > 0)
|
||||||
{
|
{
|
||||||
/* Yes, get the event (this should not block since we know there are
|
/* Yes, get the event (this should not block since we know there are
|
||||||
* pending events)
|
* pending events)
|
||||||
|
Loading…
Reference in New Issue
Block a user