projects
/
enjoyable.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Less crap in the dock menu.
[enjoyable.git]
/
NJOutputMouseScroll.m
diff --git
a/NJOutputMouseScroll.m
b/NJOutputMouseScroll.m
index
9057125
..
7bbf4f8
100644
(file)
--- a/
NJOutputMouseScroll.m
+++ b/
NJOutputMouseScroll.m
@@
-7,51
+7,47
@@
#import "NJOutputMouseScroll.h"
#import "NJOutputMouseScroll.h"
-@implementation NJOutputMouseScroll {
- int sign;
-}
+@implementation NJOutputMouseScroll
+ (NSString *)serializationCode {
return @"mouse scroll";
}
- (NSDictionary *)serialize {
+ (NSString *)serializationCode {
return @"mouse scroll";
}
- (NSDictionary *)serialize {
- return @{ @"type": @"mouse scroll", @"amount": @(_amount) };
+ return @{ @"type": self.class.serializationCode,
+ @"direction": @(_direction),
+ @"speed": @(_speed)
+ };
}
+ (NJOutput *)outputDeserialize:(NSDictionary *)serialization
withMappings:(NSArray *)mappings {
NJOutputMouseScroll *output = [[NJOutputMouseScroll alloc] init];
}
+ (NJOutput *)outputDeserialize:(NSDictionary *)serialization
withMappings:(NSArray *)mappings {
NJOutputMouseScroll *output = [[NJOutputMouseScroll alloc] init];
- output.amount = [serialization[@"amount"] intValue];
+ output.direction = [serialization[@"direction"] intValue];
+ output.speed = [serialization[@"direction"] floatValue];
return output;
}
return output;
}
+- (BOOL)isContinuous {
+ return !!self.speed;
+}
+
- (void)trigger {
- (void)trigger {
- if (!self.
magnitude
) {
+ if (!self.
speed
) {
CGEventRef scroll = CGEventCreateScrollWheelEvent(NULL,
kCGScrollEventUnitLine,
1,
CGEventRef scroll = CGEventCreateScrollWheelEvent(NULL,
kCGScrollEventUnitLine,
1,
- _
amount
);
+ _
direction
);
CGEventPost(kCGHIDEventTap, scroll);
CFRelease(scroll);
}
}
CGEventPost(kCGHIDEventTap, scroll);
CFRelease(scroll);
}
}
-- (BOOL)update:(NJInputController *)jc {
- if (fabsf(self.magnitude) < 0.01f) {
- sign = 0;
+- (BOOL)update:(NJDeviceController *)jc {
+ if (self.magnitude < 0.05f)
return NO; // dead zone
return NO; // dead zone
- }
- // If the input crossed over High/Low, this output is done.
- if (!sign)
- sign = self.magnitude < 0 ? -1 : 1;
- else if (sign / self.magnitude < 0) {
- sign = 0;
- return NO;
- }
-
- int amount = (int)(16.f * fabsf(self.magnitude) * _amount);
+ int amount = (int)(_speed * self.magnitude * _direction);
CGEventRef scroll = CGEventCreateScrollWheelEvent(NULL,
kCGScrollEventUnitPixel,
1,
CGEventRef scroll = CGEventCreateScrollWheelEvent(NULL,
kCGScrollEventUnitPixel,
1,
@@
-62,8
+58,4
@@
return YES;
}
return YES;
}
-- (BOOL)isContinuous {
- return YES;
-}
-
@end
@end