Files
YaeBlog/source/posts/linux-genshin-cloud.md
jackfiled 462fbb28ac
Some checks failed
Build blog docker image / Build-Blog-Image (push) Failing after 14s
feat: rewrite about page for 2026. (#21)
Signed-off-by: jackfiled <xcrenchangjun@outlook.com>
Reviewed-on: #21
2026-03-03 09:09:49 +00:00

1.7 KiB

title, tags, date
title tags date
解决云原神无法在Linux中浏览器下运行的问题
生活小妙招
原神
2023-10-09 23:56:34

本文为转载bilibili用户@SocialismTeen在他的专栏中给出的解决办法。

问题

Linux平台上使用Chromium系列内核的浏览器打开云原神会发生鼠标无法控制视角的问题。

解决

根据上面提到那位同志的研究,该问题是由于云原神在获得鼠标移动时使用的API: Pointer Lock API。在其他平台上该API支持名为unadjustedMovement的参数以关闭鼠标加速获得更好的体验,但是在Linux平台上并不支持该参数,因此程序无法正确获得到鼠标指针的位置。

该同志给出的解决办法为使用钩子函数消除调用该API时的参数,使用的代码如下:

const origin = HTMLElement.prototype.requestPointerLock
HTMLElement.prototype.requestPointerLock = function () {
  return origin.call(this)
} 

为了获得良好的游戏体验,可以使用油猴插件在进入网页时自动运行上述脚本:

// ==UserScript==
// @name         Genshin Cloud
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  fix a Genshin Impact cloud game bug
// @match        https://ys.mihoyo.com/cloud/*
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

  const origin = HTMLElement.prototype.requestPointerLock
  HTMLElement.prototype.requestPointerLock = function () {
    return origin.call(this)
  }
})();