Mouse Input Module 3.00 [XP/VX/VXA]

Have you renamed you Game.exe file?
If you have changed to say MyGame.exe then you have to change this piece:
  1. command = 'Game'
  2. # Change to
  3. command = 'MyGame'
Expand to see the code.


@Vergessen:
There is an issue with RGSS Player where pressing F12 does not properly restart the game.
It just starts over from the first section. Not all pieces of code works when you run them twice.
I haven't renamed Game.exe.
Guys, what version of RM* are you using? I just tested this with both XP and VX, and neither of them crashed on F12. Would you be able to tell me what version you're using, along with what scripts you've got in the game? Potentially, the stack level too deep error could be a result of some other script aliasing the update method of the Input module (which would mean it's actually my key input module that is causing the issue, and not this script. That said, if you're using ACE, I have yet to try any of my scripts in that, so I have no idea as to how functional they are in that. (One thing to note is that the typical reason for a crash is the use of the Ruby alias method. If you go to your script console, and hit ctrl+shift+f, then search for "alias" (without the quotes), you might find that other scripts are doing the same thing. If a script simply aliases a method, without checking to see if the aliased name already exists, and it calls the aliased version in the replacement, then you ALWAYS get a stack level too deep error when that method is called after hitting F12, because then the replacement method is aliased and replaced with itself, so it forms an infinite loop of calling itself, which gets cut short and throws the stack level error.)
Thanks for replyling. I'm on RMXP version 1.02a. The only other scripts in my project that alias anything are Ccoa's UMS and NR_Kready's Audio encryption, but neither of these alias anything in the Input module. I tried commenting every line of code beginning with the word "alias" in every script not written by you, but I still get a crash on F12. I've also tried creating a brand new project adding nothing to it other than the Input and Mouse scripts, and I still get the crash.
flowerthief wrote:
Thanks for replyling. I'm on RMXP version 1.02a. The only other scripts in my project that alias anything are Ccoa's UMS and NR_Kready's Audio encryption, but neither of these alias anything in the Input module. I tried commenting every line of code beginning with the word "alias" in every script not written by you, but I still get a crash on F12. I've also tried creating a brand new project adding nothing to it other than the Input and Mouse scripts, and I still get the crash.


Would you mind uploading a copy of that blank project so that I can try it out myself? I'm rather curious about why the blank project I tried worked just fine, while the one you tried did not. I'm also curious as to whether you did anything before hitting F12, and whether or not you're using the version of this script that I have in the first post of this thread.
edit:
Aha, I was not using the latest version of your Input module! (FYI your website doesn't have the latest version) After updating, the problem is gone :) Thanks for the help! This is a wonderful script.
Hello. Of all the mouse scripts I found yours to be convenient. I'm honestly a n00b and yeah, I read the advice, but how do I let the cursor show on full screen? It just disappears. Thank you!
Hey Glitchfinder, since becoming a programmer I can read RGSS scripts properly and understand them, yours is a brilliant example of Win32 DLL calls, thanks for writing this!

Have you experienced and performance drops when polling for mouse input? Zeriab tells me that all Win32 API calls lock the RGSS player's threads until they are complete, it would be interesting if your mouse input suffers from this too.
Jeea wrote:
Hello. Of all the mouse scripts I found yours to be convenient. I'm honestly a n00b and yeah, I read the advice, but how do I let the cursor show on full screen? It just disappears. Thank you!


It's been a while since I looked at this, but I'm fairly certain that you could do an event script call for Mouse.show_cursor() to manage that.

Xilef wrote:
Hey Glitchfinder, since becoming a programmer I can read RGSS scripts properly and understand them, yours is a brilliant example of Win32 DLL calls, thanks for writing this!

Have you experienced and performance drops when polling for mouse input? Zeriab tells me that all Win32 API calls lock the RGSS player's threads until they are complete, it would be interesting if your mouse input suffers from this too.


Actually, one of the main reasons I made this script was because the input setup I considered to be the best at the time, AWorks, was slow and had several logical errors in the setup. (If you'll note, the actual function names are rather blatant rip-offs of it, as well) The last time I checked, this actually didn't have any issues in terms of a performance hit, but that's mostly because it uses user32.dll, which Microsoft has optimized beyond belief due to its use in the OS itself. I would imagine that it does lock the thread though, it's just a matter of the access time being entirely minimal. (The dll is, from what I can recall, constantly loaded into active memory anyway) That said, on computers that have inherent I/O issues, I would imagine this would have a performance impact, but that's to be expected in such a situation.

Actually, your posting here reminded me of something. I've been planning to nuke the limits in the T&C section of all my scripts for a while now. I really don't care if people use the scripts for whatever they want, so long as they don't claim they made it. But, finding all of them and modding them right now is a bit of a pain, considering it's after midnight. Tomorrow, maybe.
Quote:
It's been a while since I looked at this, but I'm fairly certain that you could do an event script call for Mouse.show_cursor() to manage that.



Ok. so I tried putting it and inside the parentheses, I placed "reset_state = true" ( or just "true") and what happens is that the event/common event freezes, may it be set on parallel, autorun, etc. I've tried disabling the event by self switch, exit process, or erase event, and still the same happens. Next i tried putting it on the script, specifically on Main, below or on top of the auto fullscreen piece. It runs normally, except for the problem being unsolved. Any ideas?
Jeea wrote:
Quote:
It's been a while since I looked at this, but I'm fairly certain that you could do an event script call for Mouse.show_cursor() to manage that.



Ok. so I tried putting it and inside the parentheses, I placed "reset_state = true" ( or just "true") and what happens is that the event/common event freezes, may it be set on parallel, autorun, etc. I've tried disabling the event by self switch, exit process, or erase event, and still the same happens. Next i tried putting it on the script, specifically on Main, below or on top of the auto fullscreen piece. It runs normally, except for the problem being unsolved. Any ideas?


Hmm. Try dropping the parentheses altogether. The function isn't supposed to need them. (In other words, just "Mouse.show_cursor", minus the quotes.) Do you also have my Keyboard script installed? This gets updated by that one, and without it the mouse won't keep being updated.
Glitchfinder wrote:
Hmm. Try dropping the parentheses altogether. The function isn't supposed to need them. (In other words, just "Mouse.show_cursor", minus the quotes.) Do you also have my Keyboard script installed? This gets updated by that one, and without it the mouse won't keep being updated.


I tried it out, and it still freezes the event. It makes the player unable to move. I also tried it on main and same results also(see my early post). Yes, I do have your Key input module at the top of the Mouse input module. (I also upgraded it to version 1.20).
If this may help, I also have other scripts used like MGC's FPLE, and a map name displayer (which has no name on it..>< I'll look it up again)
Jeea wrote:
Glitchfinder wrote:
Hmm. Try dropping the parentheses altogether. The function isn't supposed to need them. (In other words, just "Mouse.show_cursor", minus the quotes.) Do you also have my Keyboard script installed? This gets updated by that one, and without it the mouse won't keep being updated.


I tried it out, and it still freezes the event. It makes the player unable to move. I also tried it on main and same results also(see my early post). Yes, I do have your Key input module at the top of the Mouse input module. (I also upgraded it to version 1.20).
If this may help, I also have other scripts used like MGC's FPLE, and a map name displayer (which has no name on it..>< I'll look it up again)


I was looking into it a couple of days ago, and it would seem my script has some flaws regarding showing/hiding the mouse. I got it to consistently show the mouse, but it couldn't keep it constantly visible in fullscreen even then. At the same time, I didn't test hiding the mouse, but I imagine it wouldn't be too difficult to hide the mouse and swap out an ingame cursor. I've done that before.
Glitchfinder wrote:
I was looking into it a couple of days ago, and it would seem my script has some flaws regarding showing/hiding the mouse. I got it to consistently show the mouse, but it couldn't keep it constantly visible in fullscreen even then. At the same time, I didn't test hiding the mouse, but I imagine it wouldn't be too difficult to hide the mouse and swap out an ingame cursor. I've done that before.


That sounds even better! Could you add that up to the script? That'd be awesome :angel:
I'm in the process of writing a pretty hefty update to this script and possibly my keyboard script. They'll both be getting new licenses as well. (at the moment, I'm thinking about going with the MIT license) To give a preview of the changes in this one, thus far I have:

  • Rewritten mouse show/hide to use image cursors
  • Finished implementing the double click feature
  • Reworked double click and drag tracking to work per button
  • Given access to more of the calculated values
  • Started work on functions to convert the different types of mouse coordinates I have to other kinds. (i.e. x, real_x, relative_x, etc.)

I might be able to post it tonight, but I'm not entirely certain.
Take your time. That's a long list. Thanks for giving it considerations by the way. I appreciate that. 😀
Jeea wrote:
Take your time. That's a long list. Thanks for giving it considerations by the way. I appreciate that. :biggrin:


Actually, everything but the last point in that list was written in the past tense because I had already done it. I was working on the last point when I got called in to work, so...yeah. Haven't finished, have a really busy schedule next week too >_<.
Oh, I see. XD You should comply with it then. Focus on that and when you feel like it, you can resume working on the last one. There's no need to rush it. Take your time, please. 🙂
I've just updated this script to a new version. The condensed changelog is below.

Version 3.00:
  • Updated and improved the update function.
  • Added the ability to use the non-primary mouse keys for the drag check.
  • Added the ability to use the non-primary mouse keys for the double-click check.
  • Added the ability to check the position of the mouse at the last click.
  • Added the ability to move the cursor.
  • Added shortcut functions for conversion between three of the coordinate systems used in this script.
  • Fixed the calculations used to determine screen size and location.
  • Fixed the show_cursor and hide_cursor functions.
  • Changed the license to the MIT license for better ease of use.
  • Tested to ensure functionality in RPG Maker XP, RPG Maker VX, and RPG Maker VX Ace.
  • Heavily updated the format of the initial post.

The most important update here is that this script is now under the MIT license, which means that you're free to use it as you see fit so long as you include the license somewhere. It also means I can't see any legal repercussions for what you do with the script, since that's not under my control. That said, this is a major update, enough that it got bumped up to 3.00 for the version number.
Awesome! Thanks Glithfinder. Definitely crediting you for this. :bd keep up the great work
Jeea wrote:
Awesome! Thanks Glithfinder. Definitely crediting you for this. :bd keep up the great work


I'm sorry it took so long to roll that update out. Stuff was kind of crazy at work for a few months, so I didn't have much time on my plate.

Anyway, if there are any issues, please feel free to ask about them.
Glitchfinder wrote:
Jeea wrote:
Awesome! Thanks Glithfinder. Definitely crediting you for this. :bd keep up the great work


I'm sorry it took so long to roll that update out. Stuff was kind of crazy at work for a few months, so I didn't have much time on my plate.

Anyway, if there are any issues, please feel free to ask about them.


It's ok. I tried it out a while earlier and so far, it works great. I'll let you know if I have one.
I'm having trouble getting LBUTTON, RBUTTON, ANYBUTTON to trigger anything. Other keys work, and position works, but none of my ifs do anything for mouse buttons. Could this be due to using a touchpad and usb mouse?
Do PRIMARY or SECONDARY work? If so, I recommend using those anyway (as they refer to whichever button "left" click is on the given machine. You can reverse them for lefties, after all.) As for ANYBUTTON, I'm not entirely certain what the issue could be. I doubt it has anything to do with the touchpad/USB mouse, since I built this script using the same kind of combination. When you say other keys work, what exactly does that refer to? If it's for the keyboard, I'll have to double check to make sure that things are interfacing properly. If it's for the mouse too, then I'll have to do some more in-depth digging to see if there have been any system-wide changes in how this input is handled.

Speaking of, what OS are you on?
I've worked out it's another script in my project causing issues, as it works perfectly in a blank project. I'll try and work out what it is and remove it. I wouldn't have thought anything I have would though, but I bet there's something.
Mind if I take a look at the project? I could probably narrow it down, at least.
I realised one of the scripts I have has an Input module in the middle of it. Removed it and it works fine now, sorry.
Hello,

I have some problems to use your script.
In fact, I don't know how to use it : for example, I would like to open the menu when I click on right button of my mouse (like a trigger so).
I used differents methods : event with a condition script/switch on to enable a common event witch work in parallel with switch condition.
I hope that you will accept help me ^^'

Kinsuke

PS : I'm french so, excuse me if my english isn't perfect ^^'
Hello! Thank you for the great scipt!

My knowledge is a bit limited, so I want to ask if it's possible (and if so, how) to transfer the values I get with Mouse.real_x_to_x() to variables? The idea is to have a parallel process event changing a picture depending on the mouse position.

Thank you for your help!
Use a Call Script event command to set `$game_variables[NUMBER] = Mouse.real_x_to_x()` where NUMBER is the variable number. That's my quick suggestion without knowing what the Mouse.real_x_to_x() method does.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=71133