Skip to content

Commit

Permalink
Re-branded app as HTWebRemote, Added Nvidia Shield and Roku device su…
Browse files Browse the repository at this point in the history
…pport, Added copy button to remote editor, bump to v1.5
  • Loading branch information
nicko88 committed Nov 2, 2021
1 parent aed4186 commit 039ad28
Show file tree
Hide file tree
Showing 86 changed files with 915 additions and 373 deletions.
18 changes: 0 additions & 18 deletions HTPCRemote/Devices/Controllers/HTP1Control.cs

This file was deleted.

23 changes: 0 additions & 23 deletions HTPCRemote/Devices/Controllers/HttpGetControl.cs

This file was deleted.

15 changes: 0 additions & 15 deletions HTPCRemote/Devices/Controllers/ZappitiControl.cs

This file was deleted.

Binary file removed HTPCRemote/Resources/QR Code.png
Binary file not shown.
2 changes: 1 addition & 1 deletion HTPCRemote.sln → HTWebRemote.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.452
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HTPCRemote", "HTPCRemote\HTPCRemote.csproj", "{B9E44033-829B-43E3-B5DB-A534F18B1BFB}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HTWebRemote", "HTWebRemote\HTWebRemote.csproj", "{B9E44033-829B-43E3-B5DB-A534F18B1BFB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Text;
using System.Threading;

namespace HTPCRemote.Devices.Controllers
namespace HTWebRemote.Devices.Controllers
{
class AnthemControl
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Text;
using System.Threading;

namespace HTPCRemote.Devices.Controllers
namespace HTWebRemote.Devices.Controllers
{
class BenQControl
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Threading;
using System.Text;

namespace HTPCRemote.Devices.Controllers
namespace HTWebRemote.Devices.Controllers
{
class ChristieControl
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Net.Sockets;
using System.Threading;

namespace HTPCRemote.Devices.Controllers
namespace HTWebRemote.Devices.Controllers
{
class DBOXControl
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Text;
using System.Windows.Forms;

namespace HTPCRemote.Devices.Controllers
namespace HTWebRemote.Devices.Controllers
{
static class DMControl
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Text;
using System.Threading;

namespace HTPCRemote.Devices.Controllers
namespace HTWebRemote.Devices.Controllers
{
class EmotivaControl
{
Expand Down
36 changes: 36 additions & 0 deletions HTWebRemote/Devices/Controllers/HTP1Control.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Net.Http;
using System.Windows.Forms;

namespace HTWebRemote.Devices.Controllers
{
class HTP1Control
{
public static void RunCmd(string IP, string cmd, string param, bool showErrors)
{
if(cmd.ToLower() == "ir")
{
HttpClient httpClient = new HttpClient();
httpClient.Timeout = TimeSpan.FromSeconds(3);

HttpResponseMessage result;
try
{
result = httpClient.GetAsync($"http://{IP}/ircmd?code={param}").Result;

if (!result.IsSuccessStatusCode)
{
throw new Exception();
}
}
catch (Exception e)
{
if (showErrors)
{
MessageBox.Show($"Error sending command to HTP-1: http://{IP}/ircmd?code={param}\n\n{e.Message}", "Error");
}
}
}
}
}
}
40 changes: 40 additions & 0 deletions HTWebRemote/Devices/Controllers/HttpGetControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Windows.Forms;

namespace HTWebRemote.Devices.Controllers
{
class HttpGetControl
{
public static void RunCmd(string IP, string cmd, string param, bool showErrors)
{
HttpClient httpClient = new HttpClient();
httpClient.Timeout = TimeSpan.FromSeconds(3);

if (!string.IsNullOrEmpty(param))
{
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(param)));
}

HttpResponseMessage result;
try
{
result = httpClient.GetAsync($"{IP}{cmd}").Result;

if (!result.IsSuccessStatusCode)
{
throw new Exception();
}
}
catch (Exception e)
{
if (showErrors)
{
MessageBox.Show($"Error sending http GET request: {IP}{cmd}\n\n{e.Message}", "Error");
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Threading;
using System.Windows.Forms;

namespace HTPCRemote.Devices.Controllers
namespace HTWebRemote.Devices.Controllers
{
class JVCControl
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace HTPCRemote.Devices.Controllers
namespace HTWebRemote.Devices.Controllers
{
class KeysControl
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Net.Sockets;
using System.Text;

namespace HTPCRemote.Devices.Controllers
namespace HTWebRemote.Devices.Controllers
{
class LIRCControl
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Text;
using System.Windows.Forms;

namespace HTPCRemote.Devices.Controllers
namespace HTWebRemote.Devices.Controllers
{
class MPCControl
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Windows.Forms;

namespace HTPCRemote.Devices.Controllers
namespace HTWebRemote.Devices.Controllers
{
class MQTTControl
{
Expand Down Expand Up @@ -48,7 +48,7 @@ public static void RunCmd(string IP, string cmd, string param, bool showErrors)
{
if (showErrors)
{
MessageBox.Show($@"Failed sending Topic: ""{cmd}"" and Payload: ""{param}"" to MQTT broker at: {IP}");
MessageBox.Show($@"Failed sending Topic: ""{cmd}"" and Payload: ""{param}"" to MQTT broker at: {IP}", "Error");
}
}
}
Expand Down
108 changes: 108 additions & 0 deletions HTWebRemote/Devices/Controllers/NVShieldControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
using HTWebRemote.Util;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;

namespace HTWebRemote.Devices.Controllers
{
class NVShieldControl
{
private static Dictionary<string, (string, string)> _apps;
private static Dictionary<string, (string, string)> Apps
{
get
{
_apps = new Dictionary<string, (string, string)>
{
{ "netflix", ("shell monkey -p com.netflix.ninja 1", "shell am force-stop com.netflix.ninja") },
{ "plex", ("shell monkey -p com.plexapp.android 1", "shell am force-stop com.plexapp.android") },
{ "youtube", ("shell monkey -p com.google.android.youtube.tv 1", "shell am force-stop com.google.android.youtube.tv") },
{ "disney+", ("shell monkey -p com.disney.disneyplus 1", "shell am force-stop com.disney.disneyplus") },
{ "hulu", ("shell monkey -p com.hulu.livingroomplus 1", "shell am force-stop com.hulu.livingroomplus") },
{ "spotify", ("shell monkey -p com.spotify.tv.android 1", "shell am force-stop com.spotify.tv.android") },
{ "hbomax", ("shell monkey -p com.hbo.hbonow 1", "shell am force-stop com.hbo.hbonow") },
{ "twitch", ("shell monkey -p tv.twitch.android.app 1", "shell am force-stop tv.twitch.android.app") },
{ "kodi", ("shell monkey -p org.xbmc.kodi 1", "shell am force-stop org.xbmc.kodi") },
{ "criterion", ("shell monkey -p com.criterionchannel 1", "shell am force-stop com.criterionchannel") },
{ "pbs", ("shell monkey -p com.pbs.video 1", "shell am force-stop com.pbs.video") },
{ "kanopy", ("shell monkey -p com.kanopy.tvapp 1", "shell am force-stop com.kanopy.tvapp") },
{ "puffin_browser", ("shell monkey -p com.cloudmosa.puffinTV 1", "shell am force-stop com.cloudmosa.puffinTV") },
{ "remote_locator", ("shell monkey -p com.nvidia.remotelocator 1", "shell am force-stop com.nvidia.remotelocator") },
{ "amazon_video", ("shell am start -n com.amazon.amazonvideo.livingroom/com.amazon.ignition.IgnitionActivity", "shell am force-stop com.amazon.amazonvideo.livingroom") },
{ "amazon_music", ("shell am start -n com.amazon.music.tv/com.amazon.music.MainActivity", "shell am force-stop com.amazon.music.tv") },
{ "appletv+", ("shell am start -n com.apple.atve.androidtv.appletv/.MainActivity", "shell am force-stop com.apple.atve.androidtv.appletv") },
{ "movies_anywhere", ("shell am start -n com.moviesanywhere.goo/com.disney.brooklyn.tv.main.DeepLinkActivity", "shell am force-stop com.moviesanywhere.goo") },
{ "vimeo", ("shell am start -n com.vimeo.android.videoapp/.core.MainActivity", "shell am force-stop com.vimeo.android.videoapp") },
{ "vudu", ("shell am start -n air.com.vudu.air.DownloaderTablet/.TvMainActivity", "shell am force-stop air.com.vudu.air.DownloaderTablet") }
};

return _apps;
}
}

public static void RunCmd(string IP, string cmd, string param)
{
ExecuteCmd($"connect {IP}:5555", "");
ExecuteCmd(cmd, param);
}

private static void ExecuteCmd(string cmd, string param)
{
string arguments = cmd;

if (cmd.StartsWith("KEYCODE"))
{
arguments = $"shell input keyevent {cmd}";
}
else if (cmd == "start")
{
if (Apps.TryGetValue(param, out (string, string) appcmd))
{
arguments = appcmd.Item1;
}
else if(param.Contains("/"))
{
arguments = $"shell am start -n {param}";
}
else
{
arguments = $"shell monkey -p {param} 1";
}

}
else if (cmd == "stop")
{
if (Apps.TryGetValue(param, out (string, string) appcmd))
{
arguments = appcmd.Item2;
}
else
{
arguments = $"shell am force-stop {param}";
}
}

try
{
Process process = new Process();

process.StartInfo.FileName = Path.Combine(ConfigHelper.WorkingPath, "adb.exe");
process.StartInfo.Arguments = arguments;

process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;

process.Start();
process.WaitForExit();
}
catch
{
if(ConfigHelper.CheckRegKey(@"SOFTWARE\HTWebRemote", "ShowErrors"))
{
MessageBox.Show($"Unable to locate: {Path.Combine(ConfigHelper.WorkingPath, "adb.exe")}", "Error");
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Net.Sockets;
using System.Text;

namespace HTPCRemote.Devices.Controllers
namespace HTWebRemote.Devices.Controllers
{
class OppoControl
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.IO.Ports;
using System.Windows.Forms;

namespace HTPCRemote.Devices.Controllers
namespace HTWebRemote.Devices.Controllers
{
class RS232Control
{
Expand Down
Loading

0 comments on commit 039ad28

Please sign in to comment.