예제 #1
0
    private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
    {
        hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
        if (VRMouse.GetInstance().lastMouseX == -1)
        {
            VRMouse.GetInstance().lastMouseX = hookStruct.pt.x;
            VRMouse.GetInstance().lastMouseY = hookStruct.pt.y;
        }
        VRMouse.GetInstance().MouseX = hookStruct.pt.x;
        VRMouse.GetInstance().MouseY = hookStruct.pt.y;

        return(CallNextHookEx(_hookID, nCode, wParam, lParam));
    }
예제 #2
0
    // Start is called before the first frame update
    void Start()
    {
        if (_VRMouse == null)
        {
            _VRMouse = this;
        }

        currentProcess = Process.GetCurrentProcess();
        UnityEngine.Debug.Log("currentProcess " + currentProcess.ProcessName);

        activeWindow = (IntPtr)GetActiveWindow();

        lockCursor(true);
        ShowAndSetTransparent(activeWindow);
    }
예제 #3
0
        private Vector2 GetScreenCoords()
        {
            Vector3 fromPosition = VRMouse.GetInstance().source.transform.position;
            Vector3 toPosition   = VRMouse.GetInstance().destination.transform.position;
            Vector3 direction    = toPosition - fromPosition;

            RaycastHit hit;

            if (!Physics.Raycast(VRMouse.GetInstance().source.transform.position, direction, out hit))
            {
                return(new Vector2(-1f, -1f));
            }
            Texture tex     = _mainMaterial.mainTexture;
            Vector2 pixelUV = hit.textureCoord;

            pixelUV.x  = (1 - pixelUV.x) * tex.width;
            pixelUV.y *= tex.height;
            return(pixelUV);
        }
    private bool m_forceMouseTrail = false; // Otherwise cursor is not visible

    // Use this for initialization
    IEnumerator Start()
    {
        Instance = this;

        ReInit();

        // StartMultiMonitor();
        StartFirstMonitor();

        yield return(new WaitForSeconds(1));

#if VDM_SteamVR
        RefreshControllers();
#endif

        StartCoroutine(OnRender());

        VRMouse.GetInstance().m_manager = this;
    }