1
0
Fork 0

Fix a crash in Joypad initialization on iOS

Creating a JoypadApple can trigger a notification to add a joypad (if
a device is already connected before the game is started). Observed
on iOS 18.2.1 with a Nimbus SteelSeries.

However at this point the Input singleton is not available yet, so
it will crash.

This commit moves JoypadApple initialization to `initialize_joypad()`
which is called explicitly after the Input singleton is available.

This is consistent with other platform joypad initialization.
This commit is contained in:
Janis Kirsteins 2025-01-31 01:03:44 +01:00 committed by Jānis Kiršteins
parent 9ee1873ae1
commit e77a011188
No known key found for this signature in database
GPG Key ID: 7241E3D2B3A2637B
2 changed files with 5 additions and 4 deletions

View File

@ -65,8 +65,7 @@ private:
virtual void initialize_core() override;
virtual void initialize() override;
virtual void initialize_joypads() override {
}
virtual void initialize_joypads() override;
virtual void set_main_loop(MainLoop *p_main_loop) override;
virtual MainLoop *get_main_loop() const override;

View File

@ -126,11 +126,13 @@ void OS_IOS::initialize() {
initialize_core();
}
void OS_IOS::initialize_joypads() {
joypad_apple = memnew(JoypadApple);
}
void OS_IOS::initialize_modules() {
ios = memnew(iOS);
Engine::get_singleton()->add_singleton(Engine::Singleton("iOS", ios));
joypad_apple = memnew(JoypadApple);
}
void OS_IOS::deinitialize_modules() {