Added virtual keypress handler in base example class (#56)
This commit is contained in:
parent
6af10ce764
commit
e2c6246d69
2 changed files with 16 additions and 8 deletions
|
|
@ -736,6 +736,7 @@ void VulkanExampleBase::handleMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
keyPressed((uint32_t)wParam);
|
||||||
break;
|
break;
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
|
|
@ -766,8 +767,7 @@ void VulkanExampleBase::handleMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// Linux : Setup window
|
// Set up a window using XCB and request event types
|
||||||
// TODO : Not finished...
|
|
||||||
xcb_window_t VulkanExampleBase::setupWindow()
|
xcb_window_t VulkanExampleBase::setupWindow()
|
||||||
{
|
{
|
||||||
uint32_t value_mask, value_list[32];
|
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_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
|
||||||
value_list[0] = screen->black_pixel;
|
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_EXPOSURE |
|
||||||
XCB_EVENT_MASK_STRUCTURE_NOTIFY |
|
XCB_EVENT_MASK_STRUCTURE_NOTIFY |
|
||||||
XCB_EVENT_MASK_POINTER_MOTION |
|
XCB_EVENT_MASK_POINTER_MOTION |
|
||||||
|
|
@ -879,11 +880,10 @@ void VulkanExampleBase::handleEvent(const xcb_generic_event_t *event)
|
||||||
break;
|
break;
|
||||||
case XCB_KEY_RELEASE:
|
case XCB_KEY_RELEASE:
|
||||||
{
|
{
|
||||||
const xcb_key_release_event_t *key =
|
const xcb_key_release_event_t *keyEvent = (const xcb_key_release_event_t *)event;
|
||||||
(const xcb_key_release_event_t *)event;
|
if (keyEvent->detail == 0x9)
|
||||||
|
|
||||||
if (key->detail == 0x9)
|
|
||||||
quit = true;
|
quit = true;
|
||||||
|
keyPressed(keyEvent->detail);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XCB_DESTROY_NOTIFY:
|
case XCB_DESTROY_NOTIFY:
|
||||||
|
|
@ -897,7 +897,12 @@ void VulkanExampleBase::handleEvent(const xcb_generic_event_t *event)
|
||||||
|
|
||||||
void VulkanExampleBase::viewChanged()
|
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)
|
VkBool32 VulkanExampleBase::getMemoryType(uint32_t typeBits, VkFlags properties, uint32_t * typeIndex)
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,9 @@ public:
|
||||||
// Can be overriden in derived class to e.g. update uniform buffers
|
// Can be overriden in derived class to e.g. update uniform buffers
|
||||||
// Containing view dependant matrices
|
// Containing view dependant matrices
|
||||||
virtual void viewChanged();
|
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)
|
// Get memory type for a given memory allocation (flags and bits)
|
||||||
VkBool32 getMemoryType(uint32_t typeBits, VkFlags properties, uint32_t *typeIndex);
|
VkBool32 getMemoryType(uint32_t typeBits, VkFlags properties, uint32_t *typeIndex);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue