Author Topic: [FIXED] Fn key combinations cause OXCE to cycle through units  (Read 4542 times)

Offline Player701

  • Sergeant
  • **
  • Posts: 40
    • View Profile
I'm reporting this in a separate thread so that there is less chance for my report to get lost within the main thread.

My keyboard has an Fn key which, combined with the various F-keys in the upper row, can perform a variety of actions (controlling volume, media playback etc). For some reason, when I use such a key combination, it also causes OXCE to select the next unit on the battlescape. This happens even with the default configuration settings (I deleted my OpenXcom folder in Documents to verify the bug).

In addition, with my configuration file, each time I use an Fn key combo, the whole battlescape suddenly acquires a weird green tint (sorry, I have no idea what this is supposed to be - see screenshot). When I use such a key combo again (not necessarily the one I used just before), the tint disappears.

Spoiler:

Also, I have a separate USB volume control with a big knob, and it also cycles through units each time I use it. But all this weirdness only seems to happen on my desktop PC and not on my laptop for some reason. I can provide detailed system information if necessary. My OS is Windows 10 x64, on both PCs.

The bug does not happen in OpenXcom nightly openxcom_git_master_2020_03_27_1613, only in OXCE (6.4.2 tested).
« Last Edit: February 12, 2023, 09:16:27 am by Meridian »

Offline PltSgtMac

  • Squaddie
  • *
  • Posts: 8
    • View Profile
Re: [Bug] Fn key combinations cause OXCE to cycle through units
« Reply #1 on: March 28, 2020, 05:10:55 pm »
The green tint is night vision, Scroll Lock by default. Most keys can be changed under Options --> Controls. You can right-click on a shortcut there to disable it.

Offline Player701

  • Sergeant
  • **
  • Posts: 40
    • View Profile
Re: [Bug] Fn key combinations cause OXCE to cycle through units
« Reply #2 on: March 28, 2020, 05:26:54 pm »
I just disabled ALL shortcuts in Options -> Controls, and now Fn combos and my volume control do some really weird stuff. During a battle, it ended the current turn, opened the options menu, prompted me to abort the mission, and also brought up the firing modes menu for the selected soldier's weapon - and all of this happened at the same time.

It appears that this bug triggers when a shortcut is unset. In my preferred configuration, I did disable the night vision shortcuts (never needed it before, so I disabled it to avoid messing with it accidentally) - that's why it turns on with my config file but not with the default one. "Select Previous Unit" is unbound by default, and I haven''t touched it. If I bind it to anything, it no longer activates when I use the Fn key or the volume control.

In OpenXcom, "Select Previous Unit" is bound by default, that's why the bug doesn't happen there. But if I unbind it, it starts triggering to. So this is actually an issue from upstream, it seems.

Offline PltSgtMac

  • Squaddie
  • *
  • Posts: 8
    • View Profile
Re: [Bug] Fn key combinations cause OXCE to cycle through units
« Reply #3 on: March 28, 2020, 06:11:00 pm »
Most likely because right-clicking on a shortcut isn't really disabling the shortcut but setting it as "SDLK_UNKNOWN" (OptionsControlsState.cpp)
When you use volume control it is interpreted as "SDLK_UNKNOWN" instead of "SDLK_VOLUMEUP" or "SDLK_VOLUMEDOWN". Why that is I do not know.

Offline BlackStaff

  • Colonel
  • ****
  • Posts: 336
    • View Profile
Re: [Bug] Fn key combinations cause OXCE to cycle through units
« Reply #4 on: March 28, 2020, 07:20:23 pm »
It's not a bug to me. It's normal!
The game doesn't take into account the Fn key.

Offline PltSgtMac

  • Squaddie
  • *
  • Posts: 8
    • View Profile
Re: [Bug] Fn key combinations cause OXCE to cycle through units
« Reply #5 on: March 28, 2020, 07:43:36 pm »
You are right, it is normal to ignore Fn key. it is not normal to assign all "disabled" keys to "SDLK_UNKNOWN" and then do stuff when you press that key. It should ignore any SDLK_UNKNOWN key input.

Offline Player701

  • Sergeant
  • **
  • Posts: 40
    • View Profile
Re: [Bug] Fn key combinations cause OXCE to cycle through units
« Reply #6 on: March 29, 2020, 11:50:16 am »
Reported as #1481.

It seems that the Markdown parser on the bug tracker doesn't work for some reason. Doesn't look like it's been getting much attention lately... I hope the developers still use it.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9084
    • View Profile
Re: [Bug] Fn key combinations cause OXCE to cycle through units
« Reply #7 on: March 29, 2020, 11:52:13 am »
I'm reporting this in a separate thread so that there is less chance for my report to get lost within the main thread.

Thank you, yes this is the correct way of reporting bugs, much appreciated.
I wish everyone would do it this way.

1/ As for green tint, just change the NightVision hotkey in the Options from ScrollLock to something less exotic

2/ As for selecting next soldier... it is actually selecting previous soldier, not next :) Can also be fixed by assigning a hotkey to that action (by default the hotkey is empty in OXCE)

3/ Lastly "empty" hotkeys doing weird stuff is indeed a bug (I assume both in OXC and OXCE)... I will try to fix it

Offline Player701

  • Sergeant
  • **
  • Posts: 40
    • View Profile
Re: [Bug] Fn key combinations cause OXCE to cycle through units
« Reply #8 on: March 29, 2020, 12:07:19 pm »
2/ As for selecting next soldier... it is actually selecting previous soldier, not next :) Can also be fixed by assigning a hotkey to that action (by default the hotkey is empty in OXCE)

Yes, I already got that. However, assigning every unassigned action to something is a workaround and not an actual fix. I hope it can eventually be fixed for real. (and if for some reason it doesn't, maybe I'll even try to do that myself - just have to stop being lazy and take some time to set up the development environment again)

UPD: Here's my attempt to fix this: PR upstream

UPD2: The PR has been merged. Thanks to everyone who replied in this thread!
« Last Edit: April 05, 2020, 09:21:20 am by Player701 »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9084
    • View Profile
Re: [Bug] Fn key combinations cause OXCE to cycle through units
« Reply #9 on: April 05, 2020, 01:08:53 pm »
Merged in OXCE too.
I can't test it (don't have a fancy keyboard), let me know if it works...

Offline Player701

  • Sergeant
  • **
  • Posts: 40
    • View Profile
Re: [Bug] Fn key combinations cause OXCE to cycle through units
« Reply #10 on: April 05, 2020, 01:32:05 pm »
Well, I did test it in OpenXcom of course. I suppose it'll work in OXCE too, if there haven't been any significant changes to that part of code.