本文整理汇总了C++中SDL_GetMouse函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_GetMouse函数的具体用法?C++ SDL_GetMouse怎么用?C++ SDL_GetMouse使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_GetMouse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WIN_InitMouse
void
WIN_InitMouse(_THIS)
{
SDL_Mouse *mouse = SDL_GetMouse();
mouse->CreateCursor = WIN_CreateCursor;
mouse->CreateSystemCursor = WIN_CreateSystemCursor;
mouse->ShowCursor = WIN_ShowCursor;
mouse->FreeCursor = WIN_FreeCursor;
mouse->WarpMouse = WIN_WarpMouse;
mouse->SetRelativeMouseMode = WIN_SetRelativeMouseMode;
SDL_SetDefaultCursor(WIN_CreateDefaultCursor());
}
示例2: MIR_InitMouse
/* TODO Actually implement the cursor, need to wait for mir support */
void
MIR_InitMouse()
{
SDL_Mouse* mouse = SDL_GetMouse();
mouse->CreateCursor = MIR_CreateCursor;
mouse->ShowCursor = MIR_ShowCursor;
mouse->FreeCursor = MIR_FreeCursor;
mouse->WarpMouse = MIR_WarpMouse;
mouse->CreateSystemCursor = MIR_CreateSystemCursor;
mouse->SetRelativeMouseMode = MIR_SetRelativeMouseMode;
SDL_SetDefaultCursor(MIR_CreateDefaultCursor());
}
示例3: MIR_FiniMouse
void
MIR_FiniMouse()
{
SDL_Mouse* mouse = SDL_GetMouse();
MIR_FreeCursor(mouse->def_cursor);
mouse->def_cursor = NULL;
mouse->CreateCursor = NULL;
mouse->ShowCursor = NULL;
mouse->FreeCursor = NULL;
mouse->WarpMouse = NULL;
mouse->CreateSystemCursor = NULL;
mouse->SetRelativeMouseMode = NULL;
}
示例4: SDL_GetRelativeMouseState
Uint32
SDL_GetRelativeMouseState(int *x, int *y)
{
SDL_Mouse *mouse = SDL_GetMouse();
if (x) {
*x = mouse->xdelta;
}
if (y) {
*y = mouse->ydelta;
}
mouse->xdelta = 0;
mouse->ydelta = 0;
return mouse->buttonstate;
}
示例5: MotionAllMice
static void
MotionAllMice(_THIS, int x, int y)
{
#if USE_MULTI_API
SDL_DFB_DEVICEDATA(_this);
int index;
for (index = 0; index < devdata->num_mice; index++) {
SDL_Mouse *mouse = SDL_GetMouse(index);
mouse->x = mouse->last_x = x;
mouse->y = mouse->last_y = y;
//SDL_SendMouseMotion(devdata->mouse_id[index], 0, x, y, 0);
}
#endif
}
示例6: SDL_SendMouseButton
int
SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button)
{
SDL_Mouse *mouse = SDL_GetMouse();
int posted;
Uint32 type;
if (window) {
SDL_SetMouseFocus(window);
}
/* Figure out which event to perform */
switch (state) {
case SDL_PRESSED:
if (mouse->buttonstate & SDL_BUTTON(button)) {
/* Ignore this event, no state change */
return 0;
}
type = SDL_MOUSEBUTTONDOWN;
mouse->buttonstate |= SDL_BUTTON(button);
break;
case SDL_RELEASED:
if (!(mouse->buttonstate & SDL_BUTTON(button))) {
/* Ignore this event, no state change */
return 0;
}
type = SDL_MOUSEBUTTONUP;
mouse->buttonstate &= ~SDL_BUTTON(button);
break;
default:
/* Invalid state -- bail */
return 0;
}
/* Post the event, if desired */
posted = 0;
if (SDL_GetEventState(type) == SDL_ENABLE) {
SDL_Event event;
event.type = type;
event.button.state = state;
event.button.button = button;
event.button.x = mouse->x;
event.button.y = mouse->y;
event.button.windowID = mouse->focus ? mouse->focus->id : 0;
posted = (SDL_PushEvent(&event) > 0);
}
return posted;
}
示例7: SDL_SetRelativeMouseMode
int
SDL_SetRelativeMouseMode(SDL_bool enabled)
{
SDL_Mouse *mouse = SDL_GetMouse();
SDL_Window *focusWindow = SDL_GetKeyboardFocus();
if (enabled == mouse->relative_mode) {
return 0;
}
if (enabled && focusWindow) {
/* Center it in the focused window to prevent clicks from going through
* to background windows.
*/
SDL_SetMouseFocus(focusWindow);
SDL_WarpMouseInWindow(focusWindow, focusWindow->w/2, focusWindow->h/2);
}
/* Set the relative mode */
if (!enabled && mouse->relative_mode_warp) {
mouse->relative_mode_warp = SDL_FALSE;
} else if (enabled && ShouldUseRelativeModeWarp(mouse)) {
mouse->relative_mode_warp = SDL_TRUE;
} else if (mouse->SetRelativeMouseMode(enabled) < 0) {
if (enabled) {
/* Fall back to warp mode if native relative mode failed */
mouse->relative_mode_warp = SDL_TRUE;
}
}
mouse->relative_mode = enabled;
if (mouse->focus) {
SDL_UpdateWindowGrab(mouse->focus);
/* Put the cursor back to where the application expects it */
if (!enabled) {
SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y);
}
}
/* Flush pending mouse motion - ideally we would pump events, but that's not always safe */
SDL_FlushEvent(SDL_MOUSEMOTION);
/* Update cursor visibility */
SDL_SetCursor(NULL);
return 0;
}
示例8: SDL_WarpMouseInWindow
void
SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
{
SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse);
if (!mouse) {
return;
}
if (mouse->WarpMouse) {
mouse->WarpMouse(mouse, window, x, y);
} else {
SDL_SetMouseFocus(SDL_current_mouse, window);
SDL_SendMouseMotion(SDL_current_mouse, 0, x, y, 0);
}
}
示例9: SDL_ResetMouse
void
SDL_ResetMouse(void)
{
SDL_Mouse *mouse = SDL_GetMouse();
Uint8 i;
#ifdef DEBUG_MOUSE
printf("Resetting mouse\n");
#endif
for (i = 1; i <= sizeof(mouse->buttonstate)*8; ++i) {
if (mouse->buttonstate & SDL_BUTTON(i)) {
SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, i);
}
}
SDL_assert(mouse->buttonstate == 0);
}
示例10: SDL_WarpMouseInWindow
void
SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
{
SDL_Mouse *mouse = SDL_GetMouse();
if (mouse->WarpMouse) {
mouse->WarpMouse(window, x, y);
// Urho3D: update the internal position
mouse->x = x;
mouse->y = y;
mouse->last_x = x;
mouse->last_y = y;
} else {
SDL_SendMouseMotion(window, 0, x, y);
}
}
示例11: DirectFB_InitMouse
void
DirectFB_InitMouse(_THIS)
{
SDL_DFB_DEVICEDATA(_this);
SDL_Mouse *mouse = SDL_GetMouse();
mouse->CreateCursor = DirectFB_CreateCursor;
mouse->ShowCursor = DirectFB_ShowCursor;
mouse->WarpMouse = DirectFB_WarpMouse;
mouse->FreeCursor = DirectFB_FreeCursor;
SDL_SetDefaultCursor(DirectFB_CreateDefaultCursor());
devdata->num_mice = 1;
}
示例12: SDL_SetRelativeMouseMode
int
SDL_SetRelativeMouseMode(SDL_bool enabled)
{
SDL_Mouse *mouse = SDL_GetMouse();
SDL_Window *focusWindow = SDL_GetKeyboardFocus();
int original_x = mouse->x, original_y = mouse->y;
if (enabled == mouse->relative_mode) {
return 0;
}
if (!mouse->SetRelativeMouseMode) {
return SDL_Unsupported();
}
if (enabled && focusWindow) {
/* Center it in the focused window to prevent clicks from going through
* to background windows.
*/
SDL_SetMouseFocus(focusWindow);
SDL_WarpMouseInWindow(focusWindow, focusWindow->w/2, focusWindow->h/2);
}
if (mouse->SetRelativeMouseMode(enabled) < 0) {
return -1;
}
/* Set the relative mode */
mouse->relative_mode = enabled;
if (enabled) {
/* Save the expected mouse position */
mouse->original_x = original_x;
mouse->original_y = original_y;
} else if (mouse->focus) {
/* Restore the expected mouse position */
SDL_WarpMouseInWindow(mouse->focus, mouse->original_x, mouse->original_y);
}
/* Flush pending mouse motion */
SDL_FlushEvent(SDL_MOUSEMOTION);
/* Update cursor visibility */
SDL_SetCursor(NULL);
return 0;
}
示例13: X11_InitMouse
void
X11_InitMouse(_THIS)
{
SDL_Mouse *mouse = SDL_GetMouse();
mouse->CreateCursor = X11_CreateCursor;
mouse->CreateSystemCursor = X11_CreateSystemCursor;
mouse->ShowCursor = X11_ShowCursor;
mouse->FreeCursor = X11_FreeCursor;
mouse->WarpMouse = X11_WarpMouse;
mouse->WarpMouseGlobal = X11_WarpMouseGlobal;
mouse->SetRelativeMouseMode = X11_SetRelativeMouseMode;
mouse->CaptureMouse = X11_CaptureMouse;
mouse->GetGlobalMouseState = X11_GetGlobalMouseState;
SDL_SetDefaultCursor(X11_CreateDefaultCursor());
}
示例14: RPI_InitMouse
void
RPI_InitMouse(_THIS)
{
/* FIXME: Using UDEV it should be possible to scan all mice
* but there's no point in doing so as there's no multimice support...yet!
*/
SDL_Mouse *mouse = SDL_GetMouse();
mouse->CreateCursor = RPI_CreateCursor;
mouse->ShowCursor = RPI_ShowCursor;
mouse->MoveCursor = RPI_MoveCursor;
mouse->FreeCursor = RPI_FreeCursor;
mouse->WarpMouse = RPI_WarpMouse;
mouse->WarpMouseGlobal = RPI_WarpMouseGlobal;
SDL_SetDefaultCursor(RPI_CreateDefaultCursor());
}
示例15: SDL_WarpMouseInWindow
void
SDL_WarpMouseInWindow(SDL_Window * window, int x, int y)
{
SDL_Mouse *mouse = SDL_GetMouse();
if ( window == NULL )
window = mouse->focus;
if ( window == NULL )
return;
if (mouse->WarpMouse) {
mouse->WarpMouse(window, x, y);
} else {
SDL_SendMouseMotion(window, mouse->mouseID, 0, x, y);
}
}