Added include/touch.h Now reading in resolution of touch pad.
This commit is contained in:
parent
f75117cf0f
commit
4960f0aff9
7 changed files with 226 additions and 82 deletions
118
include/SDL_touch.h
Normal file
118
include/SDL_touch.h
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
/*
|
||||||
|
SDL - Simple DirectMedia Layer
|
||||||
|
Copyright (C) 1997-2010 Sam Lantinga
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Sam Lantinga
|
||||||
|
slouken@libsdl.org
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file SDL_touch.h
|
||||||
|
*
|
||||||
|
* Include file for SDL mouse event handling.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SDL_touch_h
|
||||||
|
#define _SDL_touch_h
|
||||||
|
|
||||||
|
#include "SDL_stdinc.h"
|
||||||
|
#include "SDL_error.h"
|
||||||
|
#include "SDL_video.h"
|
||||||
|
|
||||||
|
#include "begin_code.h"
|
||||||
|
/* Set up for C function definitions, even when using C++ */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
/* *INDENT-OFF* */
|
||||||
|
extern "C" {
|
||||||
|
/* *INDENT-ON* */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct SDL_Touch SDL_Touch;
|
||||||
|
typedef struct SDL_Finger SDL_Finger;
|
||||||
|
|
||||||
|
struct SDL_Finger {
|
||||||
|
int id;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int z; /* for future use */
|
||||||
|
int xdelta;
|
||||||
|
int ydelta;
|
||||||
|
int last_x, last_y,last_pressure; /* the last reported coordinates */
|
||||||
|
int pressure;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct SDL_Touch
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Free the touch when it's time */
|
||||||
|
void (*FreeTouch) (SDL_Touch * touch);
|
||||||
|
|
||||||
|
/* data common for tablets */
|
||||||
|
int pressure_max, pressure_min;
|
||||||
|
int x_max,x_min;
|
||||||
|
int y_max,y_min;
|
||||||
|
int xres,yres,pressureres;
|
||||||
|
int tilt; /* for future use */
|
||||||
|
int rotation; /* for future use */
|
||||||
|
|
||||||
|
/* Data common to all touch */
|
||||||
|
int id;
|
||||||
|
SDL_Window *focus;
|
||||||
|
|
||||||
|
char *name;
|
||||||
|
Uint8 buttonstate;
|
||||||
|
SDL_bool relative_mode;
|
||||||
|
SDL_bool flush_motion;
|
||||||
|
|
||||||
|
int num_fingers;
|
||||||
|
int max_fingers;
|
||||||
|
SDL_Finger** fingers;
|
||||||
|
|
||||||
|
void *driverdata;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Function prototypes */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get the touch object at the given id.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
extern DECLSPEC SDL_Touch* SDLCALL SDL_GetTouch(int id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Get the finger object of the given touch, at the given id.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
extern DECLSPEC SDL_Finger* SDLCALL SDL_GetFinger(SDL_Touch *touch, int id);
|
||||||
|
|
||||||
|
/* Ends C function definitions when using C++ */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
/* *INDENT-OFF* */
|
||||||
|
}
|
||||||
|
/* *INDENT-ON* */
|
||||||
|
#endif
|
||||||
|
#include "close_code.h"
|
||||||
|
|
||||||
|
#endif /* _SDL_mouse_h */
|
||||||
|
|
||||||
|
/* vi: set ts=4 sw=4 expandtab: */
|
|
@ -133,9 +133,9 @@ SDL_AddTouch(const SDL_Touch * touch, char *name)
|
||||||
SDL_strlcpy(SDL_touchPads[index]->name, name, length + 1);
|
SDL_strlcpy(SDL_touchPads[index]->name, name, length + 1);
|
||||||
|
|
||||||
SDL_touchPads[index]->num_fingers = 0;
|
SDL_touchPads[index]->num_fingers = 0;
|
||||||
SDL_touchPads[index]->max_fingers = 0;
|
SDL_touchPads[index]->max_fingers = 1;
|
||||||
SDL_touchPads[index]->fingers = NULL;
|
SDL_touchPads[index]->fingers = (SDL_Finger **) SDL_malloc(sizeof(SDL_Finger*));
|
||||||
|
SDL_touchPads[index]->fingers[0] = NULL;
|
||||||
SDL_touchPads[index]->buttonstate = 0;
|
SDL_touchPads[index]->buttonstate = 0;
|
||||||
SDL_touchPads[index]->relative_mode = SDL_FALSE;
|
SDL_touchPads[index]->relative_mode = SDL_FALSE;
|
||||||
SDL_touchPads[index]->flush_motion = SDL_FALSE;
|
SDL_touchPads[index]->flush_motion = SDL_FALSE;
|
||||||
|
@ -253,39 +253,37 @@ SDL_AddFinger(SDL_Touch* touch,SDL_Finger* finger)
|
||||||
int index;
|
int index;
|
||||||
SDL_Finger **fingers;
|
SDL_Finger **fingers;
|
||||||
size_t length;
|
size_t length;
|
||||||
|
//printf("Adding Finger...\n");
|
||||||
if (SDL_GetFingerIndexId(touch,finger->id) != -1) {
|
if (SDL_GetFingerIndexId(touch,finger->id) != -1) {
|
||||||
SDL_SetError("Finger ID already in use");
|
SDL_SetError("Finger ID already in use");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add the touch to the list of touch */
|
/* Add the touch to the list of touch */
|
||||||
if(touch->num_fingers >= touch->max_fingers){
|
if(touch->num_fingers >= touch->max_fingers){
|
||||||
if(fingers == NULL) {
|
printf("Making room for it!\n");
|
||||||
touch->max_fingers = 1;
|
|
||||||
fingers = (SDL_Finger **) SDL_malloc(sizeof(finger));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fingers = (SDL_Finger **) SDL_realloc(touch->fingers,
|
fingers = (SDL_Finger **) SDL_realloc(touch->fingers,
|
||||||
(touch->num_fingers + 1) * sizeof(finger));
|
(touch->num_fingers + 1) * sizeof(SDL_Finger *));
|
||||||
touch->max_fingers = touch->num_fingers+1;
|
touch->max_fingers = touch->num_fingers+1;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fingers) {
|
if (!fingers) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
touch->max_fingers = touch->num_fingers+1;
|
||||||
touch->fingers = fingers;
|
touch->fingers = fingers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
index = touch->num_fingers;
|
index = touch->num_fingers;
|
||||||
touch->num_fingers++;
|
//printf("Max_Fingers: %i Index: %i\n",touch->max_fingers,index);
|
||||||
touch->fingers[index] = (SDL_Finger *) SDL_malloc(sizeof(*(touch->fingers[index])));
|
|
||||||
|
touch->fingers[index] = (SDL_Finger *) SDL_malloc(sizeof(SDL_Finger));
|
||||||
if (!touch->fingers[index]) {
|
if (!touch->fingers[index]) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*touch->fingers[index] = *finger;
|
*(touch->fingers[index]) = *finger;
|
||||||
|
touch->num_fingers++;
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
@ -323,6 +321,7 @@ SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressu
|
||||||
nf.ydelta = 0;
|
nf.ydelta = 0;
|
||||||
nf.last_x = x;
|
nf.last_x = x;
|
||||||
nf.last_y = y;
|
nf.last_y = y;
|
||||||
|
nf.last_pressure = pressure;
|
||||||
SDL_AddFinger(touch,&nf);
|
SDL_AddFinger(touch,&nf);
|
||||||
|
|
||||||
posted = 0;
|
posted = 0;
|
||||||
|
@ -383,6 +382,7 @@ SDL_SendTouchMotion(int id, int fingerid, int relative,
|
||||||
} else {
|
} else {
|
||||||
if(x < 0) x = finger->last_x; /*If movement is only in one axis,*/
|
if(x < 0) x = finger->last_x; /*If movement is only in one axis,*/
|
||||||
if(y < 0) y = finger->last_y; /*The other is marked as -1*/
|
if(y < 0) y = finger->last_y; /*The other is marked as -1*/
|
||||||
|
if(pressure < 0) pressure = finger->last_pressure;
|
||||||
xrel = x - finger->last_x;
|
xrel = x - finger->last_x;
|
||||||
yrel = y - finger->last_y;
|
yrel = y - finger->last_y;
|
||||||
}
|
}
|
||||||
|
@ -418,8 +418,8 @@ SDL_SendTouchMotion(int id, int fingerid, int relative,
|
||||||
touch->y = 0;
|
touch->y = 0;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
finger->xdelta += xrel;
|
finger->xdelta = xrel;
|
||||||
finger->ydelta += yrel;
|
finger->ydelta = yrel;
|
||||||
finger->pressure = pressure;
|
finger->pressure = pressure;
|
||||||
|
|
||||||
|
|
||||||
|
@ -440,6 +440,7 @@ SDL_SendTouchMotion(int id, int fingerid, int relative,
|
||||||
}
|
}
|
||||||
finger->last_x = finger->x;
|
finger->last_x = finger->x;
|
||||||
finger->last_y = finger->y;
|
finger->last_y = finger->y;
|
||||||
|
finger->last_pressure = finger->pressure;
|
||||||
return posted;
|
return posted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,52 +20,11 @@
|
||||||
slouken@libsdl.org
|
slouken@libsdl.org
|
||||||
*/
|
*/
|
||||||
#include "SDL_config.h"
|
#include "SDL_config.h"
|
||||||
|
#include "../../include/SDL_touch.h"
|
||||||
|
|
||||||
#ifndef _SDL_touch_c_h
|
#ifndef _SDL_touch_c_h
|
||||||
#define _SDL_touch_c_h
|
#define _SDL_touch_c_h
|
||||||
|
|
||||||
typedef struct SDL_Touch SDL_Touch;
|
|
||||||
typedef struct SDL_Finger SDL_Finger;
|
|
||||||
|
|
||||||
struct SDL_Finger {
|
|
||||||
int id;
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
int z; /* for future use */
|
|
||||||
int xdelta;
|
|
||||||
int ydelta;
|
|
||||||
int last_x, last_y; /* the last reported x and y coordinates */
|
|
||||||
int pressure;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct SDL_Touch
|
|
||||||
{
|
|
||||||
|
|
||||||
/* Free the touch when it's time */
|
|
||||||
void (*FreeTouch) (SDL_Touch * touch);
|
|
||||||
|
|
||||||
/* data common for tablets */
|
|
||||||
int pressure_max;
|
|
||||||
int pressure_min;
|
|
||||||
int tilt; /* for future use */
|
|
||||||
int rotation; /* for future use */
|
|
||||||
|
|
||||||
/* Data common to all touch */
|
|
||||||
int id;
|
|
||||||
SDL_Window *focus;
|
|
||||||
|
|
||||||
char *name;
|
|
||||||
Uint8 buttonstate;
|
|
||||||
SDL_bool relative_mode;
|
|
||||||
SDL_bool flush_motion;
|
|
||||||
|
|
||||||
int num_fingers;
|
|
||||||
int max_fingers;
|
|
||||||
SDL_Finger** fingers;
|
|
||||||
|
|
||||||
void *driverdata;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* Initialize the touch subsystem */
|
/* Initialize the touch subsystem */
|
||||||
|
|
|
@ -56,6 +56,8 @@ X11_InitTouch(_THIS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
touch.driverdata = SDL_malloc(sizeof(EventTouchData));
|
touch.driverdata = SDL_malloc(sizeof(EventTouchData));
|
||||||
EventTouchData* data = (EventTouchData*)(touch.driverdata);
|
EventTouchData* data = (EventTouchData*)(touch.driverdata);
|
||||||
printf("Opening device...\n");
|
printf("Opening device...\n");
|
||||||
|
@ -64,6 +66,24 @@ X11_InitTouch(_THIS)
|
||||||
O_RDONLY | O_NONBLOCK);
|
O_RDONLY | O_NONBLOCK);
|
||||||
ioctl (data->eventStream, EVIOCGNAME (sizeof (tstr)), tstr);
|
ioctl (data->eventStream, EVIOCGNAME (sizeof (tstr)), tstr);
|
||||||
printf ("Reading From : %s\n", tstr);
|
printf ("Reading From : %s\n", tstr);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int abs[5];
|
||||||
|
ioctl(data->eventStream,EVIOCGABS(0),abs);
|
||||||
|
touch.x_min = abs[1];
|
||||||
|
touch.x_max = abs[2];
|
||||||
|
touch.xres = touch.x_max - touch.x_min;
|
||||||
|
ioctl(data->eventStream,EVIOCGABS(ABS_Y),abs);
|
||||||
|
touch.y_min = abs[1];
|
||||||
|
touch.y_max = abs[2];
|
||||||
|
touch.yres = touch.y_max - touch.y_min;
|
||||||
|
ioctl(data->eventStream,EVIOCGABS(ABS_PRESSURE),abs);
|
||||||
|
touch.pressure_min = abs[1];
|
||||||
|
touch.pressure_max = abs[2];
|
||||||
|
touch.pressureres = touch.pressure_max - touch.pressure_min;
|
||||||
|
|
||||||
|
|
||||||
SDL_AddTouch(&touch, tstr);
|
SDL_AddTouch(&touch, tstr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -449,6 +449,7 @@ X11_PumpEvents(_THIS)
|
||||||
break;
|
break;
|
||||||
case ABS_PRESSURE:
|
case ABS_PRESSURE:
|
||||||
data->pressure = ev[i].value;
|
data->pressure = ev[i].value;
|
||||||
|
if(data->pressure < 0) data->pressure = 0;
|
||||||
break;
|
break;
|
||||||
case ABS_MISC:
|
case ABS_MISC:
|
||||||
data->up = SDL_TRUE;
|
data->up = SDL_TRUE;
|
||||||
|
@ -461,7 +462,7 @@ X11_PumpEvents(_THIS)
|
||||||
data->finger = ev[i].value;
|
data->finger = ev[i].value;
|
||||||
break;
|
break;
|
||||||
case EV_SYN:
|
case EV_SYN:
|
||||||
printf("Id: %i\n",touch->id);
|
//printf("Id: %i\n",touch->id);
|
||||||
if(data->x >= 0 || data->y >= 0)
|
if(data->x >= 0 || data->y >= 0)
|
||||||
SDL_SendTouchMotion(touch->id,data->finger,
|
SDL_SendTouchMotion(touch->id,data->finger,
|
||||||
SDL_FALSE,data->x,data->y,
|
SDL_FALSE,data->x,data->y,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
|
||||||
int main(int agrc,char **argv)
|
int main(int agrc,char **argv)
|
||||||
|
@ -22,7 +23,23 @@ int main(int agrc,char **argv)
|
||||||
sprintf(tstr,"/dev/input/event%i",event);
|
sprintf(tstr,"/dev/input/event%i",event);
|
||||||
printf("At location: %s\n",tstr);
|
printf("At location: %s\n",tstr);
|
||||||
|
|
||||||
|
int inFile = open(tstr,O_RDONLY);
|
||||||
|
|
||||||
|
unsigned long bits[4];
|
||||||
|
int abs[5];
|
||||||
|
ioctl(inFile,EVIOCGABS(ABS_X),abs);
|
||||||
|
int minx,maxx,miny,maxy,minp,maxp;
|
||||||
|
minx = abs[1];
|
||||||
|
maxx = abs[2];
|
||||||
|
ioctl(inFile,EVIOCGABS(ABS_Y),abs);
|
||||||
|
miny = abs[1];
|
||||||
|
maxy = abs[2];
|
||||||
|
ioctl(inFile,EVIOCGABS(ABS_PRESSURE),abs);
|
||||||
|
minp = abs[1];
|
||||||
|
maxp = abs[2];
|
||||||
|
|
||||||
|
|
||||||
|
close(inFile);
|
||||||
}
|
}
|
||||||
vendor = -1;
|
vendor = -1;
|
||||||
product = -1;
|
product = -1;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "../src/events/SDL_touch_c.h" //BAD!!!
|
#include <SDL_touch.h>
|
||||||
|
|
||||||
#define PI 3.1415926535897
|
#define PI 3.1415926535897
|
||||||
#define WIDTH 640
|
#define WIDTH 640
|
||||||
|
@ -19,12 +19,12 @@ int bstatus;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int x,y;
|
float x,y;
|
||||||
} Point;
|
} Point;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Point p;
|
Point p;
|
||||||
int pressure;
|
float pressure;
|
||||||
} Finger;
|
} Finger;
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ Finger finger[MAXFINGERS];
|
||||||
|
|
||||||
void handler (int sig)
|
void handler (int sig)
|
||||||
{
|
{
|
||||||
printf ("\nexiting...(%d)\n", sig);
|
printf ("\exiting...(%d)\n", sig);
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,8 +61,17 @@ void drawCircle(SDL_Surface* screen,int x,int y,int r,int c)
|
||||||
{
|
{
|
||||||
|
|
||||||
float a;
|
float a;
|
||||||
for(a=0;a<PI/2;a+=1.f/(float)r)
|
int tx;
|
||||||
|
for(a=0;a<PI/2;a+=1.f/(float)abs(r))
|
||||||
{
|
{
|
||||||
|
if(r > 0) { //r<0 ==> unfilled circle
|
||||||
|
for(tx=x-r*cos(a);tx<x+r*cos(a);tx++) {
|
||||||
|
setpix(screen,tx,(int)(y+r*sin(a)),c);
|
||||||
|
setpix(screen,tx,(int)(y-r*sin(a)),c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Always Draw Outline
|
||||||
setpix(screen,(int)(x+r*cos(a)),(int)(y+r*sin(a)),c);
|
setpix(screen,(int)(x+r*cos(a)),(int)(y+r*sin(a)),c);
|
||||||
setpix(screen,(int)(x-r*cos(a)),(int)(y+r*sin(a)),c);
|
setpix(screen,(int)(x-r*cos(a)),(int)(y+r*sin(a)),c);
|
||||||
setpix(screen,(int)(x+r*cos(a)),(int)(y-r*sin(a)),c);
|
setpix(screen,(int)(x+r*cos(a)),(int)(y-r*sin(a)),c);
|
||||||
|
@ -89,12 +98,17 @@ void DrawScreen(SDL_Surface* screen, int h)
|
||||||
setpix(screen,x,y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255);
|
setpix(screen,x,y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drawCircle(screen,mousx,mousy,30,0xFFFFFF);
|
drawCircle(screen,mousx,mousy,-30,0xFFFFFF);
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for(i=0;i<MAXFINGERS;i++)
|
for(i=0;i<MAXFINGERS;i++)
|
||||||
if(finger[i].p.x >= 0 && finger[i].p.y >= 0)
|
if(finger[i].p.x >= 0 && finger[i].p.y >= 0)
|
||||||
drawCircle(screen,finger[i].p.x,finger[i].p.y,20,0xFF6600-finger[i].pressure);
|
if(finger[i].pressure > 0)
|
||||||
|
drawCircle(screen,finger[i].p.x*screen->w,finger[i].p.y*screen->h
|
||||||
|
,20,0xFF*finger[i].pressure);
|
||||||
|
else
|
||||||
|
drawCircle(screen,finger[i].p.x*screen->w,finger[i].p.y*screen->h
|
||||||
|
,20,0xFF);
|
||||||
|
|
||||||
if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen);
|
if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen);
|
||||||
|
|
||||||
|
@ -162,14 +176,28 @@ int main(int argc, char* argv[])
|
||||||
bstatus &= ~(1<<(event.button.button-1));
|
bstatus &= ~(1<<(event.button.button-1));
|
||||||
break;
|
break;
|
||||||
case SDL_FINGERMOTION:
|
case SDL_FINGERMOTION:
|
||||||
|
;
|
||||||
//printf("Finger: %i,x: %i, y: %i\n",event.tfinger.fingerId,
|
//printf("Finger: %i,x: %i, y: %i\n",event.tfinger.fingerId,
|
||||||
// event.tfinger.x,event.tfinger.y);
|
// event.tfinger.x,event.tfinger.y);
|
||||||
finger[event.tfinger.fingerId].p.x = event.tfinger.x;
|
SDL_Touch* inTouch = SDL_GetTouch(event.tfinger.touchId);
|
||||||
finger[event.tfinger.fingerId].p.y = event.tfinger.y;
|
SDL_Finger* inFinger = SDL_GetFinger(inTouch,event.tfinger.fingerId);
|
||||||
finger[event.tfinger.fingerId].pressure = event.tfinger.pressure;
|
|
||||||
printf("Finger: %i, pressure: %i\n",event.tfinger.fingerId,
|
finger[event.tfinger.fingerId].p.x = ((float)event.tfinger.x)/
|
||||||
event.tfinger.pressure);
|
inTouch->xres;
|
||||||
|
finger[event.tfinger.fingerId].p.y = ((float)event.tfinger.y)/
|
||||||
|
inTouch->yres;
|
||||||
|
|
||||||
|
finger[event.tfinger.fingerId].pressure =
|
||||||
|
((float)event.tfinger.pressure)/inTouch->pressureres;
|
||||||
|
|
||||||
|
printf("Finger: %i, Pressure: %f Pressureres: %i\n",
|
||||||
|
event.tfinger.fingerId,
|
||||||
|
finger[event.tfinger.fingerId].pressure,
|
||||||
|
inTouch->pressureres);
|
||||||
|
//printf("Finger: %i, pressure: %f\n",event.tfinger.fingerId,
|
||||||
|
// finger[event.tfinger.fingerId].pressure);
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case SDL_FINGERDOWN:
|
case SDL_FINGERDOWN:
|
||||||
printf("Figner: %i down - x: %i, y: %i\n",event.tfinger.fingerId,
|
printf("Figner: %i down - x: %i, y: %i\n",event.tfinger.fingerId,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue