void Dialog::config_key(int pad, int key) { bool captured = false; u32 key_pressed = 0; // I don't have any guarantee that not-yet-pressed state is egual to released state GamePad::UpdateReleaseState(); while (!captured) { std::vector<GamePad *>::iterator itjoy; if (PollX11KeyboardMouseEvent(key_pressed)) { // special case for keyboard/mouse to handle multiple keys // Note: key_pressed == 0 when ESC is hit to abort the capture if (key_pressed > 0) { clear_key(pad, key); set_keyboard_key(pad, key_pressed, key); m_simulatedKeys[pad][key] = key_pressed; m_map_images[pad][key_pressed] = key; } captured = true; } else { GamePad::UpdateGamePadState(); itjoy = s_vgamePad.begin(); while ((itjoy != s_vgamePad.end()) && (!captured)) { if ((*itjoy)->PollButtons(key_pressed)) { clear_key(pad, key); set_key(pad, key, key_pressed); m_map_images[pad][key_pressed] = key; captured = true; } else if ((*itjoy)->PollAxes(key_pressed)) { clear_key(pad, key); set_key(pad, key, key_pressed); m_map_images[pad][key_pressed] = key; captured = true; } else if ((*itjoy)->PollHats(key_pressed)) { clear_key(pad, key); set_key(pad, key, key_pressed); m_map_images[pad][key_pressed] = key; captured = true; } ++itjoy; } } } m_bt_gamepad[pad][key]->SetLabel( KeyName(pad, key, m_simulatedKeys[pad][key]).c_str()); }
void config_key(int pad, int key) { bool captured = false; u32 key_pressed = 0; // save the joystick states UpdateJoysticks(); while (!captured) { vector<JoystickInfo*>::iterator itjoy; if (PollX11KeyboardMouseEvent(key_pressed)) { // special case for keyboard/mouse to handle multiple keys // Note: key_pressed == 0 when ESC is hit to abort the capture if (key_pressed > 0) set_keyboad_key(pad, key_pressed, key); captured = true; break; } SDL_JoystickUpdate(); itjoy = s_vjoysticks.begin(); while ((itjoy != s_vjoysticks.end()) && (!captured)) { if ((*itjoy)->PollButtons(key_pressed)) { set_key(pad, key, key_pressed); captured = true; break; } if ((*itjoy)->PollAxes(key_pressed)) { set_key(pad, key, key_pressed); captured = true; break; } if ((*itjoy)->PollHats(key_pressed)) { set_key(pad, key, key_pressed); captured = true; break; } itjoy++; } } PAD_LOG("%s\n", KeyName(pad, key).c_str()); }