Renamed X11 touch files for consistency
authorSam Lantinga
Wed, 01 Dec 2010 12:17:12 -0800
changeset 49231002d074d459
parent 4922 ba79f17d68c1
child 4924 455c0dad84df
Renamed X11 touch files for consistency
src/video/x11/SDL_eventtouch.c
src/video/x11/SDL_eventtouch.h
src/video/x11/SDL_x11touch.c
src/video/x11/SDL_x11touch.h
src/video/x11/SDL_x11video.c
src/video/x11/SDL_x11video.h
     1.1 --- a/src/video/x11/SDL_eventtouch.c	Wed Dec 01 12:02:52 2010 -0800
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,128 +0,0 @@
     1.4 -/*
     1.5 -    SDL - Simple DirectMedia Layer
     1.6 -    Copyright (C) 1997-2010 Sam Lantinga
     1.7 -
     1.8 -    This library is free software; you can redistribute it and/or
     1.9 -    modify it under the terms of the GNU Lesser General Public
    1.10 -    License as published by the Free Software Foundation; either
    1.11 -    version 2.1 of the License, or (at your option) any later version.
    1.12 -
    1.13 -    This library is distributed in the hope that it will be useful,
    1.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 -    Lesser General Public License for more details.
    1.17 -
    1.18 -    You should have received a copy of the GNU Lesser General Public
    1.19 -    License along with this library; if not, write to the Free Software
    1.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    1.21 -
    1.22 -    Sam Lantinga
    1.23 -    slouken@libsdl.org
    1.24 -*/
    1.25 -#include "SDL_config.h"
    1.26 -#include "SDL_x11video.h"
    1.27 -#include "SDL_eventtouch.h"
    1.28 -#include "../../events/SDL_touch_c.h"
    1.29 -
    1.30 -
    1.31 -#ifdef SDL_INPUT_LINUXEV
    1.32 -#include <linux/input.h>
    1.33 -#include <fcntl.h>
    1.34 -#endif
    1.35 -
    1.36 -void
    1.37 -X11_InitTouch(_THIS)
    1.38 -{
    1.39 -#ifdef SDL_INPUT_LINUXEV
    1.40 -  printf("Initializing touch...\n");
    1.41 -
    1.42 -  FILE *fd;
    1.43 -  fd = fopen("/proc/bus/input/devices","r");
    1.44 -  
    1.45 -  char c;
    1.46 -  int i = 0;
    1.47 -  char line[256];
    1.48 -  char tstr[256];
    1.49 -  int vendor = -1,product = -1,event = -1;
    1.50 -  while(!feof(fd)) {
    1.51 -    if(fgets(line,256,fd) <=0) continue;
    1.52 -    //printf("%s",line);
    1.53 -    if(line[0] == '\n') {
    1.54 -      if(vendor == 1386){
    1.55 -	printf("Wacom... Assuming it is a touch device\n");
    1.56 -	sprintf(tstr,"/dev/input/event%i",event);
    1.57 -	printf("At location: %s\n",tstr);
    1.58 -
    1.59 -	SDL_Touch touch;
    1.60 -	touch.pressure_max = 0;
    1.61 -	touch.pressure_min = 0;
    1.62 -	touch.id = event; 
    1.63 -	
    1.64 -
    1.65 -	touch.driverdata = SDL_malloc(sizeof(EventTouchData));
    1.66 -	EventTouchData* data = (EventTouchData*)(touch.driverdata);
    1.67 -
    1.68 -	data->x = -1;
    1.69 -	data->y = -1;
    1.70 -	data->pressure = -1;
    1.71 -	data->finger = 0;
    1.72 -	data->up = SDL_FALSE;
    1.73 -	
    1.74 -
    1.75 -	printf("Opening device...\n");
    1.76 -	//printf("New Touch - DataPtr: %i\n",data);
    1.77 -	data->eventStream = open(tstr, 
    1.78 -				 O_RDONLY | O_NONBLOCK);
    1.79 -	ioctl (data->eventStream, EVIOCGNAME (sizeof (tstr)), tstr);
    1.80 -	printf ("Reading From : %s\n", tstr);
    1.81 -
    1.82 -
    1.83 -
    1.84 -	int abs[5];
    1.85 -	ioctl(data->eventStream,EVIOCGABS(0),abs);	
    1.86 -	touch.x_min = abs[1];
    1.87 -	touch.x_max = abs[2];
    1.88 -	touch.native_xres = touch.x_max - touch.x_min;
    1.89 -	ioctl(data->eventStream,EVIOCGABS(ABS_Y),abs);	
    1.90 -	touch.y_min = abs[1];
    1.91 -	touch.y_max = abs[2];
    1.92 -	touch.native_yres = touch.y_max - touch.y_min;
    1.93 -	ioctl(data->eventStream,EVIOCGABS(ABS_PRESSURE),abs);	
    1.94 -	touch.pressure_min = abs[1];
    1.95 -	touch.pressure_max = abs[2];
    1.96 -	touch.native_pressureres = touch.pressure_max - touch.pressure_min;
    1.97 -
    1.98 -	SDL_AddTouch(&touch, tstr);
    1.99 -      }
   1.100 -      vendor = -1;
   1.101 -      product = -1;
   1.102 -      event = -1;      
   1.103 -    }
   1.104 -    else if(line[0] == 'I') {
   1.105 -      i = 1;
   1.106 -      while(line[i]) {
   1.107 -	sscanf(&line[i],"Vendor=%x",&vendor);
   1.108 -	sscanf(&line[i],"Product=%x",&product);
   1.109 -	i++;
   1.110 -      }
   1.111 -    }
   1.112 -    else if(line[0] == 'H') {
   1.113 -      i = 1;
   1.114 -      while(line[i]) {
   1.115 -	sscanf(&line[i],"event%d",&event);
   1.116 -	i++;
   1.117 -      }
   1.118 -    }
   1.119 -  }
   1.120 -  
   1.121 -  close(fd);
   1.122 -#endif
   1.123 -}
   1.124 -
   1.125 -void
   1.126 -X11_QuitTouch(_THIS)
   1.127 -{
   1.128 -    SDL_TouchQuit();
   1.129 -}
   1.130 -
   1.131 -/* vi: set ts=4 sw=4 expandtab: */
     2.1 --- a/src/video/x11/SDL_eventtouch.h	Wed Dec 01 12:02:52 2010 -0800
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,43 +0,0 @@
     2.4 -/*
     2.5 -    SDL - Simple DirectMedia Layer
     2.6 -    Copyright (C) 1997-2010 Sam Lantinga
     2.7 -
     2.8 -    This library is free software; you can redistribute it and/or
     2.9 -    modify it under the terms of the GNU Lesser General Public
    2.10 -    License as published by the Free Software Foundation; either
    2.11 -    version 2.1 of the License, or (at your option) any later version.
    2.12 -
    2.13 -    This library is distributed in the hope that it will be useful,
    2.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    2.16 -    Lesser General Public License for more details.
    2.17 -
    2.18 -    You should have received a copy of the GNU Lesser General Public
    2.19 -    License along with this library; if not, write to the Free Software
    2.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    2.21 -
    2.22 -    Sam Lantinga
    2.23 -    slouken@libsdl.org
    2.24 -*/
    2.25 -#include "SDL_config.h"
    2.26 -
    2.27 -#ifndef _SDL_eventtouch_h
    2.28 -#define _SDL_eventtouch_h
    2.29 -
    2.30 -
    2.31 -//What should this be?
    2.32 -#if SDL_VIDEO_DRIVER_X11_XINPUT
    2.33 -typedef struct EventTouchData
    2.34 -{
    2.35 -    int x,y,pressure,finger; //Temporary Variables until sync
    2.36 -    int eventStream;
    2.37 -    SDL_bool up;
    2.38 -} EventTouchData;
    2.39 -#endif
    2.40 -
    2.41 -extern void X11_InitTouch(_THIS);
    2.42 -extern void X11_QuitTouch(_THIS);
    2.43 -
    2.44 -#endif /* _SDL_eventtouch_h */
    2.45 -
    2.46 -/* vi: set ts=4 sw=4 expandtab: */
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/video/x11/SDL_x11touch.c	Wed Dec 01 12:17:12 2010 -0800
     3.3 @@ -0,0 +1,128 @@
     3.4 +/*
     3.5 +    SDL - Simple DirectMedia Layer
     3.6 +    Copyright (C) 1997-2010 Sam Lantinga
     3.7 +
     3.8 +    This library is free software; you can redistribute it and/or
     3.9 +    modify it under the terms of the GNU Lesser General Public
    3.10 +    License as published by the Free Software Foundation; either
    3.11 +    version 2.1 of the License, or (at your option) any later version.
    3.12 +
    3.13 +    This library is distributed in the hope that it will be useful,
    3.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    3.16 +    Lesser General Public License for more details.
    3.17 +
    3.18 +    You should have received a copy of the GNU Lesser General Public
    3.19 +    License along with this library; if not, write to the Free Software
    3.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    3.21 +
    3.22 +    Sam Lantinga
    3.23 +    slouken@libsdl.org
    3.24 +*/
    3.25 +#include "SDL_config.h"
    3.26 +#include "SDL_x11video.h"
    3.27 +#include "SDL_x11touch.h"
    3.28 +#include "../../events/SDL_touch_c.h"
    3.29 +
    3.30 +
    3.31 +#ifdef SDL_INPUT_LINUXEV
    3.32 +#include <linux/input.h>
    3.33 +#include <fcntl.h>
    3.34 +#endif
    3.35 +
    3.36 +void
    3.37 +X11_InitTouch(_THIS)
    3.38 +{
    3.39 +#ifdef SDL_INPUT_LINUXEV
    3.40 +  printf("Initializing touch...\n");
    3.41 +
    3.42 +  FILE *fd;
    3.43 +  fd = fopen("/proc/bus/input/devices","r");
    3.44 +  
    3.45 +  char c;
    3.46 +  int i = 0;
    3.47 +  char line[256];
    3.48 +  char tstr[256];
    3.49 +  int vendor = -1,product = -1,event = -1;
    3.50 +  while(!feof(fd)) {
    3.51 +    if(fgets(line,256,fd) <=0) continue;
    3.52 +    //printf("%s",line);
    3.53 +    if(line[0] == '\n') {
    3.54 +      if(vendor == 1386){
    3.55 +	printf("Wacom... Assuming it is a touch device\n");
    3.56 +	sprintf(tstr,"/dev/input/event%i",event);
    3.57 +	printf("At location: %s\n",tstr);
    3.58 +
    3.59 +	SDL_Touch touch;
    3.60 +	touch.pressure_max = 0;
    3.61 +	touch.pressure_min = 0;
    3.62 +	touch.id = event; 
    3.63 +	
    3.64 +
    3.65 +	touch.driverdata = SDL_malloc(sizeof(EventTouchData));
    3.66 +	EventTouchData* data = (EventTouchData*)(touch.driverdata);
    3.67 +
    3.68 +	data->x = -1;
    3.69 +	data->y = -1;
    3.70 +	data->pressure = -1;
    3.71 +	data->finger = 0;
    3.72 +	data->up = SDL_FALSE;
    3.73 +	
    3.74 +
    3.75 +	printf("Opening device...\n");
    3.76 +	//printf("New Touch - DataPtr: %i\n",data);
    3.77 +	data->eventStream = open(tstr, 
    3.78 +				 O_RDONLY | O_NONBLOCK);
    3.79 +	ioctl (data->eventStream, EVIOCGNAME (sizeof (tstr)), tstr);
    3.80 +	printf ("Reading From : %s\n", tstr);
    3.81 +
    3.82 +
    3.83 +
    3.84 +	int abs[5];
    3.85 +	ioctl(data->eventStream,EVIOCGABS(0),abs);	
    3.86 +	touch.x_min = abs[1];
    3.87 +	touch.x_max = abs[2];
    3.88 +	touch.native_xres = touch.x_max - touch.x_min;
    3.89 +	ioctl(data->eventStream,EVIOCGABS(ABS_Y),abs);	
    3.90 +	touch.y_min = abs[1];
    3.91 +	touch.y_max = abs[2];
    3.92 +	touch.native_yres = touch.y_max - touch.y_min;
    3.93 +	ioctl(data->eventStream,EVIOCGABS(ABS_PRESSURE),abs);	
    3.94 +	touch.pressure_min = abs[1];
    3.95 +	touch.pressure_max = abs[2];
    3.96 +	touch.native_pressureres = touch.pressure_max - touch.pressure_min;
    3.97 +
    3.98 +	SDL_AddTouch(&touch, tstr);
    3.99 +      }
   3.100 +      vendor = -1;
   3.101 +      product = -1;
   3.102 +      event = -1;      
   3.103 +    }
   3.104 +    else if(line[0] == 'I') {
   3.105 +      i = 1;
   3.106 +      while(line[i]) {
   3.107 +	sscanf(&line[i],"Vendor=%x",&vendor);
   3.108 +	sscanf(&line[i],"Product=%x",&product);
   3.109 +	i++;
   3.110 +      }
   3.111 +    }
   3.112 +    else if(line[0] == 'H') {
   3.113 +      i = 1;
   3.114 +      while(line[i]) {
   3.115 +	sscanf(&line[i],"event%d",&event);
   3.116 +	i++;
   3.117 +      }
   3.118 +    }
   3.119 +  }
   3.120 +  
   3.121 +  close(fd);
   3.122 +#endif
   3.123 +}
   3.124 +
   3.125 +void
   3.126 +X11_QuitTouch(_THIS)
   3.127 +{
   3.128 +    SDL_TouchQuit();
   3.129 +}
   3.130 +
   3.131 +/* vi: set ts=4 sw=4 expandtab: */
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/video/x11/SDL_x11touch.h	Wed Dec 01 12:17:12 2010 -0800
     4.3 @@ -0,0 +1,43 @@
     4.4 +/*
     4.5 +    SDL - Simple DirectMedia Layer
     4.6 +    Copyright (C) 1997-2010 Sam Lantinga
     4.7 +
     4.8 +    This library is free software; you can redistribute it and/or
     4.9 +    modify it under the terms of the GNU Lesser General Public
    4.10 +    License as published by the Free Software Foundation; either
    4.11 +    version 2.1 of the License, or (at your option) any later version.
    4.12 +
    4.13 +    This library is distributed in the hope that it will be useful,
    4.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.16 +    Lesser General Public License for more details.
    4.17 +
    4.18 +    You should have received a copy of the GNU Lesser General Public
    4.19 +    License along with this library; if not, write to the Free Software
    4.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    4.21 +
    4.22 +    Sam Lantinga
    4.23 +    slouken@libsdl.org
    4.24 +*/
    4.25 +#include "SDL_config.h"
    4.26 +
    4.27 +#ifndef _SDL_eventtouch_h
    4.28 +#define _SDL_eventtouch_h
    4.29 +
    4.30 +
    4.31 +//What should this be?
    4.32 +#if SDL_VIDEO_DRIVER_X11_XINPUT
    4.33 +typedef struct EventTouchData
    4.34 +{
    4.35 +    int x,y,pressure,finger; //Temporary Variables until sync
    4.36 +    int eventStream;
    4.37 +    SDL_bool up;
    4.38 +} EventTouchData;
    4.39 +#endif
    4.40 +
    4.41 +extern void X11_InitTouch(_THIS);
    4.42 +extern void X11_QuitTouch(_THIS);
    4.43 +
    4.44 +#endif /* _SDL_eventtouch_h */
    4.45 +
    4.46 +/* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/src/video/x11/SDL_x11video.c	Wed Dec 01 12:02:52 2010 -0800
     5.2 +++ b/src/video/x11/SDL_x11video.c	Wed Dec 01 12:17:12 2010 -0800
     5.3 @@ -25,13 +25,13 @@
     5.4  
     5.5  #include "SDL_video.h"
     5.6  #include "SDL_mouse.h"
     5.7 -#include "SDL_eventtouch.h" 
     5.8  #include "../SDL_sysvideo.h"
     5.9  #include "../SDL_pixels_c.h"
    5.10  
    5.11  #include "SDL_x11video.h"
    5.12  #include "SDL_x11render.h"
    5.13  #include "SDL_x11shape.h"
    5.14 +#include "SDL_x11touch.h" 
    5.15  
    5.16  #if SDL_VIDEO_DRIVER_PANDORA
    5.17  #include "SDL_x11opengles.h"
     6.1 --- a/src/video/x11/SDL_x11video.h	Wed Dec 01 12:02:52 2010 -0800
     6.2 +++ b/src/video/x11/SDL_x11video.h	Wed Dec 01 12:17:12 2010 -0800
     6.3 @@ -66,7 +66,6 @@
     6.4  #include "SDL_x11keyboard.h"
     6.5  #include "SDL_x11modes.h"
     6.6  #include "SDL_x11mouse.h"
     6.7 -#include "SDL_eventtouch.h"
     6.8  #include "SDL_x11opengl.h"
     6.9  #include "SDL_x11window.h"
    6.10