|
|
|
|
@ -24,6 +24,7 @@
|
|
|
|
|
DEALINGS IN THE SOFTWARE. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
#include <Corrade/Containers/EnumSet.hpp> |
|
|
|
|
#include <Corrade/Containers/Optional.h> |
|
|
|
|
#include <Corrade/PluginManager/Manager.h> |
|
|
|
|
#include <Corrade/Utility/Arguments.h> |
|
|
|
|
@ -53,9 +54,86 @@
|
|
|
|
|
#include "Magnum/GL/DefaultFramebuffer.h" |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
namespace Magnum { namespace Platform { namespace Test { namespace { |
|
|
|
|
namespace Magnum { namespace Platform { |
|
|
|
|
|
|
|
|
|
Debug& operator<<(Debug& debug, const Application::KeyEvent::Key value) { |
|
|
|
|
/* These cannot be in an anonymous namespace as enumSetDebugOutput() below
|
|
|
|
|
wouldn't be able to pick them up */ |
|
|
|
|
|
|
|
|
|
static Debug& operator<<(Debug& debug, Application::InputEvent::Modifier value) { |
|
|
|
|
debug << "Modifier" << Debug::nospace; |
|
|
|
|
|
|
|
|
|
switch(value) { |
|
|
|
|
#define _c(value) case Application::InputEvent::Modifier::value: return debug << "::" #value; |
|
|
|
|
_c(Shift) |
|
|
|
|
_c(Ctrl) |
|
|
|
|
_c(Alt) |
|
|
|
|
_c(Super) |
|
|
|
|
_c(AltGr) |
|
|
|
|
_c(CapsLock) |
|
|
|
|
_c(NumLock) |
|
|
|
|
#undef _c |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return debug << "(" << Debug::nospace << UnsignedInt(value) << Debug::nospace << ")"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static Debug& operator<<(Debug& debug, Application::MouseMoveEvent::Button value) { |
|
|
|
|
debug << "Button" << Debug::nospace; |
|
|
|
|
|
|
|
|
|
switch(value) { |
|
|
|
|
#define _c(value) case Application::MouseMoveEvent::Button::value: return debug << "::" #value; |
|
|
|
|
_c(Left) |
|
|
|
|
_c(Middle) |
|
|
|
|
_c(Right) |
|
|
|
|
_c(X1) |
|
|
|
|
_c(X2) |
|
|
|
|
#undef _c |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return debug << "(" << Debug::nospace << UnsignedInt(value) << Debug::nospace << ")"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
namespace Test { namespace { |
|
|
|
|
|
|
|
|
|
Debug& operator<<(Debug& debug, Application::InputEvent::Modifiers value) { |
|
|
|
|
return Containers::enumSetDebugOutput(debug, value, "Modifiers{}", { |
|
|
|
|
Application::InputEvent::Modifier::Shift, |
|
|
|
|
Application::InputEvent::Modifier::Ctrl, |
|
|
|
|
Application::InputEvent::Modifier::Alt, |
|
|
|
|
Application::InputEvent::Modifier::Super, |
|
|
|
|
Application::InputEvent::Modifier::AltGr, |
|
|
|
|
Application::InputEvent::Modifier::CapsLock, |
|
|
|
|
Application::InputEvent::Modifier::NumLock, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Debug& operator<<(Debug& debug, Application::MouseEvent::Button value) { |
|
|
|
|
debug << "Button" << Debug::nospace; |
|
|
|
|
|
|
|
|
|
switch(value) { |
|
|
|
|
#define _c(value) case Application::MouseEvent::Button::value: return debug << "::" #value; |
|
|
|
|
_c(Left) |
|
|
|
|
_c(Middle) |
|
|
|
|
_c(Right) |
|
|
|
|
_c(X1) |
|
|
|
|
_c(X2) |
|
|
|
|
#undef _c |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return debug << "(" << Debug::nospace << UnsignedInt(value) << Debug::nospace << ")"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Debug& operator<<(Debug& debug, Application::MouseMoveEvent::Buttons value) { |
|
|
|
|
return Containers::enumSetDebugOutput(debug, value, "Buttons{}", { |
|
|
|
|
Application::MouseMoveEvent::Button::Left, |
|
|
|
|
Application::MouseMoveEvent::Button::Middle, |
|
|
|
|
Application::MouseMoveEvent::Button::Right, |
|
|
|
|
Application::MouseMoveEvent::Button::X1, |
|
|
|
|
Application::MouseMoveEvent::Button::X2, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Debug& operator<<(Debug& debug, Application::KeyEvent::Key value) { |
|
|
|
|
debug << "Key" << Debug::nospace; |
|
|
|
|
|
|
|
|
|
switch(value) { |
|
|
|
|
@ -209,23 +287,23 @@ struct Sdl2ApplicationTest: Platform::Application {
|
|
|
|
|
|
|
|
|
|
/* For testing event coordinates */ |
|
|
|
|
void mousePressEvent(MouseEvent& event) override { |
|
|
|
|
Debug{} << "mouse press event:" << event.position() << Int(event.button()); |
|
|
|
|
Debug{} << "mouse press:" << event.button() << Debug::packed << event.position() << event.modifiers(); |
|
|
|
|
_gestureDistance = {}; |
|
|
|
|
_gestureRotation = {}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void mouseReleaseEvent(MouseEvent& event) override { |
|
|
|
|
Debug{} << "mouse release event:" << event.position() << Int(event.button()); |
|
|
|
|
Debug{} << "mouse release:" << event.button() << Debug::packed << event.position() << event.modifiers(); |
|
|
|
|
_gestureDistance = {}; |
|
|
|
|
_gestureRotation = {}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void mouseMoveEvent(MouseMoveEvent& event) override { |
|
|
|
|
Debug{} << "mouse move event:" << event.position() << event.relativePosition() << Uint32(event.buttons()); |
|
|
|
|
Debug{} << "mouse move:" << event.buttons() << Debug::packed << event.position() << Debug::packed << event.relativePosition() << event.modifiers(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void mouseScrollEvent(MouseScrollEvent& event) override { |
|
|
|
|
Debug{} << "mouse scroll event:" << event.offset() << event.position(); |
|
|
|
|
Debug{} << "mouse scroll:" << event.modifiers() << Debug::packed << event.offset() << Debug::packed << event.position(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void multiGestureEvent(MultiGestureEvent& event) override { |
|
|
|
|
@ -235,11 +313,11 @@ struct Sdl2ApplicationTest: Platform::Application {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void keyPressEvent(KeyEvent& event) override { |
|
|
|
|
Debug{} << "key press event:" << event.key() << "keycode:" << SDL_Keycode(event.key()) << event.keyName() << "scancode:" << event.event().key.keysym.scancode |
|
|
|
|
Debug{} << "key press:" << event.key() << "keycode:" << SDL_Keycode(event.key()) << event.keyName() << "scancode:" << event.event().key.keysym.scancode |
|
|
|
|
#ifndef CORRADE_TARGET_EMSCRIPTEN |
|
|
|
|
<< SDL_GetScancodeName(event.event().key.keysym.scancode) |
|
|
|
|
#endif |
|
|
|
|
; |
|
|
|
|
<< event.modifiers(); |
|
|
|
|
|
|
|
|
|
if(event.key() == KeyEvent::Key::F1) { |
|
|
|
|
Debug{} << "starting text input"; |
|
|
|
|
@ -300,11 +378,11 @@ struct Sdl2ApplicationTest: Platform::Application {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void keyReleaseEvent(KeyEvent& event) override { |
|
|
|
|
Debug{} << "key release event:" << event.key() << "keycode:" << SDL_Keycode(event.key()) << event.keyName() << "scancode:" << event.event().key.keysym.scancode |
|
|
|
|
Debug{} << "key release:" << event.key() << "keycode:" << SDL_Keycode(event.key()) << event.keyName() << "scancode:" << event.event().key.keysym.scancode |
|
|
|
|
#ifndef CORRADE_TARGET_EMSCRIPTEN |
|
|
|
|
<< SDL_GetScancodeName(event.event().key.keysym.scancode) |
|
|
|
|
#endif |
|
|
|
|
; |
|
|
|
|
<< event.modifiers(); |
|
|
|
|
|
|
|
|
|
/* With EmscriptenApplication, this makes the event stop from
|
|
|
|
|
propagating further to the page (such as when pressing F1). |
|
|
|
|
|