diff options
Diffstat (limited to 'apps/plugins/lib/pluginlib_touchscreen.c')
-rw-r--r-- | apps/plugins/lib/pluginlib_touchscreen.c | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/apps/plugins/lib/pluginlib_touchscreen.c b/apps/plugins/lib/pluginlib_touchscreen.c index eca76a6999..8c746e1bc4 100644 --- a/apps/plugins/lib/pluginlib_touchscreen.c +++ b/apps/plugins/lib/pluginlib_touchscreen.c | |||
@@ -23,28 +23,31 @@ | |||
23 | #include "plugin.h" | 23 | #include "plugin.h" |
24 | 24 | ||
25 | #include "pluginlib_touchscreen.h" | 25 | #include "pluginlib_touchscreen.h" |
26 | #include "pluginlib_exit.h" | ||
26 | 27 | ||
27 | /******************************************************************************* | 28 | /******************************************************************************* |
28 | * Touchbutton functions: These functions allow the plugin to specify a button | 29 | * Touchbutton functions: These functions allow the plugin to specify a button |
29 | * location that, in turn gets mapped to a button press return value. | 30 | * location that, in turn gets mapped to a button press return value. |
30 | ******************************************************************************/ | 31 | ******************************************************************************/ |
31 | 32 | ||
32 | /* touchbutton_get: | 33 | /* touchbutton_check_button: |
33 | * This function checks the touchbutton structure passed to it for hits. When | 34 | * This function checks the touchbutton structure passed to it for hits. When |
34 | * one is found it returns action. | 35 | * one is found it returns action. It doesn't block because it doesn't actually |
36 | * call button_get. You need to call it before and pass its result. | ||
35 | * inputs: | 37 | * inputs: |
36 | * struct touchbutton *data: This is intended to be an array of | 38 | * struct touchbutton *data: This is intended to be an array of |
37 | * touchbuttons of size num_buttons. Each element in the array defines | 39 | * touchbuttons of size num_buttons. Each element in the array defines |
38 | * one button. | 40 | * one button. |
39 | * int button: This is the button return value from a button_get() call. | 41 | * int button: This is the button return value from a button_get() call. |
40 | * It is used to determine REPEAT/RELEASE events. | 42 | * It is used to determine REPEAT/RELEASE events. This way |
43 | * this function can be mixed with other buttons | ||
41 | * int num_buttons: This tells touchbutton_get how many elements are in | 44 | * int num_buttons: This tells touchbutton_get how many elements are in |
42 | * data. | 45 | * data. |
43 | * return: | 46 | * return: |
44 | * If a touch occured over one of the defined buttons, return action, else | 47 | * If a touch occured over one of the defined buttons, return action, else |
45 | * return 0. | 48 | * return 0. |
46 | */ | 49 | */ |
47 | int touchbutton_get(struct touchbutton *data, int button, int num_buttons) { | 50 | int touchbutton_check_button(int button, struct touchbutton *data, int num_buttons) { |
48 | short x,y; | 51 | short x,y; |
49 | 52 | ||
50 | /* Get the x/y location of the button press, this is set by button_get when | 53 | /* Get the x/y location of the button press, this is set by button_get when |
@@ -71,6 +74,46 @@ int touchbutton_get(struct touchbutton *data, int button, int num_buttons) { | |||
71 | return 0; | 74 | return 0; |
72 | } | 75 | } |
73 | 76 | ||
77 | /* touchbutton_get_w_tmo: | ||
78 | * This function checks the touchbutton structure passed to it for hits. When | ||
79 | * one is found it returns the corresponding action. | ||
80 | * inputs: | ||
81 | * struct touchbutton *data: This is intended to be an array of | ||
82 | * touchbuttons of size num_buttons. Each element in the array defines | ||
83 | * one button. | ||
84 | * int tmo: Timeout when waiting for input. | ||
85 | * int num_buttons: This tells touchbutton_get how many elements are in | ||
86 | * data. | ||
87 | * return: | ||
88 | * If a touch occured over one of the defined buttons, return action, else | ||
89 | * return 0. | ||
90 | */ | ||
91 | int touchbutton_get_w_tmo(int tmo, struct touchbutton *data, int num_buttons) | ||
92 | { | ||
93 | int btn = rb->button_get_w_tmo(tmo); | ||
94 | int result = touchbutton_check_button(btn, data, num_buttons); | ||
95 | exit_on_usb(result); | ||
96 | return result; | ||
97 | } | ||
98 | |||
99 | /* touchbutton_get: | ||
100 | * This function checks the touchbutton structure passed to it for hits. When | ||
101 | * one is found it returns the corresponding action. | ||
102 | * inputs: | ||
103 | * struct touchbutton *data: This is intended to be an array of | ||
104 | * touchbuttons of size num_buttons. Each element in the array defines | ||
105 | * one button. | ||
106 | * int num_buttons: This tells touchbutton_get how many elements are in | ||
107 | * data. | ||
108 | * return: | ||
109 | * If a touch occured over one of the defined buttons, return action, else | ||
110 | * return 0. | ||
111 | */ | ||
112 | int touchbutton_get(struct touchbutton *data, int num_buttons) | ||
113 | { | ||
114 | return touchbutton_get_w_tmo(TIMEOUT_BLOCK, data, num_buttons); | ||
115 | } | ||
116 | |||
74 | /* touchbutton_draw: | 117 | /* touchbutton_draw: |
75 | * This function draws the button with the associated text as long as the | 118 | * This function draws the button with the associated text as long as the |
76 | * invisible flag is not set. Support for pixmaps needs to be added. | 119 | * invisible flag is not set. Support for pixmaps needs to be added. |