/** * * rct2: 0x006E3B43 */ void title_handle_keyboard_input() { rct_window *w; int key; if (gOpenRCT2Headless) { return; } if (!gConsoleOpen) { // Handle modifier keys and key scrolling gInputPlaceObjectModifier = PLACE_OBJECT_MODIFIER_NONE; if (RCT2_GLOBAL(0x009E2B64, uint32) != 1) { if (gKeysState[SDL_SCANCODE_LSHIFT] || gKeysState[SDL_SCANCODE_RSHIFT]) gInputPlaceObjectModifier |= PLACE_OBJECT_MODIFIER_SHIFT_Z; if (gKeysState[SDL_SCANCODE_LCTRL] || gKeysState[SDL_SCANCODE_RCTRL]) gInputPlaceObjectModifier |= PLACE_OBJECT_MODIFIER_COPY_Z; if (gKeysState[SDL_SCANCODE_LALT] || gKeysState[SDL_SCANCODE_RALT]) gInputPlaceObjectModifier |= 4; #ifdef __MACOSX__ if (gKeysState[SDL_SCANCODE_LGUI] || gKeysState[SDL_SCANCODE_RGUI]) { gInputPlaceObjectModifier |= 8; } #endif } } while ((key = get_next_key()) != 0) { if (key == 255) continue; // Reserve backtick for console if (key == SDL_SCANCODE_GRAVE) { if (gConfigGeneral.debugging_tools || gConsoleOpen) { window_cancel_textbox(); console_toggle(); } continue; } else if (gConsoleOpen) { console_input(key); continue; } key |= gInputPlaceObjectModifier << 8; w = window_find_by_class(WC_CHANGE_KEYBOARD_SHORTCUT); if (w != NULL) { keyboard_shortcut_set(key); } else { w = window_find_by_class(WC_TEXTINPUT); if (w != NULL) { window_text_input_key(w, key); } if (key == gShortcutKeys[SHORTCUT_SCREENSHOT]) { keyboard_shortcut_handle_command(SHORTCUT_SCREENSHOT); } } } }
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); } } } }
/** * * rct2: 0x006E95F9 */ static void input_widget_left(sint32 x, sint32 y, rct_window *w, rct_widgetindex widgetIndex) { rct_windowclass windowClass = 255; rct_windownumber windowNumber = 0; rct_widget *widget; if (w != NULL) { windowClass = w->classification; windowNumber = w->number; } window_close_by_class(WC_ERROR); window_close_by_class(WC_TOOLTIP); // Window might have changed position in the list, therefore find it again w = window_find_by_number(windowClass, windowNumber); if (w == NULL) return; w = window_bring_to_front(w); if (widgetIndex == -1) return; if (windowClass != gCurrentTextBox.window.classification || windowNumber != gCurrentTextBox.window.number || widgetIndex != gCurrentTextBox.widget_index) { window_cancel_textbox(); } widget = &w->widgets[widgetIndex]; switch (widget->type) { case WWT_FRAME: case WWT_RESIZE: if (window_can_resize(w) && (x >= w->x + w->width - 19 && y >= w->y + w->height - 19)) input_window_resize_begin(w, widgetIndex, x, y); break; case WWT_VIEWPORT: _inputState = INPUT_STATE_VIEWPORT_LEFT; gInputDragLastX = x; gInputDragLastY = y; _dragWidget.window_classification = windowClass; _dragWidget.window_number = windowNumber; if (_inputFlags & INPUT_FLAG_TOOL_ACTIVE) { w = window_find_by_number( gCurrentToolWidget.window_classification, gCurrentToolWidget.window_number ); if (w != NULL) { window_event_tool_down_call(w, gCurrentToolWidget.widget_index, x, y); _inputFlags |= INPUT_FLAG_4; } } break; case WWT_CAPTION: input_window_position_begin(w, widgetIndex, x, y); break; case WWT_SCROLL: input_scroll_begin(w, widgetIndex, x, y); break; default: if (widget_is_enabled(w, widgetIndex) && !widget_is_disabled(w, widgetIndex)) { audio_play_sound_panned(SOUND_CLICK_1, w->x + (widget->left + widget->right) / 2, 0, 0, 0); // Set new cursor down widget gPressedWidget.window_classification = windowClass; gPressedWidget.window_number = windowNumber; gPressedWidget.widget_index = widgetIndex; _inputFlags |= INPUT_FLAG_WIDGET_PRESSED; _inputState = INPUT_STATE_WIDGET_PRESSED; _clickRepeatTicks = 1; widget_invalidate_by_number(windowClass, windowNumber, widgetIndex); window_event_mouse_down_call(w, widgetIndex); } break; } }
/** * * rct2: 0x006E3B43 */ void game_handle_keyboard_input() { rct_window *w; sint32 key; if (!gConsoleOpen) { // Handle mouse scrolling if (_inputState == 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; if (gKeysState[SDL_SCANCODE_LSHIFT] || gKeysState[SDL_SCANCODE_RSHIFT]) { gInputPlaceObjectModifier |= PLACE_OBJECT_MODIFIER_SHIFT_Z; } if (gKeysState[SDL_SCANCODE_LCTRL] || gKeysState[SDL_SCANCODE_RCTRL]) { gInputPlaceObjectModifier |= PLACE_OBJECT_MODIFIER_COPY_Z; } if (gKeysState[SDL_SCANCODE_LALT] || gKeysState[SDL_SCANCODE_RALT]) { gInputPlaceObjectModifier |= 4; } #ifdef __MACOSX__ if (gKeysState[SDL_SCANCODE_LGUI] || gKeysState[SDL_SCANCODE_RGUI]) { gInputPlaceObjectModifier |= 8; } #endif game_handle_key_scroll(); } // Handle key input while (!gOpenRCT2Headless && (key = get_next_key()) != 0) { if (key == 255) continue; // Reserve backtick for console if (key == SDL_SCANCODE_GRAVE) { if ((gConfigGeneral.debugging_tools && !platform_is_input_active()) || gConsoleOpen) { window_cancel_textbox(); console_toggle(); } continue; } else if (gConsoleOpen) { console_input(key); continue; } else if (gChatOpen) { chat_input(key); continue; } key |= gInputPlaceObjectModifier << 8; w = window_find_by_class(WC_CHANGE_KEYBOARD_SHORTCUT); if (w != NULL) { keyboard_shortcut_set(key); } else { w = window_find_by_class(WC_TEXTINPUT); if (w != NULL) { window_text_input_key(w, key); } else if (!gUsingWidgetTextBox) { keyboard_shortcut_handle(key); } } } }