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

Side by Side Diff: tools/vulkan/viewer/InputHandler.cpp

Issue 1865553005: Clean up input handling in VulkanViewer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rename resize params 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 unified diff | Download patch
« no previous file with comments | « tools/vulkan/viewer/InputHandler.h ('k') | tools/vulkan/viewer/VulkanViewer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "InputHandler.h"
9 #include <ctype.h>
10
11 InputHandler::InputHandler() : fMouseDown(false), fMousePressed(false), fMouseRe leased(false)
12 , fMouseX(0), fMouseY(0) {
13 // clear key states
14 memset(fKeys, 0, sizeof(bool) * 256);
15 memset(fKeyPressed, 0, sizeof(bool) * 256);
16 memset(fKeyReleased, 0, sizeof(bool) * 256);
17 }
18
19 void InputHandler::onKeyDown(unsigned char key) {
20 if (!fKeys[key]) {
21 fKeys[key] = true;
22 fKeyPressed[key] = true;
23 }
24 }
25
26 void InputHandler::onKeyUp(unsigned char key) {
27 if (fKeys[key]) {
28 fKeys[key] = false;
29 fKeyReleased[key] = true;
30 }
31 }
32
33 void InputHandler::onMouseDown(unsigned int h, unsigned int v) {
34 if (!fMouseDown) {
35 fMouseDown = true;
36 fMousePressed = true;
37 }
38
39 fMouseX = h;
40 fMouseY = v;
41 }
42
43 void InputHandler::onMouseUp() {
44 if (fMouseDown) {
45 fMouseDown = false;
46 fMouseReleased = true;
47 }
48 }
OLDNEW
« no previous file with comments | « tools/vulkan/viewer/InputHandler.h ('k') | tools/vulkan/viewer/VulkanViewer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698