Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

bug

examples for direct input

This topic is 6935 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone know where I could find some examples if setting up and using an input device such as the mouse in directX? I''ve been having some trouble with this and I was wondering if any of you knew where I could find some code examples for this. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
This is the process that I use to setup and use the mouse with DirectInput.

---Setup

DirectInputCreateEx(hInst, DIRECTINPUT_VERSION, IID_IDirectInput7, (void**)&m_pDI, NULL);

m_pDI->CreateDeviceEx( GUID_SysMouse, IID_IDirectInputDevice7, (void**)&m_pMouse, NULL );

m_pMouse->SetDataFormat( &c_dfDIMouse2 );

m_pMouse->SetCooperativeLevel( m_hWnd, DISCL_EXCLUSIVE / DISCL_FOREGROUND);

m_pMouse->Acquire();

---Usage

m_pMouse->GetDeviceState( sizeof(DIMOUSESTATE2), &m_MouseState );

// Get the mouse state from m_MouseState

---Cleanup

m_pMouse->Release();

m_pDI->Release();

---

Of course I use a bit more error checking, but this is basically what I do. As you can see there aren't that much to it. In the SDK there are samples of a couple of different ways of setting up the devices, buffered keyboard, non exclusive access etc.

As usual the slash in SetCooperativeLevel() should be a pipe, but the board for some reason doesn't like pipes so...

WitchLord

Edited by - WitchLord on 4/21/00 2:20:49 PM

Share this post


Link to post
Share on other sites
hi bug,

try Chris Hargroves "Code on the Cob"
you can find it here on gamedev net:
"Reference" -> "Game Programming" -> "General"

http://www.gamedev.net/reference/docs/refarticlelistuser.asp?catid=45

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!