MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / Input_ReadInputFromFile

Function Input_ReadInputFromFile

src/input/input.c:311–359  ·  view source on GitHub ↗

Read input event from file. */

Source from the content-addressed store, hash-verified

309
310/** Read input event from file. */
311static void Input_ReadInputFromFile(void)
312{
313 uint16 value;
314 uint16 mouseBuffer[2];
315
316 if (g_mouseMode == INPUT_MOUSE_MODE_NORMAL || g_mouseMode != INPUT_MOUSE_MODE_PLAY) return;
317
318 if (File_Read(g_mouseFileID, mouseBuffer, 4) != 4) {
319 Warning("Input_ReadInputFromFile(): File_Read() error.\n");
320 return;
321 }
322 Debug(" time=%hu value=0x%04hx\n", mouseBuffer[1], mouseBuffer[0]);
323
324 g_mouseRecordedTimer = mouseBuffer[1];
325 value = g_mouseInputValue = mouseBuffer[0];
326
327 if ((value & 0xFF) != 0x2D) {
328 uint8 idx, bit;
329
330 idx = (value & 0xFF) >> 3;
331 bit = 1 << (value & 7);
332
333 s_activeInputMap[idx] &= ~bit;
334 if ((value & 0x800) == 0) s_activeInputMap[idx] |= bit;
335
336 if ((value & 0xFF) < 0x41 || (value & 0xFF) > 0x44) {
337 g_timerInput = 0;
338 return;
339 }
340
341 value -= 0x41;
342 if ((value & 0xFF) <= 0x2) {
343 g_prevButtonState &= ~(1 << (value & 0xFF));
344 g_prevButtonState |= (((value & 0x800) >> (3+8)) ^ 1) << (value & 0xFF);
345 }
346 }
347
348 if (File_Read(g_mouseFileID, mouseBuffer, 4) != 4) {
349 Warning("Input_ReadInputFromFile(): File_Read() error.\n");
350 return;
351 }
352 Debug(" mouseX=%hu mouseY=%hu\n", mouseBuffer[0], mouseBuffer[1]);
353
354 g_mouseX = g_mouseRecordedX = mouseBuffer[0];
355 value = g_mouseY = g_mouseRecordedY = mouseBuffer[1];
356
357 Mouse_HandleMovementIfMoved(value);
358 g_timerInput = 0;
359}
360
361/**
362 * Get input, and add it to the history.

Callers 3

Input_AddHistoryFunction · 0.85
Input_WaitFunction · 0.85
Input_WaitForValidInputFunction · 0.85

Calls 4

File_ReadFunction · 0.85
WarningFunction · 0.50
DebugFunction · 0.50

Tested by

no test coverage detected