Skip to content

Commit

Permalink
first checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
btastic committed Oct 7, 2014
1 parent dae5548 commit 0e06907
Show file tree
Hide file tree
Showing 5 changed files with 417 additions and 0 deletions.
20 changes: 20 additions & 0 deletions adb remote.sln
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions adb remote/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
297 changes: 297 additions & 0 deletions adb remote/Program.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
36 changes: 36 additions & 0 deletions adb remote/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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")]
Loading

0 comments on commit 0e06907

Please sign in to comment.