src/events/SDL_mouse_c.h
author Ryan C. Gordon <icculus@icculus.org>
Fri, 17 Jul 2015 21:03:58 -0400
changeset 9807 57b448735f48
parent 9619 b94b6d0bff0f
child 9998 f67cf37e9cd4
permissions -rw-r--r--
SDL_WarpMouseGlobal() should return non-void.

There are platforms it isn't implemented on (and currently can't be
implemented on!), and there's currently no way for an app to know this.

This shouldn't break ABI on apps that moved to a revision between 2.0.3 and
2.0.4.
slouken@1895
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@9619
     3
  Copyright (C) 1997-2015 Sam Lantinga <slouken@libsdl.org>
slouken@1895
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@1895
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@1895
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@1895
    20
*/
icculus@8093
    21
#include "../SDL_internal.h"
slouken@1895
    22
slouken@1895
    23
#ifndef _SDL_mouse_c_h
slouken@1895
    24
#define _SDL_mouse_c_h
slouken@1895
    25
slouken@5371
    26
#include "SDL_mouse.h"
slouken@5371
    27
slouken@6950
    28
typedef Uint32 SDL_MouseID;
slouken@6950
    29
slouken@1895
    30
struct SDL_Cursor
slouken@1895
    31
{
slouken@5001
    32
    struct SDL_Cursor *next;
slouken@1895
    33
    void *driverdata;
slouken@1895
    34
};
slouken@1895
    35
slouken@5371
    36
typedef struct
slouken@5371
    37
{
slouken@8066
    38
    int last_x, last_y;
slouken@8066
    39
    Uint32 last_timestamp;
slouken@8066
    40
    Uint8 click_count;
slouken@8066
    41
} SDL_MouseClickState;
slouken@8066
    42
slouken@8066
    43
typedef struct
slouken@8066
    44
{
slouken@5371
    45
    /* Create a cursor from a surface */
slouken@5371
    46
    SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y);
slouken@5371
    47
mikesart@6675
    48
    /* Create a system cursor */
slouken@7191
    49
    SDL_Cursor *(*CreateSystemCursor) (SDL_SystemCursor id);
mikesart@6675
    50
slouken@5371
    51
    /* Show the specified cursor, or hide if cursor is NULL */
slouken@5371
    52
    int (*ShowCursor) (SDL_Cursor * cursor);
slouken@5371
    53
slouken@5371
    54
    /* This is called when a mouse motion event occurs */
slouken@5371
    55
    void (*MoveCursor) (SDL_Cursor * cursor);
slouken@5371
    56
slouken@5371
    57
    /* Free a window manager cursor */
slouken@5371
    58
    void (*FreeCursor) (SDL_Cursor * cursor);
slouken@5371
    59
slouken@8815
    60
    /* Warp the mouse to (x,y) within a window */
slouken@5371
    61
    void (*WarpMouse) (SDL_Window * window, int x, int y);
slouken@5371
    62
slouken@8815
    63
    /* Warp the mouse to (x,y) in screen space */
icculus@9807
    64
    int (*WarpMouseGlobal) (int x, int y);
slouken@8815
    65
slouken@5406
    66
    /* Set relative mode */
slouken@5406
    67
    int (*SetRelativeMouseMode) (SDL_bool enabled);
slouken@5406
    68
icculus@8927
    69
    /* Set mouse capture */
icculus@8927
    70
    int (*CaptureMouse) (SDL_Window * window);
icculus@8927
    71
icculus@8945
    72
    /* Get absolute mouse coordinates. (x) and (y) are never NULL and set to zero before call. */
icculus@8952
    73
    Uint32 (*GetGlobalMouseState) (int *x, int *y);
icculus@8945
    74
slouken@5371
    75
    /* Data common to all mice */
slouken@6950
    76
    SDL_MouseID mouseID;
slouken@5371
    77
    SDL_Window *focus;
slouken@5371
    78
    int x;
slouken@5371
    79
    int y;
slouken@5371
    80
    int xdelta;
slouken@5371
    81
    int ydelta;
slouken@5371
    82
    int last_x, last_y;         /* the last reported x and y coordinates */
slouken@6673
    83
    Uint32 buttonstate;
slouken@5371
    84
    SDL_bool relative_mode;
slouken@8071
    85
    SDL_bool relative_mode_warp;
slouken@5371
    86
slouken@8066
    87
    /* Data for double-click tracking */
slouken@8066
    88
    int num_clickstates;
slouken@8066
    89
    SDL_MouseClickState *clickstate;
slouken@8066
    90
slouken@5371
    91
    SDL_Cursor *cursors;
slouken@5371
    92
    SDL_Cursor *def_cursor;
slouken@5371
    93
    SDL_Cursor *cur_cursor;
slouken@5371
    94
    SDL_bool cursor_shown;
jorgen@7114
    95
jorgen@7114
    96
    /* Driver-dependent data. */
jorgen@7114
    97
    void *driverdata;
slouken@5371
    98
} SDL_Mouse;
slouken@5371
    99
slouken@5371
   100
slouken@1895
   101
/* Initialize the mouse subsystem */
slouken@1895
   102
extern int SDL_MouseInit(void);
slouken@1895
   103
slouken@5371
   104
/* Get the mouse state structure */
slouken@5371
   105
SDL_Mouse *SDL_GetMouse(void);
slouken@5371
   106
slouken@8066
   107
/* Set the default double-click interval */
slouken@8066
   108
extern void SDL_SetDoubleClickTime(Uint32 interval);
slouken@8066
   109
slouken@5405
   110
/* Set the default mouse cursor */
slouken@5405
   111
extern void SDL_SetDefaultCursor(SDL_Cursor * cursor);
slouken@5405
   112
slouken@1895
   113
/* Set the mouse focus window */
slouken@4465
   114
extern void SDL_SetMouseFocus(SDL_Window * window);
slouken@1895
   115
slouken@4465
   116
/* Send a mouse motion event */
slouken@6950
   117
extern int SDL_SendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y);
slouken@1895
   118
slouken@4465
   119
/* Send a mouse button event */
slouken@6950
   120
extern int SDL_SendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button);
slouken@1895
   121
slouken@4465
   122
/* Send a mouse wheel event */
urkle@9257
   123
extern int SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, int x, int y, SDL_MouseWheelDirection direction);
slouken@2727
   124
slouken@1895
   125
/* Shutdown the mouse subsystem */
slouken@1895
   126
extern void SDL_MouseQuit(void);
slouken@1895
   127
slouken@1895
   128
#endif /* _SDL_mouse_c_h */
slouken@1895
   129
slouken@1895
   130
/* vi: set ts=4 sw=4 expandtab: */