  | |  | HID devices alternative ? | HID devices alternative ? 2003-11-27 - By Geoff Stahl
Back Top of my head, you need to add IOKit framework to either the framework you create or to the project.
On Nov 27, 2003, at 12:17 AM, Alexander Repenning wrote:
> This code was of great help and worked well when creating a C, Carbon > application interfacing with gamePads etc. Unfortunately, using a > different programming language, I cannot create a complete C + Carbon > application but need to wrap the HIDUtility access code below up into > either a bundle or framework. This is causing an error when trying to > call any of the HID functions: > > gameDeviceInput:0: > /Users/alex/Projects/gameDeviceInput/ > libHIDUtilities.a(HID_Utilities.o) illegal reference to symbol: > _IODestroyPlugInInterface defined in indirectly referenced dynamic > library /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit > > The code is the same. All I changed is to create a framework instead > of an application. I am probably just missing a stupid little > detail.. on the other hand could it be that there is some conceptual > reason why code using the HIDUtilities cannot be turned into a > framework? > > any clues would be appreciated. > > > Alex > > > > > At 9:50 AM -0600 11/4/03, Wade Williams wrote: >> On Nov 4, 2003, at 1:19 AM, Patrice Krysztofiak wrote: >>> I did, i wasted a complete day on that code, I'm just clueless to >>> even how to use it, it's far too complicated for a simple gamepad. ( >>> and for my brain ) >>> >>> I'm looking for someone to help, so far the few people who contacted >>> me have the same problem :( >>> >>> patrice. >>> ps :Apple dev team : please make an RHID ( Real Human Interface >>> Device ) API for USB :) >>> >> >> In a general sense, there's nothing wrong with the HID Utilities >> code. (I say in a general sense because I know those with complex >> needs have things they'd like it to do different/better) >> >> What is wrong from your point of view is that there's no real >> documentation, so to read the headers and sample code and figure it >> out assumes you have some experience. >> >> So, with that said, let's try to make it as easy as possible. >> >> 1) Download the HID Utilities sample code. >> >> 2) Double-click the HID Utilities slib.pbproj file to open it in >> Project Builder. >> >> 3) Click build. This will create a build folder that will contain >> libHIDUtilities.a once it's finished building. (Actually building it >> may not be necessary, but it doesn't hurt.) >> >> 4) Add libHIDUtilities.a to your project. >> >> 5) Add #include "HID_Utilities_External.h" and #include >> <Kernel/IOKit/hidsystem/IOHIDUsageTables.h> >> to your joystick code file. >> >> 6) Build a list of devices by doing: >> >> HIDBuildDeviceList( NULL, NULL ); >> >> if (! HIDHaveDeviceList() ) >> return NULL; >> >> num_devices = HIDCountDevices(); >> >> 7) Loop through the devices, looking for the one you're interested >> in. You find it by matching its usage and usagePage. For example, >> for a game pad, you'd look for a usagePage of kHIDPage_GenericDesktop >> and a usage of kHIDUsage_GD_GamePad. (All this stuff is found in >> IOHIDUsageTables.h) >> >> >> pRecDevice deviceCandidate = NULL, *stored_device[100 ]; >> int i, foundDevices = 0; >> >> deviceCandidate = HIDGetFirstDevice(); >> >> i = 0; >> while ( i < num_devices ) >> { >> if ( deviceCandidate ) >> { >> //here I filter out keyboards, mice and totally unrelated devices >> if ( (deviceCandidate->usage == kHIDUsage_GD_Keyboard) >> || (deviceCandidate->usagePage != kHIDPage_GenericDesktop) || >> (deviceCandidate->usage == kHIDUsage_GD_Mouse) ) >> { >> if ( HIDIsValidDevice( deviceCandidate ) ) >> { >> //skip this one and just go on to the next one >> deviceCandidate = HIDGetNextDevice( deviceCandidate ); >> } >> else >> { >> //handle error >> } >> } >> else >> { >> if ( HIDIsValidDevice( deviceCandidate ) ) >> { >> //store the device in a list of devices we're interested in >> stored_device[foundDevices] = deviceCandidate; >> deviceCandidate = HIDGetNextDevice( deviceCandidate ); >> foundDevices++; >> } >> else >> { >> //handle error >> } >> >> >> } >> >> i++; >> } >> } >> >> 8) Now that you've got the device, go through its elements and find >> the axis or button you're interested in: >> >> if ( HIDIsValidDevice( device ) ) >> { >> elRec=HIDGetFirstDeviceElement( js_devices[id].device, >> kHIDElementTypeInput ); >> if ( elRec ) >> { >> >> switch (elRec->usagePage) >> { >> case kHIDPage_GenericDesktop: >> switch ( elRec->usage ) >> { >> case kHIDUsage_GD_X: >> x_axis = elRec; >> break; >> case kHIDUsage_GD_Y: >> y_axis = elRec; >> break; >> case kHIDUsage_GD_GamePad: >> pad = elRec; >> break; >> //etc >> } >> } >> >> //if the right element was not found, continue looping through the >> rest of the elements by calling HIDGetNextDeviceElement() until you >> //find the right one or it returns NULL >> } >> >> 9) Now that you've got the actual element, you can query it's value: >> >> if ( HIDIsValidElement( devicePtr, elementPtr ) ) >> { >> value = HIDGetElementValue(devicePtr, elementPtr); >> } >> >> I hope this helps. >> >> Wade >> __ ____ ____ ____ ____ ____ ____ ____ ____ ____ >> mac-games-dev mailing list | mac-games-dev@(protected) >> Help/Unsubscribe/Archives: >> http://www.lists.apple.com/mailman/listinfo/mac-games-dev >> Do not post admin requests to the list. They will be ignored. > > > -- > Prof. Alexander Repenning > University of Colorado > Department of Computer Science and > Center of LifeLong Learning & Design > Campus Box 430 > Boulder, CO 80309-0430 > __ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ___ > mailto:ralex@(protected) phone: (303) 492-1349 > http://www.cs.colorado.edu/~ralex/ fax: (303) 492-2844 > __ ____ ____ ____ ____ ____ ____ ____ ____ ____ > mac-games-dev mailing list | mac-games-dev@(protected) > Help/Unsubscribe/Archives: > http://www.lists.apple.com/mailman/listinfo/mac-games-dev > Do not post admin requests to the list. They will be ignored. > > --- Geoff Stahl 3D Software Engineer Apple __ ____ ____ ____ ____ ____ ____ ____ ____ ____ mac-games-dev mailing list | mac-games-dev@(protected) Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/mac -games-dev Do not post admin requests to the list. They will be ignored.
Earn $52 per hosting referral at Lunarpages.
|
|
 |