Jump to content

Supporting Xbox Controller in plugin?


DMes71

Recommended Posts

Does anybody know how to do this? I'm looking to start with just being able to read input from a controller. Are there any examples anywhere to follow? Is this supported with rage alone or do I need more references? Any push in the right direction is appreciated. 

Link to comment
Share on other sites

19 hours ago, DMes71 said:

Does anybody know how to do this? I'm looking to start with just being able to read input from a controller. Are there any examples anywhere to follow? Is this supported with rage alone or do I need more references? Any push in the right direction is appreciated. 

Game.IsControllerButtonDown() and the ControllerButtons enum should get you a long way :smile:

My YouTube: Click here. 

My Discord Server - https://discord.gg/0taiZvBSiw5qGAXU

Useful post? Let me and others know by clicking the Like button.
Check out my many script modifications! 
Having issues? LSPDFR Troubleshooter by Albo1125.

Link to comment
Share on other sites

2 hours ago, Albo1125 said:

Game.IsControllerButtonDown() and the ControllerButtons enum should get you a long way :smile:

I'll have to keep messing with it, but it doesn't seem to work.  I can't ever get IsControllerButtonDown() to return as true when I'm holding a button down.

Link to comment
Share on other sites

On 2/7/2016 at 4:16 AM, tanu1215 said:

Make sure to use a while loop to constantly listen for Button press events 

Thanks for the reply.

It's in a loop the code looks something like this:

while (true)
            {
                

                if (Game.IsKeyDown(Keys.E) || Game.IsControllerButtonDown(Rage.ControllerButtons.A))
                {
                    if (((Ped)GetAimedEntity()).Exists() && ((Ped)GetAimedEntity()).IsValid() 
                        && (((Ped)GetAimedEntity()).DistanceTo(Game.LocalPlayer.Character.GetOffsetPosition(Vector3.RelativeFront * 0f))) <= 5f)
                    {}
                                                                                                                                               
           }

I know the loop is working because the if statement passes if I press E.

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...