src/events/SDL_touch_c.h
author Jim Grandpre
Fri, 28 May 2010 01:26:52 -0400
changeset 4642 057e8762d2a1
parent 4641 49a97daea6ec
child 4645 0375d020e7e3
permissions -rw-r--r--
Added reading of event* for touch events.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2010 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 #include "SDL_config.h"
    23 
    24 #ifndef _SDL_touch_c_h
    25 #define _SDL_touch_c_h
    26 
    27 typedef struct SDL_Touch SDL_Touch;
    28 typedef struct SDL_Finger SDL_Finger;
    29 
    30 struct SDL_Finger {
    31   int id;
    32   int x;
    33   int y;
    34   int z;                      /* for future use */
    35   int xdelta;
    36   int ydelta;
    37   int last_x, last_y;         /* the last reported x and y coordinates */
    38   int pressure;
    39 };
    40 
    41 
    42 struct SDL_Touch
    43 {
    44   
    45   /* Free the touch when it's time */
    46   void (*FreeTouch) (SDL_Touch * touch);
    47   
    48   /* data common for tablets */
    49   int pressure_max;
    50   int pressure_min;
    51   int tilt;                   /* for future use */
    52   int rotation;               /* for future use */
    53   
    54   /* Data common to all touch */
    55   int id;
    56   SDL_Window *focus;
    57   
    58   char *name;
    59   Uint8 buttonstate;
    60   SDL_bool relative_mode;
    61   SDL_bool flush_motion;
    62 
    63   int num_fingers;
    64   SDL_Finger** fingers;
    65     
    66   void *driverdata;
    67 };
    68 
    69 
    70 /* Initialize the touch subsystem */
    71 extern int SDL_TouchInit(void);
    72 
    73 /*Get the touch at an index */
    74 extern SDL_Touch *SDL_GetTouchIndex(int index);
    75 
    76 /* Get the touch with id = id */
    77 extern SDL_Touch *SDL_GetTouch(int id);
    78 
    79 /*Get the finger at an index */
    80 extern SDL_Finger *SDL_GetFingerIndex(SDL_Touch *touch, int index);
    81 
    82 /* Get the finger with id = id */
    83 extern SDL_Finger *SDL_GetFinger(SDL_Touch *touch,int id);
    84 
    85 
    86 /* Add a touch, possibly reattaching at a particular index (or -1),
    87    returning the index of the touch, or -1 if there was an error. */
    88 extern int SDL_AddTouch(const SDL_Touch * touch, char *name);
    89                      
    90 
    91 /* Remove a touch at an index, clearing the slot for later */
    92 extern void SDL_DelTouch(int index);
    93 
    94 /* Set the touch focus window */
    95 extern void SDL_SetTouchFocus(int id, SDL_Window * window);
    96 
    97 /* Send a touch motion event for a touch */
    98 extern int SDL_SendTouchMotion(int id, int fingerid,
    99 			       int relative, int x, int y, int z);
   100 
   101 /* Send a touch button event for a touch */
   102 extern int SDL_SendTouchButton(int id, Uint8 state, Uint8 button);
   103 
   104 /* Shutdown the touch subsystem */
   105 extern void SDL_TouchQuit(void);
   106 
   107 /* FIXME: Where do these functions go in this header? */
   108 extern void SDL_ChangeEnd(int id, int end);
   109 
   110 #endif /* _SDL_touch_c_h */
   111 
   112 /* vi: set ts=4 sw=4 expandtab: */