Post

Replies

Boosts

Views

Activity

Reply to Input with Metal-CPP, overriding MTK::View
Although this doesn't answer the question since it asks "Hopefully without having an Objective-C bridge", I would like to put here as a reference answer to those which only cares about things getting done: For getting the input to work while working with a MTKView and using the Metal/Game template from Xcode you can: Create a new Objective-C file, (I named it InputView.m) Make it extend UIView or NSView On GameViewController, start it with [[InputView alloc] initWithFrame:mtkView.frame] Call [mtkView addSubView:myInputView] Call [inputView becomeFirstResponder] In your InputView, implement - (BOOL) acceptsFirstResponder{ return YES;} Now you can check on the input related methods, such as - (void)mouseDown:(NSEvent*)event. If you need to check the mouse movement, you'll need to add a NSTrackingArea by calling [self addTrackingArea:myTrackingArea]
Topic: Graphics & Games SubTopic: General Tags:
Mar ’23
Reply to Input with Metal-CPP, overriding MTK::View
Although this doesn't answer the question since it asks "Hopefully without having an Objective-C bridge", I would like to put here as a reference answer to those which only cares about things getting done: For getting the input to work while working with a MTKView and using the Metal/Game template from Xcode you can: Create a new Objective-C file, (I named it InputView.m) Make it extend UIView or NSView On GameViewController, start it with [[InputView alloc] initWithFrame:mtkView.frame] Call [mtkView addSubView:myInputView] Call [inputView becomeFirstResponder] In your InputView, implement - (BOOL) acceptsFirstResponder{ return YES;} Now you can check on the input related methods, such as - (void)mouseDown:(NSEvent*)event. If you need to check the mouse movement, you'll need to add a NSTrackingArea by calling [self addTrackingArea:myTrackingArea]
Topic: Graphics & Games SubTopic: General Tags:
Replies
Boosts
Views
Activity
Mar ’23