[PLUGIN] Simple Native-like Mouselocking Plugin

    • Plugin Information

      Plugin + Example Download

      Simple Mouselock Plugin: Download | Simple Mouselock Example: Download

      Plugin Description

      This plugin makes it possible to make use of native-like pointer locking in your projects and games. In comparison with the existing but deprecated plugin, this plugin is much more simplified and easier to use. The majority of features from the deprecated plugin have been imported, enhanced and optimized.

    • Plugin Features

      Featured Highlights:

      • Simple mouselocking with several bounding options
      • Properties and events to modify the pointer or fetch other useful information
      • New properties to auto-enable or activate mouselocking without any events
      • Generally simplified & optimized the plugin to improve usability
    • Plugin Changelog

      Version 1.5

      <Fixed> Bounding Area "Unbound" property not working correctly

      <Other> Updated example project to support the most recent version

      Version 1.4

      <Fixed> Bounding Area not updating when going into fullscreen

      <Fixed> Mouse pointer jumping in "bound to window" mode

      <Fixed> Setting pointer position X/Y not working in fullscreen mode

      <Other> Updated plugin example to address some minor issues

      <Other> Performance improvements and code optimization

    • Credits & References

      Thanks to armaldio for creating and making this plugin possible! (Donations ➚ | Website ➚)

  • Awesome! This plugin got released just in time for my 2D shooter's weapon wheel. When the weapon wheel UI pops up, I need to get mouse input even if the mouse is at the top limit of the screen. The mouse raw input did the trick. Thanks!

  • Awesome! This plugin got released just in time for my 2D shooter's weapon wheel. When the weapon wheel UI pops up, I need to get mouse input even if the mouse is at the top limit of the screen. The mouse raw input did the trick. Thanks!

    Cool, glad that you also found use for mouse locking in your game!

    It might be worth mentioning here since I forgot to do it in the main post but this plugin doesn't support minifying.

    If anyone is minifying their game on export, it will unfortunately break this plugin at the current state.

  • I came across 2 issues with the plugin that happens even with the example cap.

    The first is that when you go into full screen, the mouse seems to be locked to the previous window size. This can be worked around by disabling the mouselock, then re-enabling it.

    The second issue seems to happen randomly. When I preview your cap file, I click on the viewport to activate the mouse lock. Then if I just move the mouse around for a few seconds, the cursor will jump locations. Any chance you could look into this?

  • I came across 2 issues with the plugin that happens even with the example cap.

    The first is that when you go into full screen, the mouse seems to be locked to the previous window size. This can be worked around by disabling the mouselock, then re-enabling it.

    The second issue seems to happen randomly. When I preview your cap file, I click on the viewport to activate the mouse lock. Then if I just move the mouse around for a few seconds, the cursor will jump locations. Any chance you could look into this?

    I gave it over to Armaldio a couple of days ago, these bugs are quite difficult to fix but it should be possible (hopefully).

    Sorry for the late response. I will keep you posted about the progress.

  • Plugin Version 1.4 Released

    Cheers!

  • Okay, i´m a bit confused.

    I tried to set the plugin to "unbound" but the mouse (or at least the sprite that is bound to the mouse coordinates) is bound to the layout.

    Please tell me that i´m just to dumb to use it. ^^

    Here is a video.

    https://youtu.be/9Rdb3sAxbT8

  • Okay, i´m a bit confused.

    I tried to set the plugin to "unbound" but the mouse (or at least the sprite that is bound to the mouse coordinates) is bound to the layout.

    Please tell me that i´m just to dumb to use it. ^^

    Here is a video.

    https://youtu.be/9Rdb3sAxbT8

    It looks like the unbounded property is bugged. Probably a result of fixing a previous bug.

    Gave it over to Armaldio, he should be able to fix it as soon as he's got the time to.

    EDIT: Update released, please remove all previous versions before installing the updated plugin!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Plugin Version 1.5 Released

    Cheers!

  • Thx, works great now. ^^

  • Is there a plugin for C3 as well?

  • Is there a plugin for C3 as well?

    Asked Armaldio about this and he says that should be doable.

    It might take a couple of days so I'd recommend subscribing to this topic to get notifications about the latest progress.

  • Unfortunately I'm unable to use this plugin since at random intervals it seems to read the raw mouse movement as opposite, and at a much greater speed compared to what I'm actually doing. So say I'm moving a sprite using the raw values to the right and it's reading raw X at around 2 to 9 - suddenly it will jump to the left at a raw x value of something like -280 for no apparent reason. Anyone else experiencing this?

    See these logged raw values as an example:

  • Unfortunately I'm unable to use this plugin since at random intervals it seems to read the raw mouse movement as opposite, and at a much greater speed compared to what I'm actually doing. So say I'm moving a sprite using the raw values to the right and it's reading raw X at around 2 to 9 - suddenly it will jump to the left at a raw x value of something like -280 for no apparent reason. Anyone else experiencing this?

    See these logged raw values as an example: <image>

    I believe this is the fault of the API and not of the actual plugin code. The Mouselock API is known for being buggy like that sometimes.

    Do you have the same problem when using "normal" and not "raw" coordinates?

    (P.s. We're currently having a completely reworked plugin in testing which will add C3 support and might fix issues like that as well.)

  • Ah, sorry, I forgot to mention as well that this was in NW.js.

    I investigated further and found this: https://github.com/nwjs/nw.js/issues/6336#issuecomment-352252411 I've been on a version a few versions back, avoiding to update in case it breaks a big project of mine. Testing v0.29.0 it seems the fix has been implemented, however, everything runs at 30 fps now (was hitting 144 fps without issues before) so I'll have to do some more testing, restart my computer and maybe try v0.28.0 too. I'll update with further findings.

    EDIT:

    So v0.28.0 seems to be the best solution for now if you don't wanna fiddle too much. Mouse lock works and the performance is good.

    I found the reason for the poor performance with v0.29.0 (Ashley and NW.js devs are aware as you can see): https://github.com/nwjs/nw.js/issues/6498

    Hopefully an updated version will be available soon that doesn't require manual handling of those command line arguments.

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