forked from pioneerspacesim/pioneer
-
Notifications
You must be signed in to change notification settings - Fork 1
Discussion.Input System
John Bartholomew edited this page Oct 26, 2011
·
3 revisions
Requirements:
-
Support button and key-remapping
-
Support alternative keys for an action (e.g., Joystick Button 1, or Space key)
-
Support trigger and axis actions
-
Detect ambiguities in the mapping set
-
Allow shortcuts that use modifier keys
-
Group actions into action sets that can be enabled/disabled as a whole
-
Support modal input/input capture (e.g., the key binding options screen needs to be able to capture all input; text entry widgets need to be able to capture text input)
Actions:
- An Action is something like zooming, firing lasers, hyperspacing, switching view, rolling and so on. Actions come in two types: TriggerAction and AxisAction.
- Trigger actions fire once when the given button is pressed. Most GUI shortcuts would be implemented as trigger actions. Firing lasers would not be a trigger action, because the laser is supposed to keep firing while the key/button is held down. Triggers include mouse buttons I assume, mouse gestures like in Blender where a flick is detected might apply
- Axis actions have a current value. Axis actions are quite flexible, and probably easiest to understand through examples:
- Zoom controls would be a single axis action. One key maps to +zoom, one key maps to -zoom. The scroll wheel can also be mapped to the same Axis action.
- Manual flight orientation controls would be a set of axis actions (roll, pitch, yaw). Keyboard controls for these would be mapped in positive/negative pairs. These controls would probably also be mapped to the joystick.
- Manual flight linear thrust controls would be a set of axis actions similar to the orientation controls, but might have opposing thrusters mapped separately (? not sure). The main (forward) thruster could be mapped to a joystick throttle lever.
It would be intuitive, for some people, to have the opposing thrusters work simultaneously, even though releasing the key would be logical
- Don't understand what you mean by "releasing the key would be logical". If thrusters are mapped as one action per axis then you have a binding for +z and a binding for -z (two keys, if neither is pressed you're not thrusting; if both are pressed you're not thrusting). If thrusters are mapped as separate actions for opposing directions you get one binding for +forward and one binding for +backward (two keys, if neither is pressed you're not thrusting, if both are pressed, you're thrusting both ways and probably accelerating forwards since the main thruster is more powerful)
- I was thinking of equal side thrusters(where releasing one thruster is the same as firing both), for non-symmetric thrusters like forward/reverse it's better to map separately..there might end up being fuel consumption,noticeable lack of animation, and even a gameplay relevant burning effect of being too close which might justify not having a switch off effect for symmetric thrusters firing at once.
- Ok. I think we're in agreement (that it's better to map opposing thrusters to separate actions)
- Lasers would be mapped to an axis action, with one key mapped to +lasers.
- Firing simultanously from multiple lasers?
- I was assuming the current behaviour would be retained, so there's one key to fire and it fires whichever laser matches your current view.
- For multiple views (eg, multiple turrets) I would think mouse controls would be better, but haven't considered that before.
- different modes for different purposes might be catered for as a part of API I guess (controlling drones, specific equipment related overrides)
- I wouldn't expect the input layer itself to have to care about that -- obviously different combinations of actions/bindings/bindingsets can be set up by the game code as necessary. As long as the input layer doesn't have any fundamental restrictions that we think will cause problems.
- I was thinking along the lines of associating a set of bindings according to a mutually exclusive or a priority based system and switching between these instead of having software figure things out
- InputHandler stack gives binding priorities. The mutual exclusion stuff (detecting ambiguities in the bindings) is I think trickier and I'm still unsure about it (see notes at bottom). Suggestions welcome of course :-)
Bindings:
- InputButton and InputAxis are auxiliary types that specify one button (key, key+modifiers, mouse button, joystick button) or one axis (scroll wheel, joystick axis, mouse axis). They also provide string conversions for that data.
- A Binding takes input events and maps them onto one Action. The Binding specifies the way the input is mapped (e.g., a BindButtonToAxis binding would have axis values for pressed and un-pressed), and has an InputButton or InputAxis value specifying what button or axis it responds to.
Input handling stack:
- Input events are handled by sending them down a stack of InputHandler objects. Each InputHandler in the stack gets an opportunity to capture it.
- A BindingSet is an InputHandler which has references to a set of bindings and captures input for them, passing it on to their input mapping methods. An BindingSet can also detect ambiguities between its bindings.
- There will be a few other custom InputHandler types for specific purposes (text entry, key-binding screen)
Examples:
- When mouse flight controls are enabled, mouse events should be captured by pushing a BindingSet containing bindings for the mouse x & y axes (of course the mouse also has to be captured & hidden)
- All GUI keyboard shortcuts should become TriggerActions. Typically each GUI screen would have a BindingSet for its actions, which it pushes when it's shown and pops when it's hidden.
- Text entry widgets will require a custom InputHandler type which it should push onFocus and pop onBlur.
- Scrollable GUI widgets will have to push a BindingSet onMouseEnter to capture scroll-wheel events (? not sure I like this)
- External view, sector view and system view, should share a BindingSet for their view controls (zooming and rotation). A little care will have to be taken to avoid the current problem that scrolling in one of these views zooms in all of them.
Open questions/problems:
- What should the exact criteria for ambiguities between controls in a single BindingSet be? I'm particularly thinking of modifiers here. We have several trigger actions that use modifier keys (e.g., the time acceleration shortcuts). These shouldn't be considered ambiguous with shortcuts that don't use modifiers. However, what if someone tries to bind a modifier key itself to an action (trigger or axis)?
- The above only provides for ambiguity detection between controls in a single BindingSet, but BindingSets might be quite small -- perhaps BindingSets themselves need to be grouped and ambiguity detected within a whole group of BindingSets?