How do I detect input device and mouse movement?

0 favourites
  • 6 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Hello

    In my game I use three types of input controls



    -Keyboard & Mouse

    I want to detect input device dynamically according to one user is using.

    In the case of keyboard & mouse I want this to be activated using both - by key press and by mouse click or move.

    So far I managed to do everything except mouse move detection.

    My events

    So my question is - how can I detect mouse movement?

  • I believe on a device without mouse, Mouse.X and Mouse.Y will always return 0.

    So you can simple check if they are not equal 0.

  • Thanks for the reply but that is not something I'm looking for.

    Maybe I wasn't clear enough in my previous post - I want to detect input device dynamically to represent device used currently by the player. So in the example situation - lets presume the player uses PC and a gamepad - what I need is a way to detect if mouse was moved to change input device to "keyboard & mouse", and when player uses gamepad again it should change back to "gamepad".

    It works as expected using keyborad key press. The mouse movement detection is all I'm missing

  • Hello MrSheet,

    I didn't really understand why you need to detect which controller was used by the user as C2 already do the job for this, the easiest solution you have was to make function based event to call when action need to be performed ...


    On keyboard 'F' press

    or ---> function call "interact".

    On gamepad button 'A' press


    On function "interact" ---> YOUR ACTION EVENT HERE


    And this normally works ...

    But for mouse it's a little trickier you need to make two distinct event to perform this if it was based on mouse position (Mouse.X, Mouse.Y) if not it will work the same as the previous one with mouse click.

    Hope this could help if not post the sample capx and i will try to solve it with you =)

  • You can add a variable PreviousMouseX=0 and do this:

    On Every tick
    Mouse.X not equal PreviousMouseX
    ....Set controlsType="kn&mouse"
    ....Set PreviousMouseX to Mouse.X
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi and thanks!

    I've done something similar to dop2000 post


    I'm working on top-down shooter and I needed this detection to enable/disable certain controller specific events.

    For PC I need to hide all on-screen controls that are visible on mobile but also I had to disable mouse when using gamepad as one of my events for kb&mouse controls setting is "Every tick - player aim set angle to MouseX, MouseY" so even if the player is using gamepad the character was still aiming towards mouse position

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)