Mercurial > sdl-ios-xcode
comparison src/events/SDL_mouse.c @ 1724:6c63fc2bd986 SDL-1.3
Proof of concept done - Win32 GDI implementation mostly complete.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 06 Jul 2006 07:17:11 +0000 |
parents | 5daa04d862f1 |
children | 875c3cf1a12c |
comparison
equal
deleted
inserted
replaced
1723:4bdbb9b2bd0a | 1724:6c63fc2bd986 |
---|---|
263 mouse->xdelta = 0; | 263 mouse->xdelta = 0; |
264 mouse->ydelta = 0; | 264 mouse->ydelta = 0; |
265 return mouse->buttonstate; | 265 return mouse->buttonstate; |
266 } | 266 } |
267 | 267 |
268 int | 268 void |
269 SDL_SendMouseMotion(int index, SDL_WindowID windowID, int relative, int x, | 269 SDL_SetMouseFocus(int index, SDL_WindowID windowID) |
270 int y) | 270 { |
271 SDL_Mouse *mouse = SDL_GetMouse(index); | |
272 int i; | |
273 SDL_bool focus; | |
274 | |
275 if (!mouse || (mouse->focus == windowID)) { | |
276 return; | |
277 } | |
278 | |
279 /* See if the current window has lost focus */ | |
280 if (mouse->focus) { | |
281 focus = SDL_FALSE; | |
282 for (i = 0; i < SDL_num_mice; ++i) { | |
283 SDL_Mouse *check; | |
284 if (i != index) { | |
285 check = SDL_GetMouse(i); | |
286 if (check && check->focus == mouse->focus) { | |
287 focus = SDL_TRUE; | |
288 break; | |
289 } | |
290 } | |
291 } | |
292 if (!focus) { | |
293 SDL_SendWindowEvent(windowID, SDL_WINDOWEVENT_LEAVE, 0, 0); | |
294 } | |
295 } | |
296 | |
297 mouse->focus = windowID; | |
298 | |
299 if (mouse->focus) { | |
300 focus = SDL_FALSE; | |
301 for (i = 0; i < SDL_num_mice; ++i) { | |
302 SDL_Mouse *check; | |
303 if (i != index) { | |
304 check = SDL_GetMouse(i); | |
305 if (check && check->focus == mouse->focus) { | |
306 focus = SDL_TRUE; | |
307 break; | |
308 } | |
309 } | |
310 } | |
311 if (!focus) { | |
312 SDL_SendWindowEvent(windowID, SDL_WINDOWEVENT_ENTER, 0, 0); | |
313 } | |
314 } | |
315 } | |
316 | |
317 int | |
318 SDL_SendMouseMotion(int index, int relative, int x, int y) | |
271 { | 319 { |
272 SDL_Mouse *mouse = SDL_GetMouse(index); | 320 SDL_Mouse *mouse = SDL_GetMouse(index); |
273 int posted; | 321 int posted; |
274 int xrel; | 322 int xrel; |
275 int yrel; | 323 int yrel; |
276 | 324 |
277 if (!mouse || mouse->flush_motion) { | 325 if (!mouse || mouse->flush_motion) { |
278 return 0; | 326 return 0; |
279 } | |
280 | |
281 if (windowID) { | |
282 mouse->focus = windowID; | |
283 } | 327 } |
284 | 328 |
285 if (relative) { | 329 if (relative) { |
286 /* Push the cursor around */ | 330 /* Push the cursor around */ |
287 xrel = x; | 331 xrel = x; |
335 } | 379 } |
336 return posted; | 380 return posted; |
337 } | 381 } |
338 | 382 |
339 int | 383 int |
340 SDL_SendMouseButton(int index, SDL_WindowID windowID, Uint8 state, | 384 SDL_SendMouseButton(int index, Uint8 state, Uint8 button) |
341 Uint8 button) | |
342 { | 385 { |
343 SDL_Mouse *mouse = SDL_GetMouse(index); | 386 SDL_Mouse *mouse = SDL_GetMouse(index); |
344 int posted; | 387 int posted; |
345 Uint8 type; | 388 Uint8 type; |
346 | 389 |
347 if (!mouse) { | 390 if (!mouse) { |
348 return 0; | 391 return 0; |
349 } | |
350 | |
351 if (windowID) { | |
352 mouse->focus = windowID; | |
353 } | 392 } |
354 | 393 |
355 /* Figure out which event to perform */ | 394 /* Figure out which event to perform */ |
356 switch (state) { | 395 switch (state) { |
357 case SDL_PRESSED: | 396 case SDL_PRESSED: |
393 } | 432 } |
394 } | 433 } |
395 return posted; | 434 return posted; |
396 } | 435 } |
397 | 436 |
437 int | |
438 SDL_SendMouseWheel(int index, int motion) | |
439 { | |
440 SDL_Mouse *mouse = SDL_GetMouse(index); | |
441 int posted; | |
442 | |
443 if (!mouse || !motion) { | |
444 return 0; | |
445 } | |
446 | |
447 /* Post the event, if desired */ | |
448 posted = 0; | |
449 if (SDL_ProcessEvents[SDL_MOUSEWHEEL] == SDL_ENABLE) { | |
450 SDL_Event event; | |
451 event.type = SDL_MOUSEWHEEL; | |
452 event.wheel.which = (Uint8) index; | |
453 event.wheel.motion = motion; | |
454 event.wheel.windowID = mouse->focus; | |
455 if ((SDL_EventOK == NULL) | |
456 || (*SDL_EventOK) (SDL_EventOKParam, &event)) { | |
457 posted = 1; | |
458 SDL_PushEvent(&event); | |
459 } | |
460 } | |
461 return posted; | |
462 } | |
463 | |
398 void | 464 void |
399 SDL_WarpMouseInWindow(SDL_WindowID windowID, int x, int y) | 465 SDL_WarpMouseInWindow(SDL_WindowID windowID, int x, int y) |
400 { | 466 { |
401 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); | 467 SDL_Mouse *mouse = SDL_GetMouse(SDL_current_mouse); |
402 | 468 |
405 } | 471 } |
406 | 472 |
407 if (mouse->WarpMouse) { | 473 if (mouse->WarpMouse) { |
408 mouse->WarpMouse(mouse, windowID, x, y); | 474 mouse->WarpMouse(mouse, windowID, x, y); |
409 } else { | 475 } else { |
410 SDL_SendMouseMotion(SDL_current_mouse, windowID, 0, x, y); | 476 SDL_SetMouseFocus(SDL_current_mouse, windowID); |
477 SDL_SendMouseMotion(SDL_current_mouse, 0, x, y); | |
411 } | 478 } |
412 } | 479 } |
413 | 480 |
414 SDL_Cursor * | 481 SDL_Cursor * |
415 SDL_CreateCursor(const Uint8 * data, const Uint8 * mask, | 482 SDL_CreateCursor(const Uint8 * data, const Uint8 * mask, |