From 44bf196b07b47bd863af302975c1d25e3cd57ef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 30 May 2015 22:11:42 -0700 Subject: [PATCH] Cleanup. --- examples/common/entry/entry.cpp | 29 ++++++++++++----------------- examples/common/entry/input.cpp | 19 +++++++++++++++++-- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/examples/common/entry/entry.cpp b/examples/common/entry/entry.cpp index 5dac1e39c..7b1fc566f 100644 --- a/examples/common/entry/entry.cpp +++ b/examples/common/entry/entry.cpp @@ -210,11 +210,6 @@ BX_PRAGMA_DIAGNOSTIC_POP(); return false; } - void cmd(const void* _userData) - { - cmdExec( (const char*)_userData); - } - int cmdMouseLock(CmdContext* /*_context*/, void* /*_userData*/, int _argc, char const* const* _argv) { if (_argc > 1) @@ -281,18 +276,18 @@ BX_PRAGMA_DIAGNOSTIC_POP(); static const InputBinding s_bindings[] = { - { entry::Key::KeyQ, entry::Modifier::LeftCtrl, 1, cmd, "exit" }, - { entry::Key::F1, entry::Modifier::None, 1, cmd, "graphics stats" }, - { entry::Key::GamepadStart, entry::Modifier::None, 1, cmd, "graphics stats" }, - { entry::Key::F1, entry::Modifier::LeftShift, 1, cmd, "graphics stats 0\ngraphics text 0" }, - { entry::Key::F3, entry::Modifier::None, 1, cmd, "graphics wireframe" }, - { entry::Key::F4, entry::Modifier::None, 1, cmd, "graphics hmd" }, - { entry::Key::F4, entry::Modifier::LeftShift, 1, cmd, "graphics hmdrecenter" }, - { entry::Key::F4, entry::Modifier::LeftCtrl, 1, cmd, "graphics hmddbg" }, - { entry::Key::F7, entry::Modifier::None, 1, cmd, "graphics vsync" }, - { entry::Key::F8, entry::Modifier::None, 1, cmd, "graphics msaa" }, - { entry::Key::F9, entry::Modifier::None, 1, cmd, "graphics flush" }, - { entry::Key::Print, entry::Modifier::None, 1, cmd, "graphics screenshot" }, + { entry::Key::KeyQ, entry::Modifier::LeftCtrl, 1, NULL, "exit" }, + { entry::Key::F1, entry::Modifier::None, 1, NULL, "graphics stats" }, + { entry::Key::GamepadStart, entry::Modifier::None, 1, NULL, "graphics stats" }, + { entry::Key::F1, entry::Modifier::LeftShift, 1, NULL, "graphics stats 0\ngraphics text 0" }, + { entry::Key::F3, entry::Modifier::None, 1, NULL, "graphics wireframe" }, + { entry::Key::F4, entry::Modifier::None, 1, NULL, "graphics hmd" }, + { entry::Key::F4, entry::Modifier::LeftShift, 1, NULL, "graphics hmdrecenter" }, + { entry::Key::F4, entry::Modifier::LeftCtrl, 1, NULL, "graphics hmddbg" }, + { entry::Key::F7, entry::Modifier::None, 1, NULL, "graphics vsync" }, + { entry::Key::F8, entry::Modifier::None, 1, NULL, "graphics msaa" }, + { entry::Key::F9, entry::Modifier::None, 1, NULL, "graphics flush" }, + { entry::Key::Print, entry::Modifier::None, 1, NULL, "graphics screenshot" }, INPUT_BINDING_END }; diff --git a/examples/common/entry/input.cpp b/examples/common/entry/input.cpp index 871bc96ea..2ee3b5163 100644 --- a/examples/common/entry/input.cpp +++ b/examples/common/entry/input.cpp @@ -7,6 +7,7 @@ #include "entry_p.h" #include "input.h" +#include "cmd.h" #include #include @@ -205,7 +206,14 @@ struct Input if (modifiers == binding->m_modifiers && !m_keyboard.m_once[binding->m_key]) { - binding->m_fn(binding->m_userData); + if (NULL == binding->m_fn) + { + cmdExec( (const char*)binding->m_userData); + } + else + { + binding->m_fn(binding->m_userData); + } m_keyboard.m_once[binding->m_key] = true; } } @@ -219,7 +227,14 @@ struct Input if (down && modifiers == binding->m_modifiers) { - binding->m_fn(binding->m_userData); + if (NULL == binding->m_fn) + { + cmdExec( (const char*)binding->m_userData); + } + else + { + binding->m_fn(binding->m_userData); + } } } }