From 5b9a6c5b4ab9129bb69ec57c32e0722e343cf374 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Fri, 18 Aug 2017 00:31:39 +0200 Subject: [PATCH] Fixed /c alias (hopefully) Updated readme a while ago Deleted CSharp part a while ago --- README.md | 30 ++- VirtualComputer/plugin.yml | 2 +- .../src/sznp/virtualcomputer/PluginMain.java | 78 +++++--- VirtualComputerSender.sln | 28 --- VirtualComputerSender/App.config | 6 - VirtualComputerSender/Computer.cs | 145 -------------- VirtualComputerSender/Form1.Designer.cs | 59 ------ VirtualComputerSender/Form1.cs | 32 ---- VirtualComputerSender/Form1.resx | 120 ------------ VirtualComputerSender/MCFrameBuffer.cs | 179 ------------------ VirtualComputerSender/MouseBS.cs | 19 -- VirtualComputerSender/NetFrameBuffer.cs | 178 ----------------- VirtualComputerSender/Program.cs | 22 --- .../Properties/AssemblyInfo.cs | 36 ---- .../Properties/Resources.Designer.cs | 63 ------ .../Properties/Resources.resx | 117 ------------ .../Properties/Settings.Designer.cs | 26 --- .../Properties/Settings.settings | 7 - .../VirtualComputerSender.csproj | 159 ---------------- VirtualComputerSender/VirtualKeys.cs | 129 ------------- 20 files changed, 60 insertions(+), 1375 deletions(-) delete mode 100644 VirtualComputerSender.sln delete mode 100644 VirtualComputerSender/App.config delete mode 100644 VirtualComputerSender/Computer.cs delete mode 100644 VirtualComputerSender/Form1.Designer.cs delete mode 100644 VirtualComputerSender/Form1.cs delete mode 100644 VirtualComputerSender/Form1.resx delete mode 100644 VirtualComputerSender/MCFrameBuffer.cs delete mode 100644 VirtualComputerSender/MouseBS.cs delete mode 100644 VirtualComputerSender/NetFrameBuffer.cs delete mode 100644 VirtualComputerSender/Program.cs delete mode 100644 VirtualComputerSender/Properties/AssemblyInfo.cs delete mode 100644 VirtualComputerSender/Properties/Resources.Designer.cs delete mode 100644 VirtualComputerSender/Properties/Resources.resx delete mode 100644 VirtualComputerSender/Properties/Settings.Designer.cs delete mode 100644 VirtualComputerSender/Properties/Settings.settings delete mode 100644 VirtualComputerSender/VirtualComputerSender.csproj delete mode 100644 VirtualComputerSender/VirtualKeys.cs diff --git a/README.md b/README.md index da5778f..5fa7b81 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # The Computer -A working modern computer in Minecraft made using VirtualBox, jni4net, C# and Java. No clientside mods required. +A working modern computer in Minecraft made using VirtualBox and Java. No clientside mods required. I started working on this project on 2015. december 5. However I did not write much code in that time as I had to figure out how things work. I plan on making a series where I show the whole process of creating this project. @@ -14,30 +14,28 @@ I plan on making a series where I show the whole process of creating this projec ### Currently compiled for (and tested on): *If you don't meet these requirements, you will need to compile the files for yourself. Please help by sending the compiled version to me so more people can download it.* -* Windows 7 64-bit -* VirtualBox 5 -* Spgiot/Bukkit 1.8/1.9 (with Movecraft for the mouse craft type) -* Microsoft .NET Framework 4.5 +* OS X +* VirtualBox 5.1 +* Spgiot/Bukkit 1.8/1.9/1.12 * Java 8 ### Possibly works with (untested): -* Any version of Windows which supports .NET 4.5 +* Any operating system which is not Windows * Other VirtualBox versions (code modifications are probably necessary) * Other Spigot/Bukkit versions * Microsoft .NET Framework 4 (code modifications *are* necessary) * Other Java versions -*Due to jni4net support limitations the plugin does not support other operating systems.* +*Due to VirtualBox Java binding support limitations the plugin does not support Windows currently.* ## Installation -**Warning:** The first loaded world on the server (the one specified in server.properties) will **lose** the first 20 maps, though it might be only a temporary effect, it might restore after the server starts up without the plugin. *(Untested.)* +**Warning:** The first loaded world on the server (the one specified in server.properties) will temporarily **lose** the first 20 maps, although it will reset if the server is loaded without the plugin. * Install all the requirements * Add a virtual PC if you don't have any (the first one will be started) * Install an OS and Guest Additions, if you haven't already * Put the jar file into /plugins directory -* Put the dll file into /plugins/VirtualComputer directory - if it doesn't exist, create it -* Make sure your server is set to a world that you don't mind your maps deleted from +* Make sure your server is set to a world that you don't mind your maps temporarily deleted from * Start your server ## Usage @@ -55,22 +53,18 @@ Where you'll need to increment 0 for each map. It is also recommended to start the virtual machine first so you can distinguish the different parts of the display while placing it. #### Keyboard -You can either open the chat keyboard using /computer input key, or you can use /computer key \. You can find key names [here](https://github.com/NorbiPeti/VirtualComputer/blob/master/VirtualComputerSender/VirtualKeys.cs). Note that not all keys are currently supported. +You can either open the chat keyboard using /computer input key, or you can use /computer key \. You can find key names [here](https://github.com/NorbiPeti/VirtualComputer/blob/directvb/VirtualComputer/src/sznp/virtualcomputer/Scancode.java). #### Mouse You can "lock" the physical mouse to the virtual one with /computer input mouse, or you can move the mouse (including scrolling) with /computer mouse \ \ \ \, where dx specifies the amount of pixels to move right, and dy specifies the amount of pixels to move down, while dz and dw specify the scrolling vertically (positive values scroll down) and horizontally. To set the locked mouse speed, use /computer input mspeed \. The difference in look position will be multiplied with this number. Recommended values are between 1 and 10 (inclusive). Default: 1. -You can also use the "mouse" Movecraft craft type to move the mouse, though it's a bit unreliable. - You can press a mouse button with /computer mouse . For example: /computer mouse leftbutton. You can find all the button names [here](https://github.com/NorbiPeti/VirtualComputer/blob/master/VirtualComputerSender/MouseBS.cs). #### Sounds -Due to the way it works, it automatically plays every sound from the virtual machine **on the host computer**. This is built into VBoxHeadless, it seems. In order to make the sounds play for every connected player, we'd need a clientside mod. +Due to the way it works, it automatically plays every sound from the virtual machine **on the host computer**. This is built into the VM, it seems. In order to make the sounds play for every connected player, we'd need a clientside mod. ### Special thanks: -* The creators of VirtualBox for making it open-source and easy to use (though I had minor issues but those was because .NET had a few marshaling errors with booleans and that I needed to learn how machines work - especially keyboards) -* The creators of jni4net, after I figured it out, it was quite easy to use -* Minecraft player iie for testing and suggesting the Movecraft mouse and other ideas not related to this project -* The creator(s) of SketchMap, a plugin which I edited to create the display +* The creators of VirtualBox for making it open-source and kind of easy to use (though I had minor issues as the documentation doesn't really tell me how to write a new frontend :P and that I needed to learn how machines work - especially keyboards) +* @iiegit for testing and more testing for the non-Windows version diff --git a/VirtualComputer/plugin.yml b/VirtualComputer/plugin.yml index cc1c5b0..3114d8d 100644 --- a/VirtualComputer/plugin.yml +++ b/VirtualComputer/plugin.yml @@ -4,4 +4,4 @@ version: 2.0 commands: computer: usage: Use /computer start|stop|reset|key|mouse|input|fix - alias: c + aliases: c diff --git a/VirtualComputer/src/sznp/virtualcomputer/PluginMain.java b/VirtualComputer/src/sznp/virtualcomputer/PluginMain.java index f3ef14a..6e66d0c 100644 --- a/VirtualComputer/src/sznp/virtualcomputer/PluginMain.java +++ b/VirtualComputer/src/sznp/virtualcomputer/PluginMain.java @@ -82,6 +82,7 @@ public class PluginMain extends JavaPlugin { session.setName("minecraft"); // machine.launchVMProcess(session, "headless", "").waitForCompletion(10000); - This creates a *process*, we don't want that anymore machine.lockMachine(session, LockType.VM); // We want the machine inside *our* process <-- Need the VM type to have console access + sender.sendMessage("A: " + machine.getState().toString()); screenupdatetask = Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> { if (session.getState() != SessionState.Locked) // https://www.virtualbox.org/sdkref/_virtual_box_8idl.html#ac82c179a797c0d7c249d1b98a8e3aa8f return; // "This state also occurs as a short transient state during an IMachine::lockMachine call." @@ -90,20 +91,21 @@ public class PluginMain extends JavaPlugin { screenupdatetask = null; } machine = session.getMachine(); // This is the Machine object we can work with - /* - * if (session == null) System.out.println("Session is null"); final IConsole console = session.getConsole(); if (console == null) System.out.println("Console is null"); final - * IProgress powerUp = console.powerUp(); if (powerUp == null) System.out.println("Progess is null"); powerUp.waitForCompletion(10000); - * System.out.println("I DON'T FKIN KNOW WHAT'S NULL - Okay so Console's null as I guessed"); System.out.println("Okay, actually it's good news if this shows."); - */ final IConsole console = session.getConsole(); + sender.sendMessage("1: " + console.getState().toString()); + console.powerUp().waitForCompletion(10000); + sender.sendMessage("2: " + console.getState().toString()); console.getDisplay().attachFramebuffer(0L, new IFramebuffer(new MCFrameBuffer(console.getDisplay()))); + sender.sendMessage("3: " + console.getState().toString()); if (screenupdatetask == null) screenupdatetask = Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> { + sender.sendMessage("4: " + console.getState().toString()); if (session.getState().equals(SessionState.Locked) // Don't run until the machine is running && console.getState().equals(MachineState.Running)) console.getDisplay().invalidateAndUpdateScreen(0L); if (session.getState().equals(SessionState.Unlocked) // Stop if the machine stopped fully || console.getState().equals(MachineState.PoweredOff)) { + sender.sendMessage("5: " + console.getState().toString()); if (session.getState().equals(SessionState.Locked)) { session.unlockMachine(); sender.sendMessage("Computer powered off, released it."); @@ -120,6 +122,8 @@ public class PluginMain extends JavaPlugin { public static int MouseSpeed = 1; public void Stop(CommandSender sender) { + if (!checkMachineRunning(sender)) + return; sender.sendMessage("§eStopping computer..."); session.getConsole().powerDown().waitForCompletion(2000); session.unlockMachine(); @@ -143,48 +147,58 @@ public class PluginMain extends JavaPlugin { } public void Reset(CommandSender sender) { + if (!checkMachineRunning(sender)) + return; sender.sendMessage("§eResetting computer..."); - if (session.getState() == SessionState.Locked) - session.getConsole().reset(); + session.getConsole().reset(); sender.sendMessage("§eComputer reset."); } public void FixScreen(CommandSender sender) { + if (!checkMachineRunning(sender)) + return; sender.sendMessage("§eFixing screen..."); session.getConsole().getDisplay().setSeamlessMode(false); session.getConsole().getDisplay().setVideoModeHint(0L, true, false, 0, 0, 640L, 480L, 32L); sender.sendMessage("§eScreen fixed."); } + private boolean checkMachineRunning(CommandSender sender) { + if (session.getState() != SessionState.Locked || machine.getState() != MachineState.Running) { + sender.sendMessage("§cMachine isn't running."); + return false; + } + return true; + } + public void PressKey(CommandSender sender, String key, String stateorduration) { - if (session.getState() == SessionState.Locked) { - int durationorstate; - if (stateorduration.length() == 0) - durationorstate = 0; - else if (stateorduration.equalsIgnoreCase("down")) - durationorstate = -1; - else if (stateorduration.equalsIgnoreCase("up")) - durationorstate = -2; - else - durationorstate = Short.parseShort(stateorduration); - int code = 0; - // Release key scan code concept taken from VirtualBox source code (KeyboardImpl.cpp:putCAD()) - // +128 - if (durationorstate != 2) - session.getConsole().getKeyboard().putScancode(code); - Runnable sendrelease = () -> session.getConsole().getKeyboard() - .putScancodes(Lists.newArrayList(code + 128, Scancode.sc_controlLeft.Code + 128, - Scancode.sc_shiftLeft.Code + 128, Scancode.sc_altLeft.Code + 128)); - if (durationorstate == 0 || durationorstate == -2) - sendrelease.run(); - if (durationorstate > 0) { - Bukkit.getScheduler().runTaskLaterAsynchronously(this, sendrelease, durationorstate); - } + if (!checkMachineRunning(sender)) + return; + int durationorstate; + if (stateorduration.length() == 0) + durationorstate = 0; + else if (stateorduration.equalsIgnoreCase("down")) + durationorstate = -1; + else if (stateorduration.equalsIgnoreCase("up")) + durationorstate = -2; + else + durationorstate = Short.parseShort(stateorduration); + int code = 0; + // Release key scan code concept taken from VirtualBox source code (KeyboardImpl.cpp:putCAD()) + // +128 + if (durationorstate != 2) + session.getConsole().getKeyboard().putScancode(code); + Runnable sendrelease = () -> session.getConsole().getKeyboard().putScancodes(Lists.newArrayList(code + 128, + Scancode.sc_controlLeft.Code + 128, Scancode.sc_shiftLeft.Code + 128, Scancode.sc_altLeft.Code + 128)); + if (durationorstate == 0 || durationorstate == -2) + sendrelease.run(); + if (durationorstate > 0) { + Bukkit.getScheduler().runTaskLaterAsynchronously(this, sendrelease, durationorstate); } } public void UpdateMouse(CommandSender sender, int x, int y, int z, int w, String mbs, boolean down) { - if (session.getState() != SessionState.Locked) + if (!checkMachineRunning(sender)) return; int state = 0; if (mbs.length() > 0 && down) @@ -194,6 +208,8 @@ public class PluginMain extends JavaPlugin { } public void UpdateMouse(CommandSender sender, int x, int y, int z, int w, String mbs) { + if (!checkMachineRunning(sender)) + return; UpdateMouse(sender, x, y, z, w, mbs, true); UpdateMouse(sender, x, y, z, w, mbs, false); } diff --git a/VirtualComputerSender.sln b/VirtualComputerSender.sln deleted file mode 100644 index 48599ce..0000000 --- a/VirtualComputerSender.sln +++ /dev/null @@ -1,28 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.24720.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VirtualComputerSender", "VirtualComputerSender\VirtualComputerSender.csproj", "{5EF12535-ACDF-4D60-8E32-087F5A277946}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5EF12535-ACDF-4D60-8E32-087F5A277946}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5EF12535-ACDF-4D60-8E32-087F5A277946}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5EF12535-ACDF-4D60-8E32-087F5A277946}.Debug|x64.ActiveCfg = Debug|x64 - {5EF12535-ACDF-4D60-8E32-087F5A277946}.Debug|x64.Build.0 = Debug|x64 - {5EF12535-ACDF-4D60-8E32-087F5A277946}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5EF12535-ACDF-4D60-8E32-087F5A277946}.Release|Any CPU.Build.0 = Release|Any CPU - {5EF12535-ACDF-4D60-8E32-087F5A277946}.Release|x64.ActiveCfg = Release|x64 - {5EF12535-ACDF-4D60-8E32-087F5A277946}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/VirtualComputerSender/App.config b/VirtualComputerSender/App.config deleted file mode 100644 index bae5d6d..0000000 --- a/VirtualComputerSender/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/VirtualComputerSender/Computer.cs b/VirtualComputerSender/Computer.cs deleted file mode 100644 index 4dc3fc0..0000000 --- a/VirtualComputerSender/Computer.cs +++ /dev/null @@ -1,145 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using VirtualBox; - -namespace VirtualComputerSender //Copyright © NorbiPeti 2015-2016 -{ - public class Computer - { //Self-note: Don't add/edit public members - private VirtualBoxClass vbox; - private Session session; - public Computer() - { - vbox = new VirtualBoxClass(); - session = new Session(); - } - - public void Start() - { - var machine = (IMachine)vbox.Machines.GetValue(0); - var progress = machine.LaunchVMProcess(session, "headless", ""); - progress.WaitForCompletion(100000); - var fb = new MCFrameBuffer(session.Console.Display); - Screen = fb.Screen; //fb.Screen is assigned on object creation - session.Console.Display.AttachFramebuffer(0, fb); - session.Console.Display.SetSeamlessMode(0); - } - - public bool PowerButton() - { - if (session.State != SessionState.SessionState_Locked || session.Machine == null) - { - Start(); - return true; - } - else - { - session.Console.PowerButton(); - if (session.State != SessionState.SessionState_Locked) - Screen = null; - return false; - } - } - - public void PowerOff() - { - if (session.State == SessionState.SessionState_Locked) - { - session.Console.PowerDown().WaitForCompletion(10000); - Screen = null; - } - } - - public void Reset() - { - if (session.State == SessionState.SessionState_Locked) - session.Console.Reset(); - } - - private volatile int[] Screen; - - public int[] GetScreenPixelColors() - { - if (Screen == null) - { - Screen = new int[640 * 480]; - for (int i = 0; i < Screen.Length; i++) - Screen[i] = Color.Black.ToArgb(); - } - return Screen; - } - - [DllImport("user32.dll")] - static extern uint MapVirtualKey(uint uCode, uint uMapType); - - const uint MAPVK_VK_TO_VSC = 0x00; - const uint MAPVK_VSC_TO_VK = 0x01; - const uint MAPVK_VK_TO_CHAR = 0x02; - const uint MAPVK_VSC_TO_VK_EX = 0x03; - const uint MAPVK_VK_TO_VSC_EX = 0x04; - - public void PressKey(string key, short durationorstate) - { - if (session.State == SessionState.SessionState_Locked) - { - int code = 0; - if (key == "testall") - { - int x = 0; - session.Console.Keyboard.PutScancodes(new int[128].Select(i => x++).ToArray()); - return; - } - //Virtual key code taken from Kennedy.ManagedHooks project - //Release key scan code concept taken from VirtualBox source code (KeyboardImpl.cpp:putCAD()) - //+128 - code = (int)MapVirtualKey((uint)(VirtualKeys)Enum.Parse(typeof(VirtualKeys), key, true), MAPVK_VK_TO_VSC); - int codeShift = (int)MapVirtualKey((uint)VirtualKeys.ShiftLeft, MAPVK_VK_TO_VSC); - int codeCtrl = (int)MapVirtualKey((uint)VirtualKeys.ControlLeft, MAPVK_VK_TO_VSC); - int codeAlt = (int)MapVirtualKey((uint)VirtualKeys.AltLeft, MAPVK_VK_TO_VSC); - if (durationorstate != -2) //<-- 2016.02.22. - session.Console.Keyboard.PutScancode(code); - if (durationorstate == 0 || durationorstate == -2) - session.Console.Keyboard.PutScancodes(new int[] { code + 128, codeCtrl + 128, codeShift + 128, codeAlt + 128 }); - if (durationorstate > 0) - { - Timer t = new Timer(); - t.Tick += delegate - { - session.Console.Keyboard.PutScancode(code + 128); - t.Stop(); - }; - t.Interval = durationorstate; - t.Start(); - } - } - } - - public void UpdateMouse(int x, int y, int z, int w, string mbs) - { - if (session.State != SessionState.SessionState_Locked) - return; - int state = 0; - if (mbs.Length > 0) - state = (int)(MouseBS)Enum.Parse(typeof(MouseBS), mbs, true); - session.Console.Mouse.PutMouseEvent(x, y, z, w, state); - } - - public void FixScreen() - { - session.Console.Display.SetSeamlessMode(0); - session.Console.Display.SetVideoModeHint(0, 1, 0, 0, 0, 640, 480, 32); - } - - ~Computer() - { - if (session.State == SessionState.SessionState_Locked) - session.Machine.SaveState(); - } - } -} diff --git a/VirtualComputerSender/Form1.Designer.cs b/VirtualComputerSender/Form1.Designer.cs deleted file mode 100644 index dc85f9d..0000000 --- a/VirtualComputerSender/Form1.Designer.cs +++ /dev/null @@ -1,59 +0,0 @@ -namespace VirtualComputerSender -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.panel1 = new System.Windows.Forms.Panel(); - this.SuspendLayout(); - // - // panel1 - // - this.panel1.BackColor = System.Drawing.Color.Black; - this.panel1.Location = new System.Drawing.Point(12, 12); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(800, 600); - this.panel1.TabIndex = 0; - // - // Form1 - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(861, 662); - this.Controls.Add(this.panel1); - this.Name = "Form1"; - this.Text = "Form1"; - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.Panel panel1; - } -} - diff --git a/VirtualComputerSender/Form1.cs b/VirtualComputerSender/Form1.cs deleted file mode 100644 index f89f623..0000000 --- a/VirtualComputerSender/Form1.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using VirtualBox; - -namespace VirtualComputerSender //Copyright © NorbiPeti 2015-2016 -{ - public partial class Form1: Form - { - private static Form1 Instance; - public Form1() - { - Instance = this; - InitializeComponent(); - Screen = panel1.CreateGraphics(); - var vbox = new VirtualBoxClass(); - var session = new Session(); - var machine = (IMachine)vbox.Machines.GetValue(0); - var progress = machine.LaunchVMProcess(session, "headless", ""); - progress.WaitForCompletion(100000); - session.Console.Display.AttachFramebuffer(0, new NetFrameBuffer(session.Console.Display)); - } - - public static Graphics Screen; - } -} diff --git a/VirtualComputerSender/Form1.resx b/VirtualComputerSender/Form1.resx deleted file mode 100644 index 1af7de1..0000000 --- a/VirtualComputerSender/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/VirtualComputerSender/MCFrameBuffer.cs b/VirtualComputerSender/MCFrameBuffer.cs deleted file mode 100644 index ff98174..0000000 --- a/VirtualComputerSender/MCFrameBuffer.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Net; -using System.Net.Sockets; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using System.Timers; -using VirtualBox; - -namespace VirtualComputerSender //Copyright © NorbiPeti 2015-2016 -{ - public class MCFrameBuffer : IFramebuffer - { - private IDisplay Display; - private Timer LastFullUpdateTimer; - private UdpClient Client; - - public MCFrameBuffer(IDisplay display) - { - Display = display; - LastFullUpdateTimer = new Timer(); - LastFullUpdateTimer.Interval = 5000; - LastFullUpdateTimer.Elapsed += UpdateScreen; - Client = new UdpClient(); - Client.Connect(new IPEndPoint(IPAddress.Loopback, 5896)); - LastFullUpdateTimer.Start(); - } - - private void UpdateScreen(object sender, EventArgs args) - { - Display.InvalidateAndUpdateScreen(0); - } - - public IntPtr Address - { - get - { - return IntPtr.Zero; - } - } - - public const uint CBitsPerPixel = 32; - public uint BitsPerPixel - { - get - { - return CBitsPerPixel; - } - } - - public uint BytesPerLine - { - get - { - return ScreenWidth; - } - } - - public uint Height - { - get - { - Console.WriteLine("Screen height queried."); - return ScreenHeight; - } - } - - public uint HeightReduction - { - get - { - return 2; - } - } - - public IFramebufferOverlay Overlay - { - get - { - return null; - } - } - - public BitmapFormat PixelFormat - { - get - { - return BitmapFormat.BitmapFormat_RGBA; - } - } - - public uint Width - { - get - { - Console.WriteLine("Screen width queried."); - return ScreenWidth; - } - } - - public long WinId - { - get - { - return 0; - } - } - - public Array Capabilities - { - get - { - return new FramebufferCapabilities[] { FramebufferCapabilities.FramebufferCapabilities_UpdateImage }; - } - } - - public uint GetVisibleRegion(ref byte aRectangles, uint aCount) - { - throw new InvalidOperationException("This should not be used."); - } - - public void NotifyUpdate(uint aX, uint aY, uint aWidth, uint aHeight) - { - - } - - public void ProcessVHWACommand(ref byte aCommand) - { - } - - public void SetVisibleRegion(ref byte aRectangles, uint aCount) - { - } - - public int VideoModeSupported(uint aWidth, uint aHeight, uint aBpp) - { - return 1; - } - - public const int ScreenWidth = 640; - public const int ScreenHeight = 480; - - public volatile int[] Screen = new int[640 * 480]; - public void NotifyUpdateImage(uint aX, uint aY, uint aWidth, uint aHeight, Array aImage) - { - Task.Run(() => - { - var img = (byte[])aImage; - int x = 0; - for (int j = (int)aY; j < aHeight && j < ScreenHeight; j++) - { - for (int i = (int)aX; i < aWidth && i < ScreenWidth; i++) - { - if (x + 4 > aImage.Length) - return; - Screen[640 * j + i] = Color.FromArgb(img[x + 2], img[x + 1], img[x]).ToArgb(); //TODO: Touchscreen and/or left click right click forwarding - x += 4; - } - x += (int)aX * 4; - int add = ((int)(aX + aWidth) - ScreenWidth); - if (add > 0) - x += add * 4; - } - }); - } - - public void NotifyChange(uint aScreenId, uint aXOrigin, uint aYOrigin, uint aWidth, uint aHeight) - { - } - - public void Notify3DEvent(uint aType, Array aData) - { - } - } -} diff --git a/VirtualComputerSender/MouseBS.cs b/VirtualComputerSender/MouseBS.cs deleted file mode 100644 index 25992bd..0000000 --- a/VirtualComputerSender/MouseBS.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace VirtualComputerSender -{ - public enum MouseBS - { - LeftButton = 1, - MiddleButton = 4, - RightButton = 2, - WheelDown = 16, - WheelUp = 8, - XButton1 = 32, - XButton2 = 64 - } -} diff --git a/VirtualComputerSender/NetFrameBuffer.cs b/VirtualComputerSender/NetFrameBuffer.cs deleted file mode 100644 index e6b715e..0000000 --- a/VirtualComputerSender/NetFrameBuffer.cs +++ /dev/null @@ -1,178 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Net; -using System.Net.Sockets; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; -using System.Timers; -using VirtualBox; - -namespace VirtualComputerSender //Copyright © NorbiPeti 2015-2016 -{ - public class NetFrameBuffer : IFramebuffer - { - private IDisplay Display; - private Timer LastFullUpdateTimer; - private UdpClient Client; - - public NetFrameBuffer(IDisplay display) - { - //address = Marshal.AllocHGlobal(1440 * 900 * 4); - Display = display; - LastFullUpdateTimer = new Timer(); - LastFullUpdateTimer.Interval = 60000; - LastFullUpdateTimer.Elapsed += UpdateScreen; - Client = new UdpClient(); - Client.Connect(new IPEndPoint(IPAddress.Loopback, 5896)); - LastFullUpdateTimer.Start(); - } - - private void UpdateScreen(object sender, EventArgs args) - { - Display.InvalidateAndUpdateScreen(0); - } - - public IntPtr Address - { - get - { - return IntPtr.Zero; - } - } - - public const uint CBitsPerPixel = 32; - public uint BitsPerPixel - { - get - { - return CBitsPerPixel; - } - } - - public uint BytesPerLine - { - get - { - return ScreenWidth; - } - } - - public uint Height - { - get - { - return ScreenHeight; - } - } - - public uint HeightReduction - { - get - { - return 2; - } - } - - public IFramebufferOverlay Overlay - { - get - { - return null; - } - } - - public BitmapFormat PixelFormat - { - get - { - return BitmapFormat.BitmapFormat_RGBA; - } - } - - public uint Width - { - get - { - return ScreenWidth; - } - } - - public long WinId - { - get - { - return 0; - } - } - - public Array Capabilities - { - get - { - return new FramebufferCapabilities[] { FramebufferCapabilities.FramebufferCapabilities_UpdateImage }; - } - } - - public uint GetVisibleRegion(ref byte aRectangles, uint aCount) - { - throw new InvalidOperationException("This should not be used."); - } - - public void NotifyUpdate(uint aX, uint aY, uint aWidth, uint aHeight) - { - //throw new InvalidOperationException("This should not be used. (Only UpdateImage.)"); - } - - public void ProcessVHWACommand(ref byte aCommand) - { - } - - public void SetVisibleRegion(ref byte aRectangles, uint aCount) - { - } - - public int VideoModeSupported(uint aWidth, uint aHeight, uint aBpp) - { - return 1; - } - - public const int ScreenWidth = 640; - public const int ScreenHeight = 480; - - private Color[,] Screen = new Color[640, 480]; - public void NotifyUpdateImage(uint aX, uint aY, uint aWidth, uint aHeight, Array aImage) - { - var img = aImage.Cast().ToArray(); - int x = 0; - for (int j = (int)aY; j < aHeight && j < ScreenHeight; j++) - { - //for (int i = (int)aX; (j % 20 == 0 ? (i < aWidth - 1 && i < ScreenWidth - 1) : (i < aWidth && i < ScreenWidth)); i++) - for (int i = (int)aX; i < aWidth && i < ScreenWidth; i++) - { - if (x + 4 > aImage.Length) - return; - //Form1.Screen.FillRectangle(new SolidBrush(Color.FromArgb(255, img[x + 2], img[x + 1], img[x])), i, j, 1, 1); - Screen[i, j] = Color.FromArgb(img[x + 2], img[x + 1], img[x]); - //Form1.Screen.FillRectangle(new SolidBrush(Color.FromArgb(255, img[x], img[x + 1], img[x + 2])), i, j, 1, 1); - x += 4; - } - x += (int)aX * 4; - int add = ((int)(aX + aWidth) - ScreenWidth); - if (add > 0) - x += add * 4; - } - } - - public void NotifyChange(uint aScreenId, uint aXOrigin, uint aYOrigin, uint aWidth, uint aHeight) - { - } - - public void Notify3DEvent(uint aType, Array aData) - { - } - } -} diff --git a/VirtualComputerSender/Program.cs b/VirtualComputerSender/Program.cs deleted file mode 100644 index e1066d9..0000000 --- a/VirtualComputerSender/Program.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace VirtualComputerSender -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); - } - } -} diff --git a/VirtualComputerSender/Properties/AssemblyInfo.cs b/VirtualComputerSender/Properties/AssemblyInfo.cs deleted file mode 100644 index 3767f2d..0000000 --- a/VirtualComputerSender/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -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("VirtualComputerSender")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("VirtualComputerSender")] -[assembly: AssemblyCopyright("Copyright © NorbiPeti 2015-2016")] -[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("5ef12535-acdf-4d60-8e32-087f5a277946")] - -// 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/VirtualComputerSender/Properties/Resources.Designer.cs b/VirtualComputerSender/Properties/Resources.Designer.cs deleted file mode 100644 index 2d8cbf7..0000000 --- a/VirtualComputerSender/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace VirtualComputerSender.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("VirtualComputerSender.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/VirtualComputerSender/Properties/Resources.resx b/VirtualComputerSender/Properties/Resources.resx deleted file mode 100644 index af7dbeb..0000000 --- a/VirtualComputerSender/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/VirtualComputerSender/Properties/Settings.Designer.cs b/VirtualComputerSender/Properties/Settings.Designer.cs deleted file mode 100644 index ce4d32d..0000000 --- a/VirtualComputerSender/Properties/Settings.Designer.cs +++ /dev/null @@ -1,26 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace VirtualComputerSender.Properties { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - } -} diff --git a/VirtualComputerSender/Properties/Settings.settings b/VirtualComputerSender/Properties/Settings.settings deleted file mode 100644 index 3964565..0000000 --- a/VirtualComputerSender/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/VirtualComputerSender/VirtualComputerSender.csproj b/VirtualComputerSender/VirtualComputerSender.csproj deleted file mode 100644 index c576d42..0000000 --- a/VirtualComputerSender/VirtualComputerSender.csproj +++ /dev/null @@ -1,159 +0,0 @@ - - - - - Debug - AnyCPU - {5EF12535-ACDF-4D60-8E32-087F5A277946} - WinExe - Properties - VirtualComputerSender - VirtualComputerSender - v4.6.1 - 512 - true - false - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - true - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - true - ..\..\TheButtonMCAutoFlairProto\Spigot server\plugins\VirtualComputer\ - DEBUG;TRACE - full - x64 - prompt - MinimumRecommendedRules.ruleset - true - - - bin\x64\Release\ - TRACE - true - pdbonly - x64 - prompt - MinimumRecommendedRules.ruleset - true - - - - - - - - - - - - - - - - - - - - Form - - - Form1.cs - - - - - - - - - Form1.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - True - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - - - - False - Microsoft .NET Framework 4.5.2 %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 - false - - - - - {D7569351-1750-46F0-936E-BD127D5BC264} - 1 - 3 - 0 - tlbimp - False - False - - - - - \ No newline at end of file diff --git a/VirtualComputerSender/VirtualKeys.cs b/VirtualComputerSender/VirtualKeys.cs deleted file mode 100644 index 1409e65..0000000 --- a/VirtualComputerSender/VirtualKeys.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace VirtualComputerSender -{ - internal enum VirtualKeys - { - Back = 0x08, - Tab = 0x09, - Clear = 0x0C, - Return = 0x0D, - - ShiftLeft = 0xA0, - ControlLeft = 0xA2, - ShiftRight = 0xA1, - ControlRight = 0xA3, - AltLeft = 0xA4, - AltRight = 0xA5, - - Menu = 0x12, - Pause = 0x13, - Capital = 0x14, - Escape = 0x1B, - Space = 0x20, - Prior = 0x21, - Next = 0x22, - End = 0x23, - Home = 0x24, - Left = 0x25, - Up = 0x26, - Right = 0x27, - Down = 0x28, - Select = 0x29, - Print = 0x2A, - Execute = 0x2B, - Snapshot = 0x2C, - Insert = 0x2D, - Delete = 0x2E, - Help = 0x2F, - - D0 = 0x30, - D1 = 0x31, - D2 = 0x32, - D3 = 0x33, - D4 = 0x34, - D5 = 0x35, - D6 = 0x36, - D7 = 0x37, - D8 = 0x38, - D9 = 0x39, - - A = 0x41, - B = 0x42, - C = 0x43, - D = 0x44, - E = 0x45, - F = 0x46, - G = 0x47, - H = 0x48, - I = 0x49, - J = 0x4A, - K = 0x4B, - L = 0x4C, - M = 0x4D, - N = 0x4E, - O = 0x4F, - P = 0x50, - Q = 0x51, - R = 0x52, - S = 0x53, - T = 0x54, - U = 0x55, - V = 0x56, - W = 0x57, - X = 0x58, - Y = 0x59, - Z = 0x5A, - - LWindows = 0x5B, - RWindows = 0x5C, - Apps = 0x5D, - NumPad0 = 0x60, - NumPad1 = 0x61, - NumPad2 = 0x62, - NumPad3 = 0x63, - NumPad4 = 0x64, - NumPad5 = 0x65, - NumPad6 = 0x66, - NumPad7 = 0x67, - NumPad8 = 0x68, - NumPad9 = 0x69, - - Multiply = 0x6A, - Add = 0x6B, - Separator = 0x6C, - Subtract = 0x6D, - Decimal = 0x6E, - Divide = 0x6F, - F1 = 0x70, - F2 = 0x71, - F3 = 0x72, - F4 = 0x73, - F5 = 0x74, - F6 = 0x75, - F7 = 0x76, - F8 = 0x77, - F9 = 0x78, - F10 = 0x79, - F11 = 0x7A, - F12 = 0x7B, - F13 = 0x7C, - F14 = 0x7D, - F15 = 0x7E, - F16 = 0x7F, - F17 = 0x80, - F18 = 0x81, - F19 = 0x82, - F20 = 0x83, - F21 = 0x84, - F22 = 0x85, - F23 = 0x86, - F24 = 0x87, - - NumLock = 0x90, - Scroll = 0x91, - } -}