OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "native_client/src/shared/ppapi_proxy/plugin_instance_data.h" | 5 #include "native_client/src/shared/ppapi_proxy/plugin_instance_data.h" |
6 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_gamepad.h" | 6 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_gamepad.h" |
7 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" | 7 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" |
8 #include "native_client/src/shared/ppapi_proxy/utility.h" | 8 #include "native_client/src/shared/ppapi_proxy/utility.h" |
9 #include "ppapi/c/pp_size.h" | 9 #include "ppapi/c/pp_size.h" |
10 #include "ppapi/c/dev/ppb_fullscreen_dev.h" | 10 #include "ppapi/c/dev/ppb_fullscreen_dev.h" |
11 #include "srpcgen/ppb_rpc.h" | 11 #include "srpcgen/ppb_rpc.h" |
12 | 12 |
13 namespace ppapi_proxy { | 13 namespace ppapi_proxy { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 void SampleGamepads(PP_Instance instance, struct PP_GamepadsData_Dev* pads) { | 17 void SampleGamepads(PP_Instance instance, struct PP_GamepadsData_Dev* pads) { |
18 DebugPrintf("PPB_Gamepad::SampleGamepads: instance=%"NACL_PRIu32"\n", | 18 DebugPrintf("PPB_Gamepad::SampleGamepads: instance=%"NACL_PRId32"\n", |
19 instance); | 19 instance); |
20 if (pads == NULL) | 20 if (pads == NULL) |
21 return; | 21 return; |
22 | 22 |
23 nacl_abi_size_t pads_bytes = | 23 nacl_abi_size_t pads_bytes = |
24 static_cast<nacl_abi_size_t>(sizeof(struct PP_GamepadsData_Dev)); | 24 static_cast<nacl_abi_size_t>(sizeof(struct PP_GamepadsData_Dev)); |
25 NaClSrpcError srpc_result = | 25 NaClSrpcError srpc_result = |
26 PpbGamepadRpcClient::PPB_Gamepad_SampleGamepads( | 26 PpbGamepadRpcClient::PPB_Gamepad_SampleGamepads( |
27 GetMainSrpcChannel(), | 27 GetMainSrpcChannel(), |
28 instance, | 28 instance, |
29 &pads_bytes, | 29 &pads_bytes, |
30 reinterpret_cast<char*>(pads)); | 30 reinterpret_cast<char*>(pads)); |
31 DebugPrintf("PPB_Gamepad::SampleGamepads: %s\n", | 31 DebugPrintf("PPB_Gamepad::SampleGamepads: %s\n", |
32 NaClSrpcErrorString(srpc_result)); | 32 NaClSrpcErrorString(srpc_result)); |
33 | 33 |
34 if (srpc_result != NACL_SRPC_RESULT_OK) | 34 if (srpc_result != NACL_SRPC_RESULT_OK) |
35 pads->length = 0; | 35 pads->length = 0; |
36 } | 36 } |
37 | 37 |
38 } // namespace | 38 } // namespace |
39 | 39 |
40 const PPB_Gamepad_Dev* PluginGamepad::GetInterface() { | 40 const PPB_Gamepad_Dev* PluginGamepad::GetInterface() { |
41 static const PPB_Gamepad_Dev gamepad_interface = { | 41 static const PPB_Gamepad_Dev gamepad_interface = { |
42 SampleGamepads | 42 SampleGamepads |
43 }; | 43 }; |
44 return &gamepad_interface; | 44 return &gamepad_interface; |
45 } | 45 } |
46 | 46 |
47 } // namespace ppapi_proxy | 47 } // namespace ppapi_proxy |
OLD | NEW |