Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Revamped Input System
ricky Offline
Junior Member

Posts: 3
Threads: 1
Joined: May 2010
Reputation: 0
#1
Revamped Input System

Hey guys,

One of the things that I noticed when I first played Penumbra Overture (which I got in the humble bundle), was the lack of support for gamepads. As a programmer, with a now open-source piece of software, I decided to fill in this little gap... However, I went a little bit out of control, and rewrote a lot of the input system.

(You can find the changes at http://www.github.com/ricky26/HPL1Engine and http://www.github.com/ricky26/PenumbraOverture.)

There are currently a few bugs, especially in the area of the menu system, but overall as an initial implementation it works quite well. (I still have a lot of gunk from the old system to clean out and patch up.)

One feature that I am trying to work on is having a decent language for communicating complex control schemes to the engine. Every input device is split down into individual controls (a single button, slider, or axis of a gyroscope, etc), and each control can often be accessed in a number of ways. For example, with any games controller, you can specify Axis 1+, this is the 'button' simulated when you move the joystick to the positive end of Axis 1, or just 'Axis 1' which is the whole axis (which often provides a much smoother experience, especially when it is bound to a movement action).

As an example, here is my layout.xml for my xbox-360 controller:
<!-- Calibration Data -->
<Calibration device="Microsoft PC-joystick driver" control="Axis 1" offset="0" deadZone="0.2" cutoff="0.7" />
<Calibration device="Microsoft PC-joystick driver" control="Axis 2" offset="0" deadZone="0.2" cutoff="0.7" />
<Calibration device="Microsoft PC-joystick driver" control="Axis 3" offset="0" deadZone="0" cutoff="0.95" />
<Calibration device="Microsoft PC-joystick driver" control="Axis 4" offset="0" deadZone="0.2" cutoff="0.7" scale="6" />
<Calibration device="Microsoft PC-joystick driver" control="Axis 5" offset="0" deadZone="0.2" cutoff="0.7" scale="6"  />

<!-- Layout Configuration -->
<Action name="Quit">
    <Bind device="Keyboard" control="F12" />
</Action>
<Action name="Escape">
    <Bind device="Keyboard" control="Escape" />
    <Bind device="Microsoft PC-joystick driver" control="Button 8" />
</Action>
<Action name="Enter">
    <Bind device="Keyboard" control="Return" />
    <Bind device="Microsoft PC-joystick driver" control="Button 3" />
</Action>
<Action name="Click">
    <Bind device="Mouse" control="1" />
    <Bind device="Microsoft PC-joystick driver" control="Button 6" />
</Action>
<Action name="RightClick">
    <Bind device="Mouse" control="3" />
    <Bind device="Microsoft PC-joystick driver" control="Button 5" />
</Action>
<Action name="Interact">
    <Bind device="Mouse" control="1" />
    <Bind device="Microsoft PC-joystick driver" control="Button 6" />
</Action>
<Action name="Examine">
    <Bind device="Mouse" control="3" />
    <Bind device="Microsoft PC-joystick driver" control="Button 5" />
</Action>
<Action name="Jump">
    <Bind device="Keyboard" control="Space" />
    <Bind device="Microsoft PC-joystick driver" control="Button 1" />
</Action>
<Action name="Forward">
    <Bind device="Keyboard" control="W" />
</Action>
<Action name="Backward">
    <Bind device="Keyboard" control="S" />
</Action>
<Action name="Left">
    <Bind device="Keyboard" control="A" />
</Action>
<Action name="Right">
    <Bind device="Keyboard" control="D" />
</Action>
<Action name="LookX">
    <Bind device="Microsoft PC-joystick driver" control="Axis 5" />
</Action>
<Action name="LookY">
    <Bind device="Microsoft PC-joystick driver" control="Axis 4" />
</Action>
<Action name="MoveX">
    <Bind device="Microsoft PC-joystick driver" control="Axis 1" />
</Action>
<Action name="MoveY">
    <Bind device="Microsoft PC-joystick driver" control="Axis 2" inverted="1" />
</Action>
<Action name="Lean">
    <Bind device="Microsoft PC-joystick driver" control="Axis 3" inverted="1" />
</Action>
<Action name="LeanLeft">
    <Bind device="Keyboard" control="Q" />
    <!--<Bind device="Microsoft PC-joystick driver" control="Button 5" />-->
</Action>
<Action name="LeanRight">
    <Bind device="Keyboard" control="E" />
    <!--<Bind device="Microsoft PC-joystick driver" control="Button 6" />-->
</Action>
<Action name="InteractMode">
    <Bind device="Keyboard" control="R" />
    <Bind device="Microsoft PC-joystick driver" control="Button 4" />
</Action>
<Action name="Inventory">
    <Bind device="Keyboard" control="Tab" />
    <Bind device="Microsoft PC-joystick driver" control="Button 7" />
</Action>
<Action name="Notebook">
    <Bind device="Keyboard" control="N" />
    <Bind device="Microsoft PC-joystick driver" control="Hat 1 XAxis-" />
</Action>
<Action name="PersonalNotes">
    <Bind device="Keyboard" control="P" />
    <Bind device="Microsoft PC-joystick driver" control="Hat 1 XAxis+" />
</Action>
<Action name="ScrollUp">
    <Bind device="Mouse" control="4" />
    <Bind device="Microsoft PC-joystick driver" control="Hat 1 YAxis-" />
</Action>
<Action name="ScrollDown">
    <Bind device="Mouse" control="5" />
    <Bind device="Microsoft PC-joystick driver" control="Hat 1 YAxis+" />
</Action>
<Action name="Crouch">
    <Bind device="Keyboard" control="C" />
    <Bind device="Microsoft PC-joystick driver" control="Button 9" />
</Action>
<Action name="Flashlight">
    <Bind device="Keyboard" control="F" />
    <Bind device="Microsoft PC-joystick driver" control="Button 2" />
</Action>
<Action name="GlowStick">
    <Bind device="Keyboard" control="G" />
    <Bind device="Microsoft PC-joystick driver" control="Button 10" />
</Action>
<Action name="Zero">
    <Bind device="Keyboard" control="0" />
</Action>
<Action name="One">
    <Bind device="Keyboard" control="1" />
</Action>
<Action name="Two">
    <Bind device="Keyboard" control="2" />
</Action>
<Action name="Three">
    <Bind device="Keyboard" control="3" />
</Action>
<Action name="Four">
    <Bind device="Keyboard" control="4" />
</Action>
<Action name="Five">
    <Bind device="Keyboard" control="5" />
</Action>
<Action name="Six">
    <Bind device="Keyboard" control="6" />
</Action>
<Action name="Seven">
    <Bind device="Keyboard" control="7" />
</Action>
<Action name="Eight">
    <Bind device="Keyboard" control="8" />
</Action>
<Action name="Nine">
    <Bind device="Keyboard" control="9" />
</Action>

At the moment, there are 4 types of control:
  • A basic control, which provides a boolean value.
  • An axis control, which provides a floating-point value, (and a boolean specifying whether the joystick has been moved from the center).
  • A hat/POV/D-pad control, which provides a single direction, as well as 4 axes, each of which provides two simulated buttons.
  • A motion control, which dictates a displacement in one dimension, it also provides a boolean value (which is whether the control has moved at all).

The first 3 are used in the SDL gamepad driver as 'Button x', 'Axis x' and 'Hat x'. I have not yet moved the mouse to use motion controls. Tongue

And thus is my contribution, if anyone cares. Smile
05-22-2010, 12:40 AM
Find
Thomas Offline
Frictional Games

Posts: 2,634
Threads: 184
Joined: Apr 2006
Reputation: 68
#2
RE: Revamped Input System

Oh, cool! Big Grin
05-22-2010, 12:57 AM
Find
cdoublejj Offline
Junior Member

Posts: 32
Threads: 2
Joined: Mar 2007
Reputation: 0
#3
RE: Revamped Input System

(05-22-2010, 12:57 AM)Thomas Wrote: Oh, cool! Big Grin

we need things like this.
06-05-2010, 06:52 AM
Find




Users browsing this thread: 1 Guest(s)