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

Initial support for Jot Touch 4 Stylus #12

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 30 additions & 2 deletions Brushes.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@
C01FCF5008A9545400542493 /* WDUpdateLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = C01FCF5008A9545400542492 /* WDUpdateLayer.m */; };
C01FCF5008A9545400542499 /* WDDocumentChange.m in Sources */ = {isa = PBXBuildFile; fileRef = C01FCF5008A9545400542498 /* WDDocumentChange.m */; };
C01FCF5008A95454005424A5 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C01FCF5008A95454005424A4 /* Accelerate.framework */; };
E7F79FE91890395100999BE2 /* JotTouchSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7F79FE81890395100999BE2 /* JotTouchSDK.framework */; };
E7F79FEB1890395F00999BE2 /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7F79FEA1890395F00999BE2 /* CoreMotion.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -985,13 +987,18 @@
C01FCF5008A9545400542492 /* WDUpdateLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WDUpdateLayer.m; sourceTree = "<group>"; };
C01FCF5008A9545400542498 /* WDDocumentChange.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WDDocumentChange.m; sourceTree = "<group>"; };
C01FCF5008A95454005424A4 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; };
E7F79FE81890395100999BE2 /* JotTouchSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JotTouchSDK.framework; sourceTree = "<group>"; };
E7F79FEA1890395F00999BE2 /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
1D60588F0D05DD3D006BFB54 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
E7F79FEB1890395F00999BE2 /* CoreMotion.framework in Frameworks */,
6BDB83D01593D2920037E10B /* CoreBluetooth.framework in Frameworks */,
E7F79FE91890395100999BE2 /* JotTouchSDK.framework in Frameworks */,
29E41AC213F9B229000C3305 /* libz.dylib in Frameworks */,
29FF9389145223600000B6BB /* AudioToolbox.framework in Frameworks */,
6BD7072012AD011F004E07C9 /* CoreGraphics.framework in Frameworks */,
Expand All @@ -1009,7 +1016,6 @@
6B6240511561B941003EB9B3 /* DropboxSDK.framework in Frameworks */,
6BDB83CA1593CDC10037E10B /* libT1PogoManager.a in Frameworks */,
6BDB83CE1593D2710037E10B /* AVFoundation.framework in Frameworks */,
6BDB83D01593D2920037E10B /* CoreBluetooth.framework in Frameworks */,
6B29083616013C2400593812 /* Social.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -1084,6 +1090,8 @@
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
isa = PBXGroup;
children = (
E7F79FEA1890395F00999BE2 /* CoreMotion.framework */,
E7F79FE81890395100999BE2 /* JotTouchSDK.framework */,
29E41AC113F9B229000C3305 /* libz.dylib */,
6BDB83C11593CDC10037E10B /* T1PogoManager */,
C01FCF5008A95454005424A4 /* Accelerate.framework */,
Expand Down Expand Up @@ -1893,7 +1901,7 @@
ORGANIZATIONNAME = "Taptrix, Inc.";
TargetAttributes = {
1D6058900D05DD3D006BFB54 = {
DevelopmentTeam = CQ46W8F62S;
DevelopmentTeam = U23H35XF22;
SystemCapabilities = {
com.apple.GameCenter = {
enabled = 0;
Expand Down Expand Up @@ -2384,6 +2392,7 @@
"$(inherited)",
"$(SRCROOT)",
/Users/sprang/Development/Brushes,
/Users/alan/dev/Brushes,
);
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
Expand All @@ -2397,6 +2406,10 @@
"$(inherited)",
"\"$(SRCROOT)/T1PogoManager\"",
);
OTHER_LDFLAGS = (
"-lxml2",
"-ObjC",
);
PRODUCT_NAME = Brushes;
PROVISIONING_PROFILE = "";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
Expand All @@ -2418,6 +2431,7 @@
"$(inherited)",
"$(SRCROOT)",
/Users/sprang/Development/Brushes,
/Users/alan/dev/Brushes,
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Brushes_Prefix.pch;
Expand All @@ -2429,6 +2443,10 @@
"$(inherited)",
"\"$(SRCROOT)/T1PogoManager\"",
);
OTHER_LDFLAGS = (
"-lxml2",
"-ObjC",
);
PRODUCT_NAME = Brushes;
PROVISIONING_PROFILE = "";
SDKROOT = iphoneos;
Expand Down Expand Up @@ -2471,6 +2489,7 @@
"$(inherited)",
"$(SRCROOT)",
/Users/sprang/Development/Brushes,
/Users/alan/dev/Brushes,
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Brushes_Prefix.pch;
Expand All @@ -2482,6 +2501,10 @@
"$(inherited)",
"\"$(SRCROOT)/T1PogoManager\"",
);
OTHER_LDFLAGS = (
"-lxml2",
"-ObjC",
);
PRODUCT_NAME = Brushes;
PROVISIONING_PROFILE = "";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
Expand Down Expand Up @@ -2528,6 +2551,7 @@
"$(inherited)",
"$(SRCROOT)",
/Users/sprang/Development/Brushes,
/Users/alan/dev/Brushes,
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Brushes_Prefix.pch;
Expand All @@ -2540,6 +2564,10 @@
"$(inherited)",
"\"$(SRCROOT)/T1PogoManager\"",
);
OTHER_LDFLAGS = (
"-lxml2",
"-ObjC",
);
PRODUCT_NAME = Brushes;
PROVISIONING_PROFILE = "";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
Expand Down
2 changes: 1 addition & 1 deletion Classes/WDAddPath.m
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ - (void) endAnimation:(WDPainting *)painting
WDLayer *layer = [painting layerWithUUID:self.layerUUID];
[layer commitStroke:pathBounds_ color:path.color erase:erase undoable:undoable_];
} else if ([path.nodes count] > 0) {
WDLog(@"Empty path bounds with path of length %d", [path.nodes count]);
WDLog(@"Empty path bounds with path of length %lu", (unsigned long)[path.nodes count]);
}
painting.activePath = nil;
}
Expand Down
5 changes: 5 additions & 0 deletions Classes/WDStylusManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@
// Pogo Connect (Blue Tiger)
#import "T1PogoManager.h"

// Jot Touch 4
#import <JotTouchSDK/JotStylusManager.h>

typedef enum {
WDNoStylus = 0,
WDPogoConnectStylus,
WDJotTouchStylus,
WDMaxStylusTypes
} WDStylusType;

Expand All @@ -35,6 +39,7 @@ typedef enum {
@interface WDStylusManager : NSObject <CBCentralManagerDelegate>

@property (nonatomic) T1PogoManager *pogoManager;
@property (nonatomic) JotStylusManager *jotManager;
@property (nonatomic, readonly) NSUInteger numberOfStylusTypes;
@property (nonatomic) WDStylusType mode;
@property (nonatomic) WDBlueToothState blueToothState;
Expand Down
78 changes: 75 additions & 3 deletions Classes/WDStylusManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ @interface WDStylusManager ()
@implementation WDStylusManager

@synthesize pogoManager;
@synthesize jotManager;
@synthesize newlyDiscoveredPen;
@synthesize centralBlueToothManager;
@synthesize blueToothState;
Expand Down Expand Up @@ -128,6 +129,10 @@ - (WDStylusData *) dataForStylusType:(WDStylusType)type atIndex:(NSUInteger)inde
data.connected = pen.isConnected;
data.pogoPen = pen;
}
} else if (type == WDJotTouchStylus) {
data.productName = NSLocalizedString(@"Jot Touch", @"Jot Touch");
data.connected = (jotManager.connectionStatus == JotConnectionStatusConnected);
data.batteryLevel = @(jotManager.batteryLevel / 100.0f);
}

return data;
Expand All @@ -146,6 +151,12 @@ - (float) pressureForTouch:(UITouch *)touch realPressue:(BOOL *)isRealPressure
if ((mode == WDPogoConnectStylus) && [pogoManager oneOrMorePensAreConnected]) {
isReal = YES;
pressure = [pogoManager pressureForTouch:touch];
} else if ((mode == WDJotTouchStylus) && ([jotManager connectionStatus] == JotConnectionStatusConnected)) {
isReal = YES;
NSLog(@"Pressure: %lu", (unsigned long)[jotManager getPressure]);
pressure = [jotManager getPressure] / 2047.0f;


} else if (mode != WDNoStylus) {
isReal = YES;
// since we're in stylus mode, but no styli are active, use 1.0 pressure
Expand Down Expand Up @@ -194,6 +205,52 @@ - (void) didDisconnectStylus:(NSString *)stylus
[self postNotificationOnMainQueue:WDStylusDidDisconnectNotification userInfo:userInfo];
}

#pragma mark -- Jot Touch
- (void)jotConnectionChange:(NSNotification *) note
{
switch([[JotStylusManager sharedInstance] connectionStatus])
{
case JotConnectionStatusOff:
break;
case JotConnectionStatusScanning:
break;
case JotConnectionStatusPairing:
break;
case JotConnectionStatusConnected:
[self didConnectStylus:NSLocalizedString(@"Jot Touch", @"Jot Touch")];
break;
case JotConnectionStatusDisconnected:
[self didDisconnectStylus:NSLocalizedString(@"Jot Touch", @"Jot Touch")];
break;
default:
break;
}
}

-(void)jotStylusTouchBegan:(NSSet*)jotTouches{
// a Jot stylus has begun to draw on the screen
}
-(void)jotStylusTouchMoved:(NSSet*)jotTouches{
// a Jot stylus is moving on the screen
}
-(void)jotStylusTouchEnded:(NSSet*)jotTouches{
// a Jot stylus has ended normally on the screen
}
-(void)jotStylusTouchCancelled:(NSSet*)jotTouches{
// a stylus event has been cancelled on the screen
}
-(void)jotSuggestsToDisableGestures{
// the Jot Touch SDK has determined that the user’s palm is likely
// resting on the screen or the user is actively drawing with the
// Jot stylus, and we recommend to disable any other gestures
// that might be attached to that UIView, such as a pinch-to-zoom
// gesture
}
-(void)jotSuggestsToEnableGestures{
// The user’s palm has lifted and drawing has stopped, so it is
// safe to re-enable any other gestures on the UIView
}

#pragma mark -- Pogo Connect

- (NSString *) defaultPogoConnectName
Expand Down Expand Up @@ -255,9 +312,24 @@ - (void) setBlueToothState:(WDBlueToothState)inBlueToothState

blueToothState = inBlueToothState;

if (blueToothState == WDBlueToothLowEnergy && !pogoManager) {
pogoManager = [T1PogoManager pogoManagerWithDelegate:self];
pogoManager.enablePenInputOverNetworkIfIncompatiblePad = YES;
if (blueToothState == WDBlueToothLowEnergy) {
if (!pogoManager) {
pogoManager = [T1PogoManager pogoManagerWithDelegate:self];
pogoManager.enablePenInputOverNetworkIfIncompatiblePad = YES;
}

if (!jotManager) {
jotManager = [JotStylusManager sharedInstance];

[[NSNotificationCenter defaultCenter] addObserver: self
selector:@selector(jotConnectionChange:)
name: JotStylusManagerDidChangeConnectionStatus
object:nil];
jotManager.rejectMode = NO;
jotManager.enabled = YES;


}
}

[[NSNotificationCenter defaultCenter] postNotificationName:WDBlueToothStateChangedNotification object:self];
Expand Down
1 change: 1 addition & 0 deletions JotTouchSDK.framework/Headers
1 change: 1 addition & 0 deletions JotTouchSDK.framework/JotTouchSDK
1 change: 1 addition & 0 deletions JotTouchSDK.framework/Resources
85 changes: 85 additions & 0 deletions JotTouchSDK.framework/Versions/A/Headers/JotConstants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//
// JotConstants.h
// JotTouchSDK
//
// Created on 6/27/13.
// Copyright (c) 2013 Adonit. All rights reserved.
//

#import <Foundation/Foundation.h>

#define JOT_MIN_PRESSURE 0
#define JOT_MAX_PRESSURE 2047

#define DistanceOfTransmitterFromTipInInches 0.2893168033

#define JotStylusManagerDidChangeConnectionStatus @"jotStylusManagerDidChangeConnectionStatus"
#define JotStylusManagerDidPairWithStylus @"jotStylusManagerDidPairWithStylus"
#define JotStylusManagerDidChangeBatteryLevel @"jotStylusManagerDidChangeBatteryLevel"

#define JotStylusButton1Down @"jotStylusButton1Down"
#define JotStylusButton1Up @"jotStylusButton1Up"
#define JotStylusButton2Down @"jotStylusButton2Down"
#define JotStylusButton2Up @"jotStylusButton2Up"

#define JOT_STYLUS_RIGHTHANDED_REJECTION_ANGLE 45
#define JOT_STYLUS_LEFTHANDED_REJECTION_ANGLE 135

#define JOT_STYLUS_RIGHTHANDED_REJECTION_ANGLE_JotWritingStyleRightUp 45
#define JOT_STYLUS_RIGHTHANDED_REJECTION_ANGLE_JotWritingStyleRightMiddle 0
#define JOT_STYLUS_RIGHTHANDED_REJECTION_ANGLE_JotWritingStyleRightDown -45
#define JOT_STYLUS_RIGHTHANDED_REJECTION_ANGLE_JotWritingStyleLeftUp 225
#define JOT_STYLUS_RIGHTHANDED_REJECTION_ANGLE_JotWritingStyleLeftMiddle 180
#define JOT_STYLUS_RIGHTHANDED_REJECTION_ANGLE_JotWritingStyleLeftDown 135


typedef NS_ENUM(NSUInteger, JotModel) {
JotModelUndefined = 0,
JotModelJT2 = 1,
JotModelJT4 = 2,
JotModelJS = 3,
JotModelJTPP = 4,
JotModelMighty = 5,
};

typedef NS_ENUM(NSUInteger, JotStylusTipStatus) {
JotStylusTipStatusOffScreen = 0,
JotStylusTipStatusOnScreen = 1

};

typedef NS_ENUM(NSUInteger, JotPalmRejectionOrientation) {
JotPalmRejectionLeftHanded,
JotPalmRejectionRightHanded
};

typedef NS_ENUM(NSUInteger, JotWritingStyle) {
JotWritingStyleRightUp,
JotWritingStyleRightMiddle,
JotWritingStyleRightDown,
JotWritingStyleLeftUp,
JotWritingStyleLeftMiddle,
JotWritingStyleLeftDown,
};

typedef NS_ENUM(NSUInteger, JotConnectionStatus) {
JotConnectionStatusOff,
JotConnectionStatusScanning,
JotConnectionStatusPairing,
JotConnectionStatusConnected,
JotConnectionStatusDisconnected
};

typedef NS_ENUM(NSUInteger, JotPreferredStylusType) {
JotPreferredStylusBT21,
JotPreferredStylusBT40,
JotNoPreferredStylus,
};

extern NSString * const Connection_BT21;
extern NSString * const Connection_BT40;
extern NSString * const Model_JT2;
extern NSString * const Model_JT4;
extern NSString * const Model_JS;
extern NSString * const Model_JTPP;
extern NSString * const Model_Mighty;