From 0e0690768b7a53bb97569f24138fa95fc143a2c0 Mon Sep 17 00:00:00 2001 From: btastic Date: Tue, 7 Oct 2014 16:11:49 +0200 Subject: [PATCH] first checkin --- adb remote.sln | 20 ++ adb remote/App.config | 6 + adb remote/Program.cs | 297 ++++++++++++++++++++++++++ adb remote/Properties/AssemblyInfo.cs | 36 ++++ adb remote/adb remote.csproj | 58 +++++ 5 files changed, 417 insertions(+) create mode 100644 adb remote.sln create mode 100644 adb remote/App.config create mode 100644 adb remote/Program.cs create mode 100644 adb remote/Properties/AssemblyInfo.cs create mode 100644 adb remote/adb remote.csproj diff --git a/adb remote.sln b/adb remote.sln new file mode 100644 index 0000000..d9d3518 --- /dev/null +++ b/adb remote.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "adb remote", "adb remote\adb remote.csproj", "{6F0FC5C4-53D5-4B6C-AFA5-F589184D437B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6F0FC5C4-53D5-4B6C-AFA5-F589184D437B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6F0FC5C4-53D5-4B6C-AFA5-F589184D437B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6F0FC5C4-53D5-4B6C-AFA5-F589184D437B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6F0FC5C4-53D5-4B6C-AFA5-F589184D437B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/adb remote/App.config b/adb remote/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/adb remote/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/adb remote/Program.cs b/adb remote/Program.cs new file mode 100644 index 0000000..1d28dfc --- /dev/null +++ b/adb remote/Program.cs @@ -0,0 +1,297 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace adb_remote +{ + class Program + { + static string IPAddress = "192.168.178.60"; + + static void Main(string[] args) + { + if (IPAddress == string.Empty) + { + Console.Write("Welcome.\r\nPlease enter the IP Address of the ADB Device: "); + IPAddress = Console.ReadLine(); + } + adbCommand("kill-server"); + adbCommand("start-server"); + adbCommand("connect " + IPAddress); + + while (true) + { + Console.Clear(); + PrintMainMenu(); + + ConsoleKeyInfo cki; + cki = Console.ReadKey(); + + switch (cki.Key) + { + case ConsoleKey.D1: + RemoteControlMode(); + break; + + case ConsoleKey.D2: + ADBMode(); + break; + + case ConsoleKey.D3: + ExitApplication(); + break; + + default: + PrintMainMenu(); + break; + } + } + + } + + static void adbCommand(string adbCommand) + { + var p = new Process(); + p.StartInfo = new ProcessStartInfo("adb", adbCommand) + { + UseShellExecute = false + }; + p.Start(); + p.WaitForExit(); + + } + + static void PrintMainMenu() + { + Console.WriteLine("Connected to: " + IPAddress); + Console.WriteLine("--------------------------------"); + Console.WriteLine("1) Remote Control"); + Console.WriteLine("2) ADB Mode"); + Console.WriteLine("3) Exit"); + } + + static void ADBMode() + { + Console.Clear(); + Console.WriteLine("ADB Mode (F5 for Mainmenu)"); + + bool getOut = false; + while (!getOut) + { + ConsoleKeyInfo cki = Console.ReadKey(); + if (cki.Key != ConsoleKey.F5) + { + string command = Console.ReadLine(); + adbCommand(command); + } + else + { + getOut = true; + } + + } + } + + static void RemoteControlMode() + { + Console.Clear(); + Console.WriteLine("Remote Control Mode (F5 for Mainmenu)"); + + bool getOut = false; + while (!getOut) + { + ConsoleKeyInfo cki = Console.ReadKey(); + + switch (cki.Key) + { + case ConsoleKey.UpArrow: + adbCommand("shell input keyevent 19"); + break; + case ConsoleKey.DownArrow: + adbCommand("shell input keyevent 20"); + break; + case ConsoleKey.LeftArrow: + adbCommand("shell input keyevent 21"); + break; + case ConsoleKey.RightArrow: + adbCommand("shell input keyevent 22"); + break; + case ConsoleKey.Escape: + adbCommand("shell input keyevent 3"); + break; + case ConsoleKey.Backspace: + adbCommand("shell input keyevent 4"); + break; + case ConsoleKey.Enter: + adbCommand("shell input keyevent 66"); + break; + + case ConsoleKey.A: + adbCommand("shell input keyevent 29"); + break; + + case ConsoleKey.B: + adbCommand("shell input keyevent 30"); + break; + + case ConsoleKey.C: + adbCommand("shell input keyevent 31"); + break; + + case ConsoleKey.D: + adbCommand("shell input keyevent 32"); + break; + + case ConsoleKey.E: + adbCommand("shell input keyevent 33"); + break; + + case ConsoleKey.F: + adbCommand("shell input keyevent 34"); + break; + + case ConsoleKey.G: + adbCommand("shell input keyevent 35"); + break; + + case ConsoleKey.H: + adbCommand("shell input keyevent 36"); + break; + + case ConsoleKey.I: + adbCommand("shell input keyevent 37"); + break; + + case ConsoleKey.J: + adbCommand("shell input keyevent 38"); + break; + + case ConsoleKey.K: + adbCommand("shell input keyevent 39"); + break; + + case ConsoleKey.L: + adbCommand("shell input keyevent 40"); + break; + + case ConsoleKey.M: + adbCommand("shell input keyevent 41"); + break; + + case ConsoleKey.N: + adbCommand("shell input keyevent 42"); + break; + + case ConsoleKey.O: + adbCommand("shell input keyevent 43"); + break; + + case ConsoleKey.P: + adbCommand("shell input keyevent 44"); + break; + + case ConsoleKey.Q: + adbCommand("shell input keyevent 45"); + break; + + case ConsoleKey.R: + adbCommand("shell input keyevent 46"); + break; + + case ConsoleKey.S: + adbCommand("shell input keyevent 47"); + break; + + case ConsoleKey.T: + adbCommand("shell input keyevent 48"); + break; + + case ConsoleKey.U: + adbCommand("shell input keyevent 49"); + break; + + case ConsoleKey.V: + adbCommand("shell input keyevent 50"); + break; + + case ConsoleKey.W: + adbCommand("shell input keyevent 51"); + break; + + case ConsoleKey.X: + adbCommand("shell input keyevent 52"); + break; + + case ConsoleKey.Y: + adbCommand("shell input keyevent 53"); + break; + + case ConsoleKey.Z: + adbCommand("shell input keyevent 54"); + break; + + case ConsoleKey.D0: + adbCommand("shell input keyevent 7"); + break; + + case ConsoleKey.D1: + adbCommand("shell input keyevent 8"); + break; + + case ConsoleKey.D2: + adbCommand("shell input keyevent 9"); + break; + + case ConsoleKey.D3: + adbCommand("shell input keyevent 10"); + break; + + case ConsoleKey.D4: + adbCommand("shell input keyevent 11"); + break; + + case ConsoleKey.D5: + adbCommand("shell input keyevent 12"); + break; + + case ConsoleKey.D6: + adbCommand("shell input keyevent 13"); + break; + + case ConsoleKey.D7: + adbCommand("shell input keyevent 14"); + break; + + case ConsoleKey.D8: + adbCommand("shell input keyevent 15"); + break; + + case ConsoleKey.D9: + adbCommand("shell input keyevent 16"); + break; + + case ConsoleKey.OemPeriod: + adbCommand("shell input keyevent 56"); + break; + + case ConsoleKey.OemComma: + adbCommand("shell input keyevent 55"); + break; + case ConsoleKey.F5: + getOut = true; + break; + } + } + } + + static void ExitApplication() + { + adbCommand("disconnect"); + adbCommand("kill-server"); + Environment.Exit(0); + } + } +} diff --git a/adb remote/Properties/AssemblyInfo.cs b/adb remote/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..da902f5 --- /dev/null +++ b/adb remote/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("adb remote")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("adb remote")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("110c2b07-93a9-4725-b5a8-3ac78d03caa9")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/adb remote/adb remote.csproj b/adb remote/adb remote.csproj new file mode 100644 index 0000000..be87413 --- /dev/null +++ b/adb remote/adb remote.csproj @@ -0,0 +1,58 @@ + + + + + Debug + AnyCPU + {6F0FC5C4-53D5-4B6C-AFA5-F589184D437B} + Exe + Properties + adb_remote + adb remote + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file