diff options
-rw-r--r-- | glcddrivers/driver.c | 4 | ||||
-rw-r--r-- | glcddrivers/driver.h | 6 | ||||
-rw-r--r-- | glcddrivers/serdisp.c | 44 | ||||
-rw-r--r-- | glcddrivers/serdisp.h | 24 | ||||
-rw-r--r-- | glcdskin/object.c | 4 |
5 files changed, 58 insertions, 24 deletions
diff --git a/glcddrivers/driver.c b/glcddrivers/driver.c index fadef72..ea13eaf 100644 --- a/glcddrivers/driver.c +++ b/glcddrivers/driver.c @@ -10,7 +10,7 @@ * to the COPYING file distributed with this package. * * (c) 2004-2010 Andreas Regel <andreas.regel AT powarman.de> - * (c) 2010-2011 Wolfgang Astleitner <mrwastl AT users sourceforge net> + * (c) 2010-2013 Wolfgang Astleitner <mrwastl AT users sourceforge net> */ #include "common.h" @@ -20,7 +20,7 @@ namespace GLCD { -cSimpleTouchEvent::cSimpleTouchEvent() : x(0), y(0), touch(0) +cTouchEvent::cTouchEvent() : x(0), y(0), touch(0) { } diff --git a/glcddrivers/driver.h b/glcddrivers/driver.h index ca6980a..3e28a3f 100644 --- a/glcddrivers/driver.h +++ b/glcddrivers/driver.h @@ -10,7 +10,7 @@ * to the COPYING file distributed with this package. * * (c) 2004-2010 Andreas Regel <andreas.regel AT powarman.de> - * (c) 2010-2011 Wolfgang Astleitner <mrwastl AT users sourceforge net> + * (c) 2010-2013 Wolfgang Astleitner <mrwastl AT users sourceforge net> */ #ifndef _GLCDDRIVERS_DRIVER_H_ @@ -30,12 +30,12 @@ public: virtual ~cGLCDEvent() {} }; -class cSimpleTouchEvent : public cGLCDEvent { +class cTouchEvent : public cGLCDEvent { public: int x; int y; int touch; - cSimpleTouchEvent(); + cTouchEvent(); }; class cDriverConfig; diff --git a/glcddrivers/serdisp.c b/glcddrivers/serdisp.c index a45c1c1..1fac5ba 100644 --- a/glcddrivers/serdisp.c +++ b/glcddrivers/serdisp.c @@ -7,7 +7,7 @@ * This file is released under the GNU General Public License. Refer * to the COPYING file distributed with this package. * - * (c) 2003-2012 Wolfgang Astleitner <mrwastl AT users.sourceforge.net> + * (c) 2003-2013 Wolfgang Astleitner <mrwastl AT users.sourceforge.net> */ #include <stdio.h> @@ -36,6 +36,11 @@ // taken from serdisp_gpevents.h #define SDGPT_SIMPLETOUCH 0x10 /* simple touch screen event, type: SDGP_evpkt_simpletouch_t */ +#define SDGPT_GENERICTOUCH 0x11 /* generic touch screen event, type: SDGP_evpkt_generictouch_t */ + +#define SDGPT_TOUCHDOWN 0x0 +#define SDGPT_TOUCHUP 0x1 +#define SDGPT_TOUCHMOVE 0x2 namespace GLCD { @@ -359,7 +364,7 @@ int cDriverSerDisp::Init(void) Clear(); touchEvent = new tTouchEvent; - touchEvent->simpleTouchChanged = false; + touchEvent->touchChanged = false; touchEvents[dd] = touchEvent; syslog(LOG_INFO, "%s: SerDisp with %s initialized.\n", config->name.c_str(), controller.c_str()); @@ -598,15 +603,15 @@ bool cDriverSerDisp::GetDriverFeature (const std::string & Feature, int & value cGLCDEvent * cDriverSerDisp::GetEvent(void) { tTouchEvent* tev = touchEvents[dd]; - if (tev && tev->simpleTouchChanged == false) + if (tev && tev->touchChanged == false) return NULL; - cSimpleTouchEvent * ev = new cSimpleTouchEvent(); + cTouchEvent * ev = new cTouchEvent(); - ev->x = tev->simpleTouchX; - ev->y = tev->simpleTouchY; - ev->touch = tev->simpleTouchT; - tev->simpleTouchChanged = false; + ev->x = tev->touchX; + ev->y = tev->touchY; + ev->touch = tev->touchT; + tev->touchChanged = false; return ev; } @@ -619,10 +624,25 @@ static void wrapEventListener(void* dd, SDGP_event_t* event) { tTouchEvent* tev = touchEvents[dd]; if (tev) { - tev->simpleTouchChanged = true; - tev->simpleTouchX = simpletouch.norm_x; - tev->simpleTouchY = simpletouch.norm_y; - tev->simpleTouchT = simpletouch.norm_touch; + tev->touchChanged = true; + tev->touchX = simpletouch.norm_x; + tev->touchY = simpletouch.norm_y; + tev->touchT = simpletouch.norm_touch; + } + } else if (event->type == SDGPT_GENERICTOUCH) { + SDGP_evpkt_generictouch_t generictouch; + memcpy(&generictouch, &event->data, sizeof(SDGP_evpkt_generictouch_t)); + + /* ignore all but SDGPT_TOUCHDOWN events */ + if (generictouch.type != SDGPT_TOUCHDOWN) + return; + + tTouchEvent* tev = touchEvents[dd]; + if (tev) { + tev->touchChanged = true; + tev->touchX = generictouch.norm_x; + tev->touchY = generictouch.norm_y; + tev->touchT = (int)generictouch.norm_touch; } } } diff --git a/glcddrivers/serdisp.h b/glcddrivers/serdisp.h index db8ff60..31fcdad 100644 --- a/glcddrivers/serdisp.h +++ b/glcddrivers/serdisp.h @@ -7,7 +7,7 @@ * This file is released under the GNU General Public License. Refer * to the COPYING file distributed with this package. * - * (c) 2003-2011 Wolfgang Astleitner <mrwastl AT users.sourceforge.net> + * (c) 2003-2013 Wolfgang Astleitner <mrwastl AT users.sourceforge.net> */ #ifndef _GLCDDRIVERS_SERDISP_H_ @@ -51,12 +51,26 @@ typedef struct SDGP_evpkt_simpletouch_s { /* 16 bytes */ int16_t norm_touch; /* normalised touch value */ } SDGP_evpkt_simpletouch_t; +/* event-payload-type for generic touchscreen events (only importat stuff is defined here, rest is ignored (read only!) */ +typedef struct SDGP_evpkt_generictouch_s { /* 16 bytes */ + uint8_t type; /* event type: 0: up, 1: down, 2: move */ + uint8_t flags; /* 0000 000x ... 0: binary touch, 1: touch with pressure information */ + /* xxxx 0000 ... 0000: union not used */ + /* 0001: raw touch information included in union */ + /* 0010: reserved */ + /* 0011: reserved */ + int16_t norm_x; /* normalised coordinate X (norm_x <= dd->width) */ + int16_t norm_y; /* normalised coordinate Y (norm_y <= dd->height) */ + uint16_t norm_touch; /* normalised touch value */ + /* ignore all union stuff */ +} SDGP_evpkt_generictouch_t; + typedef struct { - bool simpleTouchChanged; - int simpleTouchX; - int simpleTouchY; - int simpleTouchT; + bool touchChanged; + int touchX; + int touchY; + int touchT; } tTouchEvent; diff --git a/glcdskin/object.c b/glcdskin/object.c index a59532d..796e436 100644 --- a/glcdskin/object.c +++ b/glcdskin/object.c @@ -1209,8 +1209,8 @@ std::string cSkinObject::CheckAction(cGLCDEvent * ev) if (mAction == "") return ""; - if (ev && (typeid(*ev) == typeid(cSimpleTouchEvent))) { - cSimpleTouchEvent * stev = (cSimpleTouchEvent*)ev; + if (ev && (typeid(*ev) == typeid(cTouchEvent))) { + cTouchEvent * stev = (cTouchEvent*)ev; // check if touch event is in bounding box of object // uses > and < -1 instead of >= and < -0 for better results if ( (stev->x > Pos().x) && (stev->x < (Pos().x+Size().w -1)) && |