Exemplo n.º 1
0
//-- INPUT CALLBACK
void ev_input_callback(struct input_event * ev){
  if (ev->type==EV_KEY){
  	if ((ev->code == KEY_VOLUMEDOWN) && (key_pressed[KEY_VOLUMEDOWN] == 0) && (ev->value == 0))
		return;
    ev_post_message(ev->code,ev->value);
#ifdef  SIMULATE_KEY_UP_EVENT   	
	if (ev->code == KEY_BACK)
		ev_post_message(KEY_BACK, 0);
#endif	
  }
  else if (ev->type == EV_ABS) {
    evtouch_x = ev->value >> 16;
    evtouch_y = ev->value & 0xFFFF;
    
    if ((evtouch_x>0)&&(evtouch_y>0)){
      if (ev->code==0){
        evtouch_state = 0;
      }
      else if (evtouch_state==0){
        evtouch_state = 1;
      }
      else{
        evtouch_state = 2;
      }
      ev_post_message(evtouch_code,evtouch_state);
    }
    else{
      //-- False Event
      evtouch_state = 0;
      evtouch_x = 0;
      evtouch_y = 0;
    }
  }
Exemplo n.º 2
0
void ev_input_callback_(struct input_event * ev) {
  if (ev->type == EV_KEY) {
    ev_post_message(ev->code, ev->value);
  }
  else if (ev->type == EV_ABS) {
    evtouch_x = ev->value >> 16;
    evtouch_y = ev->value & 0xFFFF;
    
    if ((evtouch_x != 0) && (evtouch_y != 0)) {
      if (ev->code == 0) {
        evtouch_state = 0;
      }
      else if (evtouch_state == 0) {
        evtouch_state = 1;
      }
      else {
        evtouch_state = 2;
      }
      
      ev_post_message(evtouch_code, evtouch_state);
    }
    else {
      //-- False Event
      evtouch_state = 0;
      evtouch_x = 0;
      evtouch_y = 0;
    }
  }
Exemplo n.º 3
0
/* touch, key, state, x, y */
void ev_input_callback(byte touch, int key, byte state, int x, int y) {
  if (state == 3) {
    state = 0;
  }
  
  if (touch == 0) {
    ev_post_message(key, state);
  }
  else {
    printf("Touch %i - %i (%i)\n", x, y, state);
    evtouch_x = x;
    evtouch_y = y;
    ev_post_message(evtouch_code, state);
  }
}
Exemplo n.º 4
0
static void *ev_input_thack(void *cookie){
  miui_debug("pthread %s start, evtouch_thack is %d...\n", __FUNCTION__, evtouch_thack);
  while(evtouch_thack){
    if (evtouch_state!=0){
      if (evtouch_lastick<alib_tick()-10){
        evtouch_locked  = 1;
        evtouch_alreadyu= 1;
        evtouch_state   = 0;
        evtouch_sx      = 0;
        evtouch_sy      = 0;
        evtouch_rx      = 0;
        evtouch_ry      = 0;
        ev_post_message(evtouch_code,0);
      }
    }
    usleep(20);
  }
  return NULL;
}
Exemplo n.º 5
0
//-- SEND ATOUCH CUSTOM MESSAGE
void atouch_send_message(dword msg){
  atouch_message_value = msg;
  ev_post_message(atouch_message_code,0);
}
Exemplo n.º 6
0
void ev_input_callback(int fd, short revents){
  if (revents&POLLIN) {
    struct input_event ev;
    int         r = read(fd, &ev, sizeof(ev));
    if (r == sizeof(ev)){
        input_event_dump("input event", &ev);
      //-- OK ITS READY FOR HANDLING
      
      switch (ev.type){
        //-- Real Key Input Event
        case EV_KEY:{
          if ((ev.code==330)&&(evtouch_alreadyu==0)&&(ev.value==0)){
            if (!evtouch_thack){
              evtouch_alreadyu=1;
              evtouch_locked=1;
              evtouch_state=0;
              evtouch_sx = 0;
              evtouch_sy = 0;
              evtouch_rx = 0;
              evtouch_ry = 0;
              evtouch_mt_syn=0;
              ev_post_message(evtouch_code,0);
            }
          }
          else
            ev_post_message(ev.code,ev.value);
        }
        break;
        
        //-- Relative Input Event
        case EV_REL:{
	   #if 0
               input_event_dump("EV_REL", &ev);
	   #endif
          if (evrel_key!=ev.code){
            evrel_key = ev.code;
            evrel_size= 0;
          }
          int evt=((ev.value<0)?-1:1);
          if (evrel_val!=evt){
            evrel_val = evt;
            evrel_size= 0;
          }
          if (ev.code==REL_Y) {
            evrel_size += ev.value;
            if (evrel_size>8) {
              //-- DOWN
              ev_post_message(KEY_DOWN,0);
              evrel_size=0;
            }
            else if (evrel_size<-8) {
              //-- UP
              ev_post_message(KEY_UP,0);
              evrel_size=0;
            }
          }
          else if (ev.code == REL_X) {
            evrel_size += ev.value;
            if (evrel_size>8) {
              //-- RIGHT
              ev_post_message(KEY_RIGHT,0);
              evrel_size=0;
            }
            else if (evrel_size<-8) {
              //-- LEFT
              ev_post_message(KEY_LEFT,0);
              evrel_size=0;
            }
          }
        }
        break;
        
#if 1
        case EV_SYN:{
	   #if 0
               input_event_dump("EV_SYN", &ev);
	   #endif
          if (ev.code==SYN_MT_REPORT){
            if (evtouch_state>0){
              if (evtouch_mt_syn==2){
                evtouch_mt_syn=1;
              }
              else if(evtouch_mt_syn==1){
                evtouch_mt_syn=0;
                if (evtouch_alreadyu==0){
                  if (!evtouch_thack){
                    evtouch_locked=1;
                    evtouch_alreadyu=1;
                    evtouch_state = 0;
                    evtouch_sx = 0;
                    evtouch_sy = 0;
                    evtouch_rx = 0;
                    evtouch_ry = 0;
                    ev_post_message(evtouch_code,0);
                  }
                }
              }
            }
            else if (evtouch_state==0){
              if (evtouch_mt_syn==3){
                evtouch_mt_syn=1;
                atouch_translate_raw();
                evtouch_locked=1;
                evtouch_alreadyu=0;
                evtouch_x=evtouch_tx;
                evtouch_y=evtouch_ty;
                evtouch_state = 1;
                evtouch_sx = evtouch_x;
                evtouch_sy = evtouch_y;
                ev_post_message(evtouch_code,1);
              }
            }
          }
        }break;
#endif
        
        //-- Touch Input Event
        case EV_ABS:{
          evtouch_lastick = alib_tick();
          
          if (ev.code==ABS_MT_TOUCH_MAJOR){
            evtouch_mt_syn = 2;
            if ((evtouch_rx>0)&&(evtouch_ry>0)){              
              byte tmptouch  = (ev.value>0)?((evtouch_state==0)?1:2):((evtouch_state==0)?3:0);              
              if (tmptouch!=3){
                atouch_translate_raw(); //-- Translate RAW
                //-- TOUCH DOWN
                if (tmptouch==1){
                  evtouch_locked=1;
                  evtouch_alreadyu=0;
                  evtouch_x=evtouch_tx;
                  evtouch_y=evtouch_ty;
                  evtouch_state = 1;
                  evtouch_sx = evtouch_x;
                  evtouch_sy = evtouch_y;
                  ev_post_message(evtouch_code,1);
                }
                //-- TOUCH MOVE
                else if ((tmptouch==2)&&(evtouch_alreadyu==0)){
                  int agdp2=agdp()*2;
                  //-- SNAP TOUCH MOVE
                  if ((abs(evtouch_sx-evtouch_tx)>=agdp2)||(abs(evtouch_sy-evtouch_ty)>=agdp2)){
                    //-- IT MOVE MORE THAN DEVICE PIXELATE
                    evtouch_locked=1;
                    evtouch_x=evtouch_tx;
                    evtouch_y=evtouch_ty;
                    evtouch_state = 2;
                    evtouch_sx = evtouch_x;
                    evtouch_sy = evtouch_y;
                    ev_post_message(evtouch_code,2);
                    
                    //evtouch_thack
                  }
                }
                //-- TOUCH UP
                else if ((tmptouch==0)&&(evtouch_alreadyu==0)){
                  if (!evtouch_thack){
                    evtouch_locked=1;
                    evtouch_alreadyu=1;
                    evtouch_state = 0;
                    evtouch_sx = 0;
                    evtouch_sy = 0;
                    evtouch_rx = 0;
                    evtouch_ry = 0;
                    evtouch_mt_syn=0;
                    ev_post_message(evtouch_code,0);
                  }
                }
              }
            }
            else{
              byte tmptouch  = (ev.value>0)?((evtouch_state==0)?1:2):((evtouch_state==0)?3:0);
              if ((tmptouch!=0)&&(tmptouch!=3)){
                evtouch_mt_syn=3;
                evtouch_locked=0;
              }
            }
          }
          else if ((ev.code==ABS_MT_POSITION_X)||(ev.code==ABS_X)){
            //-- GOT RAW TOUCH X COORDINATE
            if (!evtouch_locked){
              if (ev.value>0) evtouch_rx = ev.value;
            }
          }
          else if ((ev.code==ABS_MT_POSITION_Y)||(ev.code==ABS_Y)){
            //-- GOT RAW TOUCH Y COORDINATE
            if (!evtouch_locked){
              if (ev.value>0) evtouch_ry = ev.value;
            }
          }
        }
        break;
      }
    }
  }
}