Results 1 to 8 of 8

Thread: Problem with inmediate mode for mouse (Clootie's libs)

  1. #1

    Problem with inmediate mode for mouse (Clootie's libs)

    I made a version with DirectInput that is buffered and it works almost fine. One problem I found is when using the exclusive mode the cursor is lost, and other is the movement values of the mouse are not the same as the desktop mouse, making my cursor to delay it's position. Anyway, even solving this problem I'm limiting the coordinates of the mouse inside the window frame, causing the app and desktop pointer to have different positions. And, even with the desktop cursor hidden, I can see it interacting with background windows, not clicking but rolling over :? And it's supposed to be foreground and exclusive, no idea why it makes that! :x

    So, I don't want to fight nature anymore, and instead I want to allow and show the desktop cursor always, and I want to follow it while it crosses the window. But I have followed tutorials, I have followed the sample in DX9 SDK (the code for inmediate mode is so simple compared to buffered), but I just can't make it work!! :x When I call GetDeviceState, it returns errors. I Adquire the device in a loop, and it returns 1, but when calling GetDeviceState it keeps returning some error code. It's hard to debug which error it is, but after crawling in the code I found it sends: DIERR_INVALIDPARAM... According to SDK:

    "An invalid parameter was passed to the returning function, or the object was not in a state that permitted the function to be called. This value is equal to the E_INVALIDARG standard COM return value."

    Not very informative. What can I do? I'm starting to hate DirectInput, it offers full control of the device, but that's not true... maybe I should read the mouse coordinates with WinAPI. Just in case, I'm using a formless application. Any suggestion?? Thanks in advance for any help.

  2. #2

    Problem with inmediate mode for mouse (Clootie's libs)

    Do you have small repro case? I would like to look at it.
    There are only 10 types of people in this world; those who understand binary and those who don't.

  3. #3

    Problem with inmediate mode for mouse (Clootie's libs)

    Thanks Clootie. I made a demo for you, and I get exactly the same errors (source included):

    http://www.teleportmedia.com/mundano/Mouse.zip

    This is the output I get:

    Code:
    Creating DirectInput, result = 0
    Creating system mouse device, result = 0
    Setting data format, result = 0
    Setting cooperative level, result = 0
    Aquiring device, result = -2147024891
    Getting device state, result = -2147024884
    Aquiring device, result = 0
    Getting device state, result = -2147024809
    Aquiring device, result = 1
    Getting device state, result = -2147024809
    Aquiring device, result = 1
    Getting device state, result = -2147024809
    Aquiring device, result = 1
    Everything goes fine in the initialization, then I can't read nor acquire the device. It's weird. :?

  4. #4

    Problem with inmediate mode for mouse (Clootie's libs)

    Yes, it's really an invalid param:
    as you called "Mouse.SetDataFormat(c_dfDIMouse);" you should later use "DIMOUSESTATE" and not "DIMOUSESTATE2".

    For second version of mouse state struct you should initialize with c_dfDIMouse2.
    There are only 10 types of people in this world; those who understand binary and those who don't.

  5. #5

    Problem with inmediate mode for mouse (Clootie's libs)

    Wow! Thanks a lot Clootie

  6. #6

    Problem with inmediate mode for mouse (Clootie's libs)

    Now I have it working. One question is, how do I determine the starting position of the mouse pointer? I'm using a formless window.

  7. #7

    Problem with inmediate mode for mouse (Clootie's libs)

    GetCursorPos()?
    There are only 10 types of people in this world; those who understand binary and those who don't.

  8. #8

    Problem with inmediate mode for mouse (Clootie's libs)

    Thanks again, and there is the SetCursorPos() function I needed.

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
  •