Mercurial > sdl-ios-xcode
comparison src/video/ps2gs/SDL_gsmouse.c @ 1895:c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 10 Jul 2006 21:04:37 +0000 |
parents | d910939febfa |
children | 99210400e8b9 |
comparison
equal
deleted
inserted
replaced
1894:c69cee13dd76 | 1895:c121d94672cb |
---|---|
29 #include "SDL_gsvideo.h" | 29 #include "SDL_gsvideo.h" |
30 #include "SDL_gsmouse_c.h" | 30 #include "SDL_gsmouse_c.h" |
31 | 31 |
32 | 32 |
33 /* The implementation dependent data for the window manager cursor */ | 33 /* The implementation dependent data for the window manager cursor */ |
34 struct WMcursor { | 34 struct WMcursor |
35 int unused; | 35 { |
36 int unused; | |
36 }; | 37 }; |
37 | 38 |
38 /* There isn't any implementation dependent data */ | 39 /* There isn't any implementation dependent data */ |
39 void GS_FreeWMCursor(_THIS, WMcursor *cursor) | 40 void |
41 GS_FreeWMCursor(_THIS, WMcursor * cursor) | |
40 { | 42 { |
41 return; | 43 return; |
42 } | 44 } |
43 | 45 |
44 /* There isn't any implementation dependent data */ | 46 /* There isn't any implementation dependent data */ |
45 WMcursor *GS_CreateWMCursor(_THIS, | 47 WMcursor * |
46 Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) | 48 GS_CreateWMCursor(_THIS, |
49 Uint8 * data, Uint8 * mask, int w, int h, int hot_x, | |
50 int hot_y) | |
47 { | 51 { |
48 return((WMcursor *)0x01); | 52 return ((WMcursor *) 0x01); |
49 } | 53 } |
50 | 54 |
51 static void GS_MoveCursor(_THIS, SDL_Cursor *cursor, int x, int y) | 55 static void |
56 GS_MoveCursor(_THIS, SDL_Cursor * cursor, int x, int y) | |
52 { | 57 { |
53 SDL_Surface *screen; | 58 SDL_Surface *screen; |
54 struct ps2_image image; | 59 struct ps2_image image; |
55 SDL_Rect area; | 60 SDL_Rect area; |
56 int mouse_y1, mouse_y2; | 61 int mouse_y1, mouse_y2; |
57 void *saved_pixels; | 62 void *saved_pixels; |
58 int screen_updated; | 63 int screen_updated; |
59 | 64 |
60 /* Lock so we don't interrupt an update with mouse motion */ | 65 /* Lock so we don't interrupt an update with mouse motion */ |
61 SDL_LockCursor(); | 66 SDL_LockCursor(); |
62 | 67 |
63 /* Make sure any pending DMA has completed */ | 68 /* Make sure any pending DMA has completed */ |
64 if ( dma_pending ) { | 69 if (dma_pending) { |
65 ioctl(console_fd, PS2IOC_SENDQCT, 1); | 70 ioctl(console_fd, PS2IOC_SENDQCT, 1); |
66 dma_pending = 0; | 71 dma_pending = 0; |
67 } | 72 } |
68 | 73 |
69 /* Remove the cursor image from the DMA area */ | 74 /* Remove the cursor image from the DMA area */ |
70 screen = this->screen; | 75 screen = this->screen; |
71 saved_pixels = screen->pixels; | 76 saved_pixels = screen->pixels; |
72 screen->pixels = mapped_mem + screen->offset; | 77 screen->pixels = mapped_mem + screen->offset; |
73 screen_updated = 0; | 78 screen_updated = 0; |
74 if ( cursor_drawn ) { | 79 if (cursor_drawn) { |
75 SDL_EraseCursorNoLock(screen); | 80 SDL_EraseCursorNoLock(screen); |
76 cursor_drawn = 0; | 81 cursor_drawn = 0; |
77 screen_updated = 1; | 82 screen_updated = 1; |
78 } | 83 } |
79 | 84 |
80 /* Save the current mouse area */ | 85 /* Save the current mouse area */ |
81 SDL_MouseRect(&area); | 86 SDL_MouseRect(&area); |
82 mouse_y1 = area.y; | 87 mouse_y1 = area.y; |
83 mouse_y2 = area.y+area.h; | 88 mouse_y2 = area.y + area.h; |
84 | 89 |
85 /* Only draw the new cursor if there was one passed in */ | 90 /* Only draw the new cursor if there was one passed in */ |
86 if ( cursor ) { | 91 if (cursor) { |
87 /* Set the new location */ | 92 /* Set the new location */ |
88 cursor->area.x = (x - cursor->hot_x); | 93 cursor->area.x = (x - cursor->hot_x); |
89 cursor->area.y = (y - cursor->hot_y); | 94 cursor->area.y = (y - cursor->hot_y); |
90 | 95 |
91 /* Draw the cursor at the new location */ | 96 /* Draw the cursor at the new location */ |
92 if ( (SDL_cursorstate & CURSOR_VISIBLE) && screen->pixels ) { | 97 if ((SDL_cursorstate & CURSOR_VISIBLE) && screen->pixels) { |
93 SDL_DrawCursorNoLock(screen); | 98 SDL_DrawCursorNoLock(screen); |
94 cursor_drawn = 1; | 99 cursor_drawn = 1; |
95 screen_updated = 1; | 100 screen_updated = 1; |
96 } | 101 } |
97 } | 102 } |
98 screen->pixels = saved_pixels; | 103 screen->pixels = saved_pixels; |
99 | 104 |
100 /* Update the affected area of the screen */ | 105 /* Update the affected area of the screen */ |
101 if ( screen_updated ) { | 106 if (screen_updated) { |
102 SDL_MouseRect(&area); | 107 SDL_MouseRect(&area); |
103 if ( area.y < mouse_y1 ) { | 108 if (area.y < mouse_y1) { |
104 mouse_y1 = area.y; | 109 mouse_y1 = area.y; |
105 } | 110 } |
106 if ( (area.y+area.h) > mouse_y2 ) { | 111 if ((area.y + area.h) > mouse_y2) { |
107 mouse_y2 = area.y+area.h; | 112 mouse_y2 = area.y + area.h; |
108 } | 113 } |
109 image = screen_image; | 114 image = screen_image; |
110 image.y += screen->offset / screen->pitch + mouse_y1; | 115 image.y += screen->offset / screen->pitch + mouse_y1; |
111 image.h = mouse_y2 - mouse_y1; | 116 image.h = mouse_y2 - mouse_y1; |
112 image.ptr = mapped_mem + | 117 image.ptr = mapped_mem + (image.y - screen_image.y) * screen->pitch; |
113 (image.y - screen_image.y) * screen->pitch; | 118 ioctl(console_fd, PS2IOC_LOADIMAGE, &image); |
114 ioctl(console_fd, PS2IOC_LOADIMAGE, &image); | |
115 | 119 |
116 /* Need to scale offscreen image to TV output */ | 120 /* Need to scale offscreen image to TV output */ |
117 if ( image.y > 0 ) { | 121 if (image.y > 0) { |
118 scaleimage_nonblock(console_fd, | 122 scaleimage_nonblock(console_fd, tex_tags_mem, scale_tags_mem); |
119 tex_tags_mem, scale_tags_mem); | 123 } |
120 } | 124 } |
121 } | |
122 | 125 |
123 /* We're finished */ | 126 /* We're finished */ |
124 SDL_UnlockCursor(); | 127 SDL_UnlockCursor(); |
125 } | 128 } |
126 | 129 |
127 void GS_MoveWMCursor(_THIS, int x, int y) | 130 void |
131 GS_MoveWMCursor(_THIS, int x, int y) | |
128 { | 132 { |
129 GS_MoveCursor(this, SDL_cursor, x, y); | 133 GS_MoveCursor(this, SDL_cursor, x, y); |
130 } | 134 } |
131 | 135 |
132 int GS_ShowWMCursor(_THIS, WMcursor *wmcursor) | 136 int |
137 GS_ShowWMCursor(_THIS, WMcursor * wmcursor) | |
133 { | 138 { |
134 SDL_Cursor *cursor; | 139 SDL_Cursor *cursor; |
135 int x, y; | 140 int x, y; |
136 | 141 |
137 /* Draw the cursor at the appropriate location */ | 142 /* Draw the cursor at the appropriate location */ |
138 SDL_GetMouseState(&x, &y); | 143 SDL_GetMouseState(&x, &y); |
139 if ( wmcursor ) { | 144 if (wmcursor) { |
140 cursor = SDL_cursor; | 145 cursor = SDL_cursor; |
141 } else { | 146 } else { |
142 cursor = NULL; | 147 cursor = NULL; |
143 } | 148 } |
144 GS_MoveCursor(this, cursor, x, y); | 149 GS_MoveCursor(this, cursor, x, y); |
145 return(1); | 150 return (1); |
146 } | 151 } |
152 | |
153 /* vi: set ts=4 sw=4 expandtab: */ |