Exemple #1
0
bool InputHandler::processInput(int timeout_ms)
{
	input_event ev;
	int ret = ev_get(&ev, timeout_ms);

	if (ret < 0)
	{
		// This path means that we did not get any new touch data, but
		// we do not get new touch data if you press and hold on either
		// the screen or on a keyboard key or mouse button
		if (touch_status || key_status)
			processHoldAndRepeat();
		return (ret != -2);  // -2 means no more events in the queue
	}

	switch (ev.type)
	{
	case EV_ABS:
		process_EV_ABS(ev);
		break;

	case EV_REL:
		process_EV_REL(ev);
		break;

	case EV_KEY:
		process_EV_KEY(ev);
		break;
	}

	blankTimer.resetTimerAndUnblank();
	return true;  // we got an event, so there might be more in the queue
}
Exemple #2
0
    void init()
    {
        // these might be read from DataManager in the future
        touch_hold_ms = 500;
        touch_repeat_ms = 100;
        key_hold_ms = 500;
        key_repeat_ms = 100;
        touch_status = TS_NONE;
        key_status = KS_NONE;
        state = AS_NO_ACTION;
        x = y = 0;

        if (!(tw_flags & TW_FLAG_NO_SCREEN_TIMEOUT)) {
            std::string seconds;
            DataManager::GetValue(TW_SCREEN_TIMEOUT_SECS, seconds);
            blankTimer.setTime(atoi(seconds.c_str()));
            blankTimer.resetTimerAndUnblank();
        } else {
            LOGI("Skipping screen timeout: TW_NO_SCREEN_TIMEOUT is set");
        }
    }
Exemple #3
0
	void init()
	{
		// these might be read from DataManager in the future
		touch_hold_ms = 500;
		touch_repeat_ms = 100;
		key_hold_ms = 500;
		key_repeat_ms = 100;
		touch_status = TS_NONE;
		key_status = KS_NONE;
		state = AS_NO_ACTION;
		x = y = 0;

#ifndef TW_NO_SCREEN_TIMEOUT
		{
			string seconds;
			DataManager::GetValue("tw_screen_timeout_secs", seconds);
			blankTimer.setTime(atoi(seconds.c_str()));
			blankTimer.resetTimerAndUnblank();
		}
#else
		LOGINFO("Skipping screen timeout: TW_NO_SCREEN_TIMEOUT is set\n");
#endif
	}
Exemple #4
0
static void * input_thread(void *cookie)
{

	int drag = 0;
	static int touch_and_hold = 0, dontwait = 0;
	static int touch_repeat = 0, key_repeat = 0;
	static int x = 0, y = 0;
	static int lshift = 0, rshift = 0;
	static struct timeval touchStart;
	string seconds;
	HardwareKeyboard *kb = PageManager::GetHardwareKeyboard();
	MouseCursor *cursor = PageManager::GetMouseCursor();

#ifndef TW_NO_SCREEN_TIMEOUT
	//start screen timeout threads
	blankTimer.setTimerThread();
	DataManager::GetValue("tw_screen_timeout_secs", seconds);
	blankTimer.setTime(atoi(seconds.c_str()));
#else
	LOGINFO("Skipping screen timeout threads: TW_NO_SCREEN_TIMEOUT is set\n");
#endif

	for (;;)
	{
		// wait for the next event
		struct input_event ev;
		int state = 0, ret = 0;

		ret = ev_get(&ev, dontwait);

		if (ret < 0)
		{
			struct timeval curTime;
			gettimeofday(&curTime, NULL);
			long mtime, seconds, useconds;

			seconds = curTime.tv_sec - touchStart.tv_sec;
			useconds = curTime.tv_usec - touchStart.tv_usec;

			mtime = ((seconds) * 1000 + useconds / 1000.0) + 0.5;
			if (touch_and_hold && mtime > 500)
			{
				touch_and_hold = 0;
				touch_repeat = 1;
				gettimeofday(&touchStart, NULL);
#ifdef _EVENT_LOGGING
				LOGERR("TOUCH_HOLD: %d,%d\n", x, y);
#endif
				PageManager::NotifyTouch(TOUCH_HOLD, x, y);
#ifndef TW_NO_SCREEN_TIMEOUT
				blankTimer.resetTimerAndUnblank();
#endif
			}
			else if (touch_repeat && mtime > 100)
			{
#ifdef _EVENT_LOGGING
				LOGERR("TOUCH_REPEAT: %d,%d\n", x, y);
#endif
				gettimeofday(&touchStart, NULL);
				PageManager::NotifyTouch(TOUCH_REPEAT, x, y);
#ifndef TW_NO_SCREEN_TIMEOUT
				blankTimer.resetTimerAndUnblank();
#endif
			}
			else if (key_repeat == 1 && mtime > 500)
			{
#ifdef _EVENT_LOGGING
				LOGERR("KEY_HOLD: %d,%d\n", x, y);
#endif
				gettimeofday(&touchStart, NULL);
				key_repeat = 2;
				kb->KeyRepeat();
#ifndef TW_NO_SCREEN_TIMEOUT
				blankTimer.resetTimerAndUnblank();
#endif

			}
			else if (key_repeat == 2 && mtime > 100)
			{
#ifdef _EVENT_LOGGING
				LOGERR("KEY_REPEAT: %d,%d\n", x, y);
#endif
				gettimeofday(&touchStart, NULL);
				kb->KeyRepeat();
#ifndef TW_NO_SCREEN_TIMEOUT
				blankTimer.resetTimerAndUnblank();
#endif
			}
		}
		else if (ev.type == EV_ABS)
		{

			x = ev.value >> 16;
			y = ev.value & 0xFFFF;

			if (ev.code == 0)
			{
				if (state == 0)
				{
#ifdef _EVENT_LOGGING
					LOGERR("TOUCH_RELEASE: %d,%d\n", x, y);
#endif
					PageManager::NotifyTouch(TOUCH_RELEASE, x, y);
#ifndef TW_NO_SCREEN_TIMEOUT
					blankTimer.resetTimerAndUnblank();
#endif
					touch_and_hold = 0;
					touch_repeat = 0;
					if (!key_repeat)
						dontwait = 0;
				}
				state = 0;
				drag = 0;
			}
			else
			{
				if (!drag)
				{
					if (x != 0 && y != 0) {
#ifdef _EVENT_LOGGING
						LOGERR("TOUCH_START: %d,%d\n", x, y);
#endif
						if (PageManager::NotifyTouch(TOUCH_START, x, y) > 0)
							state = 1;
						drag = 1;
						touch_and_hold = 1;
						dontwait = 1;
						key_repeat = 0;
						gettimeofday(&touchStart, NULL);
					}
#ifndef TW_NO_SCREEN_TIMEOUT
					blankTimer.resetTimerAndUnblank();
#endif
				}
				else
				{
					if (state == 0)
					{
#ifdef _EVENT_LOGGING
						LOGERR("TOUCH_DRAG: %d,%d\n", x, y);
#endif
						if (PageManager::NotifyTouch(TOUCH_DRAG, x, y) > 0)
							state = 1;
						key_repeat = 0;
#ifndef TW_NO_SCREEN_TIMEOUT
						blankTimer.resetTimerAndUnblank();
#endif
					}
				}
			}
		}
		else if (ev.type == EV_KEY)