Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 ^^

Chaos is merely logic beyond human comprehension
Posted
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!
Chaos is merely logic beyond human comprehension

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...