MPLABĀ® Harmony Graphics Suite
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 /* internal use only */
64 #define LE_INPUT_PRIMARY_ID 0
65 #define LE_MAX_TOUCH_STATES 2
66 
71 // *****************************************************************************
72 
77 typedef enum leGestureID
78 {
79  LE_GESTURE_NONE = 0
81 
82 // *****************************************************************************
83 /* Enumeration:
84  leKey
85 
86  Summary:
87  All values possible for key entry from the legato keyboard widget
88 
89  Description:
90  All values possible for key entry from the legato keyboard widget
91 
92  Remarks:
93  None.
94 */
100 typedef enum leKey
101 {
102  KEY_NULL = 0,
103  KEY_ESCAPE,
104  KEY_F1,
105  KEY_F2,
106  KEY_F3,
107  KEY_F4,
108  KEY_F5,
109  KEY_F6,
110  KEY_F7,
111  KEY_F8,
112  KEY_F9,
113  KEY_F10,
114  KEY_F11,
115  KEY_F12,
116  KEY_PRINTSCREEN,
117  KEY_SCROLLLOCK,
118  KEY_PAUSE,
119  KEY_1,
120  KEY_2,
121  KEY_3,
122  KEY_4,
123  KEY_5,
124  KEY_6,
125  KEY_7,
126  KEY_8,
127  KEY_9,
128  KEY_0,
129  KEY_BACKQUOTE,
130  KEY_TAB,
131  KEY_CAPSLOCK,
132  KEY_BRACKET_LEFT,
133  KEY_BRACKET_RIGHT,
134  KEY_SLASH,
135  KEY_SEMICOLON,
136  KEY_QUOTE,
137  KEY_BACKSLASH,
138  KEY_EQUALS,
139  KEY_BACKSPACE,
140  KEY_MINUS,
141  KEY_COMMA,
142  KEY_ENTER,
143  KEY_PERIOD,
144  KEY_A,
145  KEY_B,
146  KEY_C,
147  KEY_D,
148  KEY_E,
149  KEY_F,
150  KEY_G,
151  KEY_H,
152  KEY_I,
153  KEY_J,
154  KEY_K,
155  KEY_L,
156  KEY_M,
157  KEY_N,
158  KEY_O,
159  KEY_P,
160  KEY_Q,
161  KEY_R,
162  KEY_S,
163  KEY_T,
164  KEY_U,
165  KEY_V,
166  KEY_W,
167  KEY_X,
168  KEY_Y,
169  KEY_Z,
170  KEY_SPACE,
171  KEY_LCTRL,
172  KEY_RCTRL,
173  KEY_LSHIFT,
174  KEY_RSHIFT,
175  KEY_LALT,
176  KEY_RALT,
177  KEY_LMETA,
178  KEY_RMETA,
179  KEY_INSERT,
180  KEY_HOME,
181  KEY_PAGEUP,
182  KEY_END,
183  KEY_PAGEDOWN,
184  KEY_RIGHT,
185  KEY_LEFT,
186  KEY_DOWN,
187  KEY_UP,
188  KEY_NUMLOCK,
189  KEY_KP_DIVIDE,
190  KEY_KP_MULTIPLY,
191  KEY_KP_MINUS,
192  KEY_KP_PLUS,
193  KEY_KP_ENTER,
194  KEY_KP_1,
195  KEY_KP_2,
196  KEY_KP_3,
197  KEY_KP_4,
198  KEY_KP_5,
199  KEY_KP_6,
200  KEY_KP_7,
201  KEY_KP_8,
202  KEY_KP_9,
203  KEY_KP_0,
204  KEY_KP_PERIOD,
205  KEY_LAST = KEY_KP_PERIOD
207 
208 // *****************************************************************************
214 typedef enum leMouseButton
215 {
216  BUTTON_NONE = 0,
217  BUTTON_LEFT,
218  BUTTON_MIDDLE,
219  BUTTON_RIGHT,
220  BUTTON_WHEEL_UP,
221  BUTTON_WHEEL_DOWN,
222  BUTTON_LAST = BUTTON_WHEEL_DOWN
224 
225 #define NUM_KEYS KEY_LAST + 1
226 #define NUM_BUTTONS BUTTON_LAST + 1
227 
228 // *****************************************************************************
234 typedef struct leTouchState
235 {
236  uint32_t valid;
237  int32_t x;
238  int32_t y;
240 
241 // *****************************************************************************
247 typedef struct leInputState
248 {
249  leBool enabled;
250 
251  leTouchState touch[LE_MAX_TOUCH_STATES];
252  //uint8_t keyState[KEY_LAST]; // change to bitset?
253  //leMouseState mouse;
254 
255  int32_t driverAdjustX;
256  int32_t driverAdjustY;
257 
259 
260 /* internal use only */
264 leInputState* _leGetInputState();
265 
266 leResult leInput_Init();
267 void leInput_Shutdown();
274 // *****************************************************************************
275 // *****************************************************************************
276 // Section: Routines
277 // *****************************************************************************
278 // *****************************************************************************
279 
280 // *****************************************************************************
281 /* Function:
282  leBool leInput_GetEnabled()
283 
284  Summary:
285  Returns the input enabled status of the current context
286 
287  Description:
288  Returns the input enabled status of the current context
289 
290  Parameters:
291 
292 
293  Returns:
294  leBool
295 
296  Remarks:
297 
298 */
308 LIB_EXPORT leBool leInput_GetEnabled();
309 
310 // *****************************************************************************
311 /* Function:
312  leResult leInput_SetEnabled(leBool enable)
313 
314  Summary:
315  Sets the input status of the current context with the specified input argument
316 
317  Description:
318  Sets the input status of the current context with the specified input argument
319 
320  Parameters:
321  leBool
322 
323  Returns:
324  leResult
325 
326  Remarks:
327 
328 */
339 LIB_EXPORT leResult leInput_SetEnabled(leBool enable);
340 
341 // *****************************************************************************
342 /* Function:
343  leResult leInput_InjectTouchDown(uint32_t id, int32_t x, int32_t y)
344 
345  Summary:
346  Register and track the touch down event and queue it for handling by associated widgets
347 
348  Description:
349  Register and track the touch down event and queue it for handling by associated widgets
350 
351  Parameters:
352  uint32_t
353  int32_t x
354  int32_t y
355 
356  Returns:
357  leResult
358 
359  Remarks:
360 
361 */
375 LIB_EXPORT leResult leInput_InjectTouchDown(uint32_t id, int32_t x, int32_t y);
376 
377 // *****************************************************************************
378 /* Function:
379  leResult leInput_InjectTouchUp(uint32_t id, int32_t x, int32_t y)
380 
381  Summary:
382  Register and track the touch up event and queue it for handling by associated widgets
383 
384  Description:
385  Register and track the touch up event and queue it for handling by associated widgets
386 
387  Parameters:
388  uint32_t
389  int32_t x
390  int32_t y
391 
392  Returns:
393  leResult
394 
395  Remarks:
396 
397 */
411 LIB_EXPORT leResult leInput_InjectTouchUp(uint32_t id, int32_t x, int32_t y);
412 
413 // *****************************************************************************
414 /* Function:
415  leResult leInput_InjectTouchMoved(uint32_t id, int32_t x, int32_t y)
416 
417  Summary:
418  Register and track the touch moved event and queue it for handling by associated widgets
419 
420  Description:
421  Register and track the touch moved event and queue it for handling by associated widgets
422 
423  Parameters:
424  uint32_t
425  int32_t x
426  int32_t y
427 
428  Returns:
429  leResult
430 
431  Remarks:
432 
433 */
447 LIB_EXPORT leResult leInput_InjectTouchMoved(uint32_t id, int32_t x, int32_t y);
448 
449 /* internal use only */
454 // alternative input APIs (not yet implemented)
455 
456 /*
457 LIB_EXPORT leResult leInput_InjectGesture(leGesture id, int32_t x, int32_t y);
458 
459 LIB_EXPORT leResult leInput_InjectKeyDown(leKey key);
460 LIB_EXPORT leResult leInput_InjectKeyUp(leKey key);
461 
462 LIB_EXPORT leResult leInput_InjectMouseButtonDown(leMouseButton button);
463 LIB_EXPORT leResult leInput_InjectMouseButtonUp(leMouseButton button);
464 LIB_EXPORT leResult leInput_InjectMouseMoved(int32_t x, int32_t y);*/
465 
466 leEventResult _leInput_HandleInputEvent(leEvent* evt);
472 #endif /* LEGATO_INPUT_H */
leEventResult
leEventResult
This enum represents an event result.
Definition: legato_event.h:146
legato_input.h
Legato input definitions.
leResult
leResult
This enum represents function call results.
Definition: legato_common.h:134
leRect
This struct represents a rectangle.
Definition: legato_common.h:405
leEvent_AddEvent
leResult leEvent_AddEvent(leEvent *evt)
Add event.
Definition: legato_event.c:73
leWidgetEvent_TouchUp
Used to define widget touch up event.
Definition: legato_widget.h:403
LE_EVENT_TOUCH_DOWN
@ LE_EVENT_TOUCH_DOWN
Definition: legato_event.h:68
leList::head
leListNode * head
Definition: legato_list.h:92
LE_EVENT_DEFERRED
@ LE_EVENT_DEFERRED
Definition: legato_event.h:149
leEventState::events
leList events
Definition: legato_event.h:116
leEvent
This enum presents a event. An event contains valid event ids.
Definition: legato_event.h:88
leMouseButton
leMouseButton
This enum represents key entry for legato mouse input.
Definition: legato_input.h:215
legato_memory.h
Memory functions and definitions.
LE_EVENT_TOUCH_UP
@ LE_EVENT_TOUCH_UP
Definition: legato_event.h:69
legato_event.h
Legato event definitions.
leWidgetEvent_TouchDown
Used to define widget touch down event.
Definition: legato_widget.h:377
leGetFocusWidget
LIB_EXPORT leWidget * leGetFocusWidget()
Get focus widget.
Definition: legato_state.c:490
legato_renderer.h
legato_widget.h
Legato widget definitions.
leTouchState::valid
uint32_t valid
Definition: legato_input.h:236
leTouchState::y
int32_t y
Definition: legato_input.h:238
leBool
leBool
This enum represents booleans.
Definition: legato_common.h:157
leInput_SetEnabled
LIB_EXPORT leResult leInput_SetEnabled(leBool enable)
Set input enabled status.
Definition: legato_input.c:67
leInput_InjectTouchUp
LIB_EXPORT leResult leInput_InjectTouchUp(uint32_t id, int32_t x, int32_t y)
Inject touch up event.
Definition: legato_input.c:141
leInput_InjectTouchMoved
LIB_EXPORT leResult leInput_InjectTouchMoved(uint32_t id, int32_t x, int32_t y)
Inject touch moved event.
Definition: legato_input.c:202
LE_FALSE
@ LE_FALSE
Definition: legato_common.h:158
leInputState
struct leInputState leInputState
This struct represents input state.
leInputState
This struct represents input state.
Definition: legato_input.h:248
LE_EVENT_TOUCH_MOVE
@ LE_EVENT_TOUCH_MOVE
Definition: legato_event.h:70
leIsDrawing
LIB_EXPORT leBool leIsDrawing()
Check active screen drawing state.
Definition: legato_state.c:561
leUtils_PickFromWidget
leWidget * leUtils_PickFromWidget(const leWidget *wgt, int32_t x, int32_t y)
Finds the top-most visible widget in a layer at the given coordinates.
Definition: legato_utils.c:34
leTouchState::x
int32_t x
Definition: legato_input.h:237
legato_utils.h
General internal utilities for the library.
leEvent::id
leEventID id
Definition: legato_event.h:89
leInput_InjectTouchDown
LIB_EXPORT leResult leInput_InjectTouchDown(uint32_t id, int32_t x, int32_t y)
Inject touch down event.
Definition: legato_input.c:74
leInput_GetEnabled
LIB_EXPORT leBool leInput_GetEnabled()
Get input enabled status.
Definition: legato_input.c:62
leWidget
Used to define a widget.
Definition: legato_widget.h:623
leTouchState
This struct represents a touch state.
Definition: legato_input.h:235
leWidgetEvent_TouchMove
Used to define widget touch move event.
Definition: legato_widget.h:429
leGestureID
leGestureID
This enum represents gesture type IDs.
Definition: legato_input.h:78
leListNode::next
struct leListNode * next
Definition: legato_list.h:70
leState::rootWidget
leWidget rootWidget[LE_LAYER_COUNT]
Definition: legato_state.h:83
LE_GESTURE_NONE
@ LE_GESTURE_NONE
Definition: legato_input.h:79
LE_EVENT_HANDLED
@ LE_EVENT_HANDLED
Definition: legato_event.h:148
LE_TRUE
@ LE_TRUE
Definition: legato_common.h:159
leKey
leKey
This enum represents legato keyboard entry.
Definition: legato_input.h:101
legato_common.h
Common macros and definitions used by Legato.
leListNode::val
void * val
Definition: legato_list.h:71
legato_state.h
leListNode
This struct represents a list node .
Definition: legato_list.h:69
leTouchState
struct leTouchState leTouchState
This struct represents a touch state.
leSetFocusWidget
LIB_EXPORT leResult leSetFocusWidget(leWidget *widget)
Get language by index.
Definition: legato_state.c:495
lePoint
This structure represents a integer Cartesian point.
Definition: legato_common.h:357