diff options
Diffstat (limited to 'glcddrivers/serdisp.c')
-rw-r--r-- | glcddrivers/serdisp.c | 409 |
1 files changed, 278 insertions, 131 deletions
diff --git a/glcddrivers/serdisp.c b/glcddrivers/serdisp.c index b092659..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-2010 Wolfgang Astleitner <mrwastl AT users.sourceforge.net> + * (c) 2003-2013 Wolfgang Astleitner <mrwastl AT users.sourceforge.net> */ #include <stdio.h> @@ -19,6 +19,11 @@ #include "config.h" #include "serdisp.h" +// for memcpy +#include <string.h> + +#include <map> + #define SERDISP_VERSION(a,b) ((long)(((a) << 8) + (b))) #define SERDISP_VERSION_GET_MAJOR(_c) ((int)( (_c) >> 8 )) #define SERDISP_VERSION_GET_MINOR(_c) ((int)( (_c) & 0xFF )) @@ -29,23 +34,26 @@ #define FEATURE_BACKLIGHT 0x03 #define FEATURE_ROTATE 0x04 -#define SD_COL_BLACK 0xFF000000 -#define SD_COL_WHITE 0xFFFFFFFF +// 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 { -cDriverSerDisp::cDriverSerDisp(cDriverConfig * config) -: config(config) -{ - oldConfig = new cDriverConfig(*config); +static void wrapEventListener(void* dd, SDGP_event_t* recylce); + +static std::map<void* ,tTouchEvent*> touchEvents; - dd = (void *) NULL; -} -cDriverSerDisp::~cDriverSerDisp(void) +cDriverSerDisp::cDriverSerDisp(cDriverConfig * config) +: cDriver(config) { - delete oldConfig; + dd = (void *) NULL; } int cDriverSerDisp::Init(void) @@ -58,10 +66,27 @@ int cDriverSerDisp::Init(void) std::string optionstring = ""; std::string wiringstring; + int chk_major = 0; + std::string libname = ""; // dynamically load serdisplib using dlopen() & co. + sdhnd = NULL; + chk_major = 3; // max major version to check + + while ( ! sdhnd && chk_major > 0) { + libname = "libserdisp.so."; + libname.push_back (chk_major + '0'); + sdhnd = dlopen(libname.c_str(), RTLD_LAZY); + if (!sdhnd) { // try /usr/local/lib + libname.insert(0, "/usr/local/lib/"); + sdhnd = dlopen(libname.c_str(), RTLD_LAZY); + } + chk_major --; + } - sdhnd = dlopen("libserdisp.so", RTLD_LAZY); + if (!sdhnd) { // try libserdisp.so without major version + sdhnd = dlopen("libserdisp.so", RTLD_LAZY); + } if (!sdhnd) { // try /usr/local/lib sdhnd = dlopen("/usr/local/lib/libserdisp.so", RTLD_LAZY); } @@ -76,102 +101,63 @@ int cDriverSerDisp::Init(void) /* pre-init some flags, function pointers, ... */ supports_options = 0; - fg_colour = 1; - bg_colour = -1; + fgcol = GRAPHLCD_Black; /* set foreground colour to black */ + bgcol = GRAPHLCD_ERRCOL; // get serdisp version fp_serdisp_getversioncode = (long int (*)()) dlsym(sdhnd, "serdisp_getversioncode"); if (dlerror()) { // no serdisp_getversioncode() -> version of serdisplib is < 1.95 - syslog(LOG_DEBUG, "%s: INFO: symbol serdisp_getversioncode unknown: autodetecting pre 1.95 serdisplib version (cDriver::Init)\n", - config->name.c_str()); - - fp_SDCONN_open = (void*(*)(const char*)) dlsym(sdhnd, "SDCONN_open"); - if (dlerror()) { // no SDCONN_open() -> version of serdisplib is < 1.93 - serdisp_version = SERDISP_VERSION(1,92); - syslog(LOG_DEBUG, "%s: INFO: detected serdisplib version <= 1.92 (cDriver::Init)\n", config->name.c_str()); - - fp_PP_open = (void*(*)(const char*))dlsym(sdhnd, "PP_open"); - if ( (errmsg = dlerror()) != NULL ) { // should not happen - syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n", - config->name.c_str(), "PP_open", errmsg); - return -1; - } - fp_PP_close = (void*(*)(void*))dlsym(sdhnd, "PP_close"); - if ( (errmsg = dlerror()) != NULL ) { // should not happen - syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n", - config->name.c_str(), "PP_close", errmsg); - return -1; - } - } else { - serdisp_version = SERDISP_VERSION(1,94); // no serdisp_getversioncode, but SDCONN_open: 1.93 or 1.94 - syslog(LOG_DEBUG, "%s: INFO: detected serdisplib version 1.93 or 1.94 (cDriver::Init)\n", config->name.c_str()); + syslog(LOG_ERR, "%s: error: serdisplib version >= 1.95 required\n", config->name.c_str()); + return -1; + } - fp_serdisp_quit = (void (*)(void*)) dlsym(sdhnd, "serdisp_quit"); - if ( (errmsg = dlerror()) != NULL ) { // should not happen - syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n", - config->name.c_str(), "serdisp_quit", errmsg); - return -1; - } - } + serdisp_version = fp_serdisp_getversioncode(); + syslog(LOG_DEBUG, "%s: INFO: detected serdisplib version %d.%d (cDriver::Init)\n", + config->name.c_str(), SERDISP_VERSION_GET_MAJOR(serdisp_version), SERDISP_VERSION_GET_MINOR(serdisp_version)); - fp_serdisp_setpixcol = (void (*)(void*, int, int, long int)) dlsym(sdhnd, "serdisp_setpixel"); - if ( (errmsg = dlerror()) != NULL ) { // should not happen - syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n", - config->name.c_str(), "serdisp_setpixel", errmsg); - return -1; - } - fg_colour = 1; /* set foreground to 'pixel on' */ - } else { // serdisp version >= 1.95 - serdisp_version = fp_serdisp_getversioncode(); - syslog(LOG_DEBUG, "%s: INFO: detected serdisplib version %d.%d (cDriver::Init)\n", - config->name.c_str(), SERDISP_VERSION_GET_MAJOR(serdisp_version), SERDISP_VERSION_GET_MINOR(serdisp_version)); + fp_SDCONN_open = (void*(*)(const char*)) dlsym(sdhnd, "SDCONN_open"); + if ( (errmsg = dlerror()) != NULL ) { // should not happen + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n", + config->name.c_str(), "SDCONN_open", errmsg); + return -1; + } + fp_serdisp_quit = (void (*)(void*)) dlsym(sdhnd, "serdisp_quit"); + if ( (errmsg = dlerror()) != NULL ) { // should not happen + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n", + config->name.c_str(), "serdisp_quit", errmsg); + return -1; + } + fp_serdisp_setcolour = (void (*)(void*, int, int, long int)) dlsym(sdhnd, "serdisp_setcolour"); + if ( (errmsg = dlerror()) != NULL ) { // should not happen + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n", + config->name.c_str(), "serdisp_setcolour", errmsg); + return -1; + } + if (serdisp_version >= SERDISP_VERSION(1,96) ) { + supports_options = 1; - fp_SDCONN_open = (void*(*)(const char*)) dlsym(sdhnd, "SDCONN_open"); + fp_serdisp_isoption = (int (*)(void*, const char*)) dlsym(sdhnd, "serdisp_isoption"); if ( (errmsg = dlerror()) != NULL ) { // should not happen syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n", - config->name.c_str(), "SDCONN_open", errmsg); + config->name.c_str(), "serdisp_isoption", errmsg); return -1; } - fp_serdisp_quit = (void (*)(void*)) dlsym(sdhnd, "serdisp_quit"); + fp_serdisp_setoption = (void (*)(void*, const char*, long int)) dlsym(sdhnd, "serdisp_setoption"); if ( (errmsg = dlerror()) != NULL ) { // should not happen syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n", - config->name.c_str(), "serdisp_quit", errmsg); + config->name.c_str(), "serdisp_setoption", errmsg); return -1; } - fp_serdisp_setpixcol = (void (*)(void*, int, int, long int)) dlsym(sdhnd, "serdisp_setcolour"); + fp_serdisp_getoption = (long int (*)(void*, const char*, int*)) dlsym(sdhnd, "serdisp_getoption"); if ( (errmsg = dlerror()) != NULL ) { // should not happen syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n", - config->name.c_str(), "serdisp_setcolour", errmsg); + config->name.c_str(), "serdisp_getoption", errmsg); return -1; } - fg_colour = SD_COL_BLACK; /* set foreground colour to black */ - - if (serdisp_version >= SERDISP_VERSION(1,96) ) { - supports_options = 1; - - fp_serdisp_isoption = (int (*)(void*, const char*)) dlsym(sdhnd, "serdisp_isoption"); - if ( (errmsg = dlerror()) != NULL ) { // should not happen - syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n", - config->name.c_str(), "serdisp_isoption", errmsg); - return -1; - } - fp_serdisp_setoption = (void (*)(void*, const char*, long int)) dlsym(sdhnd, "serdisp_setoption"); - if ( (errmsg = dlerror()) != NULL ) { // should not happen - syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n", - config->name.c_str(), "serdisp_setoption", errmsg); - return -1; - } - fp_serdisp_getoption = (long int (*)(void*, const char*, int*)) dlsym(sdhnd, "serdisp_getoption"); - if ( (errmsg = dlerror()) != NULL ) { // should not happen - syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n", - config->name.c_str(), "serdisp_getoption", errmsg); - return -1; - } - } /* >= 1.96 */ - } + } /* >= 1.96 */ // load other symbols that will be required fp_serdisp_init = (void*(*)(void*, const char*, const char*)) dlsym(sdhnd, "serdisp_init"); @@ -230,6 +216,24 @@ int cDriverSerDisp::Init(void) return -1; } + fp_serdisp_getcolours = (int (*)(void*)) dlsym(sdhnd, "serdisp_getcolours"); + if ( (errmsg = dlerror()) != NULL ) { // should not happen + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n", + config->name.c_str(), "serdisp_getcolours", errmsg); + return -1; + } + + // don't care if the following functions are not available + fp_serdisp_getdepth = (int (*)(void*)) dlsym(sdhnd, "serdisp_getdepth"); + + fp_SDGPI_search = (uint8_t (*)(void*, const char*)) dlsym(sdhnd, "SDGPI_search"); + fp_SDGPI_isenabled = (int (*)(void*, uint8_t)) dlsym(sdhnd, "SDGPI_isenabled"); + fp_SDGPI_enable = (int (*)(void*, uint8_t, int)) dlsym(sdhnd, "SDGPI_enable"); + fp_SDEVLP_add_listener = (int (*)(void*, uint8_t, fp_eventlistener_t)) dlsym(sdhnd, "SDEVLP_add_listener"); + fp_serdisp_defaultdevice = (const char* (*)(const char*)) dlsym(sdhnd, "serdisp_defaultdevice"); + + + // done loading all required symbols // setting up the display @@ -245,12 +249,12 @@ int cDriverSerDisp::Init(void) } else if (config->options[i].name == "Wiring") { wiringstring = config->options[i].value; } else if (config->options[i].name == "FGColour") { - fg_colour = strtoul(config->options[i].value.c_str(), (char **)NULL, 0); - fg_colour |= 0xFF000000L; /* force alpha to 0xFF */ + fgcol = (uint32_t)strtoul(config->options[i].value.c_str(), (char **)NULL, 0); + fgcol |= 0xFF000000; /* force alpha to 0xFF */ fg_forced = 1; } else if (config->options[i].name == "BGColour") { - bg_colour = strtoul(config->options[i].value.c_str(), (char **)NULL, 0); - bg_colour |= 0xFF000000L; /* force alpha to 0xFF */ + bgcol = (uint32_t)strtoul(config->options[i].value.c_str(), (char **)NULL, 0); + bgcol |= 0xFF000000; /* force alpha to 0xFF */ bg_forced = 1; } } @@ -266,22 +270,13 @@ int cDriverSerDisp::Init(void) } - if (config->device == "") + if (config->device == "" && config->port > 0) /* port will only be used if device is not set */ { // use DirectIO - - // neither device nor port is set - if (config->port == 0) - return -1; - char temp[10]; snprintf(temp, 8, "0x%x", config->port); - if (serdisp_version < SERDISP_VERSION(1,93) ) { - sdcd = fp_PP_open(temp); - } else { - sdcd = fp_SDCONN_open(temp); - } + sdcd = fp_SDCONN_open(temp); if (sdcd == 0) { syslog(LOG_ERR, "%s: error: unable to open port 0x%x for display %s. (cDriver::Init)\n", @@ -293,9 +288,13 @@ int cDriverSerDisp::Init(void) } else { - // use ppdev - if (serdisp_version < SERDISP_VERSION(1,93) ) { - sdcd = fp_PP_open(config->device.c_str()); + if (config->device == "") { + if (fp_serdisp_defaultdevice) { // supported only in serdisplib >= v2.00 + sdcd = fp_SDCONN_open(fp_serdisp_defaultdevice(controller.c_str())); + } else { + // neither device nor port is set and getting default device expression is not supported -> exit + return -1; + } } else { sdcd = fp_SDCONN_open(config->device.c_str()); } @@ -307,10 +306,7 @@ int cDriverSerDisp::Init(void) } } - if (serdisp_version < SERDISP_VERSION(1,95) ) - dd = fp_serdisp_init(sdcd, controller.c_str(), ""); - else - dd = fp_serdisp_init(sdcd, controller.c_str(), optionstring.c_str()); + dd = fp_serdisp_init(sdcd, controller.c_str(), optionstring.c_str()); if (!dd) { @@ -322,9 +318,9 @@ int cDriverSerDisp::Init(void) // self-emitting displays (like OLEDs): default background colour => black if ( supports_options && fp_serdisp_isoption(dd, "SELFEMITTING") && (fp_serdisp_getoption(dd, "SELFEMITTING", 0)) ) { if (!bg_forced) - bg_colour = SD_COL_BLACK; /* set background colour to black */ + bgcol = GRAPHLCD_Black; /* set background colour to black */ if (!fg_forced) - fg_colour = SD_COL_WHITE; /* set foreground colour to white */ + fgcol = GRAPHLCD_White; /* set foreground colour to white */ } width = config->width; @@ -367,22 +363,28 @@ int cDriverSerDisp::Init(void) // clear display Clear(); + touchEvent = new tTouchEvent; + touchEvent->touchChanged = false; + touchEvents[dd] = touchEvent; + syslog(LOG_INFO, "%s: SerDisp with %s initialized.\n", config->name.c_str(), controller.c_str()); return 0; } int cDriverSerDisp::DeInit(void) { - if (serdisp_version < SERDISP_VERSION(1,93) ) { - fp_serdisp_close(dd); - fp_PP_close(sdcd); - sdcd = NULL; - } else { - //fp_serdisp_quit(dd); - /* use serdisp_close instead of serdisp_quit so that showpic and showtext are usable together with serdisplib */ - fp_serdisp_close(dd); - } - (int) dlclose(sdhnd); + if (!dd) + return 0; + + touchEvents.erase(dd); + delete touchEvent; + touchEvent = NULL; + + //fp_serdisp_quit(dd); + /* use serdisp_close instead of serdisp_quit so that showpic and showtext are usable together with serdisplib */ + fp_serdisp_close(dd); + + dlclose(sdhnd); sdhnd = NULL; return 0; @@ -434,6 +436,7 @@ int cDriverSerDisp::CheckSetup() update = true; } +#if 0 /* driver dependend options */ if ( supports_options ) { for (unsigned int i = 0; i < config->options.size(); i++) { @@ -448,7 +451,7 @@ int cDriverSerDisp::CheckSetup() } } } - +#endif if (update) return 1; @@ -457,16 +460,17 @@ int cDriverSerDisp::CheckSetup() void cDriverSerDisp::Clear(void) { - if (bg_colour == -1) + if (bgcol == GRAPHLCD_ERRCOL) // bgcol not set fp_serdisp_clearbuffer(dd); - else { /* if bg_colour is set, draw background 'by hand' */ + else { /* if bgcol is set, draw background 'by hand' */ int x,y; for (y = 0; y < fp_serdisp_getheight(dd); y++) for (x = 0; x < fp_serdisp_getwidth(dd); x++) - fp_serdisp_setpixcol(dd, x, y, bg_colour); /* >= 1.95: serdisp_setcolour(), < 1.95: serdisp_setpixel() */ + fp_serdisp_setcolour(dd, x, y, (long)bgcol); } } +#if 0 void cDriverSerDisp::Set8Pixels(int x, int y, unsigned char data) { int i, start, pixel; @@ -476,12 +480,50 @@ void cDriverSerDisp::Set8Pixels(int x, int y, unsigned char data) { for (i = 0; i < 8; i++) { pixel = data & (1 << i); - if (pixel) - fp_serdisp_setpixcol(dd, start + i, y, fg_colour); /* >= 1.95: serdisp_setcolour(), < 1.95: serdisp_setpixel() */ - else if (!pixel && bg_colour != -1) /* if bg_colour is set: use it if pixel is not set */ - fp_serdisp_setpixcol(dd, start + i, y, bg_colour); /* >= 1.95: serdisp_setcolour(), < 1.95: serdisp_setpixel() */ + if (pixel) { + SetPixel(start + i, y, (long)fgcol); + } else if (!pixel && bgcol != GRAPHLCD_ERRCOL) { /* if bgcol is set: use it if pixel is not set */ + SetPixel(start + i, y, (long)bgcol); + } } } +#endif + +void cDriverSerDisp::SetPixel(int x, int y, uint32_t data) +{ + fp_serdisp_setcolour(dd, x, y, (long)data); +} + +#if 0 +// temporarily overwrite SetScreen() until problem with 'to Clear() or not to Clear()' is solved +void cDriverSerDisp::SetScreen(const unsigned char * data, int wid, int hgt, int lineSize) +{ + int x, y; + + if (wid > width) + wid = width; + if (hgt > height) + hgt = height; + + //Clear(); + if (data) + { + for (y = 0; y < hgt; y++) + { + for (x = 0; x < (wid / 8); x++) + { + Set8Pixels(x * 8, y, data[y * lineSize + x]); + } + if (width % 8) + { + Set8Pixels((wid / 8) * 8, y, data[y * lineSize + wid / 8] & bitmaskl[wid % 8 - 1]); + } + } + } else { + Clear(); + } +} +#endif void cDriverSerDisp::Refresh(bool refreshAll) { @@ -495,9 +537,114 @@ void cDriverSerDisp::Refresh(bool refreshAll) } void cDriverSerDisp::SetBrightness(unsigned int percent) -{ - if ( supports_options && (fp_serdisp_isoption(dd, "BRIGHTNESS") == 1) ) /* if == 1: option is existing AND r/w */ - fp_serdisp_setoption(dd, "BRIGHTNESS", (long)percent); +{ + if ( dd && supports_options && (fp_serdisp_isoption(dd, "BRIGHTNESS") == 1) ) /* if == 1: option is existing AND r/w */ + fp_serdisp_setoption(dd, "BRIGHTNESS", (long)percent); +} + +uint32_t cDriverSerDisp::GetDefaultBackgroundColor(void) { + if ( dd && supports_options && fp_serdisp_isoption(dd, "SELFEMITTING") && (fp_serdisp_getoption(dd, "SELFEMITTING", 0)) ) { + return GRAPHLCD_Black; + } + return GRAPHLCD_White; +} + + +bool cDriverSerDisp::SetFeature (const std::string & Feature, int value) +{ + if (dd && (strcasecmp(Feature.c_str(), "TOUCHSCREEN") == 0 || strcasecmp(Feature.c_str(), "TOUCH") == 0)) { + if (fp_SDGPI_search && fp_SDGPI_isenabled && fp_SDGPI_enable) { + uint8_t gpid = fp_SDGPI_search(dd, Feature.c_str()); + if (gpid == 0xFF) + return false; + + int ena = fp_SDGPI_isenabled(dd, gpid); + bool enable = (value == 1) ? true : false; + if (ena == enable) { // already enabled or disabled + return true; + } else { + bool rc = (fp_SDGPI_enable(dd, gpid, ((enable) ? 1 : 0)) >= 0) ? true : false; + + if (enable && rc && fp_SDEVLP_add_listener) { + fp_SDEVLP_add_listener(dd, gpid, wrapEventListener); + } + return true; + } + } + } + return false; +} + +bool cDriverSerDisp::GetDriverFeature (const std::string & Feature, int & value) { + if (dd) { + if (strcasecmp(Feature.c_str(), "depth") == 0) { + value = fp_serdisp_getdepth(dd); + return true; + } else if (strcasecmp(Feature.c_str(), "ismonochrome") == 0) { + value = (fp_serdisp_getdepth(dd) == 1) ? 1 : 0; + return true; + } else if (strcasecmp(Feature.c_str(), "isgreyscale") == 0 || strcasecmp(Feature.c_str(), "isgrayscale") == 0) { + value = (fp_serdisp_getdepth(dd) > 1 && fp_serdisp_getdepth(dd) < 8) ? 1 : 0; + return true; + } else if (strcasecmp(Feature.c_str(), "iscolour") == 0 || strcasecmp(Feature.c_str(), "iscolor") == 0) { + value = (fp_serdisp_getdepth(dd) >= 8) ? 1 : 0; + return true; + } else if (strcasecmp(Feature.c_str(), "touch") == 0 || strcasecmp(Feature.c_str(), "touchscreen") == 0) { + if (fp_SDGPI_search && fp_SDGPI_isenabled) { + uint8_t gpid = fp_SDGPI_search(dd, Feature.c_str()); + value = (gpid != 0xFF && fp_SDGPI_isenabled(dd, gpid)) ? 1 : 0; + } + return true; + } + } + value = 0; + return false; +} + +cGLCDEvent * cDriverSerDisp::GetEvent(void) { + tTouchEvent* tev = touchEvents[dd]; + if (tev && tev->touchChanged == false) + return NULL; + + cTouchEvent * ev = new cTouchEvent(); + + ev->x = tev->touchX; + ev->y = tev->touchY; + ev->touch = tev->touchT; + tev->touchChanged = false; + + return ev; +} + +static void wrapEventListener(void* dd, SDGP_event_t* event) { + if (!event) return; + if (event->type == SDGPT_SIMPLETOUCH) { + SDGP_evpkt_simpletouch_t simpletouch; + memcpy(&simpletouch, &event->data, sizeof(SDGP_evpkt_simpletouch_t)); + + tTouchEvent* tev = touchEvents[dd]; + if (tev) { + 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; + } + } } } // end of namespace |