[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3.2 Command Input

The commandinput property class implements a simple way to register input binds and get appropriate callbacks in response to them.

Property Class Details

General Information

PcCommandInput serves for receiving mouse, keyboard and joystick input messages inside entities. Also handles loading/saving of config files for easy specification of commands attached to each kind of input events.

This property class works by defining a series of Binds that link input events codes to the desired messages to receive at the entity behaviour.

This Binds can be specified either by using xml actions (for blxml and map format) or iPcCommandInput api (for c++ or blpython).

Bind codes

Bind codes can correspond to key codes or to special codes to handle different situations, here is a list of currently supported codes:

Also for joystick/mouse move events ‘_centered’ can be appended to the bind code to get coordinates relative to the center of the screen.

Message callbacks at behaviours

Message callbacks received when a bind is fullfilled always start with ‘pccommandinput_’, with the specified command code appended afterwards.

For example, for a bind defined as pitch = MouseY, the message would be ‘pccommandinput_pitch’.

Also for key/button messages the key state can be included in the message name, so for example a bind defined as forward = up, the received messages would be ‘pccommandinput_forward1’ (key down), ‘pccommandinput_forward0’ (key press) and ‘pccommandinput_forward_’ (key autorepeat).

Note this the default behaviour but can be turned off to get only one message for all states. For this ‘.args’ must be appended to the command name, so for example a bind defined as forward.args = up would receive only ‘pccommandinput_forward’ message, with ‘state’ parameter holding the state.

Config file.

Config files can hold binds, by using the following notation:

<section>.Input.Bind.<commandcode> = <bindcode> [bindcode2] ... [bindcodeN]

This would be an example config file:

 
; this is a command definition for a spaceship.
Ecksdee.Input.Bind.fire = JoystickButton0
Ecksdee.Input.Bind.forward = JoystickButton1
Ecksdee.Input.Bind.turbo = JoystickButton2
Ecksdee.Input.Bind.brake = JoystickButton3
Ecksdee.Input.Bind.slide = JoystickButton4
Ecksdee.Input.Bind.afterburner = JoystickButton5
Ecksdee.Input.Bind.yaw = JoystickAxis0
Ecksdee.Input.Bind.pitch = JoystickAxis1
Ecksdee.Input.Bind.yaw = JoystickAxis2
Ecksdee.Input.Bind.pitch = JoystickAxis3

Ecksdee.Input.Bind.rotateup = up
Ecksdee.Input.Bind.rotatedown = down

Ecksdee.Input.Bind.rotateleft = left
Ecksdee.Input.Bind.rotateright = right

Ecksdee.Input.Bind.fire = c
Ecksdee.Input.Bind.forward = x
Ecksdee.Input.Bind.turbo = space
Ecksdee.Input.Bind.brake = shift
Ecksdee.Input.Bind.slide = alt
Ecksdee.Input.Bind.afterburner = ctrl

Ecksdee.Input.Bind.dumpinventory = i
Ecksdee.Input.Bind.cammode = tab
Ecksdee.Input.Bind.resetpos = r
Ecksdee.Input.Bind.nextreg = t

The binds can then be loaded from the property class by doing LoadConfig(<section>), note for this the config file must already be loaded. LoadConfig is available both as xml action for blxml/map files, and from iPcCommandInput api for c++ and python.

PcCommandInput properties

PcCommandInput also has several properties that can be set to further customize behaviour from this property class, these are:

Defining command input for an entity in map xml.

To define an entity that uses this property class we add a <propclass> stance to the entity or entity template <addon> section.

 
<addon entityname="SpaceShip" plugin="cel.addons.celentity">
  <propclass name="pcinput.standard">
    <action name="LoadConfig">
      <par name="prefix" string="Ecksdee"/>
    </action>
  </propclass>
  <propclass name="pcobject.mesh">
    <action name="SetMesh">
      <par string="orogor" name="name"/>
    </action>
  </propclass>
  <behaviour layer="blpython" name="spaceship"/>
</addon>

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated using texi2html 1.76.