View Full Version : InputSprocket to HID Manager
FreakSoftware
2004.01.18, 04:06 AM
In converting this top secret game of mine, I need to convert the use of InputSprocket to the HID Manager. (Or some plain code which does the same thing. Only keyboard support is _really_ required, but HID would be the best thing.)
Has anyone here done any InputSprocket to HID work or as used both and would be able to provide me with some assistance via email? I would very much appreciate it, and if all goes well (it seems to be going great so far!) the Mac community will have an old classic back in their hands! I haven't used either and I can't even find some decent documentation on HID.
FreakSoftware
2004.01.18, 07:54 AM
Alright, well never mind on the ISp -> HID help, because there was another version of the code that just used GetKeys so I didnt need to change a thing!
isgoed
2004.09.02, 04:01 PM
Alright, well never mind on the ISp -> HID help, because there was another version of the code that just used GetKeys so I didnt need to change a thing!
Would you share this information with us. It's nice for the other people who visit this thread afterwards.
isgoed
2004.09.02, 04:15 PM
Would you share this information with us. It's nice for the other people who visit this thread afterwards.
See this is how it works:
http://www.zsculpt.com/website/appsutils/hidwizard/hidwizard.html
In order to let google find this much more easier inputSprocket OSX OR "OS X" (http://www.zsculpt.com/website/appsutils/hidwizard/hidwizard.html)
edit: Amelio framework seems to do the same http://www.macupdate.com/info.php/id/13203
edit 2: only it can't be found any more. Not even on http://legacy.newdoom.com/
edit 3: hidwizard does not seem that great actually. It requires an installer; it is not MachO (It's that CFM-stuff you know) and it is closed source. Seems like I need to write my own code based on apples's HID.
aarku
2004.09.02, 04:41 PM
edit: Amelio framework seems to do the same http://www.macupdate.com/info.php/id/13203
Unfortunately the Amelio framework seems utterly broken at the moment. It relied on a static url that is no longer hosted at iDevGames (which can be changed or the functionaility removed without too much of a hassle). Additionally, preferences don't work correctly in Carbon, and your configuration for your game never gets saved.
It'd be wonderful to see someone (maybe me) work on Amelio. Now that I'm more used to OS X development I might be able to fix it if I get a chance.
I contacted the author of it about 8 months ago about figuring out why things weren't working but unfortunately couldn't come up with any answers. I'm sure it wasn't me screwing something up, because the example that came with Amelio didn't work even.
-Jon
p.s. I wasted a lot of time poking at Amelio. Good idea, needs work.
FreakSoftware
2004.09.02, 04:53 PM
Would you share this information with us. It's nice for the other people who visit this thread afterwards.
No, I can't. But either way, the GetKeys code didn't make the transition from ISp to HID easy, it gave me an avenue to ignore both entirely.
Fenris
2004.09.02, 05:07 PM
If anyone's interested, I've got a C++ class hierarchy that (needing a little cleanup, though) correctly handles InputSprocket and HID, with fallbacks to GetKeys completely transparently. Sound off, and I'll pack it up for you.
isgoed
2004.09.02, 06:07 PM
If anyone's interested, I've got a C++ class hierarchy that (needing a little cleanup, though) correctly handles InputSprocket and HID, with fallbacks to GetKeys completely transparently. Sound off, and I'll pack it up for you.
Yeah, I am interested. That's why I started scanning these forums in the first place. Maybe you can post your code on the internet? I am specifically interested in having a nice user configuration interface and secondly to have dual mouse input (split screen game). Anyway, I sent you an email.
aarku
2004.09.02, 06:10 PM
If anyone's interested, I've got a C++ class hierarchy that (needing a little cleanup, though) correctly handles InputSprocket and HID, with fallbacks to GetKeys completely transparently. Sound off, and I'll pack it up for you.
That sounds awesome! Such a thing would be good for many many mac game devs and would at the very minimum benifit Inkubator quite a bit. (When it gets back in gear after uDG!)
If it wouldn't be too much of a pain, that'd be awesome if you released that.
-Jon
ThemsAllTook
2004.09.02, 06:20 PM
If anyone's interested, I've got a C++ class hierarchy that (needing a little cleanup, though) correctly handles InputSprocket and HID, with fallbacks to GetKeys completely transparently. Sound off, and I'll pack it up for you.
I'd really like to see this too. Thanks!
Alex Diener
Fenris
2004.09.03, 03:43 AM
I looked at the code, and it is something of a mess. I'll do my very best to clean it up during the weekend. In the meantime, check out the HID Utilities sample code from Apple - that's where I learned it all. Look at the examples, and you'll be up and running with HID in no-time. :)
Anyways, the code is up at http://www.rusted.se/hidstuff.zip
I know there are bugs in it, it doesn't work perfectly with all gamepads (which is a bit odd) but at least it's a starting point. There's a lot of hardcoded stuff, and it is not compileable. (Because of omitted source)
The source includes the following:
InputController.cpp/h - the classes for handling an input controller. You create a pointer of type BaseInputController (which is a singleton, by the way) and set it to point to an object of the type you want (GetKeys, Events, HID or ISp) - check out the header.
HIDDevice.cpp/h is just the stuff that encapsulates a HID device, of course.
HIDDialog.cpp/h is a configuration dialog in Carbon. It is written on top of the stuff in BaseDialog.cpp/h, which is a quite nifty way of doing Carbon dialogs, by the way. I've gotta run, but check it out! And do ask questions. :)
isgoed
2004.09.03, 06:19 AM
I looked at the code, and it is something of a mess. I'll do my very best to clean it up during the weekend. In the meantime, check out the HID Utilities sample code from Apple - that's where I learned it all. Look at the examples, and you'll be up and running with HID in no-time. :)
Anyways, the code is up at http://www.rusted.se/hidstuff.zip
Yeah I downloaded your code. It looks good. I still see that it is not usable yet. You don't provide the nib-file for the dialog and looking at the code I's say you were making a first person shooter since I found some hard coded controlls defined.
And the code you made is actually a wrapper for Inputsprocket so only usable on OS9 right? But this doesn't matter, since HID and getkeys combo will probably be better. I always found inputsprocket the hardest to configure (and drawsprocket the one that just wouldn't listen). Your code at least seems easier to use.
Anyway, I am coding in C myself. Is there any way to use C and C++ code side by side, without renaming al my c-files to cpp-files? (Compiling in C still provides faster code).
Fenris
2004.09.03, 05:57 PM
You don't provide the nib-file for the dialog and looking at the code I's say you were making a first person shooter since I found some hard coded controlls defined.
Oops. Forgot about the nib. I'll provide it when I get the time. :)
And the code you made is actually a wrapper for Inputsprocket so only usable on OS9 right? But this doesn't matter, since HID and getkeys combo will probably be better.
Not really true. There are four complete classes in there (plus the base class) - one for GetKeys, one for Carbon Events, one for HID and one for InputSprocket. The InputSprocket class will not be compiled in if __MACH__ is defined, and HID won't be if it isn't. Thus, you'll have to build one version of the code for CFM and one for Mach-O, but that's mandatory anyway.
As for C and C++, yes, sure. Just put them into the same project. However, the file in which you use the classes must be a .cpp file.
I'll be back during the weekend.
isgoed
2004.09.20, 01:05 PM
Oops. Forgot about the nib. I'll provide it when I get the time. :)
iDevGames went offline in the last week. Could you put that nib online? I would apreciate it. thanks.
FreakSoftware
2004.09.21, 12:20 PM
Finder always says the zip file is corrupted...
Fenris
2004.10.04, 05:07 PM
Oh, sweet things, it completely slipped my mind. It's up at http://www.rusted.se/hiddialognib.zip
Sorry about the delay, and keep asking questions as they arise! :)
isgoed
2004.10.07, 03:22 PM
If anyone's interested, I've got a C++ class hierarchy that (needing a little cleanup, though) correctly handles InputSprocket and HID, with fallbacks to GetKeys completely transparently. Sound off, and I'll pack it up for you.
Well, I got your code compiled today. I could not get it to run properly. It still crashes because there were still dependencies on your classes, headers and resources. Your code did lead me to the apple source code, which was real usefull. I suggest everybody look at it. It's at: http://developer.apple.com/samplecode/Hardware/idxHumanInterfaceDeviceForceFeedback-date.html
. I made my own sample code based on apple. It works stand alone check it out at:
HID Sample Code: "Control HID input" at www.revaro.net/developer/
here is a snap:
http://www.revaro.net/developer/images/HID_Control_Input.jpg
laters,
FreakSoftware
2004.10.09, 06:01 PM
HID Sample Code: "Control HID input" at www.revaro.net/developer/
Ok, I would really like to pick this apart (Fenris' too), but what's with the missing code?
Am I the only programmer alive that likes to have a complete, working, well presented example where I can click "build" and it works?
Fenris
2004.10.09, 06:35 PM
No, you're not. :) However, you may be the only programmer alive with the time to do it. I'm mentally thinking about writing a HID tutorial, but I've got to fix my book reviews for IDG and then fix my school assignments. However, they way I learned it was to pick apart George Warner's HID Utilities example from developer.apple.com, but I don't think that's around anymore. ...
No, it's there: http://developer.apple.com/samplecode/HID_Utilities_Source/HID_Utilities_Source.html Also look at the other HID examples and pick them apart too. I'm sorry about my lacking support here, but I hardly have the time to even log on to here anymore. :( I'm available for any questions though.
Fenris
2004.10.09, 06:36 PM
Sorry, the HID utilities is just an abstraction layer to the 'real' HID stuff. It's great, but it's not a learning source. HID Explorer is what you want to look at.
isgoed
2004.10.10, 06:50 AM
Ok, I would really like to pick this apart (Fenris' too), but what's with the missing code?
Sorry,
I just put a corrected example online (it's version 1.0.1 now). www.revaro.net/developer
You wouldn't believe how I hated xcode just now. First it takes a minute to launch (normally 15 secs or so). Than it gives weird error messags, it's abnormaly slow, it crashes on me when I was nearly finished and then it doesn't want to copy the new dylib. Well I hope it works now for you.
You should now be able to just build it. Putting sample code and working applications online almost never works the first time.
FreakSoftware
2004.10.11, 08:49 PM
Sorry,
I just put a corrected example online (it's version 1.0.1 now). www.revaro.net/developer
Cool beans, I'll look at that now. Thanks. (Waiting for Brian's book...)
aegidian
2004.10.12, 08:52 AM
Brian Greenstone's new book Pangea Software's Ultimate Game Programming Guide for Mac OS X has a great chapter (12) dealing with HID, and spilling all the code for Nanosaur 2's HID interface.
Although I've only glanced at it for 15mins or so (it arrived this morning) I'd recommend it.
anonuser
2004.10.12, 07:55 PM
well you can do this, I don't reccomend this. but you can get a key press based on an event.
this is if you're using the Carbon Event Manager.
to your Event Type Spec add this a kEventClassKeyboard, and a kEventRawKeyDown. This will allow you to test for keyboard events when a key is down. However you're limited in the fact modifier keys won't work of the bat but it is really easy to get the key pressed.
sample Event Type Spec:
EventTypeSpec mainSpec[] = {
{ kEventClassCommand, kEventCommandProcess },
{ kEventClassMouse, kEventMouseDown },
{ kEventClassControl, kEventControlHit },
{ kEventClassWindow, kEventWindowBoundsChanged },
{ kEventClassWindow, kEventWindowClose },
{ kEventClassKeyboard, kEventRawKeyDown},
{ kEventClassKeyboard, kEventRawKeyRepeat }
};
just add this when you're testing if a key was pressed to get the pressed key.
char macKey;
GetEventParameter(event,kEventParamKeyMacCharCodes ,typeChar,NULL,sizeof(macKey),NULL,&macKey);
that'll get you you're key, provided your event handler is setup correctly .
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.