Gamepad Extender (v1.1, 2/20/2015)

Lone Wolf

Tsundere
Veteran
Joined
Mar 13, 2012
Messages
311
Reaction score
73
First Language
English
Primarily Uses
Way to give me everything but what I need to help. :p

Which one is line 219?
 
Joined
Apr 20, 2015
Messages
23
Reaction score
0
First Language
English
Primarily Uses
Way to give me everything but what I need to help. :p

Which one is line 219?
Line 219 is:         key_holds(button, pad_index) > 0

I don't really think it might be your scripts problem and more of an edit error on my part with the multiplayer
 

Lone Wolf

Tsundere
Veteran
Joined
Mar 13, 2012
Messages
311
Reaction score
73
First Language
English
Primarily Uses
Still wasn't much to go on, but I reproduced that error. You forgot to set the number of gamepads to use, so it's trying to check the buttons on a pad it hasn't been told to look for. Look though PadConfig again and you'll see what you forgot to change.
 
Joined
Apr 20, 2015
Messages
23
Reaction score
0
First Language
English
Primarily Uses
Still wasn't much to go on, but I reproduced that error. You forgot to set the number of gamepads to use, so it's trying to check the buttons on a pad it hasn't been told to look for. Look though PadConfig again and you'll see what you forgot to change.
Thanks! I'll try it
 
Joined
Apr 20, 2015
Messages
23
Reaction score
0
First Language
English
Primarily Uses
Still wasn't much to go on, but I reproduced that error. You forgot to set the number of gamepads to use, so it's trying to check the buttons on a pad it hasn't been told to look for. Look though PadConfig again and you'll see what you forgot to change.
I did this and I had number of controllers set to 1 and currently nothing happens. Or is it that I change something else?
 

Lone Wolf

Tsundere
Veteran
Joined
Mar 13, 2012
Messages
311
Reaction score
73
First Language
English
Primarily Uses
I did this and I had number of controllers set to 1 and currently nothing happens. Or is it that I change something else?
It's confusing, but if you're trying to read values from pad 1, you need to use the pad ID 0. The code you posted had you trying to call values from pad ID 1 (which is controller 2). So either set the number of controllers to 2 for those calls to work, or set the ID of the controller you're checking to 0. Problem solved.
 
Joined
Apr 20, 2015
Messages
23
Reaction score
0
First Language
English
Primarily Uses
It's confusing, but if you're trying to read values from pad 1, you need to use the pad ID 0. The code you posted had you trying to call values from pad ID 1 (which is controller 2). So either set the number of controllers to 2 for those calls to work, or set the ID of the controller you're checking to 0. Problem solved.
That's sorta the point this is player 2's controller and it wasn't working. And still isn't
 

Lone Wolf

Tsundere
Veteran
Joined
Mar 13, 2012
Messages
311
Reaction score
73
First Language
English
Primarily Uses
Nope, you still aren't getting it. For two-controller support, set PadConfig.CONTROLLERS = 2, and make calls to it by its ID, 1. The numbers used are different. If you have the number of controllers set to 1, calls to a pad with id 1 won't work.
 
Joined
Apr 20, 2015
Messages
23
Reaction score
0
First Language
English
Primarily Uses
Nope, you still aren't getting it. For two-controller support, set PadConfig.CONTROLLERS = 2, and make calls to it by its ID, 1. The numbers used are different. If you have the number of controllers set to 1, calls to a pad with id 1 won't work.
Okay I did that and player 2 can't move only player 1
 

Lone Wolf

Tsundere
Veteran
Joined
Mar 13, 2012
Messages
311
Reaction score
73
First Language
English
Primarily Uses
Okay I did that and player 2 can't move only player 1
Which means you're still doing something wrong on your end. I'm willing to help out if it's actually an issue in my script, but now that we've cleared up that it's not you should be able to figure out the rest. There are entirely too many things that can go wrong when implementing unfamiliar code, and I think you'd be better served learning to do that on your own.
 

King Gerar

White Wolf
Veteran
Joined
May 15, 2012
Messages
165
Reaction score
212
First Language
Portuguese
Primarily Uses
RMMV
I'm trying to use this script along with this other, but only the directional functions works (buttons and analog). I tried to configure of different ways, putting ":A", ":B" ou "PadConfig.confirm" in the another script, for example, but not worked.

Is there a way to use them together, or really are incompatible? I appreciate if you can help me, because I don't understand scripts very well >.>
 

ZServ

Veteran
Veteran
Joined
Jun 16, 2014
Messages
260
Reaction score
71
Primarily Uses
Wolf may correct me if I'm wrong here, but it's important to remember that generally input scripts tap into the default input module OR replace them entirely. From what I'm seeing, you want to have the Extender first, then keyboard module, and then have the keyboard module use PadConfig calls, but from what I'm seeing (I'm no script genius either) they're putting the potential button presses into an array and then having it sorted elsewhere to be the proper option.

module Input @released = Hash.new{} @triggers = Hash.new{} @pressed = Hash.new{} @timer = Hash.new{} @table = { 2 => :DOWN, 4 => :LEFT, 6 => :RIGHT, 8 => :UP, 11 => :A, 12 => :B, 13 => :C, 14 => :X, 15 => :Y, 16 => :Z, 17 => :L, 18 => :R, }the above area is what you need to change on the keyboard manager, but I'm fairly certain it would need rewritten with support in mind for the extender.
 

Lone Wolf

Tsundere
Veteran
Joined
Mar 13, 2012
Messages
311
Reaction score
73
First Language
English
Primarily Uses
Having given it a once-over, the incompatibilities are on his end, not mine. He did the bad thing, not me. /pointsfinger
 
You'll want to put my module after the Keyboard Manager, because that module basically overwrites the entire default Input instead of simply aliasing a redirect like I did. If you do that, my script's very minor changes to Input will just reroute keyboard calls to the new module instead of the default (that is the purpose of alias, after all). If that doesn't work cleanly, it would probably only take a few minor edits to my Input aliases to work properly.
 
PadConfig exists only to correlate button mappings themselves, so it won't be useful for compatibility. It can, however, use Keyboard Manager's custom :SYMBOL mappings (i.e. :JUMP) without issue, so you should still use PadConfig calls in the rest of your scripts in place of direct :SYMBOL references.
 
 
I also have a few sample in-line edits that could prove useful for using the extended keyboard and gamepad together (though they won't "fix" anything):

return WolfPad.press?(button) || vxa_press?(button) if WolfPad.plugged_in?
Code:
WolfPad.plugged_in? ? [b]WolfPad.dir4 || vxa_dir4[/b] : vxa_dir4
If you scroll to the "Input redefinitions" section at the bottom of my module page, you should see which lines to edit. These are really advanced edits, though, so don't feel like you have to get them to work if you aren't sure.
 
Last edited by a moderator:

MikeJoz84

Warper
Member
Joined
Jun 6, 2015
Messages
1
Reaction score
0
Primarily Uses
Hello there! I'm a noob when it comes to scripting! How can I edit this so X is Y , Y is X and A is B, B is A ?

that way it will work perfect in my game. Tried many times to change it but nothing. Can you please help me!
 

Lone Wolf

Tsundere
Veteran
Joined
Mar 13, 2012
Messages
311
Reaction score
73
First Language
English
Primarily Uses
You shouldn't need to edit it at all. Just switch around which buttons the actual game scripts are checking.
 

redshard

Warper
Member
Joined
Sep 7, 2015
Messages
4
Reaction score
2
First Language
English
Primarily Uses
Hey, thanks for making this script. I really love that I can use vibrations now. But of course, I have a question.

My first problem is that on my Xbox 360 controller, B always opens the menu (and cancels it?) and A always edits the walking speed. No matter what I do, whether it be press F1 and change the controls (i.e. getting rid of all button assignments) or changing button assignments in your script, this problem persists. But when I removed your scripts and removed assignments in the F1 window, this problem was gone. What could be causing this if I removed all buttons related to those functions? It seems to be something in your script, but I don't seem to see any calls to sprinting or opening/closing the menu, aside from the configuration options in the beginning of your script. Then again, I am not familiar with what things are called in the script-world. Does that make sense?

Also, when you've told other people that if they want to change the default configurations, they have to edit the stock RPG Maker scripts, wouldn't that erase the keyboard controls? If it doesn't though, is there a list of all scripts that have input calls? Because I can't seem to find the file with the player movement stuff in it in the script editor.

Finally, could I make it to where the left control stick controls the player, as well as the menu, and have the dpad do the exact same thing? Either that or just use the dpad, but that's just my preference... I'd rather have both, if that's possible.

Thanks in advance for any responses. It's greatly appreciated. 
 

Rikifive

Bringer of Happiness
Veteran
Joined
Jun 21, 2015
Messages
1,441
Reaction score
680
First Language
Polish
Primarily Uses
Other
UOH! This is what I exactly need for my local coop game!

Gonna follow this topic, to remember about this and I'll try it later, because I'm busy right now.

Sounds totally great!
 

radicalpain

Villager
Member
Joined
Oct 7, 2014
Messages
6
Reaction score
0
First Language
English
Primarily Uses
awesome work wolf. I was planing on using this script for a game I am developing but have some issues. I do apologize if you have stated this before but I went through the forum and didn't see it. I wanted to use numbers instead on letters for my out (R2=:N1) which is number one. It works with my keyboard and everything works with my xbox one controller except when I try to change it over to numbers. I saw when you stated replace Input.trigger?:)C) with Input.trigger?(PadConfig.confirm] but have no idea when to change this. For testing purposes I posted my edited version tryng to use SHIFT instead on numbers. Please let me know where I got confused! Thanks!

R.Pain

#==============================================================================

# Gamepad Extender v1.1 (2/20/15)

# by Lone Wolf

#------------------------------------------------------------------------------

# This allows scripters to utilize the extra buttons on modern

# XInput-compatible gamepads. It requires DirectX 9.0 or later and

# an XInput compatible gamepad. Incompatible pads will default to

# using the standard Input module functionality.

#

# This is not a plug-and-play script.

# Some knowledge of RGSS is required for proper use.

#

# Instructions:

#     1) Paste in the Materials section

#  2) Replace button calls in (other) scripts to use gamepad buttons as needed

#        (see Command Reference below)

# Optional:

#     2) Use the PadConfig section to specify button differences between

#          Gamepad and Keyboard (for players without gamepads)

#     3) Replace direct button calls in your scripts (and the defaults) with

#          PadConfig calls or these will do nothing

#        (see Command Reference below)

#------------------------------------------------------------------------------

# Command Reference:

#------------------------------------------------------------------------------

# All calls to extended buttons on Pad 1 can be made through the Input module.

# When using multiple pads, send calls to WolfPad with pad number (0...3)

#    as the final parameter. (i.e.  WolfPad.press?:)A, 3)  )

#

# The current list of mappable buttons is as follows:

#

#     :A, :B, :X, :Y     - XBOX 360 standard face buttons.

#     :L1, :L2, :R1, :R2 - Four triggers (LB, LT, RB, RT)

#     :SELECT, :START    - Back and Start buttons

#     :L3, :R3                    - Clickable Analog buttons

#

#     :UP, :DOWN,

#     :LEFT, :RIGHT        - D-Pad buttons

#

#  :L_UP, :L_DOWN

#  :L_LEFT, :L_RIGHT  - Left stick directions

#

#  :R_UP, :R_DOWN

#  :R_LEFT, :R_RIGHT  - Right stick directions

#

# NON-STANDARD MAPPINGS WILL DO NOTHING without a compatible gamepad.

# To that end, use calls to PadConfig to remap non-standard keys into

# the standard domain where possible.

#

#         for example:    Input.trigger?(PadConfig.page_down)

#         will return :R1 if a gamepad is plugged in, but :R otherwise

#

# Analog values can be referenced with the following commands:

#     left_stick

#     right_stick

#     left_trigger

#     right_trigger

#

# Directional values of analog sticks can be referenced with these:

#     lstick4

#     lstick8

#     rstick4

#     rstick8

#

# Controller vibration can be accessed with these:

#     vibrate(left_motor, right_motor, frame_duration)

#     set_motors(left_motor, right_motor)

#

# All functions take an optional gamepad id (0-3) as their final parameter.

#

#------------------------------------------------------------------------------

# Terms of Use:

#------------------------------------------------------------------------------

#     If you use it, give credit. With a few caveats:

#

#     Can't call it alpha nay more, but I consider this script in-development.

#     I make no guarantees of compatibility with other scripts.

#

#  Contact me via PM is you plan on using this in a commercial game.

#  I probably won't charge anything, but I will want to know it's out there.

#

#     This script was posted at the official RPG Maker forums.

#     Do modify or redistribute this script by itself, though you may

#     include a configured version with your own script demos provided

#     you inclide this header in its entirety.

#------------------------------------------------------------------------------

# Contact Info:

#------------------------------------------------------------------------------

# I can be reached via PM only at the RPG Maker Web forums.

#                                                                                     (http://forums.rpgmakerweb.com)

#

# PM'ing the user Lone Wolf at other RPG Maker sites may have...

# unpredicatable results. I made someone really happy the day I registered...

#------------------------------------------------------------------------------

# Credits:

# Lone Wolf (99% of the code)

# raulf17 (directional movement bug fix; now obsolete)

#------------------------------------------------------------------------------

# 翻訳したいんですか?いいんだが、まだ未完成です。

#==============================================================================

module PadConfig

  # Basic configuration settings:

  # static:

  CONTROLLERS = 1 # can be any number from 1-4, higher values may cause errors

 

  # can be redefined by other scripts and changed in-game:

  def self.deadzone # Deadzone for axis input (%), may require adjusting

    0.01

  end

  def self.move_with_stick  # Use left-analog stick with dir4 and dir8

    false

  end

  def self.enable_vibration # Enable force-feedback

    true

  end

 

  # Use this section to write flexible button-mappings for your scripts.

  # Add additional methods as needed.

  # Format:   

  #      WolfPad.plugged_in? ? (gamepad binding) : (fallback binding)

  def self.confirm

    WolfPad.plugged_in? ? :A : :X

  end

  def self.cancel

    WolfPad.plugged_in? ? :B : :B

  end

  def self.dash

    WolfPad.plugged_in? ? :X : :A

  end

  def self.menu

    WolfPad.plugged_in? ? :Y : :Y

  end

  def self.page_up

    WolfPad.plugged_in? ? :L1 : :L

  end

  def self.page_down

    WolfPad.plugged_in? ? :R1 : :Input.trigger?:)SHIFT)

  end

  def self.debug

    WolfPad.plugged_in? ? :L2 : :N3

  end

  def self.debug2

    WolfPad.plugged_in? ? :R3 : :N4

  end

end

# Main module:

module WolfPad

  def self.update

    for pad_index in 0...PadConfig::CONTROLLERS

      input = get_state(pad_index)

      if @packet[pad_index] == input[0]

      set_holds(pad_index)

      next

      end

      @packet[pad_index] = input[0]

      @buttons[pad_index] = (input[1] | 0x10000).to_s(2)

      @triggers[pad_index] = [input[2], input[3]]

      @lstick[pad_index] = [constrain_axis(input[4]), -constrain_axis(input[5])]

      @rstick[pad_index] = [constrain_axis(input[6]), -constrain_axis(input[7])]

      set_holds(pad_index)

    end

    update_vibration

  end

  def self.test # Prints no. of detected controllers (debugging use only)

    detected = 0

    for i in 0...PadConfig::CONTROLLERS

      self.update

      detected += plugged_in?(i) ? 1 : 0

    end

    puts sprintf("%d XInput controller(s) in use.", detected)

  end

  def self.readout # prints a range from the holds table (debugging use only)

    for i in 18...26

      print sprintf(" %d", @holds[0, i])

    end

    puts ";"

  end

  # Basic vibration call.

  # For simplicity, motor values should be floats from 0.0 to 1.0

  def self.vibrate(left, right, duration, pad_index = 0)

    return unless PadConfig.enable_vibration

    set_motors(left, right, pad_index)

    @vibrations[pad_index] = duration

  end

  # Counts down vibration event timers

  def self.update_vibration

    for pad in 0...PadConfig::CONTROLLERS

       next if @vibrations[pad] == -1

       @vibrations[pad] -= 1

       if @vibrations[pad] == 0

          @vibrations[pad] = -1

          set_motors(0, 0, pad)

       end

    end

  end

  # Set left and right motor speeds. Vibration continues until stopped.

  # Repeated calls with different values can create vibration effects.

  # For simplicity, input values should be floats from 0.0 to 1.0

  def self.set_motors(left, right, pad_index = 0)

    return unless (PadConfig.enable_vibration) || (left == 0 && right == 0)

    left_v = [left * 65535, 65535].min

    right_v = [right * 65535, 65535].min

    vibration = [left_v, right_v].pack("SS")

    @set_state.call(pad_index, vibration)

  end

  def self.press?(button, pad_index = 0)

    key_holds(button, pad_index) > 0

  end

  def self.trigger?(button, pad_index = 0)

    key_holds(button, pad_index) == 1

  end

  def self.repeat?(button, p_i = 0)

    return true if key_holds(button, p_i) == 1

    return true if key_holds(button, p_i) > 30 && key_holds(button, p_i) % 5 == 0

  end

  # Returns left stick as a pair of floats [x, y] between -1.0 and 1.0

  def self.left_stick(pad_index = 0)

    @lstick[pad_index]

  end

  # Returns right stick as a pair of floats [x, y] between -1.0 and 1.0

  def self.right_stick(pad_index = 0)

    @rstick[pad_index]

  end

  # Returns left trigger as float between 0.0 to 1.0

  def self.left_trigger(pad_index = 0)

    @triggers[pad_index][0] / 255.0

  end

  # Returns right trigger as float between 0.0 to 1.0

  def self.right_trigger(pad_index = 0)

    @triggers[pad_index][1] / 255.0

  end

  def self.dir4(p_i = 0)

    return lstick4(p_i) if PadConfig.move_with_stick

    if press?:)UP, p_i)

     8

    elsif press?:)RIGHT, p_i)

     6

    elsif press?:)LEFT, p_i)

     4

    elsif press?:)DOWN, p_i)

     2

    else

     0

    end

  end

  def self.dir8(p_i = 0)

    return lstick8(p_i) if PadConfig.move_with_stick

    if press?:)UP, p_i) and press?:)LEFT, p_i)

     7

    elsif press?:)UP, p_i) and press?:)RIGHT, p_i)

     9

    elsif press?:)DOWN, p_i) and press?:)LEFT, p_i)

     1

    elsif press?:)DOWN, p_i) and press?:)RIGHT, p_i)

     3

    else

     dir4(p_i)

    end

  end

  # Left-stick direction

  def self.lstick8(p_i = 0)

      flags_to_dir8(key_holds:)L_RIGHT, p_i),key_holds:)L_LEFT, p_i),

                    key_holds:)L_DOWN, p_i),key_holds:)L_UP, p_i))

  end

  def self.lstick4(p_i = 0)

      flags_to_dir4(key_holds:)L_RIGHT, p_i),key_holds:)L_LEFT, p_i),

                    key_holds:)L_DOWN, p_i),key_holds:)L_UP, p_i))

  end

  # Right-stick direction

  def self.rstick8(p_i = 0)

      flags_to_dir8(key_holds:)R_RIGHT, p_i),key_holds:)R_LEFT, p_i),

                    key_holds:)R_DOWN, p_i),key_holds:)R_UP, p_i))

  end

  def self.rstick4(p_i = 0)

      flags_to_dir4(key_holds:)R_RIGHT, p_i),key_holds:)R_LEFT, p_i),

                    key_holds:)R_DOWN, p_i),key_holds:)R_UP, p_i))

  end

  def self.plugged_in?(pad_index = 0)

    @packet[pad_index] && @packet[pad_index] > 0

  end

  def self.keyboard_key?(button)

    !@keys.has_key?(button)

  end

 

  #Helper functions:

  # convert signed half-word axis state to float

  def self.constrain_axis(axis)

    val = axis.to_f / 2**15

    val.abs > PadConfig.deadzone ? val : 0

  end

 

  # derives a dir8 value from directional hold values

  def self.flags_to_dir8(right, left, down, up)

    x = right == left ? 0 : (right > left ? 1 : 2)

    y = down == up ? 0 : (down > up ? 1 : 2)

    table = [[5, 2, 8],

            [ 6, 3, 9],

            [ 4, 1, 7]]

    return table[x][y]

  end

  # derives a dir4 value from directional hold values

  def self.flags_to_dir4(right, left, down, up)

    selection = [right, left, down, up].max

    table = [0,0,down,0,left,0,right,0,up]

    return table.index(selection)

  end

 

  # calculates the precise geometric angle from stick axis values [x,y]

  def self.axis_to_angle(axis)

    cy = -axis[1]

    cx = -axis[0]

    return -1 if cy == 0 && cx == 0

    angle = Math.atan2(cx, cy) * 180 / Math::pI

    angle = angle < 0 ? angle + 360 : angle

    return angle

  end

 

  # Original angle-conversion handlers for analog sticks

  # OBSOLETE: preserved for reference only

  def self.axis_to_dir8(axis)

    angle_to_dir8(axis_to_angle(axis))

  end

  def self.axis_to_dir4(axis)

    angle_to_dir4(axis_to_angle(axis))

  end

 

  def self.angle_to_dir8(angle)

    return 0 if angle == -1

    d = 0

    if angle < 22.5 || angle >= 337.5

     d = 8

    elsif angle < 67.5

     d = 7

    elsif angle < 112.5

     d = 4

    elsif angle < 157.5

     d = 1

    elsif angle < 202.5

     d = 2

    elsif angle < 247.5

     d = 3

    elsif angle < 292.5

     d = 6

    elsif angle < 337.5

     d = 9

    end

    return d

  end

  def self.angle_to_dir4(angle)

    return 0 if angle == -1

    d = 0

    if angle < 45 || angle >= 315

     d = 8

    elsif angle < 135

     d = 4

    elsif angle < 225

     d = 2

    elsif angle < 315

     d = 6

    end

    return d

  end

 

  private # methods past here can't be called from outside

  # This hash correlates RM's Input to XInput keys. Experienced Users only!

  # The Input module will handle any keys not listed here (i.e. :CTRL) itself.

  # Integers refer to specific gamepad button IDs.

  @keys = {

    :UP    => 15, #d-pad up

    :DOWN => 14, #d-pad left

    :LEFT => 13, #d-pad down

    :RIGHT => 12, #d-pad right

    :A     => 3, #lower face button

    :B     => 2, #right face button

    :X     => 1, #left face button

    :Y     => 0, #upper face button

    :L1    => 7, #upper left trigger

    :R1    => 6, #upper right trigger

    :START => 11,

    :SELECT => 10,

    :L3    => 9, #left thubstick button

    :R3    => 8, #right thubstick button

    :L2    => 16, #lower left trigger (press only)

    :R2    => 17, #lower right trigger (press only)

    :L_UP    => 21,

    :L_DOWN    => 20,

    :L_LEFT    => 19,

    :L_RIGHT    =>18,

    :R_UP    => 25,

    :R_DOWN    => 24,

    :R_LEFT    => 23,

    :R_RIGHT    => 22

    }

  #Win32API calls. Leave these alone.

  @set_state = Win32API.new("XINPUT9_1_0", "XInputSetState", "IP", "V")

  @get_state = Win32API.new("XINPUT9_1_0", "XInputGetState", "IP", "L")

  #Initializers

  # Will store data for number of gamepads in use.

  @packet = Array.new(PadConfig::CONTROLLERS)

  @buttons = Array.new(PadConfig::CONTROLLERS)

  @triggers = Array.new(PadConfig::CONTROLLERS)

  @lstick = Array.new(PadConfig::CONTROLLERS)

  @rstick = Array.new(PadConfig::CONTROLLERS)

  # tracks how long buttons have been pressed

  @holds = Table.new(PadConfig::CONTROLLERS, 26)

  # stores vibration event timers

  @vibrations = Array.new(PadConfig::CONTROLLERS, -1)

  def self.key_holds(symbol, pad_index)

    return 0 if keyboard_key?(symbol)

    @holds[pad_index, @keys[symbol]]

  end

  def self.get_state(pad_index)

    state = "\0" * 16

    @get_state.call(pad_index, state)

    return state.unpack("LSCCssss")

  end

  def self.set_holds(p_i)

    for i in 1...17

     @holds[p_i, i-1] = @buttons[p_i].to_i > 0 ? @holds[p_i, i-1] + 1 : 0

    end

    @holds[p_i, 16] = left_trigger(p_i) >= 0.5 ? @holds[p_i, 16]+1 : 0

    @holds[p_i, 17] = right_trigger(p_i) >= 0.5 ? @holds[p_i, 17]+1 : 0

    @holds[p_i, 18] = left_stick(p_i)[0] >= 0.5 ? @holds[p_i, 18]+1 : 0

    @holds[p_i, 19] = left_stick(p_i)[0] <= -0.5 ? @holds[p_i, 19]+1 : 0

    @holds[p_i, 20] = left_stick(p_i)[1] >= 0.5 ? @holds[p_i, 20]+1 : 0

    @holds[p_i, 21] = left_stick(p_i)[1] <= -0.5 ? @holds[p_i, 21]+1 : 0

    @holds[p_i, 22] = right_stick(p_i)[0] >= 0.5 ? @holds[p_i, 22]+1 : 0

    @holds[p_i, 23] = right_stick(p_i)[0] <= -0.5 ? @holds[p_i, 23]+1 : 0

    @holds[p_i, 24] = right_stick(p_i)[1] >= 0.5 ? @holds[p_i, 24]+1 : 0

    @holds[p_i, 25] = right_stick(p_i)[1] <= -0.5 ? @holds[p_i, 25]+1 : 0

  end

end

# Aliases to tie the above into VXAce's Input module

module Input

  class <<self

    alias :vxa_update :update

    alias :vxa_press? :press?

    alias :vxa_trigger? :trigger?

    alias :vxa_repeat? :repeat?

    alias :vxa_dir4 :dir4

    alias :vxa_dir8 :dir8

  end

  def self.update

    WolfPad.update

    vxa_update

  end

  def self.press?(button)

    return vxa_press?(button) if WolfPad.keyboard_key?(button)

    return WolfPad.press?(button) if WolfPad.plugged_in?

    return vxa_press?(button)

  end

  def self.trigger?(button)

    return vxa_trigger?(button) if WolfPad.keyboard_key?(button)

    return WolfPad.trigger?(button) if WolfPad.plugged_in?

    return vxa_trigger?(button)

  end

  def self.repeat?(button)

    return vxa_repeat?(button) if WolfPad.keyboard_key?(button)

    return WolfPad.repeat?(button) if WolfPad.plugged_in?

    return vxa_repeat?(button)

  end

  def self.dir4

    WolfPad.plugged_in? ? WolfPad.dir4 : vxa_dir4

  end

  def self.dir8

    WolfPad.plugged_in? ? WolfPad.dir8 : vxa_dir8

  end

end
 
Last edited by a moderator:

Lone Wolf

Tsundere
Veteran
Joined
Mar 13, 2012
Messages
311
Reaction score
73
First Language
English
Primarily Uses
Not sure about the rest (put it in code tags, please), or where your custom :SYMBOLs are routed to, but if you're trying to use Input.trigger? calls from within PadConfig, you're already doing it wrong. PadConfig as written is strictly for deciding which of two :SYMBOLs to pass to Input calls in the main script package. Think of it as another way of writing a specific number, rather than an actual button check.

So:

  def self.page_down    WolfPad.plugged_in? ? :R1 : :Input.trigger?:)SHIFT)  endshould actually just be:

Code:
  def self.page_down    WolfPad.plugged_in? ? :R1 : :SHIFT  end
This is an oddly common mistake I've seen, but there really was no easier or more readable way to write that section than how I did, and I assumed it to be self-explanatory. Sorry 'bout that.

Also, this script only adds gamepad buttons read via XInput. For the numpad other keyboard key calls, you might need a separate script (if there is one), and you'll need to be sure to have this one after it in the script list. Unfortunately, RGSS is designed to only read a handful of specific keyboard keys, and this module makes no change to that part of the system.
 
Last edited by a moderator:

radicalpain

Villager
Member
Joined
Oct 7, 2014
Messages
6
Reaction score
0
First Language
English
Primarily Uses
Not sure about the rest (put it in code tags, please), or where your custom :SYMBOLs are routed to, but if you're trying to use Input.trigger? calls from within PadConfig, you're already doing it wrong. PadConfig as written is strictly for deciding which of two :SYMBOLs to pass to Input calls in the main script package. Think of it as another way of writing a specific number, rather than an actual button check.

So:

  def self.page_down    WolfPad.plugged_in? ? :R1 : :Input.trigger?:)SHIFT)  endshould actually just be:

Code:
  def self.page_down    WolfPad.plugged_in? ? :R1 : :SHIFT  end
This is an oddly common mistake I've seen, but there really was no easier or more readable way to write that section than how I did, and I assumed it to be self-explanatory. Sorry 'bout that.

Also, this script only adds gamepad buttons read via XInput. For the numpad other keyboard key calls, you might need a separate script (if there is one), and you'll need to be sure to have this one after it in the script list. Unfortunately, RGSS is designed to only read a handful of specific keyboard keys, and this module makes no change to that part of the system.
Thanks a lot. Yea I managed to get shift working so I think it is the script I am using won't work with it as I changed it to "F" instead of "N1" and still a no-go.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Are we allowed to post about non-RPG Maker games?
I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:

Forum statistics

Threads
105,883
Messages
1,017,236
Members
137,608
Latest member
Arm9
Top