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

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

问题描述

您好
我在人工计算机界面使用C ++和OpenCV在CodeBlocks IDE中使用手指控制鼠标
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

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

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

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