Author Topic: T-Flight HOTAS X and VA  (Read 2270 times)

blgarath

  • Guest
T-Flight HOTAS X and VA
« on: January 28, 2019, 02:17:31 PM »
I'm currently playing X4 Foundations, but the game is not complete and some functions aren't yet working. One of them is using the POV Hat to look around. I understand how to program VA to recognize the presses of the Hat and send the equivalent keyboard command to the game, so I'm able to look around, but not return to the center view without have to say the command "Center View." I'm not real good with programming in general, but is there a way to add a conditional to the commands so that if I release the Hat, it automatically returns to the center view? Any help would be appreciated.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: T-Flight HOTAS X and VA
« Reply #1 on: January 28, 2019, 03:26:49 PM »
Does the view pan to a set position? I.E. when you press the keyboard key once(by moving the hat), the view moves to a position and stays there?

If all you need is being able to hold the hat to look in a given direction, then release it to recenter, that's relatively simple:
Code: [Select]
Press NumPad 6 key and hold for 0,06 seconds and release
Start Loop While : Joystick 1 Button 1 Is Pressed OR Joystick 1 Button 2 Is Pressed OR Joystick 1 Button 3 Is Pressed OR Joystick 1 Button 4 Is Pressed
End Loop
Press NumPad 5 key and hold for 0,06 seconds and release

The command would press num6, wait until you none of the hat's POV directions are pressed, then center the view. If you roll the hat around multiple directions without centering, it'll center multiple times when you release it, but that shouldn't be an issue in most games.

Obviously you'd want to use the relevant keyboard keys and joystick buttons for your application instead(and probably add four more directions to the loop check, if you're using an eight-way hat).


If the view moves continuously while you hold the hat, you'd need to use a timeout(E.G. you can move the view for as long as you want, but if you stop for 1 second it'll center).

blgarath

  • Guest
Re: T-Flight HOTAS X and VA
« Reply #2 on: January 28, 2019, 04:25:19 PM »
When I created the commands, VA recognizes the POV Hat position for that command. Your solution would work if the POV Hat buttons were listed in the conditionals but they aren't.  The list has buttons 1 through 128 but not POV Hat buttons 1 though 8. The only thing I can think of is creating an if/then loop to check the position of the hat switch and then have it execute my "Center View" command if no buttons at all are pressed on the joystick. That would mean that if I'm in combat, I would have to release all buttons, including any fire or maneuvering buttons for it to work.

I guess I'm going to have to program a completely separate button to center the view. Once Egosoft gets the bug squashed that prevents the Hat from not working correctly, this will be moot.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: T-Flight HOTAS X and VA
« Reply #3 on: January 28, 2019, 04:55:46 PM »
Ah yes, I misremembered that the POV gets assigned to buttons.

However, the actual solution is simpler, so that's something:
Code: [Select]
Press NumPad 6 key and hold for 0,06 seconds and release
Start Loop While : [{STATE_JOYSTICK1POV1}] Does Not Equal 'CENTER'
End Loop
Press NumPad 5 key and hold for 0,06 seconds and release


The only thing I can think of is creating an if/then loop to check the position of the hat switch and then have it execute my "Center View" command if no buttons at all are pressed on the joystick.
Unfortunately the POV "buttons" don't trigger that condition.

blgarath

  • Guest
Re: T-Flight HOTAS X and VA
« Reply #4 on: January 28, 2019, 06:02:18 PM »
YES!! Awesome. Your solution works perfectly. Many, many thanks.   :D