Windows SendInput function

About Monkey 2 Forums Monkey 2 Programming Help Windows SendInput function

This topic contains 7 replies, has 3 voices, and was last updated by  Hezkore 1 year, 11 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #8109

    Hezkore
    Participant

    I’m working on a front-end for my arcade machine.
    I need to translate my custom made gamepad into mouse movements.
    I’m trying to figure out how Window’s SendInput function works, but I’m really confused..

    Here’s the MSDN link to SendInput.
    https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310(v=vs.85).aspx

    Any help?

    #8110

    impixi
    Participant

    Can’t you just use MX2’s built-in event handling mechanisms to generate mouse movement events? Eg:

    [/crayon]
    #8115

    Hezkore
    Participant

    Hmm, my mouse doesn’t move when I run that code.
    But it does print “Spacebar pressed. Mouse moved.”.
    I need to actually move the mouse pointer around on the screen.
    Triggering the mouse event in M2 sadly isn’t enough.

    My arcade machine doesn’t have a mouse, just a gamepad I’ve built myself.
    Sometimes I do need a mouse though, so I figured I’d code a “mouse mode” or something, where I can control the mouse via the gamepad itself.

    #8116

    impixi
    Participant

    * Hide the “actual” mouse cursor. Draw a “sprite” mouse cursor instead.
    * Read your gamepad input coordinates.
    * Translate the coordinates to a screen location vector.
    * Draw the mouse cursor sprite at the vector.
    * Trigger an EventType.MouseMove event, including the vector.
    * Handle the event in the OnMouseEvent method.

    Easy peasy?! 😉

    Or I still misunderstand your objectives… Forgive me if that’s the case. 🙂

    #8118

    Hezkore
    Participant

    I need to click Windows buttons, or drag desktop icons, or click Windows text fields, browse the web etc.
    The mouse isn’t for my stuff, I just need to control it from my code to interact with lots of other applications.

    #8119

    impixi
    Participant

    Ah, I see. Then yes, you’ll need something lower level, probably coded in C/C++. Good luck. 😉

    #8121

    seyhajin
    Participant

    Directly with SDL function : SDL_WarpMouseGlobal:Void( x:Int, y:Int )
    Remarks : This function generates a mouse motion event. A failure of this function usually means that it is unsupported by a platform.

    #8127

    Hezkore
    Participant

    SDL_WarpMouseGlobal actually works for Windows stuff.
    Sadly, it doesn’t seem to register in any other apps.
    But it’s something at least!
    Big thanks.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.