include/SDL_touch.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 18 Jul 2012 15:53:33 -0700
changeset 6372 76d0f2cf2ca6
parent 6342 ac83b73f0edd
child 6885 700f1b25f77f
permissions -rw-r--r--
Fixed bug 1542 - SDL_Touch should reserve tilt_x and tilt_y

Gerry JJ 2012-07-14 19:42:23 PDT
The SDL_Touch structure currently reserves fields for tablet tilt and rotation
(marked "for future use"), but a tablet stylus can tilt in both x and y
directions in addition to rotation around itself (or, put another way, it can
rotate in x, y and z). So, the struct should probably reserve fields for both
tilt_x and tilt_y, not just tilt.
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     4 
     5   This software is provided 'as-is', without any express or implied
     6   warranty.  In no event will the authors be held liable for any damages
     7   arising from the use of this software.
     8 
     9   Permission is granted to anyone to use this software for any purpose,
    10   including commercial applications, and to alter it and redistribute it
    11   freely, subject to the following restrictions:
    12 
    13   1. The origin of this software must not be misrepresented; you must not
    14      claim that you wrote the original software. If you use this software
    15      in a product, an acknowledgment in the product documentation would be
    16      appreciated but is not required.
    17   2. Altered source versions must be plainly marked as such, and must not be
    18      misrepresented as being the original software.
    19   3. This notice may not be removed or altered from any source distribution.
    20 */
    21 
    22 /**
    23  *  \file SDL_touch.h
    24  *  
    25  *  Include file for SDL touch event handling.
    26  */
    27 
    28 #ifndef _SDL_touch_h
    29 #define _SDL_touch_h
    30 
    31 #include "SDL_stdinc.h"
    32 #include "SDL_error.h"
    33 #include "SDL_video.h"
    34 
    35 #include "begin_code.h"
    36 /* Set up for C function definitions, even when using C++ */
    37 #ifdef __cplusplus
    38 /* *INDENT-OFF* */
    39 extern "C" {
    40 /* *INDENT-ON* */
    41 #endif
    42 
    43 
    44 typedef Sint64 SDL_TouchID;
    45 typedef Sint64 SDL_FingerID;
    46 
    47 
    48 struct SDL_Finger {
    49   SDL_FingerID id;
    50   Uint16 x;
    51   Uint16 y;
    52   Uint16 pressure;
    53   Uint16 xdelta;
    54   Uint16 ydelta;
    55   Uint16 last_x, last_y,last_pressure;  /* the last reported coordinates */
    56   SDL_bool down;
    57 };
    58 
    59 typedef struct SDL_Touch SDL_Touch;
    60 typedef struct SDL_Finger SDL_Finger;
    61 
    62 
    63 struct SDL_Touch {
    64   
    65   /* Free the touch when it's time */
    66   void (*FreeTouch) (SDL_Touch * touch);
    67   
    68   /* data common for tablets */
    69   float pressure_max, pressure_min;
    70   float x_max,x_min;
    71   float y_max,y_min;
    72   Uint16 xres,yres,pressureres;
    73   float native_xres,native_yres,native_pressureres;
    74   float tilt_x;                 /* for future use */
    75   float tilt_y;                 /* for future use */
    76   float rotation;               /* for future use */
    77   
    78   /* Data common to all touch */
    79   SDL_TouchID id;
    80   SDL_Window *focus;
    81   
    82   char *name;
    83   Uint8 buttonstate;
    84   SDL_bool relative_mode;
    85   SDL_bool flush_motion;
    86 
    87   int num_fingers;
    88   int max_fingers;
    89   SDL_Finger** fingers;
    90     
    91   void *driverdata;
    92 };
    93 
    94 
    95 
    96 /* Function prototypes */
    97 
    98 /**
    99  *  \brief Get the touch object at the given id.
   100  *
   101  *
   102  */
   103   extern DECLSPEC SDL_Touch* SDLCALL SDL_GetTouch(SDL_TouchID id);
   104 
   105 
   106 
   107 /**
   108  *  \brief Get the finger object of the given touch, at the given id.
   109  *
   110  *
   111  */
   112   extern 
   113   DECLSPEC SDL_Finger* SDLCALL SDL_GetFinger(SDL_Touch *touch, SDL_FingerID id);
   114 
   115 /* Ends C function definitions when using C++ */
   116 #ifdef __cplusplus
   117 /* *INDENT-OFF* */
   118 }
   119 /* *INDENT-ON* */
   120 #endif
   121 #include "close_code.h"
   122 
   123 #endif /* _SDL_touch_h */
   124 
   125 /* vi: set ts=4 sw=4 expandtab: */