Results 1 to 10 of 10

Thread: DirectInput is wierd

  1. #1

    DirectInput is wierd

    I've been trying to implement action mapping in my AlphaInput engine, but I'm a little puzzled about a few things.

    Microsoft define the DIACTION stucture with a field named uAppData of type UINT_PTR. In the Delphi (JEDI) version (DirectInput8.pas), the uAppData member of TDIAction is defined as a pointer. According to the DirectX help file, uAppData should be a pointer to a value to be returned in the uAppData member of the DIDDEVICEDATA structure. However, in the C++ sample program, Multimapper, they pass various constant values in the uAppData member, not pointers, and the value which is returned is exactly the same piece of data. So, what exactly is a UINT_PTR, and should I just use a DWORD instead of a pointer?
    [size=10px][ Join us in #pgd on irc.freenode.net ] [ Sign the Petition for a Software Patent Free Europe ][/size]

  2. #2

    DirectInput is wierd

    UINT_PTR is integer with SizeOf(UINT_PTR)=SizeOf(Pointer). So basically it was designed to allow programmers pass either integer or pointer to something with variables of this type.

    The bold line here - where are DirectX versions [beta & private] for 64bit processors.
    There are only 10 types of people in this world; those who understand binary and those who don't.

  3. #3

    DirectInput is wierd

    So it shouldn't be defined as Pointer in the JEDI headers? I've changed it to LongWord and it works fine.
    [size=10px][ Join us in #pgd on irc.freenode.net ] [ Sign the Petition for a Software Patent Free Europe ][/size]

  4. #4

    DirectInput is wierd

    PCardinal would be the closest, but Pointer is not wrong. As it doesn't matter what you reference there as long it's 4 Bytes (for 32 Bit Systems).
    Like a Delphi Comp or something else.

    Edit :
    LongWord is wrong, it's double wrong too ...

  5. #5

    DirectInput is wierd

    Quote Originally Posted by Summers Gone
    LongWord is wrong, it's double wrong too ...
    Why? Maybe it should be a Cardinal, but not a PCardinal since then I can only pass pointers to cardinals. I think the problem only arises because Delphi is more strongly typed than C++, which seems to let you pass whatever you like.
    [size=10px][ Join us in #pgd on irc.freenode.net ] [ Sign the Petition for a Software Patent Free Europe ][/size]

  6. #6

    DirectInput is wierd

    Why? Maybe it should be a Cardinal
    Right.
    but not a PCardinal since then I can only pass pointers to cardinals.
    Sure a PCardinal, passing a Pointer to Cardinal is exactly what you are supposed to do :
    "Address of an application-defined UINT value to be returned ... "

  7. #7

    DirectInput is wierd

    Quote Originally Posted by Summers Gone
    "Address of an application-defined UINT value to be returned ... "
    This is what I originally thought. But MS's tutorial and demo program doesn't pass a pointer, it passes a #DEFINE'ed constant, which Delphi won't let you do because Cardinal and Pointer are different types.
    [size=10px][ Join us in #pgd on irc.freenode.net ] [ Sign the Petition for a Software Patent Free Europe ][/size]

  8. #8

    DirectInput is wierd

    [pascal]const DefinedConstant : Cardinal = 2123;
    {or const DefinedConstant = 2123; }
    var DIAction : TDIAction;
    begin
    DIAction.uAppData := Pointer(DefinedConstant);
    end;[/pascal]

    This Syntax Highlighting Colors are a Joke !

  9. #9

    DirectInput is wierd

    Yeah, except I don't really like putting all those typecasts in there, especially when there is a whole array of TDIAction things.

    (Btw, you do know that
    [pascal]const DefinedConstant : Cardinal = 2123;[/pascal]
    is not the same as
    [pascal]const DefinedConstant = 2123;[/pascal]
    ?

    The first one is a typed constant, which is kept in memory, and the second is just a constant value that the compiler will replace references to with its value, which is why you cannot take the addess of the second type.)
    [size=10px][ Join us in #pgd on irc.freenode.net ] [ Sign the Petition for a Software Patent Free Europe ][/size]

  10. #10

    DirectInput is wierd

    Yes I know the difference. But the difference is of no importance here as
    the Typecast is not used to get the Address of the constant, it's just a Typecast. It's only a Number after all, it's totally in your hands how you use it.

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
  •