projects
/
enjoyable.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix for dropping input events in OS X 10.10.
[enjoyable.git]
/
Classes
/
NJOutputMouseScroll.m
diff --git
a/Classes/NJOutputMouseScroll.m
b/Classes/NJOutputMouseScroll.m
index
99cec4a
..
1ae08cc
100644
(file)
--- a/
Classes/NJOutputMouseScroll.m
+++ b/
Classes/NJOutputMouseScroll.m
@@
-16,42
+16,51
@@
- (NSDictionary *)serialize {
return @{ @"type": self.class.serializationCode,
@"direction": @(_direction),
- (NSDictionary *)serialize {
return @{ @"type": self.class.serializationCode,
@"direction": @(_direction),
- @"speed": @(_speed)
+ @"speed": @(_speed),
+ @"smooth": @(_smooth),
};
}
};
}
-+ (NJOutput *)outputDeserialize:(NSDictionary *)serialization
- withMappings:(NSArray *)mappings {
++ (NJOutput *)outputWithSerialization:(NSDictionary *)serialization {
NJOutputMouseScroll *output = [[NJOutputMouseScroll alloc] init];
output.direction = [serialization[@"direction"] intValue];
output.speed = [serialization[@"speed"] floatValue];
NJOutputMouseScroll *output = [[NJOutputMouseScroll alloc] init];
output.direction = [serialization[@"direction"] intValue];
output.speed = [serialization[@"speed"] floatValue];
+ output.smooth = [serialization[@"smooth"] boolValue];
return output;
}
- (BOOL)isContinuous {
return output;
}
- (BOOL)isContinuous {
- return !!self.speed;
+ return _smooth;
+}
+
+- (int)wheel:(int)n {
+ int amount = abs(_direction) == n ? _direction / n : 0;
+ if (self.smooth)
+ amount *= _speed * self.magnitude;
+ return amount;
}
- (void)trigger {
}
- (void)trigger {
- if (!
self.speed
) {
+ if (!
_smooth
) {
CGEventRef scroll = CGEventCreateScrollWheelEvent(NULL,
kCGScrollEventUnitLine,
CGEventRef scroll = CGEventCreateScrollWheelEvent(NULL,
kCGScrollEventUnitLine,
- 1,
- _direction);
+ 2,
+ [self wheel:1],
+ [self wheel:2]);
CGEventPost(kCGHIDEventTap, scroll);
CFRelease(scroll);
}
}
CGEventPost(kCGHIDEventTap, scroll);
CFRelease(scroll);
}
}
-- (BOOL)update:(NJ
DeviceController *)j
c {
+- (BOOL)update:(NJ
InputController *)i
c {
if (self.magnitude < 0.05f)
return NO; // dead zone
if (self.magnitude < 0.05f)
return NO; // dead zone
- int amount = (int)(_speed * self.magnitude * _direction);
CGEventRef scroll = CGEventCreateScrollWheelEvent(NULL,
kCGScrollEventUnitPixel,
CGEventRef scroll = CGEventCreateScrollWheelEvent(NULL,
kCGScrollEventUnitPixel,
- 1,
- amount);
+ 2,
+ [self wheel:1],
+ [self wheel:2]);
CGEventPost(kCGHIDEventTap, scroll);
CFRelease(scroll);
CGEventPost(kCGHIDEventTap, scroll);
CFRelease(scroll);