Commit 72c5a40b authored by Jim Grandpre's avatar Jim Grandpre

Added reading of event* for touch events.

parent f806d397
...@@ -310,6 +310,8 @@ typedef struct SDL_TouchFingerEvent ...@@ -310,6 +310,8 @@ typedef struct SDL_TouchFingerEvent
Uint8 state; /**< The current button state */ Uint8 state; /**< The current button state */
Uint8 fingerId; Uint8 fingerId;
Uint8 padding1; Uint8 padding1;
int x;
int y;
} SDL_TouchFingerEvent; } SDL_TouchFingerEvent;
......
...@@ -254,6 +254,7 @@ SDL_StartEventLoop(Uint32 flags) ...@@ -254,6 +254,7 @@ SDL_StartEventLoop(Uint32 flags)
retcode = 0; retcode = 0;
retcode += SDL_KeyboardInit(); retcode += SDL_KeyboardInit();
retcode += SDL_MouseInit(); retcode += SDL_MouseInit();
retcode += SDL_TouchInit();
retcode += SDL_QuitInit(); retcode += SDL_QuitInit();
if (retcode < 0) { if (retcode < 0) {
/* We don't expect them to fail, but... */ /* We don't expect them to fail, but... */
......
...@@ -36,8 +36,15 @@ static SDL_Touch **SDL_touchPads = NULL; ...@@ -36,8 +36,15 @@ static SDL_Touch **SDL_touchPads = NULL;
int int
SDL_TouchInit(void) SDL_TouchInit(void)
{ {
SDL_Touch touch;
touch.pressure_max = 0;
touch.pressure_min = 0;
touch.id = 0; //Should be function?
SDL_AddTouch(&touch, "Touch1");
return (0); return (0);
} }
SDL_Touch * SDL_Touch *
SDL_GetTouch(int id) SDL_GetTouch(int id)
{ {
...@@ -48,13 +55,13 @@ SDL_GetTouch(int id) ...@@ -48,13 +55,13 @@ SDL_GetTouch(int id)
return SDL_touchPads[index]; return SDL_touchPads[index];
} }
SDL_Finger * SDL_Touch *
SDL_GetFinger(SDL_Touch* touch,int id) SDL_GetTouchIndex(int index)
{ {
int index = SDL_GetFingerIndexId(touch,id); if (index < 0 || index >= SDL_num_touch) {
if(index < 0 || index >= touch->num_fingers) return NULL;
return NULL; }
return touch->fingers[index]; return SDL_touchPads[index];
} }
int int
...@@ -67,6 +74,17 @@ SDL_GetFingerIndexId(SDL_Touch* touch,int fingerid) ...@@ -67,6 +74,17 @@ SDL_GetFingerIndexId(SDL_Touch* touch,int fingerid)
return -1; return -1;
} }
SDL_Finger *
SDL_GetFinger(SDL_Touch* touch,int id)
{
int index = SDL_GetFingerIndexId(touch,id);
if(index < 0 || index >= touch->num_fingers)
return NULL;
return touch->fingers[index];
}
int int
SDL_GetTouchIndexId(int id) SDL_GetTouchIndexId(int id)
{ {
...@@ -83,8 +101,7 @@ SDL_GetTouchIndexId(int id) ...@@ -83,8 +101,7 @@ SDL_GetTouchIndexId(int id)
} }
int int
SDL_AddTouch(const SDL_Touch * touch, char *name, int pressure_max, SDL_AddTouch(const SDL_Touch * touch, char *name)
int pressure_min, int ends)
{ {
SDL_Touch **touchPads; SDL_Touch **touchPads;
int selected_touch; int selected_touch;
...@@ -118,11 +135,13 @@ SDL_AddTouch(const SDL_Touch * touch, char *name, int pressure_max, ...@@ -118,11 +135,13 @@ SDL_AddTouch(const SDL_Touch * touch, char *name, int pressure_max,
length = SDL_strlen(name); length = SDL_strlen(name);
SDL_touchPads[index]->focus = 0; SDL_touchPads[index]->focus = 0;
SDL_touchPads[index]->name = SDL_malloc((length + 2) * sizeof(char)); SDL_touchPads[index]->name = SDL_malloc((length + 2) * sizeof(char));
SDL_strlcpy(SDL_touchPads[index]->name, name, length + 1); SDL_strlcpy(SDL_touchPads[index]->name, name, length + 1);
SDL_touchPads[index]->pressure_max = pressure_max;
SDL_touchPads[index]->pressure_min = pressure_min;
SDL_touchPads[index]->num_fingers = 0;
SDL_touchPads[index]->buttonstate = 0;
SDL_touchPads[index]->relative_mode = SDL_FALSE;
SDL_touchPads[index]->flush_motion = SDL_FALSE;
return index; return index;
} }
...@@ -239,7 +258,7 @@ SDL_AddFinger(SDL_Touch* touch,SDL_Finger* finger) ...@@ -239,7 +258,7 @@ SDL_AddFinger(SDL_Touch* touch,SDL_Finger* finger)
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 */
fingers = (SDL_Finger **) SDL_realloc(touch->fingers, fingers = (SDL_Finger **) SDL_realloc(touch->fingers,
...@@ -250,7 +269,7 @@ SDL_AddFinger(SDL_Touch* touch,SDL_Finger* finger) ...@@ -250,7 +269,7 @@ SDL_AddFinger(SDL_Touch* touch,SDL_Finger* finger)
} }
touch->fingers = fingers; touch->fingers = fingers;
index = SDL_num_touch++; index = touch->num_fingers++;
touch->fingers[index] = (SDL_Finger *) SDL_malloc(sizeof(*(touch->fingers[index]))); touch->fingers[index] = (SDL_Finger *) SDL_malloc(sizeof(*(touch->fingers[index])));
if (!touch->fingers[index]) { if (!touch->fingers[index]) {
...@@ -265,7 +284,7 @@ SDL_AddFinger(SDL_Touch* touch,SDL_Finger* finger) ...@@ -265,7 +284,7 @@ SDL_AddFinger(SDL_Touch* touch,SDL_Finger* finger)
int int
SDL_DelFinger(SDL_Touch* touch,int fingerid) SDL_DelFinger(SDL_Touch* touch,int fingerid)
{ {
int index = SLD_GetFingerIndexId(touch,fingerid); int index = SDL_GetFingerIndexId(touch,fingerid);
SDL_Finger* finger = SDL_GetFinger(touch,fingerid); SDL_Finger* finger = SDL_GetFinger(touch,fingerid);
if (!finger) { if (!finger) {
...@@ -282,6 +301,7 @@ SDL_DelFinger(SDL_Touch* touch,int fingerid) ...@@ -282,6 +301,7 @@ SDL_DelFinger(SDL_Touch* touch,int fingerid)
int int
SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressure) SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressure)
{ {
int posted;
SDL_Touch* touch = SDL_GetTouch(id); SDL_Touch* touch = SDL_GetTouch(id);
if(down) { if(down) {
SDL_Finger nf; SDL_Finger nf;
...@@ -300,9 +320,11 @@ SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressu ...@@ -300,9 +320,11 @@ SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressu
SDL_Event event; SDL_Event event;
event.tfinger.type = SDL_FINGERDOWN; event.tfinger.type = SDL_FINGERDOWN;
event.tfinger.touchId = (Uint8) id; event.tfinger.touchId = (Uint8) id;
event.tfinger.x = x;
event.tfinger.y = y;
event.tfinger.state = touch->buttonstate; event.tfinger.state = touch->buttonstate;
event.tfinger.windowID = touch->focus ? touch->focus->id : 0; event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
event.fingerId = id; event.tfinger.fingerId = id;
posted = (SDL_PushEvent(&event) > 0); posted = (SDL_PushEvent(&event) > 0);
} }
return posted; return posted;
...@@ -316,7 +338,7 @@ SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressu ...@@ -316,7 +338,7 @@ SDL_SendFingerDown(int id, int fingerid, SDL_bool down, int x, int y, int pressu
event.tfinger.touchId = (Uint8) id; event.tfinger.touchId = (Uint8) id;
event.tfinger.state = touch->buttonstate; event.tfinger.state = touch->buttonstate;
event.tfinger.windowID = touch->focus ? touch->focus->id : 0; event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
event.fingerId = id; event.tfinger.fingerId = id;
posted = (SDL_PushEvent(&event) > 0); posted = (SDL_PushEvent(&event) > 0);
} }
return posted; return posted;
...@@ -339,69 +361,76 @@ SDL_SendTouchMotion(int id, int fingerid, int relative, ...@@ -339,69 +361,76 @@ SDL_SendTouchMotion(int id, int fingerid, int relative,
return 0; return 0;
} }
/* the relative motion is calculated regarding the system cursor last position */ if(finger == NULL)
if (relative) { SDL_SendFingerDown(id,fingerid,SDL_TRUE,x,y,pressure);
xrel = x; else {
yrel = y; /* the relative motion is calculated regarding the last position */
x = (finger->last_x + x); if (relative) {
y = (finger->last_y + y); xrel = x;
} else { yrel = y;
xrel = x - finger->last_x; x = (finger->last_x + x);
yrel = y - finger->last_y; y = (finger->last_y + y);
} } else {
if(x < 0) x = finger->last_x; /*If movement is only in one axis,*/
/* Drop events that don't change state */ if(y < 0) y = finger->last_y; /*The other is marked as -1*/
if (!xrel && !yrel) { xrel = x - finger->last_x;
yrel = y - finger->last_y;
}
/* Drop events that don't change state */
if (!xrel && !yrel) {
#if 0 #if 0
printf("Touch event didn't change state - dropped!\n"); printf("Touch event didn't change state - dropped!\n");
#endif #endif
return 0; return 0;
} }
/* Update internal touch coordinates */ /* Update internal touch coordinates */
finger->x = x; finger->x = x;
finger->y = y; finger->y = y;
/*Should scale to window? Normalize? Maintain Aspect?*/ /*Should scale to window? Normalize? Maintain Aspect?*/
//SDL_GetWindowSize(touch->focus, &x_max, &y_max); //SDL_GetWindowSize(touch->focus, &x_max, &y_max);
/* make sure that the pointers find themselves inside the windows */ /* make sure that the pointers find themselves inside the windows */
/* only check if touch->xmax is set ! */ /* only check if touch->xmax is set ! */
/* /*
if (x_max && touch->x > x_max) { if (x_max && touch->x > x_max) {
touch->x = x_max; touch->x = x_max;
} else if (touch->x < 0) { } else if (touch->x < 0) {
touch->x = 0; touch->x = 0;
} }
if (y_max && touch->y > y_max) { if (y_max && touch->y > y_max) {
touch->y = y_max; touch->y = y_max;
} else if (touch->y < 0) { } else if (touch->y < 0) {
touch->y = 0; touch->y = 0;
} }
*/ */
finger->xdelta += xrel; finger->xdelta += xrel;
finger->ydelta += yrel; finger->ydelta += yrel;
finger->pressure = pressure; finger->pressure = pressure;
/* Post the event, if desired */ /* Post the event, if desired */
posted = 0; posted = 0;
if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) { if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) {
SDL_Event event; SDL_Event event;
event.tfinger.type = SDL_FINGERMOTION; event.tfinger.type = SDL_FINGERMOTION;
event.tfinger.which = (Uint8) index; event.tfinger.touchId = (Uint8) index;
event.tfinger.state = touch->buttonstate; event.tfinger.x = x;
event.tfinger.windowID = touch->focus ? touch->focus->id : 0; event.tfinger.y = y;
posted = (SDL_PushEvent(&event) > 0); event.tfinger.state = touch->buttonstate;
event.tfinger.windowID = touch->focus ? touch->focus->id : 0;
posted = (SDL_PushEvent(&event) > 0);
}
finger->last_x = finger->x;
finger->last_y = finger->y;
return posted;
} }
finger->last_x = finger->x;
finger->last_y = finger->y;
return posted;
} }
int int
SDL_SendTouchButton(int id, Uint8 state, Uint8 button) SDL_SendTouchButton(int id, Uint8 state, Uint8 button)
{ {
...@@ -441,7 +470,7 @@ SDL_SendTouchButton(int id, Uint8 state, Uint8 button) ...@@ -441,7 +470,7 @@ SDL_SendTouchButton(int id, Uint8 state, Uint8 button)
if (SDL_GetEventState(type) == SDL_ENABLE) { if (SDL_GetEventState(type) == SDL_ENABLE) {
SDL_Event event; SDL_Event event;
event.type = type; event.type = type;
event.tbutton.which = (Uint8) index; event.tbutton.touchId = (Uint8) index;
event.tbutton.state = state; event.tbutton.state = state;
event.tbutton.button = button; event.tbutton.button = button;
event.tbutton.windowID = touch->focus ? touch->focus->id : 0; event.tbutton.windowID = touch->focus ? touch->focus->id : 0;
......
...@@ -51,9 +51,6 @@ struct SDL_Touch ...@@ -51,9 +51,6 @@ struct SDL_Touch
int tilt; /* for future use */ int tilt; /* for future use */
int rotation; /* for future use */ int rotation; /* for future use */
int total_ends;
int current_end;
/* Data common to all touch */ /* Data common to all touch */
int id; int id;
SDL_Window *focus; SDL_Window *focus;
...@@ -73,14 +70,23 @@ struct SDL_Touch ...@@ -73,14 +70,23 @@ struct SDL_Touch
/* Initialize the touch subsystem */ /* Initialize the touch subsystem */
extern int SDL_TouchInit(void); extern int SDL_TouchInit(void);
/* Get the touch at an index */ /*Get the touch at an index */
extern SDL_Touch *SDL_GetTouch(int index); extern SDL_Touch *SDL_GetTouchIndex(int index);
/* Get the touch with id = id */
extern SDL_Touch *SDL_GetTouch(int id);
/*Get the finger at an index */
extern SDL_Finger *SDL_GetFingerIndex(SDL_Touch *touch, int index);
/* Get the finger with id = id */
extern SDL_Finger *SDL_GetFinger(SDL_Touch *touch,int id);
/* Add a touch, possibly reattaching at a particular index (or -1), /* Add a touch, possibly reattaching at a particular index (or -1),
returning the index of the touch, or -1 if there was an error. returning the index of the touch, or -1 if there was an error. */
*/ extern int SDL_AddTouch(const SDL_Touch * touch, char *name);
extern int SDL_AddTouch(const SDL_Touch * touch, char *name,
int pressure_max, int pressure_min, int ends);
/* Remove a touch at an index, clearing the slot for later */ /* Remove a touch at an index, clearing the slot for later */
extern void SDL_DelTouch(int index); extern void SDL_DelTouch(int index);
......
/*
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
*/
#include "SDL_config.h"
#ifndef _SDL_eventtouch_h
#define _SDL_eventtouch_h
//What should this be?
#if SDL_VIDEO_DRIVER_X11_XINPUT
typedef struct EventTouchData
{
int x,y,pressure,finger; //Temporary Variables until sync
int eventStream;
} EventTouchData;
#endif
//extern void X11_InitMouse(_THIS);
//extern void X11_QuitMouse(_THIS);
#endif /* _SDL_eventtouch_h */
/* vi: set ts=4 sw=4 expandtab: */
...@@ -28,9 +28,16 @@ ...@@ -28,9 +28,16 @@
#include "SDL_x11video.h" #include "SDL_x11video.h"
#include "../../events/SDL_events_c.h" #include "../../events/SDL_events_c.h"
#include "../../events/SDL_mouse_c.h" #include "../../events/SDL_mouse_c.h"
#include "../../events/SDL_touch_c.h"
#include "SDL_syswm.h" #include "SDL_syswm.h"
#include <stdio.h>
//Touch Input/event* includes
#include <linux/input.h>
#include <fcntl.h>
static void static void
X11_DispatchEvent(_THIS) X11_DispatchEvent(_THIS)
{ {
...@@ -410,8 +417,65 @@ X11_PumpEvents(_THIS) ...@@ -410,8 +417,65 @@ X11_PumpEvents(_THIS)
} }
/* Process Touch events - TODO When X gets touch support, REMOVE THIS*/ /* Process Touch events - TODO When X gets touch support, use that instead*/
int i = 0,rd;
char * name[256];
struct input_event ev[64];
int size = sizeof (struct input_event);
static int initd = 0; //TODO - HACK!
for(i = 0;i < SDL_GetNumTouch();++i) {
SDL_Touch* touch = SDL_GetTouchIndex(i);
if(!touch) printf("Touch %i/%i DNE\n",i,SDL_GetNumTouch());
EventTouchData* data;
if(!initd){//data->eventStream <= 0) {
touch->driverdata = SDL_malloc(sizeof(EventTouchData));
data = (EventTouchData*)(touch->driverdata);
printf("Openning device...\n");
data->eventStream = open("/dev/input/wacom-touch",
O_RDONLY | O_NONBLOCK);
ioctl (data->eventStream, EVIOCGNAME (sizeof (name)), name);
printf ("Reading From : %s\n", name);
initd = 1;
}
else
data = (EventTouchData*)(touch->driverdata);
if(data->eventStream <= 0)
printf("Error: Couldn't open stream\n");
rd = read(data->eventStream, ev, size * 64);
//printf("Got %i/%i bytes\n",rd,size);
if(rd >= size) {
for (i = 0; i < rd / sizeof(struct input_event); i++) {
switch (ev[i].type) {
case EV_ABS:
//printf("Got position x: %i!\n",data->x);
if(ev[i].code == ABS_X)
data->x = ev[i].value;
else if (ev[i].code == ABS_Y)
data->y = ev[i].value;
break;
case EV_MSC:
if(ev[i].code == MSC_SERIAL)
data->finger = ev[i].value;
break;
case EV_SYN:
data->finger -= 1; /*Wacom indexes fingers from 1,
I index from 0*/
if(data->x >= 0 || data->y >= 0)
SDL_SendTouchMotion(touch->id,data->finger,
SDL_FALSE,data->x,data->y,
data->pressure);
//printf("Synched: %i tx: %i, ty: %i\n",
// data->finger,data->x,data->y);
data->x = -1;
data->y = -1;
data->pressure = -1;
break;
}
}
}
}
} }
/* This is so wrong it hurts */ /* This is so wrong it hurts */
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include "SDL_x11keyboard.h" #include "SDL_x11keyboard.h"
#include "SDL_x11modes.h" #include "SDL_x11modes.h"
#include "SDL_x11mouse.h" #include "SDL_x11mouse.h"
#include "SDL_eventtouch.h"
#include "SDL_x11opengl.h" #include "SDL_x11opengl.h"
#include "SDL_x11window.h" #include "SDL_x11window.h"
......
SDLTest : touchSimp.c touchPong.c SDLTest : touchSimp.c touchPong.c
gcc touchTest.c -o touchTest `sdl-config --cflags --libs` -g
gcc touchSimp.c -o touchSimp `sdl-config --cflags --libs` -g gcc touchSimp.c -o touchSimp `sdl-config --cflags --libs` -g
gcc touchPong.c -o touchPong `sdl-config --cflags --libs` -g gcc touchPong.c -o touchPong `sdl-config --cflags --libs` -g
No preview for this file type
No preview for this file type
...@@ -186,6 +186,10 @@ int main(int argc, char* argv[]) ...@@ -186,6 +186,10 @@ int main(int argc, char* argv[])
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
bstatus &= ~(1<<(event.button.button-1)); bstatus &= ~(1<<(event.button.button-1));
break; break;
case SDL_FINGERMOTION:
printf("Holy SH!T\n");
break;
} }
} }
......
#include <stdio.h>
#include <SDL.h>
#include <math.h>
#include "../src/events/SDL_touch_c.h" //BAD!!!
#define PI 3.1415926535897
#define WIDTH 640
#define HEIGHT 480
#define BPP 4
#define DEPTH 32
int mousx,mousy;
int keystat[512];
int bstatus;
typedef struct {
int x,y;
} Point;
void handler (int sig)
{
printf ("\nexiting...(%d)\n", sig);
exit (0);
}
void perror_exit (char *error)
{
perror (error);
handler (9);
}
void setpix(SDL_Surface *screen, int x, int y, int col)
{
Uint32 *pixmem32;
Uint32 colour;
if((unsigned)x > screen->w) return;
if((unsigned)y > screen->h) return;
colour = SDL_MapRGB( screen->format, (col>>16)&0xFF, (col>>8)&0xFF, col&0xFF);
pixmem32 = (Uint32*) screen->pixels + y*screen->pitch/BPP + x;
*pixmem32 = colour;
}
void drawCircle(SDL_Surface* screen,int x,int y,int r,int c)
{
float a;
for(a=0;a<2*PI;a+=1.f/(float)r)
{
setpix(screen,(int)(x+r*cos(a)),(int)(y+r*sin(a)),c);
}
}
void DrawScreen(SDL_Surface* screen, int h)
{
int x, y, xm,ym,c;
if(SDL_MUSTLOCK(screen))
{
if(SDL_LockSurface(screen) < 0) return;
}
for(y = 0; y < screen->h; y++ )
{
for( x = 0; x < screen->w; x++ )
{
//setpixel(screen, x, y, (x*x)/256+3*y+h, (y*y)/256+x+h, h);
//xm = (x+h)%screen->w;
//ym = (y+h)%screen->w;
//c = sin(h/256*2*PI)*x*y/screen->w/screen->h;
//setpix(screen,x,y,255*sin(xm/screen->w*2*PI),sin(h/255*2*PI)*255*y/screen->h,c);
setpix(screen,x,y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255);
}
}
drawCircle(screen,mousx,mousy,30,0xFFFFFF);
if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen);
SDL_Flip(screen);
}
SDL_Surface* initScreen(int width,int height)
{
return SDL_SetVideoMode(width, height, DEPTH,
SDL_HWSURFACE | SDL_RESIZABLE);
}
int main(int argc, char* argv[])
{
SDL_Surface *screen;
SDL_Event event;
int keypress = 0;
int h=0,s=1,i,j;
memset(keystat,0,512*sizeof(keystat[0]));
if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1;
if (!(screen = initScreen(WIDTH,HEIGHT)))
{
SDL_Quit();
return 1;
}
while(!keystat[27]) {
//Poll SDL
while(SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
keystat[27] = 1;
break;
case SDL_KEYDOWN:
//printf("%i\n",event.key.keysym.sym);
keystat[event.key.keysym.sym] = 1;
//keypress = 1;
break;
case SDL_KEYUP:
//printf("%i\n",event.key.keysym.sym);
keystat[event.key.keysym.sym] = 0;
//keypress = 1;
break;
case SDL_VIDEORESIZE:
if (!(screen = initScreen(event.resize.w,
event.resize.h)))
{
SDL_Quit();
return 1;
}
break;
case SDL_MOUSEMOTION:
mousx = event.motion.x;
mousy = event.motion.y;
break;
case SDL_MOUSEBUTTONDOWN:
bstatus |= (1<<(event.button.button-1));
break;
case SDL_MOUSEBUTTONUP:
bstatus &= ~(1<<(event.button.button-1));
break;
case SDL_FINGERMOTION:
i = 1;
printf("Finger: %i,x: %i, y: %i\n",event.tfinger.fingerId,
event.tfinger.x,event.tfinger.y);
break;
}
}
//And draw
DrawScreen(screen,h);
/*
for(i=0;i<512;i++)
if(keystat[i]) printf("%i\n",i);
printf("Buttons:%i\n",bstatus);
*/
}
SDL_Quit();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment