-
July 30th, 2013, 06:08 PM
#1
Xinput controller state problem
I am making a mapper program for the 360 controller using XInput I am using SendInput to send keypresses to games
Code:
if(controller1->GetState().Gamepad.wButtons & XINPUT_GAMEPAD_B)
{
memset(&ip,0,sizeof(INPUT));//
UINT_PTR code = controller1->profile->Buttons[21]->keycode;
ip.type = INPUT_KEYBOARD;
ip.ki.wScan = MapVirtualKey(code,0);
ip.ki.time = 0;
ip.ki.dwExtraInfo = GetMessageExtraInfo();
ip.ki.wVk = 0;
ip.ki.dwFlags = KEYEVENTF_SCANCODE ;
if(controller1->profile->Buttons[21]->delayTimer <= 0)
SendInput(1, &ip, sizeof(INPUT));
++controller1->profile->Buttons[21]->delayTimer;
if(controller1->profile->Buttons[21]->delayTimer >= 300)
{
++controller1->profile->Buttons[21]->repeatTimer;
if(controller1->profile->Buttons[21]->repeatTimer >= 100)
{
SendInput(1, &ip, sizeof(INPUT));
controller1->profile->Buttons[21]->repeatTimer = 0;
}
}
}
else
{
ip.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP ;
SendInput(1, &ip, sizeof(INPUT));
controller1->profile->Buttons[21]->delayTimer = 0;
controller1->profile->Buttons[21]->repeatTimer = 0;
}
it sends the key up event continuously wich is not what I want I want to make it so when the button is up it only send the key up event once. I figured I would do this using a current controller state and a previous controller state using an XOR but I have failed every attempt. Any advice would be helpful considering this is the only thing holding me back from finishing.
P.S the code for checking the buttons state is in the main message loop.
-
May 14th, 2020, 10:28 PM
#2
Re: Xinput controller state problem
quick question, what are you using for your key codes?
-
May 15th, 2020, 01:57 AM
#3
Re: Xinput controller state problem
I doubt william3711 will read your question. His latest post to this forum was about seven years ago.
Victor Nijegorodov
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|