Skip to content

Fixes issues in mapping/unmapping joystick functions to OXP equipment#611

Merged
phkb merged 5 commits intomasterfrom
bugfix-oxp-joystick-mapping
May 2, 2026
Merged

Fixes issues in mapping/unmapping joystick functions to OXP equipment#611
phkb merged 5 commits intomasterfrom
bugfix-oxp-joystick-mapping

Conversation

@phkb
Copy link
Copy Markdown
Contributor

@phkb phkb commented Apr 25, 2026

Fixes #610

@mcarans
Copy link
Copy Markdown
Contributor

mcarans commented Apr 29, 2026

Is this a Windows specific issue or general? How can this fix be tested eg. install an OXP with equipment (such as your https://wiki.alioth.net/index.php/GalCop_Missions) then do something in the debug console to add the equipment?

@phkb
Copy link
Copy Markdown
Contributor Author

phkb commented Apr 29, 2026

It's not OS dependent. Before this fix, you couldn't map the Activate or Mode functions of OXP equipment (for instance, Fast Target Selector) to joystick buttons. When you try, nothing happens and you get an error in the log.

With the patch, you should be able to go into Joystick configuration and successfully map the Activate or Mode functions of OXP equipment to any joystick button.

@mcarans
Copy link
Copy Markdown
Contributor

mcarans commented Apr 29, 2026

Ok, I'll dig out my joystick and try tomorrow.

@phkb
Copy link
Copy Markdown
Contributor Author

phkb commented Apr 29, 2026

No idea why GitHub decided to flag the entire file as changed, when I only changed a few lines.

@mcarans
Copy link
Copy Markdown
Contributor

mcarans commented Apr 29, 2026

Maybe line endings have changed?

I was hoping to run a quick test this morning but ran into a problem with my nVidia drivers refusing to load and attached monitor not being recognised that I've wasted a lot of time debugging. All is working now, but I need to catch up with my day job.

@oocube
Copy link
Copy Markdown
Contributor

oocube commented Apr 30, 2026

If only line endings - or in other words whitespace changes you can ask various diff tools to ignore this. Github may be an exception, but e.g. WinMerge can.

@kanthoney
Copy link
Copy Markdown
Contributor

I can confirm this works apart from one thing - if you try unsetting a key when there's a joystick setting it still fails

@phkb
Copy link
Copy Markdown
Contributor Author

phkb commented Apr 30, 2026

Thanks @kanthoney, should be working now I think!

@kanthoney
Copy link
Copy Markdown
Contributor

I'm getting a crash if I set a joystick button to activate a feature, and then try and set a joystick button for the mode. Here's a backtrace, showing the crash is at src/Core/Entities/PlayerEntityStickMapper.m:296:

#0  0x00007ffff7493b8c in objc_msgSend_fpret () from /home/kevin/Documents/git/oolite/oolite.app/libobjc.so.4.6
#1  0x00007ffff7697188 in -[NSDictionary isEqual:] (self=0x5dea498, _cmd=<optimized out>, other=0x3b8fe78) at NSDictionary.m:761
#2  0x00007ffff7605ab7 in -[GSArray isEqualToArray:] (self=0x67b1b18, _cmd=<optimized out>, otherArray=0x395b3a8) at GSArray.m:328
#3  0x00007ffff776c71c in -[GSPersistentDomain setObject:forKey:] (self=0x7fffec085c98, _cmd=<optimized out>, anObject=0x67b1b18, aKey=0x9187a0 <.objc_str_CustomEquipActivation>)
    at NSUserDefaults.m:2872
#4  0x00007ffff7769c5d in -[NSUserDefaults setObject:forKey:] (self=0x7fffec08c1e8, _cmd=<optimized out>, value=0x67b1b18, defaultName=0x9187a0 <.objc_str_CustomEquipActivation>)
    at NSUserDefaults.m:1689
#5  0x000000000070a540 in -[PlayerEntity(StickMapper) updateFunction:] (self=0x1e8ea48, _cmd=<optimized out>, hwDict=0x5dbcd28) at src/Core/Entities/PlayerEntityStickMapper.m:296
#6  0x00000000008544ad in -[OOJoystickManager decodeButtonEvent:] (self=0x13ddbe8, _cmd=<optimized out>, evt=0x7fffffffcdc0) at src/Core/OOJoystickManager.m:639
#7  0x000000000085632e in -[OOSDLJoystickManager handleSDLEvent:] (self=0x3b8fe78, _cmd=<optimized out>, evt=0x7ffff7aeaa80 <._OBJC_CLASS_NSDictionary>) at src/SDL/OOSDLJoystickManager.m:82
#8  0x000000000085e444 in -[MyOpenGLView pollControls] (self=0xe03088, _cmd=<optimized out>) at src/SDL/MyOpenGLView.m:2147
#9  0x0000000000851c5d in -[GameController performGameTick:] (self=0xd484e8, _cmd=<optimized out>, sender=<optimized out>) at src/Core/GameController.m:366
#10 0x00007ffff7746c97 in -[NSTimer fire] (self=0x696e7a8, _cmd=<optimized out>) at NSTimer.m:342
#11 0x00007ffff771c3f0 in -[NSRunLoop _limitDateForContext:] (self=0xd04b38, _cmd=<optimized out>, context=0xd2f5c8) at NSRunLoop.m:1051
#12 0x00007ffff771cb89 in -[NSRunLoop limitDateForMode:] (self=0xd04b38, _cmd=0x7ffff7b63cf8 <.objc_selector_limitDateForMode:_240:816>, mode=0x7ffff7b4ba88 <.objc_str_NSDefaultRunLoopMode>)
    at NSRunLoop.m:1151
#13 0x00007ffff771d26a in -[NSRunLoop runMode:beforeDate:] (self=0xd04b38, _cmd=0x7ffff7b59ce8 <.objc_selector_runMode:beforeDate:_C320:81624>, 
    mode=0x7ffff7b4ba88 <.objc_str_NSDefaultRunLoopMode>, date=0x19eb1e3110000006) at NSRunLoop.m:1325
#14 0x00007ffff771d361 in -[NSRunLoop runUntilDate:] (self=0xd04b38, _cmd=<optimized out>, date=0x19eb1e3110000006) at NSRunLoop.m:1374
#15 0x000000000085650d in main (argc=1, argv=<optimized out>) at src/SDL/main.m:221

By the way, there is a line endings problem, which is why the pull request is saying the whole file has changed. If you run the command

git config --global core.autocrlf true

that should fix the problem in the future. The --global option sets it for all repositories - if you just want to change the setting for Oolite, leave off that option. More info here

@kanthoney
Copy link
Copy Markdown
Contributor

I think the problem is the release in PlayerEntityStickMapper.m:292 - you don't release this because you haven't created a copy of the object or allocated a new one. Taking out this line stops the crash

@mcarans
Copy link
Copy Markdown
Contributor

mcarans commented Apr 30, 2026

I tested and experienced a segmentation fault on exiting the game. The button setting worked though. @kanthoney 's suggested fix will likely resolve this crash which presumably has the same cause.

@oocube
Copy link
Copy Markdown
Contributor

oocube commented Apr 30, 2026

Go for it, guys. I just pulled out my old MS Sidewinder and experienced way better combat handling than with the keyboard. Still need to improve myself though. I was not aware that putting my hand on the force feedback joystick is already registered as button press.

But it shows to me how important good joystick support is.

@phkb
Copy link
Copy Markdown
Contributor Author

phkb commented May 1, 2026

That commit was me. Just got mixed up with another github account.

@kanthoney
Copy link
Copy Markdown
Contributor

I've found another problem. Try the following sequence:

  • Open your GNUstep/Defaults/OoliteDefaults.plist file and delete the setting for custom key configs, so you're starting from scratch
  • Buy some equipment and set a key to activate it
  • Then go into joystick settings, and set a joystick button for the mode
  • If you go back into key settings, the key you set to activate the equipment is no longer there

@phkb
Copy link
Copy Markdown
Contributor Author

phkb commented May 1, 2026

Should I be doing something different to get all the automated builds to work?

@mcarans
Copy link
Copy Markdown
Contributor

mcarans commented May 2, 2026

The Fedora failure should be fixed by merging master where I made a fix while doing the AnyLinux appimage changes. The windows failure is strange and needs investigation.

@oocube
Copy link
Copy Markdown
Contributor

oocube commented May 2, 2026

I've had windows build failures also on the semver branch where I just tried to calculate a version number (no code change at all). Seems some connectivity is broken.
Could we distinguish to buildy, test and publish the code to all the different targets? That would make it more evident where a problem might be. Also some of the target might not be required all the time, reducing our network dependency.

@mcarans
Copy link
Copy Markdown
Contributor

mcarans commented May 2, 2026

Ah that's good to know. The Windows test failure is for me to look into then.

@mcarans
Copy link
Copy Markdown
Contributor

mcarans commented May 2, 2026

I updated MSYS2 locally and hit the same problem. The test is actually working as it should. I cannot run Oolite itself outside the test - it gives a symbol error.

I've kicked off a new build of Windows dependencies and will check tomorrow to see if that fixes it: https://github.com/OoliteProject/oolite_windeps_build/releases/tag/0.1.1

@kanthoney
Copy link
Copy Markdown
Contributor

The latest commit fixes all the key/joystick mapping issues I can find

@mcarans
Copy link
Copy Markdown
Contributor

mcarans commented May 2, 2026

The Windeps build failed for the same reason the Arch build used to fail: I think MSYS2 has moved to clang 22. I will update to latest GNUstep packages.

@mcarans
Copy link
Copy Markdown
Contributor

mcarans commented May 2, 2026

In the meantime I tested on Linux and this PR works fine. If you've run it locally on Windows without issue, I'd say go ahead and release. No need to wait for my fix to Windeps.

@phkb phkb merged commit f71e5c6 into master May 2, 2026
21 of 24 checks passed
@mcarans
Copy link
Copy Markdown
Contributor

mcarans commented May 2, 2026

I was able to fix the Windows GNUstep build by adding -Wno-incompatible-pointer-types

I reran the Windows build of this PR on master and it now passes.

I am unsure if this flag is a good long term solution. I have raised an issue with GNUstep Base: gnustep/libs-base#604

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to map joystick functions to OXP equipment

5 participants