Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to deal with varied input devices?



I've been dabbling with the HID Manager lately. The APIs are simple
enough, but I'm a bit stumped as to how to put them to practical use.

Let's take a simple example: suppose I'm writing a game where the only
control you have is to move your character in the 8 compass directions.
I want to allow people to sit back in their comfy chair and play this
with their favorite game pad or joystick.

The trouble is, a brief survey of some colleague's various controllers
reveals a wide variety in how the directional input is presented:

- Some controllers present the D-pad as a single input element with a
value of 0 for up, 1 for up/right, 2 for right, and so on in clockwise
fashion; when not pressed at all, this element reports 15.

- Some controllers present the D-pad in a similar manner but use 1 for
up, 2 for up/right, etc., and use 0 to mean not pressed at all.

- Some controllers present the D-pad as four separate button inputs.

- Some controllers present the D-pad as two analog inputs (even though
they are in fact digital), each with a value of 64 when not pressed and
0 or 127 when pressed.

- Some controllers, of course, have true joysticks; these at least seem
consistent so far in presenting two analog inputs with values roughly
from 0 to 255.

How do I write code that makes sense of this mess, without requiring the
user to demonstrate all eight possible directions? (Note that asking
for the four cardinal directions isn't good enough, since with the first
two schemes above, the diagonal directions are not a simple combination
of the cardinal directions.)

Seems like every controller-savvy game must deal with these issues (ah,
for the days of InputSprocket...). Any tips for a newbie?

Thanks,
- Joe

--

,------------------------------------------------------------------.
| Joseph J. Strout Codenautics: quality Mac software |
| email@hidden http://codenautics.com/ |
`------------------------------------------------------------------'
_______________________________________________
mac-games-dev mailing list | email@hidden
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.



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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.