MCPcopy Create free account
hub / github.com/ValveSoftware/GameNetworkingSockets / LocalUserInput_Init

Function LocalUserInput_Init

examples/example_chat.cpp:149–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147std::thread *s_pThreadUserInput = nullptr;
148
149void LocalUserInput_Init()
150{
151 s_pThreadUserInput = new std::thread( []()
152 {
153 while ( !g_bQuit )
154 {
155 char szLine[ 4000 ];
156 if ( !fgets( szLine, sizeof(szLine), stdin ) )
157 {
158 // Well, you would hope that you could close the handle
159 // from the other thread to trigger this. Nope.
160 if ( g_bQuit )
161 return;
162 g_bQuit = true;
163 Printf( "Failed to read on stdin, quitting\n" );
164 break;
165 }
166
167 mutexUserInputQueue.lock();
168 queueUserInput.push( std::string( szLine ) );
169 mutexUserInputQueue.unlock();
170 }
171 } );
172}
173
174void LocalUserInput_Kill()
175{

Callers 1

mainFunction · 0.85

Calls 3

lockMethod · 0.80
unlockMethod · 0.80
PrintfFunction · 0.70

Tested by

no test coverage detected