C ++将操纵杆定向输入发送到程序 [英] C++ sending Joystick directional input to program
问题描述
我试图欺骗PS3控制器并将模拟摇杆定向输入发送到特定程序,但是我不知道INPUT.hi结构是如何工作的。我可以使用$ p $
$ b
I'm trying to spoof a PS3 controller and send analog stick directional input to a specific program, but i can't figure out how the INPUT.hi struct works. I can send keypresses over with
INPUT keys;
keys.type = INPUT_KEYBOARD;
keys.ki.dwFlags = KEYEVENTF_SCANCODE;
keys.ki.wScan = 0x11;//hex for 'w' key
SendInput(1, &keys, sizeof(INPUT));
Sleep(60);//delay to ensure game doesnt drop keypress
keys.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
SendInput(1, &keys, sizeof(INPUT));
我相信通过操纵杆发送命令也可以类似地工作,例如
and i believe that sending over joystick commands would work similarly, something like
INPUT analogSticks;
analogSticks.type = INPUT_HARDWARE;
analogSticks.hi.uMsg = WM_INPUT;
analogSticks.hi.wParamL = //what are the values for these?
analogSticks.hi.wParamH = //what are the values for these?
SendInput(1, &analogSticks, sizeof(INPUT));
但是尝试为wParamL和wParamH设置不同的值不会执行任何操作。我做错什么了吗,和/或有没有办法我可以输入特定的角度,例如,如果我将角度设置为45,则可以生成一个与该角度相对应的操纵杆信号,就像我可以通过按键进行操作一样?
but trying out different values for wParamL and wParamH doesnt do anything. Am i doing something wrong, and/or is there a way i can input specific angles, say, if i were to put in 45, i could generate a joystick signal that would correspond to that angle, much like i can do with keypresses?
推荐答案
看起来我无法使用winapi做到这一点,但是操纵杆驱动程序vJoy vjoystick.sourceforge.net/可以完美地运行,及其sdk http://vjoystick.sourceforge。 net / site / index.php / dev / 87-writing-a-feeder-application2 清楚地说明了如何欺骗操纵杆输入。
It looks like i cant do this with the winapi, but the joystick driver vJoy vjoystick.sourceforge.net/ works perfectly, and their sdk http://vjoystick.sourceforge.net/site/index.php/dev/87-writing-a-feeder-application2 clearly explains how to spoof joystick input.
另一种选择是< a href = http://developer.mbed.org/users/wim/notebook/usb-joystick-device/ rel = nofollow> http://developer.mbed.org/users/wim/notebook/usb -joystick-device / ,它的工作方式与此类似。
Another option is http://developer.mbed.org/users/wim/notebook/usb-joystick-device/, which appears to work similarly.
这篇关于C ++将操纵杆定向输入发送到程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!