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

I'm trying to setup your script in my game and I believe I did that right.


With what I'm having troubles though, is not having compatible controllers apparently. I kinda got stuck with getting it to work.


While I'll be trying to Google stuff by myself ~ does anybody know of a solution to make the game read non-xbox controllers?


(BTW I hate the xbox-controller issues these times =x )


WtvmtpT.png



I've added dll, configured stuff but still nothing. =/
Most USB gamepads from the last five years or so work out of the box with XInput, so require no special drivers to work. Failing that, if you have a PS3 controller you can use SCP.  If your controller is really that old, though, you may be able to get something going with a DirectInput to XInput wrapper, like this one.
Hmm... What I did so far is this:


That's my configuration in scripts:

Spoiler
def P1_UP;     WolfPad.trigger?🙂UP, 0); end
    def P1_DOWN;     WolfPad.trigger?🙂DOWN, 0); end
    def P1_LEFT;     WolfPad.trigger?🙂LEFT, 0); end
    def P1_RIGHT;     WolfPad.trigger?🙂RIGHT, 0); end
    def P1_A;     WolfPad.trigger?🙂A, 0); end
    def P1_B;     WolfPad.trigger?🙂X, 0); end
    def P1_START;     WolfPad.trigger?🙂START, 0); end
    def P1_SELECT;     WolfPad.trigger?🙂SELECT, 0); end
      
    def P2_UP;     WolfPad.trigger?🙂UP, 1); end
    def P2_DOWN;     WolfPad.trigger?🙂DOWN, 1); end
    def P2_LEFT;     WolfPad.trigger?🙂LEFT, 1); end
    def P2_RIGHT;     WolfPad.trigger?🙂RIGHT, 1); end
    def P2_A;     WolfPad.trigger?🙂A, 1); end
    def P2_B;     WolfPad.trigger?🙂X, 1); end
    def P2_START;     WolfPad.trigger?🙂START, 1); end
    def P2_SELECT;     WolfPad.trigger?🙂SELECT, 1); end

Made in class Game_System ~


And I'm referring to these keys as:

Spoiler
(It's a TEST SCENE's update method🙂



def update
    super
    if $game_system.P1_UP;    @v1 += 10; update_text; end
    if $game_system.P1_DOWN;  @v1 -= 10; update_text; end
    if $game_system.P1_LEFT;  @v1 -= 1; update_text; end
    if $game_system.P1_RIGHT; @v1 += 1; update_text; end
    if $game_system.P1_A;     @v1 += 100; update_text; end
    if $game_system.P1_B;     @v1 -= 100; update_text; end
    if $game_system.P1_START; @v1 += 333; update_text; end
    if $game_system.P1_SELECT;@v1 -= 333; update_text; end
      
    if $game_system.P2_UP;    @v2 += 10; update_text; end
    if $game_system.P2_DOWN;  @v2 -= 10; update_text; end
    if $game_system.P2_LEFT;  @v2 -= 1; update_text; end
    if $game_system.P2_RIGHT; @v2 += 1; update_text; end
    if $game_system.P2_A;     @v2 += 100; update_text; end
    if $game_system.P2_B;     @v2 -= 100; update_text; end
    if $game_system.P2_START; @v2 += 333; update_text; end
    if $game_system.P2_SELECT;@v2 -= 333; update_text; end
  end



It all works when I'll replace 


def P1_UP;     WolfPad.trigger?🙂UP, 0); end


with normal Input.trigger? stuff, so I assume this is configured properly.


I've tried the xbox emulator thingie ~

Spoiler
eb3ZnRZ.png



I was using that software before and it was working in other games, so I believe my controllers aren't that old, since they worked with that.


Though I can't manage to make it work in Ace ~ most likely I've derp'd with something~


As seen on screenshot above, both controllers are configured properly and the preview thingie works perfectly.


Now I have added these files to game's folder:

Spoiler
DbiKOen.png

And then, I'm closing the application and anything else, then run the game from EXE.


But it doesn't seem to work at all. =/


Did I miss something?


Thank you~
Easiest way to see if the script sees your controllers is to add the line WolfPad.test to the script page Main, right before the rgss_main loop, and then launch in test mode with the console window enabled. For your game, you should see the line "2 XInput controller(s) in use." printed out when you launch.

Code:
WolfPad.test
rgss_main {
  SceneManager.run
}
@Lone Wolf, along with a similar problem with @Rikifive (even when I installed the companion drivers for my older Logitech Rumblepad 2), the buttons on the Xbox 360 Controller respond so fast, that the engine gets the same input twice. Maybe it could be due to the input script I use, but I cannot confirm this right now.
With how RGSS3 handles input, it is actually impossible to process button input twice unless the query is being made twice, somehow. If you're using another input script at the same time, there's could be a conflict in the calls somewhere, and honestly, there are a lot of input scripts out there and I can't be arsed to check each and every one.


I'm guessing, though, that your problem could be something as simple as checking Input.press? when you mean to use Input.trigger? or Input.repeat? They have slightly different uses even though they all sound the same:


Input.press? is a pure binary state check that ignores input from previous frames.


Input.trigger? checks if a button has been pressed, but won't return true again until the button has been released and pressed again. 


Input.repeat? works mostly the same as Input.trigger?, except after a button has been held for 30 frames, it returns true every fifth frame for as long as the button continues to be held down. It's the call used to make menu cursors scroll really fast if you hold it down, while still allowing you to tap a direction to move it over one.
So, on this snippet on the Window_Selecteable:


#--------------------------------------------------------------------------
# * Cursor Movement Processing
#--------------------------------------------------------------------------
def process_cursor_move
return unless cursor_movable?
last_index = @index
cursor_down (Input.trigger?🙂DOWN)) if (WolfPad.press?🙂DOWN) || WolfPad.press?🙂L_DOWN))
cursor_up (Input.trigger?🙂UP)) if (WolfPad.press?🙂UP) || WolfPad.press?🙂L_UP))
cursor_right(Input.trigger?🙂RIGHT)) if (WolfPad.press?🙂RIGHT) || WolfPad.press?🙂L_RIGHT))
cursor_left (Input.trigger?🙂LEFT)) if (WolfPad.press?🙂LEFT) || WolfPad.press?🙂L_LEFT))
cursor_pagedown if !handle?🙂pagedown) && WolfPad.press?🙂R1)
cursor_pageup if !handle?🙂pageup) && WolfPad.press?🙂L1)
Sound.play_cursor if @index != last_index
end
#--------------------------------------------------------------------------
# * Handling Processing for OK and Cancel Etc.
#--------------------------------------------------------------------------
def process_handling
return unless open? && active
return process_ok if ok_enabled? && (Input.trigger?🙂C) || WolfPad.press?🙂A))
return process_cancel if cancel_enabled? && (Input.trigger?🙂😎 || WolfPad.press?🙂😎)
return process_pagedown if handle?🙂pagedown) && (Input.trigger?🙂R) || WolfPad.press?🙂R1))
return process_pageup if handle?🙂pageup) && (Input.trigger?🙂L) || WolfPad.press?🙂L1))
end


I replace Input.trigger to Input.press on the buttons (A, B, LB/L1, RB/L2)?


Also, is it possible to use both the analog stick and the d-pad at the same time (well, interchangeably without a setting)?
You need to write WolfPad calls the same as the Input calls you're running them alongside, or they'll be handled differently. For example this line of your code is checking standard RGSS3 input via trigger? but WolfPad input via press?


return process_ok if ok_enabled? && (Input.trigger?🙂C) || WolfPad.press?🙂A))


It (and the others) should read like this:


return process_ok if ok_enabled? && (Input.trigger?🙂C) || WolfPad.trigger?🙂A))


Otherwise, you're checking the keyboard once and the gamepad every frame, which is what's causing your repeated input.
That worked! Thank you!


Now, how do I make both the d-pad and the Left Analog Stick move the actors?
For that, you'd want to set move_with_stick to false over in PadConfig (to prevent it from redirecting automatically), and change Game_Player.move_by_input to something like this:


def move_by_input
return if !movable?
return if $game_map.interpreter.running?
dir = Input.dir4 != 0 ? Input.dir4 : WolfPad.lstick4
move_straight(dir) if dir != 0
end


That particular edit will prioritize input from the directional pad over the left stick, but you can also change the third line to


dir = WolfPad.lstick4 != 0 ? WolfPad.lstick4 : Input.dir4


to prioritize the left stick over the D-pad.
Okay, that works too.


Now, one last thing. For some reason, I cannot select on the menus with the left analog stick, even when I set the Window_Selectable like this:


#--------------------------------------------------------------------------
# * Cursor Movement Processing
#--------------------------------------------------------------------------
def process_cursor_move
return unless cursor_movable?
last_index = @index
cursor_down (Input.trigger?🙂DOWN)) if (WolfPad.trigger?🙂DOWN) || WolfPad.trigger?🙂L_DOWN))
cursor_up (Input.trigger?🙂UP)) if (WolfPad.trigger?🙂UP) || WolfPad.trigger?🙂L_UP))
cursor_right(Input.trigger?🙂RIGHT)) if (WolfPad.trigger?🙂RIGHT) || WolfPad.trigger?🙂L_RIGHT))
cursor_left (Input.trigger?🙂LEFT)) if (WolfPad.trigger?🙂LEFT) || WolfPad.trigger?🙂L_LEFT))
cursor_pagedown if !handle?🙂pagedown) && WolfPad.press?🙂R1)
cursor_pageup if !handle?🙂pageup) && WolfPad.press?🙂L1)
Sound.play_cursor if @index != last_index
end
#--------------------------------------------------------------------------
# * Handling Processing for OK and Cancel Etc.
#--------------------------------------------------------------------------
def process_handling
return unless open? && active
return process_ok if ok_enabled? && (Input.trigger?🙂C) || WolfPad.trigger?🙂A))
return process_cancel if cancel_enabled? && (Input.trigger?🙂😎 || WolfPad.trigger?🙂😎)
return process_pagedown if handle?🙂pagedown) && (Input.trigger?🙂R) || WolfPad.trigger?🙂R1))
return process_pageup if handle?🙂pageup) && (Input.trigger?🙂L) || WolfPad.trigger?🙂L1))
end


I can still select with the d-pad.


Could it be due to the menu script I'm using (Yanfly's Ace Menu Engine)?
I was writing this long complicated thing, but I figured out what actually happened. You can't check Input.trigger? for the same button twice in the same frame. The first check will work, but the second (and on) will be discarded as repeated input.


If you look at the original code for that section, it passes Input.trigger? along as a parameter on the condition that Input.repeat? is true. You accidentally replaced the repeat? checks with trigger? checks instead. Those lines should look like this:


cursor_down (Input.trigger?🙂DOWN)) if (WolfPad.repeat?🙂DOWN) || WolfPad.repeat?🙂L_DOWN))


What that method is supposed to do, is move the cursor in one direction for as long as the button is held down (that's repeat?), stopping the cursor at the end of the list only unless you're pressing the button again after releasing (that's trigger?) while it's already stopped at the end, in which case it wraps around to the other side.


Hope this helps you figure out where you got mixed up.
Okay, so after a bit of digging, I found that Yanfly Engine Core re-wrote the process_cursor_move when the Quick Scrolling was enabled. Pasted the gamepad code with a little different logic and now it works.


Thank you for you valuable help.
Easiest way to see if the script sees your controllers is to add the line WolfPad.test to the script page Main, right before the rgss_main loop, and then launch in test mode with the console window enabled. For your game, you should see the line "2 XInput controller(s) in use." printed out when you launch.

Code:
WolfPad.test
rgss_main {
  SceneManager.run
}

Aaaand it says 0. =/


What am I missing? D:


WtvmtpT.png



Hold your horses!


WtvmtpT.png



I got it working!


I've checked 'Help' tab in the controller-software and found this:

Spoiler
ropE12u.png

I remember, that I had the same issue with other games~ so instantly I've tried that and changing the filename to the last one worked!

Spoiler
5QD9dl3.png



This is amazing!! =3


Thank you very much! Now I can play my games properly! =3


YAY!!!!


Community much better than the software itself. =3
Ah, that was it. A while back I changed the core library from xinput1_3.dll to xinput9_1_0.dll to match the current standard, but of course that particular controller emulator works by replacing a specific DLL, so it wouldn't work without a rename. I also hadn't tested it with x360ce since I made that change, hence why I couldn't figure it out.


If it's going to cause that sort of error with such a commonly-used tool, I feel like it might be more worthwhile to just change it back and remind people that they really need to install DirectX if they expect to run anything on Windows.
I love this script, but I would like a bit of help. I'm reprogramming the windows in my game to allow for either the dpad or the left analogue stick to be used to go through the menus, but when I use the code as it is now:
  def process_cursor_move
    return unless cursor_movable?
    last_index = @index
    cursor_down (Input.trigger?🙂DOWN) or Input.trigger?🙂L_DOWN))  if Input.repeat?🙂DOWN) or Input.repeat?🙂L_DOWN)
    cursor_up   (Input.trigger?🙂UP) or Input.trigger?🙂L_UP))    if Input.repeat?🙂UP) or Input.repeat?🙂L_UP)
    cursor_right(Input.trigger?🙂RIGHT) or Input.trigger?🙂L_RIGHT)) if Input.repeat?🙂RIGHT) or Input.repeat?🙂L_RIGHT)
    cursor_left (Input.trigger?🙂LEFT) or Input.trigger?🙂L_LEFT))  if Input.repeat?🙂LEFT) or Input.repeat?🙂L_LEFT)
    cursor_pagedown   if !handle?🙂pagedown) && Input.trigger?🙂Z) # RB button
    cursor_pageup     if !handle?🙂pageup)   && Input.trigger?🙂Y) # LB button
    Sound.play_cursor if @index != last_index
  end


I get this error:


Script 'Window_Selectable' line 286: SyntaxError occurred.


unexpected keyword_or, expecting ')'
...right(Input.trigger?🙂RIGHT) or Input.Trigger?🙂L_RIGHT)) if...


If I change the above code to:


  def process_cursor_move
    return unless cursor_movable?
    last_index = @index
    cursor_down (Input.trigger?🙂DOWN) or Input.trigger?🙂L_DOWN))  if Input.repeat?🙂DOWN) or Input.repeat?🙂L_DOWN)
    cursor_up   (Input.trigger?🙂UP) or Input.trigger?🙂L_UP))    if Input.repeat?🙂UP) or Input.repeat?🙂L_UP)
    cursor_right(Input.trigger?🙂RIGHT)) if Input.repeat?🙂RIGHT) or Input.repeat?🙂L_RIGHT)
    cursor_left (Input.trigger?🙂LEFT) or Input.trigger?🙂L_LEFT))  if Input.repeat?🙂LEFT) or Input.repeat?🙂L_LEFT)
    cursor_pagedown   if !handle?🙂pagedown) && Input.trigger?🙂Z) # RB button
    cursor_pageup     if !handle?🙂pageup)   && Input.trigger?🙂Y) # LB button
    Sound.play_cursor if @index != last_index
  end


it then works, but (for hopefully obvious reasons) the cursor doesn't then wrap around to the left if moved to the right by the right analogue stick. Can someone please help me fix my code? Thanks.


UPDATE:


I changed 'or' to || in the area that was causing problems. For some reason, that fixed the problem and the cursor wraps regardless of if I use the dpad or the analogue stick too.
Just asking, is the home button on XBox controllers the guide button you were referring to? If so, I'll have to find another solution for a particular plan I have.
Hello it's me again.


I've ran into a small issue and I'm not sure what to do about this.


What's wrong?


Your script does a great job and everything is working perfectly. Everything besides one small thing.


When I'll not plug in any controller ~ Everything works perfectly.


When I'll plug in two controllers ~ Everything works perfectly. Each controller triggers its own inputs.


Now when I'll plug in only one controller - The game thinks, that there are two of them ~ That single controller triggers inputs from both.


Here's the input test - I'm using only one controller. The second one is not plugged in.

Spoiler
XKoFasB.gif

As you can see, pressing keys on one controller actually triggers inputs from both.


At the top you can see, that the game found 2 controllers, while only one is plugged in.


It's not a really big deal, but this bug allows players to cheat by doing this:

Spoiler
kppNGYK.png

They will be able to control 2 characters at the same time without any extra effort. Synchronized characters will basically result in double damage (double projectiles) and such, which is bad.


I know, that synchronized stuff like dancing or connetion is nice, but let's calm down with this a little. =3


Do you have any ideas what I could do with this? I'm suspecting xinput emulator/dll thingies, but I'm not sure how can I approach this. If it's not because of the script, then I'll try changing stuff around in that xinput emulator.


Besides that everything works perfectly and I'm really happy, that you've made such a script.


I'll appreciate any help,


Thank you!
I also have problems:


-When the gamepad is connected, Galv's Timed Button Attacks is automatically disabled. This is annoying, since I can't test if I have configured the buttons correctly.


-On Yanfly's Ace Message System, it doesn't skip messages when I hold down RB (but I can when I hold down the A button, where it shouldn't). I might have configured it wrong, but I'm asking just in case.
@Rikifive It must be something in the XInput emulator DLL, because I'm having trouble duplicating that error. If the emulator seems to be working fine, you might simply have accidentally coded something to check both controllers if one can't be found.


@AceOfAces_Mod As I mentioned in my first post, I can't reasonably test compatibility with other custom input scripts, but I have done my best to make sure my edits are minimally invasive. After a cursory read-through, I can't see anything that would cause a conflict, exactly, but I can see that it would take a lot of editing to make it work properly with my module's extra features. As for the Yanfly script, I'd need to know how you configured the skip button to be able to offer any real help.

Original thread: https://forums.rpgmakerweb.com/threads/gamepad-extender-v1-1-2-20-2015.1284/