Link gamepad button to keyboard key
Posted: Sun May 23, 2010 10:19 pm
Hi,
I try to do small program to "drive" my keyboard and mouse with a gamepad. It's to can play game (Risen, if you want know) which don't accept gamepad input
There no problem with mouse, it's work fine.
But with keyboard, it's totally don't works.
When i simulate keyboard, i arrive to send #vk_KeySomething to program but it's don't do like real key pressed.
I do this example
i try to simule Right key and see if this key is pressed with ExamineKeyboard()
But i see nothing
Thanks for your help
I try to do small program to "drive" my keyboard and mouse with a gamepad. It's to can play game (Risen, if you want know) which don't accept gamepad input
There no problem with mouse, it's work fine.
But with keyboard, it's totally don't works.
When i simulate keyboard, i arrive to send #vk_KeySomething to program but it's don't do like real key pressed.
I do this example
i try to simule Right key and see if this key is pressed with ExamineKeyboard()
But i see nothing
Code: Select all
ExamineDesktops()
Ecran_Largeur = DesktopWidth(0)
Ecran_Hauteur = DesktopHeight(0)
; On ouvre l'openscreen
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0 Or InitSprite3D() = 0
MessageRequester("Erreur", "Impossible d'initialiser la souris ,le clavier ou l'écran. Vérifiez la présence de DirectX 7 ou supérieur.", 0)
End
EndIf
If OpenScreen(Ecran_Largeur, Ecran_Hauteur, 32, "Ecran", #PB_Screen_WaitSynchronization, DesktopFrequency(0)) = 0
MessageRequester("Erreur", "Impossible d'ouvrir l'écran.", 0)
End
EndIf
Repeat
ClearScreen($000000)
Message.INPUT
Message\Type = #INPUT_KEYBOARD
Message\ki\wVk = #VK_RIGHT
Message\ki\dwFlags = 0
SendInput_(1, @Message, SizeOf(INPUT))
; On lit les évènements clavier et souris
ExamineMouse()
ExamineKeyboard()
; Position de la souris
x = MouseX()
y = MouseY()
If KeyboardPushed(#PB_Key_Right)
FD = 1
Else
FD = 0
EndIf
StartDrawing(ScreenOutput())
DrawText(10, 10, "x = " + Str(x))
DrawText(10, 30, "y = " + Str(y))
DrawText(10, 50, "Fleche droite, Right key = " + Str(FD))
StopDrawing()
Message\Type = #INPUT_KEYBOARD
Message\ki\wVk = #VK_RIGHT
Message\ki\dwFlags = #KEYEVENTF_KEYUP
SendInput_(1, @Message, SizeOf(INPUT))
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)