Пример #1
0
static void input_handle_console(sint32 key)
{
    CONSOLE_INPUT input = CONSOLE_INPUT_NONE;
    switch (key)
    {
    case SDL_SCANCODE_ESCAPE:
        input = CONSOLE_INPUT_LINE_CLEAR;
        break;
    case SDL_SCANCODE_RETURN:
        input = CONSOLE_INPUT_LINE_EXECUTE;
        break;
    case SDL_SCANCODE_UP:
        input = CONSOLE_INPUT_HISTORY_PREVIOUS;
        break;
    case SDL_SCANCODE_DOWN:
        input = CONSOLE_INPUT_HISTORY_NEXT;
        break;
    case SDL_SCANCODE_PAGEUP:
        input = CONSOLE_INPUT_SCROLL_PREVIOUS;
        break;
    case SDL_SCANCODE_PAGEDOWN:
        input = CONSOLE_INPUT_SCROLL_NEXT;
        break;
    }
    if (input != CONSOLE_INPUT_NONE)
    {
        console_input(input);
    }
}
Пример #2
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);
			}
		}
	}
}
Пример #3
0
void view_loop_input(int tick)
{
		// timing
		
	if (tick<view.time.input_tick) return;
	view.time.input_tick=tick+input_tick_rate;
	
		// pump input
		
	input_event_pump();

		// player input
	
	player_get_input(tick);
	
		// system input
	
	console_input();
	menu_input();
	file_input();
	debug_input();
}
Пример #4
0
int __cdecl main(int argc, char **argv)
{
	const char *username = argc > 1 ? argv[1] : NULL;
	const char *blob = argc > 2 ? argv[2] : NULL;
	const char *password = NULL;
	int selftest = argc > 3 ? !strcmp(argv[3], "selftest") : 0;
	char username_buf[256];
	char password_buf[256];
	int r;
	int next_timeout = 0;
	DWORD ev;
	DWORD mode;

	events[0] = CreateEvent(NULL, FALSE, FALSE, NULL);
	events[1] = GetStdHandle(STD_INPUT_HANDLE);

	printf("Using libspotify %s\n", sp_build_id());

	if (username == NULL) {
		printf("Username: (just press enter to login with stored credentials): ");
		fflush(stdout);
		fgets(username_buf, sizeof(username_buf), stdin);
		trim(username_buf);
		if(username_buf[0] == 0) {
			username = NULL;
		} else {
			username = username_buf;
		}
	}

	// If a username was supplied but no blob, prompt for password
	if (username != NULL && blob == NULL) {
		printf("Password: "******"Unable to set console mode err=%d\n", GetLastError());
			exit(1);
		}

		fgets(password_buf, sizeof(password_buf), stdin);
		trim(password_buf);
		password = password_buf;
		printf("\r\n");
	}

	if ((r = spshell_init(username, password, blob, selftest)) != 0)
		exit(r);

	if (!SetConsoleMode(events[1], ENABLE_PROCESSED_INPUT)) {
		printf("Unable to set console mode err=%d\n", GetLastError());
		exit(1);
	}

	while(!is_logged_out) {
		ev = WaitForMultipleObjects(1 + enable_console, events, FALSE, next_timeout > 0 ? next_timeout : INFINITE);
		switch (ev) {
		case WAIT_OBJECT_0 + 0:
		case WAIT_TIMEOUT:
			do {
				sp_session_process_events(g_session, &next_timeout);
			} while (next_timeout == 0);

			if(g_selftest)
				test_process();
			break;

		case WAIT_OBJECT_0 + 1:
			console_input();
			break;
		}
	}
	printf("Logged out\n");
	sp_session_release(g_session);
	printf("Exiting...\n");
	return 0;
}
Пример #5
0
void xencons_rx(char *buf, unsigned len, struct pt_regs *regs)
{
    console_input(buf, len);
}
Пример #6
0
int __cdecl main(int argc, char **argv)
{
	const char *username = argc > 1 ? argv[1] : NULL;
	const char *password = argc > 2 ? argv[2] : NULL;
	char username_buf[256];
	char password_buf[256];
	int r;
	int next_timeout = 0;
	DWORD ev;

	events[0] = CreateEvent(NULL, FALSE, FALSE, NULL);
	events[1] = GetStdHandle(STD_INPUT_HANDLE);

	if (username == NULL) {
		printf("Username: "******"Password: "******"Unable to set console mode err=%d\n", GetLastError());
			exit(1);
		}

		fgets(password_buf, sizeof(password_buf), stdin);
		trim(password_buf);
		password = password_buf;
		printf("\r\n");
	}

	if ((r = spshell_init(username, password)) != 0)
		exit(r);

	if (!SetConsoleMode(events[1], ENABLE_PROCESSED_INPUT)) {
		printf("Unable to set console mode err=%d\n", GetLastError());
		exit(1);
	}

	while(1) {
		ev = WaitForMultipleObjects(1 + enable_console, events, FALSE, next_timeout > 0 ? next_timeout : INFINITE);
		switch (ev) {
		case WAIT_OBJECT_0 + 0:
			do {
				sp_session_process_events(g_session, &next_timeout);
			} while (next_timeout == 0);
			break;

		case WAIT_OBJECT_0 + 1:
			console_input();
			break;
		}
	}
}
Пример #7
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);
			}
		}
	}
}