Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS] Fix wrong object type in joypad queue. #95425

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Aug 12, 2024

joypadsQueue expected to have GCController * when it's read, but Joypad * was pushed to it.

Should fix #95365

I can't reproduce the issue in normal conditions, but can reproduce it by delaying start_processing.

@akien-mga akien-mga added this to the 4.3 milestone Aug 12, 2024
@@ -228,7 +228,7 @@ @interface JoypadMacOSObserver ()
@property(assign, nonatomic) BOOL isObserving;
@property(assign, nonatomic) BOOL isProcessing;
@property(strong, nonatomic) NSMutableDictionary<NSNumber *, Joypad *> *connectedJoypads;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this one? I'm not familiar with that code but I see it used as GCController too:

217:                    GCController *controller = [self.connectedJoypads objectForKey:key];

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in iOS code, it's a bit different and always using GCController *.

@@ -228,7 +228,7 @@ @interface JoypadMacOSObserver ()
@property(assign, nonatomic) BOOL isObserving;
@property(assign, nonatomic) BOOL isProcessing;
@property(strong, nonatomic) NSMutableDictionary<NSNumber *, Joypad *> *connectedJoypads;
@property(strong, nonatomic) NSMutableArray<Joypad *> *joypadsQueue;
@property(strong, nonatomic) NSMutableArray<GCController *> *joypadsQueue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record, the joypad_ios.mm implementation seems similar but doesn't specify the types for the NSMutableArray and NSMutableDictionary used here. Should that be harmonized?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of iOS it should be:

@property(strong, nonatomic) NSMutableDictionary<NSNumber *, GCController *> *connectedJoypads;
@property(strong, nonatomic) NSMutableArray<GCController *> *joypadsQueue;

Probably worth merging both int a single file, it's using the same API and code should be almost same.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I'd guess that should be for a follow-up 4.4 PR, as I'm evaluating whether this one should be merged for 4.3.

@akien-mga akien-mga merged commit edc0571 into godotengine:master Aug 12, 2024
18 checks passed
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

NSException: Joypad playerIndex
2 participants