ppb_gamepad_thunk.cc revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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  EnterInstanceAPI<PPB_Gamepad_API> enter(instance);
21  if (enter.succeeded()) {
22    enter.functions()->Sample(instance, data);
23    return;
24  }
25  // Failure, zero out.
26  memset(data, 0, sizeof(PP_GamepadsSampleData));
27}
28
29const PPB_Gamepad g_ppb_gamepad_thunk = {
30  &SampleGamepads,
31};
32
33}  // namespace
34
35const PPB_Gamepad* GetPPB_Gamepad_1_0_Thunk() {
36  return &g_ppb_gamepad_thunk;
37}
38
39}  // namespace thunk
40}  // namespace ppapi
41