7 #define WIN32_LEAN_AND_MEAN
9 #undef WIN32_LEAN_AND_MEAN
13 #include <Ecore_Input.h>
15 #include "Ecore_WinCE.h"
16 #include "ecore_wince_private.h"
18 /*============================================================================*
20 *============================================================================*/
26 static Ecore_WinCE_Window *_ecore_wince_mouse_down_last_window = NULL;
27 static Ecore_WinCE_Window *_ecore_wince_mouse_down_last_last_window = NULL;
28 static long _ecore_wince_mouse_down_last_time = 0;
29 static long _ecore_wince_mouse_down_last_last_time = 0;
30 static int _ecore_wince_mouse_down_did_triple = 0;
31 static int _ecore_wince_mouse_up_count = 0;
34 _ecore_wince_event_free_key_down(void *data __UNUSED__,
40 if (e->keyname) free((char *)e->keyname);
41 if (e->key) free((char *)e->key);
42 if (e->string) free((char *)e->string);
47 _ecore_wince_event_free_key_up(void *data __UNUSED__,
53 if (e->keyname) free((char *)e->keyname);
54 if (e->key) free((char *)e->key);
55 if (e->string) free((char *)e->string);
60 _ecore_wince_event_keystroke_get(int key,
223 * VK_F20 indicates that an arrow key came from a rocker.
224 * This can safely be ignored.
229 * VK_F21 indicates that an arrow key came from a directional
230 * pad. This can safely be ignored.
240 * Sent with VK_RETURN when doing an action (usually the middle
241 * button on a directional pad. This can safely be ignored.
260 /* other non keystroke characters */
263 *keyname = strdup(kn);
264 if (!*keyname) return 0;
265 *keysymbol = strdup(ks);
272 *keycompose = strdup(kc);
286 _ecore_wince_event_char_get(int key,
303 strncpy(kn, "BackSpace", 32);
304 strncpy(ks, "BackSpace", 32);
305 strncpy(kc, "BackSpace", 32);
309 strncpy(kn, "Tab", 32);
310 strncpy(ks, "Tab", 32);
311 strncpy(kc, "Tab", 32);
315 /* Line feed (Shift + Enter) */
316 strncpy(kn, "LineFeed", 32);
317 strncpy(ks, "LineFeed", 32);
318 strncpy(kc, "LineFeed", 32);
322 strncpy(kn, "Return", 32);
323 strncpy(ks, "Return", 32);
324 strncpy(kc, "Return", 32);
328 strncpy(kn, "Escape", 32);
329 strncpy(ks, "Escape", 32);
330 strncpy(kc, "Escape", 32);
333 /* displayable characters */
334 printf (" * key : %d\n", key);
343 *keyname = strdup(kn);
344 if (!*keyname) return 0;
345 *keysymbol = strdup(ks);
352 *keycompose = strdup(kc);
370 /*============================================================================*
372 *============================================================================*/
375 _ecore_wince_event_handle_key_press(Ecore_WinCE_Callback_Data *msg,
382 e = (Ecore_Event_Key *)malloc(sizeof(Ecore_Event_Key));
387 if (!_ecore_wince_event_keystroke_get(LOWORD(msg->window_param),
388 (char **)&e->keyname,
390 (char **)&e->string))
398 if (!_ecore_wince_event_char_get(LOWORD(msg->window_param),
399 (char **)&e->keyname,
401 (char **)&e->string))
408 e->window = (Ecore_Window)GetWindowLong(msg->window, GWL_USERDATA);
414 e->timestamp = msg->time;
416 _ecore_wince_event_last_time = e->timestamp;
418 ecore_event_add(ECORE_EVENT_KEY_DOWN, e, _ecore_wince_event_free_key_down, NULL);
422 _ecore_wince_event_handle_key_release(Ecore_WinCE_Callback_Data *msg,
429 e = (Ecore_Event_Key *)calloc(1, sizeof(Ecore_Event_Key));
434 if (!_ecore_wince_event_keystroke_get(LOWORD(msg->window_param),
435 (char **)&e->keyname,
437 (char **)&e->string))
445 if (!_ecore_wince_event_char_get(LOWORD(msg->window_param),
446 (char **)&e->keyname,
448 (char **)&e->string))
455 e->window = (Ecore_Window)GetWindowLong(msg->window, GWL_USERDATA);
461 e->timestamp = msg->time;
463 _ecore_wince_event_last_time = e->timestamp;
465 ecore_event_add(ECORE_EVENT_KEY_UP, e, _ecore_wince_event_free_key_up, NULL);
469 _ecore_wince_event_handle_button_press(Ecore_WinCE_Callback_Data *msg,
472 Ecore_WinCE_Window *window;
474 INF("mouse button pressed");
476 window = (Ecore_WinCE_Window *)GetWindowLong(msg->window, GWL_USERDATA);
479 Ecore_Event_Mouse_Move *e;
481 e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move));
484 e->window = (Ecore_Window)window;
485 e->x = LOWORD(msg->data_param);
486 e->y = HIWORD(msg->data_param);
487 e->timestamp = msg->time;
489 _ecore_wince_event_last_time = e->timestamp;
490 _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window;
492 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL);
496 Ecore_Event_Mouse_Button *e;
498 if (_ecore_wince_mouse_down_did_triple)
500 _ecore_wince_mouse_down_last_window = NULL;
501 _ecore_wince_mouse_down_last_last_window = NULL;
502 _ecore_wince_mouse_down_last_time = 0;
503 _ecore_wince_mouse_down_last_last_time = 0;
506 e = (Ecore_Event_Mouse_Button *)calloc(1, sizeof(Ecore_Event_Mouse_Button));
509 e->window = (Ecore_Window)window;
511 e->x = LOWORD(msg->data_param);
512 e->y = HIWORD(msg->data_param);
513 e->timestamp = msg->time;
515 if (((e->timestamp - _ecore_wince_mouse_down_last_time) <= (long)(1000 * _ecore_wince_double_click_time)) &&
516 (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window))
519 if (((e->timestamp - _ecore_wince_mouse_down_last_last_time) <= (long)(2 * 1000 * _ecore_wince_double_click_time)) &&
520 (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window) &&
521 (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_last_window))
524 _ecore_wince_mouse_down_did_triple = 1;
527 _ecore_wince_mouse_down_did_triple = 0;
529 if (!e->double_click && !e->triple_click)
530 _ecore_wince_mouse_up_count = 0;
532 _ecore_wince_event_last_time = e->timestamp;
533 _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window;
535 if (!_ecore_wince_mouse_down_did_triple)
537 _ecore_wince_mouse_down_last_last_window = _ecore_wince_mouse_down_last_window;
538 _ecore_wince_mouse_down_last_window = (Ecore_WinCE_Window *)e->window;
539 _ecore_wince_mouse_down_last_last_time = _ecore_wince_mouse_down_last_time;
540 _ecore_wince_mouse_down_last_time = e->timestamp;
543 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL);
548 _ecore_wince_event_handle_button_release(Ecore_WinCE_Callback_Data *msg,
551 Ecore_WinCE_Window *window;
553 INF("mouse button released");
555 window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
558 Ecore_Event_Mouse_Move *e;
560 e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move));
563 e->window = (Ecore_Window)window;
564 e->x = LOWORD(msg->data_param);
565 e->y = HIWORD(msg->data_param);
566 e->timestamp = msg->time;
568 _ecore_wince_event_last_time = e->timestamp;
569 _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window;
571 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL);
575 Ecore_Event_Mouse_Button *e;
577 e = (Ecore_Event_Mouse_Button *)calloc(1, sizeof(Ecore_Event_Mouse_Button));
580 e->window = (Ecore_Window)window;
582 e->x = LOWORD(msg->data_param);
583 e->y = HIWORD(msg->data_param);
584 e->timestamp = msg->time;
586 _ecore_wince_mouse_up_count++;
588 if ((_ecore_wince_mouse_up_count >= 2) &&
589 ((e->timestamp - _ecore_wince_mouse_down_last_time) <= (long)(1000 * _ecore_wince_double_click_time)) &&
590 (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window))
593 if ((_ecore_wince_mouse_up_count >= 3) &&
594 ((e->timestamp - _ecore_wince_mouse_down_last_last_time) <= (long)(2 * 1000 * _ecore_wince_double_click_time)) &&
595 (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window) &&
596 (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_last_window))
599 _ecore_wince_event_last_time = e->timestamp;
600 _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window;
602 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL);
607 _ecore_wince_event_handle_motion_notify(Ecore_WinCE_Callback_Data *msg)
609 Ecore_Event_Mouse_Move *e;
613 e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move));
616 e->window = (Ecore_Window)GetWindowLong(msg->window, GWL_USERDATA);
617 e->x = LOWORD(msg->data_param);
618 e->y = HIWORD(msg->data_param);
619 e->timestamp = msg->time;
621 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL);
625 _ecore_wince_event_handle_enter_notify(Ecore_WinCE_Callback_Data *msg)
627 Ecore_WinCE_Window *window;
631 window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
634 Ecore_Event_Mouse_Move *e;
636 e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move));
639 e->window = (Ecore_Window)window;
642 e->timestamp = msg->time;
644 _ecore_wince_event_last_time = e->timestamp;
645 _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window;
647 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL);
651 Ecore_WinCE_Event_Mouse_In *e;
653 e = (Ecore_WinCE_Event_Mouse_In *)calloc(1, sizeof(Ecore_WinCE_Event_Mouse_In));
661 _ecore_wince_event_last_time = e->time;
663 ecore_event_add(ECORE_WINCE_EVENT_MOUSE_IN, e, NULL, NULL);
668 _ecore_wince_event_handle_leave_notify(Ecore_WinCE_Callback_Data *msg)
670 Ecore_WinCE_Window *window;
674 window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
677 Ecore_Event_Mouse_Move *e;
679 e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move));
682 e->window = (Ecore_Window)window;
685 e->timestamp = msg->time;
687 _ecore_wince_event_last_time = e->timestamp;
688 _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window;
690 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL);
694 Ecore_WinCE_Event_Mouse_Out *e;
696 e = (Ecore_WinCE_Event_Mouse_Out *)calloc(1, sizeof(Ecore_WinCE_Event_Mouse_Out));
704 _ecore_wince_event_last_time = e->time;
706 ecore_event_add(ECORE_WINCE_EVENT_MOUSE_OUT, e, NULL, NULL);
711 _ecore_wince_event_handle_focus_in(Ecore_WinCE_Callback_Data *msg)
713 Ecore_WinCE_Event_Window_Focus_In *e;
714 struct _Ecore_WinCE_Window *window;
718 e = (Ecore_WinCE_Event_Window_Focus_In *)calloc(1, sizeof(Ecore_WinCE_Event_Window_Focus_In));
721 window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
729 window->resume(window->backend);
733 e->time = _ecore_wince_event_last_time;
734 _ecore_wince_event_last_time = e->time;
736 ecore_event_add(ECORE_WINCE_EVENT_WINDOW_FOCUS_IN, e, NULL, NULL);
740 _ecore_wince_event_handle_focus_out(Ecore_WinCE_Callback_Data *msg)
742 Ecore_WinCE_Event_Window_Focus_Out *e;
743 struct _Ecore_WinCE_Window *window;
747 e = (Ecore_WinCE_Event_Window_Focus_Out *)calloc(1, sizeof(Ecore_WinCE_Event_Window_Focus_Out));
750 window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
757 window->suspend(window->backend);
761 e->time = _ecore_wince_event_last_time;
762 _ecore_wince_event_last_time = e->time;
764 ecore_event_add(ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT, e, NULL, NULL);
768 _ecore_wince_event_handle_expose(Ecore_WinCE_Callback_Data *msg)
770 Ecore_WinCE_Event_Window_Damage *e;
772 INF("window expose");
774 e = (Ecore_WinCE_Event_Window_Damage *)calloc(1, sizeof(Ecore_WinCE_Event_Window_Damage));
777 e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
784 e->x = msg->update.left;
785 e->y = msg->update.top;
786 e->width = msg->update.right - msg->update.left;
787 e->height = msg->update.bottom - msg->update.top;
788 INF("window expose size: %dx%d", e->width, e->height);
790 e->time = _ecore_wince_event_last_time;
792 ecore_event_add(ECORE_WINCE_EVENT_WINDOW_DAMAGE, e, NULL, NULL);
796 _ecore_wince_event_handle_create_notify(Ecore_WinCE_Callback_Data *msg)
798 Ecore_WinCE_Event_Window_Create *e;
800 INF("window create notify");
802 e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Create));
805 e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
812 e->time = _ecore_wince_event_last_time;
814 ecore_event_add(ECORE_WINCE_EVENT_WINDOW_CREATE, e, NULL, NULL);
818 _ecore_wince_event_handle_destroy_notify(Ecore_WinCE_Callback_Data *msg)
820 Ecore_WinCE_Event_Window_Destroy *e;
822 INF("window destroy notify");
824 e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Destroy));
827 e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
834 e->time = _ecore_wince_event_last_time;
835 /* if (e->window == _ecore_wince_event_last_window) _ecore_wince_event_last_window = NULL; */
837 ecore_event_add(ECORE_WINCE_EVENT_WINDOW_DESTROY, e, NULL, NULL);
841 _ecore_wince_event_handle_map_notify(Ecore_WinCE_Callback_Data *msg)
843 Ecore_WinCE_Event_Window_Show *e;
845 INF("window map notify");
847 e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Show));
850 e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
857 e->time = _ecore_wince_event_last_time;
859 ecore_event_add(ECORE_WINCE_EVENT_WINDOW_SHOW, e, NULL, NULL);
863 _ecore_wince_event_handle_unmap_notify(Ecore_WinCE_Callback_Data *msg)
865 Ecore_WinCE_Event_Window_Hide *e;
867 INF("window unmap notify");
869 e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Hide));
872 e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
879 e->time = _ecore_wince_event_last_time;
881 ecore_event_add(ECORE_WINCE_EVENT_WINDOW_HIDE, e, NULL, NULL);
885 _ecore_wince_event_handle_delete_request(Ecore_WinCE_Callback_Data *msg)
887 Ecore_WinCE_Event_Window_Delete_Request *e;
889 INF("window delete request");
891 e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Delete_Request));
894 e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA);
901 e->time = _ecore_wince_event_last_time;
903 ecore_event_add(ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL);
906 /*============================================================================*
908 *============================================================================*/