src/events/SDL_touch_c.h
author Jim Grandpre
Thu, 27 May 2010 01:21:37 -0400
changeset 4641 49a97daea6ec
parent 4640 f068a6dfc858
child 4642 057e8762d2a1
permissions -rw-r--r--
Added touch event definitions. Heavily modified events/SDL_touch*.
     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   int total_ends;
    55   int current_end;
    56   
    57   /* Data common to all touch */
    58   int id;
    59   SDL_Window *focus;
    60   
    61   char *name;
    62   Uint8 buttonstate;
    63   SDL_bool relative_mode;
    64   SDL_bool flush_motion;
    65 
    66   int num_fingers;
    67   SDL_Finger** fingers;
    68     
    69   void *driverdata;
    70 };
    71 
    72 
    73 /* Initialize the touch subsystem */
    74 extern int SDL_TouchInit(void);
    75 
    76 /* Get the touch at an index */
    77 extern SDL_Touch *SDL_GetTouch(int index);
    78 
    79 /* Add a touch, possibly reattaching at a particular index (or -1),
    80    returning the index of the touch, or -1 if there was an error.
    81  */
    82 extern int SDL_AddTouch(const SDL_Touch * touch, char *name,
    83                         int pressure_max, int pressure_min, int ends);
    84 
    85 /* Remove a touch at an index, clearing the slot for later */
    86 extern void SDL_DelTouch(int index);
    87 
    88 /* Set the touch focus window */
    89 extern void SDL_SetTouchFocus(int id, SDL_Window * window);
    90 
    91 /* Send a touch motion event for a touch */
    92 extern int SDL_SendTouchMotion(int id, int fingerid,
    93 			       int relative, int x, int y, int z);
    94 
    95 /* Send a touch button event for a touch */
    96 extern int SDL_SendTouchButton(int id, Uint8 state, Uint8 button);
    97 
    98 /* Shutdown the touch subsystem */
    99 extern void SDL_TouchQuit(void);
   100 
   101 /* FIXME: Where do these functions go in this header? */
   102 extern void SDL_ChangeEnd(int id, int end);
   103 
   104 #endif /* _SDL_touch_c_h */
   105 
   106 /* vi: set ts=4 sw=4 expandtab: */