add support for Apple Pencil and build for iOS

This commit is contained in:
2017-07-28 20:35:59 +01:00
parent e32329ea98
commit 0907429a60
15 changed files with 236 additions and 35 deletions

View File

@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
@@ -30,6 +40,16 @@
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
@@ -61,9 +81,16 @@
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "icon512.png",
"scale" : "2x"
},
{
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "icon1024.png",
"scale" : "1x"
}
],
"info" : {

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -1,8 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BV1-FR-VrT">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13156.6" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BV1-FR-VrT">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13137.5"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Game View Controller-->
@@ -14,9 +18,9 @@
<viewControllerLayoutGuide type="bottom" id="qHh-Mt-9TT"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="3se-qz-xqx" customClass="GLKView">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="SZV-WD-TEh" sceneMemberID="firstResponder"/>

View File

@@ -9,6 +9,6 @@
#import <UIKit/UIKit.h>
#import <GLKit/GLKit.h>
@interface GameViewController : GLKViewController
@interface GameViewController : GLKViewController <UIKeyInput>
@end

View File

@@ -19,28 +19,98 @@
- (void)tearDownGL;
@end
//std::map<
int t_count = 0;
@implementation GameViewController
- (void)insertText:(NSString *)text
{
if (const char* cstr = [text cStringUsingEncoding:NSASCIIStringEncoding])
App::I.key_char(cstr[0]);
NSLog(@"%@", text);
// Do something with the typed character
}
- (void)deleteBackward {
App::I.key_char('\b');
// Handle the delete key
}
- (BOOL)hasText {
// Return whether there's any text present
return YES;
}
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self.view];
float scale = self.view.contentScaleFactor;
App::I.mouse_down(0, touchLocation.x * scale, touchLocation.y * scale);
App::I.mouse_down(0, touchLocation.x * scale, touchLocation.y * scale, touch.force);
t_count = 1;
}
- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self.view];
NSUInteger n = [[event allTouches] count];
float scale = self.view.contentScaleFactor;
App::I.mouse_move(touchLocation.x * scale, touchLocation.y * scale);
UITouch* t0 = nullptr;
UITouch* t1 = nullptr;
t0 = [[[event allTouches] allObjects] objectAtIndex:0];
CGPoint tl0 = [t0 locationInView:self.view];
glm::vec2 p0 = glm::vec2(tl0.x * scale, tl0.y * scale);
glm::vec2 p1;
if (n > 1)
{
t1 = [[[event allTouches] allObjects] objectAtIndex:1];
CGPoint tl1 = [t1 locationInView:self.view];
p1 = glm::vec2(tl1.x * scale, tl1.y * scale);
}
if (n == 2)
{
if (t_count == 1)
{
App::I.mouse_cancel(0);
App::I.gesture_start(p0, p1);
}
else
App::I.gesture_move(p0, p1);
t_count = 2;
}
else if (n == 1)
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self.view];
//auto p = glm::vec2(touchLocation.x * scale, touchLocation.y * scale);
float force = touch.type == UITouchType::UITouchTypeStylus ? touch.force : 1.0f;
if (t_count == 2)
{
//App::I.gesture_end();
//App::I.mouse_down(0, touchLocation.x * scale, touchLocation.y * scale, force);
}
else
{
App::I.mouse_move(touchLocation.x * scale, touchLocation.y * scale, force);
}
}
}
-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint touchLocation = [touch locationInView:self.view];
float scale = self.view.contentScaleFactor;
App::I.mouse_up(0, touchLocation.x * scale, touchLocation.y * scale);
if (t_count == 2)
App::I.gesture_end();
else
App::I.mouse_up(0, touchLocation.x * scale, touchLocation.y * scale);
t_count = 0;
}
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
@@ -49,11 +119,16 @@
size.height * self.view.contentScaleFactor);
}
- (void)viewDidAppear:(BOOL)animated
{
[self resignFirstResponder];
}
- (void)viewDidLoad
{
[super viewDidLoad];
App::I.initLog();
App::I.ios_view = self;
self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3];