[#5785] 7.10 Hotfix 3 BUG Pressing joystick key and mouse button triggers context menu on selected target during flight

Ask here if you experience technical problems with X4: Foundations.

Moderator: Moderators for English X Forum

Forum rules
See full rules at Technical Support Request Rules

Required Information in all Technical Support Requests

Please ensure that you provide the following information for all questions posted in this Technical Support forum.
  • Version and language (e.g. 8.00 Hotfix 3, English, etc.).
  • Whether or not your game is modified using any third party scripts or mods (see note below).
  • The game start you originally selected for the game in which the problem occurred.
  • Exact nature of the problem, where and when it occurs and what you were doing at the time.
  • Any possibly relevant changes you have made to your game, system, or software before the issue occurred.
  • Where appropriate, additional symptoms, error messages, links to saves, screenshots and crash dump files (see this Wiki entry).
  • Your system specifications in the form of a DxDiag report and vulkaninfo (see this Wiki entry).
Failure to provide all this information will make it pretty much impossible for people to help you and may mean that it takes longer for your problem to be identified and hopefully solved. So please don't waste your own time and everyone else's by just posting something like "My game freezes. Help!!!".

If you are supplying information that will not conveniently fit into posts in this forum (approx 70,000 character limit per post), in the worst case you can split long text files across 2 consecutive posts, or ideally you can upload the data to a reputable public fileshare site (a few examples are Google Drive, DropBox or PasteBin, etc) but please don't use sites that spam advertising or require registration for downloads. Please use in your post the open public sharing link to your file(s) that will not require any account or registration for others to download.

Note: Support for third party modifications must be provided by the authors of those modifications, and any requests for such support should be posted in the appropriate thread in the Scripts and Modding forum.
azaghal
Posts: 432
Joined: Wed, 21. Mar 07, 13:19
xr

[#5785] 7.10 Hotfix 3 BUG Pressing joystick key and mouse button triggers context menu on selected target during flight

Post by azaghal »

Store: GOG
OS: Debian GNU/Linux 12 (Bookworm)
Hardware: Thrustmaster T.16000M FCS HOTAS
Version: 7.10 Hotfix 3 (538965)
Modified: No
Game start: Young Gun
Configuration changes: See reproduction steps below

When the left mouse button is released while pressing/holding down a joystick button during flight, a context menu for the selected target is triggered, with the pre-requisite that the left mouse button is not bound to the Steer Towards Cursor control. In general, it looks like any mouse button that is bound to the Target Object (Mouse) control and not to any other will behave this way. Ordering of the press/release sequence is important (see reproduction steps) - mouse down, joystick button press, mouse release.

This being a little bit of a bizarre bug, to provide some context on how I ran into it - I have been trying to improve my control schema with the HOTAS, and ended-up experimenting with a couple of external applications - AntiMicroX, xbindkeys, and xdotool. The AntiMicroX application has allowed me to simulate a mouse-click on the center of the screen using one of the throttle (D-Pad Right) buttons. The other two I have used for some macro functionality to simulate a couple of missing controls/bindings/behaviours (like F2-like rename ship binding, calling up mission offers etc). So basically the AntiMicroX was effectively sending in a same-ish sequence like listed in the reproduction steps (both mouse and joystick button press).

Just to emphasize - the reproduction steps listed below have been 100% reliable for me even without the above-listed applications running, with pure vanilla game, straight out of fresh new game. I have checked multiple times to ensure that none of the above applications are running for reproducing the problem (ps aux and all). I have gone even as far as to fully reboot the machine prior to testing (just in case something is borked on a deeper level) after applying all pending upgrades. If you happen not to be able to reproduce the problem on your side, I will happily start with an unconfigured X4 game from scratch to see if I missed any other relevant configuration steps (heck, I could even create a new account on the machine just to be sure).

Reproduction steps:
  1. Connect the Thrustmaster T.16000M to the computer.
  2. Connect the Thrustmaster TWCS to the computer.
  3. Launch the game.
  4. Configure the controls as follows:
    • Configure the Thrusmaster T.16000M to be the joystick number one, and Thrustmaster TWCS to be joystick number two.
    • Reset controls to Default - Keyboard & Mouse / Controller profile.
    • Under General Controls, unbind Steer Towards Cursor binding from the left mouse button.
    • Under General Controls, unbind the joystick button you will be using for testing. For example D-Pad Right on TWCS (in loaded profile it should not be assigned to anything already).
    • Set the Gamepad Mode to Off
  5. Start a new game, skip the prologue sequence.
  6. Get into the ship, fly out of the station, and find some ship that can be targeted, then pause the game (just to test in peace).
  7. Click once on a target with left mouse button to select it.
  8. Hover the mouse cursor over target, press the left mouse button down, then press a button on joystick (D-Pad Right) while still holding the left mouse button down, release the button on joystick, and finally release the left mouse button as well.
  9. Context menu for the targeted ship will pop up.
Additional observations:
  • From what I can tell, the important thing is that the joystick button has been pressed and released while the mouse button has been pressed - so there can be some variations in reproduction steps so long as that part is respected.
  • Reproduction step require that the Gamepad Mode is Off or Only with Controllers. I noticed that a small mouse icon just under the speed indicator/FLR 0 seems to pop in and out of existence when doing this type of joystick/mouse combo.
  • If the Gamepad Mode is set to For all Controllers/Joysticks, issue cannot be reproduced. What is interesting is that in this mode the little mouse indicator icon from above does not flicker in and out.
  • If you hover the mouse cursor over selected target, then lift the mouse off the mouse pad surface while still managing to keep the cursor on top of target, you will reduce number of mouse events generated. In this set-up you can make sure that only the mouse click (and not movement) events are registered. In this instance it is clearly visible that the mouse icon under the speed meter pops back into existence when the mouse button is released - so maybe something accidentally gets carried over in state when that happens (this is just me making huge assumptions about your internal code, sorry if it sounds like rambling :) )?
Last edited by Tranxalive on Thu, 18. Jun 26, 19:36, edited 1 time in total.
Reason: Adding Mantis Report number.
azaghal
Posts: 432
Joined: Wed, 21. Mar 07, 13:19
xr

Re: 7.10 Hotfix 3 BUG Pressing joystick key and mouse button triggers context menu on selected target during flight

Post by azaghal »

Updated the title (had a typo in the game version - 7.00 -> 7.10).

Best regards
azaghal
Posts: 432
Joined: Wed, 21. Mar 07, 13:19
xr

Re: 7.10 Hotfix 3 BUG Pressing joystick key and mouse button triggers context menu on selected target during flight

Post by azaghal »

This obscure funny little thing is still present in version 9.00, probably would not care if it were possible to do left-click-style target selection under targeting reticle via mappable input.
azaghal
Posts: 432
Joined: Wed, 21. Mar 07, 13:19
xr

Re: [#5785] 7.10 Hotfix 3 BUG Pressing joystick key and mouse button triggers context menu on selected target during fli

Post by azaghal »

After digging into the game's scripting internals more than I really should, I finally managed to figure out why this happens. This is from the 8.00.HF4 version of the game (@HERE denotes the culprit piece of code):

Code: Select all

-- Handle mouse-click event (i.e. mouse button was released on the same Anark element on which it was pressed)
function handleMouseClick(element, delayed, mousebuttonid, modifiers)
        if isFirstPersonMode() then
                return -- special case: mouse clicks in first person are always handled in engine
        end
        local inputstate = ffi.string(C.GetCurrentTargetMouseButtonMapping(mousebuttonid, modifiers, true))
        if inputstate ~= "" then
                --print(string.format("handleMouseClick(element=%s, delayed=%s, mousebuttonid=%s modifiers=%s), mapped as %s", tostring(element), tostring(delayed), tostring(mousebuttonid), tostring(modifiers), inputstate))

                -- The mouse click is mapped to a TARGETMOUSE state in the input system. Since we handle that here, we have to notify the input system that the mouse input is blocked,
                -- preventing the default target mouse handling (for clicks outside of an Anark element, e.g. on object geometry or in empty space).
                -- Normally we can only block input when the button is pressed, not on release (see handleMouseDown()) because we cannot change our mind once the input handling has started -
                -- however, for TARGETMOUSE states it is guaranteed that the input is only handled on button-up, not on button-down, so it is not too late.
                C.SetMouseInputBlockedByAnarkElement(mousebuttonid, modifiers, true)

                if inputstate == "INPUT_STATE_TARGETMOUSE_SELECT" then
                        -- in touch controller/gamepad mode, INPUT_STATE_TARGETMOUSE_SELECT opens an interact menu on already selected target (unlike in mouse mode)

                        -- @HERE: Original line which exhibits the issue
                        performSelectSofttargetOnClick(element, delayed, false, (not private.mouseMode))

                        -- @HERE: "Fix" (that also kills off that touch/gamepad mode thing for opening interact menu on already selected target).
                        performSelectSofttargetOnClick(element, delayed, false, false)

                elseif inputstate == "INPUT_STATE_TARGETMOUSE_INTERACTION_MENU" then
                        performSelectSofttargetOnClick(element, delayed, true, true)
                elseif inputstate == "INPUT_STATE_TARGETMOUSE_SELECT_AND_INTERACT" then
                        performSelectSofttargetOnClick(element, delayed, false, true)
                else
                        DebugError("Target System error. Unhandled target mouse button mapping: " .. inputstate)
                end
        end
end
So, you press down the mouse button - the input gets put into mouse mode. Then you activate one of the joystick controls - the input gets put into joystick mode (so the private.mouseMode is now false). Then you release the joystick button - the input is still in joystick mode (private.mouseMode is false). You release the mouse button, but I guess it does not get detected as being in mouse mode at that point (yet), and the INPUT_STATE_TARGETMOUSE_SELECT gets kicked off and triggers the behaviour intended for controller/gamepad mode.

At least this could be interesting to anyone else that ends up working around the lack of manual boresight target selection via half-arsed solutions like myself...

Return to “X4: Foundations - Technical Support”