Added virtual keypress handler in base example class (#56)

This commit is contained in:
saschawillems 2016-03-03 16:41:57 +01:00
parent 6af10ce764
commit e2c6246d69
2 changed files with 16 additions and 8 deletions

View file

@ -736,6 +736,7 @@ void VulkanExampleBase::handleMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
exit(0);
break;
}
keyPressed((uint32_t)wParam);
break;
case WM_RBUTTONDOWN:
case WM_LBUTTONDOWN:
@ -766,8 +767,7 @@ void VulkanExampleBase::handleMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
#else
// Linux : Setup window
// TODO : Not finished...
// Set up a window using XCB and request event types
xcb_window_t VulkanExampleBase::setupWindow()
{
uint32_t value_mask, value_list[32];
@ -776,7 +776,8 @@ xcb_window_t VulkanExampleBase::setupWindow()
value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
value_list[0] = screen->black_pixel;
value_list[1] = XCB_EVENT_MASK_KEY_RELEASE |
value_list[1] =
XCB_EVENT_MASK_KEY_RELEASE |
XCB_EVENT_MASK_EXPOSURE |
XCB_EVENT_MASK_STRUCTURE_NOTIFY |
XCB_EVENT_MASK_POINTER_MOTION |
@ -879,11 +880,10 @@ void VulkanExampleBase::handleEvent(const xcb_generic_event_t *event)
break;
case XCB_KEY_RELEASE:
{
const xcb_key_release_event_t *key =
(const xcb_key_release_event_t *)event;
if (key->detail == 0x9)
const xcb_key_release_event_t *keyEvent = (const xcb_key_release_event_t *)event;
if (keyEvent->detail == 0x9)
quit = true;
keyPressed(keyEvent->detail);
}
break;
case XCB_DESTROY_NOTIFY:
@ -897,7 +897,12 @@ void VulkanExampleBase::handleEvent(const xcb_generic_event_t *event)
void VulkanExampleBase::viewChanged()
{
// For overriding on derived class
// Can be overrdiden in derived class
}
void VulkanExampleBase::keyPressed(uint32_t keyCode)
{
// Can be overriden in derived class
}
VkBool32 VulkanExampleBase::getMemoryType(uint32_t typeBits, VkFlags properties, uint32_t * typeIndex)

View file

@ -163,6 +163,9 @@ public:
// Can be overriden in derived class to e.g. update uniform buffers
// Containing view dependant matrices
virtual void viewChanged();
// Called if a key is pressed
// Can be overriden derived class to do custom key handling
virtual void keyPressed(uint32_t keyCode);
// Get memory type for a given memory allocation (flags and bits)
VkBool32 getMemoryType(uint32_t typeBits, VkFlags properties, uint32_t *typeIndex);