mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:53:50 +00:00
25 lines
760 B
C++
25 lines
760 B
C++
|
#include <Script/Script.hpp>
|
||
|
#include <Kbhit.h>
|
||
|
using namespace std;
|
||
|
namespace mwmp_input {
|
||
|
string windowInputBuffer;
|
||
|
void handler() {
|
||
|
char c;
|
||
|
#ifndef WIN32 // on WIndows conio.h getch() and kbhit() are deprecated, use _getch() and _kbhit() instead
|
||
|
while (kbhit()) {
|
||
|
c = getch();
|
||
|
#else
|
||
|
while (_kbhit()) {
|
||
|
c = _getch();
|
||
|
#endif
|
||
|
cout << c << flush;
|
||
|
if (c == '\n' || c == '\r') { // handle carriage return as new line on Windows
|
||
|
cout << endl;
|
||
|
Script::Call<Script::CallbackIdentity("OnServerWindowInput")>(windowInputBuffer.c_str());
|
||
|
windowInputBuffer.assign("");
|
||
|
}
|
||
|
else windowInputBuffer += c;
|
||
|
}
|
||
|
}
|
||
|
}
|