Mouse Wheel Scroll
Authors: KK20
Version: 1.0
Type: Input Add-on
Key Term: Misc System
IntroductionThis script allows the use of scrolling the mouse wheel. It was written as an extension to Blizzard's Mouse Controller:
http://forum.chaos-project.com/index.php/topic,4710.0.html
Note that this script is not necessarily complete. It is up to you, the developer, to make use of this script's features. I only added the ability to scroll through Window_Selectable contents.
Features
- Players can scroll the mouse wheel
- Additional configuration option to allow the cursor to be visible at all times
- Windows_Selectable#update allows the ability to scroll through the windows via mouse wheel
ScreenshotsNone.
DemoNone.
Script
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Mouse Wheel Scroll for Mouse Controller
# Version: 1.0
# Type: Custom Input System
# Date: July 4 2016
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# Compatibility:
#
# Requires Blizzard's Mouse Controller
# http://forum.chaos-project.com/index.php/topic,4710.0.html
# Be sure the Mouse Controller is placed above this script.
#
# Features:
#
# - allows the ability to scroll the mouse wheel
# - adds an option to keep the mouse cursor constantly displayed on screen
#
# Instructions:
#
# Add the file MouseWheel.dll to your game project. Configure below.
#
# - Script Calls:
#
# The following commands are possible:
# Input.scroll_up? Returns TRUE if the wheel scrolled up
# Input.scroll_down? Returns TRUE if the wheel scrolled down
# Input.scroll? Returns TRUE if the wheel scrolled
# Input.wheel_delta Returns the number of times the wheel scrolled this
# frame (Positive for up, Negative for down)
#
# Side Note:
#
# Feel free to use this script in any way you want. If you would like the
# mouse wheel scrolling for another mouse script, you may modify this script
# accordingly.
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# If you find any bugs, please report them here:
# http://forum.chaos-project.com
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#===============================================================================
# Mouse
#===============================================================================
class Mouse
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# If true, the Windows cursor will always be displayed over the game window.
# If HIDE_WINDOWS_CURSOR is true, this option will be ignored.
ALWAYS_VISIBLE = true
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
StartWheel = Win32API.new('MouseWheel', 'Initialize', 'i', 'i')
StartWheel.call(HIDE_WINDOWS_CURSOR ? 0 : (ALWAYS_VISIBLE ? 1 : 0))
WheelDelta = Win32API.new('MouseWheel', 'WheelDelta', '', 'i')
attr_reader :delta
alias init_mouse_scroll initialize
def initialize
@delta = 0
init_mouse_scroll
end
alias update_for_mouse_scroll update
def update
@delta = WheelDelta.call
update_for_mouse_scroll
end
end
#===============================================================================
# Input
#===============================================================================
module Input
def self.scroll_up?
$mouse.delta > 0
end
def self.scroll_down?
$mouse.delta < 0
end
def self.scroll?
$mouse.delta != 0
end
def self.wheel_delta
$mouse.delta
end
end
#===============================================================================
# Window_Selectable
#===============================================================================
class Window_Selectable
alias update_for_mouse_wheel update
def update
if self.active
if Input.scroll_up?
self.top_row -= 1
elsif Input.scroll_down? &&
self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
self.top_row += 1
end
end
update_for_mouse_wheel
end
end
InstructionsRequires Blizzard's Mouse Controller script (link above). The Controller should be placed above this add-on in the script list.
Download the required DLL here (includes source code): Download (https://www.dropbox.com/s/iig0ckd9u5wbta5/MouseWheel.zip?dl=0)
All other instructions in script.
CompatibilityRequires Blizzard's Mouse Controller.
Credits and Thanks
- KK20 - Script and DLL
- Blizzard - Assistance with making DLL
Author's NotesPerformance might be slow on terrible computers. I would appreciate it if people can test this for me.
If you wish to adapt this script to other existing mouse controller scripts, you are free to do so.
(http://imgur.com/3Y8otkWs.png) (http://imgur.com/3Y8otkW.png)
http://imgur.com/3Y8otkW
it seems... not compatible with my Windows 7 Ultimate (Service Pack 1)
Script used :
RTP
Custom Control (Ripped from Tons)
Mouse Controller
Mouse Wheel Scroll
KK20, you should probably check my linker settings in XPA_Window. Mine works on XP SP3 and higher.
But does this only apply to this script or all my DLLs? I wonder if it has anything to do with the window events or creating a thread.
Likely all DLLs if you are using the same compilation settings. I set up mine to use the minimum of dependencies and to link to static libs so no extra stuff is needed. Handling window events and creating a thread shouldn't be a problem. Though, it might not be a bad idea to run Game.exe as admin to see if that is the problem.
I just installed a Win7Ultimatex64 VM to test it out. I think I uploaded the wrong version of the DLL, one that was using some optimization [-O2] (this is set by default :\ ). On my Windows10, it just gave me a critical error.
Anyways, the version I've been using for my tests is here: -removed-
Worked on my end.
I'll update the dropbox link when I get back home.
Edit: Done.
Perfect! :D