Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Net.Sockets;
- using System.Reflection;
- using System.Runtime.InteropServices;
- using System.Runtime.Serialization.Formatters.Binary;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using MiscUtil;
- namespace RemoteControl
- {
- class Program
- {
- static void Main(string[] args)
- {
- //Spam A
- while (true)
- {
- Console.WriteLine("Send Key");
- //Send Input
- SendInput("192.168.1.15", Keys.A, 50).GetAwaiter().GetResult();
- //Free Input
- SendInput("192.168.1.15", Keys.None, 50).GetAwaiter().GetResult();
- }
- //Console.ReadKey();
- }
- public class Keys
- {
- public const uint None = 0;
- public const uint A = 1;
- public const uint B = 1 << 1;
- public const uint X = 1 << 2;
- public const uint Y = 1 << 3;
- public const uint LEFT_STICK = 1 << 4;
- public const uint RIGHT_STICK = 1 << 5;
- public const uint L = 1 << 6;
- public const uint R = 1 << 7;
- public const uint ZL = 1 << 8;
- public const uint ZR = 1 << 9;
- public const uint PLUS = 1 << 10;
- public const uint MINUS = 1 << 11;
- public const uint DPAD_LEFT = 1 << 12;
- public const uint DOWN_UP = 1 << 13;
- public const uint DPAD_RIGHT = 1 << 14;
- public const uint DPAD_DOWN = 1 << 15;
- public const uint LEFT_ANALOG_LEFT = 1 << 16;
- public const uint LEFT_ANALOG_UP = 1 << 17;
- public const uint LEFT_ANALOG_RIGHT = 1 << 18;
- public const uint LEFT_ANALOG_DOWN = 1 << 19;
- public const uint RIGHT_ANALOG_LEFT = 1 << 20;
- public const uint RIGHT_ANALOG_UP = 1 << 21;
- public const uint RIGHT_ANALOG_RIGHT = 1 << 22;
- public const uint RIGHT_ANALOG_DOWN = 1 << 23;
- public const uint SL = 1 << 24;
- public const uint SR = 1 << 25;
- }
- private static uint get_key_state(uint Key, int Status)
- {
- uint Out = 0;
- if (Status >= 0)
- {
- Out |= Key;
- }
- else
- {
- Out &= ~Key;
- }
- return Out;
- }
- public static async Task SendInput(string host, uint Key, int Delay)
- {
- var client = new UdpClient();
- IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(host), 8080); // Build a UDP Socket
- MemoryStream stream = new MemoryStream(26);
- using (BinaryWriter writer = new BinaryWriter(stream))
- {
- writer.Write((UInt16)0x3275); // Magic
- writer.Write((UInt64)get_key_state(Key, 0)); //pressed Key(s)
- writer.Write((Int16)0); // Left Stick X Axis
- writer.Write((Int16)0); // Left Stick Y Axis
- writer.Write((Int16)0); // Right Stick X Axis
- writer.Write((Int16)0); // Right Stick Y Axis
- client.Send(stream.ToArray(), (int)stream.Length, endpoint); // Send Input
- }
- await Task.Delay(Delay); // Delay
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement