2 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2009 Sam Lantinga
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "SDL_config.h"
24 #include <sys/ioctl.h>
26 #include "SDL_mouse.h"
27 #include "../../events/SDL_events_c.h"
28 #include "../SDL_cursor_c.h"
29 #include "SDL_gsvideo.h"
30 #include "SDL_gsmouse_c.h"
33 /* The implementation dependent data for the window manager cursor */
38 /* There isn't any implementation dependent data */
39 void GS_FreeWMCursor(_THIS, WMcursor *cursor)
44 /* There isn't any implementation dependent data */
45 WMcursor *GS_CreateWMCursor(_THIS,
46 Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
48 return((WMcursor *)0x01);
51 static void GS_MoveCursor(_THIS, SDL_Cursor *cursor, int x, int y)
54 struct ps2_image image;
56 int mouse_y1, mouse_y2;
60 /* Lock so we don't interrupt an update with mouse motion */
63 /* Make sure any pending DMA has completed */
65 ioctl(console_fd, PS2IOC_SENDQCT, 1);
69 /* Remove the cursor image from the DMA area */
70 screen = this->screen;
71 saved_pixels = screen->pixels;
72 screen->pixels = mapped_mem + screen->offset;
75 SDL_EraseCursorNoLock(screen);
80 /* Save the current mouse area */
83 mouse_y2 = area.y+area.h;
85 /* Only draw the new cursor if there was one passed in */
87 /* Set the new location */
88 cursor->area.x = (x - cursor->hot_x);
89 cursor->area.y = (y - cursor->hot_y);
91 /* Draw the cursor at the new location */
92 if ( (SDL_cursorstate & CURSOR_VISIBLE) && screen->pixels ) {
93 SDL_DrawCursorNoLock(screen);
98 screen->pixels = saved_pixels;
100 /* Update the affected area of the screen */
101 if ( screen_updated ) {
102 SDL_MouseRect(&area);
103 if ( area.y < mouse_y1 ) {
106 if ( (area.y+area.h) > mouse_y2 ) {
107 mouse_y2 = area.y+area.h;
109 image = screen_image;
110 image.y += screen->offset / screen->pitch + mouse_y1;
111 image.h = mouse_y2 - mouse_y1;
112 image.ptr = mapped_mem +
113 (image.y - screen_image.y) * screen->pitch;
114 ioctl(console_fd, PS2IOC_LOADIMAGE, &image);
116 /* Need to scale offscreen image to TV output */
118 scaleimage_nonblock(console_fd,
119 tex_tags_mem, scale_tags_mem);
127 void GS_MoveWMCursor(_THIS, int x, int y)
129 GS_MoveCursor(this, SDL_cursor, x, y);
132 int GS_ShowWMCursor(_THIS, WMcursor *wmcursor)
137 /* Draw the cursor at the appropriate location */
138 SDL_GetMouseState(&x, &y);
144 GS_MoveCursor(this, cursor, x, y);