I have been writing a program which needs to simulate an input from a controller. I have been using SendInput() with a keyboard input and used VK_GAMEPAD_A as my test key.
When I run this code nothing happens. Is this a problem with my code or with the receiving program? Am I using the right keycode?Code:void PressButton(WORD key, unsigned short time = 50) { INPUT Input = { 0 }; unsigned int size = sizeof(INPUT); WORD vKey = MapVirtualKey(key, 0); Input.type = INPUT_KEYBOARD; Input.ki.wScan = vKey; Input.ki.dwExtraInfo = GetMessageExtraInfo(); Input.ki.dwFlags = KEYEVENTF_SCANCODE; SendInput(1, &Input, size); Sleep(100); ZeroMemory(&Input, size); Input.type = INPUT_KEYBOARD; Input.ki.wScan = vKey; Input.ki.dwExtraInfo = GetMessageExtraInfo(); Input.ki.dwFlags = KEYEVENTF_SCANCODE; SendInput(1, &Input, size); Sleep(time); }
Also I will need to do joysticks and triggers. There will be a float or double as the input for those.




Reply With Quote
