Add keyboard support for iOS and macOS under MoltenVK.
This commit is contained in:
parent
626ab5803f
commit
6ba784053b
7 changed files with 134 additions and 40 deletions
|
|
@ -52,24 +52,17 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink,
|
|||
CVDisplayLinkStart(_displayLink);
|
||||
}
|
||||
|
||||
/** Resize the window to fit the size of the content as set by the sample code. */
|
||||
-(void) viewWillAppear {
|
||||
[super viewWillAppear];
|
||||
|
||||
CGSize vSz = self.view.bounds.size;
|
||||
NSWindow *window = self.view.window;
|
||||
NSRect wFrm = [window contentRectForFrameRect: window.frame];
|
||||
NSRect newWFrm = [window frameRectForContentRect: NSMakeRect(wFrm.origin.x, wFrm.origin.y, vSz.width, vSz.height)];
|
||||
[window setFrame: newWFrm display: YES animate: window.isVisible];
|
||||
[window center];
|
||||
}
|
||||
|
||||
-(void) dealloc {
|
||||
CVDisplayLinkRelease(_displayLink);
|
||||
delete(_vulkanExample);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
// Handle keyboard input
|
||||
-(void) keyDown:(NSEvent*) theEvent {
|
||||
_vulkanExample->keyPressed(theEvent.keyCode);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
|
@ -85,6 +78,13 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink,
|
|||
+(Class) layerClass { return [CAMetalLayer class]; }
|
||||
|
||||
/** If the wantsLayer property is set to YES, this method will be invoked to return a layer instance. */
|
||||
-(CALayer*) makeBackingLayer { return [self.class.layerClass layer]; }
|
||||
-(CALayer*) makeBackingLayer {
|
||||
CALayer* layer = [self.class.layerClass layer];
|
||||
CGSize viewScale = [self convertSizeToBacking: CGSizeMake(1.0, 1.0)];
|
||||
layer.contentsScale = MIN(viewScale.width, viewScale.height);
|
||||
return layer;
|
||||
}
|
||||
|
||||
-(BOOL) acceptsFirstResponder { return YES; }
|
||||
|
||||
@end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue