include/SDL_touch.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 02 Mar 2013 20:44:16 -0800
changeset 6950 1ddb72193079
parent 6885 700f1b25f77f
child 6951 7833f01322b3
permissions -rw-r--r--
Added a mouse ID to the mouse events, which set to the special value SDL_TOUCH_MOUSEID for mouse events simulated by touch input.
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2013 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 typedef Sint64 SDL_TouchID;
    44 typedef Sint64 SDL_FingerID;
    45 
    46 typedef struct SDL_Finger
    47 {
    48     SDL_FingerID id;
    49     Uint16 x;
    50     Uint16 y;
    51     Uint16 pressure;
    52     Uint16 xdelta;
    53     Uint16 ydelta;
    54     Uint16 last_x, last_y,last_pressure;  /* the last reported coordinates */
    55     SDL_bool down;
    56 } SDL_Finger;
    57 
    58 typedef struct SDL_Touch
    59 {
    60   /* Free the touch when it's time */
    61   void (*FreeTouch) (struct SDL_Touch * touch);
    62   
    63   /* data common for tablets */
    64   float pressure_max, pressure_min;
    65   float x_max,x_min;
    66   float y_max,y_min;
    67   Uint16 xres,yres,pressureres;
    68   float native_xres,native_yres,native_pressureres;
    69   float tilt_x;                 /* for future use */
    70   float tilt_y;                 /* for future use */
    71   float rotation;               /* for future use */
    72   
    73   /* Data common to all touch */
    74   SDL_TouchID id;
    75   SDL_Window *focus;
    76   
    77   char *name;
    78   Uint8 buttonstate;
    79   SDL_bool relative_mode;
    80   SDL_bool flush_motion;
    81 
    82   int num_fingers;
    83   int max_fingers;
    84   SDL_Finger** fingers;
    85     
    86   void *driverdata;
    87 } SDL_Touch;
    88 
    89 /* Used as the device ID for mouse events simulated with touch input */
    90 #define SDL_TOUCH_MOUSEID ((Uint32)-1)
    91 
    92 
    93 /* Function prototypes */
    94 
    95 /**
    96  *  \brief Get the touch object with the given id.
    97  */
    98 extern DECLSPEC SDL_Touch* SDLCALL SDL_GetTouch(SDL_TouchID id);
    99 
   100 /**
   101  *  \brief Get the finger object of the given touch, with the given id.
   102  */
   103 extern DECLSPEC SDL_Finger* SDLCALL SDL_GetFinger(SDL_Touch *touch, SDL_FingerID id);
   104 
   105 /* Ends C function definitions when using C++ */
   106 #ifdef __cplusplus
   107 /* *INDENT-OFF* */
   108 }
   109 /* *INDENT-ON* */
   110 #endif
   111 #include "close_code.h"
   112 
   113 #endif /* _SDL_touch_h */
   114 
   115 /* vi: set ts=4 sw=4 expandtab: */