CInputMap Class Reference

Used to get the state of a key, control, button etc. More...

#include <input.h>

List of all members.

Enum data

enum  eScancode {
  scancode_bad = -2, scancode_always = -1, scancode_none = 0, scancode_esc = 1 ,
  scancode_end_keyboard = 512 , scancode_mouse_right = 281 , scancode_joy_button_1 = 256 , scancode_joy2_button_1 = 268
}
 Input scancodes (keyboard, mouse, joypad, etc.). More...
static eScancode scancode_for_str (const char *str)
 Get the scancode for the character string input.

Public Member Functions

Create methods
 CInputMap ()
 Create with default values.
 CInputMap (const char *c)
 Create an input map using the character string.
 CInputMap (const char *c1, const char *c2)
 Create an input map using the character strings.
 CInputMap (eScancode newcode1, eScancode newcode2=scancode_none)
 Create an input map using scancode values.
Info methods
bool is_empty ()
 
Returns:
true if this object doesn't check for input.

bool is_down ()
 Is a key pressed?
unit get_value ()
 Get value/state of input.
unit get_joy_value (unit raw) const
 Convert raw joystick values into a range (-2 to +2).
Get/Set methods
int get_cntl1 () const
 
Returns:
The first scancode.

int get_cntl2 () const
 
Returns:
The second scancode.

int get_cntl1_str () const
 Get the string for the controller.
int get_cntl2_str () const
 Get the string for the second part of the controller.
void set (const int newcode1, const int newcode2=0)
 Set to the new scancode.
bool set (const char *strCode1, const char *strCode2=0)
 Set to the new scancode from character strings.
void set_delay (const int tick)
 Set a delay between inputs.
void set_scaler (const unit f)


Detailed Description

Used to get the state of a key, control, button etc.

(c) 2007-2008 oP group Germany GbR. All rights reserved.
This source code is provided "as is" with no warranty and must not be distributed without written permission.

Author:
Doug Poston
Version:
1.3
Date:
12/28/2007

Member Enumeration Documentation

enum CInputMap::eScancode

Input scancodes (keyboard, mouse, joypad, etc.).

Enumerator:
scancode_bad  Bad scancode (never on).
scancode_always  Always on (mostly used for testing).
scancode_none  Never on.
scancode_esc  Escape key.
scancode_end_keyboard  Everything beyond this is a non-keyboard control.
scancode_mouse_right  right mouse button scancode
scancode_joy_button_1  joy 1 button scancode
scancode_joy2_button_1  joy2 1 button scancode


Constructor & Destructor Documentation

CInputMap::CInputMap ( eScancode  newcode1,
eScancode  newcode2 = scancode_none 
)

Create an input map using scancode values.

Parameters:
newcode1 Scancode of first input.
newcode2 Scancode of second input (none if left blank).


Member Function Documentation

CInputMap::eScancode CInputMap::scancode_for_str ( const char *  str  )  [static]

Get the scancode for the character string input.

Note:
Assume we are using a US keyboard layout.
Parameters:
str Character string used to lookup scancode.
Returns:
The input scancode for the string passed in.

< convert to char since key_for_str does not take const char*

bool CInputMap::is_down (  ) 

Is a key pressed?

Returns:
true if scancode1 and/or scancode2 is pressed

false if neither scancode1 and scancode2 are pressed

unit CInputMap::get_value (  ) 

Get value/state of input.

Returns:
0 if off, 1 if totally on, -1 to 1 for analog controls

unit CInputMap::get_joy_value ( unit  raw  )  const

Convert raw joystick values into a range (-2 to +2).

Parameters:
raw Raw joystick input.
Returns:
Raw joystick value as a -2 to +2 value,

bool CInputMap::set ( const char *  strCode1,
const char *  strCode2 = 0 
)

Set to the new scancode from character strings.

Parameters:
strCode1 String used for scancode.
strCode2 String used for scancode2 (optional).
Returns:
False if both scancodes are not valid.

void CInputMap::set_delay ( const int  tick  )  [inline]

Set a delay between inputs.

Note:
Normally used for keydown invents that rotate inventory, or preform expensive opperations.
Parameters:
tick Time to delay between reporting inputs (in ticks).


The documentation for this class was generated from the following files:
Generated on Fri Dec 28 12:55:07 2007 for template7 by  doxygen 1.5.4