| 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 16 matching lines...) Expand all  Loading... | 
|   27 #include "WebCommon.h" |   27 #include "WebCommon.h" | 
|   28  |   28  | 
|   29 #if BLINK_IMPLEMENTATION |   29 #if BLINK_IMPLEMENTATION | 
|   30 #include "wtf/Assertions.h" |   30 #include "wtf/Assertions.h" | 
|   31 #endif |   31 #endif | 
|   32  |   32  | 
|   33 namespace blink { |   33 namespace blink { | 
|   34  |   34  | 
|   35 #pragma pack(push, 1) |   35 #pragma pack(push, 1) | 
|   36  |   36  | 
|   37 #if defined(ENABLE_NEW_GAMEPAD_API) |  | 
|   38 class WebGamepadButton { |  | 
|   39 public: |  | 
|   40     WebGamepadButton() |  | 
|   41         : pressed(false) |  | 
|   42         , value(0.f) |  | 
|   43     { |  | 
|   44     } |  | 
|   45     WebGamepadButton(bool pressed, float value) |  | 
|   46         : pressed(pressed) |  | 
|   47         , value(value) |  | 
|   48     { |  | 
|   49     } |  | 
|   50     bool pressed; |  | 
|   51     float value; |  | 
|   52 }; |  | 
|   53 #endif |  | 
|   54  |  | 
|   55 // 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 | 
|   56 // 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 | 
|   57 // also WebGamepads.h. |   39 // also WebGamepads.h. | 
|   58 class WebGamepad { |   40 class WebGamepad { | 
|   59 public: |   41 public: | 
|   60     static const size_t idLengthCap = 128; |   42     static const size_t idLengthCap = 128; | 
|   61     static const size_t mappingLengthCap = 16; |  | 
|   62     static const size_t axesLengthCap = 16; |   43     static const size_t axesLengthCap = 16; | 
|   63     static const size_t buttonsLengthCap = 32; |   44     static const size_t buttonsLengthCap = 32; | 
|   64  |   45  | 
|   65     WebGamepad() |   46     WebGamepad() | 
|   66         : connected(false) |   47         : connected(false) | 
|   67         , timestamp(0) |   48         , timestamp(0) | 
|   68         , axesLength(0) |   49         , axesLength(0) | 
|   69         , buttonsLength(0) |   50         , buttonsLength(0) | 
|   70     { |   51     { | 
|   71         id[0] = 0; |   52         id[0] = 0; | 
|   72 #if defined(ENABLE_NEW_GAMEPAD_API) |  | 
|   73         mapping[0] = 0; |  | 
|   74 #endif |  | 
|   75     } |   53     } | 
|   76  |   54  | 
|   77     // Is there a gamepad connected at this index? |   55     // Is there a gamepad connected at this index? | 
|   78     bool connected; |   56     bool connected; | 
|   79  |   57  | 
|   80     // Device identifier (based on manufacturer, model, etc.). |   58     // Device identifier (based on manufacturer, model, etc.). | 
|   81     WebUChar id[idLengthCap]; |   59     WebUChar id[idLengthCap]; | 
|   82  |   60  | 
|   83     // Monotonically increasing value referring to when the data were last |   61     // Monotonically increasing value referring to when the data were last | 
|   84     // updated. |   62     // updated. | 
|   85     unsigned long long timestamp; |   63     unsigned long long timestamp; | 
|   86  |   64  | 
|   87     // Number of valid entries in the axes array. |   65     // Number of valid entries in the axes array. | 
|   88     unsigned axesLength; |   66     unsigned axesLength; | 
|   89  |   67  | 
|   90     // Normalized values representing axes, in the range [-1..1]. |   68     // Normalized values representing axes, in the range [-1..1]. | 
|   91     float axes[axesLengthCap]; |   69     float axes[axesLengthCap]; | 
|   92  |   70  | 
|   93     // Number of valid entries in the buttons array. |   71     // Number of valid entries in the buttons array. | 
|   94     unsigned buttonsLength; |   72     unsigned buttonsLength; | 
|   95  |   73  | 
|   96 #if defined(ENABLE_NEW_GAMEPAD_API) |   74     // Normalized values representing buttons, in the range [0..1]. | 
|   97     // Button states |  | 
|   98     WebGamepadButton buttons[buttonsLengthCap]; |  | 
|   99  |  | 
|  100     // Mapping type (for example "standard") |  | 
|  101     WebUChar mapping[mappingLengthCap]; |  | 
|  102 #else |  | 
|  103     float buttons[buttonsLengthCap]; |   75     float buttons[buttonsLengthCap]; | 
|  104 #endif |  | 
|  105 }; |   76 }; | 
|  106  |   77  | 
|  107 #if BLINK_IMPLEMENTATION |   78 #if BLINK_IMPLEMENTATION | 
|  108 #if defined(ENABLE_NEW_GAMEPAD_API) |  | 
|  109 COMPILE_ASSERT(sizeof(WebGamepad) == 529, WebGamepad_has_wrong_size); |  | 
|  110 #else |  | 
|  111 COMPILE_ASSERT(sizeof(WebGamepad) == 465, WebGamepad_has_wrong_size); |   79 COMPILE_ASSERT(sizeof(WebGamepad) == 465, WebGamepad_has_wrong_size); | 
|  112 #endif |   80 #endif | 
|  113 #endif |  | 
|  114  |   81  | 
|  115 #pragma pack(pop) |   82 #pragma pack(pop) | 
|  116  |   83  | 
|  117 } |   84 } | 
|  118  |   85  | 
|  119 #endif // WebGamepad_h |   86 #endif // WebGamepad_h | 
| OLD | NEW |