include/SDL_touchscreen.h
branchgsoc2008_nds
changeset 2678 3895761db26a
parent 2677 6386764eb222
child 2679 bc3e3e889f6d
equal deleted inserted replaced
2677:6386764eb222 2678:3895761db26a
     1 /*
       
     2     SDL - Simple DirectMedia Layer
       
     3     Copyright (C) 1997-2006 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 
       
    23 /**
       
    24  * \file SDL_touchscreen.h
       
    25  *
       
    26  * Include file for SDL touchscreen event handling
       
    27  */
       
    28 
       
    29 #ifndef _SDL_touchscreen_h
       
    30 #define _SDL_touchscreen_h
       
    31 
       
    32 #include "SDL_stdinc.h"
       
    33 #include "SDL_error.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 /* In order to use these functions, SDL_Init() must have been called
       
    44    with the SDL_INIT_TOUCHSCREEN flag.  This causes SDL to scan the system
       
    45    for touchscreens, and load appropriate drivers.
       
    46 */
       
    47 
       
    48 /* The touchscreen structure used to identify an SDL touchscreen */
       
    49 struct _SDL_Touchscreen;
       
    50 typedef struct _SDL_Touchscreen SDL_Touchscreen;
       
    51 
       
    52 
       
    53 /* Function prototypes */
       
    54 /*
       
    55  * Count the number of touchscreens attached to the system
       
    56  */
       
    57 extern DECLSPEC int SDLCALL SDL_NumTouchscreens(void);
       
    58 
       
    59 /*
       
    60  * Get the implementation dependent name of a touchscreen.
       
    61  * This can be called before any touchscreens are opened.
       
    62  * If no name can be found, this function returns NULL.
       
    63  */
       
    64 extern DECLSPEC const char *SDLCALL SDL_TouchscreenName(int device_index);
       
    65 
       
    66 /*
       
    67  * Open a touchscreen for use - the index passed as an argument refers to
       
    68  * the N'th touchscreen on the system.  This index is the value which will
       
    69  * identify this touchscreen in future touchscreen events.
       
    70  *
       
    71  * This function returns a touchscreen identifier, or NULL if an error occurred.
       
    72  */
       
    73 extern DECLSPEC SDL_Touchscreen *SDLCALL SDL_TouchscreenOpen(int device_index);
       
    74 
       
    75 /*
       
    76  * Returns 1 if the touchscreen has been opened, or 0 if it has not.
       
    77  */
       
    78 extern DECLSPEC int SDLCALL SDL_TouchscreenOpened(int device_index);
       
    79 
       
    80 /*
       
    81  * Get the device index of an opened touchscreen.
       
    82  */
       
    83 extern DECLSPEC int SDLCALL SDL_TouchscreenIndex(SDL_Touchscreen * touchscreen);
       
    84 
       
    85 /*
       
    86  * Get the number of points a touchscreen can register at a time
       
    87  * (single or multi-touch.)
       
    88  */
       
    89 extern DECLSPEC int SDLCALL SDL_TouchscreenMaxPoints(SDL_Touchscreen * touchscreen);
       
    90 
       
    91 /*
       
    92  * Update the current state of the open touchscreens.
       
    93  * This is called automatically by the event loop if any touchscreen
       
    94  * events are enabled.
       
    95  */
       
    96 extern DECLSPEC void SDLCALL SDL_TouchscreenUpdate(void);
       
    97 
       
    98 /*
       
    99  * Enable/disable touchscreen event polling.
       
   100  * If touchscreen events are disabled, you must call SDL_TouchscreenUpdate()
       
   101  * yourself and check the state of the touchscreen when you want touchscreen
       
   102  * information.
       
   103  * The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.
       
   104  */
       
   105 extern DECLSPEC int SDLCALL SDL_TouchscreenEventState(int state);
       
   106 
       
   107 /*
       
   108  * Get the current X,Y position of the indicated point on the touchscreen.
       
   109  *
       
   110  * If not NULL, *x is set to an unsigned integer in the range [1,65535]
       
   111  * where 1 is the left edge, 32768 is roughly center, 65535 is right edge.
       
   112  * Similarly with *y, for the top, center, and bottom, respectively.
       
   113  * The returned value is an unsigned integer in the range [1,65535],
       
   114  * which represents the pressure of the touch.  This should be 32767 in
       
   115  * non-pressure-sensitive driver implementations.
       
   116  * If not being touched, 0 is returned and *x and *y are unmodified.
       
   117  *
       
   118  * The touch point indices start at index 0.
       
   119  * If given a negative value for point, all the X,Y, and pressures
       
   120  * for all the currently touched points on a multitouch device
       
   121  * should be averaged and used for *x, *y, and the return value.
       
   122  * If the value of point exceeds the number of points currently touched,
       
   123  * 0 should be returned, and *x, *y should be left unmodified.
       
   124  *
       
   125  * On error, -1 is returned.
       
   126  */
       
   127 extern DECLSPEC Uint16 SDLCALL SDL_TouchscreenGetXY(SDL_Touchscreen *touchscreen,
       
   128                                                     int point, Uint16 *x, Uint16 *y);
       
   129 
       
   130 /*
       
   131  * Get the number of currently touched points on a touchscreen.
       
   132  * This is either 0 or 1 for a single-touch device.
       
   133  * On error, -1 is returned.
       
   134  */
       
   135 extern DECLSPEC int SDLCALL SDL_TouchscreenGetPoints(SDL_Touchscreen * touchscreen);
       
   136 
       
   137 /*
       
   138  * Close a touchscreen previously opened with SDL_TouchscreenOpen()
       
   139  */
       
   140 extern DECLSPEC void SDLCALL SDL_TouchscreenClose(SDL_Touchscreen * touchscreen);
       
   141 
       
   142 
       
   143 /* Ends C function definitions when using C++ */
       
   144 #ifdef __cplusplus
       
   145 /* *INDENT-OFF* */
       
   146 }
       
   147 /* *INDENT-ON* */
       
   148 #endif
       
   149 #include "close_code.h"
       
   150 
       
   151 #endif /* _SDL_touchscreen_h */
       
   152 
       
   153 /* vi: set ts=4 sw=4 expandtab: */