Skip to content

Commit 7c8ff05

Browse files
fix(ds): address Copilot review — guard stylus press notification spam
- Add `ndsTouchActive` ivar to melonDS and DeSmuME 2015 bridge headers - Guard `setLeftMouseButtonPressed:YES` so it fires only on touch-down, not on every move update (avoids spamming PVMouseButtonDidPress) - Remove duplicate `@import PVCoreBridge` in PVMelonDSCore+Controls.mm Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 4c359b1 commit 7c8ff05

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

Cores/Desmume2015/PVDesmume2015Core/Core/PVDesmume2015Core+Controls.mm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,15 @@ - (void)touchScreenAtPoint:(CGPoint)point {
292292
CGFloat normalizedX = point.x / 256.0;
293293
CGFloat normalizedY = point.y / 192.0;
294294
[self setMousePosition:CGPointMake(normalizedX, normalizedY)];
295-
[self setLeftMouseButtonPressed:YES];
295+
// Only transition to pressed on touch-down; avoid re-sending press notifications on move updates.
296+
if (!ndsTouchActive) {
297+
ndsTouchActive = YES;
298+
[self setLeftMouseButtonPressed:YES];
299+
}
296300
}
297301

298302
- (void)releaseScreenTouch {
303+
ndsTouchActive = NO;
299304
[self setLeftMouseButtonPressed:NO];
300305
}
301306

Cores/Desmume2015/PVDesmume2015Core/Core/PVDesmume2015Core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ __attribute__((visibility("default")))
2424
uint8_t padData[4][14]; //[PVDSButton.count];
2525
@public
2626
dispatch_queue_t _callbackQueue;
27+
BOOL ndsTouchActive; // tracks whether stylus is currently down to avoid spamming PVMouseButtonDidPress
2728
}
2829

2930
@end

Cores/melonDS/PVMelonDSCore/Core/PVMelonDSCore+Controls.mm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#import <PVMelonDS/PVMelonDS.h>
1010
#import <Foundation/Foundation.h>
1111
@import PVCoreBridge;
12-
@import PVCoreBridge;
1312

1413
#define DC_BTN_C (1<<0)
1514
#define DC_BTN_B (1<<1)
@@ -292,10 +291,15 @@ - (void)touchScreenAtPoint:(CGPoint)point {
292291
CGFloat normalizedX = point.x / 256.0;
293292
CGFloat normalizedY = point.y / 192.0;
294293
[self setMousePosition:CGPointMake(normalizedX, normalizedY)];
295-
[self setLeftMouseButtonPressed:YES];
294+
// Only transition to pressed on touch-down; avoid re-sending press notifications on move updates.
295+
if (!ndsTouchActive) {
296+
ndsTouchActive = YES;
297+
[self setLeftMouseButtonPressed:YES];
298+
}
296299
}
297300

298301
- (void)releaseScreenTouch {
302+
ndsTouchActive = NO;
299303
[self setLeftMouseButtonPressed:NO];
300304
}
301305

Cores/melonDS/PVMelonDSCore/Core/PVMelonDSCore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ __attribute__((visibility("default")))
2525
#pragma clang diagnostic pop
2626
@public
2727
dispatch_queue_t _callbackQueue;
28+
BOOL ndsTouchActive; // tracks whether stylus is currently down to avoid spamming PVMouseButtonDidPress
2829
}
2930

3031
@end

0 commit comments

Comments
 (0)