Yanfly's Button Common Events: Binding to a gamepad?

Papillon

Veteran
Veteran
Joined
Feb 22, 2017
Messages
60
Reaction score
8
First Language
English
Primarily Uses
RMMV
Hi there. I'm currently having issues trying to get a common event to activate with a gamepad.
I have a common event where upon pressing a button the current party leader will change. I'm trying to get that to work by pressing the left shoulder button, so I've tried to bind the event to Page Up but nothing seems to work.
Is there any way to do this? I've tried Yanfly's Gamepad Config but that doesn't seem to work either/
 

Oatilis

Veteran
Veteran
Joined
Mar 16, 2016
Messages
37
Reaction score
12
First Language
Hebrew
Primarily Uses
I was searching for this as well, but couldn't find a fix so I just edited Yanfly's plugin to include the gamepad. This is an old thread so it might not be relevant to OP anymore, but I decided to reply anyway for people who might find this thread in the future looking for a solution. I would share the script but since Yanfly changed his revenue model (scripts are not free anymore) I don't think I can. So I can describe what I've done.

I only needed movement, plus buttons A and B but you can add all the rest.

First, I added the parameters to the plugin:
Code:
* @param ---Gamepad---
* @default
*
* @param Gamepad A
* @parent ---Gamepad---
* @type common_event
* @desc The common event to call when this button is pressed.
* Set to 0 if you don't wish for a common event to call.
* @default 0
*
* @param Gamepad B
* @parent ---Gamepad---
* @type common_event
* @desc The common event to call when this button is pressed.
* Set to 0 if you don't wish for a common event to call.
* @default 0
*
* @param Gamepad Up
* @parent ---Gamepad---
* @type common_event
* @desc The common event to call when this button is pressed.
* Set to 0 if you don't wish for a common event to call.
* @default 0
*
* @param Gamepad Down
* @parent ---Gamepad---
* @type common_event
* @desc The common event to call when this button is pressed.
* Set to 0 if you don't wish for a common event to call.
* @default 0
*
* @param Gamepad Left
* @parent ---Gamepad---
* @type common_event
* @desc The common event to call when this button is pressed.
* Set to 0 if you don't wish for a common event to call.
* @default 0
*
* @param Gamepad Right
* @parent ---Gamepad---
* @type common_event
* @desc The common event to call when this button is pressed.
* Set to 0 if you don't wish for a common event to call.
* @default 0
Then I added them to the BCE list:
Code:
Yanfly.Param.BCEList = {
      //GAMEPAD
      gamepad_a: Number(Yanfly.Parameters['Gamepad A']),
      gamepad_b: Number(Yanfly.Parameters['Gamepad B']),
      gamepad_up: Number(Yanfly.Parameters['Gamepad Up']),
      gamepad_down: Number(Yanfly.Parameters['Gamepad Down']),
      gamepad_left: Number(Yanfly.Parameters['Gamepad Left']),
      gamepad_right: Number(Yanfly.Parameters['Gamepad Right']),
      // list continues...
Then to the mapper section:
Code:
//=============================================================================
// Input Key Mapper
//=============================================================================

if (Yanfly.Param.BCEList['gamepad_a'] !== 0) Input.gamepadMapper[0] = 'gamepad_a';
if (Yanfly.Param.BCEList['gamepad_b'] !== 0) Input.gamepadMapper[1] = 'gamepad_b';
if (Yanfly.Param.BCEList['gamepad_up'] !== 0) Input.gamepadMapper[12] = 'gamepad_up';
if (Yanfly.Param.BCEList['gamepad_down'] !== 0) Input.gamepadMapper[13] = 'gamepad_down';
if (Yanfly.Param.BCEList['gamepad_left'] !== 0) Input.gamepadMapper[14] = 'gamepad_left';
if (Yanfly.Param.BCEList['gamepad_right'] !== 0) Input.gamepadMapper[15] = 'gamepad_right';
Now for the switching and reverting. This will be a bit more work, but for me, I just use 'Switch All' and 'Revert All' so I skipped checks for specific switching.
Code:
Input._revertButton = function(button) {
    ...
    ...
    } else if (button === 'ALL') {
        this.gamepadMapper[0] = 'ok';
        this.gamepadMapper[1] = 'cancel';
        this.gamepadMapper[12] = 'up';
        this.gamepadMapper[13] = 'down';
        this.gamepadMapper[14] = 'left';
        this.gamepadMapper[15] = 'right';
        ...
        ...
}

Input._switchButton = function(button) {
    ...
    ...
    } else if (button === 'ALL') {
          } else if (button === 'ALL') {
            if (Yanfly.Param.BCEList['gamepad_a'] !== 0) this.gamepadMapper[0] = 'gamepad_a';
            if (Yanfly.Param.BCEList['gamepad_b'] !== 0) this.gamepadMapper[1] = 'gamepad_b';
            if (Yanfly.Param.BCEList['gamepad_up'] !== 0) this.gamepadMapper[12] = 'gamepad_up';
            if (Yanfly.Param.BCEList['gamepad_down'] !== 0) this.gamepadMapper[13] = 'gamepad_down';
            if (Yanfly.Param.BCEList['gamepad_left'] !== 0) this.gamepadMapper[14] = 'gamepad_left';
            if (Yanfly.Param.BCEList['gamepad_right'] !== 0) this.gamepadMapper[15] = 'gamepad_right';


And here we go. It works great (I'm on MV version 1.5.2).
1602842013644.png
 
Last edited:

Mykeje

Villager
Member
Joined
Jan 31, 2019
Messages
9
Reaction score
3
First Language
Italian
Primarily Uses
RMMV
I was searching for this as well, but couldn't find a fix so I just edited Yanfly's plugin to include the gamepad. This is an old thread so it might not be relevant to OP anymore, but I decided to reply anyway for people who might find this thread in the future looking for a solution. I would share the script but since Yanfly changed his revenue model (scripts are not free anymore) I don't think I can. So I can describe what I've done.

I only needed movement, plus buttons A and B but you can add all the rest.

First, I added the parameters to the plugin:
Code:
* @param ---Gamepad---
* @default
*
* @param Gamepad A
* @parent ---Gamepad---
* @type common_event
* @desc The common event to call when this button is pressed.
* Set to 0 if you don't wish for a common event to call.
* @default 0
*
* @param Gamepad B
* @parent ---Gamepad---
* @type common_event
* @desc The common event to call when this button is pressed.
* Set to 0 if you don't wish for a common event to call.
* @default 0
*
* @param Gamepad Up
* @parent ---Gamepad---
* @type common_event
* @desc The common event to call when this button is pressed.
* Set to 0 if you don't wish for a common event to call.
* @default 0
*
* @param Gamepad Down
* @parent ---Gamepad---
* @type common_event
* @desc The common event to call when this button is pressed.
* Set to 0 if you don't wish for a common event to call.
* @default 0
*
* @param Gamepad Left
* @parent ---Gamepad---
* @type common_event
* @desc The common event to call when this button is pressed.
* Set to 0 if you don't wish for a common event to call.
* @default 0
*
* @param Gamepad Right
* @parent ---Gamepad---
* @type common_event
* @desc The common event to call when this button is pressed.
* Set to 0 if you don't wish for a common event to call.
* @default 0
Then I added them to the BCE list:
Code:
Yanfly.Param.BCEList = {
      //GAMEPAD
      gamepad_a: Number(Yanfly.Parameters['Gamepad A']),
      gamepad_b: Number(Yanfly.Parameters['Gamepad B']),
      gamepad_up: Number(Yanfly.Parameters['Gamepad Up']),
      gamepad_down: Number(Yanfly.Parameters['Gamepad Down']),
      gamepad_left: Number(Yanfly.Parameters['Gamepad Left']),
      gamepad_right: Number(Yanfly.Parameters['Gamepad Right']),
      // list continues...
Then to the mapper section:
Code:
//=============================================================================
// Input Key Mapper
//=============================================================================

if (Yanfly.Param.BCEList['gamepad_a'] !== 0) Input.gamepadMapper[0] = 'gamepad_a';
if (Yanfly.Param.BCEList['gamepad_b'] !== 0) Input.gamepadMapper[1] = 'gamepad_b';
if (Yanfly.Param.BCEList['gamepad_up'] !== 0) Input.gamepadMapper[12] = 'gamepad_up';
if (Yanfly.Param.BCEList['gamepad_down'] !== 0) Input.gamepadMapper[13] = 'gamepad_down';
if (Yanfly.Param.BCEList['gamepad_left'] !== 0) Input.gamepadMapper[14] = 'gamepad_left';
if (Yanfly.Param.BCEList['gamepad_right'] !== 0) Input.gamepadMapper[15] = 'gamepad_right';
Now for the switching and reverting. This will be a bit more work, but for me, I just use 'Switch All' and 'Revert All' so I skipped checks for specific switching.
Code:
Input._revertButton = function(button) {
    ...
    ...
    } else if (button === 'ALL') {
        this.gamepadMapper[0] = 'ok';
        this.gamepadMapper[1] = 'cancel';
        this.gamepadMapper[12] = 'up';
        this.gamepadMapper[13] = 'down';
        this.gamepadMapper[14] = 'left';
        this.gamepadMapper[15] = 'right';
        ...
        ...
}

Input._switchButton = function(button) {
    ...
    ...
    } else if (button === 'ALL') {
          } else if (button === 'ALL') {
            if (Yanfly.Param.BCEList['gamepad_a'] !== 0) this.gamepadMapper[0] = 'gamepad_a';
            if (Yanfly.Param.BCEList['gamepad_b'] !== 0) this.gamepadMapper[1] = 'gamepad_b';
            if (Yanfly.Param.BCEList['gamepad_up'] !== 0) this.gamepadMapper[12] = 'gamepad_up';
            if (Yanfly.Param.BCEList['gamepad_down'] !== 0) this.gamepadMapper[13] = 'gamepad_down';
            if (Yanfly.Param.BCEList['gamepad_left'] !== 0) this.gamepadMapper[14] = 'gamepad_left';
            if (Yanfly.Param.BCEList['gamepad_right'] !== 0) this.gamepadMapper[15] = 'gamepad_right';


And here we go. It works great (I'm on MV version 1.5.2).
View attachment 164025
OMG You saved me!! I'll never thank you much enough! Now I can finally make my action game!!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

All of the auditions for our game are so good, I'm so glad I'm not in charge of choosing completely. lol I just can't with some of them. I listen to them on repeat. XD
Working on a Patch to integrate AlphaABS into random generated Dungeons. Was a bit tricky, but the outcome is a real Life Changer!!

Will release it the next days!
Been pretty busy... but I got a better headset for recording and listening today. Dad says that he'll consider taking me to Great Wolf Lodge for the first time once I finish summer classes (my final semester!) I'll be taking my plushie friends with me: Bendy, Lolbit, and Helen Henny. (I WUV PLUSHIES!)
SF_Monster3,4 added!


My only regret is the portal mirror effect is too subtle to show up in these GIFs. It probably just needs more sparkles. :LZSwink:

Forum statistics

Threads
105,650
Messages
1,015,291
Members
137,327
Latest member
Mezzy
Top