• Advertisement
Sign in to follow this  

DInput Design: Managing Devices

This topic is 4839 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm rewriting my old Input class, and I'm having dificulties designing an input system that is scalable. I'm thinking of merging all of the input information (mouse, keyboard, joysticks, gamepads) into one huge array of state information, which I'll then map to game-related actions (running, firing, etc)... This becomes complex, as some actions are of a boolean nature (is the player firing? is he not?) and others require a scale (how much to the left if the Force Feedback Wheel turning), and also because there can be any number of input devices (I currently have an XBox controller, and a Microsoft Sidewinder FF Pro). So, I'm thinking of having a container class "Actions", which has a "Fill" method. Imagine these two actions: - Brake (boolean, either on or off) - Throttle (variable scalar, between 0 and 1000) Now, if our primary input device is Keyboard, then Fill will: Brake: If "SpaceBar" key pressed, then Brake = True. Throttle: If "Up Arrow" key is pressed then Throttle = 1000, else Throttle=0. And now Fill using the GamePad input Device: Brake: If "Key 01" key is pressed, then Brake = true. Throttle: Fetch Axis 01, Throttle equals that value (value will range from 0 to 1000). This works I think, but it can get quite complex due to the various types of input devices, and what each can and cannot do... My real question is, how do you manage it? [Edited by - Prozak on October 24, 2004 9:35:44 PM]

Share this post


Link to post
Share on other sites
Advertisement
I was thinking about this earlier as well. I like your concept of a monolithic input system. As for values, how about using floating point and automatically mapping booleans and scalars to [0.0, 1.0]. The problem with that is infinite range inputs wouldn't work. Maybe, for infinite inputs, you could provide a sensitivity attribute and return their scaled value relative to the last query. Anyways, that's all I can think of at the moment...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement