Exemplo n.º 1
0
/**
 *
 *  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);
			}
		}
	}
}
Exemplo n.º 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);
			}
		}
	}
}