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

Side by Side Diff: third_party/WebKit/Source/modules/gamepad/GamepadPose.cpp

Issue 2300543003: Added Pose attribute to Gamepad (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gamepad_touched
Patch Set: Rebase Created 4 years, 3 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 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "modules/gamepad/GamepadPose.h"
6
7 namespace blink {
8
9 namespace {
10
11 DOMFloat32Array* vecToFloat32Array(const WebGamepadVector& vec)
12 {
13 if (vec.notNull) {
14 DOMFloat32Array* out = DOMFloat32Array::create(3);
15 out->data()[0] = vec.x;
16 out->data()[1] = vec.y;
17 out->data()[2] = vec.z;
18 return out;
19 }
20 return nullptr;
21 }
22
23 DOMFloat32Array* quatToFloat32Array(const WebGamepadQuaternion& quat)
24 {
25 if (quat.notNull) {
26 DOMFloat32Array* out = DOMFloat32Array::create(4);
27 out->data()[0] = quat.x;
28 out->data()[1] = quat.y;
29 out->data()[2] = quat.z;
30 out->data()[3] = quat.w;
31 return out;
32 }
33 return nullptr;
34 }
35
36 } // namespace
37
38 GamepadPose::GamepadPose()
39 {
40 }
41
42 void GamepadPose::setPose(const WebGamepadPose &state)
43 {
44 if (state.notNull) {
45 m_hasOrientation = state.hasOrientation;
46 m_hasPosition = state.hasPosition;
47
48 m_orientation = quatToFloat32Array(state.orientation);
49 m_position = vecToFloat32Array(state.position);
50 m_angularVelocity = vecToFloat32Array(state.angularVelocity);
51 m_linearVelocity = vecToFloat32Array(state.linearVelocity);
52 m_angularAcceleration = vecToFloat32Array(state.angularAcceleration);
53 m_linearAcceleration = vecToFloat32Array(state.linearAcceleration);
54 }
55 }
56
57 DEFINE_TRACE(GamepadPose)
58 {
59 visitor->trace(m_orientation);
60 visitor->trace(m_position);
61 visitor->trace(m_angularVelocity);
62 visitor->trace(m_linearVelocity);
63 visitor->trace(m_angularAcceleration);
64 visitor->trace(m_linearAcceleration);
65 }
66
67 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/gamepad/GamepadPose.h ('k') | third_party/WebKit/Source/modules/gamepad/GamepadPose.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698