CryoEnix
Regular
Hey all, I've been dabbling with directdraw for a few weeks, and thought it was time to deal with keystrokes for my upcoming game. I created this class to simplify directinput, but for some reason it won't work. Any ideas?
Please ignore the redundant joystick code, I'll get to that in time ^^
Code:
Public Class DirectInput
Dim KBState As Microsoft.DirectX.DirectInput.KeyboardState
Dim KB As New Microsoft.DirectX.DirectInput.Device(SystemGuid.Keyboard)
Dim JoyState As JoystickState 'finish me!
Sub New(ByRef theParentForm As Form)
KB.SetCooperativeLevel(theParentForm, Background Or NonExclusive)
KB.Acquire()
End Sub
Public Function isPressed(ByRef theKey As Keys, Optional ByRef acquireFirst As Boolean = False) As Boolean
If acquireFirst Then
KB.Acquire()
KBState = KB.GetCurrentKeyboardState
End If
isPressed = KBState.Item(theKey)
End Function
Public Sub acquire()
KB.Acquire()
KBState = KB.GetCurrentKeyboardState
'one for joypad, too!
End Sub
End Class
Please ignore the redundant joystick code, I'll get to that in time ^^