15 #define VK_USE_PLATFORM_MACOS_MVK
17 #include <vsg/app/Window.h>
18 #include <vsg/ui/KeyEvent.h>
22 @class vsg_MacOS_NSView;
23 @class vsg_MacOS_NSWindow;
25 #import <Cocoa/Cocoa.h>
29 extern vsg::Names getInstanceExtensions();
30 using KeySymbolState = std::pair<vsg::KeySymbol,bool>;
31 using ModifierKeyChanges = std::vector< KeySymbolState >;
39 using kVKKeyCodeToKeySymbolMap = std::map<unsigned short, vsg::KeySymbol>;
40 bool getKeySymbol(NSEvent* anEvent, vsg::KeySymbol& keySymbol, vsg::KeySymbol& modifiedKeySymbol, vsg::KeyModifier& keyModifier);
41 void getModifierKeyChanges(NSEvent* anEvent, ModifierKeyChanges& changes);
44 kVKKeyCodeToKeySymbolMap _vk2vsg;
45 NSEventModifierFlags _lastFlags;
58 const char* instanceExtensionSurfaceName()
const override {
return "VK_MVK_macos_surface"; }
60 bool valid()
const override {
return _window; }
64 void resize()
override;
66 bool handleNSEvent(NSEvent* anEvent);
69 vsg_MacOS_NSWindow* window() {
return _window; };
70 vsg_MacOS_NSView* view() {
return _view; };
71 CAMetalLayer* layer() {
return _metalLayer; };
73 vsg::clock::time_point getEventTime(
double eventTime)
75 long elapsedmilli = long(
double(eventTime - _first_macos_timestamp) * 1000.0f);
76 return _first_macos_time_point + std::chrono::milliseconds(elapsedmilli);
82 virtual ~MacOS_Window();
84 void _initSurface()
override;
86 vsg_MacOS_NSWindow* _window;
87 vsg_MacOS_NSView* _view;
88 CAMetalLayer* _metalLayer;
90 double _first_macos_timestamp = 0;
91 vsg::clock::time_point _first_macos_time_point;
KeyboardMap maps macOS keyboard events to vsg::KeySymbol.
Definition: MacOS_Window.h:35
MacOS_Window implements macOS specific window creation, event handling and vulkan Surface setup.
Definition: MacOS_Window.h:50
bool pollEvents(vsg::UIEvents &events) override
get the list of events since the last pollEvents() call by splicing bufferEvents with polled windowin...
UIEvent is a base class for user interface events.
Definition: UIEvent.h:28
UIEvents bufferedEvents
events buffered since the last pollEvents.
Definition: Window.h:54