Example #1
0
void SylVNCMouseDriver::DispatchEvent( int nDeltaX, int nDeltaY, uint32 nButtons )
{
    Point cDeltaMove( nDeltaX, nDeltaY );
    uint32 	nButtonFlg;
    static uint32 nLastButtons = 0;
  
    nButtonFlg	= nButtons ^ nLastButtons;
    nLastButtons	= nButtons;

    if ( nButtonFlg != 0 ) {
	Message* pcEvent;
    
	if ( nButtonFlg & 0x01 ) {
	    if ( nButtons & 0x01 ) {
		pcEvent = new Message( M_MOUSE_DOWN );
//		dbprintf( "Mouse Button 1 Down\n");
	    } else {
		pcEvent = new Message( M_MOUSE_UP );
//		dbprintf( "Mouse Button 1 Up\n");
	    }
	    pcEvent->AddInt32( "_button", 1 );
	    pcEvent->AddInt32( "_buttons", 1 ); // To be removed
	    EnqueueEvent( pcEvent );
	}
	if ( nButtonFlg & 0x02 ) {
	    if ( nButtons & 0x02 ) {
		pcEvent = new Message( M_MOUSE_DOWN );
//		dbprintf( "Mouse Button 2 Down\n");
	    } else {
		pcEvent = new Message( M_MOUSE_UP );
//		dbprintf( "Mouse Button 2 Up\n");
	    }
	    pcEvent->AddInt32( "_button", 2 );
	    pcEvent->AddInt32( "_buttons", 2 ); // To be removed
	    EnqueueEvent( pcEvent );
	}
    }
    if ( nDeltaX != 0 || nDeltaY != 0 ) {
	Message* pcEvent = new Message( M_MOUSE_MOVED );
	pcEvent->AddPoint( "delta_move", cDeltaMove );
	EnqueueEvent( pcEvent );
    }
}
Example #2
0
status_t ConvertFromAMessage(const os::Message & from, Message & to) 
{
   to.Clear();
   to.what = from.GetCode();

   int numNames = from.GetNumNames();
   for (int32 i=0; i<numNames; i++)
   {
      int type;
      int count;
      std::string name = from.GetName(i);
      if (from.GetNameInfo(name.c_str(), &type, &count) == B_NO_ERROR)
      {
         for (int j=0; j<count; j++)
         {
            const void * nextItem;
            size_t itemSize;
            if (from.FindData(name.c_str(), type, &nextItem, &itemSize, j) != B_NO_ERROR) return B_ERROR;

            // do any necessary translation from the AtheOS data types to Muscle data types
            switch(type)
            {
               case os::T_POINT:
               {
                  const os::Point * p = static_cast<const os::Point *>(nextItem);
                  Point pPoint(p->x, p->y);
                  if (to.AddPoint(name.c_str(), pPoint) != B_NO_ERROR) return B_ERROR;
               }
               break;

               case os::T_RECT:
               {
                  const os::Rect * r = static_cast<const os::Rect *>(nextItem);
                  Rect pRect(r->left, r->top, r->right, r->bottom);
                  if (to.AddRect(name.c_str(), pRect) != B_NO_ERROR) return B_ERROR;
               }
               break;

               case os::T_MESSAGE:
               {
                  os::Message amsg;
                  if (amsg.Unflatten(static_cast<const uint8 *>(nextItem)) != B_NO_ERROR) return B_ERROR;
                  Message * newMsg = newnothrow Message;
                  if (newMsg)
                  {
                     MessageRef msgRef(newMsg);
                     if (ConvertFromAMessage(amsg, *newMsg) != B_NO_ERROR) return B_ERROR;
                     if (to.AddMessage(name.c_str(), msgRef) != B_NO_ERROR) return B_ERROR;
                  }
                  else {WARN_OUT_OF_MEMORY; return B_ERROR;}
               }
               break;

               default:
                  if (to.AddData(name.c_str(), type, nextItem, itemSize) != B_NO_ERROR) return B_ERROR;
               break;
            }

         }
      }
   }
   return B_NO_ERROR;
}
Example #3
0
void USBMouseDriver::DispatchEvent( int nDeltaX, int nDeltaY, uint32 nButtons, int nVScroll, int nHScroll )
{
    Point cDeltaMove( nDeltaX, nDeltaY );
    static uint32 nLastButtons = 0;
    uint32 	nButtonFlg;
  
    nButtonFlg	= nButtons ^ nLastButtons;
    nLastButtons	= nButtons;

    if ( nButtonFlg != 0 ) {
	Message* pcEvent;
    
	if ( nButtonFlg & 0x01 ) {
	    if ( nButtons & 0x01 ) {
		pcEvent = new Message( M_MOUSE_DOWN );
	    } else {
		pcEvent = new Message( M_MOUSE_UP );
	    }
	    pcEvent->AddInt32( "_button", 1 );
	    pcEvent->AddInt32( "_buttons", 1 ); // To be removed
	    EnqueueEvent( pcEvent );
	}
	if ( nButtonFlg & 0x02 ) {
	    if ( nButtons & 0x02 ) {
		pcEvent = new Message( M_MOUSE_DOWN );
	    } else {
		pcEvent = new Message( M_MOUSE_UP );
	    }
	    pcEvent->AddInt32( "_button", 2 );
	    pcEvent->AddInt32( "_buttons", 2 ); // To be removed
	    EnqueueEvent( pcEvent );
	}
        // (xxl) Middle mouse button
	if ( nButtonFlg & 0x04 ) {
	    if ( nButtons & 0x04 ) {
		pcEvent = new Message( M_MOUSE_DOWN );
	    } else {
		pcEvent = new Message( M_MOUSE_UP );
	    }
	    pcEvent->AddInt32( "_button", 3 );
	    pcEvent->AddInt32( "_buttons", 3 ); // To be removed
	    EnqueueEvent( pcEvent );
	}
    }
    if ( nDeltaX != 0 || nDeltaY != 0 ) {
	Message* pcEvent = new Message( M_MOUSE_MOVED );
	pcEvent->AddPoint( "delta_move", cDeltaMove );
	EnqueueEvent( pcEvent );
    }
    // (xxl) Vertical and/or horizontal scroll
    if( nVScroll !=0 || nHScroll != 0 ) {
       Point cScroll( nHScroll, nVScroll );
       // send a specific scroll message: M_MOUSE_SCROLL
       Message* pcEvent = new Message( M_WHEEL_MOVED );
       // the "delta_move" key contains the scroll amount
       // as a os::Point structure ("x" for horizontal and
       // "y" for vertical). Usually the scroll amount is
       // either -1, 0 or 1, but I noticed that sometimes
       // the mouse send other values as well (-2 and 2 are
       // the most common).
       pcEvent->AddPoint( "delta_move", cScroll );
       EnqueueEvent( pcEvent );
    }
}