sint32 widget_is_pressed(rct_window *w, rct_widgetindex widgetIndex) { if (w->pressed_widgets & (1LL << widgetIndex)) { return 1; } if (input_get_state() == INPUT_STATE_WIDGET_PRESSED || input_get_state() == INPUT_STATE_DROPDOWN_ACTIVE) { if (!(input_test_flag(INPUT_FLAG_WIDGET_PRESSED))) return 0; if (gPressedWidget.window_classification != w->classification) return 0; if (gPressedWidget.window_number != w->number) return 0; if (gPressedWidget.widget_index != widgetIndex) return 0; return 1; } return 0; }
void input_handle_keyboard(bool isTitle) { if (gOpenRCT2Headless) { return; } if (!gConsoleOpen) { if (!isTitle) { // Handle mouse scrolling if (input_get_state() == INPUT_STATE_NORMAL && gConfigGeneral.edge_scrolling) { if (!(gInputPlaceObjectModifier & (PLACE_OBJECT_MODIFIER_SHIFT_Z | PLACE_OBJECT_MODIFIER_COPY_Z))) { game_handle_edge_scroll(); } } } // Handle modifier keys and key scrolling gInputPlaceObjectModifier = PLACE_OBJECT_MODIFIER_NONE; const uint8 * keysState = context_get_keys_state(); if (keysState[SDL_SCANCODE_LSHIFT] || keysState[SDL_SCANCODE_RSHIFT]) { gInputPlaceObjectModifier |= PLACE_OBJECT_MODIFIER_SHIFT_Z; } if (keysState[SDL_SCANCODE_LCTRL] || keysState[SDL_SCANCODE_RCTRL]) { gInputPlaceObjectModifier |= PLACE_OBJECT_MODIFIER_COPY_Z; } if (keysState[SDL_SCANCODE_LALT] || keysState[SDL_SCANCODE_RALT]) { gInputPlaceObjectModifier |= 4; } #ifdef __MACOSX__ if (keysState[SDL_SCANCODE_LGUI] || keysState[SDL_SCANCODE_RGUI]) { gInputPlaceObjectModifier |= 8; } #endif if (!isTitle) { game_handle_key_scroll(); } } if (gConfigGeneral.use_virtual_floor) { if (gInputPlaceObjectModifier & (PLACE_OBJECT_MODIFIER_COPY_Z | PLACE_OBJECT_MODIFIER_SHIFT_Z)) virtual_floor_enable(); else virtual_floor_disable(); } // Handle key input sint32 key; while (!gOpenRCT2Headless && (key = get_next_key()) != 0) { if (key == 255) continue; // Reserve backtick for console if (key == SDL_SCANCODE_GRAVE) { if ((gConfigGeneral.debugging_tools && !context_is_input_active()) || gConsoleOpen) { window_cancel_textbox(); console_toggle(); } continue; } else if (gConsoleOpen) { input_handle_console(key); continue; } else if (!isTitle && gChatOpen) { input_handle_chat(key); continue; } key |= gInputPlaceObjectModifier << 8; rct_window * w = window_find_by_class(WC_TEXTINPUT); if (w != nullptr) { char keychar = input_scancode_to_rct_keycode(key & 0xFF); window_text_input_key(w, keychar); } else if (!gUsingWidgetTextBox) { w = window_find_by_class(WC_CHANGE_KEYBOARD_SHORTCUT); if (w != nullptr) { keyboard_shortcuts_set(key); window_close_by_class(WC_CHANGE_KEYBOARD_SHORTCUT); window_invalidate_by_class(WC_KEYBOARD_SHORTCUT_LIST); } else { keyboard_shortcut_handle(key); } } } }