diff options
Diffstat (limited to 'uisimulator/sdl/button.c')
-rw-r--r-- | uisimulator/sdl/button.c | 118 |
1 files changed, 68 insertions, 50 deletions
diff --git a/uisimulator/sdl/button.c b/uisimulator/sdl/button.c index 15764da900..6672a4164e 100644 --- a/uisimulator/sdl/button.c +++ b/uisimulator/sdl/button.c | |||
@@ -32,6 +32,15 @@ static intptr_t button_data; /* data value from last message dequeued */ | |||
32 | 32 | ||
33 | #ifdef HAVE_TOUCHPAD | 33 | #ifdef HAVE_TOUCHPAD |
34 | static int mouse_coords = 0; | 34 | static int mouse_coords = 0; |
35 | static enum touchpad_mode touchpad_mode = TOUCHPAD_POINT; | ||
36 | void touchpad_set_mode(enum touchpad_mode mode) | ||
37 | { | ||
38 | touchpad_mode = mode; | ||
39 | } | ||
40 | enum touchpad_mode touchpad_get_mode(void) | ||
41 | { | ||
42 | return touchpad_mode; | ||
43 | } | ||
35 | #endif | 44 | #endif |
36 | /* how long until repeat kicks in */ | 45 | /* how long until repeat kicks in */ |
37 | #define REPEAT_START 6 | 46 | #define REPEAT_START 6 |
@@ -111,9 +120,53 @@ void button_event(int key, bool pressed) | |||
111 | 120 | ||
112 | #ifdef HAVE_TOUCHPAD | 121 | #ifdef HAVE_TOUCHPAD |
113 | case BUTTON_TOUCHPAD: | 122 | case BUTTON_TOUCHPAD: |
114 | new_btn = BUTTON_TOUCHPAD; | ||
115 | data = mouse_coords; | 123 | data = mouse_coords; |
124 | switch (touchpad_mode) | ||
125 | { | ||
126 | case TOUCHPAD_POINT: | ||
127 | new_btn = BUTTON_TOUCHPAD; | ||
128 | break; | ||
129 | case TOUCHPAD_BUTTON: | ||
130 | { | ||
131 | static int touchpad_buttons[3][3] = { | ||
132 | {BUTTON_TOPLEFT, BUTTON_TOPMIDDLE, BUTTON_TOPRIGHT}, | ||
133 | {BUTTON_MIDLEFT, BUTTON_CENTER, BUTTON_MIDRIGHT}, | ||
134 | {BUTTON_BOTTOMLEFT, BUTTON_BOTTOMMIDDLE, BUTTON_BOTTOMRIGHT}, | ||
135 | }; | ||
136 | int px_x = ((data&0xffff0000)>>16), px_y = ((data&0x0000ffff)); | ||
137 | new_btn = touchpad_buttons[px_y/(LCD_HEIGHT/3)][px_x/(LCD_WIDTH/3)]; | ||
138 | break; | ||
139 | } | ||
140 | } | ||
116 | break; | 141 | break; |
142 | case SDLK_KP7: | ||
143 | new_btn = BUTTON_TOPLEFT; | ||
144 | break; | ||
145 | case SDLK_KP8: | ||
146 | new_btn = BUTTON_TOPMIDDLE; | ||
147 | break; | ||
148 | case SDLK_KP9: | ||
149 | new_btn = BUTTON_TOPRIGHT; | ||
150 | break; | ||
151 | case SDLK_KP4: | ||
152 | new_btn = BUTTON_MIDLEFT; | ||
153 | break; | ||
154 | case SDLK_KP5: | ||
155 | new_btn = BUTTON_CENTER; | ||
156 | break; | ||
157 | case SDLK_KP6: | ||
158 | new_btn = BUTTON_MIDRIGHT; | ||
159 | break; | ||
160 | case SDLK_KP1: | ||
161 | new_btn = BUTTON_BOTTOMLEFT; | ||
162 | break; | ||
163 | case SDLK_KP2: | ||
164 | new_btn = BUTTON_BOTTOMMIDDLE; | ||
165 | break; | ||
166 | case SDLK_KP3: | ||
167 | new_btn = BUTTON_BOTTOMRIGHT; | ||
168 | break; | ||
169 | |||
117 | #endif | 170 | #endif |
118 | case SDLK_u: | 171 | case SDLK_u: |
119 | if (!pressed) | 172 | if (!pressed) |
@@ -665,43 +718,34 @@ void button_event(int key, bool pressed) | |||
665 | break; | 718 | break; |
666 | 719 | ||
667 | #elif CONFIG_KEYPAD == MROBE500_PAD | 720 | #elif CONFIG_KEYPAD == MROBE500_PAD |
668 | case SDLK_KP4: | 721 | case SDLK_F9: |
722 | new_btn = BUTTON_RC_HEART; | ||
723 | break; | ||
724 | case SDLK_F10: | ||
725 | new_btn = BUTTON_RC_MODE; | ||
726 | break; | ||
727 | case SDLK_F11: | ||
728 | new_btn = BUTTON_RC_VOL_DOWN; | ||
729 | break; | ||
730 | case SDLK_F12: | ||
731 | new_btn = BUTTON_RC_VOL_UP; | ||
732 | break; | ||
669 | case SDLK_LEFT: | 733 | case SDLK_LEFT: |
670 | new_btn = BUTTON_LEFT; | 734 | new_btn = BUTTON_LEFT; |
671 | break; | 735 | break; |
672 | case SDLK_KP6: | ||
673 | case SDLK_RIGHT: | 736 | case SDLK_RIGHT: |
674 | new_btn = BUTTON_RIGHT; | 737 | new_btn = BUTTON_RIGHT; |
675 | break; | 738 | break; |
676 | case SDLK_KP8: | ||
677 | case SDLK_UP: | 739 | case SDLK_UP: |
678 | new_btn = BUTTON_RC_PLAY; | 740 | new_btn = BUTTON_RC_PLAY; |
679 | break; | 741 | break; |
680 | case SDLK_KP2: | ||
681 | case SDLK_DOWN: | 742 | case SDLK_DOWN: |
682 | new_btn = BUTTON_RC_DOWN; | 743 | new_btn = BUTTON_RC_DOWN; |
683 | break; | 744 | break; |
684 | case SDLK_KP_PLUS: | ||
685 | case SDLK_F8: | 745 | case SDLK_F8: |
686 | new_btn = BUTTON_POWER; | ||
687 | break; | ||
688 | case SDLK_ESCAPE: | 746 | case SDLK_ESCAPE: |
689 | new_btn = BUTTON_POWER; | 747 | new_btn = BUTTON_POWER; |
690 | break; | 748 | break; |
691 | case SDLK_KP_ENTER: | ||
692 | case SDLK_RETURN: | ||
693 | case SDLK_a: | ||
694 | new_btn = BUTTON_RC_VOL_UP; | ||
695 | break; | ||
696 | case SDLK_KP5: | ||
697 | case SDLK_SPACE: | ||
698 | new_btn = BUTTON_RC_HEART; | ||
699 | break; | ||
700 | case SDLK_KP_PERIOD: | ||
701 | case SDLK_INSERT: | ||
702 | new_btn = BUTTON_RC_MODE; | ||
703 | break; | ||
704 | |||
705 | #elif CONFIG_KEYPAD == MROBE100_PAD | 749 | #elif CONFIG_KEYPAD == MROBE100_PAD |
706 | case SDLK_KP1: | 750 | case SDLK_KP1: |
707 | new_btn = BUTTON_DISPLAY; | 751 | new_btn = BUTTON_DISPLAY; |
@@ -739,37 +783,16 @@ void button_event(int key, bool pressed) | |||
739 | break; | 783 | break; |
740 | 784 | ||
741 | #elif CONFIG_KEYPAD == COWOND2_PAD | 785 | #elif CONFIG_KEYPAD == COWOND2_PAD |
742 | case SDLK_KP4: | 786 | case SDLK_ESCAPE: |
743 | case SDLK_LEFT: | ||
744 | new_btn = BUTTON_LEFT; | ||
745 | break; | ||
746 | case SDLK_KP6: | ||
747 | case SDLK_RIGHT: | ||
748 | new_btn = BUTTON_RIGHT; | ||
749 | break; | ||
750 | case SDLK_KP8: | ||
751 | case SDLK_UP: | ||
752 | new_btn = BUTTON_UP; | ||
753 | break; | ||
754 | case SDLK_KP2: | ||
755 | case SDLK_DOWN: | ||
756 | new_btn = BUTTON_DOWN; | ||
757 | break; | ||
758 | case SDLK_KP3: | ||
759 | new_btn = BUTTON_POWER; | 787 | new_btn = BUTTON_POWER; |
760 | break; | 788 | break; |
761 | case SDLK_KP5: | ||
762 | case SDLK_KP_ENTER: | ||
763 | case SDLK_RETURN: | ||
764 | new_btn = BUTTON_SELECT; | ||
765 | break; | ||
766 | case SDLK_KP_PLUS: | 789 | case SDLK_KP_PLUS: |
767 | new_btn = BUTTON_PLUS; | 790 | new_btn = BUTTON_PLUS; |
768 | break; | 791 | break; |
769 | case SDLK_KP_MINUS: | 792 | case SDLK_KP_MINUS: |
770 | new_btn = BUTTON_MINUS; | 793 | new_btn = BUTTON_MINUS; |
771 | break; | 794 | break; |
772 | case SDLK_KP9: | 795 | case SDLK_KP_ENTER: |
773 | new_btn = BUTTON_MENU; | 796 | new_btn = BUTTON_MENU; |
774 | break; | 797 | break; |
775 | #else | 798 | #else |
@@ -977,11 +1000,6 @@ void mouse_tick_task(void) | |||
977 | if (debug_wps) | 1000 | if (debug_wps) |
978 | printf("Mouse at: (%d, %d)\n", x, y); | 1001 | printf("Mouse at: (%d, %d)\n", x, y); |
979 | } | 1002 | } |
980 | else if (lastbtn == BUTTON_TOUCHPAD) | ||
981 | { | ||
982 | button_event(BUTTON_TOUCHPAD, false); | ||
983 | mouse_coords = 0; | ||
984 | } | ||
985 | } | 1003 | } |
986 | #endif | 1004 | #endif |
987 | void button_init(void) | 1005 | void button_init(void) |