zoukankan      html  css  js  c++  java
  • unreal3窗口锁定鼠标开关

    GameViewportClient中有个变量控制是否显示硬件鼠标:

    var transient bool bDisplayHardwareMouseCursor

    也就是系统的光标,一般通过该类中的函数来操纵:

    simulated event SetHardwareMouseCursorVisibility(bool bIsVisible)
    {
        local Vector2D ViewportSize;
        
        //If we are going to be turning on the hardware cursor when it was not already on, we will move the cursor to the middle of the screen
        if (bIsVisible && !bDisplayHardwareMouseCursor)
        {
            GetViewportSize(ViewportSize);
            SetMouse(ViewportSize.X/2,ViewportSize.Y/2);
        }
        bDisplayHardwareMouseCursor = bIsVisible;
    
        ForceUpdateMouseCursor(TRUE);
    }

    其中ForceUpdateMouseCursor是native函数,调用到UGameViewportClient::ForceUpdateMouseCursor,

    在Windows上的实现类为FWindowsViewport,其成员函数

    void FWindowsViewport::UpdateMouseLock( UBOOL bEnforceMouseLockRequestedFlag )

    在每个tick中被调用,会对该控制变量进行检测:

        RECT ClipRect;
        UBOOL bIsHardwareCursorVisible = (GEngine && GEngine->GameViewport && GEngine->GameViewport->bDisplayHardwareMouseCursor);
        UBOOL bIsAnyCursorVisible = bIsSystemCursorVisible || bIsHardwareCursorVisible;
        UBOOL bClipRectValid = (::GetClipCursor( &ClipRect ) != 0);
        UBOOL bHasFocus = HasFocus();
        UBOOL bShouldMouseLock = bEnforceMouseLockRequestedFlag ? bMouseLockRequested : bHasFocus && (IsFullscreen() || !bIsAnyCursorVisible || bMouseLockRequested);

    最后在bShouldMouseLock为TRUE时,调用::ClipCursor锁定鼠标。

  • 相关阅读:
    记一道有趣的数学题
    BJOI2018 二进制
    BJOI2016 IP地址
    BJOI2016 回转寿司
    BJOI2017 开车
    BJOI2019 光线
    java 下载
    springboot 运行相关命令
    sql mapper 里面 Integer 类型判断
    springboot 访问jar同级别下的文件访问问题
  • 原文地址:https://www.cnblogs.com/wellbye/p/5330020.html
Copyright © 2011-2022 走看看