Exemple #1
0
DFBResult
CoreInputHub_AddDevice( CoreInputHub                    *hub,
                        DFBInputDeviceID                 device_id,
                        const DFBInputDeviceDescription *desc )
{
     InputHubNotification notification;

     D_ASSERT( hub != NULL );
     D_ASSERT( desc != NULL );

     D_DEBUG_AT( Core_InputHub, "%s( ID %u, '%s' )\n", __FUNCTION__, device_id, desc->name );

     memset( &notification, 0, sizeof(notification) );

     notification.type = IHNT_DEVICE_ADD;

     notification.data.device_add.device_id   = device_id;
     notification.data.device_add.description = *desc;

     direct_mutex_lock( &hub->lock );

     OneQueue_Dispatch( hub->notify_qid, &notification, sizeof(notification) );

     direct_mutex_unlock( &hub->lock );

     return DFB_OK;
}
Exemple #2
0
DFBResult
CoreInputHub_DispatchEvent( CoreInputHub        *hub,
                            DFBInputDeviceID     device_id,
                            const DFBInputEvent *event )
{
     InputHubNotification notification;

     D_DEBUG_AT( Core_InputHub, "%s( ID %u, %s )\n", __FUNCTION__, device_id, dfb_input_event_type_name(event->type) );

     D_ASSERT( hub != NULL );
     D_ASSERT( event != NULL );

     memset( &notification, 0, sizeof(notification) );

     notification.type = IHNT_EVENT_DISPATCH;

     notification.data.event_dispatch.device_id = device_id;
     notification.data.event_dispatch.event     = *event;

     direct_mutex_lock( &hub->lock );

     OneQueue_Dispatch( hub->notify_qid, &notification, sizeof(notification) );

     direct_mutex_unlock( &hub->lock );

     return DFB_OK;
}
Exemple #3
0
static void
CoreInputHub_Dispatch( void                  *context,
                       const OnePacketHeader *header,
                       void                  *data,
                       OneThread             *thread )
{
     InputHubAttachRequest *request = data;
     CoreInputHub          *hub     = context;

     D_DEBUG_AT( Core_InputHub, "%s()\n", __FUNCTION__ );

     direct_mutex_lock( &hub->lock );

     // FIXME: replace by own list of devices recorded in CoreInputHub_AddDevice/RemoveDevice calls
     dfb_input_enumerate_devices( CoreInputHub_EnumDevice_Callback, request, DICAPS_ALL );


     InputHubNotification notification;

     memset( &notification, 0, sizeof(notification) );

     notification.type = IHNT_ATTACHED;

     OneQueue_Dispatch( request->listen_qid, &notification, sizeof(notification) );


     OneQueue_Attach( hub->notify_qid, request->listen_qid );

     direct_mutex_unlock( &hub->lock );
}
Exemple #4
0
DFBResult
CoreInputHubClient_Activate( CoreInputHubClient *client )
{
     InputHubAttachRequest request;

     D_DEBUG_AT( Core_InputHub, "%s()\n", __FUNCTION__ );

     request.listen_qid = client->listen_qid;

     OneQueue_Dispatch( client->remote_qid, &request, sizeof(request) );

     return DFB_OK;
}
Exemple #5
0
static DFBEnumerationResult
CoreInputHub_EnumDevice_Callback( CoreInputDevice *device,
                                  void            *ctx )
{
     InputHubNotification   notification;
     InputHubAttachRequest *request = ctx;

     memset( &notification, 0, sizeof(notification) );

     notification.type = IHNT_DEVICE_ADD;

     notification.data.device_add.device_id = dfb_input_device_id( device );

     dfb_input_device_description( device, &notification.data.device_add.description );

     OneQueue_Dispatch( request->listen_qid, &notification, sizeof(notification) );

     return DFENUM_OK;
}
Exemple #6
0
static void *
CoreInputHubClient_ActivateThread( DirectThread *thread,
                                   void         *arg )
{
     CoreInputHubClient    *client = arg;
     InputHubAttachRequest  request;

     D_DEBUG_AT( Core_InputHub, "%s()\n", __FUNCTION__ );

     direct_mutex_lock( &client->lock );

     while (!client->activate_stop) {
          request.listen_qid = client->listen_qid;

          OneQueue_Dispatch( client->remote_qid, &request, sizeof(request) );

          direct_waitqueue_wait_timeout( &client->wq, &client->lock, 1000000 );
     }

     direct_mutex_unlock( &client->lock );

     return DFB_OK;
}
Exemple #7
0
DFBResult
CoreInputHub_RemoveDevice( CoreInputHub     *hub,
                           DFBInputDeviceID  device_id )
{
     InputHubNotification notification;

     D_DEBUG_AT( Core_InputHub, "%s( ID %u )\n", __FUNCTION__, device_id );

     D_ASSERT( hub != NULL );

     memset( &notification, 0, sizeof(notification) );

     notification.type = IHNT_DEVICE_REMOVE;

     notification.data.device_remove.device_id = device_id;

     direct_mutex_lock( &hub->lock );

     OneQueue_Dispatch( hub->notify_qid, &notification, sizeof(notification) );

     direct_mutex_unlock( &hub->lock );

     return DFB_OK;
}
Exemple #8
0
static DirectResult
TestWakeUp(void)
{
    DirectResult ret;
    char         buf[512];
    int          loops = 1000000;

    while (loops--) {
        ret = OneThread_AddQueue( thread, queue_id, TestDispatch, NULL );
        if (ret) {
            D_DERROR( ret, "OneTest: AddQueue error!\n" );
            return ret;
        }

        direct_mutex_lock( &lock );

        ret = OneQueue_Dispatch( queue_id, buf, 12 );
        if (ret) {
            D_DERROR( ret, "OneTest: Dispatch error!\n" );
            direct_mutex_unlock( &lock );
            return ret;
        }

        direct_waitqueue_wait( &queue, &lock );

        direct_mutex_unlock( &lock );

        ret = OneThread_RemoveQueue( thread, queue_id );
        if (ret) {
            D_DERROR( ret, "OneTest: RemoveQueue error!\n" );
            return ret;
        }
    }

    return DR_OK;
}