Click here to Skip to main content
15,847,750 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
void testCFTcpServer()
{
    CFTcpServer server;
    int port = 8000;
    if(!server.setup(port))
    {
        std::cout << std::endl << "server setup failed"<< std::endl;
        return;
    }
    std::cout << std::endl << "server running"<< std::endl;

    CFRunLoopRun();
}


How can I use the device call back event here in this server program...
what should I do?
Posted
Updated 31-Oct-10 11:05am
v2
Comments
voloda2 20-Oct-10 9:26am    
What exactly do you means by device callback event?
bhawna.gopalka 20-Oct-10 9:38am    
i want to send the event of the mouse to the server..



void Mouse3D::deviceValueCallback( void * inContext, IOReturn inResult, void * inSender, IOHIDValueRef inIOHIDValueRef )
{
//#pragma unused( inSender )
IOHIDElementRef eref = IOHIDValueGetElement( inIOHIDValueRef );
if (!eref) return;



IOHIDDeviceRef tIOHIDDeviceRef = IOHIDElementGetDevice(eref);
if (!tIOHIDDeviceRef) return;

Mouse3D *d = ( Mouse3D* ) inContext;
if (!d) return;

std::cout << std::endl;

UInt32 usagePage = IOHIDElementGetUsagePage( eref );
UInt32 usage = IOHIDElementGetUsage( eref );

if ( !usagePage || !usage ) return;
if ( -1 == usage ) return;

//HIDDumpElementInfo(eref);
CFIndex value = IOHIDValueGetIntegerValue(inIOHIDValueRef);

switch(usagePage)
{
case Usage::PRIMARY_USAGE_PAGE:
switch(usage)
{
case Usage::USAGE_X: d->asyncEvent.tx = value; break;
case Usage::USAGE_Y: d->asyncEvent.ty = value; break;
case Usage::USAGE_Z: d->asyncEvent.tz = value; break;
case Usage::USAGE_RX: d->asyncEvent.rx = value; break;
case Usage::USAGE_RY: d->asyncEvent.ry = value; break;
case Usage::USAGE_RZ: d->asyncEvent.rz = value; break;
}
break;

case Usage::USAGE_PAGE_BUTTON:
d->asyncEvent.buttons[usage-1] = (value == 1); break;
break;
}

d->asyncEvent.printOn(std::cout);

}
}
this is the device value call back

1 solution

You need a client, a counter part which communicates to your networking class CFTcpServer. For example create a client socket that connects to you server (port 8000 in your example), then for each mouse event collect the relevant information and send it to the server. Start with a simple networking example.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900