MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_input.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2020 Microchip Technology Inc. and its subsidiaries.
3 *
4 * Subject to your compliance with these terms, you may use Microchip software
5 * and any derivatives exclusively with Microchip products. It is your
6 * responsibility to comply with third party license terms applicable to your
7 * use of third party software (including open source software) that may
8 * accompany Microchip software.
9 *
10 * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
11 * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
12 * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
13 * PARTICULAR PURPOSE.
14 *
15 * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
16 * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
17 * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
18 * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
19 * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
20 * ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
21 * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
22 *******************************************************************************/
23 
24 /*******************************************************************************
25  Module for Microchip Graphics Library - Legato User Interface Library
26 
27  Company:
28  Microchip Technology Inc.
29 
30  File Name:
31  legato_input.h
32 
33  Summary:
34 
35 
36 *******************************************************************************/
37 
44 #ifndef LEGATO_INPUT_H
45 #define LEGATO_INPUT_H
46 
49 
50 // *****************************************************************************
51 // *****************************************************************************
52 // Section: Data Types and Constants
53 // *****************************************************************************
54 // *****************************************************************************
55 
56 // *****************************************************************************
57 
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
64 /* internal use only */
68 #define LE_INPUT_PRIMARY_ID 0
69 #define LE_MAX_TOUCH_STATES 2
70 
75 // *****************************************************************************
76 
81 typedef enum leGestureID
82 {
84 } leGestureID;
85 
86 // *****************************************************************************
87 /* Enumeration:
88  leKey
89 
90  Summary:
91  All values possible for key entry from the legato keyboard widget
92 
93  Description:
94  All values possible for key entry from the legato keyboard widget
95 
96  Remarks:
97  None.
98 */
104 typedef enum leKey
105 {
106  KEY_NULL = 0,
107  KEY_ESCAPE,
108  KEY_F1,
109  KEY_F2,
110  KEY_F3,
111  KEY_F4,
112  KEY_F5,
113  KEY_F6,
114  KEY_F7,
115  KEY_F8,
116  KEY_F9,
117  KEY_F10,
118  KEY_F11,
119  KEY_F12,
120  KEY_PRINTSCREEN,
121  KEY_SCROLLLOCK,
122  KEY_PAUSE,
123  KEY_1,
124  KEY_2,
125  KEY_3,
126  KEY_4,
127  KEY_5,
128  KEY_6,
129  KEY_7,
130  KEY_8,
131  KEY_9,
132  KEY_0,
133  KEY_BACKQUOTE,
134  KEY_TAB,
135  KEY_CAPSLOCK,
136  KEY_BRACKET_LEFT,
137  KEY_BRACKET_RIGHT,
138  KEY_SLASH,
139  KEY_SEMICOLON,
140  KEY_QUOTE,
141  KEY_BACKSLASH,
142  KEY_EQUALS,
143  KEY_BACKSPACE,
144  KEY_MINUS,
145  KEY_COMMA,
146  KEY_ENTER,
147  KEY_PERIOD,
148  KEY_A,
149  KEY_B,
150  KEY_C,
151  KEY_D,
152  KEY_E,
153  KEY_F,
154  KEY_G,
155  KEY_H,
156  KEY_I,
157  KEY_J,
158  KEY_K,
159  KEY_L,
160  KEY_M,
161  KEY_N,
162  KEY_O,
163  KEY_P,
164  KEY_Q,
165  KEY_R,
166  KEY_S,
167  KEY_T,
168  KEY_U,
169  KEY_V,
170  KEY_W,
171  KEY_X,
172  KEY_Y,
173  KEY_Z,
174  KEY_SPACE,
175  KEY_LCTRL,
176  KEY_RCTRL,
177  KEY_LSHIFT,
178  KEY_RSHIFT,
179  KEY_LALT,
180  KEY_RALT,
181  KEY_LMETA,
182  KEY_RMETA,
183  KEY_INSERT,
184  KEY_HOME,
185  KEY_PAGEUP,
186  KEY_END,
187  KEY_PAGEDOWN,
188  KEY_RIGHT,
189  KEY_LEFT,
190  KEY_DOWN,
191  KEY_UP,
192  KEY_NUMLOCK,
193  KEY_KP_DIVIDE,
194  KEY_KP_MULTIPLY,
195  KEY_KP_MINUS,
196  KEY_KP_PLUS,
197  KEY_KP_ENTER,
198  KEY_KP_1,
199  KEY_KP_2,
200  KEY_KP_3,
201  KEY_KP_4,
202  KEY_KP_5,
203  KEY_KP_6,
204  KEY_KP_7,
205  KEY_KP_8,
206  KEY_KP_9,
207  KEY_KP_0,
208  KEY_KP_PERIOD,
209  KEY_LAST = KEY_KP_PERIOD
210 } leKey;
211 
212 // *****************************************************************************
218 typedef enum leMouseButton
219 {
220  BUTTON_NONE = 0,
221  BUTTON_LEFT,
222  BUTTON_MIDDLE,
223  BUTTON_RIGHT,
224  BUTTON_WHEEL_UP,
225  BUTTON_WHEEL_DOWN,
226  BUTTON_LAST = BUTTON_WHEEL_DOWN
227 } leMouseButton;
228 
229 #define NUM_KEYS KEY_LAST + 1
230 #define NUM_BUTTONS BUTTON_LAST + 1
231 
232 // *****************************************************************************
238 typedef struct leTouchState
239 {
240  uint32_t valid;
241  int32_t x;
242  int32_t y;
243 } leTouchState;
244 
245 // *****************************************************************************
251 typedef struct leInputState
252 {
253  leBool enabled;
254 
255  leTouchState touch[LE_MAX_TOUCH_STATES];
256  //uint8_t keyState[KEY_LAST]; // change to bitset?
257  //leMouseState mouse;
258 
259  int32_t driverAdjustX;
260  int32_t driverAdjustY;
261 
262 } leInputState;
263 
264 /* internal use only */
268 leInputState* _leGetInputState(void);
269 
270 leResult leInput_Init(void);
271 void leInput_Shutdown(void);
278 // *****************************************************************************
279 // *****************************************************************************
280 // Section: Routines
281 // *****************************************************************************
282 // *****************************************************************************
283 
284 // *****************************************************************************
285 /* Function:
286  leBool leInput_GetEnabled()
287 
288  Summary:
289  Returns the input enabled status of the current context
290 
291  Description:
292  Returns the input enabled status of the current context
293 
294  Parameters:
295 
296 
297  Returns:
298  leBool
299 
300  Remarks:
301 
302 */
313 
314 // *****************************************************************************
315 /* Function:
316  leResult leInput_SetEnabled(leBool enable)
317 
318  Summary:
319  Sets the input status of the current context with the specified input argument
320 
321  Description:
322  Sets the input status of the current context with the specified input argument
323 
324  Parameters:
325  leBool
326 
327  Returns:
328  leResult
329 
330  Remarks:
331 
332 */
344 
345 // *****************************************************************************
346 /* Function:
347  leResult leInput_InjectTouchDown(uint32_t id, int32_t x, int32_t y)
348 
349  Summary:
350  Register and track the touch down event and queue it for handling by associated widgets
351 
352  Description:
353  Register and track the touch down event and queue it for handling by associated widgets
354 
355  Parameters:
356  uint32_t
357  int32_t x
358  int32_t y
359 
360  Returns:
361  leResult
362 
363  Remarks:
364 
365 */
379 leResult leInput_InjectTouchDown(uint32_t id, int32_t x, int32_t y);
380 
381 // *****************************************************************************
382 /* Function:
383  leResult leInput_InjectTouchUp(uint32_t id, int32_t x, int32_t y)
384 
385  Summary:
386  Register and track the touch up event and queue it for handling by associated widgets
387 
388  Description:
389  Register and track the touch up event and queue it for handling by associated widgets
390 
391  Parameters:
392  uint32_t
393  int32_t x
394  int32_t y
395 
396  Returns:
397  leResult
398 
399  Remarks:
400 
401 */
415 leResult leInput_InjectTouchUp(uint32_t id, int32_t x, int32_t y);
416 
417 // *****************************************************************************
418 /* Function:
419  leResult leInput_InjectTouchMoved(uint32_t id, int32_t x, int32_t y)
420 
421  Summary:
422  Register and track the touch moved event and queue it for handling by associated widgets
423 
424  Description:
425  Register and track the touch moved event and queue it for handling by associated widgets
426 
427  Parameters:
428  uint32_t
429  int32_t x
430  int32_t y
431 
432  Returns:
433  leResult
434 
435  Remarks:
436 
437 */
451 leResult leInput_InjectTouchMoved(uint32_t id, int32_t x, int32_t y);
452 
453 /* internal use only */
458 // alternative input APIs (not yet implemented)
459 
460 /*
461 leResult leInput_InjectGesture(leGesture id, int32_t x, int32_t y);
462 
463 leResult leInput_InjectKeyDown(leKey key);
464 leResult leInput_InjectKeyUp(leKey key);
465 
466 leResult leInput_InjectMouseButtonDown(leMouseButton button);
467 leResult leInput_InjectMouseButtonUp(leMouseButton button);
468 leResult leInput_InjectMouseMoved(int32_t x, int32_t y);*/
469 
470 leEventResult _leInput_HandleInputEvent(leEvent* evt);
476 #ifdef __cplusplus
477 }
478 #endif
479 
480 #endif /* LEGATO_INPUT_H */
leMouseButton
This enum represents key entry for legato mouse input.
Definition: legato_input.h:218
struct leInputState leInputState
This struct represents input state.
Common macros and definitions used by Legato.
leBool leInput_GetEnabled(void)
Get input enabled status.
Definition: legato_input.c:57
Legato event definitions.
This struct represents input state.
Definition: legato_input.h:251
leEventResult
This enum represents an event result.
Definition: legato_event.h:149
leResult leInput_SetEnabled(leBool enable)
Set input enabled status.
Definition: legato_input.c:62
Definition: legato_input.h:83
int32_t x
Definition: legato_input.h:241
leResult
This enum represents function call results.
Definition: legato_common.h:123
struct leTouchState leTouchState
This struct represents a touch state.
leResult leInput_InjectTouchUp(uint32_t id, int32_t x, int32_t y)
Inject touch up event.
Definition: legato_input.c:136
leGestureID
This enum represents gesture type IDs.
Definition: legato_input.h:81
leKey
This enum represents legato keyboard entry.
Definition: legato_input.h:104
uint32_t valid
Definition: legato_input.h:240
Legato widget definitions.
leResult leInput_InjectTouchMoved(uint32_t id, int32_t x, int32_t y)
Inject touch moved event.
Definition: legato_input.c:200
This struct represents a touch state.
Definition: legato_input.h:238
int32_t y
Definition: legato_input.h:242
leBool
This enum represents booleans.
Definition: legato_common.h:146
leResult leInput_InjectTouchDown(uint32_t id, int32_t x, int32_t y)
Inject touch down event.
Definition: legato_input.c:69
This enum presents a event. An event contains valid event ids.
Definition: legato_event.h:91