Пример #1
0
static void input_handle_chat(sint32 key)
{
    CHAT_INPUT input = CHAT_INPUT_NONE;
    switch (key)
    {
    case SDL_SCANCODE_ESCAPE:
        input = CHAT_INPUT_CLOSE;
        break;
    case SDL_SCANCODE_RETURN:
        input = CHAT_INPUT_SEND;
        break;
    }
    if (input != CHAT_INPUT_NONE)
    {
        chat_input(input);
    }
}
Пример #2
0
/**
 *
 *  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);
			}
		}
	}
}