NXWidgets::CImage needs to catch mouse/touchscreen events; All touchscreen drivers need to report the last valid X/Y data when the screen is untouched.
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4731 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
4da2091db0
commit
776db19800
@ -2746,4 +2746,7 @@
|
||||
other logic can use the defaults.
|
||||
* graphics/nxtk/nxtk_events.c: Fixed an important but in the logic that
|
||||
translates the mouse/touchscreen position data for framed windows and toolbars.
|
||||
|
||||
* drivers/input/stmpe11_tsc.c, tsc2007.c, and ads7843e.c: Need to keep track of
|
||||
when if positional data is valid. When the touch is released, the X/Y position
|
||||
of the release must be the same as the X/Y position of the last touch (se that
|
||||
the release occurs in the same window as the last touch).
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* drivers/input/ads7843e.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||
* Diego Sanchez <dsanchez@nx-engineering.com>
|
||||
*
|
||||
@ -383,9 +383,12 @@ static int ads7843e_sample(FAR struct ads7843e_dev_s *priv,
|
||||
|
||||
if (sample->contact == CONTACT_UP)
|
||||
{
|
||||
/* Next.. no contact. Increment the ID so that next contact ID will be unique */
|
||||
/* Next.. no contact. Increment the ID so that next contact ID
|
||||
* will be unique. X/Y positions are no longer valid.
|
||||
*/
|
||||
|
||||
priv->sample.contact = CONTACT_NONE;
|
||||
priv->sample.valid = false;
|
||||
priv->id++;
|
||||
}
|
||||
else if (sample->contact == CONTACT_DOWN)
|
||||
@ -584,15 +587,28 @@ static void ads7843e_worker(FAR void *arg)
|
||||
|
||||
priv->sample.contact = CONTACT_UP;
|
||||
}
|
||||
|
||||
/* It is a pen down event. If the last loss-of-contact event has not been
|
||||
* processed yet, then we have to ignore the pen down event (or else it will
|
||||
* look like a drag event)
|
||||
*/
|
||||
|
||||
else if (priv->sample.contact == CONTACT_UP)
|
||||
{
|
||||
goto errout;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Handle all pen down events. First, sample positional values. */
|
||||
/* Handle pen down events. First, sample positional values. */
|
||||
|
||||
priv->sample.x = ads7843e_sendcmd(priv, ADS7843_CMD_XPOSITION);
|
||||
priv->sample.y = ads7843e_sendcmd(priv, ADS7843_CMD_YPOSITION);
|
||||
(void)ads7843e_sendcmd(priv, ADS7843_CMD_ENABPINIRQ);
|
||||
|
||||
/* If this is the first (acknowledged) pend down report, then report
|
||||
/* The X/Y positional data is now valid */
|
||||
|
||||
priv->sample.valid = true;
|
||||
|
||||
/* If this is the first (acknowledged) pen down report, then report
|
||||
* this as the first contact. If contact == CONTACT_DOWN, it will be
|
||||
* set to set to CONTACT_MOVE after the contact is first sampled.
|
||||
*/
|
||||
@ -621,6 +637,7 @@ static void ads7843e_worker(FAR void *arg)
|
||||
/* Exit, re-enabling ADS7843E interrupts */
|
||||
|
||||
errout:
|
||||
(void)ads7843e_sendcmd(priv, ADS7843_CMD_ENABPINIRQ);
|
||||
config->enable(config, true);
|
||||
}
|
||||
|
||||
@ -856,9 +873,20 @@ static ssize_t ads7843e_read(FAR struct file *filep, FAR char *buffer, size_t le
|
||||
|
||||
if (sample.contact == CONTACT_UP)
|
||||
{
|
||||
/* Pen is now up */
|
||||
/* Pen is now up. Is the positional data valid? This is important to
|
||||
* know because the release will be sent to the window based on its
|
||||
* last positional data.
|
||||
*/
|
||||
|
||||
report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID;
|
||||
if (sample.valid)
|
||||
{
|
||||
report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID |
|
||||
TOUCH_POS_VALID | TOUCH_PRESSURE_VALID;
|
||||
}
|
||||
else
|
||||
{
|
||||
report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID;
|
||||
}
|
||||
}
|
||||
else if (sample.contact == CONTACT_DOWN)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/********************************************************************************************
|
||||
* drivers/input/ads7843e.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* References:
|
||||
@ -115,6 +115,7 @@ struct ads7843e_sample_s
|
||||
{
|
||||
uint8_t id; /* Sampled touch point ID */
|
||||
uint8_t contact; /* Contact state (see enum ads7843e_contact_e) */
|
||||
bool valid; /* True: x,y contain valid, sampled data */
|
||||
uint16_t x; /* Measured X position */
|
||||
uint16_t y; /* Measured Y position */
|
||||
};
|
||||
|
@ -111,6 +111,7 @@ struct stmpe11_sample_s
|
||||
{
|
||||
uint8_t id; /* Sampled touch point ID */
|
||||
uint8_t contact; /* Contact state (see enum stmpe11_contact_e) */
|
||||
bool valid; /* True: x,y,z contain valid, sampled data */
|
||||
uint16_t x; /* Measured X position */
|
||||
uint16_t y; /* Measured Y position */
|
||||
uint8_t z; /* Measured Z index */
|
||||
|
@ -242,6 +242,7 @@ static int stmpe11_sample(FAR struct stmpe11_dev_s *priv,
|
||||
*/
|
||||
|
||||
priv->sample.contact = CONTACT_NONE;
|
||||
priv->sample.valid = false;
|
||||
priv->id++;
|
||||
}
|
||||
else if (sample->contact == CONTACT_DOWN)
|
||||
@ -537,26 +538,34 @@ static ssize_t stmpe11_read(FAR struct file *filep, FAR char *buffer, size_t len
|
||||
|
||||
if (sample.contact == CONTACT_UP)
|
||||
{
|
||||
/* Pen is now up */
|
||||
/* Pen is now up. Is the positional data valid? This is important to
|
||||
* know because the release will be sent to the window based on its
|
||||
* last positional data.
|
||||
*/
|
||||
|
||||
report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID;
|
||||
if (sample.valid)
|
||||
{
|
||||
report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID |
|
||||
TOUCH_POS_VALID | TOUCH_PRESSURE_VALID;
|
||||
}
|
||||
else
|
||||
{
|
||||
report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (sample.contact == CONTACT_DOWN)
|
||||
{
|
||||
if (sample.contact == CONTACT_DOWN)
|
||||
{
|
||||
/* First contact */
|
||||
/* First contact */
|
||||
|
||||
report->point[0].flags = TOUCH_DOWN | TOUCH_ID_VALID |
|
||||
TOUCH_POS_VALID | TOUCH_PRESSURE_VALID;
|
||||
}
|
||||
else /* if (sample->contact == CONTACT_MOVE) */
|
||||
{
|
||||
/* Movement of the same contact */
|
||||
report->point[0].flags = TOUCH_DOWN | TOUCH_ID_VALID |
|
||||
TOUCH_POS_VALID | TOUCH_PRESSURE_VALID;
|
||||
}
|
||||
else /* if (sample->contact == CONTACT_MOVE) */
|
||||
{
|
||||
/* Movement of the same contact */
|
||||
|
||||
report->point[0].flags = TOUCH_MOVE | TOUCH_ID_VALID |
|
||||
TOUCH_POS_VALID | TOUCH_PRESSURE_VALID;
|
||||
}
|
||||
report->point[0].flags = TOUCH_MOVE | TOUCH_ID_VALID |
|
||||
TOUCH_POS_VALID | TOUCH_PRESSURE_VALID;
|
||||
}
|
||||
|
||||
ret = SIZEOF_TOUCH_SAMPLE_S(1);
|
||||
@ -996,17 +1005,18 @@ void stmpe11_tscworker(FAR struct stmpe11_dev_s *priv, uint8_t intsta)
|
||||
|
||||
/* When we see a big difference, snap to the new x/y thresholds */
|
||||
|
||||
priv->threshx = x;
|
||||
priv->threshy = y;
|
||||
priv->threshx = x;
|
||||
priv->threshy = y;
|
||||
|
||||
/* Update the x/y position in the sample data */
|
||||
|
||||
priv->sample.x = priv->threshx;
|
||||
priv->sample.y = priv->threshy;
|
||||
priv->sample.x = priv->threshx;
|
||||
priv->sample.y = priv->threshy;
|
||||
|
||||
/* Update the Z pressure index */
|
||||
|
||||
priv->sample.z = stmpe11_getreg8(priv, STMPE11_TSC_DATAZ);
|
||||
priv->sample.z = stmpe11_getreg8(priv, STMPE11_TSC_DATAZ);
|
||||
priv->sample.valid = true;
|
||||
|
||||
/* If this is the first (acknowledged) pen down report, then report
|
||||
* this as the first contact. If contact == CONTACT_DOWN, it will be
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* drivers/input/tsc2007.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* References:
|
||||
@ -142,6 +142,7 @@ struct tsc2007_sample_s
|
||||
{
|
||||
uint8_t id; /* Sampled touch point ID */
|
||||
uint8_t contact; /* Contact state (see enum tsc2007_contact_e) */
|
||||
bool valid; /* True: x,y,pressure contain valid, sampled data */
|
||||
uint16_t x; /* Measured X position */
|
||||
uint16_t y; /* Measured Y position */
|
||||
uint16_t pressure; /* Calculated pressure */
|
||||
@ -314,9 +315,12 @@ static int tsc2007_sample(FAR struct tsc2007_dev_s *priv,
|
||||
|
||||
if (sample->contact == CONTACT_UP)
|
||||
{
|
||||
/* Next.. no contract. Increment the ID so that next contact ID will be unique */
|
||||
/* Next.. no contact. Increment the ID so that next contact ID
|
||||
* will be unique. X/Y positions are no longer valid.
|
||||
*/
|
||||
|
||||
priv->sample.contact = CONTACT_NONE;
|
||||
priv->sample.valid = false;
|
||||
priv->id++;
|
||||
}
|
||||
else if (sample->contact == CONTACT_DOWN)
|
||||
@ -586,6 +590,16 @@ static void tsc2007_worker(FAR void *arg)
|
||||
goto errout;
|
||||
}
|
||||
}
|
||||
|
||||
/* It is a pen down event. If the last loss-of-contact event has not been
|
||||
* processed yet, then we have to ignore the pen down event (or else it will
|
||||
* look like a drag event)
|
||||
*/
|
||||
|
||||
else if (priv->sample.contact == CONTACT_UP)
|
||||
{
|
||||
goto errout;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Handle all pen down events. First, sample X, Y, Z1, and Z2 values.
|
||||
@ -678,6 +692,7 @@ static void tsc2007_worker(FAR void *arg)
|
||||
priv->sample.x = x;
|
||||
priv->sample.y = y;
|
||||
priv->sample.pressure = pressure;
|
||||
priv->sample.valid = true;
|
||||
}
|
||||
|
||||
/* Note the availability of new measurements */
|
||||
@ -956,9 +971,20 @@ static ssize_t tsc2007_read(FAR struct file *filep, FAR char *buffer, size_t len
|
||||
|
||||
if (sample.contact == CONTACT_UP)
|
||||
{
|
||||
/* Pen is now up */
|
||||
/* Pen is now up. Is the positional data valid? This is important to
|
||||
* know because the release will be sent to the window based on its
|
||||
* last positional data.
|
||||
*/
|
||||
|
||||
report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID;
|
||||
if (sample.valid)
|
||||
{
|
||||
report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID |
|
||||
TOUCH_POS_VALID | TOUCH_PRESSURE_VALID;
|
||||
}
|
||||
else
|
||||
{
|
||||
report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/********************************************************************************************
|
||||
* drivers/input/tsc2007.h
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* References:
|
||||
|
Loading…
Reference in New Issue
Block a user