Skip to content

Commit 38b4a39

Browse files
committed
Remove KVO observers for the PrefPane buttons:
They were causing too many issues.
1 parent 7876532 commit 38b4a39

13 files changed

+144
-234
lines changed

360 Driver.xcodeproj/project.pbxproj

+2-4
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,13 @@
205205
/* End PBXCopyFilesBuildPhase section */
206206

207207
/* Begin PBXFileReference section */
208+
551B911F1A68BDB000EA6527 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/Pref360ControlPref.xib; sourceTree = "<group>"; };
208209
551CDFFD196EF52F000869B6 /* Pref360Control_Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Pref360Control_Prefix.pch; sourceTree = "<group>"; };
209210
551CDFFF196EFD34000869B6 /* Install360Controller.pkgproj */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Install360Controller.pkgproj; sourceTree = "<group>"; };
210211
551CE001196EFD34000869B6 /* finish.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = finish.sh; sourceTree = "<group>"; };
211212
551CE002196EFD34000869B6 /* upgrade.sh */ = {isa = PBXFileReference; indentWidth = 3; lastKnownFileType = text.script.sh; path = upgrade.sh; sourceTree = "<group>"; };
212213
551CE004196EFD34000869B6 /* Welcome.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = Welcome.rtf; sourceTree = "<group>"; };
213214
553BDB43196DF3BA00D1F569 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
214-
554B55691971CFBE00D762BF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/Pref360ControlPref.xib; sourceTree = "<group>"; };
215-
554B556B1971CFE300D762BF /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Pref360ControlPref.strings; sourceTree = "<group>"; };
216215
55699CD51971D96E00C40A31 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
217216
55750C07190AFB5B0047FF41 /* DaemonLEDs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DaemonLEDs.h; sourceTree = "<group>"; usesTabs = 1; };
218217
55750C08190AFB5B0047FF41 /* DaemonLEDs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DaemonLEDs.m; sourceTree = "<group>"; usesTabs = 1; };
@@ -1100,8 +1099,7 @@
11001099
551CDFFB196EEE76000869B6 /* Pref360ControlPref.xib */ = {
11011100
isa = PBXVariantGroup;
11021101
children = (
1103-
554B55691971CFBE00D762BF /* Base */,
1104-
554B556B1971CFE300D762BF /* en */,
1102+
551B911F1A68BDB000EA6527 /* en */,
11051103
);
11061104
name = Pref360ControlPref.xib;
11071105
sourceTree = "<group>";

Pref360Control/MyAnalogStick.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
#import <Cocoa/Cocoa.h>
2424

2525
@interface MyAnalogStick : NSView
26-
@property int deadzone;
27-
@property int positionX;
28-
@property int positionY;
29-
@property BOOL pressed;
30-
@property BOOL linked;
26+
@property (nonatomic) int deadzone;
27+
@property (nonatomic) int positionX;
28+
@property (nonatomic) int positionY;
29+
@property (nonatomic) BOOL pressed;
30+
@property (nonatomic) BOOL linked;
3131

3232
- (void)setPositionX:(int)xPos y:(int)yPos;
3333

Pref360Control/MyAnalogStick.m

+21-19
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,34 @@ @implementation MyAnalogStick
3232
@synthesize positionY = y;
3333
@synthesize linked;
3434

35-
- (id)initWithFrame:(NSRect)frameRect
35+
- (void)setPressed:(BOOL)apressed
3636
{
37-
if (self = [super initWithFrame:frameRect]) {
38-
[self addObserver:self forKeyPath:@"deadzone" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
39-
[self addObserver:self forKeyPath:@"positionX" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
40-
[self addObserver:self forKeyPath:@"positionY" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
41-
[self addObserver:self forKeyPath:@"pressed" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
42-
[self addObserver:self forKeyPath:@"linked" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
43-
}
44-
return self;
37+
pressed = apressed;
38+
self.needsDisplay = YES;
4539
}
4640

47-
- (void)dealloc
41+
- (void)setDeadzone:(int)adeadzone
4842
{
49-
[self removeObserver:self forKeyPath:@"pressed"];
50-
[self removeObserver:self forKeyPath:@"positionX"];
51-
[self removeObserver:self forKeyPath:@"positiony"];
52-
[self removeObserver:self forKeyPath:@"deadzone"];
53-
[self removeObserver:self forKeyPath:@"linked"];
43+
deadzone = adeadzone;
44+
self.needsDisplay = YES;
5445
}
5546

56-
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
47+
- (void)setPositionX:(int)positionX
5748
{
58-
if (object == self) {
59-
[self setNeedsDisplay:YES];
60-
}
49+
x = positionX;
50+
self.needsDisplay = YES;
51+
}
52+
53+
- (void)setPositionY:(int)positionY
54+
{
55+
y = positionY;
56+
self.needsDisplay = YES;
57+
}
58+
59+
- (void)setLinked:(BOOL)alinked
60+
{
61+
linked = alinked;
62+
self.needsDisplay = YES;
6163
}
6264

6365
- (void)drawRect:(NSRect)rect

Pref360Control/MyCentreButtons.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#import <Cocoa/Cocoa.h>
2424

2525
@interface MyCentreButtons : NSView
26-
@property BOOL back;
27-
@property BOOL start;
28-
@property BOOL specific;
26+
@property (nonatomic) BOOL back;
27+
@property (nonatomic) BOOL start;
28+
@property (nonatomic) BOOL specific;
2929
@end

Pref360Control/MyCentreButtons.m

+9-15
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,22 @@ @implementation MyCentreButtons
2828
@synthesize start;
2929
@synthesize specific = appSpecific;
3030

31-
- (id)initWithFrame:(NSRect)frameRect
31+
- (void)setBack:(BOOL)aback
3232
{
33-
if ((self = [super initWithFrame:frameRect]) != nil) {
34-
[self addObserver:self forKeyPath:@"back" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
35-
[self addObserver:self forKeyPath:@"start" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
36-
[self addObserver:self forKeyPath:@"specific" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
37-
}
38-
return self;
33+
back = aback;
34+
self.needsDisplay = YES;
3935
}
4036

41-
- (void)dealloc
37+
- (void)setStart:(BOOL)astart
4238
{
43-
[self removeObserver:self forKeyPath:@"back"];
44-
[self removeObserver:self forKeyPath:@"start"];
45-
[self removeObserver:self forKeyPath:@"specific"];
39+
start = astart;
40+
self.needsDisplay = YES;
4641
}
4742

48-
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
43+
- (void)setSpecific:(BOOL)specific
4944
{
50-
if (object == self) {
51-
[self setNeedsDisplay:YES];
52-
}
45+
appSpecific = specific;
46+
self.needsDisplay = YES;
5347
}
5448

5549
+ (void)drawButton:(NSString*)button inRectangle:(NSRect)rect pressed:(BOOL)down

Pref360Control/MyDigitalStick.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#import <Cocoa/Cocoa.h>
2424

2525
@interface MyDigitalStick : NSView
26-
@property BOOL up;
27-
@property BOOL down;
28-
@property BOOL left;
29-
@property BOOL right;
26+
@property (nonatomic) BOOL up;
27+
@property (nonatomic) BOOL down;
28+
@property (nonatomic) BOOL left;
29+
@property (nonatomic) BOOL right;
3030
@end

Pref360Control/MyDigitalStick.m

+24-20
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,30 @@ @implementation MyDigitalStick
3434
@synthesize left = bLeft;
3535
@synthesize right = bRight;
3636

37+
- (void)setUp:(BOOL)anup
38+
{
39+
bUp = anup;
40+
self.needsDisplay = YES;
41+
}
42+
43+
- (void)setDown:(BOOL)adown
44+
{
45+
bDown = adown;
46+
self.needsDisplay = YES;
47+
}
48+
49+
- (void)setLeft:(BOOL)aleft
50+
{
51+
bLeft = aleft;
52+
self.needsDisplay = YES;
53+
}
54+
55+
- (void)setRight:(BOOL)aright
56+
{
57+
bRight = aright;
58+
self.needsDisplay = YES;
59+
}
60+
3761
+ (NSBezierPath*)makeTriangle:(int)start inRectangle:(NSRect)rect;
3862
{
3963
// Create path
@@ -68,11 +92,6 @@ - (id)initWithFrame:(NSRect)frameRect
6892
if ((self = [super initWithFrame:frameRect]) != nil) {
6993
NSRect rect = [self bounds], triangle;
7094

71-
[self addObserver:self forKeyPath:@"up" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
72-
[self addObserver:self forKeyPath:@"down" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
73-
[self addObserver:self forKeyPath:@"left" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
74-
[self addObserver:self forKeyPath:@"right" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
75-
7695
triangle.origin.x = INSET_AMOUNT;
7796
triangle.origin.y = INSET_AMOUNT;
7897
triangle.size.width =- INSET_AMOUNT * 2;
@@ -93,21 +112,6 @@ - (id)initWithFrame:(NSRect)frameRect
93112
return self;
94113
}
95114

96-
- (void)dealloc
97-
{
98-
[self removeObserver:self forKeyPath:@"up"];
99-
[self removeObserver:self forKeyPath:@"down"];
100-
[self removeObserver:self forKeyPath:@"left"];
101-
[self removeObserver:self forKeyPath:@"right"];
102-
}
103-
104-
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
105-
{
106-
if (object == self) {
107-
[self setNeedsDisplay:YES];
108-
}
109-
}
110-
111115
- (void)drawRect:(NSRect)rect
112116
{
113117
NSRect area = [self bounds];

Pref360Control/MyMainButtons.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#import <Cocoa/Cocoa.h>
2424

2525
@interface MyMainButtons : NSView
26-
@property BOOL a;
27-
@property BOOL b;
28-
@property BOOL x;
29-
@property BOOL y;
26+
@property (nonatomic) BOOL a;
27+
@property (nonatomic) BOOL b;
28+
@property (nonatomic) BOOL x;
29+
@property (nonatomic) BOOL y;
3030
@end

Pref360Control/MyMainButtons.m

+19-18
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,33 @@
2525
#define MINI_OFFSET 2
2626

2727
@implementation MyMainButtons
28-
@synthesize a, b, x, y;
28+
@synthesize a;
29+
@synthesize b;
30+
@synthesize x;
31+
@synthesize y;
2932

30-
- (id)initWithFrame:(NSRect)frameRect
33+
- (void)setA:(BOOL)aa
3134
{
32-
if (self = [super initWithFrame:frameRect]) {
33-
[self addObserver:self forKeyPath:@"a" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
34-
[self addObserver:self forKeyPath:@"b" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
35-
[self addObserver:self forKeyPath:@"x" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
36-
[self addObserver:self forKeyPath:@"y" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
37-
}
38-
return self;
35+
a = aa;
36+
self.needsDisplay = YES;
3937
}
4038

41-
- (void)dealloc
39+
- (void)setB:(BOOL)aa
4240
{
43-
[self removeObserver:self forKeyPath:@"a"];
44-
[self removeObserver:self forKeyPath:@"b"];
45-
[self removeObserver:self forKeyPath:@"x"];
46-
[self removeObserver:self forKeyPath:@"y"];
41+
b = aa;
42+
self.needsDisplay = YES;
4743
}
4844

49-
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
45+
- (void)setX:(BOOL)aa
5046
{
51-
if (object == self) {
52-
[self setNeedsDisplay:YES];
53-
}
47+
x = aa;
48+
self.needsDisplay = YES;
49+
}
50+
51+
- (void)setY:(BOOL)aa
52+
{
53+
y = aa;
54+
self.needsDisplay = YES;
5455
}
5556

5657
+ (void)drawButton:(NSString*)button inRectangle:(NSRect)rect pressed:(BOOL)down

Pref360Control/MyShoulderButton.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323
#import <Cocoa/Cocoa.h>
2424

2525
@interface MyShoulderButton : NSView
26-
@property (getter = isPressed) BOOL pressed;
26+
@property (nonatomic, getter = isPressed) BOOL pressed;
2727
@end

Pref360Control/MyShoulderButton.m

+3-17
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,10 @@
2727
@implementation MyShoulderButton
2828
@synthesize pressed;
2929

30-
- (id)initWithFrame:(NSRect)frameRect
30+
- (void)setPressed:(BOOL)apressed
3131
{
32-
if (self = [super initWithFrame:frameRect]) {
33-
[self addObserver:self forKeyPath:@"pressed" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:NULL];
34-
}
35-
return self;
36-
}
37-
38-
- (void)dealloc
39-
{
40-
[self removeObserver:self forKeyPath:@"pressed"];
41-
}
42-
43-
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
44-
{
45-
if (object == self) {
46-
[self setNeedsDisplay:YES];
47-
}
32+
pressed = apressed;
33+
self.needsDisplay = YES;
4834
}
4935

5036
- (void)drawRect:(NSRect)rect

Pref360Control/en.lproj/Pref360ControlPref.strings

-75
This file was deleted.

0 commit comments

Comments
 (0)