Path: blob/main/system/include/SDL/SDL_mouse.h
6169 views
/*1Simple DirectMedia Layer2Copyright (C) 1997-2011 Sam Lantinga <[email protected]>34This software is provided 'as-is', without any express or implied5warranty. In no event will the authors be held liable for any damages6arising from the use of this software.78Permission is granted to anyone to use this software for any purpose,9including commercial applications, and to alter it and redistribute it10freely, subject to the following restrictions:11121. The origin of this software must not be misrepresented; you must not13claim that you wrote the original software. If you use this software14in a product, an acknowledgment in the product documentation would be15appreciated but is not required.162. Altered source versions must be plainly marked as such, and must not be17misrepresented as being the original software.183. This notice may not be removed or altered from any source distribution.19*/2021/**22* \file SDL_mouse.h23*24* Include file for SDL mouse event handling.25*26* Please note that this ONLY discusses "mice" with the notion of the27* desktop GUI. You (usually) have one system cursor, and the OS hides28* the hardware details from you. If you plug in 10 mice, all ten move that29* one cursor. For many applications and games, this is perfect, and this30* API has served hundreds of SDL programs well since its birth.31*32* It's not the whole picture, though. If you want more lowlevel control,33* SDL offers a different API, that gives you visibility into each input34* device, multi-touch interfaces, etc.35*36* Those two APIs are incompatible, and you usually should not use both37* at the same time. But for legacy purposes, this API refers to a "mouse"38* when it actually means the system pointer and not a physical mouse.39*40* The other API is in SDL_input.h41*/4243#ifndef _SDL_mouse_h44#define _SDL_mouse_h4546#include "SDL_stdinc.h"47#include "SDL_error.h"48#include "SDL_video.h"4950#include "begin_code.h"51/* Set up for C function definitions, even when using C++ */52#ifdef __cplusplus53/* *INDENT-OFF* */54extern "C" {55/* *INDENT-ON* */56#endif5758typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */596061/* Function prototypes */6263/**64* \brief Get the window which currently has mouse focus.65*/66extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);6768/**69* \brief Retrieve the current state of the mouse.70*71* The current button state is returned as a button bitmask, which can72* be tested using the SDL_BUTTON(X) macros, and x and y are set to the73* mouse cursor position relative to the focus window for the currently74* selected mouse. You can pass NULL for either x or y.75*/76extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y);7778/**79* \brief Retrieve the relative state of the mouse.80*81* The current button state is returned as a button bitmask, which can82* be tested using the SDL_BUTTON(X) macros, and x and y are set to the83* mouse deltas since the last call to SDL_GetRelativeMouseState().84*/85extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);8687/**88* \brief Moves the mouse to the given position within the window.89*90* \param window The window to move the mouse into, or NULL for the current mouse focus91* \param x The x coordinate within the window92* \param y The y coordinate within the window93*94* \note This function generates a mouse motion event95*/96extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,97int x, int y);9899/**100* \brief Set relative mouse mode.101*102* \param enabled Whether or not to enable relative mode103*104* \return 0 on success, or -1 if relative mode is not supported.105*106* While the mouse is in relative mode, the cursor is hidden, and the107* driver will try to report continuous motion in the current window.108* Only relative motion events will be delivered, the mouse position109* will not change.110*111* \note This function will flush any pending mouse motion.112*113* \sa SDL_GetRelativeMouseMode()114*/115extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled);116117/**118* \brief Query whether relative mouse mode is enabled.119*120* \sa SDL_SetRelativeMouseMode()121*/122extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void);123124/**125* \brief Create a cursor, using the specified bitmap data and126* mask (in MSB format).127*128* The cursor width must be a multiple of 8 bits.129*130* The cursor is created in black and white according to the following:131* <table>132* <tr><td> data </td><td> mask </td><td> resulting pixel on screen </td></tr>133* <tr><td> 0 </td><td> 1 </td><td> White </td></tr>134* <tr><td> 1 </td><td> 1 </td><td> Black </td></tr>135* <tr><td> 0 </td><td> 0 </td><td> Transparent </td></tr>136* <tr><td> 1 </td><td> 0 </td><td> Inverted color if possible, black137* if not. </td></tr>138* </table>139*140* \sa SDL_FreeCursor()141*/142extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,143const Uint8 * mask,144int w, int h, int hot_x,145int hot_y);146147/**148* \brief Create a color cursor.149*150* \sa SDL_FreeCursor()151*/152extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface,153int hot_x,154int hot_y);155156/**157* \brief Set the active cursor.158*/159extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor);160161/**162* \brief Return the active cursor.163*/164extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);165166/**167* \brief Frees a cursor created with SDL_CreateCursor().168*169* \sa SDL_CreateCursor()170*/171extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor);172173/**174* \brief Toggle whether or not the cursor is shown.175*176* \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current177* state.178*179* \return 1 if the cursor is shown, or 0 if the cursor is hidden.180*/181extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);182183/**184* Used as a mask when testing buttons in buttonstate.185* - Button 1: Left mouse button186* - Button 2: Middle mouse button187* - Button 3: Right mouse button188*/189#define SDL_BUTTON(X) (1 << ((X)-1))190#define SDL_BUTTON_LEFT 1191#define SDL_BUTTON_MIDDLE 2192#define SDL_BUTTON_RIGHT 3193#define SDL_BUTTON_X1 4194#define SDL_BUTTON_X2 5195#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT)196#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE)197#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT)198#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1)199#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2)200201202/* Ends C function definitions when using C++ */203#ifdef __cplusplus204/* *INDENT-OFF* */205}206/* *INDENT-ON* */207#endif208#include "close_code.h"209210#endif /* _SDL_mouse_h */211212/* vi: set ts=4 sw=4 expandtab: */213214215