Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: mouse, keyboard ... (continued ...)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mouse, keyboard ... (continued ...)



what should I set in the "PrimaryUsagePage" in the matching directory ?
it's quite unclear to me ...


I've seen some example where they use '1', but why ? ...


BW I have 2 keyboard, but my call return 3.
when I display IORegistryEntryGetPath with kIOServicePlane argument, it
seems that one of the 3 keyboard, is in fact my USB mouse ..... any
ideas ?

On Saturday, March 22, 2003, at 04:51 AM, Rob Yepez wrote:

> IOHIDKeyboardDevice is a compatibility shim put in place to make older
> keyboard drivers visible to the HID Manager.
>
> How many keyboards do you have attached to your system?
>
> You have to keep in mind that the HID Manager works with other
> transports as well. To limit your search to USB devices, add a
> key/value pair of kIOHIDTransportKey/"USB" to your matching > dictionary.
>
> Also, i noticed that you are only adding the PrimaryUsage to the
> matching dictionary. You should really add the PrimaryUsagePage to
> your matching dictionary as well. This will eliminate any noise if
> you were to add other types of HID Devices to your machine.
>
> - Rob
>
> On Thursday, March 20, 2003, at 08:44 PM, Lloyd Dupont wrote:
>
>> now IOKit examples and documentation begin to make sense.
>> I realize that they describe well how to access SCSI, serial, etc ..
>> device, but they forget to describe the HID one.
>> Furthermore the HID key (
>> #define kIOHIDTransportKey "Transport"
>> #define kIOHIDVendorIDKey "VendorID"
>> #define kIOHIDProductIDKey "ProductID"
>> #define kIOHIDVersionNumberKey "VersionNumber"
>> #define kIOHIDManufacturerKey "Manufacturer"
>> #define kIOHIDProductKey "Product"
>> #define kIOHIDSerialNumberKey "SerialNumber"
>> #define kIOHIDLocationIDKey "LocationID"
>> #define kIOHIDPrimaryUsageKey "PrimaryUsage"
>> #define kIOHIDPrimaryUsagePageKey "PrimaryUsagePage"
>> )
>> are not all very meaningful, what's "LocationID" for instance ?
>>
>> Anyway I have one more immediate worry.
>> Now I'm able to have a list of a given type of USB device (let say
>> keyboard) (see code sample see below) what embarrassed me is, when I
>> tried to list the keyboard I get 3 instance, 3 of them instance of
>> class "IOHIDKeyboardDevice", what could it be ?
>>
>> how to cull the noise ?
>> any thought ? ideas ? links ?
>>
>> (BTW, where is defined "mach_port_deallocate()" I see in sample I
>> should use it, and it link well, but it's not in the man page, neither
>> in IOKit headers)
>>
>> // --- get list code ----
>> // call with kHIDUsage_GD_Keyboard, kHIDUsage_GD_Mouse, ...
>> static void FindMatchingHIDDevice(UInt32 HIDDevice)
>> {
>> mach_port_t masterPort = NULL;
>> io_iterator_t hidObjectIterator = NULL;
>> IOReturn ioReturnValue = kIOReturnSuccess;
>>
>> //Get a Mach port to initiate communication with I/O Kit.
>> ioReturnValue = IOMasterPort(bootstrap_port, &masterPort);
>> if(ioReturnValue != kIOReturnSuccess) {
>> printf("Could not create a master I/O Kit Port.");
>> return;
>> }
>>
>> // If error, print message and hang (for debugging purposes)
>> //print_errmsg_if_io_err(ioReturnValue, "Could not create a
>> master
>> I/O Kit Port.");
>>
>> CFMutableDictionaryRef hidMatchDictionary = NULL;
>> Boolean noMatchingDevices = false;
>>
>> // Set up a matching dictionary to search the I/O Registry by
>> class
>> // name for all HID class devices
>> hidMatchDictionary = IOServiceMatching(kIOHIDDeviceKey);
>>
>> // *** Should add code here for a more specific search ***
>> if (hidMatchDictionary != NULL)
>> {
>> CFNumberRef refDevice = CFNumberCreate (kCFAllocatorDefault,
>> kCFNumberIntType, &HIDDevice);
>> CFDictionarySetValue (hidMatchDictionary, CFSTR
>> (kIOHIDPrimaryUsageKey), refDevice);
>> }
>>
>> // Now search I/O Registry for matching devices.
>> ioReturnValue = IOServiceGetMatchingServices(masterPort,
>> hidMatchDictionary, &hidObjectIterator);
>>
>> noMatchingDevices = ((ioReturnValue != kIOReturnSuccess)
>> | (hidObjectIterator == NULL));
>>
>> //If search is unsuccessful, print message and hang.
>> if (noMatchingDevices) {
>> printf("No matching HID class devices found.");
>> return;
>> }
>>
>> // IOServiceGetMatchingServices consumes a reference to the
>> // dictionary, so we don't need to release the dictionary ref.
>> hidMatchDictionary = NULL;
>>
>> io_object_t hidDevice = NULL;
>> while ((hidDevice = IOIteratorNext(hidObjectIterator)))
>> info(hidDevice);
>>
>> IOObjectRelease(hidObjectIterator);
>>
>> //Free master port if we created one.
>> if (masterPort)
>> mach_port_deallocate(mach_task_self(), masterPort);
>> }
>> _______________________________________________
>> darwin-development mailing list | email@hidden
>> Help/Unsubscribe/Archives:
>> http://www.lists.apple.com/mailman/listinfo/darwin-development
>> Do not post admin requests to the list. They will be ignored.
_______________________________________________
darwin-userlevel mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-userlevel
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.