| 139 | } |
| 140 | |
| 141 | void AndroidConsole::inputLoop() |
| 142 | { |
| 143 | Con::printf("Console Input Thread Started"); |
| 144 | unsigned char c; |
| 145 | while(consoleEnabled) |
| 146 | { |
| 147 | c = fgetc(stdin); |
| 148 | if(c == '\n') |
| 149 | { |
| 150 | // exec the line |
| 151 | dStrcpy(postEvent.data, inBuf); |
| 152 | postEvent.size = ConsoleEventHeaderSize + dStrlen(inBuf) + 1; |
| 153 | Con::printf("=> %s",postEvent.data); |
| 154 | Game->postEvent(postEvent); |
| 155 | // clear the buffer |
| 156 | clearInBuf(); |
| 157 | // display the prompt. Note that we're using real printf, not Con::printf... |
| 158 | printf("=> "); |
| 159 | } |
| 160 | else |
| 161 | { |
| 162 | // add it to the buffer. |
| 163 | inBuf[inBufPos++] = c; |
| 164 | // if we're full, clear & warn. |
| 165 | if(inBufPos >= MaxConsoleLineSize-1) |
| 166 | { |
| 167 | clearInBuf(); |
| 168 | Con::warnf("Line to long, discarding the last 512 bytes..."); |
| 169 | } |
| 170 | } |
| 171 | } |
| 172 | Con::printf("Console Input Thread Stopped"); |
| 173 | } |