Skip to content

Commit

Permalink
Getting the plugin working in Chrome.
Browse files Browse the repository at this point in the history
  • Loading branch information
benvanik committed Apr 7, 2013
1 parent 65ff8cc commit 32be7da
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 19 deletions.
1 change: 0 additions & 1 deletion manifest.json
Expand Up @@ -3,7 +3,6 @@
"version": "1.0.0.0",
"manifest_version": 2,
"description": "NPAPI plugin to expose fun VR devices.",
"default_locale": "en",
"offline_enabled": true,

"plugins": [
Expand Down
8 changes: 4 additions & 4 deletions src/np_entry.cpp
Expand Up @@ -54,8 +54,8 @@ NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs)
if(pFuncs == NULL)
return NPERR_INVALID_FUNCTABLE_ERROR;

if(pFuncs->size < sizeof(NPPluginFuncs))
return NPERR_INVALID_FUNCTABLE_ERROR;
//if(pFuncs->size < sizeof(NPPluginFuncs))
// return NPERR_INVALID_FUNCTABLE_ERROR;

pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
pFuncs->newp = NPP_New;
Expand Down Expand Up @@ -104,8 +104,8 @@ NPError OSCALL NP_Initialize(NPNetscapeFuncs* pFuncs, NPPluginFuncs* pluginFuncs
if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
return NPERR_INCOMPATIBLE_VERSION_ERROR;

if(pFuncs->size < sizeof(NPNetscapeFuncs))
return NPERR_INVALID_FUNCTABLE_ERROR;
//if(pFuncs->size < sizeof(NPNetscapeFuncs))
// return NPERR_INVALID_FUNCTABLE_ERROR;

NPNFuncs.size = pFuncs->size;
NPNFuncs.version = pFuncs->version;
Expand Down
7 changes: 4 additions & 3 deletions src/npvr.def
@@ -1,8 +1,9 @@
LIBRARY NPVR

EXPORTS
NP_GetEntryPoints @1
NP_Initialize @2
NP_Shutdown @3
NP_GetEntryPoints @1
NP_Initialize @2
NP_Shutdown @3
NP_GetMIMEDescription @4
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
10 changes: 5 additions & 5 deletions src/npvr.rc
Expand Up @@ -46,13 +46,13 @@ BEGIN
VALUE "CompanyName", "Ben Vanik"
VALUE "FileDescription", "NPAPI plugin for talking to fun new VR devices."
VALUE "FileOpenName", "NPVR"
VALUE "FileVersion", "1, 0, 0, 0"
VALUE "FileVersion", "1.0.0.0"
VALUE "InternalName", "NPVR"
VALUE "LegalCopyright", "Copyright 2013 Ben Vanik."
VALUE "MIMEType", "application/x-vnd-vr"
VALUE "OriginalFilename", "npvr.dll"
VALUE "ProductName", "NPVR"
VALUE "ProductVersion", "1, 0, 0, 0"
VALUE "ProductVersion", "1.0.0.0"
END
END
BLOCK "VarFileInfo"
Expand All @@ -68,18 +68,18 @@ END
// TEXTINCLUDE
//

1 TEXTINCLUDE
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END

2 TEXTINCLUDE
2 TEXTINCLUDE
BEGIN
"#include ""winresrc.h""\r\n"
"\0"
END

3 TEXTINCLUDE
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
Expand Down
9 changes: 7 additions & 2 deletions src/npvr/vr_object.cpp
Expand Up @@ -57,12 +57,17 @@ bool VRObject::InvokeExec(const NPVariant* args, uint32_t arg_count,
if (arg_count != 2) {
return false;
}
if (!NPVARIANT_IS_INT32(args[0]) ||
if (!(NPVARIANT_IS_INT32(args[0]) || NPVARIANT_IS_DOUBLE(args[0])) ||
!NPVARIANT_IS_STRING(args[1])) {
return false;
}

int32_t command_id = NPVARIANT_TO_INT32(args[0]);
int32_t command_id = 0;
if (NPVARIANT_IS_INT32(args[0])) {
command_id = NPVARIANT_TO_INT32(args[0]);
} else if (NPVARIANT_IS_DOUBLE(args[1])) {
command_id = (int)NPVARIANT_TO_DOUBLE(args[0]);
}
const NPUTF8* command_str = NPVARIANT_TO_STRING(args[1]).UTF8Characters;

std::ostringstream s;
Expand Down
9 changes: 7 additions & 2 deletions test/raw_data.html
Expand Up @@ -8,6 +8,11 @@
<canvas id="canvas" width="400" height="600"></canvas>

<script>
var requestAnimationFrame =
window.requestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame;

var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');

Expand Down Expand Up @@ -95,9 +100,9 @@
y += h; ctx.fillText('sixense not detected', 0, y);
}

window.mozRequestAnimationFrame(tick);
requestAnimationFrame.call(window, tick);
};
window.mozRequestAnimationFrame(tick);
requestAnimationFrame.call(window, tick);
});
</script>
</body>
Expand Down
9 changes: 7 additions & 2 deletions test/sixense_demo.html
Expand Up @@ -8,6 +8,11 @@
<body>
<div id="status"></div>
<script>
var requestAnimationFrame =
window.requestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame;

var statusEl = document.getElementById('status');

var canvasWidth = 800;
Expand Down Expand Up @@ -111,9 +116,9 @@
}

renderer.render(scene, camera);
window.mozRequestAnimationFrame(tick);
requestAnimationFrame.call(window, tick);
};
window.mozRequestAnimationFrame(tick);
requestAnimationFrame.call(window, tick);
</script>
</body>
</html>

0 comments on commit 32be7da

Please sign in to comment.