int GetRCCode(int timeout_in_ms)
{
	int rv = -1;

	if (get_instance()>instance)
	{
		return rv;
	}

	if (timeout_in_ms) {
		struct pollfd pfd;
		struct timeval tv;
		uint64_t ms_now, ms_final;

		pfd.fd = rc;
		pfd.events = POLLIN;
		pfd.revents = 0;

		gettimeofday( &tv, NULL );
		ms_now = tv.tv_usec/1000 + tv.tv_sec * 1000;
		if (timeout_in_ms > 0)
			ms_final = ms_now + timeout_in_ms;
		else
			ms_final = UINT64_MAX;
		while (ms_final > ms_now) {
			switch(poll(&pfd, 1, timeout_in_ms)) {
				case -1:
					perror("GetRCCode: poll() failed");
				case 0:
					return -1;
				default:
					;
			}
			if(RCKeyPressed()) {
				rv = rccode;
				while(RCKeyPressed());
				return RCTranslate(rv);
			}

			gettimeofday( &tv, NULL );
			ms_now = tv.tv_usec/1000 + tv.tv_sec * 1000;
			if (timeout_in_ms > 0)
				timeout_in_ms = (int)(ms_final - ms_now);
		}
	} else if(RCKeyPressed()) {
		rv = rccode;
		while(RCKeyPressed());
		return RCTranslate(rv);
	}
	return rv;
}
示例#2
0
int GetRCCode(void)
{

  x=read(rc, &rccode, 2);
  
  if (x < 2)
    return -1;
  
  if (lastkey == rccode)
      {
      key_count++;
      if (key_count < 3)
          return -1;
      } else
          key_count=0;

  lastkey=rccode;

  if((rccode & 0xFF00) == 0x5C00)
  {
      rccode=RCTranslate(rccode);
  }
  else 
       rccode = -1;

  return rccode;
}
示例#3
0
int GetRCCode(void)
{
	int rv;

	if(!RCKeyPressed() || (get_instance()>instance))
	{
		return -1;
	}
	rv=rccode;
	while(RCKeyPressed());

	return RCTranslate(rv);
}
示例#4
0
int GetCode(void)
{
	if(!RCKeyPressed() || (get_instance()>instance))
	{
		return -1;
	}

	do
	{
		rc_last_key = ev.code;
	}
	while(RCKeyPressed());
	
	return RCTranslate(rc_last_key);
}