Skip to main content

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.

Input Architecture

The input system is organized into three layers:
  1. Platform Layer - Platform-specific input capture (4J_Input)
  2. Abstraction Layer - Unified input interface (Input, ConsoleInput, KeyboardMouseInput)
  3. Game Layer - Input processing for player control and UI

Input Base Class

The Input class provides the core abstraction for player movement input:
Source: Minecraft.Client/Input.h:4

Input Processing

The tick() method is called every game tick to update input state:
Implementations read from input devices and update movement/action states.

Keyboard and Mouse Input

The KeyboardMouseInput class handles PC keyboard and mouse input:

KeyboardMouseInput Class

Source: Minecraft.Client/KeyboardMouseInput.h:5

Keyboard State

Key State Query:
Source: Minecraft.Client/KeyboardMouseInput.h:42 Key Events:
Source: Minecraft.Client/KeyboardMouseInput.h:34

Mouse State

Button State Query:
Source: Minecraft.Client/KeyboardMouseInput.h:46 Mouse Position:
Source: Minecraft.Client/KeyboardMouseInput.h:50 Mouse Events:
Source: Minecraft.Client/KeyboardMouseInput.h:36

Mouse Capture

Grab/Release Mouse:
When grabbed:
  • Mouse is hidden
  • Cursor is locked to window
  • Raw delta values used for camera
Source: Minecraft.Client/KeyboardMouseInput.h:58 Cursor Visibility:
Source: Minecraft.Client/KeyboardMouseInput.h:61

Window Focus

Input is typically ignored when window is not focused. Source: Minecraft.Client/KeyboardMouseInput.h:64

Keyboard/Mouse Activation

Source: Minecraft.Client/KeyboardMouseInput.h:67

Movement Input

Source: Minecraft.Client/KeyboardMouseInput.h:75

Default Key Bindings

Source: Minecraft.Client/KeyboardMouseInput.h:15

Global Instance

Source: Minecraft.Client/KeyboardMouseInput.h:121

Console Input (Gamepad)

The console editions use gamepad input through the ConsoleInput and C_4JInput classes:

ConsoleInput Class

Source: Minecraft.Client/ConsoleInput.h:5 Used for text input results from virtual keyboards on consoles.

4J Input Manager

The C_4JInput class provides the low-level gamepad interface:
Source: Platform-specific 4J_Input.h files

Gamepad Button Mapping

Buttons are mapped to a unified button mask system:
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:10

PlayStation Button Mapping

PS Vita and PlayStation buttons are mapped to Xbox equivalents:
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:43

Gamepad State Query

Button State:
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:119 Analog Sticks:
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:137 Triggers:
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:141

Gamepad Configuration

Deadzone and Sensitivity:
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:113 Control Schemes:
Axis Maps:
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:70

Controller Detection

Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:128

Key Repeat

For menu navigation:
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:126
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

Input Manager Singleton

Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:177

Touch Input (PS Vita)

The PS Vita version supports touchscreen input:

Touch Data

Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:144

Touch Mapping

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

Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:99

Requesting Keyboard

Keyboard Results:
Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:79

Retrieving Text

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:
Source: Minecraft.Client/Options.h:74

Key Mapping Access

Source: Minecraft.Client/Options.h:117

Input Settings

Input-related settings in the Options class:
Source: Minecraft.Client/Options.h:62

Multi-Player Input

The input system supports up to 4 simultaneous players:
Each player has:
  • Independent controller
  • Separate input state
  • Own viewport (in split-screen)
  • Individual settings

Input Processing Flow

Game Input (In-World)

  1. Platform Layer captures hardware input
  2. Input Manager processes and filters input
  3. Input::tick() updates movement state
  4. LocalPlayer applies movement to player entity
  5. Game updates physics and world state

UI Input (Screens)

  1. Platform Layer captures hardware input
  2. Screen::updateEvents() polls for input events
  3. Screen::mouseEvent() / keyboardEvent() process events
  4. Screen::mouseClicked() / keyPressed() handle specific actions
  5. Screen::buttonClicked() receives button callbacks
Source: Minecraft.Client/Screen.cpp:104

Platform-Specific Input

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)

Checking Platform

Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:171

Text Input Validation

For online play, user text is validated:
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:
Japan typically uses Circle for confirm, while Western regions use Cross. Source: Minecraft.Client/PSVita/4JLibs/inc/4J_Input.h:130

Best Practices

Input Handling

  1. Check for input availability before processing
  2. Respect menu state - disable game input when UI is open
  3. Handle controller disconnect gracefully
  4. Support all control schemes (default, southpaw, legacy)
  5. Apply deadzone to analog sticks
  6. Smooth camera input using delta values
  7. Validate text input for online features

Multi-Player Support

  1. Index by player (iPad/controller index)
  2. Check connection state before reading input
  3. Handle hot-plugging (controllers connecting/disconnecting)
  4. Show appropriate prompts per platform (“Press A” vs “Press X”)
  5. Respect per-player settings (sensitivity, inversion)

Platform Compatibility

  1. Use abstraction layer - avoid platform-specific code in game logic
  2. Test all platforms - button mappings may differ
  3. Support keyboard and gamepad simultaneously on PC
  4. Handle touch input on Vita
  5. Provide fallbacks for missing input devices