ppb_gamepad_thunk.cc revision 5821806d5e7f356e8fa4b058a389a808ea183019
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 3// found in the LICENSE file. 4 5#include <string.h> 6 7#include "ppapi/c/ppb_gamepad.h" 8#include "ppapi/thunk/thunk.h" 9#include "ppapi/thunk/enter.h" 10#include "ppapi/thunk/ppb_gamepad_api.h" 11#include "ppapi/thunk/ppb_instance_api.h" 12#include "ppapi/thunk/resource_creation_api.h" 13 14namespace ppapi { 15namespace thunk { 16 17namespace { 18 19void SampleGamepads(PP_Instance instance, PP_GamepadsSampleData* data) { 20 EnterInstance enter(instance); 21 if (enter.succeeded()) { 22 PPB_Gamepad_API* api = enter.functions()->GetGamepadAPI(instance); 23 if (api) { 24 api->Sample(data); 25 return; 26 } 27 } 28 // Failure, zero out. 29 memset(data, 0, sizeof(PP_GamepadsSampleData)); 30} 31 32const PPB_Gamepad g_ppb_gamepad_thunk = { 33 &SampleGamepads, 34}; 35 36} // namespace 37 38const PPB_Gamepad* GetPPB_Gamepad_1_0_Thunk() { 39 return &g_ppb_gamepad_thunk; 40} 41 42} // namespace thunk 43} // namespace ppapi 44