src/events/SDL_mouse_c.h
author Sam Lantinga <slouken@libsdl.org>
Thu, 21 Jan 2010 06:21:52 +0000
changeset 3685 64ce267332c6
parent 2940 b93965a16fe0
child 3697 f7b03b6838cb
permissions -rw-r--r--
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
slouken@1895
     1
/*
slouken@1895
     2
    SDL - Simple DirectMedia Layer
slouken@2859
     3
    Copyright (C) 1997-2009 Sam Lantinga
slouken@1895
     4
slouken@1895
     5
    This library is free software; you can redistribute it and/or
slouken@1895
     6
    modify it under the terms of the GNU Lesser General Public
slouken@1895
     7
    License as published by the Free Software Foundation; either
slouken@1895
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@1895
     9
slouken@1895
    10
    This library is distributed in the hope that it will be useful,
slouken@1895
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@1895
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1895
    13
    Lesser General Public License for more details.
slouken@1895
    14
slouken@1895
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1895
    16
    License along with this library; if not, write to the Free Software
slouken@1895
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@1895
    18
slouken@1895
    19
    Sam Lantinga
slouken@1895
    20
    slouken@libsdl.org
slouken@1895
    21
*/
slouken@1895
    22
#include "SDL_config.h"
slouken@1895
    23
slouken@1895
    24
#ifndef _SDL_mouse_c_h
slouken@1895
    25
#define _SDL_mouse_c_h
slouken@1895
    26
slouken@1895
    27
typedef struct SDL_Mouse SDL_Mouse;
slouken@1895
    28
slouken@1895
    29
struct SDL_Cursor
slouken@1895
    30
{
slouken@1895
    31
    SDL_Mouse *mouse;
slouken@1895
    32
    SDL_Cursor *next;
slouken@1895
    33
    void *driverdata;
slouken@1895
    34
};
slouken@1895
    35
slouken@1895
    36
struct SDL_Mouse
slouken@1895
    37
{
slouken@1895
    38
    /* Create a cursor from a surface */
slouken@1895
    39
    SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y);
slouken@1895
    40
slouken@1895
    41
    /* Show the specified cursor, or hide if cursor is NULL */
slouken@1895
    42
    int (*ShowCursor) (SDL_Cursor * cursor);
slouken@1895
    43
slouken@1895
    44
    /* This is called when a mouse motion event occurs */
slouken@1895
    45
    void (*MoveCursor) (SDL_Cursor * cursor);
slouken@1895
    46
slouken@1895
    47
    /* Free a window manager cursor */
slouken@1895
    48
    void (*FreeCursor) (SDL_Cursor * cursor);
slouken@1895
    49
slouken@1895
    50
    /* Warp the mouse to (x,y) */
slouken@3685
    51
    void (*WarpMouse) (SDL_Mouse * mouse, SDL_Window * window, int x,
slouken@1895
    52
                       int y);
slouken@1895
    53
slouken@1895
    54
    /* Free the mouse when it's time */
slouken@1895
    55
    void (*FreeMouse) (SDL_Mouse * mouse);
slouken@1895
    56
slouken@2710
    57
    /* data common for tablets */
slouken@2710
    58
    int pressure;
slouken@2710
    59
    int pressure_max;
slouken@2710
    60
    int pressure_min;
slouken@2710
    61
    int tilt;                   /* for future use */
slouken@2710
    62
    int rotation;               /* for future use */
slouken@2710
    63
    int total_ends;
slouken@2710
    64
    int current_end;
slouken@2710
    65
slouken@1895
    66
    /* Data common to all mice */
slouken@2940
    67
    int id;
slouken@3685
    68
    SDL_Window *focus;
slouken@2710
    69
    int which;
slouken@2849
    70
    int x;
slouken@2849
    71
    int y;
slouken@2710
    72
    int z;                      /* for future use */
slouken@1895
    73
    int xdelta;
slouken@1895
    74
    int ydelta;
slouken@2860
    75
    int last_x, last_y;         /* the last reported x and y coordinates */
slouken@2710
    76
    char *name;
slouken@1895
    77
    Uint8 buttonstate;
slouken@1895
    78
    SDL_bool relative_mode;
slouken@2710
    79
    SDL_bool proximity;
slouken@1895
    80
    SDL_bool flush_motion;
slouken@1895
    81
slouken@1895
    82
    SDL_Cursor *cursors;
slouken@1895
    83
    SDL_Cursor *def_cursor;
slouken@1895
    84
    SDL_Cursor *cur_cursor;
slouken@1895
    85
    SDL_bool cursor_shown;
slouken@1895
    86
slouken@1895
    87
    void *driverdata;
slouken@1895
    88
};
slouken@1895
    89
slouken@1895
    90
/* Initialize the mouse subsystem */
slouken@1895
    91
extern int SDL_MouseInit(void);
slouken@1895
    92
slouken@2712
    93
/* Get the mouse at an index */
slouken@2712
    94
extern SDL_Mouse *SDL_GetMouse(int index);
slouken@2710
    95
slouken@1895
    96
/* Add a mouse, possibly reattaching at a particular index (or -1),
slouken@1895
    97
   returning the index of the mouse, or -1 if there was an error.
slouken@1895
    98
 */
slouken@2940
    99
extern int SDL_AddMouse(const SDL_Mouse * mouse, char *name,
slouken@2710
   100
                        int pressure_max, int pressure_min, int ends);
slouken@1895
   101
slouken@1895
   102
/* Remove a mouse at an index, clearing the slot for later */
slouken@1895
   103
extern void SDL_DelMouse(int index);
slouken@1895
   104
slouken@1895
   105
/* Clear the button state of a mouse at an index */
slouken@1895
   106
extern void SDL_ResetMouse(int index);
slouken@1895
   107
slouken@1895
   108
/* Set the mouse focus window */
slouken@3685
   109
extern void SDL_SetMouseFocus(int id, SDL_Window * window);
slouken@1895
   110
slouken@2727
   111
/* Send a mouse motion event for a mouse */
slouken@2710
   112
extern int SDL_SendMouseMotion(int id, int relative, int x, int y, int z);
slouken@1895
   113
slouken@2727
   114
/* Send a mouse button event for a mouse */
slouken@2710
   115
extern int SDL_SendMouseButton(int id, Uint8 state, Uint8 button);
slouken@1895
   116
slouken@2727
   117
/* Send a mouse wheel event for a mouse */
slouken@2710
   118
extern int SDL_SendMouseWheel(int id, int x, int y);
slouken@1895
   119
slouken@2727
   120
/* Send a proximity event for a mouse */
slouken@2727
   121
extern int SDL_SendProximity(int id, int x, int y, int type);
slouken@2727
   122
slouken@1895
   123
/* Shutdown the mouse subsystem */
slouken@1895
   124
extern void SDL_MouseQuit(void);
slouken@1895
   125
slouken@2710
   126
/* FIXME: Where do these functions go in this header? */
slouken@2710
   127
extern void SDL_ChangeEnd(int id, int end);
slouken@2710
   128
slouken@1895
   129
#endif /* _SDL_mouse_c_h */
slouken@1895
   130
slouken@1895
   131
/* vi: set ts=4 sw=4 expandtab: */