Original Post
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]