Hide mouse cursor when idle

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
106
Reaction score
114
First Language
French, German
Primarily Uses
RMMV
Hello everyone. Today I'd like to release a plugin I just made. (I hope I'm doing this right)
I call it: IdleMouse

It simply hides the mouse cursor when idle.
It also hides the mouse cursor immediately when the game starts, because otherwise the player would need to move the mouse at least once before the auto-hiding kicks in.

Note: The mouse cursor is only hidden when it is inside the game window. This is not a bug.

How to use
Just enable the plugin, that's it.
You can customize how long the mouse can remain idle before it is hidden. By default, the timeout is 3000 milliseconds (3 seconds).
Code:
//=============================================================================
// IdleMouse
//=============================================================================
/*:
 * @plugindesc Automatically hides mouse if it hasn't been moved for a while.
 * @author Nolonar
 *
 * @param Idle timeout
 * @desc How long the mouse can remain idle before it is hidden (in milliseconds).
 * @default 3000
 * @type number
 *
 *
 * @help This plugin does not provide plugin commands.
 *
 * Note:
 * The mouse cursor will only be hidden if it is above the game window.
 */
(function() {
    var timeoutDelay = Number(PluginManager.parameters('IdleMouse')['Idle timeout']) || 3000;
    var mouseIdleTimeout = null;
    var defaultCursor = document.body.style.cursor;
    hideMouse(); // Hidden by default.
    var window_onmousemove = window.onmousemove;
    window.onmousemove = function() {
        if (window_onmousemove) window_onmousemove.call(this); // Just in case the event is not yet set.
        showMouse();
        clearTimeout(mouseIdleTimeout);
        mouseIdleTimeout = setTimeout(function() {
            hideMouse();
        }, timeoutDelay);
    };
    function showMouse() {
        document.body.style.cursor = defaultCursor;
    };
    function hideMouse() {
        document.body.style.cursor = 'none';
    };
})();


If you don't care about the mouse at all and simply wish to keep it hidden at all times, you can just use the following one-liner.
Code:
document.body.style.cursor = 'none';
Terms of use
The one-liner (above) has absolutely no Terms of Use. Do with it whatever you want.​
The following Terms of Use only apply to the full plugin.​
  • Free for use in any RPG Maker game, commercial or not.
  • Credits not required.
  • Modifications allowed.
  • Redistribution allowed, but only if free.
  • Not allowed: Selling the plugin. It may only be sold as part of an RPG Maker game.
  • Not allowed: Claiming ownership of the plugin. You're allowed to claim ownership of any modifications you've made, as long as it's clear that it's a modification and that the original plugin isn't yours.
  • Not allowed: Change the Terms of Use. An exception is made for modifications. You are allowed to set your own Terms of Use for your modification, but it may not conflict against the "claiming ownership" or "selling" Terms.
  • I am not liable for any damage or misfortune incurred before, while, or after using the plugin or any of its modifications.

So basically, my Terms of Use are designed to be as pain-free as possible.
As long as you don't try to steal it or make profits from it (except if you're selling a game that uses the plugin), you're allowed to do pretty much whatever you want, without any obligations. You're not even required to bother with proper crediting.
In return, you agree that you won't use my plugin as an excuse to try to blame me for any misfortune that may have befallen you, past, present, or future.

Just be a decent human being, and we'll all be happy (I hope).
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

40 card deck size, the plugin seems more sluggish.
Village theme I composed for a commission!
Stream will be live shortly with some Haunting Ground! Feel free to drop by!
welp, the stock market went down by 7% because of corona today. Time to buy stocks?

Forum statistics

Threads
94,563
Messages
921,921
Members
124,429
Latest member
sheepman
Top