Exemplo n.º 1
0
static void
wheel_process_event( UniqueDevice        *device,
                     void                *data,
                     void                *ctx,
                     const DFBInputEvent *event )
{
     UniqueInputEvent  evt;
     WheelData        *wheel = data;

     (void) wheel;

     D_MAGIC_ASSERT( device, UniqueDevice );
     D_MAGIC_ASSERT( wheel, WheelData );

     D_ASSERT( event != NULL );

     D_DEBUG_AT( UniQuE_Wheel, "wheel_process_event( %p, %p, %p, %p ) <- type 0x%08x\n",
                 device, data, ctx, event, event->type );

     switch (event->type) {
          case DIET_AXISMOTION:
               switch (event->axis) {
                    case DIAI_Z:
                         evt.type = UIET_WHEEL;

                         evt.wheel.device_id = event->device_id;

                         if (event->flags & DIEF_AXISREL)
                              evt.wheel.value = -event->axisrel;
                         else if (event->flags & DIEF_AXISABS)
                              evt.wheel.value = event->axisabs;
                         else
                              break;

                         unique_device_dispatch( device, &evt );
                         break;

                    default:
                         break;
               }
               break;

          default:
               break;
     }
}
Exemplo n.º 2
0
static void
keyboard_process_event( UniqueDevice        *device,
                        void                *data,
                        void                *ctx,
                        const DFBInputEvent *event )
{
     UniqueInputEvent  evt;
     KeyboardData     *keyboard = data;

     (void) keyboard;

     D_MAGIC_ASSERT( device, UniqueDevice );
     D_MAGIC_ASSERT( keyboard, KeyboardData );

     D_ASSERT( event != NULL );

     D_DEBUG_AT( UniQuE_Keyboard, "keyboard_process_event( %p, %p, %p, %p ) <- type 0x%08x\n",
                 device, data, ctx, event, event->type );

     switch (event->type) {
          case DIET_KEYPRESS:
          case DIET_KEYRELEASE:
               evt.type = UIET_KEY;

               evt.keyboard.device_id  = event->device_id;
               evt.keyboard.press      = (event->type == DIET_KEYPRESS);
               evt.keyboard.key_code   = event->key_code;
               evt.keyboard.key_id     = event->key_id;
               evt.keyboard.key_symbol = event->key_symbol;
               evt.keyboard.modifiers  = event->modifiers;
               evt.keyboard.locks      = event->locks;

               unique_device_dispatch( device, &evt );
               break;

          default:
               break;
     }
}