Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Unified Diff: tools/vulkan/viewer/InputHandler.cpp

Issue 1848833005: First pass at VulkanViewer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments, plus add GM rendering Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/vulkan/viewer/InputHandler.cpp
diff --git a/tools/vulkan/viewer/InputHandler.cpp b/tools/vulkan/viewer/InputHandler.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0e78b94f06bcc27a256c3b2c7b06a06e7b719762
--- /dev/null
+++ b/tools/vulkan/viewer/InputHandler.cpp
@@ -0,0 +1,48 @@
+/*
+* Copyright 2016 Google Inc.
+*
+* Use of this source code is governed by a BSD-style license that can be
+* found in the LICENSE file.
+*/
+
+#include "InputHandler.h"
+#include <ctype.h>
+
+InputHandler::InputHandler() : fMouseDown(false), fMousePressed(false), fMouseReleased(false)
+ , fMouseX(0), fMouseY(0) {
+ // clear key states
+ memset(fKeys, 0, sizeof(bool) * 256);
+ memset(fKeyPressed, 0, sizeof(bool) * 256);
+ memset(fKeyReleased, 0, sizeof(bool) * 256);
+}
+
+void InputHandler::onKeyDown(unsigned char key) {
+ if (!fKeys[key]) {
+ fKeys[key] = true;
+ fKeyPressed[key] = true;
+ }
+}
+
+void InputHandler::onKeyUp(unsigned char key) {
+ if (fKeys[key]) {
+ fKeys[key] = false;
+ fKeyReleased[key] = true;
+ }
+}
+
+void InputHandler::onMouseDown(unsigned int h, unsigned int v) {
+ if (!fMouseDown) {
+ fMouseDown = true;
+ fMousePressed = true;
+ }
+
+ fMouseX = h;
+ fMouseY = v;
+}
+
+void InputHandler::onMouseUp() {
+ if (fMouseDown) {
+ fMouseDown = false;
+ fMouseReleased = true;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698