=== modified file 'src/editor/editorinteractive.cc' --- src/editor/editorinteractive.cc 2016-11-20 11:13:03 +0000 +++ src/editor/editorinteractive.cc 2016-11-22 13:28:09 +0000 @@ -257,7 +257,7 @@ void EditorInteractive::exit() { if (need_save_) { - if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) { + if (SDL_GetModState() & KMOD_CTRL) { end_modal(UI::Panel::Returncodes::kBack); } else { UI::WLMessageBox mmb(this, _("Unsaved Map"), === modified file 'src/editor/ui_menus/categorized_item_selection_menu.h' --- src/editor/ui_menus/categorized_item_selection_menu.h 2016-10-06 14:32:33 +0000 +++ src/editor/ui_menus/categorized_item_selection_menu.h 2016-11-21 16:38:23 +0000 @@ -148,7 +148,7 @@ // TODO(unknown): This code is erroneous. It checks the current key state. What it // needs is the key state at the time the mouse was clicked. See the // usage comment for get_key_state. - const bool multiselect = get_key_state(SDL_SCANCODE_LCTRL) | get_key_state(SDL_SCANCODE_RCTRL); + const bool multiselect = SDL_GetModState() & KMOD_CTRL; if (!t && (!multiselect || tool_->get_nr_enabled() == 1)) checkboxes_[n]->set_state(true); else { === modified file 'src/editor/ui_menus/tool_place_bob_options_menu.cc' --- src/editor/ui_menus/tool_place_bob_options_menu.cc 2016-10-16 09:31:42 +0000 +++ src/editor/ui_menus/tool_place_bob_options_menu.cc 2016-11-21 16:37:50 +0000 @@ -106,7 +106,7 @@ // TODO(unknown): This code is erroneous. It checks the current key state. What it // TODO(unknown): needs is the key state at the time the mouse was clicked. See the // TODO(unknown): usage comment for get_key_state. - const bool multiselect = get_key_state(SDL_SCANCODE_LCTRL) | get_key_state(SDL_SCANCODE_RCTRL); + const bool multiselect = SDL_GetModState() & KMOD_CTRL; if (!t && (!multiselect || pit_.get_nr_enabled() == 1)) { checkboxes_[n]->set_state(true); return; === modified file 'src/ui_basic/window.cc' --- src/ui_basic/window.cc 2016-10-25 08:11:31 +0000 +++ src/ui_basic/window.cc 2016-11-21 16:36:04 +0000 @@ -367,9 +367,7 @@ // TODO(unknown): This code is erroneous. It checks the current key state. What it // needs is the key state at the time the mouse was clicked. See the // usage comment for get_key_state. - if (((get_key_state(SDL_SCANCODE_LCTRL) | get_key_state(SDL_SCANCODE_RCTRL)) && - btn == SDL_BUTTON_LEFT) || - btn == SDL_BUTTON_MIDDLE) + if ((SDL_GetModState() & KMOD_CTRL && btn == SDL_BUTTON_LEFT) || btn == SDL_BUTTON_MIDDLE) is_minimal() ? restore() : minimize(); else if (btn == SDL_BUTTON_LEFT) { dragging_ = true; === modified file 'src/wui/actionconfirm.cc' --- src/wui/actionconfirm.cc 2016-08-04 15:49:05 +0000 +++ src/wui/actionconfirm.cc 2016-11-21 16:19:08 +0000 @@ -187,8 +187,7 @@ if (todestroy && building && iaplayer().can_act(building->owner().player_number()) && (building->get_playercaps() & Widelands::Building::PCap_Bulldoze)) { - game.send_player_bulldoze( - *todestroy, get_key_state(SDL_SCANCODE_LCTRL) << get_key_state(SDL_SCANCODE_RCTRL)); + game.send_player_bulldoze(*todestroy, SDL_GetModState() & KMOD_CTRL); } die(); === modified file 'src/wui/buildingwindow.cc' --- src/wui/buildingwindow.cc 2016-10-24 14:04:00 +0000 +++ src/wui/buildingwindow.cc 2016-11-21 12:20:34 +0000 @@ -317,7 +317,7 @@ =============== */ void BuildingWindow::act_bulldoze() { - if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) { + if (SDL_GetModState() & KMOD_CTRL) { if (building_.get_playercaps() & Widelands::Building::PCap_Bulldoze) igbase().game().send_player_bulldoze(building_); } else { @@ -331,7 +331,7 @@ =============== */ void BuildingWindow::act_dismantle() { - if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) { + if (SDL_GetModState() & KMOD_CTRL) { if (building_.get_playercaps() & Widelands::Building::PCap_Dismantle) igbase().game().send_player_dismantle(building_); } else { @@ -375,7 +375,7 @@ =============== */ void BuildingWindow::act_enhance(Widelands::DescriptionIndex id) { - if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) { + if (SDL_GetModState() & KMOD_CTRL) { if (building_.get_playercaps() & Widelands::Building::PCap_Enhancable) igbase().game().send_player_enhance_building(building_, id); } else { === modified file 'src/wui/fieldaction.cc' --- src/wui/fieldaction.cc 2016-10-26 06:54:00 +0000 +++ src/wui/fieldaction.cc 2016-11-22 13:28:09 +0000 @@ -605,18 +605,17 @@ upcast(InteractivePlayer, iaplayer, &ibase()); if (upcast(Widelands::Flag, flag, node_.field->get_immovable())) { + bool ctrl_pressed = SDL_GetModState() & KMOD_CTRL; if (Building* const building = flag->get_building()) { if (building->get_playercaps() & Building::PCap_Bulldoze) { - if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) { - game->send_player_bulldoze( - *flag, get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)); + if (ctrl_pressed) { + game->send_player_bulldoze(*flag, ctrl_pressed); } else { show_bulldoze_confirm(*iaplayer, *building, flag); } } } else { - game->send_player_bulldoze( - *flag, get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)); + game->send_player_bulldoze(*flag, ctrl_pressed); } } } @@ -656,8 +655,7 @@ Widelands::EditorGameBase& egbase = ibase().egbase(); if (upcast(Widelands::Road, road, egbase.map().get_immovable(node_))) { upcast(Game, game, &ibase().egbase()); - game->send_player_bulldoze( - *road, get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)); + game->send_player_bulldoze(*road, SDL_GetModState() & KMOD_CTRL); } okdialog(); } === modified file 'src/wui/game_options_menu.cc' --- src/wui/game_options_menu.cc 2016-10-26 06:54:00 +0000 +++ src/wui/game_options_menu.cc 2016-11-22 13:28:09 +0000 @@ -130,7 +130,7 @@ } void GameOptionsMenu::clicked_exit_game() { - if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) { + if (SDL_GetModState() & KMOD_CTRL) { igb_.end_modal(UI::Panel::Returncodes::kBack); } else { new GameOptionsMenuExitConfirmBox(*get_parent(), igb_); === modified file 'src/wui/interactive_base.cc' --- src/wui/interactive_base.cc 2016-11-20 08:08:18 +0000 +++ src/wui/interactive_base.cc 2016-11-22 13:28:09 +0000 @@ -502,15 +502,14 @@ else egbase().get_player(road_build_player_)->build_road(*new Widelands::Path(*buildroad_)); - if (allow_user_input() && - (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL))) { + if (allow_user_input() && (SDL_GetModState() & KMOD_CTRL)) { // place flags const Map& map = egbase().map(); const std::vector& c_vector = buildroad_->get_coords(); std::vector::const_iterator const first = c_vector.begin() + 2; std::vector::const_iterator const last = c_vector.end() - 2; - if (get_key_state(SDL_SCANCODE_LSHIFT) || get_key_state(SDL_SCANCODE_RSHIFT)) { + if (SDL_GetModState() & KMOD_SHIFT) { for // start to end (std::vector::const_iterator it = first; it <= last; === modified file 'src/wui/quicknavigation.cc' --- src/wui/quicknavigation.cc 2016-10-24 20:56:32 +0000 +++ src/wui/quicknavigation.cc 2016-11-20 23:50:53 +0000 @@ -89,9 +89,7 @@ unsigned int which = key.sym - SDLK_0; assert(which < 10); - bool ctrl = WLApplication::get()->get_key_state(SDL_SCANCODE_LCTRL) || - WLApplication::get()->get_key_state(SDL_SCANCODE_RCTRL); - if (ctrl) { + if (key.mod & KMOD_CTRL) { set_landmark(which, current_); } else { if (landmarks_[which].set) { === modified file 'src/wui/shipwindow.cc' --- src/wui/shipwindow.cc 2016-10-24 14:04:00 +0000 +++ src/wui/shipwindow.cc 2016-11-21 12:13:49 +0000 @@ -261,7 +261,7 @@ /// Sink the ship if confirmed void ShipWindow::act_sink() { - if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) { + if (SDL_GetModState() & KMOD_CTRL) { igbase_.game().send_player_sink_ship(ship_); } else { show_ship_sink_confirm(dynamic_cast(igbase_), ship_); @@ -275,7 +275,7 @@ /// Cancel expedition if confirmed void ShipWindow::act_cancel_expedition() { - if (get_key_state(SDL_SCANCODE_LCTRL) || get_key_state(SDL_SCANCODE_RCTRL)) { + if (SDL_GetModState() & KMOD_CTRL) { igbase_.game().send_player_cancel_expedition_ship(ship_); } else { show_ship_cancel_expedition_confirm(dynamic_cast(igbase_), ship_);