Archived

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

Squirell

Direct Input

Recommended Posts

Im trying to use direct input. However everytime i try to i get the following error message. Error Message: The procedure entry point c_dfDIKeyboard could not be located in the dynamic link library dinput.dll I have no idea what this means and the SDK provides no help. Does anybody have an idea of whats going wrong. By the way im using Dev C++. Here is my code:

#define WIN32_LEAN_AND_MEAN

#include <dinput.h>
#include <d3dx9.h>
#include <windows.h>


// Globals

LPDIRECTINPUT lpdi;
LPDIRECTINPUTDEVICE m_keyboard;
HWND hWND;
HINSTANCE g_hinstance;
bool done = false;


unsigned char keystate[256];

void Init(void)
{
  if (FAILED(DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, 
    IID_IDirectInput8, (void**)&lpdi, NULL)))
  {
    // error code

  }
  
  if (FAILED(lpdi->CreateDevice(GUID_SysKeyboard, &m_keyboard, NULL)))
    { /* error code */ }
  
  if (FAILED(m_keyboard->SetDataFormat(&c_dfDIKeyboard)))
    { /* error code */ }
  
  if (FAILED(m_keyboard->SetCooperativeLevel(hWND, DISCL_BACKGROUND |
    DISCL_NONEXCLUSIVE)))
    { /* error code */ }
  
  if (FAILED(m_keyboard->Acquire()))
    { /* error code */ }
}

void CleanUp()
{
  if (m_keyboard)
    m_keyboard->Release();
  
  if (lpdi)
    lpdi->Release();
}


void Render() {

}

void GameLoop()
{
    //Enter the game loop

    MSG msg; 
    BOOL fMessage;

    PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE);
    
    while(msg.message != WM_QUIT)
    {
        fMessage = PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE);

        if(fMessage)
        {
            //Process message

            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        else
        {
            //No message to process, so render the current scene

            Render();
        }

    }
}

//The windows message handler

LRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
        break;
        case WM_KEYUP: 
            switch (wParam)
            { 
                case VK_ESCAPE:
                    //User has pressed the escape key, so quit

                    DestroyWindow(hWnd);
                    return 0;
                break;
            } 
        break;

    }

    return DefWindowProc(hWnd, msg, wParam, lParam);
}

//Application entry point

INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, INT)
{
    //Register the window class

    WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_CLASSDC, WinProc, 0L, 0L, 
                     GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
                     "DX Project 1", NULL};
    RegisterClassEx(&wc);

    //Create the application''s window

    HWND hWND = CreateWindow("DX Project 1", "www.andypike.com: Tutorial 1", 
                              WS_OVERLAPPEDWINDOW, 50, 50, 500, 500,
                              GetDesktopWindow(), NULL, g_hinstance, NULL);

    //Initialize Direct3D

    Init();
    
        //Show our window

        ShowWindow(hWND, SW_SHOWDEFAULT);
        UpdateWindow(hWND);

        //Start game running: Enter the game loop

        GameLoop();
    
    
    CleanUp();

    UnregisterClass("DX Project 1", g_hinstance);
    
    return 0;
}

Share this post


Link to post
Share on other sites
Yeah you do, already have that linked in
Heres the list of libs i have linked
d3d9
d3dx9
dxguid
dxtrans
dxapi
dxinput
dxinput8
winmm

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Squirell
Yeah you do, already have that linked in
Heres the list of libs i have linked
d3d9
d3dx9
dxguid
dxtrans
dxapi
DXINPUT
DXINPUT8
winmm


Its not dxinput.lib, its dinput.lib. Same for dinput8.lib.

Share this post


Link to post
Share on other sites