dhewm3/neo/sys/osx/showcursor.c

55 lines
1 KiB
C
Raw Normal View History

2011-11-22 21:28:15 +00:00
/*
cc -o showcursor showcursor.c -framework IOKit
*/
#include <IOKit/IOKitLib.h>
#include <IOKit/hidsystem/IOHIDShared.h>
#include <assert.h>
mach_port_t masterPort;
io_connect_t OpenEventDriver( void )
{
register kern_return_t kr;
mach_port_t ev, service, iter;
2011-11-22 21:28:15 +00:00
kr = IOServiceGetMatchingServices( masterPort, IOServiceMatching( kIOHIDSystemClass ), &iter);
assert( KERN_SUCCESS == kr);
2011-11-22 21:28:15 +00:00
service = IOIteratorNext( iter );
assert(service);
2011-11-22 21:28:15 +00:00
kr = IOServiceOpen( service, mach_task_self(), kIOHIDParamConnectType, &ev);
assert( KERN_SUCCESS == kr );
2011-11-22 21:28:15 +00:00
IOObjectRelease( service );
IOObjectRelease( iter );
2011-11-22 21:28:15 +00:00
return( ev );
2011-11-22 21:28:15 +00:00
}
void TestParams( io_connect_t ev, boolean_t show )
{
kern_return_t kr;
2011-11-22 21:28:15 +00:00
kr = IOHIDSetCursorEnable( ev, show );
assert(KERN_SUCCESS == kr);
2011-11-22 21:28:15 +00:00
}
int main(int argc, char **argv)
{
kern_return_t kr;
boolean_t show;
2011-11-22 21:28:15 +00:00
if (argc != 2)
show = 1;
else
show = (atoi(argv[0]) != 0);
2011-11-22 21:28:15 +00:00
assert( KERN_SUCCESS == ( kr = IOMasterPort( bootstrap_port, &masterPort) ));
TestParams( OpenEventDriver(), show);
2011-11-22 21:28:15 +00:00
return( 0 );
2011-11-22 21:28:15 +00:00
}