KGamePad HC
#1
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! Winking 

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.

Screenshots

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. [Image: wink.gif]
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply




Users browsing this thread: 1 Guest(s)