From 5588ed8f19462764e259cbf8ae53581fb3aa6414 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 13 Feb 2016 18:27:48 -0500 Subject: [PATCH 1/5] Add forgotten header --- moonlight.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/moonlight.hpp b/moonlight.hpp index 27f3dd3..12c41e8 100644 --- a/moonlight.hpp +++ b/moonlight.hpp @@ -50,6 +50,10 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock { bool Init(uint32_t argc, const char* argn[], const char* argv[]); void HandleMessage(const pp::Var& var_message); + void handlePair(std::string pairMessage); + void handleShowGames(std::string showGamesMessage); + void handleStartStream(std::string startStreamMessage); + void handleStopStream(std::string stopStreamMessage); void UpdateModifiers(PP_InputEvent_Type eventType, short keyCode); bool HandleInputEvent(const pp::InputEvent& event); From e9870cde4fba087b6374a477d40c2ff84a32ff04 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 13 Feb 2016 18:32:13 -0500 Subject: [PATCH 2/5] Fix streaming --- main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index e86c96b..3b3ac1d 100644 --- a/main.cpp +++ b/main.cpp @@ -101,7 +101,7 @@ void MoonlightInstance::handleShowGames(std::string showGamesMessage) { } void MoonlightInstance::handleStartStream(std::string startStreamMessage) { - // Populate the stream configuration + // Populate the stream configuration LiInitializeStreamConfiguration(&s_StreamConfig); s_StreamConfig.width = 1280; s_StreamConfig.height = 720; @@ -112,7 +112,7 @@ void MoonlightInstance::handleStartStream(std::string startStreamMessage) { s_StreamConfig.audioConfiguration = AUDIO_CONFIGURATION_STEREO; // Store the host, which is between two colons - std::string host = startStreamMessage.substr(strlen(START_STREAM_DIRECTIVE), startStreamMessage.substr(strlen(START_STREAM_DIRECTIVE)).find(":") + 1); + std::string host = startStreamMessage.substr(strlen(START_STREAM_DIRECTIVE), startStreamMessage.substr(strlen(START_STREAM_DIRECTIVE)).find(":")); strcpy(s_Host, host.c_str()); // store the gameID to start, which is after the last colon From 0eca5146212b140220b9b065e42f3bc24565622d Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 13 Feb 2016 18:38:42 -0500 Subject: [PATCH 3/5] Add proper socket permissions for running as an extension --- Makefile | 1 + manifest.json | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0582a8b..202a0a0 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ include $(NACL_SDK_ROOT)/tools/common.mk # Dirty hack to allow 'make serve' to work in this directory HTTPD_PY := $(HTTPD_PY) --no-dir-check +CHROME_ARGS += --allow-nacl-socket-api=localhost LIBS = ppapi_gles2 ppapi ppapi_cpp pthread nacl_io diff --git a/manifest.json b/manifest.json index 2df2138..720c03e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "manifest_version": 2, - "name": "Moonlight Chrome", + "name": "Moonlight", "version": "0.01", "description": "A Moonlight streaming plugin for Google Chrome", "icons": { @@ -15,6 +15,14 @@ "scripts": ["background.js"] } }, - "permissions": ["fullscreen"] + "permissions": [ + "fullscreen", { + "socket": [ + "tcp-connect", + "resolve-host", + "udp-bind:*:*", + "udp-send-to:*:*" + ] } + ] } From bf048a6b1d80d0e6eeb28d6d216dfad10717630c Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 13 Feb 2016 18:43:39 -0500 Subject: [PATCH 4/5] Add pointer lock permission to allow mouse capture in plugin mode --- manifest.json | 1 + 1 file changed, 1 insertion(+) diff --git a/manifest.json b/manifest.json index 720c03e..323044f 100644 --- a/manifest.json +++ b/manifest.json @@ -16,6 +16,7 @@ } }, "permissions": [ + "pointerLock", "fullscreen", { "socket": [ "tcp-connect", From 15920cd69b8cbb29c93182151c137490439e014b Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 13 Feb 2016 19:09:25 -0500 Subject: [PATCH 5/5] Fix a couple of keyboard/mouse capturing issues --- input.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/input.cpp b/input.cpp index cb8f8b9..bb50ce7 100644 --- a/input.cpp +++ b/input.cpp @@ -31,6 +31,7 @@ void MoonlightInstance::DidLockMouse(int32_t result) { void MoonlightInstance::MouseLockLost() { m_MouseLocked = false; + m_KeyModifiers = 0; } void MoonlightInstance::UpdateModifiers(PP_InputEvent_Type eventType, short keyCode) { @@ -127,6 +128,12 @@ bool MoonlightInstance::HandleInputEvent(const pp::InputEvent& event) { // Update modifier state before sending the key event UpdateModifiers(event.GetType(), keyboardEvent.GetKeyCode()); + if (m_KeyModifiers == (MODIFIER_ALT | MODIFIER_CTRL | MODIFIER_SHIFT)) { + g_Instance->UnlockMouse(); + m_MouseLocked = false; + return true; + } + LiSendKeyboardEvent(KEY_PREFIX << 8 | keyboardEvent.GetKeyCode(), KEY_ACTION_DOWN, m_KeyModifiers); return true;