Mercurial > sdl-ios-xcode
comparison src/video/photon/SDL_ph_mouse.c @ 571:8e3ce997621c
Date: Thu, 16 Jan 2003 13:48:31 +0200
From: "Mike Gorchak"
Subject: All QNX patches
whole patches concerning QNX. Almost all code has been rewritten by Julian
and me. Added initial support for hw overlays in QNX and many many others
fixes.
P.S. This patches has been reviewed by Dave Rempel from QSSL and included in
SDL 1.2.5 distribution, which coming on 3rd party CD for newest 6.2.1
version of QNX, which will be available soon.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 20 Jan 2003 01:38:37 +0000 |
parents | bce7171e7a85 |
children | 8bedd6d61642 |
comparison
equal
deleted
inserted
replaced
570:04d6411da49d | 571:8e3ce997621c |
---|---|
33 #include "SDL_mouse.h" | 33 #include "SDL_mouse.h" |
34 #include "SDL_events_c.h" | 34 #include "SDL_events_c.h" |
35 #include "SDL_cursor_c.h" | 35 #include "SDL_cursor_c.h" |
36 #include "SDL_ph_mouse_c.h" | 36 #include "SDL_ph_mouse_c.h" |
37 | 37 |
38 struct WMcursor { | 38 struct WMcursor |
39 { | |
39 PhCursorDef_t *ph_cursor ; | 40 PhCursorDef_t *ph_cursor ; |
40 }; | 41 }; |
41 | |
42 | 42 |
43 void ph_FreeWMCursor(_THIS, WMcursor *cursor) | 43 void ph_FreeWMCursor(_THIS, WMcursor *cursor) |
44 { | 44 { |
45 if (window != NULL) | 45 if (window != NULL) |
46 { | 46 { |
47 SDL_Lock_EventThread(); | 47 SDL_Lock_EventThread(); |
48 | 48 |
49 if (PtSetResource( window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_INHERIT, 0 ) < 0) | 49 if (PtSetResource( window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_INHERIT, 0) < 0) |
50 { | 50 { |
51 /* TODO: output error msg */ | 51 /* TODO: output error msg */ |
52 } | 52 } |
53 | 53 |
54 SDL_Unlock_EventThread(); | 54 SDL_Unlock_EventThread(); |
58 } | 58 } |
59 | 59 |
60 WMcursor *ph_CreateWMCursor(_THIS, | 60 WMcursor *ph_CreateWMCursor(_THIS, |
61 Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) | 61 Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) |
62 { | 62 { |
63 WMcursor* cursor; | 63 WMcursor* cursor; |
64 int clen, i; | 64 int clen, i; |
65 unsigned char bit, databit, maskbit; | 65 unsigned char bit, databit, maskbit; |
66 | 66 |
67 /* Allocate and initialize the cursor memory */ | 67 /* Allocate and initialize the cursor memory */ |
68 if ((cursor = (WMcursor*)malloc(sizeof(WMcursor))) == NULL) | 68 if ((cursor = (WMcursor*)malloc(sizeof(WMcursor))) == NULL) |
69 { | 69 { |
70 SDL_OutOfMemory(); | 70 SDL_OutOfMemory(); |
71 return(NULL); | 71 return(NULL); |
72 } | 72 } |
73 memset(cursor,0,sizeof(WMcursor)); | 73 memset(cursor,0,sizeof(WMcursor)); |
74 | 74 |
75 cursor->ph_cursor = (PhCursorDef_t *) malloc(sizeof(PhCursorDef_t) + 32*4*2); | 75 cursor->ph_cursor = (PhCursorDef_t *) malloc(sizeof(PhCursorDef_t) + 32*4*2); |
76 if(cursor->ph_cursor == NULL) | 76 if (cursor->ph_cursor == NULL) |
77 printf("cursor malloc failed\n"); | 77 printf("cursor malloc failed\n"); |
78 | 78 |
79 memset(cursor->ph_cursor,0,(sizeof(PhCursorDef_t) + 32*4*2)); | 79 memset(cursor->ph_cursor,0,(sizeof(PhCursorDef_t) + 32*4*2)); |
80 | 80 |
81 cursor->ph_cursor->hdr.type =Ph_RDATA_CURSOR; | 81 cursor->ph_cursor->hdr.type =Ph_RDATA_CURSOR; |
82 cursor->ph_cursor->size1.x = (short)w; | 82 cursor->ph_cursor->size1.x = (short)w; |
83 cursor->ph_cursor->size1.y = (short)h; | 83 cursor->ph_cursor->size1.y = (short)h; |
84 cursor->ph_cursor->offset1.x = (short)hot_x; | 84 cursor->ph_cursor->offset1.x = (short)hot_x; |
85 cursor->ph_cursor->offset1.y = (short)hot_y; | 85 cursor->ph_cursor->offset1.y = (short)hot_y; |
86 cursor->ph_cursor->bytesperline1 = (char)w/8; | 86 cursor->ph_cursor->bytesperline1 = (char)w/8; |
87 cursor->ph_cursor->color1 = Pg_WHITE; | 87 cursor->ph_cursor->color1 = Pg_WHITE; |
88 cursor->ph_cursor->size2.x = (short)w; | 88 cursor->ph_cursor->size2.x = (short)w; |
89 cursor->ph_cursor->size2.y = (short)h; | 89 cursor->ph_cursor->size2.y = (short)h; |
90 cursor->ph_cursor->offset2.x = (short)hot_x; | 90 cursor->ph_cursor->offset2.x = (short)hot_x; |
91 cursor->ph_cursor->offset2.y = (short)hot_y; | 91 cursor->ph_cursor->offset2.y = (short)hot_y; |
92 cursor->ph_cursor->bytesperline2 = (char)w/8; | 92 cursor->ph_cursor->bytesperline2 = (char)w/8; |
93 cursor->ph_cursor->color2 = Pg_BLACK; | 93 cursor->ph_cursor->color2 = Pg_BLACK; |
94 | 94 |
95 clen = (w/8)*h; | 95 clen = (w/8)*h; |
96 | 96 |
97 /* Copy the mask and the data to different | 97 /* Copy the mask and the data to different bitmap planes */ |
98 bitmap planes */ | 98 for (i=0; i<clen; ++i) |
99 for ( i=0; i<clen; ++i ) | 99 { |
100 { | 100 for (bit = 0; bit < 8; bit++) |
101 for ( bit = 0; bit < 8; bit++ ) | 101 { |
102 { | 102 databit = data[i] & (1 << bit); |
103 databit = data[i] & (1 << bit); | 103 maskbit = mask[i] & (1 << bit); |
104 maskbit = mask[i] & (1 << bit); | |
105 | 104 |
106 cursor->ph_cursor->images[i] |= | 105 cursor->ph_cursor->images[i] |= (databit == 0) ? maskbit : 0; |
107 (databit == 0) ? maskbit : 0; | 106 /* If the databit != 0, treat it as a black pixel and |
108 /* If the databit != 0, treat it as a black pixel and | 107 * ignore the maskbit (can't do an inverted color) */ |
109 * ignore the maskbit (can't do an inverted color) */ | 108 cursor->ph_cursor->images[i+clen] |= databit; |
110 cursor->ph_cursor->images[i+clen] |= databit; | 109 } |
111 } | 110 } |
112 } | |
113 | 111 |
114 /* #bytes following the hdr struct */ | 112 /* #bytes following the hdr struct */ |
115 cursor->ph_cursor->hdr.len =sizeof(PhCursorDef_t) + clen*2 - sizeof(PhRegionDataHdr_t); | 113 cursor->ph_cursor->hdr.len =sizeof(PhCursorDef_t) + clen*2 - sizeof(PhRegionDataHdr_t); |
116 | 114 |
117 return (cursor); | 115 return (cursor); |
118 } | 116 } |
119 | |
120 | 117 |
121 PhCursorDef_t ph_GetWMPhCursor(WMcursor *cursor) | 118 PhCursorDef_t ph_GetWMPhCursor(WMcursor *cursor) |
122 { | 119 { |
123 return(*cursor->ph_cursor); | 120 return(*cursor->ph_cursor); |
124 } | 121 } |
125 | 122 |
126 int ph_ShowWMCursor(_THIS, WMcursor *cursor) | 123 int ph_ShowWMCursor(_THIS, WMcursor *cursor) |
127 { | 124 { |
128 PtArg_t args[3]; | 125 PtArg_t args[3]; |
129 int nargs = 0; | 126 int nargs = 0; |
130 short cursor_is_defined = 0; | |
131 | 127 |
132 /* Don't do anything if the display is gone */ | 128 /* Don't do anything if the display is gone */ |
133 if ( window == NULL ) { | 129 if (window == NULL) |
134 return(0); | 130 { |
135 } | 131 return (0); |
132 } | |
136 | 133 |
137 /* Set the photon cursor cursor, or blank if cursor is NULL */ | 134 /* looks like photon can't draw mouse cursor in direct mode */ |
138 if ( window ) { | 135 if ((this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) |
139 | 136 { |
140 if ( cursor != NULL ) { | 137 return (0); |
141 PtSetArg( &args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0 ); | 138 } |
142 /* Could set next to any PgColor_t value */ | 139 |
143 PtSetArg( &args[1], Pt_ARG_CURSOR_COLOR,Ph_CURSOR_DEFAULT_COLOR , 0 ); | 140 /* Set the photon cursor cursor, or blank if cursor is NULL */ |
144 PtSetArg( &args[2], Pt_ARG_BITMAP_CURSOR, cursor->ph_cursor, (cursor->ph_cursor->hdr.len + sizeof(PhRegionDataHdr_t)) ); | 141 if (cursor!=NULL) |
145 nargs = 3; | 142 { |
146 cursor_is_defined = 1; | 143 PtSetArg(&args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0); |
147 } | 144 /* Could set next to any PgColor_t value */ |
148 else /* Ph_CURSOR_NONE */ | 145 PtSetArg(&args[1], Pt_ARG_CURSOR_COLOR, Ph_CURSOR_DEFAULT_COLOR , 0); |
149 { | 146 PtSetArg(&args[2], Pt_ARG_BITMAP_CURSOR, cursor->ph_cursor, (cursor->ph_cursor->hdr.len + sizeof(PhRegionDataHdr_t))); |
150 PtSetArg( &args[0], Pt_ARG_CURSOR_TYPE,Ph_CURSOR_NONE, 0); | 147 nargs = 3; |
151 nargs = 1; | 148 } |
152 cursor_is_defined = 1; | 149 else /* Ph_CURSOR_NONE */ |
153 } | 150 { |
154 if (cursor_is_defined) | 151 PtSetArg( &args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, 0); |
155 { | 152 nargs = 1; |
156 SDL_Lock_EventThread(); | 153 } |
157 | 154 |
158 if (PtSetResources( window, nargs, args ) < 0 ) | 155 SDL_Lock_EventThread(); |
159 { | 156 |
160 return(0); | 157 if (PtSetResources(window, nargs, args) < 0 ) |
161 } | 158 { |
162 | 159 return (0); |
163 SDL_Unlock_EventThread(); | 160 } |
164 } | 161 |
165 else | 162 SDL_Unlock_EventThread(); |
166 return(0); | 163 |
167 } | 164 return (1); |
168 return(1); | |
169 } | 165 } |
170 | 166 |
171 void ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y) | 167 void ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y) |
172 { | 168 { |
173 short abs_x, abs_y; | 169 short abs_x, abs_y; |