Mercurial > sdl-ios-xcode
changeset 1201:718d00094f82
Date: Sat, 10 Dec 2005 18:29:41 +0100
From: Alberto Mardegan <mardy@users.sourceforge.net>
To: sdl@libsdl.org
Subject: [SDL] [PATCH] Touchscreen support to fbcon via tslib
Hi all!
I'm new to this list, I just subscribed. I've attached to this e-mail
a patch I've written in order to add Touchscreen support to SDL's fbcon
module via the tslib library.
Since it introduces a new dependency, I've also edited the the
configure.in file and added it as a compile-time option.
This patch is especially useful for handhelds (I've tested it in my
Zaurus).
Please consider applying it. :-)
--
Saluti,
Mardy
http://interlingua.altervista.org
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Mon, 12 Dec 2005 09:26:32 +0000 |
parents | 8f418dce02b2 |
children | 0748fbb272e7 |
files | configure.in src/video/fbcon/SDL_fbevents.c src/video/fbcon/SDL_fbvideo.h |
diffstat | 3 files changed, 81 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.in Mon Dec 12 09:22:36 2005 +0000 +++ b/configure.in Mon Dec 12 09:26:32 2005 +0000 @@ -1233,6 +1233,29 @@ fi } +dnl See if we can use the Touchscreen input library +CheckTslib() +{ + AC_ARG_ENABLE(input-tslib, +[ --enable-input-tslib use the Touchscreen library for input [default=yes]], + , enable_input_tslib=yes) + if test x$enable_input_tslib = xyes; then + AC_MSG_CHECKING(for Touchscreen library support) + enable_input_tslib=no + AC_TRY_COMPILE([ + #include "tslib.h" + ],[ + ],[ + enable_input_tslib=yes + ]) + AC_MSG_RESULT($enable_input_tslib) + if test x$enable_input_tslib = xyes; then + CFLAGS="$CFLAGS -DHAVE_TSLIB" + SYSTEM_LIBS="$SYSTEM_LIBS -lts" + fi + fi +} + dnl See if we can use GNU pth library for threads CheckPTH() { @@ -2078,6 +2101,7 @@ CheckPicoGUI CheckOpenGLX11 CheckInputEvents + CheckTslib CheckPTHREAD CheckSIGACTION CheckAltivec
--- a/src/video/fbcon/SDL_fbevents.c Mon Dec 12 09:22:36 2005 +0000 +++ b/src/video/fbcon/SDL_fbevents.c Mon Dec 12 09:26:32 2005 +0000 @@ -317,11 +317,19 @@ MOUSE_MS, MOUSE_BM, MOUSE_ELO, + MOUSE_TSLIB, NUM_MOUSE_DRVS } mouse_drv = MOUSE_NONE; void FB_CloseMouse(_THIS) { +#ifdef HAVE_TSLIB + if (ts_dev != NULL) { + ts_close(ts_dev); + ts_dev = NULL; + mouse_fd = -1; + } +#endif /* HAVE_TSLIB */ if ( mouse_fd > 0 ) { close(mouse_fd); } @@ -500,6 +508,25 @@ mousedev = getenv("SDL_MOUSEDEV"); mouse_fd = -1; +#ifdef HAVE_TSLIB + if ((mousedrv != NULL) && (strcmp(mousedrv, "TSLIB") == 0)) { + if (mousedev == NULL) mousedev = getenv("TSLIB_TSDEVICE"); + if (mousedev != NULL) { + ts_dev = ts_open(mousedev, 1); + if ((ts_dev != NULL) && (ts_config(ts_dev) >= 0)) { +#ifdef DEBUG_MOUSE + fprintf(stderr, "Using tslib touchscreen\n"); +#endif + mouse_drv = MOUSE_TSLIB; + mouse_fd = ts_fd(ts_dev); + return mouse_fd; + } + } + mouse_drv = MOUSE_NONE; + return mouse_fd; + } +#endif /* HAVE_TSLIB */ + /* ELO TOUCHSCREEN SUPPORT */ if( (mousedrv != NULL) && (strcmp(mousedrv, "ELO") == 0) ) { @@ -642,6 +669,22 @@ } } +/* Handle input from tslib */ +#ifdef HAVE_TSLIB +static void handle_tslib(_THIS) +{ + struct ts_sample sample; + int button; + + while (ts_read(ts_dev, &sample, 1) > 0) { + button = (sample.pressure > 0) ? 1 : 0; + button <<= 2; /* must report it as button 3 */ + FB_vgamousecallback(button, 0, sample.x, sample.y); + } + return; +} +#endif /* HAVE_TSLIB */ + /* For now, use MSC, PS/2, and MS protocols Driver adapted from the SVGAlib mouse driver code (taken from gpm, etc.) */ @@ -678,6 +721,11 @@ packetsize = ELO_PACKET_SIZE; relative = 0; break; + case MOUSE_TSLIB: +#ifdef HAVE_TSLIB + handle_tslib(this); +#endif + return; /* nothing left to do */ case NUM_MOUSE_DRVS: /* Uh oh.. */ packetsize = 0;
--- a/src/video/fbcon/SDL_fbvideo.h Mon Dec 12 09:22:36 2005 +0000 +++ b/src/video/fbcon/SDL_fbvideo.h Mon Dec 12 09:26:32 2005 +0000 @@ -35,6 +35,9 @@ #include "SDL_mouse.h" #include "SDL_mutex.h" #include "SDL_sysvideo.h" +#ifdef HAVE_TSLIB +#include "tslib.h" +#endif /* Hidden "this" pointer for the video functions */ #define _THIS SDL_VideoDevice *this @@ -65,6 +68,9 @@ struct termios saved_kbd_termios; int mouse_fd; +#ifdef HAVE_TSLIB + struct tsdev *ts_dev; +#endif char *mapped_mem; int mapped_memlen; @@ -95,6 +101,9 @@ #define saved_kbd_mode (this->hidden->saved_kbd_mode) #define saved_kbd_termios (this->hidden->saved_kbd_termios) #define mouse_fd (this->hidden->mouse_fd) +#ifdef HAVE_TSLIB +#define ts_dev (this->hidden->ts_dev) +#endif /* HAVE_TSLIB */ #define cache_vinfo (this->hidden->cache_vinfo) #define saved_vinfo (this->hidden->saved_vinfo) #define saved_cmaplen (this->hidden->saved_cmaplen)