µGFX  2.9
version 2.9
ginput_driver_keyboard.h
Go to the documentation of this file.
1 /*
2  * This file is subject to the terms of the GFX License. If a copy of
3  * the license was not distributed with this file, you can obtain one at:
4  *
5  * http://ugfx.io/license.html
6  */
7 
8 /**
9  * @file src/ginput/ginput_driver_keyboard.h
10  * @brief GINPUT LLD header file for keyboard drivers.
11  *
12  * @defgroup Keyboard Keyboard
13  * @ingroup GINPUT
14  * @{
15  */
16 
17 #ifndef _LLD_GINPUT_KEYBOARD_H
18 #define _LLD_GINPUT_KEYBOARD_H
19 
20 #if GINPUT_NEED_KEYBOARD //|| defined(__DOXYGEN__)
21 
22 // Include the GDRIVER infrastructure
23 #include "../gdriver/gdriver.h"
24 
25 typedef struct GKeyboard {
26  GDriver d; // The driver overheads and vmt
27  gU16 cntc; // The byte count in c
28  gU16 cntsc; // The byte count in sc
29  char c[8]; // The utf8 code for the current key
30  char sc[8]; // The scancode for the current key
31  gU32 keystate; // The keyboard state.
32  gU16 flags;
33  #define GKEYBOARD_FLG_NEEDREAD 0x0001
34  gU16 laystate; // The layout state.
35  const gU8 * pLayout; // The current keyboard layout
36  // Other driver specific fields may follow.
37 } GKeyboard;
38 
39 typedef struct GKeyboardVMT {
40  GDriverVMT d; // Device flags are part of the general vmt
41  #define GKEYBOARD_VFLG_NOPOLL 0x0001 // Do not poll this device - it is purely interrupt driven
42  #define GKEYBOARD_VFLG_DYNAMICONLY 0x8000 // This keyboard driver should not be statically initialized eg Win32
43  const gU8 * defLayout; // The default keyboard layout
44  gBool (*init)(GKeyboard *m, unsigned driverinstance); // Required
45  void (*deinit)(GKeyboard *m); // Optional
46  int (*getdata)(GKeyboard *k, gU8 *pch, int sz); // Required. Get zero or more scancode bytes. Returns the number of scancode bytes returns
47  void (*putdata)(GKeyboard *k, char ch); // Optional. Send a single byte to the keyboard.
48 } GKeyboardVMT;
49 
50 #define gkvmt(m) ((const GKeyboardVMT const *)((m)->d.vmt))
51 
52 /*===========================================================================*/
53 /* External declarations. */
54 /*===========================================================================*/
55 
56 // If we are not using multiple keyboards then hard-code the VMT name
57 #if !defined(GINPUT_KEYBOARD_DRIVER_LIST)
58  #undef GKEYBOARD_DRIVER_VMT
59  #define GKEYBOARD_DRIVER_VMT GKEYBOARDVMT_OnlyOne
60 #endif
61 
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65  /**
66  * @brief Initialize a keyboard driver
67  *
68  * @param[in] g The keyboard driver
69  * @param[in] param Unused by keyboard
70  * @param[in] driverinstance The driver instance ToDo: Add some more details
71  * @param[in] systeminstance The mouse instance ToDo: Add some more details
72  *
73  * @return gTrue on success, gFalse otherwise
74  * @note This routine is provided by the high level code for
75  * use in the driver VMT's GMouseVMT.d structure.
76  *
77  * @notapi
78  */
79  gBool _gkeyboardInitDriver(GDriver *g, void *param, unsigned driverinstance, unsigned systeminstance);
80 
81  /**
82  * @brief Routine that is called after initialization
83  *
84  * @param[in] g The keyboard driver
85  * @note This routine is provided by the high level code for
86  * use in the driver VMT's GKeyboardVMT.d structure.
87  *
88  * @notapi
89  */
90  void _gkeyboardPostInitDriver(GDriver *g);
91 
92  /**
93  * @brief Deinitialize a keyboard driver
94  *
95  * @param[in] g The kerboard driver
96  * @note This routine is provided by the high level code for
97  * use in the driver VMT's GKeyboardVMT.d structure.
98  *
99  * @notapi
100  */
101  void _gkeyboardDeInitDriver(GDriver *g);
102 
103  /**
104  * @brief Wakeup the high level code so that it attempts another read
105  *
106  * @note This routine is provided to low level drivers by the high level code
107  *
108  * @notapi
109  */
110  void _gkeyboardWakeup(GKeyboard *k);
111 
112  /**
113  * @brief Wakeup the high level code so that it attempts another read
114  *
115  * @note This routine is provided to low level drivers by the high level code
116  *
117  * @iclass
118  * @notapi
119  */
120  void _gkeyboardWakeupI(GKeyboard *k);
121 
122 #ifdef __cplusplus
123 }
124 #endif
125 
126 #endif /* GINPUT_NEED_KEYBOARD */
127 
128 #endif /* _LLD_GINPUT_KEYBOARD_H */
129 /** @} */
All runtime driver structures start with this structure.
Definition: gdriver.h:58
All driver VMT's start with this structure.
Definition: gdriver.h:66