Announcement

Collapse
No announcement yet.

Gamepad Axis Events are Dirty Little Liars

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Gamepad Axis Events are Dirty Little Liars

    I am trying to support both mouse/keyboard and gamepad for a twin-stick-shooter style game. I'm scratching my head at gamepad axis events and how deceiving they are.

    My axis events are mapped like so:
    Click image for larger version

Name:	axisbinding.JPG
Views:	1
Size:	20.5 KB
ID:	1140640

    With my gamepads disconnected I receive gamepad axis events with a value of 0.0f every frame. With no gamepads connected, I'd expect this to either not get called or be NaN. I feel like I'm missing a key part of this story, do people dynamically bind/unbind axis based on gamepad connection polling?
    Dev Blog http://www.error454.com

    #2
    0.0f events are received every frame no matter which input device you are using. You should use something like this

    Code:
    if (!FMath::IsNearlyEqual(Val, 0.f))
    	{

    Comment


      #3
      Originally posted by envenger View Post
      0.0f events are received every frame no matter which input device you are using. You should use something like this

      Code:
      if (!FMath::IsNearlyEqual(Val, 0.f))
      	{
      Right. I'm doing some outright gamepad detection now:
      Code:
      if (UseGamepad)
      {
          LastAimX = Val;
      }
      I guess I'm more interested in why this is the case from an architectural point of view. 0.0f is a valid axis value for a gamepad but that's if and only if your gamepad is connected.
      Dev Blog http://www.error454.com

      Comment


        #4
        I don't know if this has any bearing on your case, but I think you are only supposed to make one map pr. axis. The positive one, that is. Now, I would imagine, that the inputs would report both 1 and -1 and -1 and 1, depending on which way you go on the axis...

        Comment


          #5
          Originally posted by oasf View Post
          I don't know if this has any bearing on your case, but I think you are only supposed to make one map pr. axis. The positive one, that is. Now, I would imagine, that the inputs would report both 1 and -1 and -1 and 1, depending on which way you go on the axis...
          Thanks for mentioning that. It doesn't affect the original issue, but it does make things cleaner and that makes me happy
          Dev Blog http://www.error454.com

          Comment

          Working...
          X