GMS Smooth Mouse Scrolling

This is a hybrid half ask for help half request. Basically, GML has (to me) a glaring flaw in its mouse input library functions: the only thing you can detect about the mouse wheel is whether or not it is up or down. There is no information about how much the mouse wheel has been moved. The reason this is important is because the mouse wheel is moved at different rates across different OSs, and even across different installs of an OS depending on the OS-level settings. (e.g.: in the Mouse settings on macOS which has a slider for scroll speed) And across different inputs: trackpad vs a mouse with a real scroll wheel. Considering that macOS is my main OS of choice, I very much care that if I were to make anything the scrolling of any GUI I might make when using the trackpad would look and behave as I'd expect any other program on my computer to behave. (I'm interested in text adventures and made one at one point, so being able to naturally scroll the log of messages was important. I "emulated" it by using a static number of pixels per step if the wheel was moved, but that's not great, especially since I tuned for a macOS touchpad so scrolling with a wheel would feel EXTREMELY slow in comparison due to the rate of wheel events being much higher from a trackpad than a mouse wheel without getting RSI)

As an example of what I'm talking about, SDL has a SDL_MouseWheelEvent. (I'd link to it directly if it wouldn't flag this post for moderator approval) It has x and y values that give you a value representing how much to scroll, not just if the scroll happened. IIRC this should give results similar to scrolling any window in any normal GUI application if you abide by the number given as if it were pixels. I think GUI libraries often give a number that you can use to multiply by in order to show the same scrolling effect you'd normally expect.

So basically it comes down to needing one of two things to make scrolling work "correctly" across OSs: either an extension that can provide the necessary functions for getting OS-specific scroll values, or updating mouse input libraries in GML to provide that information. Ideally YYG would update the mouse library as I feel like it would be relatively easy for them to support that as they already have code for giving mouse input information and it would guarantee it always works. (it definitely feels like a neglected corner of GMS when you compare it to touch event handling and the absolutely phenomenal amount of information given for those, including things like dragging/flicking so you can do some nice smooth scrolling UI elements) But if there's another way to get this I'm still happy to have it available. I wouldn't hesitate to purchase a working extension that does what I'm asking across desktop OSs.
 

FoxyOfJungle

Kazan Games
I agree with all of that. Although we have the lerp() function to make it smoother, if I use the touchpad of a notebook to zoom with the pinch movement, the result is quite annoying, the zoom approaches super fast, because there is just no way to know the when it was rolled (since I'm using the mouse_wheel_ function)

Another thing that is missing is to detect the buttons 4 and 5 of the mouse, they are usually side buttons of the mouse. Most current games support this functionality.


 
Last edited:
I agree with all of that. Although we have the lerp() function to make it smoother, if I use the touchpad of a notebook to zoom with the pinch movement, the result is quite annoying, the zoom approaches super fast, because there is just no way to know the when it was rolled (since I'm using the mouse_wheel_ function)

Another thing that is missing is to detect the buttons 4 and 5 of the mouse, they are usually side buttons of the mouse. Most current games support this functionality.


For some reason I thought GMS had this capability already, but it just had a lot of convenience stuff around the "main 3" buttons. I would love for the other buttons to be accessible as well! Ideally you can just pass in an index to check buttons 4, 5, etc., more events can be made around that (like how we have "user event 0", "mouse button 4" up to some number, probably 15 or 16 because of the MMO mice that have like 12 buttons on one side of the mouse), and so on and so forth. Though I would not mind just a couple added GML functions for better mouse wheel handling and ability to access more mouse buttons and more integrated stuff can come later.

One thing that might be necessary for extra mouse buttons would probably be a way to query how many buttons are available. And/or a way to query which button is currently down (it can return 1, 2, 3) to be able to do things like customizable control bindings in an easier fashion than a huge if/else block.

Here's hoping someone from YYG can see these posts and comment on if this is something that can be added to their backlog, or if it can be possibly something that could come out in the near future.
 
Top