| | |
| | | /* |
| | | Simple DirectMedia Layer |
| | | Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> |
| | | Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org> |
| | | |
| | | This software is provided 'as-is', without any express or implied |
| | | warranty. In no event will the authors be held liable for any damages |
| | |
| | | return; |
| | | } |
| | | win = GetSDLWindow(winID); |
| | | |
| | | // Simple relative mode support for mouse. |
| | | if (SDL_GetMouse()->relative_mode) { |
| | | int winWidth, winHeight, winPosX, winPosY; |
| | | SDL_GetWindowSize(win, &winWidth, &winHeight); |
| | | SDL_GetWindowPosition(win, &winPosX, &winPosY); |
| | | int dx = x - (winWidth / 2); |
| | | int dy = y - (winHeight / 2); |
| | | SDL_SendMouseMotion(win, 0, SDL_GetMouse()->relative_mode, dx, dy); |
| | | set_mouse_position((winPosX + winWidth / 2), (winPosY + winHeight / 2)); |
| | | if (!be_app->IsCursorHidden()) |
| | | be_app->HideCursor(); |
| | | } else { |
| | | SDL_SendMouseMotion(win, 0, 0, x, y); |
| | | if (SDL_ShowCursor(-1) && be_app->IsCursorHidden()) |
| | | be_app->ShowCursor(); |
| | | } |
| | | |
| | | /* Tell the application that the mouse passed over, redraw needed */ |
| | | HAIKU_UpdateWindowFramebuffer(NULL,win,NULL,-1); |
| | |
| | | return; |
| | | } |
| | | win = GetSDLWindow(winID); |
| | | SDL_SendMouseWheel(win, 0, xTicks, yTicks, SDL_MOUSEWHEEL_NORMAL); |
| | | SDL_SendMouseWheel(win, 0, xTicks, -yTicks, SDL_MOUSEWHEEL_NORMAL); |
| | | } |
| | | |
| | | void _HandleKey(BMessage *msg) { |
| | |
| | | ssize_t count; |
| | | if (msg->FindData("key-utf8", B_INT8_TYPE, (const void**)&keyUtf8, &count) == B_OK) { |
| | | char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; |
| | | SDL_zero(text); |
| | | SDL_zeroa(text); |
| | | SDL_memcpy(text, keyUtf8, count); |
| | | SDL_SendKeyboardText(text); |
| | | } |