LiveriaDevs-ValheimCursorLockFix icon

ValheimCursorLockFix

Client-side cursor lock fix for Valheim. Forces cursor lock during gameplay and unlocks it in menus, inventory, build menu, map, chat and console.

Last updated 12 hours ago
Total downloads 21
Total rating 1 
Categories Mods
Dependency string LiveriaDevs-ValheimCursorLockFix-1.0.2
Dependants 0 other packages depend on this package

This mod requires the following mods to function

denikson-BepInExPack_Valheim-5.4.2202 icon
denikson-BepInExPack_Valheim

BepInEx pack for Valheim. Preconfigured and includes unstripped Unity DLLs.

Preferred version: 5.4.2202

README

ValheimCursorLockFix

Client-side BepInEx 5 plugin for Valheim that keeps the hidden mouse cursor locked during gameplay. It unlocks the cursor when UI needs it, including the main menu, pause menu, inventory, build/piece menu, map, trader/store, text viewer, chat, console, text input, and when the game window is not focused.

Install with r2modman local import

  1. Build the package with build.ps1.
  2. Open r2modman and select your Valheim profile.
  3. Go to Settings > Import local mod.
  4. Select dist/ValheimCursorLockFix-1.0.2.zip.
  5. Launch Valheim through r2modman.

Configuration

After the first launch, edit the generated config file:

BepInEx/config/ua.gyrocopter.valheim.cursorlockfix.cfg

Available options:

  • EnableFix - enables or disables the fix.
  • ForceLockInGameplay - forces Cursor.lockState = Locked and hides the cursor during gameplay.
  • UnlockInMenus - unlocks and shows the cursor in menus, inventory, build/piece menu, map, trader/store, text viewer, chat, console, text input, or when the window is inactive.
  • ToggleKey - default F8.
  • DebugLogging - enables extra log messages.

Toggle key

Press F8 in game to toggle the fix on or off. When disabled, the plugin releases the cursor and stops forcing the gameplay lock.

Troubleshooting

  • Make sure BepInExPack Valheim is installed and enabled in the same profile.
  • If the cursor still escapes, check that EnableFix and ForceLockInGameplay are both true.
  • If the cursor flickers in the screen center, update to 1.0.2 or newer.
  • If the cursor stays locked in UI, set DebugLogging = true, reproduce the issue, and check the BepInEx log for the detected cursor state.
  • If a Valheim update changes UI APIs, this plugin uses reflection-based safe checks to avoid crashes, but a compatibility update may still be needed for changed UI behavior.