gamepad button event

Chat about the Ashita v3 project here.
gilles
Posts: 28
Joined: Sun May 15, 2016 1:53 pm

gamepad button event

Post by gilles » Fri Feb 23, 2018 2:22 am

hello,
have we gamepad buttons support in ashita ?
is it possible to react when gamepad buttons are pushed ?
i would liketo have an UI enhancement
Image
User avatar
atom0s
Site Admin
Posts: 375
Joined: Sat May 14, 2016 5:13 pm

Re: gamepad button event

Post by atom0s » Fri Feb 23, 2018 1:02 pm

Currently, no there is no exposure to gamepads in Ashita. Just support for handling them properly with multiple clients and such.
Ashita also only currently supports DirectInput controllers.
Lead Ashita Developer

Want to donate to say thanks?
https://www.paypal.me/atom0s
gilles
Posts: 28
Joined: Sun May 15, 2016 1:53 pm

Re: gamepad button event

Post by gilles » Fri Feb 23, 2018 7:39 pm

i'm working on UI like this one but with gamepad :
Image
i can imagine maybe doing this with joy2key to map buttons to shift/control 1-10
Sinnersslayer
Posts: 59
Joined: Thu Jan 25, 2018 6:48 am

Re: gamepad button event

Post by Sinnersslayer » Thu Mar 01, 2018 1:01 am

Oh wow this looks great!
gilles
Posts: 28
Joined: Sun May 15, 2016 1:53 pm

Re: gamepad button event

Post by gilles » Wed Mar 28, 2018 11:14 am

is there a start page to develop plugins ?
acording to this post on ffxiah, someone is using gamepad button in an ashita plugin
gilles
Posts: 28
Joined: Sun May 15, 2016 1:53 pm

Re: gamepad button event

Post by gilles » Wed Mar 28, 2018 1:34 pm

well, i found this : http://git.ashita.atom0s.com/Ashita/ExamplePlugin
i will look at it
User avatar
atom0s
Site Admin
Posts: 375
Joined: Sat May 14, 2016 5:13 pm

Re: gamepad button event

Post by atom0s » Wed Mar 28, 2018 7:51 pm

Their plugin specifically says Xbox controllers, so I'd assume he's probably hooking XInput himself and handling the key presses of the controller manually. Ashita does not handle XInput internally at all. It only has basic handling of DirectInput controllers to allow background usage and such.
Lead Ashita Developer

Want to donate to say thanks?
https://www.paypal.me/atom0s
gilles
Posts: 28
Joined: Sun May 15, 2016 1:53 pm

Re: gamepad button event

Post by gilles » Fri Mar 30, 2018 3:52 pm

i started to code a bit on this project and have a lots of questions.

1/ where is the main function ?
(the equivalent in lua for render event)

2/ ParseCommand and QueueCommand take a int32_t type parameter
i'm always setting this to 1 in lua addon, is it a good practice to use 1 here too ?

3/ since i use my PS3 pad in directinput, i started with this msdn code but plugin is crashing (in USB and BT)

Code: Select all

if( SUCCEEDED( pJoyConfig->GetConfig( 0, &PreferredJoyCfg, DIJC_GUIDINSTANCE ) ) ) // This function is expected to fail if no joystick is attached
so for now, i'm back to xinput but going to a full 13 buttons pad to a 10 buttons plus 2 triggers make me loose ffximon
i would like to make directinput available too later
User avatar
atom0s
Site Admin
Posts: 375
Joined: Sat May 14, 2016 5:13 pm

Re: gamepad button event

Post by atom0s » Sat Mar 31, 2018 12:17 pm

Are you coding a plugin or an addon? I'd assume a plugin for this so I'll answer as if that's true.

1. Plugins are initialized from an export then told to "load" via the class you exposes function "Initialize". Take a look at the example plugin project to get a grasp of how things should be setup:
http://git.ashita.atom0s.com/Ashita/ExamplePlugin

The plugin exports a class instance that Ashita will use internally to talk with your plugin:
http://git.ashita.atom0s.com/Ashita/Exa ... n.cpp#L508

When Ashita loads and initializes your plugin, it will call your plugins class Initialize function as seen here:
http://git.ashita.atom0s.com/Ashita/Exa ... in.cpp#L64

The example plugin is fairly well commented to explain everything else on what it does and how it works. If you have other questions though, feel free to ask.

2. The command functions take a param which can be seen here:
http://git.ashita.atom0s.com/Ashita/Ash ... ita.h#L175

1 means Typed, as if the user typed the command themselves. This is generally fine for most things. In some cases you would want to use Menu as this lets you target things by their id as if the game told the client to do something. In the event that you need a command to be parsed by force you can use -3 and so on.

3. PlayStation controllers use DirectInput, so you need to handle it with DirectInput. If you use a remapper program to turn it into an XInput controller, then you would need to use XInput etc.

Something else to keep in mind. You are already in a process that has loaded the controller objects. In order for you to do anything with the controller you need to either hook onto DirectInput's calls for the controller or get the controller to effectively lose sync with the game so its re-aquired later on to intercept that creation.

You can't really just create a normal instance of DInput and go as normal since the game is already doing that and Ashita is already hooking into that code. So you need to also hook into it.
Lead Ashita Developer

Want to donate to say thanks?
https://www.paypal.me/atom0s
gilles
Posts: 28
Joined: Sun May 15, 2016 1:53 pm

Re: gamepad button event

Post by gilles » Sat Mar 31, 2018 7:25 pm

thanks for your assistance
yes, i'm coding a plugin
i take that lua can't hook xinput or doing things like that, maybe i'm wrong but now i'm on c++

for now i put all my code in HandleIncomingPacket
but for the plugin to work, i have to generate packets so i move my character without interruption to test...
i still don't understand where i need to put my code

i have another problem : when i'm pressing 1 shoulder and 1 button, the game reacts
for example (with a PS3 pad) : R1+square opens main menu (in gamepad configuration tool, square is associated with main menu)
is there something i can do so game ignore square/triangle/circle/cross/left/right/up/down buttons when L1 or R1 are pressed ?

currently, but it's ugly, i'm just leaving only movements and cameras in configuration tool and i'm sending keyboard events to the game when L1/R1 are not pressed
Post Reply