IInput

From Valve Developer Community
Revision as of 07:14, 20 May 2025 by Nesciuse (talk | contribs) (Setting bug notice hidetested=1 param on page where the bug might not need tested in param specified)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.

Conventionally, each type of supported peripheral has its own CPP file. Valve's CInput interface implementation is in in_main.cpp (for usercmd packaging and keyboard), in_mouse.cpp and in_joystick.cpp.

Minimum implementation

static CInput g_Input;
IInput* input = (IInput*)&g_Input;
Icon-Bug.pngBug:Although your mod will compile fine if you bypass creating the g_Input object, you may encounter bizarre errors (including the world not rendering and a cursor that is re-centred every frame) when launching with a debugger attached!

See also

  • CInput, Valve's basic IInput implementation