Пример #1
0
void tpw_event_loop() {
	TPW_EVENT event;

	memset(&event, 0, sizeof(event));
	#if 0

	event.key.unicode = event_sdl.key.keysym.unicode = 0;
	while (SDL_PollEvent(&event_sdl)) {
		switch (event_sdl.type) {
			case SDL_JOYAXISMOTION:
				event.type = TPW_EVENT_TYPE_JOYSTICK_MOVE;
				event.joystick.value = event_sdl.jaxis.value;
				event.joystick.axis = event_sdl.jaxis.axis;
				event.joystick.js_id = event_sdl.jaxis.which;
				break;
			case SDL_ACTIVEEVENT:
				event.type = TPW_EVENT_TYPE_ACTIVE;
				event.active.gain = event_sdl.active.gain;
				event.active.app_active = (event_sdl.active.type == SDL_APPACTIVE);
				break;
			case SDL_QUIT:
				event.type = TPW_EVENT_TYPE_QUIT;
				break;
			default:
				break;
		}	

		tpw_event_push(event);
		event.key.unicode = event_sdl.key.keysym.unicode = 0;
	}

	#endif

	return;
}
Пример #2
0
void tpw_event_loop() {
	SDL_Event event_sdl;
	TPW_EVENT event;

	event.key.unicode = event_sdl.key.keysym.unicode = 0;
	while (SDL_PollEvent(&event_sdl)) {
		switch (event_sdl.type) {
			case SDL_KEYDOWN:
				event.type = TPW_EVENT_TYPE_KEYDOWN;
				event.key.keysym = event_sdl.key.keysym.sym;
				event.key.unicode = event_sdl.key.keysym.unicode;
				break;
			case SDL_KEYUP:
				event.type = TPW_EVENT_TYPE_KEYUP;
				event.key.keysym = event_sdl.key.keysym.sym;
				event.key.unicode = event_sdl.key.keysym.unicode;
				break;
			case SDL_MOUSEMOTION:
				event.type = TPW_EVENT_TYPE_MOUSEMOVE;
				event.mouse.x = event_sdl.motion.x;
				event.mouse.y = event_sdl.motion.y;
				break;
			case SDL_MOUSEBUTTONDOWN:
				event.type = TPW_EVENT_TYPE_MOUSEBTN_DOWN;
				event.mouse.button = event_sdl.button.button;
				break;
			case SDL_MOUSEBUTTONUP:
				event.type = TPW_EVENT_TYPE_MOUSEBTN_UP;
				event.mouse.button = event_sdl.button.button;
				break;
			case SDL_JOYAXISMOTION:
				event.type = TPW_EVENT_TYPE_JOYSTICK_MOVE;
				event.joystick.value = event_sdl.jaxis.value;
				event.joystick.axis = event_sdl.jaxis.axis;
				event.joystick.js_id = event_sdl.jaxis.which;
				break;
			case SDL_ACTIVEEVENT:
				event.type = TPW_EVENT_TYPE_ACTIVE;
				event.active.gain = event_sdl.active.gain;
				event.active.app_active = (event_sdl.active.type == SDL_APPACTIVE);
				break;
			case SDL_QUIT:
				event.type = TPW_EVENT_TYPE_QUIT;
				break;
			default:
				break;
		}	

		tpw_event_push(event);
		event.key.unicode = event_sdl.key.keysym.unicode = 0;
	}

	return;
}
Пример #3
0
void tpw_event_callback_mousebtn(int button, int event) {
	TPW_EVENT event_s;

	memset(&event_s, 0, sizeof(event_s));
	
	event_s.type = (event == GLFW_PRESS) ? TPW_EVENT_TYPE_MOUSEBTN_DOWN : TPW_EVENT_TYPE_MOUSEBTN_UP;
	event_s.mouse.button = button;

	tpw_event_push(event_s);
	return;
}
Пример #4
0
void tpw_event_callback(int keysym, int event) {
	TPW_EVENT event_s;

	memset(&event_s, 0, sizeof(event_s));
	
	event_s.type = (event == GLFW_PRESS) ? TPW_EVENT_TYPE_KEYDOWN : TPW_EVENT_TYPE_KEYUP;
	event_s.key.unicode = 0;
	event_s.key.keysym = tpw_event_keysym_convert(keysym);

	tpw_event_push(event_s);
	return;
}
Пример #5
0
void tpw_event_callback_unicode(int unicode, int event) {
	TPW_EVENT event_s;

	memset(&event_s, 0, sizeof(event_s));

	event_s.type = (event == GLFW_PRESS) ? TPW_EVENT_TYPE_KEYDOWN : TPW_EVENT_TYPE_KEYUP;
	event_s.key.unicode = unicode;
	event_s.key.keysym = 0;

	tpw_event_push(event_s);
	return;
}
Пример #6
0
void tpw_event_callback_mousepos(int x, int y) {
	TPW_EVENT event;

	memset(&event, 0, sizeof(event));

	event.type = TPW_EVENT_TYPE_MOUSEMOVE;
	event.mouse.x = x;
	event.mouse.y = y;
	
	tpw_event_push(event);
	return;
}