CryoEnix Posted May 27, 2006 Posted May 27, 2006 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? 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 ^^ Quote Chaos is merely logic beyond human comprehension
CryoEnix Posted May 27, 2006 Author Posted May 27, 2006 It's okay guys, I've solved the problem. The key enum in directinput is Key, not Keys as I had mistakenly used. Thanks anyway! Quote Chaos is merely logic beyond human comprehension
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.