Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Unified Diff: native_client_sdk/src/examples/gamepad/gamepad_module.cc

Issue 9148086: Add simple NaCl gamepad example (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: and in gamepad_module Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « native_client_sdk/src/examples/gamepad/gamepad.nmf ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/examples/gamepad/gamepad_module.cc
diff --git a/native_client_sdk/src/examples/gamepad/gamepad_module.cc b/native_client_sdk/src/examples/gamepad/gamepad_module.cc
new file mode 100644
index 0000000000000000000000000000000000000000..cac25702832f981e30a3fe758c73a55445e7c99f
--- /dev/null
+++ b/native_client_sdk/src/examples/gamepad/gamepad_module.cc
@@ -0,0 +1,34 @@
+// Copyright (c) 2012 The Native Client Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <ppapi/cpp/module.h>
+
+#include "gamepad.h"
+
+namespace gamepad {
+// The Module class. The browser calls the CreateInstance() method to create
+// an instance of your NaCl module on the web page. The browser creates a new
+// instance for each <embed> tag with type="application/x-nacl".
+class GamepadModule : public pp::Module {
+ public:
+ GamepadModule() : pp::Module() {}
+ virtual ~GamepadModule() {}
+
+ // Create and return a GamepadInstance object.
+ virtual pp::Instance* CreateInstance(PP_Instance instance) {
+ return new Gamepad(instance);
+ }
+};
+} // namespace gamepad
+
+// Factory function called by the browser when the module is first loaded.
+// The browser keeps a singleton of this module. It calls the
+// CreateInstance() method on the object you return to make instances. There
+// is one instance per <embed> tag on the page. This is the main binding
+// point for your NaCl module with the browser.
+namespace pp {
+Module* CreateModule() {
+ return new gamepad::GamepadModule();
+}
+} // namespace pp
« no previous file with comments | « native_client_sdk/src/examples/gamepad/gamepad.nmf ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698