comparison src/video/ps2gs/SDL_gsmouse.c @ 1668:4da1ee79c9af SDL-1.3

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