Permalink
Browse files

Initial import

  • Loading branch information...
0 parents commit b918a9bf7df59b4f4a2b69b5b4c553cbf3d4b364 @robbertkl robbertkl committed Nov 4, 2016
Showing with 4,387 additions and 0 deletions.
  1. +19 −0 .gitignore
  2. +21 −0 LICENSE
  3. +34 −0 README.md
  4. BIN Resources/Screenshot.png
  5. BIN Resources/TouchBarIcon.sketch
  6. BIN Resources/Xcode.png
  7. +126 −0 Shared/Peertalk/PTChannel.h
  8. +634 −0 Shared/Peertalk/PTChannel.m
  9. +14 −0 Shared/Peertalk/PTPrivate.h
  10. +116 −0 Shared/Peertalk/PTProtocol.h
  11. +424 −0 Shared/Peertalk/PTProtocol.m
  12. +82 −0 Shared/Peertalk/PTUSBHub.h
  13. +633 −0 Shared/Peertalk/PTUSBHub.m
  14. +22 −0 Shared/Peertalk/Peertalk.h
  15. +3 −0 Shared/Peertalk/prefix.pch
  16. +33 −0 Shared/Protocol.h
  17. +680 −0 TouchBar.xcodeproj/project.pbxproj
  18. +17 −0 TouchBarClient/AppDelegate.h
  19. +51 −0 TouchBarClient/AppDelegate.m
  20. +152 −0 TouchBarClient/Assets.xcassets/AppIcon.appiconset/Contents.json
  21. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/Icon-40.png
  22. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png
  23. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/Icon-40@3x.png
  24. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png
  25. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png
  26. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/Icon-72.png
  27. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/Icon-72@2x.png
  28. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/Icon-76.png
  29. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png
  30. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/Icon-83.5@2x.png
  31. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/Icon-Small-50.png
  32. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/Icon-Small-50@2x.png
  33. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/Icon-Small.png
  34. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/Icon-Small@2x.png
  35. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/Icon-Small@3x.png
  36. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/Icon.png
  37. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/Icon@2x.png
  38. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/NotificationIcon@2x.png
  39. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/NotificationIcon@3x.png
  40. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/NotificationIcon~ipad.png
  41. BIN TouchBarClient/Assets.xcassets/AppIcon.appiconset/NotificationIcon~ipad@2x.png
  42. +6 −0 TouchBarClient/Assets.xcassets/Contents.json
  43. +31 −0 TouchBarClient/Base.lproj/LaunchScreen.storyboard
  44. +87 −0 TouchBarClient/Base.lproj/Main.storyboard
  45. +54 −0 TouchBarClient/Info.plist
  46. +15 −0 TouchBarClient/ViewController.h
  47. +179 −0 TouchBarClient/ViewController.m
  48. +16 −0 TouchBarClient/main.m
  49. +15 −0 TouchBarServer Helper/AppDelegate.h
  50. +23 −0 TouchBarServer Helper/AppDelegate.m
  51. +32 −0 TouchBarServer Helper/Info.plist
  52. +16 −0 TouchBarServer Helper/main.m
  53. +15 −0 TouchBarServer/AppDelegate.h
  54. +496 −0 TouchBarServer/AppDelegate.m
  55. +68 −0 TouchBarServer/Assets.xcassets/AppIcon.appiconset/Contents.json
  56. BIN TouchBarServer/Assets.xcassets/AppIcon.appiconset/icon_128x128.png
  57. BIN TouchBarServer/Assets.xcassets/AppIcon.appiconset/icon_128x128@2x.png
  58. BIN TouchBarServer/Assets.xcassets/AppIcon.appiconset/icon_16x16.png
  59. BIN TouchBarServer/Assets.xcassets/AppIcon.appiconset/icon_16x16@2x.png
  60. BIN TouchBarServer/Assets.xcassets/AppIcon.appiconset/icon_256x256.png
  61. BIN TouchBarServer/Assets.xcassets/AppIcon.appiconset/icon_256x256@2x.png
  62. BIN TouchBarServer/Assets.xcassets/AppIcon.appiconset/icon_32x32.png
  63. BIN TouchBarServer/Assets.xcassets/AppIcon.appiconset/icon_32x32@2x.png
  64. BIN TouchBarServer/Assets.xcassets/AppIcon.appiconset/icon_512x512.png
  65. BIN TouchBarServer/Assets.xcassets/AppIcon.appiconset/icon_512x512@2x.png
  66. +6 −0 TouchBarServer/Assets.xcassets/Contents.json
  67. +51 −0 TouchBarServer/Base.lproj/MainMenu.xib
  68. +36 −0 TouchBarServer/Info.plist
  69. +37 −0 TouchBarServer/StartAtLoginController.h
  70. +130 −0 TouchBarServer/StartAtLoginController.m
  71. +13 −0 TouchBarServer/main.m
@@ -0,0 +1,19 @@
+# OS X
+.DS_Store
+
+# Xcode
+build/
+*.pbxuser
+!default.pbxuser
+*.mode1v3
+!default.mode1v3
+*.mode2v3
+!default.mode2v3
+*.perspectivev3
+!default.perspectivev3
+*.xcworkspace
+!default.xcworkspace
+xcuserdata
+profile
+*.moved-aside
+DerivedData/
21 LICENSE
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2016 Bikkelbroeders
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
@@ -0,0 +1,34 @@
+# Touch Bar Demo App
+
+<img src="Resources/Screenshot.png" width="100%">
+
+Touch Bar Demo App allows you to use your macOS Touch Bar from an iPad (through USB connection) or on-screen by pressing the Fn-key.
+
+[![Click for video](https://img.youtube.com/vi/RZLx03OPpUU/0.jpg)](https://www.youtube.com/watch?v=RZLx03OPpUU)
+
+## Installation
+
+Ensure you have installed [macOS Sierra 10.12.1 build 16B2657](https://support.apple.com/kb/dl1897).
+
+Just fetch the latest ZIP from the [release section](https://github.com/bikkelbroeders/TouchBarDemoApp/releases) section and put the extracted app into your Applications folder.
+
+To build the iOS app, open `TouchBar.xcodeproj`, connect your iOS device and select the TouchBarClient target and your device:
+
+<img src="Resources/Xcode.png">
+
+For sideloading the app, see [these instructions](http://bouk.co/blog/sideload-iphone/).
+
+## Authors
+
+* Andreas Verhoeven, <ave@aveapps.com>
+* Robbert Klarenbeek, <robbertkl@renbeek.nl>
+
+## Credits
+
+* Thanks to [Alex Zielenski](https://twitter.com/#!/alexzielenski) for [StartAtLoginController](https://github.com/alexzielenski/StartAtLoginController), which ties together the ServiceManagement stuff without even a single line of code (gotta love KVO).
+
+* Thanks to [Aleksei Mazelyuk](https://dribbble.com/mazelyuk) for his [Touch bar for VK Messenger](https://dribbble.com/shots/3057522-Touch-bar-for-VK-Messenger), which was an inspiration for the app icon.
+
+## License
+
+Touch Bar Demo App is published under the [MIT License](http://www.opensource.org/licenses/mit-license.php).
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,126 @@
+//
+// Represents a communication channel between two endpoints talking the same
+// PTProtocol.
+//
+#import <Foundation/Foundation.h>
+#import <dispatch/dispatch.h>
+#import <netinet/in.h>
+#import <sys/socket.h>
+
+#import "PTProtocol.h"
+#import "PTUSBHub.h"
+
+@class PTData, PTAddress;
+@protocol PTChannelDelegate;
+
+@interface PTChannel : NSObject
+
+// Delegate
+@property (strong) id<PTChannelDelegate> delegate;
+
+// Communication protocol. Must not be nil.
+@property PTProtocol *protocol;
+
+// YES if this channel is a listening server
+@property (readonly) BOOL isListening;
+
+// YES if this channel is a connected peer
+@property (readonly) BOOL isConnected;
+
+// Arbitrary attachment. Note that if you set this, the object will grow by
+// 8 bytes (64 bits).
+@property (strong) id userInfo;
+
+// Create a new channel using the shared PTProtocol for the current dispatch
+// queue, with *delegate*.
++ (PTChannel*)channelWithDelegate:(id<PTChannelDelegate>)delegate;
+
+
+// Initialize a new frame channel, configuring it to use the calling queue's
+// protocol instance (as returned by [PTProtocol sharedProtocolForQueue:
+// dispatch_get_current_queue()])
+- (id)init;
+
+// Initialize a new frame channel with a specific protocol.
+- (id)initWithProtocol:(PTProtocol*)protocol;
+
+// Initialize a new frame channel with a specific protocol and delegate.
+- (id)initWithProtocol:(PTProtocol*)protocol delegate:(id<PTChannelDelegate>)delegate;
+
+
+// Connect to a TCP port on a device connected over USB
+- (void)connectToPort:(int)port overUSBHub:(PTUSBHub*)usbHub deviceID:(NSNumber*)deviceID callback:(void(^)(NSError *error))callback;
+
+// Connect to a TCP port at IPv4 address. Provided port must NOT be in network
+// byte order. Provided in_addr_t must NOT be in network byte order. A value returned
+// from inet_aton() will be in network byte order. You can use a value of inet_aton()
+// as the address parameter here, but you must flip the byte order before passing the
+// in_addr_t to this function.
+- (void)connectToPort:(in_port_t)port IPv4Address:(in_addr_t)address callback:(void(^)(NSError *error, PTAddress *address))callback;
+
+// Listen for connections on port and address, effectively starting a socket
+// server. Provided port must NOT be in network byte order. Provided in_addr_t
+// must NOT be in network byte order.
+// For this to make sense, you should provide a onAccept block handler
+// or a delegate implementing ioFrameChannel:didAcceptConnection:.
+- (void)listenOnPort:(in_port_t)port IPv4Address:(in_addr_t)address callback:(void(^)(NSError *error))callback;
+
+// Send a frame with an optional payload and optional callback.
+// If *callback* is not NULL, the block is invoked when either an error occured
+// or when the frame (and payload, if any) has been completely sent.
+- (void)sendFrameOfType:(uint32_t)frameType tag:(uint32_t)tag withPayload:(dispatch_data_t)payload callback:(void(^)(NSError *error))callback;
+
+// Lower-level method to assign a connected dispatch IO channel to this channel
+- (BOOL)startReadingFromConnectedChannel:(dispatch_io_t)channel error:(__autoreleasing NSError**)error;
+
+// Close the channel, preventing further reading and writing. Any ongoing and
+// queued reads and writes will be aborted.
+- (void)close;
+
+// "graceful" close -- any ongoing and queued reads and writes will complete
+// before the channel ends.
+- (void)cancel;
+
+@end
+
+
+// Wraps a mapped dispatch_data_t object. The memory pointed to by *data* is
+// valid until *dispatchData* is deallocated (normally when the receiver is
+// deallocated).
+@interface PTData : NSObject
+@property (readonly) dispatch_data_t dispatchData;
+@property (readonly) void *data;
+@property (readonly) size_t length;
+@end
+
+
+// Represents a peer's address
+@interface PTAddress : NSObject
+// For network addresses, this is the IP address in textual format
+@property (readonly) NSString *name;
+// For network addresses, this is the port number. Otherwise 0 (zero).
+@property (readonly) NSInteger port;
+@end
+
+
+// Protocol for PTChannel delegates
+@protocol PTChannelDelegate <NSObject>
+
+@required
+// Invoked when a new frame has arrived on a channel.
+- (void)ioFrameChannel:(PTChannel*)channel didReceiveFrameOfType:(uint32_t)type tag:(uint32_t)tag payload:(PTData*)payload;
+
+@optional
+// Invoked to accept an incoming frame on a channel. Reply NO ignore the
+// incoming frame. If not implemented by the delegate, all frames are accepted.
+- (BOOL)ioFrameChannel:(PTChannel*)channel shouldAcceptFrameOfType:(uint32_t)type tag:(uint32_t)tag payloadSize:(uint32_t)payloadSize;
+
+// Invoked when the channel closed. If it closed because of an error, *error* is
+// a non-nil NSError object.
+- (void)ioFrameChannel:(PTChannel*)channel didEndWithError:(NSError*)error;
+
+// For listening channels, this method is invoked when a new connection has been
+// accepted.
+- (void)ioFrameChannel:(PTChannel*)channel didAcceptConnection:(PTChannel*)otherChannel fromAddress:(PTAddress*)address;
+
+@end
Oops, something went wrong.

0 comments on commit b918a9b

Please sign in to comment.