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 --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401204
This commit is contained in:
parent
529abd8105
commit
53f29a2cb5
3 changed files with 81 additions and 0 deletions
24
configure.in
24
configure.in
|
@ -1233,6 +1233,29 @@ CheckInputEvents()
|
||||||
fi
|
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
|
dnl See if we can use GNU pth library for threads
|
||||||
CheckPTH()
|
CheckPTH()
|
||||||
{
|
{
|
||||||
|
@ -2078,6 +2101,7 @@ case "$target" in
|
||||||
CheckPicoGUI
|
CheckPicoGUI
|
||||||
CheckOpenGLX11
|
CheckOpenGLX11
|
||||||
CheckInputEvents
|
CheckInputEvents
|
||||||
|
CheckTslib
|
||||||
CheckPTHREAD
|
CheckPTHREAD
|
||||||
CheckSIGACTION
|
CheckSIGACTION
|
||||||
CheckAltivec
|
CheckAltivec
|
||||||
|
|
|
@ -317,11 +317,19 @@ static enum {
|
||||||
MOUSE_MS,
|
MOUSE_MS,
|
||||||
MOUSE_BM,
|
MOUSE_BM,
|
||||||
MOUSE_ELO,
|
MOUSE_ELO,
|
||||||
|
MOUSE_TSLIB,
|
||||||
NUM_MOUSE_DRVS
|
NUM_MOUSE_DRVS
|
||||||
} mouse_drv = MOUSE_NONE;
|
} mouse_drv = MOUSE_NONE;
|
||||||
|
|
||||||
void FB_CloseMouse(_THIS)
|
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 ) {
|
if ( mouse_fd > 0 ) {
|
||||||
close(mouse_fd);
|
close(mouse_fd);
|
||||||
}
|
}
|
||||||
|
@ -500,6 +508,25 @@ int FB_OpenMouse(_THIS)
|
||||||
mousedev = getenv("SDL_MOUSEDEV");
|
mousedev = getenv("SDL_MOUSEDEV");
|
||||||
mouse_fd = -1;
|
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 */
|
/* ELO TOUCHSCREEN SUPPORT */
|
||||||
|
|
||||||
if( (mousedrv != NULL) && (strcmp(mousedrv, "ELO") == 0) ) {
|
if( (mousedrv != NULL) && (strcmp(mousedrv, "ELO") == 0) ) {
|
||||||
|
@ -642,6 +669,22 @@ void FB_vgamousecallback(int button, int relative, int dx, int dy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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
|
/* For now, use MSC, PS/2, and MS protocols
|
||||||
Driver adapted from the SVGAlib mouse driver code (taken from gpm, etc.)
|
Driver adapted from the SVGAlib mouse driver code (taken from gpm, etc.)
|
||||||
*/
|
*/
|
||||||
|
@ -678,6 +721,11 @@ static void handle_mouse(_THIS)
|
||||||
packetsize = ELO_PACKET_SIZE;
|
packetsize = ELO_PACKET_SIZE;
|
||||||
relative = 0;
|
relative = 0;
|
||||||
break;
|
break;
|
||||||
|
case MOUSE_TSLIB:
|
||||||
|
#ifdef HAVE_TSLIB
|
||||||
|
handle_tslib(this);
|
||||||
|
#endif
|
||||||
|
return; /* nothing left to do */
|
||||||
case NUM_MOUSE_DRVS:
|
case NUM_MOUSE_DRVS:
|
||||||
/* Uh oh.. */
|
/* Uh oh.. */
|
||||||
packetsize = 0;
|
packetsize = 0;
|
||||||
|
|
|
@ -35,6 +35,9 @@ static char rcsid =
|
||||||
#include "SDL_mouse.h"
|
#include "SDL_mouse.h"
|
||||||
#include "SDL_mutex.h"
|
#include "SDL_mutex.h"
|
||||||
#include "SDL_sysvideo.h"
|
#include "SDL_sysvideo.h"
|
||||||
|
#ifdef HAVE_TSLIB
|
||||||
|
#include "tslib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Hidden "this" pointer for the video functions */
|
/* Hidden "this" pointer for the video functions */
|
||||||
#define _THIS SDL_VideoDevice *this
|
#define _THIS SDL_VideoDevice *this
|
||||||
|
@ -65,6 +68,9 @@ struct SDL_PrivateVideoData {
|
||||||
struct termios saved_kbd_termios;
|
struct termios saved_kbd_termios;
|
||||||
|
|
||||||
int mouse_fd;
|
int mouse_fd;
|
||||||
|
#ifdef HAVE_TSLIB
|
||||||
|
struct tsdev *ts_dev;
|
||||||
|
#endif
|
||||||
|
|
||||||
char *mapped_mem;
|
char *mapped_mem;
|
||||||
int mapped_memlen;
|
int mapped_memlen;
|
||||||
|
@ -95,6 +101,9 @@ struct SDL_PrivateVideoData {
|
||||||
#define saved_kbd_mode (this->hidden->saved_kbd_mode)
|
#define saved_kbd_mode (this->hidden->saved_kbd_mode)
|
||||||
#define saved_kbd_termios (this->hidden->saved_kbd_termios)
|
#define saved_kbd_termios (this->hidden->saved_kbd_termios)
|
||||||
#define mouse_fd (this->hidden->mouse_fd)
|
#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 cache_vinfo (this->hidden->cache_vinfo)
|
||||||
#define saved_vinfo (this->hidden->saved_vinfo)
|
#define saved_vinfo (this->hidden->saved_vinfo)
|
||||||
#define saved_cmaplen (this->hidden->saved_cmaplen)
|
#define saved_cmaplen (this->hidden->saved_cmaplen)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue