/** * * 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); } } } }
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: 0x006E3B43 */ void game_handle_keyboard_input() { rct_window *w; int key; // Handle mouse scrolling if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 0) if (RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_EDGE_SCROLLING, uint8) != 0) if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) == 1) if (!(RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) & 3)) game_handle_edge_scroll(); // Handle modifier keys and key scrolling RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) = 0; if (RCT2_GLOBAL(0x009E2B64, uint32) != 1) { if (gKeysState[SDL_SCANCODE_LSHIFT] || gKeysState[SDL_SCANCODE_RSHIFT]) RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) |= 1; if (gKeysState[SDL_SCANCODE_LCTRL] || gKeysState[SDL_SCANCODE_RCTRL]) RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) |= 2; if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 0) game_handle_key_scroll(); } // Handle key input while ((key = get_next_key()) != 0) { if (key == 255) continue; key |= RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) << 8; w = window_find_by_id(WC_CHANGE_KEYBOARD_SHORTCUT, 0); if (w != NULL) set_shortcut(key); else if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 1) tutorial_stop(); else handle_shortcut(key); } if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 0) return; // Tutorial and the modifier key if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 1) { int eax, ebx, ecx, edx, esi, edi, ebp; RCT2_CALLFUNC_X(0x0066EEB4, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp); eax &= 0xFF; RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) = eax; if (RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) & 4) { window_tooltip_close(); if ((w = window_get_main()) != NULL) { RCT2_CALLPROC_X(0x006EA2AA, 0, 0, 0, 0, (int)w, RCT2_GLOBAL(0x009DEA72, uint16), 0); RCT2_GLOBAL(0x009DEA72, uint16)++; } } } else { if (!(RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) & 4)) { window_tooltip_close(); if ((w = window_get_main()) != NULL) { RCT2_CALLPROC_X(0x006EA2AA, 0, 0, 0, 0, (int)w, RCT2_GLOBAL(0x009DEA72, uint16), 0); RCT2_GLOBAL(0x009DEA72, uint16)++; } } // Write tutorial input RCT2_CALLPROC_X(0x0066EEE1, RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8), 0, 0, 0, 0, 0, 0); } }