IInput: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Added categories)
No edit summary
Line 1: Line 1:
This interface is used by the Source Engine to access input functionality that must be implemented in game code. This class handles mouse and joystick input, keeps track of and modifies key "button" state, and completely controls the position of the camera. The file iinput.h should remain unedited as the engine expects to find the IInput interface as it is currently presented in iinput.h. To implement IInput the game code creates a new class inheriting IInput, and exposing it to engine:
'''<code>IInput</code>''' is a client [[interface]] that packages user input from keyboards, mice and joysticks/gamepads into [[usercmd]]s for transmission to the server. It also handles [[third-person camera]]s.


class CMyInput : public CInput
== Implementation ==
{
public:
};
static CMyInput g_Input;
// Expose this interface
IInput *input = ( IInput * )&g_Input;


The easiest way to implement this interface is by starting with and modifying the preexisting class CInput. CInput is declared in input.h and is implemented in:
<source lang=cpp>class CMyInput : public CInput
{
};


* in_main.cpp
// For mod access
* in_mouse.cpp
static CMyInput g_Input;
* in_camera.cpp
* in_joystick.cpp


[[Category:Programming]][[Category:Interfaces]]
// For engine access
IInput* input = (IInput*)&g_Input;</source>
 
== See also ==
 
* <code>[[CInput]]</code>, Valve's basic <code>IInput</code> implementation
 
[[Category:Interfaces]]

Revision as of 10:01, 3 August 2009

IInput is a client interface that packages user input from keyboards, mice and joysticks/gamepads into usercmds for transmission to the server. It also handles third-person cameras.

Implementation

class CMyInput : public CInput
{
};

// For mod access
static CMyInput g_Input;

// For engine access
IInput* input = (IInput*)&g_Input;

See also

  • CInput, Valve's basic IInput implementation