/* * Updates the state of the input queue */ void IN_Update(void) { SDL_Event event; static int IN_Update_Flag; int bstate; /* Protection against multiple calls */ if (IN_Update_Flag == 1) { return; } IN_Update_Flag = 1; while (SDL_PollEvent(&event)) { IN_GetEvent(&event); } /* Mouse button processing. Button 4 and 5 are the mousewheel and thus not processed here. */ if (!mx && !my) { SDL_GetRelativeMouseState(&mx, &my); } mouse_buttonstate = 0; bstate = SDL_GetMouseState(NULL, NULL); if (SDL_BUTTON(1) & bstate) { mouse_buttonstate |= (1 << 0); } if (SDL_BUTTON(3) & bstate) { mouse_buttonstate |= (1 << 1); } if (SDL_BUTTON(2) & bstate) { mouse_buttonstate |= (1 << 2); } if (SDL_BUTTON(6) & bstate) { mouse_buttonstate |= (1 << 3); } if (SDL_BUTTON(7) & bstate) { mouse_buttonstate |= (1 << 4); } /* Grab and ungrab the mouse if the * console is opened */ if (in_grab->value == 2) { if (old_windowed_mouse != windowed_mouse->value) { old_windowed_mouse = windowed_mouse->value; if (!windowed_mouse->value) { SDL_WM_GrabInput(SDL_GRAB_OFF); } else { SDL_WM_GrabInput(SDL_GRAB_ON); } } } else if (in_grab->value == 1) { SDL_WM_GrabInput(SDL_GRAB_ON); } else { SDL_WM_GrabInput(SDL_GRAB_OFF); } /* Process the key events */ while (keyq_head != keyq_tail) { in_state->Key_Event_fp(keyq[keyq_tail].key, keyq[keyq_tail].down); keyq_tail = (keyq_tail + 1) & 127; } IN_Update_Flag = 0; }
/* * Updates the state of the input queue */ void IN_Update(void) { SDL_Event event; static int IN_Update_Flag; int bstate; /* Protection against multiple calls */ if (IN_Update_Flag == 1) { return; } IN_Update_Flag = 1; #if defined(WIZ) || defined(CAANOO) uint32_t key; uint8_t update; uint8_t button; uint8_t state; SDLKey keymap; GPH_Input(); for (button=0; button<GPH_MAX_BUTTONS; button++) { keymap = gph_map[button]; state = GPH_GetButttonState( GPH_BUTTON(button) ) ; if (state == GPH_RELEASED_TO_PRESSED) { KeyStates[keymap] = 1; update = 1; printf( "GPH press %d\n", button ); } else if (state == GPH_PRESSED_TO_RELEASED) { if (KeyStates[keymap]) { KeyStates[keymap] = 0; update = 1; printf( "GPH release %d\n", button ); } } else { update = 0; } if (update) { /* Get the pressed key and add it to the key list */ key = IN_TranslateSDLtoQ2Key(keymap); if (key) { keyq[keyq_head].key = key; keyq[keyq_head].down = KeyStates[keymap] ? true : false; keyq_head = (keyq_head + 1) & 127; } } } #else while (SDL_PollEvent(&event)) { IN_GetEvent(&event); } #endif /* Mouse button processing. Button 4 and 5 are the mousewheel and thus not processed here. */ if (!mx && !my) { SDL_GetRelativeMouseState(&mx, &my); } mouse_buttonstate = 0; bstate = SDL_GetMouseState(NULL, NULL); if (SDL_BUTTON(1) & bstate) { mouse_buttonstate |= (1 << 0); } if (SDL_BUTTON(3) & bstate) { mouse_buttonstate |= (1 << 1); } if (SDL_BUTTON(2) & bstate) { mouse_buttonstate |= (1 << 2); } if (SDL_BUTTON(6) & bstate) { mouse_buttonstate |= (1 << 3); } if (SDL_BUTTON(7) & bstate) { mouse_buttonstate |= (1 << 4); } /* Grab and ungrab the mouse if the console is opened */ if (in_grab->value == 2) { if (old_windowed_mouse != windowed_mouse->value) { old_windowed_mouse = windowed_mouse->value; if (!windowed_mouse->value) { SDL_WM_GrabInput(SDL_GRAB_OFF); } else { SDL_WM_GrabInput(SDL_GRAB_ON); } } } else if (in_grab->value == 1) { SDL_WM_GrabInput(SDL_GRAB_ON); } else { SDL_WM_GrabInput(SDL_GRAB_OFF); } /* Process the key events */ while (keyq_head != keyq_tail) { in_state->Key_Event_fp(keyq[keyq_tail].key, keyq[keyq_tail].down); keyq_tail = (keyq_tail + 1) & 127; } IN_Update_Flag = 0; }
/* * Updates the state of the input queue */ void IN_Update(void) { SDL_Event event; static int IN_Update_Flag; int bstate; qboolean want_grab; /* Protection against multiple calls */ if (IN_Update_Flag == 1) { return; } IN_Update_Flag = 1; while (SDL_PollEvent(&event)) { IN_GetEvent(&event); } /* Mouse button processing. Button 4 and 5 are the mousewheel and thus not processed here. */ if (!mx && !my) { SDL_GetRelativeMouseState(&mx, &my); } mouse_buttonstate = 0; bstate = SDL_GetMouseState(NULL, NULL); if (SDL_BUTTON(1) & bstate) { mouse_buttonstate |= (1 << 0); } if (SDL_BUTTON(3) & bstate) { mouse_buttonstate |= (1 << 1); } if (SDL_BUTTON(2) & bstate) { mouse_buttonstate |= (1 << 2); } if (SDL_BUTTON(6) & bstate) { mouse_buttonstate |= (1 << 3); } if (SDL_BUTTON(7) & bstate) { mouse_buttonstate |= (1 << 4); } /* Grab and ungrab the mouse if the * console or the menu is opened */ want_grab = (vid_fullscreen->value || in_grab->value == 1 || (in_grab->value == 2 && windowed_mouse->value)); if (have_grab != want_grab) { SDL_WM_GrabInput((want_grab ? SDL_GRAB_ON : SDL_GRAB_OFF)); have_grab = want_grab; } /* Process the key events */ while (keyq_head != keyq_tail) { in_state->Key_Event_fp(keyq[keyq_tail].key, keyq[keyq_tail].down); keyq_tail = (keyq_tail + 1) & 127; } IN_Update_Flag = 0; }