Sign in to follow this  
F-Kop

My Input Interface

Recommended Posts

I have spent the past 30 minutes or so thinking of a good interface for input in a game. It would be able to support most input devices that I can think of. I'm open to any comments and suggestions. I guess I would mostly just like to know if this is anything like the interface used in commercial game engines. Here's the general layout: OpenController - Create controller structure CloseController - Free controller structure SetControllerValue - Set value (port indicator, force feedback, etc) GetControllerInfo - Get controller type, name, maybe a stock icon, etc OpenCharListener - (Unicode) Call a function when text is typed on a keyboard CloseCharListener - Close character listener GetKeyState - Get state of keyboard key, mouse button, gamepad button, etc OpenKeyListener - Call a function when the state of a key changes CloseKeyListener - Close key listener GetKeyInfo - Get key type, name, text value, stock icon, etc SetAnalogMode - Set minimum response, curve, cap, and sensitivity of an analog stick GetAnalogDistance - Return the position of an analog stick GetAnalogInfo - Get analog type, name, stock icon, etc SetMotionMode - Set minimum response, curve, cap, and sensitivity of a mouse or motion enabled device (like a wiimote or sixaxis) OpenMotionListener - Open a motion listener (not like a char or key listener) GetMotionDistance - Return the distance traveled since last call CloseMotionListener - Close a motion listener GetMotionInfo - Get motion type, name, stock icon, etc Here's a brief explanation of SetAnalogMode and SetMotionMode. Minimum response is the minimum value required to return any value, curve is an exponent applied to the value, cap is the maximum value, and sensitivity is multiplied. Here's the general formula: return_value = Min( cap, Max( minimum_response, pow( original_value, curve ) * sensitivity ) ); [Edited by - F-Kop on February 1, 2008 2:05:32 PM]

Share this post


Link to post
Share on other sites
The API seems pretty comprehensive. But the devil is in the details, and the parameters to each function will matter. Think about how you will handle keypresses like Ctrl-Alt-Tab or Shift-F7. Also consider how to handle non-ASCII text input.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this