Example #1
0
/* main */
int main(int argc, char * argv[])
{
	int o;
	KeyboardPrefs prefs;
	char * p;

	if(setlocale(LC_ALL, "") == NULL)
		_error("setlocale", 1);
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);
	memset(&prefs, 0, sizeof(prefs));
	gtk_init(&argc, &argv);
	while((o = getopt(argc, argv, "df:m:npwx")) != -1)
		switch(o)
		{
			case 'd':
				prefs.mode = KEYBOARD_MODE_DOCKED;
				break;
			case 'f':
				prefs.font = optarg;
				break;
			case 'm':
				prefs.monitor = strtol(optarg, &p, 10);
				if(optarg[0] == '\0' || *p != '\0')
					return _usage();
				break;
			case 'n':
				prefs.wait = 1;
				break;
			case 'p':
				prefs.mode = KEYBOARD_MODE_POPUP;
				break;
			case 'w':
				prefs.mode = KEYBOARD_MODE_WINDOWED;
				break;
			case 'x':
				prefs.mode = KEYBOARD_MODE_EMBEDDED;
				break;
			default:
				return _usage();
		}
	if(optind != argc)
		return _usage();
	return (_keyboard(&prefs) == 0) ? 0 : 2;
}
Example #2
0
void handle_keyboard(unsigned char key, int x, int y) {
	switch (key) {
	case 'Q':
	case 'q':
	case 'Z':
	case 'z':
		_end();
		break;
	case 'h':
	case 'H':
		printf("\'?\' for help\n");
		camera->init();
		break;
	case 't':
	case 'T':
		windowdump = 1;
		break;
	case 'r': // Toggle image recording
	case 'R':
		movierecord = !movierecord;
		break;
	case 'w': // Translate camera up
	case 'W':
		camera->key_up();
		break;
	case 's': // Translate camera down
	case 'S':
		camera->key_down();
		break;
	case 'a': // Translate camera left
	case 'A':
		camera->key_left();
		break;
	case 'd': // Translate camera right
	case 'D':
		camera->key_right();
		break;
	case 'o':
	case 'O':
		rotate = !rotate;
	default:
		_keyboard(key);		// Check for user-defined key controls
	}
}