# \[Feature Request\] Gamepad bIsConnected

**URL:** <https://forums.unrealengine.com/t/feature-request-gamepad-bisconnected/336265>\
**Category:** Feedback & Requests\
**Tags:** gamepad, source-build, controller, unreal-engine, FeatureRequest, question\
**Created:** [October 23, 2015, 5:46pm UTC](https://forums.unrealengine.com/t/feature-request-gamepad-bisconnected/336265 "2015-10-23T17:46:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Helghast](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Helghast](https://forums.unrealengine.com/u/Helghast)\
**Post date:** [October 23, 2015, 5:46pm UTC](https://forums.unrealengine.com/t/feature-request-gamepad-bisconnected/336265/1 "2015-10-23T17:46:16Z")

</div>

Hello, [following this old post](https://answers.unrealengine.com/questions/142358/question-is-there-a-way-to-detect-a-gamepad.html), I have tried to implement the code to detect whether gamepad is connected.

```
//GenericApplication.h
virtual bool IsGamepadConnected() { return false; }
 
//WindowsApplication.h
virtual bool IsGamepadConnected() override;

//WindowsApplication.cpp
bool FWindowsApplication::IsGamepadConnected()
{
         return XInput->IsGamepadConnected();
}

//XInputInterface.h
bool IsGamepadConnected();

//XInputInterface.cpp
bool XInputInterface::IsGamepadConnected()
{
         for (int32 ControllerIndex = 0; ControllerIndex < MAX_NUM_XINPUT_CONTROLLERS; ++ControllerIndex)
         {
             FControllerState& ControllerState = ControllerStates[ControllerIndex];
             if (ControllerState.bIsConnected)
                 return true;
         }
         return false;
}

//MyPlayerController.cpp
TSharedPtr<GenericApplication> GenericApplication = SlateApplication::Get().GetPlatformApplication();
GenericApplication->IsGamepadConnected();

```

The function “GenericApplication-\>IsGamepadConnected()” returns “true” in the editor (PIE), but in a “package build” or a “Standalone Game” returns “false” (Windows). Anyone know why?

Another problem is that “ControllerStates[MAX\_NUM\_XINPUT\_CONTROLLERS]” is private, and to implement it I must to do on the Source version. This is a problem because all computers on our team have Binary version installed.  
It would be possible to add a “getter” (accessor method) to access the attribute in a new fix of the engine?

If this is not possible, any workaround?

Thx a lot 😉

---

<div class="post-metadata">

**Author:** ![Helghast](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Helghast](https://forums.unrealengine.com/u/Helghast)\
**Post date:** [November 2, 2015, 1:00pm UTC](https://forums.unrealengine.com/t/feature-request-gamepad-bisconnected/336265/2 "2015-11-02T13:00:52Z")

</div>

any workaround?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_06f28069](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_06f28069](https://forums.unrealengine.com/u/anonymous_user_06f28069)\
**Post date:** [September 13, 2017, 1:44pm UTC](https://forums.unrealengine.com/t/feature-request-gamepad-bisconnected/336265/3 "2017-09-13T13:44:35Z")

</div>

Possible solution here, have a look.

[link text](https://answers.unrealengine.com/questions/142358/question-is-there-a-way-to-detect-a-gamepad.html?childToView=706040#answer-706040)
