在 3D 游戏中模拟鼠标移动? [英] Simulate mouse move in 3D games?

查看:39
本文介绍了在 3D 游戏中模拟鼠标移动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我在 CodeBlocks IDE 中使用 C++ 和 OpenCV 制作了一个人机界面来使用手指控制鼠标http://www.youtube.com/watch?v=-q5aXTg0pVE我想在荣誉勋章之类的3D游戏中使用这个

Hi I made a human computer interface to control mouse using fingers using C++ and OpenCV in CodeBlocks IDE http://www.youtube.com/watch?v=-q5aXTg0pVE I want to use this in a 3D game like medal of honor

首先我使用 SetCursorPos(x,y) 它不起作用所以我切换到 SendInput 和 mouse_event.他们确实解决了角色开始指向所有随机方向并自行改变方向的错误.

First I used SetCursorPos(x,y) it did not work so I switched to SendInput and mouse_event. They did work with a bug the character began pointing in all random directions and changing directions on its own.

我应该使用directinput,因为游戏使用directx.如果是这样怎么办?我已经尝试了很多教程,但都在谈论如何从鼠标获取数据,而不是如何插入鼠标流我使用了绝对定位和相对定位,但都失败了角色行为奇怪

Should I use directinput as the game uses directx. If so how? I have tried many tutorials but all speak about how to get data from mouse but not how to insert into the mouse stream I used both absolute and relative positioning but both failed the character is behaving odd

推荐答案

如果没有看到你的代码,这个答案有点长,但这里是.

Without seeing your code, this answer is a bit of a long shot, but here goes.

SendInput 应该可以工作,但我认为使用 SetCursorPos 本身会干扰游戏.许多游戏每帧都会将光标重置到屏幕中央,因此不会意外碰到边缘.

SendInput should work, but I think the game is interfering by using SetCursorPos itself. Many games reset the cursor to the centre of the screen each frame, so it doesn't hit the edge by accident.

尝试将 SendInput 与鼠标相对运动一起使用,因此 没有MOUSEINPUT 结构.

Try using SendInput with relative mouse motion, so without the MOUSEEVENTF_ABSOLUTE flag in the MOUSEINPUT struct.

这篇关于在 3D 游戏中模拟鼠标移动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆