OLD | NEW |
1 // Copyright (C) 2011, Google Inc. All rights reserved. | 1 // Copyright (C) 2011, Google Inc. All rights reserved. |
2 // | 2 // |
3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
4 // modification, are permitted provided that the following conditions are met: | 4 // modification, are permitted provided that the following conditions are met: |
5 // | 5 // |
6 // 1. Redistributions of source code must retain the above copyright | 6 // 1. Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // 2. Redistributions in binary form must reproduce the above copyright | 8 // 2. Redistributions in binary form must reproduce the above copyright |
9 // notice, this list of conditions and the following disclaimer in the | 9 // notice, this list of conditions and the following disclaimer in the |
10 // documentation and/or other materials provided with the distribution. | 10 // documentation and/or other materials provided with the distribution. |
(...skipping 22 matching lines...) Expand all Loading... |
33 namespace blink { | 33 namespace blink { |
34 | 34 |
35 #pragma pack(push, 1) | 35 #pragma pack(push, 1) |
36 | 36 |
37 // This structure is intentionally POD and fixed size so that it can be shared | 37 // This structure is intentionally POD and fixed size so that it can be shared |
38 // memory between hardware polling threads and the rest of the browser. See | 38 // memory between hardware polling threads and the rest of the browser. See |
39 // also WebGamepads.h. | 39 // also WebGamepads.h. |
40 class WebGamepad { | 40 class WebGamepad { |
41 public: | 41 public: |
42 static const size_t idLengthCap = 128; | 42 static const size_t idLengthCap = 128; |
| 43 static const size_t mappingLengthCap = 16; |
43 static const size_t axesLengthCap = 16; | 44 static const size_t axesLengthCap = 16; |
44 static const size_t buttonsLengthCap = 32; | 45 static const size_t buttonsLengthCap = 32; |
45 | 46 |
46 WebGamepad() | 47 WebGamepad() |
47 : connected(false) | 48 : connected(false) |
48 , timestamp(0) | 49 , timestamp(0) |
49 , axesLength(0) | 50 , axesLength(0) |
50 , buttonsLength(0) | 51 , buttonsLength(0) |
51 { | 52 { |
52 id[0] = 0; | 53 id[0] = 0; |
| 54 mapping[0] = 0; |
53 } | 55 } |
54 | 56 |
55 // Is there a gamepad connected at this index? | 57 // Is there a gamepad connected at this index? |
56 bool connected; | 58 bool connected; |
57 | 59 |
58 // Device identifier (based on manufacturer, model, etc.). | 60 // Device identifier (based on manufacturer, model, etc.). |
59 WebUChar id[idLengthCap]; | 61 WebUChar id[idLengthCap]; |
60 | 62 |
| 63 // Mapping type (for example "standard") |
| 64 WebUChar mapping[mappingLengthCap]; |
| 65 |
61 // Monotonically increasing value referring to when the data were last | 66 // Monotonically increasing value referring to when the data were last |
62 // updated. | 67 // updated. |
63 unsigned long long timestamp; | 68 unsigned long long timestamp; |
64 | 69 |
65 // Number of valid entries in the axes array. | 70 // Number of valid entries in the axes array. |
66 unsigned axesLength; | 71 unsigned axesLength; |
67 | 72 |
68 // Normalized values representing axes, in the range [-1..1]. | 73 // Normalized values representing axes, in the range [-1..1]. |
69 float axes[axesLengthCap]; | 74 float axes[axesLengthCap]; |
70 | 75 |
71 // Number of valid entries in the buttons array. | 76 // Number of valid entries in the buttons array. |
72 unsigned buttonsLength; | 77 unsigned buttonsLength; |
73 | 78 |
74 // Normalized values representing buttons, in the range [0..1]. | |
75 float buttons[buttonsLengthCap]; | 79 float buttons[buttonsLengthCap]; |
76 }; | 80 }; |
77 | 81 |
78 #if BLINK_IMPLEMENTATION | 82 #if BLINK_IMPLEMENTATION |
79 COMPILE_ASSERT(sizeof(WebGamepad) == 465, WebGamepad_has_wrong_size); | 83 COMPILE_ASSERT(sizeof(WebGamepad) == 497, WebGamepad_has_wrong_size); |
80 #endif | 84 #endif |
81 | 85 |
82 #pragma pack(pop) | 86 #pragma pack(pop) |
83 | 87 |
84 } | 88 } |
85 | 89 |
86 #endif // WebGamepad_h | 90 #endif // WebGamepad_h |
OLD | NEW |