Exemplo n.º 1
0
/* The main routine for PenMount */
static void *PenMountEventThread(DirectThread *thread, void *driver_data){
	
     PeMData *data = (PeMData *) driver_data;

     /* Read data */
     while (1) {
          DFBInputEvent evt;
          static int pressed = 0;

          if (!PeMGetEvent (data))
	       continue;
	      direct_thread_testcancel (thread);

          /* Dispatch axis */
          evt.type    = DIET_AXISMOTION;
          evt.flags   = DIEF_AXISABS;
          evt.axis    = DIAI_X;
          evt.axisabs = data->x;
          dfb_input_dispatch (data->device, &evt);

          evt.type    = DIET_AXISMOTION;
          evt.flags   = DIEF_AXISABS;
          evt.axis    = DIAI_Y;
          evt.axisabs = data->y;
          dfb_input_dispatch (data->device, &evt);

          /* Dispatch touch event */
          switch (data->action) {
               case PEM_PANEL_TOUCH:
               		if (!pressed)
                    	evt.type = DIET_BUTTONPRESS;
                    pressed = 1;
               		break;
               case PEM_PANEL_UNTOUCH:
               		if (pressed)
                    	evt.type = DIET_BUTTONRELEASE;
                    pressed = 0;	
                    break;
          }

          evt.flags  = DIEF_NONE;
          evt.button = DIBI_LEFT;

          dfb_input_dispatch (data->device, &evt);
          direct_thread_testcancel (thread);
     }

     return NULL;
}
Exemplo n.º 2
0
static void*
keyboardEventThread( DirectThread *thread, void *driver_data )
{
    int            readlen;
    unsigned char  buf[64];
    KeyboardData  *data = (KeyboardData*) driver_data;

    /* Read keyboard data */
    while ((readlen = read (data->vt_fd, buf, 64)) >= 0 || errno == EINTR) {
        int i;

        direct_thread_testcancel( thread );

        for (i = 0; i < readlen; i++) {
            DFBInputEvent evt;

            evt.type     = ((buf[i] & 0x80) ?
                            DIET_KEYRELEASE : DIET_KEYPRESS);
            evt.flags    = DIEF_KEYCODE;
            evt.key_code = buf[i] & 0x7f;

            dfb_input_dispatch( data->device, &evt );

            keyboard_set_lights( data, evt.locks );
        }

        if (readlen <= 0)
            usleep( 200000 );
    }

    if (readlen <= 0 && errno != EINTR)
        D_PERROR ("keyboard thread died\n");

    return NULL;
}
Exemplo n.º 3
0
/*
 * Input thread reading from device.
 * Generates events on incoming data.
 */
static void*
dreamboxremoteEventThread( DirectThread *thread, void *driver_data )
{
     DreamboxremoteData *data = (DreamboxremoteData*) driver_data;
     int              readlen;
     u16              rccode;
     DFBInputEvent    evt;

     while ((readlen = read( data->fd, &rccode, 2 )) == 2) {
          direct_thread_testcancel( thread );

          /* translate rccode to DirectFB keycode */
          evt.key_symbol = dreamboxremote_parse_rccode( rccode );
          if (evt.key_symbol != DIKS_NULL) {
               /* set event type and dispatch*/
               evt.type = DIET_KEYPRESS;
               evt.flags = DIEF_KEYSYMBOL;
               dfb_input_dispatch( data->device, &evt );

               /* set event type and dispatch*/
               evt.type = DIET_KEYRELEASE;
               evt.flags = DIEF_KEYSYMBOL;
               dfb_input_dispatch( data->device, &evt );
          }
     }

     if (readlen <= 0 && errno != EINTR)
          D_PERROR ("dreamboxremote thread died\n");

     return NULL;
}
Exemplo n.º 4
0
/*
 * Input thread reading from device.
 * Generates events on incoming data.
 */
static void*
sonypiEventThread( DirectThread *thread, void *driver_data )
{
     SonypiData    *data = (SonypiData*) driver_data;
     int            readlen;
     u8             buffer[16];

     /* loop until error occurs except EINTR */
     while ((readlen = read( data->fd, buffer, 16 )) > 0 || errno == EINTR) {
          int           i;
          DFBInputEvent evt;

          direct_thread_testcancel( thread );

          /* process each byte */
          for (i=0; i<readlen; i++) {

               /* check for jogdial events */
               switch (buffer[i]) {
                    case SONYPI_EVENT_JOGDIAL_DOWN:
                    case SONYPI_EVENT_JOGDIAL_UP:
                    case SONYPI_EVENT_JOGDIAL_DOWN_PRESSED:
                    case SONYPI_EVENT_JOGDIAL_UP_PRESSED:
                         evt.type  = DIET_AXISMOTION;
                         evt.axis  = DIAI_Z;
                         evt.flags = DIEF_AXISREL;

                         if (buffer[i] == SONYPI_EVENT_JOGDIAL_DOWN ||
                             buffer[i] == SONYPI_EVENT_JOGDIAL_DOWN_PRESSED)
                              evt.axisrel = 1;
                         else
                              evt.axisrel = -1;

                         dfb_input_dispatch( data->device, &evt );
                         break;

                    case SONYPI_EVENT_JOGDIAL_PRESSED:
                    case SONYPI_EVENT_JOGDIAL_RELEASED:
                         if (buffer[i] == SONYPI_EVENT_JOGDIAL_PRESSED)
                              evt.type = DIET_BUTTONPRESS;
                         else
                              evt.type = DIET_BUTTONRELEASE;

                         evt.flags  = DIEF_NONE; /* button is always valid */
                         evt.button = DIBI_MIDDLE;

                         dfb_input_dispatch( data->device, &evt );
                         break;

                    default:
                         ;
               }
          }
     }

     if (readlen < 0)
          D_PERROR ("sonypi thread died\n");

     return NULL;
}
Exemplo n.º 5
0
/*
 * Input thread reading from device.
 * Generates events on incoming data.
 */
static void*
osxEventThread( DirectThread *thread, void *driver_data )
{
     OSXInputData *data    = (OSXInputData*) driver_data;
     DFBOSX       *dfb_osx = data->dfb_osx;

     while (!data->stop) {
          DFBInputEvent evt;
          EventRecord   event;

          fusion_skirmish_prevail( &dfb_osx->lock );

          /* Check for events */
          while ( WaitNextEvent( everyEvent, &event, 0, nil) ) {
               fusion_skirmish_dismiss( &dfb_osx->lock );

               switch (event.what) {
                    case keyDown:
                    case keyUp:
                    case autoKey:
                         if (event.what == keyUp)
                              evt.type = DIET_KEYRELEASE;
                         else
                              evt.type = DIET_KEYPRESS;

                         if (translate_key( event.message & (charCodeMask | keyCodeMask), &evt )) {
                              dfb_input_dispatch( data->device, &evt );
                         }

                         break;
                    case mouseDown:
                         evt.type = DIET_BUTTONPRESS;
                         evt.button = DIBI_LEFT;
                         dfb_input_dispatch( data->device, &evt );
                         break;
                    case mouseUp:
                         evt.type = DIET_BUTTONRELEASE;
                         evt.button = DIBI_LEFT;
                         dfb_input_dispatch( data->device, &evt );
                         break;
                    default:
                         printf("%d\n",event.what);
                         break;
               }

               fusion_skirmish_prevail( &dfb_osx->lock );
          }

          fusion_skirmish_dismiss( &dfb_osx->lock );

          usleep(10000);

          direct_thread_testcancel( thread );
     }

     return NULL;
}
Exemplo n.º 6
0
Arquivo: elo.c Projeto: ysei/uclinux-2
/* The main routine for elo */
static void *eloTouchEventThread(DirectThread *thread, void *driver_data)
{
  eloData *data = (eloData *) driver_data;

   /* Read data */
  while (1) {
    DFBInputEvent evt;

    if(eloGetEvent(data) == -1) continue;
    direct_thread_testcancel(thread);

    /* Dispatch axis */
    evt.type    = DIET_AXISMOTION;
    evt.flags   = DIEF_AXISABS;
    evt.axis    = DIAI_X;
    evt.axisabs = data->x;
    dfb_input_dispatch(data->device, &evt);

    evt.type    = DIET_AXISMOTION;
    evt.flags   = DIEF_AXISABS;
    evt.axis    = DIAI_Y;
    evt.axisabs = data->y;
    dfb_input_dispatch(data->device, &evt);

    /* Dispatch touch event */
    if(data->action & ELO_M_UNTOUCH)
      evt.type = DIET_BUTTONRELEASE;
    else
      evt.type = DIET_BUTTONPRESS;

    evt.flags  = DIEF_NONE;
    evt.button = DIBI_LEFT;

    dfb_input_dispatch(data->device, &evt);
    direct_thread_testcancel(thread);
  }

  return NULL;
}
Exemplo n.º 7
0
static void *
vt_thread( DirectThread *thread, void *arg )
{
     D_DEBUG_AT( VT, "%s( %p, %p )\n", __FUNCTION__, thread, arg );

     pthread_mutex_lock( &dfb_vt->lock );

     while (true) {
          direct_thread_testcancel( thread );

          D_DEBUG_AT( VT, "...%s (signal %d)\n", __FUNCTION__, dfb_vt->vt_sig);

          switch (dfb_vt->vt_sig) {
               default:
                    D_BUG( "unexpected vt_sig" );
                    /* fall through */

               case -1:
                    pthread_cond_wait( &dfb_vt->wait, &dfb_vt->lock );
                    continue;

               case SIG_SWITCH_FROM:
                    if (dfb_core_suspend( dfb_fbdev->core ) == DFB_OK) {
                         if (ioctl( dfb_vt->fd, VT_RELDISP, VT_ACKACQ ) < 0)
                              D_PERROR( "DirectFB/fbdev/vt: VT_RELDISP failed\n" );
                    }

                    break;

               case SIG_SWITCH_TO:
                    if (dfb_core_resume( dfb_fbdev->core ) == DFB_OK) {
                         if (ioctl( dfb_vt->fd, VT_RELDISP, VT_ACKACQ ) < 0)
                              D_PERROR( "DirectFB/fbdev/vt: VT_RELDISP failed\n" );

                         if (dfb_config->kd_graphics) {
                              if (ioctl( dfb_vt->fd, KDSETMODE, KD_GRAPHICS ) < 0)
                                   D_PERROR( "DirectFB/fbdev/vt: KD_GRAPHICS failed!\n" );
                         }
                    }

                    break;
          }

          dfb_vt->vt_sig = -1;

          pthread_cond_signal( &dfb_vt->wait );
     }

     return NULL;
}
Exemplo n.º 8
0
static void*
joystickEventThread( DirectThread *thread, void *driver_data )
{
    int              len;
    struct js_event  jse;
    JoystickData    *data = driver_data;

    while ((len = read( data->fd, &jse,
                        sizeof(struct js_event) )) > 0 || errno == EINTR)
    {
        direct_thread_testcancel( thread );

        if (len != sizeof(struct js_event))
            continue;

        joystick_handle_event( data, jse );
    }

    if (len <= 0 && errno != EINTR)
        D_PERROR ("joystick thread died\n");

    return NULL;
}
Exemplo n.º 9
0
/*
 * Input thread reading from device.
 * Generates events on incoming data.
 */
static void*
sdlEventThread( DirectThread *thread, void *driver_data )
{
     SDLInputData *data    = (SDLInputData*) driver_data;
     DFBSDL       *dfb_sdl = data->dfb_sdl;

     while (!data->stop) {
          DFBInputEvent evt;
          SDL_Event     event;

          fusion_skirmish_prevail( &dfb_sdl->lock );

          /* Check for events */
          while ( SDL_PollEvent(&event) ) {
               fusion_skirmish_dismiss( &dfb_sdl->lock );

               switch (event.type) {
                    case SDL_MOUSEMOTION:
                         motion_compress( event.motion.x, event.motion.y );
                         break;

                    case SDL_MOUSEBUTTONUP:
                    case SDL_MOUSEBUTTONDOWN:
                         motion_realize( data );

                         if (event.type == SDL_MOUSEBUTTONDOWN)
                              evt.type = DIET_BUTTONPRESS;
                         else
                              evt.type = DIET_BUTTONRELEASE;

                         evt.flags = DIEF_NONE;

                         switch (event.button.button) {
                              case SDL_BUTTON_LEFT:
                                   evt.button = DIBI_LEFT;
                                   break;
                              case SDL_BUTTON_MIDDLE:
                                   evt.button = DIBI_MIDDLE;
                                   break;
                              case SDL_BUTTON_RIGHT:
                                   evt.button = DIBI_RIGHT;
                                   break;
                              case SDL_BUTTON_WHEELUP:
                              case SDL_BUTTON_WHEELDOWN:
                                   if (event.type != SDL_MOUSEBUTTONDOWN) {
                                        fusion_skirmish_prevail( &dfb_sdl->lock );
                                        continue;
                                   }
                                   evt.type  = DIET_AXISMOTION;
                                   evt.flags = DIEF_AXISREL;
                                   evt.axis  = DIAI_Z;
                                   if (event.button.button == SDL_BUTTON_WHEELUP)
                                        evt.axisrel = -1;
                                   else
                                        evt.axisrel = 1;
                                   break;
                              default:
                                   fusion_skirmish_prevail( &dfb_sdl->lock );
                                   continue;
                         }

                         dfb_input_dispatch( data->device, &evt );
                         break;

                    case SDL_KEYUP:
                    case SDL_KEYDOWN:
                         if (event.type == SDL_KEYDOWN)
                              evt.type = DIET_KEYPRESS;
                         else
                              evt.type = DIET_KEYRELEASE;

                         /* Get a key id first */
                         translate_key( event.key.keysym.sym, &evt );

                         /* If SDL provided a symbol, use it */
                         if (event.key.keysym.unicode) {
                              evt.flags     |= DIEF_KEYSYMBOL;
                              evt.key_symbol = event.key.keysym.unicode;

                              /**
                               * Hack to translate the Control+[letter]
                               * combination to
                               * Modifier: CONTROL, Key Symbol: [letter]
                               * A side effect here is that Control+Backspace
                               * produces Control+h
                               */
                              if (evt.modifiers == DIMM_CONTROL &&
                                  evt.key_symbol >= 1 && evt.key_symbol <= ('z'-'a'+1))
                              {
                                  evt.key_symbol += 'a'-1;
                              }
                         }

                         dfb_input_dispatch( data->device, &evt );
                         break;
                    case SDL_QUIT:
                         evt.type       = DIET_KEYPRESS;
                         evt.flags      = DIEF_KEYSYMBOL;
                         evt.key_symbol = DIKS_ESCAPE;

                         dfb_input_dispatch( data->device, &evt );

                         evt.type       = DIET_KEYRELEASE;
                         evt.flags      = DIEF_KEYSYMBOL;
                         evt.key_symbol = DIKS_ESCAPE;

                         dfb_input_dispatch( data->device, &evt );
                         break;

                    default:
                         break;
               }

               fusion_skirmish_prevail( &dfb_sdl->lock );
          }

          fusion_skirmish_dismiss( &dfb_sdl->lock );

          motion_realize( data );

          usleep(10000);

          direct_thread_testcancel( thread );
     }

     return NULL;
}
Exemplo n.º 10
0
/* the main routine for MouseSystems */
static void*
mouseEventThread_mousesystems( DirectThread *thread, void *driver_data )
{
     SerialMouseData *data = (SerialMouseData*) driver_data;

     unsigned char buf[256];
     unsigned char packet[5];
     unsigned char pos = 0;
     unsigned char last_buttons = 0;
     int i;
     int readlen;

     mouse_motion_initialize( data );

     /* Read data */
     while ((readlen = read( data->fd, buf, 256 )) >= 0 || errno == EINTR) {

          direct_thread_testcancel( thread );

          for (i = 0; i < readlen; i++) {

               if (pos == 0  && (buf[i] & 0xf8) != 0x80)
                    continue;

               packet[pos++] = buf[i];

               if (pos == 5) {
                    int dx, dy;
                    int buttons;

                    pos = 0;

                    buttons= (~packet[0]) & 0x07;
                    dx =    (signed char) (packet[1]) + (signed char)(packet[3]);
                    dy = - ((signed char) (packet[2]) + (signed char)(packet[4]));

                    mouse_motion_compress( data, dx, dy );

                    if (!dfb_config->mouse_motion_compression)
                         mouse_motion_realize( data );

                    if (last_buttons != buttons) {
                         DFBInputEvent evt;
                         unsigned char changed_buttons = last_buttons ^ buttons;

                         /* make sure the compressed motion event is dispatched
                            before any button change */
                         mouse_motion_realize( data );

                         if (changed_buttons & 0x04) {
                              evt.type = (buttons & 0x04) ?
                                   DIET_BUTTONPRESS : DIET_BUTTONRELEASE;
                              evt.flags = DIEF_NONE; /* button is always valid */
                              evt.button = DIBI_LEFT;
                              dfb_input_dispatch( data->device, &evt );
                         }
                         if (changed_buttons & 0x01) {
                              evt.type = (buttons & 0x01) ?
                                   DIET_BUTTONPRESS : DIET_BUTTONRELEASE;
                              evt.flags = DIEF_NONE; /* button is always valid */
                              evt.button = DIBI_MIDDLE;
                              dfb_input_dispatch( data->device, &evt );
                         }
                         if (changed_buttons & 0x02) {
                              evt.type = (buttons & 0x02) ?
                                   DIET_BUTTONPRESS : DIET_BUTTONRELEASE;
                              evt.flags = DIEF_NONE; /* button is always valid */
                              evt.button = DIBI_RIGHT;
                              dfb_input_dispatch( data->device, &evt );
                         }

                         last_buttons = buttons;
                    }
               }
          }

          /* make sure the compressed motion event is dispatched,
             necessary if the last packet was a motion event */
          if (readlen > 0)
               mouse_motion_realize( data );

          direct_thread_testcancel( thread );
     }

     D_PERROR ("serial mouse thread died\n");

     return NULL;
}
Exemplo n.º 11
0
/* the main routine for MS mice (plus extensions) */
static void*
mouseEventThread_ms( DirectThread *thread, void *driver_data )
{
     SerialMouseData *data = (SerialMouseData*) driver_data;
     DFBInputEvent    evt;

     unsigned char buf[256];
     unsigned char packet[4];
     unsigned char pos = 0;
     unsigned char last_buttons = 0;
     int dx, dy;
     int buttons;
     int readlen;
     int i;

     mouse_motion_initialize( data );

     /* Read data */
     while ((readlen = read( data->fd, buf, 256 )) >= 0 || errno == EINTR) {

          direct_thread_testcancel( thread );

          for (i = 0; i < readlen; i++) {

               if (pos == 0  && !(buf[i] & 0x40))
                    continue;

               /* We did not reset the position in the mouse event handler
                  since a forth byte may follow. We check for it now and
                  reset the position if this is a start byte. */
               if (pos == 3 && buf[i] & 0x40)
                    pos = 0;

               packet[pos++] = buf[i];

               switch (pos) {
               case 3:
                    if (data->protocol != PROTOCOL_MOUSEMAN)
                         pos = 0;

                    buttons = packet[0] & 0x30;
                    dx = (signed char)
                         (((packet[0] & 0x03) << 6) | (packet[1] & 0x3f));
                    dy = (signed char)
                         (((packet[0] & 0x0C) << 4) | (packet[2] & 0x3f));

                    mouse_motion_compress( data, dx, dy );

                    if (data->protocol == PROTOCOL_MS3) {
                         if (!dx && !dy && buttons == (last_buttons & ~MIDDLE))
                              buttons = last_buttons ^ MIDDLE;  /* toggle    */
                         else
                              buttons |= last_buttons & MIDDLE; /* preserve  */
                    }

                    if (!dfb_config->mouse_motion_compression)
                         mouse_motion_realize( data );

                    if (last_buttons != buttons) {
                         unsigned char changed_buttons = last_buttons ^ buttons;

                         /* make sure the compressed motion event is dispatched
                            before any button change */
                         mouse_motion_realize( data );

                         if (changed_buttons & 0x20) {
                              evt.type = (buttons & 0x20) ?
                                   DIET_BUTTONPRESS : DIET_BUTTONRELEASE;
                              evt.flags = DIEF_NONE;
                              evt.button = DIBI_LEFT;
                              dfb_input_dispatch( data->device, &evt );
                         }
                         if (changed_buttons & 0x10) {
                              evt.type = (buttons & 0x10) ?
                                   DIET_BUTTONPRESS : DIET_BUTTONRELEASE;
                              evt.flags = DIEF_NONE;
                              evt.button = DIBI_RIGHT;
                              dfb_input_dispatch( data->device, &evt );
                         }
                         if (changed_buttons & MIDDLE) {
                              evt.type = (buttons & MIDDLE) ?
                                   DIET_BUTTONPRESS : DIET_BUTTONRELEASE;
                              evt.flags = DIEF_NONE;
                              evt.button = DIBI_MIDDLE;
                              dfb_input_dispatch( data->device, &evt );
                         }

                         last_buttons = buttons;
                    }
                    break;

               case 4:
                    pos = 0;

                    evt.type = (packet[3] & 0x20) ?
                         DIET_BUTTONPRESS : DIET_BUTTONRELEASE;
                    evt.flags = DIEF_NONE; /* button is always valid */
                    evt.button = DIBI_MIDDLE;
                    dfb_input_dispatch( data->device, &evt );
                    break;

               default:
                    break;
               }
          }

          /* make sure the compressed motion event is dispatched,
             necessary if the last packet was a motion event */
          if (readlen > 0)
               mouse_motion_realize( data );

          direct_thread_testcancel( thread );
     }

     D_PERROR ("serial mouse thread died\n");

     return NULL;
}
Exemplo n.º 12
0
static void*
ps2mouseEventThread( DirectThread *thread, void *driver_data )
{
     PS2MouseData *data  = (PS2MouseData*) driver_data;

     unsigned char packet[4];
     unsigned char pos = 0;
     unsigned char last_buttons = 0;

     int readlen;
     unsigned char buf[256];


     while ( (readlen = read(data->fd, buf, 256)) > 0 ) {
          int i;

          direct_thread_testcancel( thread );

          for ( i = 0; i < readlen; i++ ) {

               if ( pos == 0  &&  (buf[i] & 0xc0) ) {
                    continue;
               }
               packet[pos++] = buf[i];
               if ( pos == data->packetLength ) {
                    int dx, dy, dz;
                    int buttons;

                    pos = 0;

                    if ( !(packet[0] & 0x08) ) {
                         /* We've lost sync! */
                         i--;    /* does this make sense? oh well,
                                    it will resync eventually (will it ?)*/
                         continue;
                    }

                    buttons = packet[0] & 0x07;
                    dx = (packet[0] & 0x10) ?   packet[1]-256  :  packet[1];
                    dy = (packet[0] & 0x20) ? -(packet[2]-256) : -packet[2];
                    if (data->mouseId == PS2_ID_IMPS2) {
                         /* Just strip off the extra buttons if present
                            and sign extend the 4 bit value */
                         dz = (s8)((packet[3] & 0x80) ?
                                      packet[3] | 0xf0 : packet[3] & 0x0F);
                         if (dz) {
                              DFBInputEvent evt;

                              evt.type    = DIET_AXISMOTION;
                              evt.flags   = DIEF_AXISREL;
                              evt.axis    = DIAI_Z;
                              evt.axisrel = dz;

                              flush_xy( data );

                              dfb_input_dispatch( data->device, &evt );
                         }
                    }
                    else {
                         dz = 0;
                    }

                    data->dx += dx;
                    data->dy += dy;

                    if ( !dfb_config->mouse_motion_compression )
                         flush_xy( data );

                    if ( last_buttons != buttons ) {
                         DFBInputEvent evt;
                         unsigned char changed_buttons;

                         changed_buttons = last_buttons ^ buttons;

                         /* make sure the compressed motion event is dispatched
                            before any button change */
                         flush_xy( data );

                         if ( changed_buttons & 0x01 ) {
                              evt.type = (buttons & 0x01) ?
                                   DIET_BUTTONPRESS : DIET_BUTTONRELEASE;
                              evt.flags = DIEF_NONE;
                              evt.button = DIBI_LEFT;
                              dfb_input_dispatch( data->device, &evt );
                         }
                         if ( changed_buttons & 0x02 ) {
                              evt.type = (buttons & 0x02) ?
                                   DIET_BUTTONPRESS : DIET_BUTTONRELEASE;
                              evt.flags = DIEF_NONE;
                              evt.button = DIBI_RIGHT;
                              dfb_input_dispatch( data->device, &evt );
                         }
                         if ( changed_buttons & 0x04 ) {
                              evt.type = (buttons & 0x04) ?
                                   DIET_BUTTONPRESS : DIET_BUTTONRELEASE;
                              evt.flags = DIEF_NONE;
                              evt.button = DIBI_MIDDLE;
                              dfb_input_dispatch( data->device, &evt );
                         }

                         last_buttons = buttons;
                    }
               }
          }
          /* make sure the compressed motion event is dispatched,
             necessary if the last packet was a motion event */
          flush_xy( data );
     }

     if ( readlen <= 0 && errno != EINTR )
          D_PERROR ("psmouse thread died\n");

     return NULL;
}
Exemplo n.º 13
0
// le thread qui sert à recevoir des données en continue :
static void *ZytronicEventThread(DirectThread *thread, void *driver_data)
{
     ZytData *data = (ZytData *) driver_data;
     int lastAction = ZYT_ACTION_RELEASE;
     struct timeval unT;
     unsigned int lastT,newT;
     unsigned short nbClignot=0;
     lastT = 0;
     DFBInputEvent evt;

     /* Read data */
     while (1) {
          if (!ZytReadTouchMessage (data)){ // si jamais il y a eut mauvaise lecture (pas normal)
               continue; // on ignore le mesage mal lu
          }
          // en mode sans drag&drop, si l'action actuelle est la même que la précédente, on l'ignore:
          if (zytConf.mode==NO_DRAG_DROP && lastAction == data->action){
               nbClignot=0; // et on dit que ça clignote pas (car c'est un appui long, pas un clignotement)
               continue;		// permet de ne garder que le premier appui, et le relachement :
          }
          gettimeofday(&unT,NULL);
          newT = unT.tv_sec*1000000 + unT.tv_usec;
          if(zytConf.debug==DEBUG){
               D_INFO("newT=%u\n",newT);
               D_INFO("lastT=%u\n",lastT);
               D_INFO("lastT+attente=%u\n",lastT+zytConf.attenteMultiClic);
          }

          // si on "appui" trop vite, sans faire un appui continu, on réenregistre la dernière action,... :
          if(data->action==ZYT_ACTION_TOUCH && nbClignot < zytConf.nbClignToPress && \
          (lastT + zytConf.attenteMultiClic) > newT) {
               nbClignot++;// ..on compte combien de fois de suite on essai d'appuyer (pour voir si c'est la fin
                           // d'un clignotement justement parce qu'on a rapprocher le doigt suffisemment) ..
               gettimeofday(&unT,NULL);
               lastT = unT.tv_sec*1000000 + unT.tv_usec;
               continue; // ..et on ignore cet appui (permet d'éviter le phénomène de clignotement..)
          }
          nbClignot=0; // on remet le compteur à zéro, puisque c'est ici un appui réel
          direct_thread_testcancel (thread); // si cette ligne fait bien ce que je pense (regarder si on n'a pas
            // demandé la fin du thread en cours) pourquoi est-elle là, et pas avant le "if" ? Car si le controlleur
            // n'envoi plus aucune information pendant un moment, le driver ne peut pas détecter de "cancel"
            // pendant ce laps de temps .. ? ***

          // Dispatch axis
          evt.type    = DIET_AXISMOTION;
          evt.flags   = DIEF_AXISABS;
          evt.axis    = DIAI_X;
          evt.axisabs = data->x;
          dfb_input_dispatch (data->device, &evt);

          evt.type    = DIET_AXISMOTION;
          evt.flags   = DIEF_AXISABS;
          evt.axis    = DIAI_Y;
          evt.axisabs = data->y;
          dfb_input_dispatch (data->device, &evt);

          // Dispatch touch event
          switch (data->action) {
               case ZYT_ACTION_TOUCH:
                    evt.type = DIET_BUTTONPRESS;
                    break;
               case ZYT_ACTION_RELEASE:
                    evt.type = DIET_BUTTONRELEASE;
                    break;
          }


          evt.flags  = DIEF_NONE;
          evt.button = DIBI_LEFT;
          dfb_input_dispatch (data->device, &evt);

          lastAction = data->action; // on enregistre l'évènement
          gettimeofday(&unT,NULL); // on enregistre quand s'est produit l'évènement
          lastT = unT.tv_sec*1000000 + unT.tv_usec;

          if(zytConf.debug==DEBUG){
               D_INFO("Zytronic TOUCH : x=%d y=%d action=%d\n", data->x,data->y,data->action);
          }

          direct_thread_testcancel (thread);
     }

     return NULL;
}
Exemplo n.º 14
0
static void *
h3600tsEventThread( DirectThread *thread, void *driver_data )
{
     H3600TSData *data = (H3600TSData*) driver_data;

     TS_EVENT ts_event;

     int readlen;

     unsigned short old_x = -1;
     unsigned short old_y = -1;
     unsigned short old_pressure = 0;

     while ((readlen = read(data->fd, &ts_event, sizeof(TS_EVENT))) > 0  ||
            errno == EINTR)
     {
          DFBInputEvent evt;

          direct_thread_testcancel( thread );

          if (readlen < 1)
               continue;

          if (ts_event.pressure) {
               if (ts_event.x != old_x) {
                    evt.type    = DIET_AXISMOTION;
                    evt.flags   = DIEF_AXISABS;
                    evt.axis    = DIAI_X;
                    evt.axisabs = ts_event.x;

                    dfb_input_dispatch( data->device, &evt );

                    old_x = ts_event.x;
               }

               if (ts_event.y != old_y) {
                    evt.type    = DIET_AXISMOTION;
                    evt.flags   = DIEF_AXISABS;
                    evt.axis    = DIAI_Y;
                    evt.axisabs = ts_event.y;

                    dfb_input_dispatch( data->device, &evt );

                    old_y = ts_event.y;
               }
          }

          if ((ts_event.pressure && !old_pressure) ||
              (!ts_event.pressure && old_pressure)) {
               evt.type   = (ts_event.pressure ?
                             DIET_BUTTONPRESS : DIET_BUTTONRELEASE);
               evt.flags  = DIEF_NONE;
               evt.button = DIBI_LEFT;

               dfb_input_dispatch( data->device, &evt );

               old_pressure = ts_event.pressure;
          }
     }

     if (readlen <= 0)
          D_PERROR ("H3600 Touchscreen thread died\n");

     return NULL;
}