void wait_noinput( JE_boolean keyboard, JE_boolean mouse, JE_boolean joystick ) { service_SDL_events(false); while ((keyboard && keydown) || (mouse && mousedown) || (joystick && joydown)) { SDL_Delay(SDL_POLL_INTERVAL); poll_joysticks(); service_SDL_events(false); if (isNetworkGame) network_check(); } }
void wait_noinput( JE_boolean keyboard, JE_boolean mouse, JE_boolean joystick ) { service_SDL_events(false); while ((keyboard && keydown) || (mouse && mousedown) || (joystick && joydown)) { JE_showVGA(); // Must update screen on Android to get new mouse events SDL_Delay(SDL_POLL_INTERVAL); poll_joysticks(); service_SDL_events(false); #ifdef WITH_NETWORK if (isNetworkGame) network_check(); #endif } }
uint32_t JoystickOSX::process_joysticks(uint32_t p_last_id) { poll_joysticks(); for (int i = 0; i < device_list.size(); i++) { joystick &joy = device_list[i]; for (int j = 0; j < joy.axis_elements.size(); j++) { rec_element &elem = joy.axis_elements[j]; int value = joy.get_hid_element_state(&elem); p_last_id = input->joy_axis(p_last_id, joy.id, j, axis_correct(value, elem.min, elem.max)); } for (int j = 0; j < joy.button_elements.size(); j++) { int value = joy.get_hid_element_state(&joy.button_elements[j]); p_last_id = input->joy_button(p_last_id, joy.id, j, (value >= 1)); } for (int j = 0; j < joy.hat_elements.size(); j++) { rec_element &elem = joy.hat_elements[j]; int value = joy.get_hid_element_state(&elem); int hat_value = process_hat_value(elem.min, elem.max, value); p_last_id = input->joy_hat(p_last_id, joy.id, hat_value); } if (joy.ffservice) { uint64_t timestamp = input->get_joy_vibration_timestamp(joy.id); if (timestamp > joy.ff_timestamp) { Vector2 strength = input->get_joy_vibration_strength(joy.id); float duration = input->get_joy_vibration_duration(joy.id); if (strength.x == 0 && strength.y == 0) { joystick_vibration_stop(joy.id, timestamp); } else { float gain = MAX(strength.x, strength.y); joystick_vibration_start(joy.id, gain, duration, timestamp); } } } } return p_last_id; }
// helps us be lazy by pretending joysticks are a keyboard (useful for menus) void push_joysticks_as_keyboard( void ) { const SDLKey confirm = SDLK_RETURN, cancel = SDLK_ESCAPE; const SDLKey direction[4] = { SDLK_UP, SDLK_RIGHT, SDLK_DOWN, SDLK_LEFT }; poll_joysticks(); for (int j = 0; j < joysticks; j++) { if (!joystick[j].input_pressed) continue; if (joystick[j].confirm) push_key(confirm); if (joystick[j].cancel) push_key(cancel); for (uint d = 0; d < COUNTOF(joystick[j].direction_pressed); d++) { if (joystick[j].direction_pressed[d]) push_key(direction[d]); } } }
JE_boolean JE_anyButton( void ) { poll_joysticks(); service_SDL_events(true); return newkey || mousedown || joydown; }