Ask a Question related to Mac Programming, Design and Development.
-
Emmanuel Dreyfus #1
[Q] IOKit: Inside the bowels of IOHIDSystem
Hi everyone
I try to understand the kernel/userland interface of the IOHIDSystem
driver in MacOS X. I wrote the following test code, strongly inspired
from XDarwin sources. But whatever happens, I never get any event for
moved mouse in the low level queue.
Anyone has an idea why?
#include <mach/mach_types.h>
#include <mach/mach_host.h>
#include <mach/mach_traps.h>
#include <mach/mach_init.h>
#include <IOKitLib.h>
#include <IOLLEvent.h>
#include <IOHIDShared.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
void dump(char *, size_t);
/*
* cc -Wall -Werror -ansi \
* -I/System/Library/Frameworks/IOKit.framework/Headers \
* -I/System/Library/Frameworks/IOKit.framework/Headers/hidsystem \
* -L/System/Library/Frameworks/IOKit.framework -g
* -o test -lIOKit test.c
*/
int
main(argc, argv)
int argc;
char **argv;
{
host_name_port_t hs;
io_master_t iop;
kern_return_t ret;
mach_port_t rp;
CFMutableDictionaryRef classToMatch;
char *cn = "IOHIDSystem";
io_iterator_t iterator;
io_object_t serviceObject;
io_connect_t dataport;
vm_address_t shmem;
vm_size_t size;
EvGlobals *evg;
int i;
int log;
if (argc != 2) {
printf("usage: %s logfile\n", argv[0]);
return 1;
}
log = open(argv[1], O_WRONLY|O_TRUNC|O_CREAT, 0644);
if (log == -1) {
perror("cannot open log file");
return 1;
}
rp = mach_reply_port();
hs = mach_host_self();
ret = IOMasterPort(MACH_PORT_NULL, &iop);
printf("ret = 0x%x, rp = 0x%x, hs = 0x%x, iop = 0x%x\n",
ret, rp, hs, iop);
if (ret != 0)
return 1;
classToMatch = IOServiceMatching(cn);
ret = IOServiceGetMatchingServices(iop,
classToMatch, &iterator);
printf("ret = 0x%x, iterator = 0x%x\n", ret, iterator);
if (ret != 0)
return 1;
serviceObject = IOIteratorNext(iterator);
printf("serviceObject = 0x%x\n", serviceObject);
ret = IOServiceOpen(serviceObject, mach_task_self(),
0, &dataport);
printf("ret = 0x%x, dataport = 0x%x\n", ret, dataport);
if (ret != 0)
return 1;
ret = IOHIDCreateSharedMemory(dataport,
kIOHIDCurrentShmemVersion);
printf("ret = 0x%x\n", ret);
if (ret != 0)
return 1;
ret = IOConnectMapMemory(dataport, kIOHIDGlobalMemory,
mach_task_self(), &shmem, &size, kIOMapAnywhere);
printf("ret = 0x%x, shmem = 0x%x, size = 0x%x\n",
ret, shmem, size);
if (ret != 0)
return 1;
evg = (EvGlobals *)(shmem +
((EvOffsets *)shmem)->evGlobalsOffset);
printf("evg = %p\n", evg);
if (evg == NULL)
return 1;
evg->movedMask = NX_MOUSEMOVEDMASK;
printf("Perform an action within 3 seconds... \n");
sleep(3);
printf("Okay, let's dump in the logfile...\n");
(void)close(1);
(void)dup(log);
printf("LLEHead = %d\n", evg->LLEHead);
printf("LLETail = %d\n", evg->LLETail);
printf("LLELast = %d\n", evg->LLELast);
for (i = 0; i < LLEQSIZE; i++) {
printf("item %d\n", i);
printf(" next = %d, type = %d, flags = %d\n",
evg->lleq[i].next,
evg->lleq[i].event.type,
evg->lleq[i].event.flags);
printf(" x = %d, y = %d, window = %d\n",
evg->lleq[i].event.location.x,
evg->lleq[i].event.location.y,
evg->lleq[i].event.window);
dump((char *)&evg->lleq[i].event.data,
sizeof(evg->lleq[i].event.data));
}
printf("\n\nFull dump of the shared memory\n");
dump((char *)shmem, size);
return 0;
}
void
dump(data, len)
char *data;
size_t len;
{
int i, j;
for (i = 0; i < len; i += 16) {
printf("%p ", &data[i]);
for (j = i; j < i + 16; j += 4)
printf("0x%08x ", *((int *)(&data[j])));
printf(" ");
for (j = i; j < i + 16; j++)
if (isprint(data[j]))
printf("%c", data[j]);
else
printf(".");
printf("\n");
}
return;
}
--
Emmanuel Dreyfus
[email]manu@netbsd.org[/email]
Emmanuel Dreyfus Guest
-
Dynamic temp. datagrid col.gen. -Session access inside a class inside a UserCtrl
Hello Dear Professionals: Based on this document:... -
Using class inside ASP
Hi all professional I would like to know how to using java class file inside ASP page I have placed the class file to C:\WINNT\java\trustlib... -
buttons inside MCs
I have a movie clip as a rollover menu, which as 4 buttons within it. The movie clips has the following code attached to it, making the MC play... -
Problem with an usb adsl modem driver - IOKit
Hello, I have some problems with an usb adsl modem driver. My modem is recognized when I start it up after Mac's launching, but in all other... -
OT: Sorry to intrude Please see Inside.
Wonder if anybody else is getting stupid pop ups from ByAdds or similar..they seem to change their name. Norton pro 2003 and AVG do not indicate any... -
Eric Albert #2
Re: [Q] IOKit: Inside the bowels of IOHIDSystem
In article <1g1dh7y.8ihsl21v0grpmN%manu@netbsd.org>,
[email]manu@netbsd.org[/email] (Emmanuel Dreyfus) wrote:
Probably not here. I'd suggest asking this on Apple's> I try to understand the kernel/userland interface of the IOHIDSystem
> driver in MacOS X. I wrote the following test code, strongly inspired
> from XDarwin sources. But whatever happens, I never get any event for
> moved mouse in the low level queue.
>
> Anyone has an idea why?
darwin-development mailing list.
-Eric
--
Eric Albert [email]ejalbert@stanford.edu[/email]
[url]http://rescomp.stanford.edu/~ejalbert/[/url]
Eric Albert Guest
-
Emmanuel Dreyfus #3
Re: [Q] IOKit: Inside the bowels of IOHIDSystem
Eric Albert <ejalbert@stanford.edu> wrote:
Thanks for the hint.> Probably not here. I'd suggest asking this on Apple's
> darwin-development mailing list.
Anyway, someone else gave me the answer behinf the scene: IOHIDSystem
will not report events until this is called:
IOHIDSetEventsEnable (dataport, TRUE);
--
Emmanuel Dreyfus
Publicité subliminale: achetez ce livre!
[url]http://www.eyrolles.com/php.informatique/Ouvrages/9782212112443.php3[/url]
[email]manu@netbsd.org[/email]
Emmanuel Dreyfus Guest



Reply With Quote

