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

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

Issue 1848833005: First pass at VulkanViewer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Revise setup and event handling 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
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 (isupper(key)) {
21 key = tolower(key);
22 }
23
24 if (!fKeys[key]) {
25 fKeys[key] = true;
26 fKeyPressed[key] = true;
27 }
28 }
29
30 void InputHandler::onKeyUp(unsigned char key) {
31 if (isupper(key)) {
32 key = tolower(key);
33 }
34
35 if (fKeys[key]) {
36 fKeys[key] = false;
37 fKeyReleased[key] = true;
38 }
39 }
40
41 void InputHandler::onMouseDown(unsigned int h, unsigned int v) {
42 if (!fMouseDown) {
43 fMouseDown = true;
44 fMousePressed = true;
45 }
46
47 fMouseX = h;
48 fMouseY = v;
49 }
50
51 void InputHandler::onMouseUp() {
52 if (fMouseDown) {
53 fMouseDown = false;
54 fMouseReleased = true;
55 }
56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698