Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Minecraft-Community-Edition/client/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Minecraft Community Edition’s input system provides a platform-agnostic abstraction layer for handling input from keyboards, mice, and game controllers. The system supports multiple input sources and handles platform-specific implementations for PC, Xbox, PlayStation, and PS Vita.
The input system is organized into three layers:
- Platform Layer - Platform-specific input capture (4J_Input)
- Abstraction Layer - Unified input interface (Input, ConsoleInput, KeyboardMouseInput)
- Game Layer - Input processing for player control and UI
┌─────────────────────────────────────┐
│ Game Layer (Player, Screen) │
├─────────────────────────────────────┤
│ Abstraction (Input, ConsoleInput) │
├─────────────────────────────────────┤
│ Platform (4J_Input, SDL, Windows) │
└─────────────────────────────────────┘
The Input class provides the core abstraction for player movement input:
class Input
{
public:
float xa; // X-axis movement (-1 to 1)
float ya; // Y-axis movement (forward/back, -1 to 1)
bool wasJumping; // Previous jump state
bool jumping; // Current jump state
bool sneaking; // Sneak/crouch state
bool sprinting; // Sprint state
virtual void tick(LocalPlayer *player);
};
Source: Minecraft.Client/Input.h:4
The tick() method is called every game tick to update input state:
virtual void tick(LocalPlayer *player);
Implementations read from input devices and update movement/action states.
The KeyboardMouseInput class handles PC keyboard and mouse input:
class KeyboardMouseInput
{
public:
static const int MAX_KEYS = 256;
static const int MAX_MOUSE_BUTTONS = 3;
// Mouse button constants
static const int MOUSE_LEFT = 0;
static const int MOUSE_RIGHT = 1;
static const int MOUSE_MIDDLE = 2;
void Init();
void Tick();
void ClearAllState();
};
Source: Minecraft.Client/KeyboardMouseInput.h:5
Keyboard State
Key State Query:
bool IsKeyDown(int vkCode) const; // Currently held
bool IsKeyPressed(int vkCode) const; // Just pressed this frame
bool IsKeyReleased(int vkCode) const; // Just released this frame
Source: Minecraft.Client/KeyboardMouseInput.h:42
Key Events:
void OnKeyDown(int vkCode); // Called when key is pressed
void OnKeyUp(int vkCode); // Called when key is released
Source: Minecraft.Client/KeyboardMouseInput.h:34
Mouse State
Button State Query:
bool IsMouseButtonDown(int button) const; // Currently held
bool IsMouseButtonPressed(int button) const; // Just clicked
bool IsMouseButtonReleased(int button) const; // Just released
Source: Minecraft.Client/KeyboardMouseInput.h:46
Mouse Position:
int GetMouseX() const; // Screen X coordinate
int GetMouseY() const; // Screen Y coordinate
int GetMouseDeltaX() const; // Movement since last frame
int GetMouseDeltaY() const; // Movement since last frame
Source: Minecraft.Client/KeyboardMouseInput.h:50
Mouse Events:
void OnMouseButtonDown(int button);
void OnMouseButtonUp(int button);
void OnMouseMove(int x, int y);
void OnMouseWheel(int delta);
void OnRawMouseDelta(int dx, int dy); // For FPS camera control
Source: Minecraft.Client/KeyboardMouseInput.h:36
Mouse Capture
Grab/Release Mouse:
void SetMouseGrabbed(bool grabbed); // Capture for FPS camera
bool IsMouseGrabbed() const;
When grabbed:
- Mouse is hidden
- Cursor is locked to window
- Raw delta values used for camera
Source: Minecraft.Client/KeyboardMouseInput.h:58
Cursor Visibility:
void SetCursorHiddenForUI(bool hidden);
bool IsCursorHiddenForUI() const;
void SetScreenCursorHidden(bool hidden);
bool IsScreenCursorHidden() const;
Source: Minecraft.Client/KeyboardMouseInput.h:61
Window Focus
void SetWindowFocused(bool focused);
bool IsWindowFocused() const;
Input is typically ignored when window is not focused.
Source: Minecraft.Client/KeyboardMouseInput.h:64
Keyboard/Mouse Activation
void SetKBMActive(bool active); // Enable/disable KB/M input
bool IsKBMActive() const;
bool HasAnyInput() const; // Any input received this frame
Source: Minecraft.Client/KeyboardMouseInput.h:67
float GetMoveX() const; // Strafe (-1 to 1)
float GetMoveY() const; // Forward/back (-1 to 1)
float GetLookX(float sensitivity) const; // Camera X rotation
float GetLookY(float sensitivity) const; // Camera Y rotation
Source: Minecraft.Client/KeyboardMouseInput.h:75
Default Key Bindings
static const int KEY_FORWARD = 'W';
static const int KEY_BACKWARD = 'S';
static const int KEY_LEFT = 'A';
static const int KEY_RIGHT = 'D';
static const int KEY_JUMP = VK_SPACE;
static const int KEY_SNEAK = VK_LSHIFT;
static const int KEY_SPRINT = VK_LCONTROL;
static const int KEY_INVENTORY = 'E';
static const int KEY_DROP = 'Q';
static const int KEY_CRAFTING = VK_TAB;
static const int KEY_CRAFTING_ALT = 'R';
static const int KEY_PAUSE = VK_ESCAPE;
static const int KEY_THIRD_PERSON = VK_F5;
static const int KEY_DEBUG_INFO = VK_F3;
Source: Minecraft.Client/KeyboardMouseInput.h:15
Global Instance
extern KeyboardMouseInput g_KBMInput; // Global singleton
Source: Minecraft.Client/KeyboardMouseInput.h:121
The console editions use gamepad input through the ConsoleInput and C_4JInput classes:
class ConsoleInput
{
public:
wstring msg; // Text input result
ConsoleInputSource *source; // Input source (player controller)
ConsoleInput(const wstring& msg, ConsoleInputSource *source);
};
Source: Minecraft.Client/ConsoleInput.h:5
Used for text input results from virtual keyboards on consoles.
The C_4JInput class provides the low-level gamepad interface:
class C_4JInput
{
public:
void Initialise(int iInputStateC, unsigned char ucMapC,
unsigned char ucActionC, unsigned char ucMenuActionC);
void Tick(void);
};
Source: Platform-specific 4J_Input.h files
Buttons are mapped to a unified button mask system:
// Xbox 360 style button mapping
#define _360_JOY_BUTTON_A 0x00000001
#define _360_JOY_BUTTON_B 0x00000002
#define _360_JOY_BUTTON_X 0x00000004
#define _360_JOY_BUTTON_Y 0x00000008
#define _360_JOY_BUTTON_START 0x00000010
#define _360_JOY_BUTTON_BACK 0x00000020
#define _360_JOY_BUTTON_RB 0x00000040
#define _360_JOY_BUTTON_LB 0x00000080
#define _360_JOY_BUTTON_RTHUMB 0x00000100
#define _360_JOY_BUTTON_LTHUMB 0x00000200
#define _360_JOY_BUTTON_DPAD_UP 0x00000400
#define _360_JOY_BUTTON_DPAD_DOWN 0x00000800
#define _360_JOY_BUTTON_DPAD_LEFT 0x00001000
#define _360_JOY_BUTTON_DPAD_RIGHT 0x00002000
#define _360_JOY_BUTTON_RT 0x00400000
#define _360_JOY_BUTTON_LT 0x00800000
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:10
PS Vita and PlayStation buttons are mapped to Xbox equivalents:
#define _PSV_JOY_BUTTON_X _360_JOY_BUTTON_A
#define _PSV_JOY_BUTTON_O _360_JOY_BUTTON_B
#define _PSV_JOY_BUTTON_SQUARE _360_JOY_BUTTON_X
#define _PSV_JOY_BUTTON_TRIANGLE _360_JOY_BUTTON_Y
#define _PSV_JOY_BUTTON_START _360_JOY_BUTTON_START
#define _PSV_JOY_BUTTON_SELECT _360_JOY_BUTTON_BACK
#define _PSV_JOY_BUTTON_R1 _360_JOY_BUTTON_RB
#define _PSV_JOY_BUTTON_L1 _360_JOY_BUTTON_LB
#define _PSV_JOY_BUTTON_R2 _360_JOY_BUTTON_RT
#define _PSV_JOY_BUTTON_L2 _360_JOY_BUTTON_LT
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:43
Gamepad State Query
Button State:
unsigned int GetValue(int iPad, unsigned char ucAction, bool bRepeat=false);
bool ButtonPressed(int iPad, unsigned char ucAction=255); // Toggled
bool ButtonReleased(int iPad, unsigned char ucAction); // Toggled
bool ButtonDown(int iPad, unsigned char ucAction=255); // Held
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:119
Analog Sticks:
// Returns -1.0 to 1.0
float GetJoypadStick_LX(int iPad, bool bCheckMenuDisplay=true);
float GetJoypadStick_LY(int iPad, bool bCheckMenuDisplay=true);
float GetJoypadStick_RX(int iPad, bool bCheckMenuDisplay=true);
float GetJoypadStick_RY(int iPad, bool bCheckMenuDisplay=true);
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:137
Triggers:
// Returns 0 to 255
unsigned char GetJoypadLTrigger(int iPad, bool bCheckMenuDisplay=true);
unsigned char GetJoypadRTrigger(int iPad, bool bCheckMenuDisplay=true);
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:141
Gamepad Configuration
Deadzone and Sensitivity:
void SetDeadzoneAndMovementRange(unsigned int uiDeadzone,
unsigned int uiMovementRangeMax);
void SetJoypadSensitivity(int iPad, float fSensitivity);
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:113
Control Schemes:
// Remap stick axes (for southpaw, legacy controls, etc.)
void SetJoypadStickAxisMap(int iPad, unsigned int uiFrom, unsigned int uiTo);
void SetJoypadStickTriggerMap(int iPad, unsigned int uiFrom, unsigned int uiTo);
Axis Maps:
#define AXIS_MAP_LX 0 // Left stick X
#define AXIS_MAP_LY 1 // Left stick Y
#define AXIS_MAP_RX 2 // Right stick X
#define AXIS_MAP_RY 3 // Right stick Y
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:70
Controller Detection
bool IsPadConnected(int iPad);
FLOAT GetIdleSeconds(int iPad); // Time since last input
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:128
Key Repeat
For menu navigation:
void SetKeyRepeatRate(float fRepeatDelaySecs, float fRepeatRateSecs);
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:126
void SetMenuDisplayed(int iPad, bool bVal);
When a menu is displayed, some input behavior changes (e.g., stick input for cursor).
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:146
extern C_4JInput InputManager; // Global singleton
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:177
The PS Vita version supports touchscreen input:
Touch Data
SceTouchData* GetTouchPadData(int iPad, bool bCheckMenuDisplay);
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:144
Touch Mapping
void MapTouchInput(int iPad, unsigned int uiActionVal);
Maps touch regions to button actions.
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:134
Virtual Keyboard
Console platforms use virtual keyboards for text input:
Keyboard Modes
enum EKeyboardMode
{
EKeyboardMode_Default,
EKeyboardMode_Numeric,
EKeyboardMode_Password,
EKeyboardMode_Alphabet,
EKeyboardMode_Full,
EKeyboardMode_Alphabet_Extended,
EKeyboardMode_IP_Address,
EKeyboardMode_Phone
};
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:99
Requesting Keyboard
EKeyboardResult RequestKeyboard(LPCWSTR Title, LPCWSTR Text, DWORD dwPad,
UINT uiMaxChars,
int (*Func)(LPVOID, const bool), LPVOID lpParam,
EKeyboardMode eMode);
Keyboard Results:
enum EKeyboardResult
{
EKeyboard_Pending,
EKeyboard_Cancelled,
EKeyboard_ResultAccept,
EKeyboard_ResultDecline
};
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:79
Retrieving Text
void GetText(uint16_t *UTF16String);
Retrieves the text entered via virtual keyboard.
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:151
Key Mappings
The Options class stores configurable key bindings:
class Options
{
public:
KeyMapping *keyUp;
KeyMapping *keyLeft;
KeyMapping *keyDown;
KeyMapping *keyRight;
KeyMapping *keyJump;
KeyMapping *keyBuild;
KeyMapping *keyDrop;
KeyMapping *keyChat;
KeyMapping *keySneak;
KeyMapping *keyAttack;
KeyMapping *keyUse;
KeyMapping *keyPlayerList;
KeyMapping *keyPickItem;
KeyMapping *keyToggleFog;
static const int keyMappings_length = 14;
KeyMapping *keyMappings[keyMappings_length];
};
Source: Minecraft.Client/Options.h:74
Key Mapping Access
wstring getKeyDescription(int i); // Get key name
wstring getKeyMessage(int i); // Get action name
void setKey(int i, int key); // Rebind key
Source: Minecraft.Client/Options.h:117
Input-related settings in the Options class:
float sensitivity; // Mouse/stick sensitivity (0.0-1.0)
bool invertYMouse; // Invert Y-axis
Source: Minecraft.Client/Options.h:62
The input system supports up to 4 simultaneous players:
#define XUSER_MAX_COUNT 4 // Maximum players
int iPad = minecraft->player->GetXboxPad(); // Get player's controller index
Each player has:
- Independent controller
- Separate input state
- Own viewport (in split-screen)
- Individual settings
- Platform Layer captures hardware input
- Input Manager processes and filters input
- Input::tick() updates movement state
- LocalPlayer applies movement to player entity
- Game updates physics and world state
- Platform Layer captures hardware input
- Screen::updateEvents() polls for input events
- Screen::mouseEvent() / keyboardEvent() process events
- Screen::mouseClicked() / keyPressed() handle specific actions
- Screen::buttonClicked() receives button callbacks
Source: Minecraft.Client/Screen.cpp:104
Windows PC
- Uses Windows message loop for keyboard/mouse
- Raw input for camera control
- DirectInput for gamepad support
- XInput for Xbox controllers
Xbox (Durango)
- Native XInput for controllers
- Kinect support (voice/gesture)
- Smart Glass integration
PlayStation 3
- Cell SPU optimized input processing
- SIXAXIS motion support
- PlayStation Network integration
PlayStation Vita
- Front and rear touchscreen
- Motion sensors (gyroscope/accelerometer)
- Hardware buttons and analog sticks
- Vita TV mode (controller-only)
bool IsVitaTV(); // Check if running on Vita TV
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:171
Text Input Validation
For online play, user text is validated:
bool VerifyStrings(WCHAR **pwStringA, int iStringC,
int (*Func)(LPVOID, STRING_VERIFY_RESPONSE *),
LPVOID lpParam);
void CancelQueuedVerifyStrings(int (*Func)(LPVOID, STRING_VERIFY_RESPONSE *),
LPVOID lpParam);
void CancelAllVerifyInProgress(void);
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:167
Used to filter offensive language in:
- Chat messages
- World names
- Player usernames
- Signs and books
Circle/Cross Swap (PlayStation)
PlayStation regions have different button conventions:
void SetCircleCrossSwapped(bool swapped);
bool IsCircleCrossSwapped();
Japan typically uses Circle for confirm, while Western regions use Cross.
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:130
Best Practices
- Check for input availability before processing
- Respect menu state - disable game input when UI is open
- Handle controller disconnect gracefully
- Support all control schemes (default, southpaw, legacy)
- Apply deadzone to analog sticks
- Smooth camera input using delta values
- Validate text input for online features
Multi-Player Support
- Index by player (iPad/controller index)
- Check connection state before reading input
- Handle hot-plugging (controllers connecting/disconnecting)
- Show appropriate prompts per platform (“Press A” vs “Press X”)
- Respect per-player settings (sensitivity, inversion)
- Use abstraction layer - avoid platform-specific code in game logic
- Test all platforms - button mappings may differ
- Support keyboard and gamepad simultaneously on PC
- Handle touch input on Vita
- Provide fallbacks for missing input devices