void acime2_regThread(ACONTROLP ctl) {
  ACIMEDP  d      = (ACIMEDP) ctl->d;
  d->loopTick = alib_tick();
  pthread_t loopThread;
  pthread_create(&loopThread, NULL, acime2_loopthread, (void *) ctl);
  pthread_detach(loopThread);
}
Example #2
0
//-- KINETIC CALCULATOR
void akinetic_downhandler(AKINETIC * p, int mouseY){
  p->isdown            = 1;
  p->velocity          = 0;
  p->history_n         = 1;
  p->previousPoints[0] = mouseY;
  p->previousTimes[0]  = alib_tick();
}
static void *afbox_holdthread(void *cookie){
  AFBOXWAITDP dt = (AFBOXWAITDP) cookie;
  if (dt->ctl->win->isActived)
    dt->ctl->win->threadnum++;
  else{
    free(dt);
    return NULL;
  }
  
  byte isvalid = 1;
  while ( alib_tick() < (dt->tick[0]+50) ){
    if (!dt->ctl->win->isActived){
      isvalid=0;
      break;
    }
    if (dt->tick[0]<=0){
      isvalid=0;
      break;
    }
    usleep(10);
  }
  
  if ((isvalid)&&(dt->tick[0]>0)){
    dt->tick[0]=-1;
    dt->ctl->oninput(dt->ctl,444,NULL);
  }
  
  dt->ctl->win->threadnum--;
  free(dt);
  return NULL;
}
Example #4
0
void atouch_sethack(byte t){
  if (t!=evtouch_thack){
    if (t){
      evtouch_lastick = alib_tick();
      evtouch_thack   = t;
      pthread_t hack_thread_t;
      pthread_create(&hack_thread_t, NULL, ev_input_thack, NULL);
      pthread_detach(hack_thread_t);
    }
  }
  evtouch_thack=t;
}
byte afs_tick(AFSDTP dt) {
  if ((dt->status != 1) || (!dt->msgTick)) {
    return 0;
  }
  
  long ctick = alib_tick();
  
  if (dt->lstTick < (ctick - dt->intTick)) {
    dt->lstTick = ctick;
    return atouch_send_message(dt->msgTick);
  }
  
  return 0;
}
Example #6
0
byte akinetic_uphandler(AKINETIC * p, int mouseY){
  if (!p->isdown) return 0;
  p->isdown             = 0;
  int   currPoint       = (mouseY==0)?p->previousPoints[p->history_n-1]:mouseY;
  long  currTime        = alib_tick();
  int   firstPoint      = p->previousPoints[0];
  long  firstTime       = p->previousTimes[0];
  
  if (currTime-firstTime<1) firstTime--;
  if (currTime-firstTime>25) return 0;
  int   diff            = firstPoint-currPoint;
  long  time            = (currTime - firstTime);
  p->velocity           = ((double) diff/(double) time)*4;
  
  return 1;
}
Example #7
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;
}
Example #8
0
int akinetic_movehandler(AKINETIC * p, int mouseY){
  if (!p->isdown) return 0;
  int   currPoint       = mouseY;
  long  currTime        = alib_tick();
  int   previousPoint   = p->previousPoints[p->history_n-1];
  int   diff            = previousPoint-currPoint;
  
  p->history_n++;
  if (p->history_n>AKINETIC_HISTORY_LENGTH){
    int i;
    for (i=1;i<AKINETIC_HISTORY_LENGTH;i++){
      p->previousPoints[i-1]=p->previousPoints[i];
      p->previousTimes[i-1]=p->previousTimes[i];
    }
    p->history_n--;
  }
  p->previousPoints[p->history_n-1]  = currPoint;
  p->previousTimes[p->history_n-1]   = currTime;
  
  return diff;
}
Example #9
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;
      }
    }
  }
}
void afbox_ondraw(void * x){
  ACONTROLP   ctl= (ACONTROLP) x;
  AFBOXDP   d  = (AFBOXDP) ctl->d;
  CANVAS *    pc = &ctl->win->c;
  
  afbox_redraw(ctl);
  if (d->invalidDrawItem!=-1){
    d->touchedItem = d->invalidDrawItem;
    afbox_redrawitem_ex(ctl,d->invalidDrawItem);
    d->invalidDrawItem=-1;
    d->lasttouch=alib_tick();
    if (((d->boxtype==0)&&(d->check_n==0))||(d->boxtype==2))
      afbox_reghold(ctl,&d->lasttouch);
  }
  
  //-- Init Device Pixel Size
  int minpadding = 2;
  int agdp3 = (agdp()* minpadding);
  int agdp6 = (agdp()*(minpadding*2));
  int agdpX = agdp6;
  
  
  
  //-- Realtime redraw
  int dr_top=d->scrollY;
  int dr_bottom=dr_top+ctl->h;
  int i;
  for (i=0;i<d->itemn;i++){
    AFBOXIP p = d->items[i];
    if (p->y+p->h<dr_top) continue;
    else if (p->y>dr_bottom) break;
    else if (!p->drawed){
      afbox_redrawitem_ex(ctl,i);
      p->drawed=1;
    }
  }
  
  ag_draw(pc,&d->control,ctl->x,ctl->y);
  ag_draw_ex(pc,&d->client,ctl->x+agdp(),ctl->y+1,0,d->scrollY+1,ctl->w-(agdp()*2),ctl->h-2);
  
  if (d->maxScrollY>0){
    //-- Glow
    // int i;
    byte isST=(d->scrollY>0)?1:0;
    byte isSB=(d->scrollY<d->maxScrollY)?1:0;
    int add_t_y = 1;
    for (i=0;i<agdpX;i++){
      byte alph = 255-round((((float) (i+1))/ ((float) agdpX))*230);
      if (isST)
        ag_rectopa(pc,ctl->x,ctl->y+i+add_t_y,ctl->w,1,acfg()->textbg,alph);
      if (isSB)
        ag_rectopa(pc,ctl->x,((ctl->y+ctl->h)-(add_t_y))-(i+1),ctl->w,1,acfg()->textbg,alph);
    }
    
    //-- Scrollbar
    int newh = ctl->h - agdp6;
    float scrdif    = ((float) newh) / ((float) d->client.h);
    int  scrollbarH = round(scrdif * newh);
    int  scrollbarY = round(scrdif * d->scrollY) + agdp3;
    if (d->scrollY<0){
      scrollbarY = agdp3;
      int alp = (1.0 - (((float) abs(d->scrollY)) / (((float) ctl->h)/4))) * 255;
      if (alp<0) alp = 0;
      ag_rectopa(pc,(ctl->w-agdp()-2)+ctl->x,scrollbarY+ctl->y,agdp(),scrollbarH,acfg()->scrollbar, alp);
    }
    else if (d->scrollY>d->maxScrollY){
      scrollbarY = round(scrdif * d->maxScrollY) + agdp3;
      int alp = (1.0 - (((float) abs(d->scrollY-d->maxScrollY)) / (((float) ctl->h)/4))) * 255;
      if (alp<0) alp = 0;
      ag_rectopa(pc,(ctl->w-agdp()-2)+ctl->x,scrollbarY+ctl->y,agdp(),scrollbarH,acfg()->scrollbar, alp);
    }
    else{
      ag_rect(pc,(ctl->w-agdp()-2)+ctl->x,scrollbarY+ctl->y,agdp(),scrollbarH,acfg()->scrollbar);
    }
  }
}