KGamePad HC - kyonides - 11-24-2025
KGamePad HC
by Kyonides
Introduction
This scriptlet shows you how you can easily implement a gamepad disconnection script.
The custom module includes all the methods the modified scene scripts would need to include. I also provide you with some XP's Scene_Title script add-on to allow it to display a gamepad icon based on its current status. This script will show you how easily you can implement the module's contents with very few lines of code.
Just don't forget to include the KGamePad module!
NOTES
The Input.gamepad_update call will return either some :add or :remove symbol. That symbol is first converted to a string and then it is used by my script to define which gamepad icon it should show next.
The Module Script
For RMXP
Code: # * KGamePad HC for XP * #
# Scripter : Kyonides
# 2025-11-24
module KGamePad
GAMEPAD_PIC = "gamepad_black"
GAMEPAD_XY = [12, 12]
GAMEPAD_FRAMES = 90
def create_gamepad_icon
@gamepad_timer = 0
@gamepad = Sprite.new
@gamepad.set_xy(*GAMEPAD_XY)
@gamepad.z = 10000
@gamepad.visible = false
@gamepad.bitmap = Bitmap.new(32, 32)
end
def dispose_gamepad_icon
@gamepad.bitmap.dispose
@gamepad.dispose
end
def update_gamepad_status
return if Input.gamepad_updates.empty?
type = Input.gamepad_update.to_s
@gamepad.bitmap.dispose
@gamepad.bitmap = RPG::Cache.picture(GAMEPAD_PIC + "_" + type)
@gamepad.visible = true
@gamepad_timer = GAMEPAD_FRAMES
@gamepad_pause = true
end
def update_gamepad_timer
return unless @gamepad_pause
@gamepad_timer -= 1
@gamepad_pause = @gamepad_timer > 0
@gamepad.bitmap.clear unless @gamepad_pause
end
end
For RMVX & RMVX ACE
Code: # * KGamePad HC for VX & ACE * #
# Scripter : Kyonides
# 2025-11-24
module KGamePad
GAMEPAD_PIC = "gamepad_black"
GAMEPAD_XY = [12, 12]
GAMEPAD_FRAMES = 90
def create_gamepad_icon
@gamepad_timer = 0
@gamepad = Sprite.new
@gamepad.set_xy(*GAMEPAD_XY)
@gamepad.z = 10000
@gamepad.visible = false
@gamepad.bitmap = Bitmap.new(32, 32)
end
def dispose_gamepad_icon
@gamepad.bitmap.dispose
@gamepad.dispose
end
def update_gamepad_status
return if Input.gamepad_updates.empty?
type = Input.gamepad_update.to_s
@gamepad.bitmap.dispose
@gamepad.bitmap = Cache.picture(GAMEPAD_PIC + "_" + type)
@gamepad.visible = true
@gamepad_timer = GAMEPAD_FRAMES
@gamepad_pause = true
end
def update_gamepad_timer
return unless @gamepad_pause
@gamepad_timer -= 1
@gamepad_pause = @gamepad_timer > 0
@gamepad.bitmap.clear unless @gamepad_pause
end
end
Scene_Title Add-On
Works on RMXP, RMVX & RMVX ACE
Code: class Scene_Title
include KGamePad
alias :kyon_gamepad_scn_ttl_main :main
alias :kyon_gamepad_scn_ttl_up :update
def main
create_gamepad_icon unless $BTEST
kyon_gamepad_scn_ttl_main
dispose_gamepad_icon unless $BTEST
end
def update
update_gamepad_status
update_gamepad_timer
kyon_gamepad_scn_ttl_up
end
end
Terms & Conditions
The same as HiddenChest Engine's.
|