[ < ] [ > ]   [ << ] [ 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 MouseY = pitch, 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 up = forward, 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 up = forward.args 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>.CommandInput.Bind.<bindcode> = <commandcode>

This would be an example config file:

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

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

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

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

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

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.