| 213 | } |
| 214 | |
| 215 | void StdConsole::process() |
| 216 | { |
| 217 | if(stdConsoleEnabled) |
| 218 | { |
| 219 | //U16 key; |
| 220 | char typedData[64]; // damn, if you can type this fast... :-D |
| 221 | |
| 222 | if (UUtils->inBackground()) |
| 223 | // we don't have the terminal |
| 224 | inBackground = true; |
| 225 | else |
| 226 | { |
| 227 | // if we were in the background, reset the terminal |
| 228 | if (inBackground) |
| 229 | resetTerminal(); |
| 230 | inBackground = false; |
| 231 | } |
| 232 | |
| 233 | // see if stdIn has any input waiting |
| 234 | // mojo for select call |
| 235 | fd_set rfds; |
| 236 | struct timeval tv; |
| 237 | |
| 238 | FD_ZERO(&rfds); |
| 239 | FD_SET(stdIn, &rfds); |
| 240 | // don't wait at all in select |
| 241 | tv.tv_sec = 0; |
| 242 | tv.tv_usec = 0; |
| 243 | |
| 244 | int numEvents = select(stdIn+1, &rfds, NULL, NULL, &tv); |
| 245 | if (numEvents <= 0) |
| 246 | // no data available |
| 247 | return; |
| 248 | |
| 249 | numEvents = read(stdIn, typedData, 64); |
| 250 | if (numEvents == -1) |
| 251 | return; |
| 252 | |
| 253 | // TODO LINUX, when debug in qtCreator some times we get false console inputs. |
| 254 | if( !stdConsoleInputEnabled ) |
| 255 | return; |
| 256 | |
| 257 | typedData[numEvents] = '\0'; |
| 258 | if (numEvents > 0) |
| 259 | { |
| 260 | char outbuf[512]; |
| 261 | S32 outpos = 0; |
| 262 | |
| 263 | for (int i = 0; i < numEvents; i++) |
| 264 | { |
| 265 | switch(typedData[i]) |
| 266 | { |
| 267 | case 8: |
| 268 | case 127: |
| 269 | /* backspace */ |
| 270 | if (inpos > 0) |
| 271 | { |
| 272 | outbuf[outpos++] = '\b'; |
nothing calls this directly
no test coverage detected