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
-------------- next part --------------
Index: SDL-1.2.7/configure.in
— SDL-1.2.7.orig/configure.in 2004-02-22 22:31:47.000000000 +0100
+++ SDL-1.2.7/configure.in 2005-12-10 14:53:01.000000000 +0100
@@ -1117,6 +1117,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()
{
@@ -1800,6 +1823,7 @@
CheckPicoGUI
CheckOpenGL
CheckInputEvents
-
CheckTslib CheckPTHREAD CheckSIGACTION CheckAltivec
Index: SDL-1.2.7/src/video/fbcon/SDL_fbevents.c
— SDL-1.2.7.orig/src/video/fbcon/SDL_fbevents.c 2004-02-18 18:22:06.000000000 +0100
+++ SDL-1.2.7/src/video/fbcon/SDL_fbevents.c 2005-12-10 18:01:28.000000000 +0100
@@ -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;
Index: SDL-1.2.7/src/video/fbcon/SDL_fbvideo.h
— SDL-1.2.7.orig/src/video/fbcon/SDL_fbvideo.h 2004-02-18 18:22:06.000000000 +0100
+++ SDL-1.2.7/src/video/fbcon/SDL_fbvideo.h 2005-12-10 15:41:00.000000000 +0100
@@ -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;
+#endifchar 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)