コード例 #1
0
ファイル: poll_input.c プロジェクト: Jack19881218/cavan
int main(int argc, char *argv[])
{
	int ret;
	const char *dev_path;
	char name[64];
	struct cavan_input_service service;

	assert(argc < 3);

	if (argc > 1)
	{
		if (file_test(argv[1], "c") < 0 && text_is_number(argv[1]))
		{
			sprintf(name, "/dev/input/event%s", argv[1]);
			dev_path = name;
		}
		else
		{
			dev_path = argv[1];
		}
	}
	else
	{
		dev_path = NULL;
	}

	cavan_input_service_init(&service, cavan_event_simple_matcher);
	service.lcd_width = service.lcd_height = 100;
	ret = cavan_input_service_start(&service, (void *) dev_path);
	if (ret < 0)
	{
		pr_error_info("cavan_input_service_start");
		return ret;
	}

	cavan_input_service_join(&service);
	cavan_input_service_stop(&service);

	return 0;
}
コード例 #2
0
ファイル: swan_upgrade.c プロジェクト: FuangCao/cavan
static void swan_show_picture(const char *state, int reset)
{
	unsigned int i;
	struct cavan_input_service service;

	close_console();

	if (cavan_fb_bmp_view2(format_text(BMP_PATH "/%s.bmp", state), NULL) < 0) {
		cavan_fb_bmp_view2(format_text(BACKUP_BMP_PATH "/%s.bmp", state), NULL);
	}

	if (reset == 0) {
		sleep(5);
		return;
	}

	print_string("Press \"Power\" reset the system");
	cavan_input_service_init(&service, swan_keypad_match);
	service.handler = swan_keypad_handler;
	cavan_input_service_start(&service, NULL);

	print_string("Press \"Enter\" into command line");
	for (i = REBOOT_TIMEOUT; i > 0; i--) {
		int c;

		print("Reboot remain time %d(s)  \r", i);

		c = cavan_getchar_timed(1, 0);

		if (c == '\n') {
			cavan_input_service_stop(&service);
			return;
		}
	}

	println("\nSystem Rebooting ...");
	sync();
	reboot(RB_AUTOBOOT);
}