Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: DirectInput creating?!

  1. #1

    DirectInput creating?!

    after i've created the input
    Code:
      DirectInput8Create(GetModuleHandle(nil),DIRECTINPUT_VERSION,IID_IDirectInput8,m_pDInput,nil);
    i need to create a device right? so here it goes:

    Code:
    m_pDInput.CreateDevice(GUID_SysKeyboard, ?!?!?!?!?!?!?, NIL);
    on the ?!?!?!?!? place i cant seem to understand what should stand

    ou and one last thing the variable should be like this, right?-> m_pDInput : IDirectInput;

    i am using clootie dx9 headers

  2. #2

    DirectInput creating?!

    The question mark part is the device you'll be creating - it's an out parameter, so... m_pDInput.CreateDevice(GUID_SysKeyboard, FKeyboardDevice, NIL);

    where FKeyboardDevice is a IDirectInputDevice8, or whatever. You'd then use the keyboard device var to access the keyboard. Your input variable should be declared as IDirectInput (maybe a specific version, like IDirectInput8 - can't remember).

    As a style note, Hungarian notation ("m_p") is frowned upon in the Delphi community. If possible, avoid it (although I understand that you may well be taking it from C++ example code).
    "All paid jobs absorb and degrade the mind."
    <br />-- Aristotle

  3. #3

    DirectInput creating?!

    [pascal]
    var
    g_pDI: IDirectInput8;
    g_pKeyboard: IDirectInputDevice8;
    begin
    if bExclusive then
    dwCoopFlags := DISCL_EXCLUSIVE
    else
    dwCoopFlags := DISCL_NONEXCLUSIVE;

    if bForeground then
    dwCoopFlags := dwCoopFlags or DISCL_FOREGROUND
    else
    dwCoopFlags := dwCoopFlags or DISCL_BACKGROUND;

    // Disabling the windows key is only allowed only if we are in foreground nonexclusive
    if bDisableWindowsKey and not bExclusive and bForeground then
    dwCoopFlags := dwCoopFlags or DISCL_NOWINKEY;

    // Create a DInput object
    hr := DirectInput8Create( HInstance, DIRECTINPUT_VERSION,
    IID_IDirectInput8, g_pDI, nil );

    // Obtain an interface to the system keyboard device.
    hr := g_pDI.CreateDevice( GUID_SysKeyboard, g_pKeyboard, nil );

    // Set the data format to "keyboard format" - a predefined data format
    //
    // A data format specifies which controls on a device we
    // are interested in, and how they should be reported.
    //
    // This tells DirectInput that we will be passing an array
    // of 256 bytes to IDirectInputDevice::GetDeviceState.
    hr := g_pKeyboard.SetDataFormat( c_dfDIKeyboard );

    // Set the cooperativity level to let DirectInput know how
    // this device should interact with the system and with other
    // DirectInput applications.
    hr := g_pKeyboard.SetCooperativeLevel( Handle, dwCoopFlags );
    [/pascal]
    There are only 10 types of people in this world; those who understand binary and those who don't.

  4. #4

    DirectInput creating?!

    10x for the info

    but Clootie hr := g_pKeyboard.SetCooperativeLevel( Handle, dwCoopFlags );

    how do i get the handle of an app created with Cmyd3dapplication ?

  5. #5

    DirectInput creating?!

    i am such a blind dude
    m_hWnd

    btw Clootie is there some documentation on the clootie dx9 ?
    cous i have to search most of the f() and vars in the headers which is not very fast

  6. #6

    DirectInput creating?!

    and again its me another problem

    [pascal]type
    TKeyBuff = array [0..256] of char;
    var
    KeyBuff : ^TKeyBuff;[/pascal]
    and just a couple a lines down :

    [pascal] DirectInput8Create(GetModuleHandle(nil),DIRECTINPU T_VERSION,IID_IDirectInput8,m_pDInput,nil);

    m_pDInput.CreateDevice(GUID_SysKeyboard, m_pDInputDevice, NIL);

    m_pDInputDevice.SetDataFormat(c_dfDIKeyboard);

    InputCoopFlags := DISCL_EXCLUSIVE +DISCL_FOREGROUND + DISCL_NOWINKEY;
    m_pDInputDevice.SetCooperativeLevel(m_Hwnd,InputCo opFlags);
    m_pDInputDevice.Acquire;

    case m_pDInputDevice.GetDeviceState(sizeof(KeyBuff),Key Buff) of
    DIERR_INVALIDPARAM : MessageBox(m_hwnd,'Invalid Parameters','',MB_OK);
    DIERR_INPUTLOST : MessageBox(m_hwnd,'Input Lost','',MB_OK);
    DIERR_NOTACQUIRED : MessageBox(m_hwnd,'Not Acquired','',MB_OK);
    DIERR_NOTINITIALIZED : MessageBox(m_hwnd,'Not Initialized','',MB_OK);
    E_PENDING : MessageBox(m_hwnd,'Pending','a',MB_OK );
    end;[/pascal]

    the code looks good and the compiler gives no error but when i run it
    it gives me Invalid Parameters so my gues is that the getdevicestate is called with bad arguments but so far i couldnt fix it, help please

    what am i doing wrong

  7. #7

    DirectInput creating?!

    btw Clootie is there some documentation on the clootie
    cous i have to search most of the f() and vars in the headers which is not very fast
    Yes, its' called MS DirectX SDK: http://msdn.microsoft.com/directx. But for D3DFramework there is not much of it.

    About erros....
    You need: [pascal]TKeyBuff = array [0..255] of char;
    [/pascal]
    There are only 10 types of people in this world; those who understand binary and those who don't.

  8. #8

    DirectInput creating?!

    hm.. i still get invalid parameters any other ideas??

  9. #9

    DirectInput creating?!

    sizeof(KeyBuff^) or sizeof(TKeyBuff)
    There are only 10 types of people in this world; those who understand binary and those who don't.

  10. #10

    DirectInput creating?!

    i get an access violation at dinput8.dll when i use sizeof(TKeyBuff) or sizeof(KeyBuff^)

    i'm beggining to hate directinput.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •