MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / ThreadforKeyGet

Function ThreadforKeyGet

bsp/simulator/drivers/uart_console.c:116–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114
115#define getch getchar
116static void * ThreadforKeyGet(void * lpParam)
117#endif /* not _WIN32*/
118{
119 /*
120 * left key(左): 0xe04b
121 * up key(上): 0xe048
122 * right key(右): 0xe04d
123 * down key(下): 0xe050
124 */
125 unsigned char key;
126
127#ifndef _WIN32
128 sigset_t sigmask, oldmask;
129 /* set the getchar without buffer */
130 sigfillset(&sigmask);
131 pthread_sigmask(SIG_BLOCK, &sigmask, &oldmask);
132 set_stty();
133#endif
134
135 (void)lpParam; //prevent compiler warnings
136
137 for (;;)
138 {
139 key = getch();
140#ifdef _WIN32
141 if (key == 0xE0)
142 {
143 key = getch();
144
145 if (key == 0x48) //up key , 0x1b 0x5b 0x41
146 {
147 SAVEKEY(0x1b);
148 SAVEKEY(0x5b);
149 SAVEKEY(0x41);
150 }
151 else if (key == 0x50)//0x1b 0x5b 0x42
152 {
153 SAVEKEY(0x1b);
154 SAVEKEY(0x5b);
155 SAVEKEY(0x42);
156 }
157 else if (key == 0x4b)//<- 0x1b 0x5b 0x44
158 {
159 SAVEKEY(0x1b);
160 SAVEKEY(0x5b);
161 SAVEKEY(0x44);
162 }
163 else if (key == 0x4d)//<- 0x1b 0x5b 0x43
164 {
165 SAVEKEY(0x1b);
166 SAVEKEY(0x5b);
167 SAVEKEY(0x43);
168 }
169
170 continue;
171 }
172#endif
173 SAVEKEY(key);

Callers

nothing calls this directly

Calls 3

pthread_sigmaskFunction · 0.85
set_sttyFunction · 0.85
rt_hw_serial_isrFunction · 0.50

Tested by

no test coverage detected