Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Blish HUD/Common/Gw2/GuildWarsControls.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Blish_HUD.Common.Gw2 {
public enum GuildWarsControls {
None,
SwapWeapons,
WeaponSkill1,
WeaponSkill2,
WeaponSkill3,
WeaponSkill4,
WeaponSkill5,
HealingSkill,
UtilitySkill1,
UtilitySkill2,
UtilitySkill3,
EliteSkill,
ProfessionSkill1,
ProfessionSkill2,
ProfessionSkill3,
ProfessionSkill4,
ProfessionSkill5,
SpecialAction
}
}
2 changes: 2 additions & 0 deletions Blish HUD/Controls/Extern/HardwareInput.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using System.Runtime.InteropServices;

namespace Blish_HUD.Controls.Extern
{
[Obsolete("HardwareInput is obsolete.", true)]
[StructLayout(LayoutKind.Sequential)]
internal struct HardwareInput
{
Expand Down
2 changes: 2 additions & 0 deletions Blish HUD/Controls/Extern/Input.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using System.Runtime.InteropServices;

namespace Blish_HUD.Controls.Extern
{
[Obsolete("Input is obsolete.", true)]
[StructLayout(LayoutKind.Sequential)]
internal struct Input
{
Expand Down
3 changes: 3 additions & 0 deletions Blish HUD/Controls/Extern/InputType.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;

namespace Blish_HUD.Controls.Extern
{
[Obsolete("InputType is obsolete.", true)]
internal enum InputType : uint
{
MOUSE = 0,
Expand Down
2 changes: 2 additions & 0 deletions Blish HUD/Controls/Extern/InputUnion.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using System.Runtime.InteropServices;

namespace Blish_HUD.Controls.Extern
{
[Obsolete("InputUnion is obsolete.", true)]
[StructLayout(LayoutKind.Explicit)]
internal struct InputUnion
{
Expand Down
1 change: 1 addition & 0 deletions Blish HUD/Controls/Extern/KeyEventF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Blish_HUD.Controls.Extern
{
[Obsolete("KeyEventF is obsolete.", true)]
[Flags]
internal enum KeyEventF : uint
{
Expand Down
1 change: 1 addition & 0 deletions Blish HUD/Controls/Extern/KeybdInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Blish_HUD.Controls.Extern
{
[Obsolete("KeybdInput is obsolete.", true)]
[StructLayout(LayoutKind.Sequential)]
internal struct KeybdInput
{
Expand Down
1 change: 1 addition & 0 deletions Blish HUD/Controls/Extern/MouseEventF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Blish_HUD.Controls.Extern
{
[Obsolete("MouseEventF is obsolete.", true)]
[Flags]
internal enum MouseEventF : uint
{
Expand Down
1 change: 1 addition & 0 deletions Blish HUD/Controls/Extern/MouseInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Blish_HUD.Controls.Extern
{
[Obsolete("MouseInput is obsolete.", true)]
[StructLayout(LayoutKind.Sequential)]
internal struct MouseInput
{
Expand Down
3 changes: 2 additions & 1 deletion Blish HUD/Controls/Extern/PInvoke.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Blish_HUD.Controls.Extern
{
[Obsolete("POINT is obsolete.", true)]
/// <summary>
/// Struct representing a point.
/// </summary>
Expand All @@ -16,7 +17,7 @@ public static implicit operator Point(POINT point) {
return new Point(point.X, point.Y);
}
}

[Obsolete("PInvoke is obsolete.", true)]
internal static class PInvoke {
[DllImport("user32.dll")]
internal static extern uint SendInput(uint nInputs, [MarshalAs(UnmanagedType.LPArray), In] Input[] pInputs, int cbSize);
Expand Down
3 changes: 3 additions & 0 deletions Blish HUD/Controls/Extern/ScanCodeShort.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;

namespace Blish_HUD.Controls.Extern
{
[Obsolete("ScanCodeShort is obsolete.", true)]
internal enum ScanCodeShort : short
{
LBUTTON = 0,
Expand Down
3 changes: 3 additions & 0 deletions Blish HUD/Controls/Extern/VirtualKeyShort.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;

namespace Blish_HUD.Controls.Extern
{
[Obsolete("VirtualKeyShort is obsolete. Please use Keys instead.", true)]
public enum VirtualKeyShort : short
{
///<summary>
Expand Down
5 changes: 4 additions & 1 deletion Blish HUD/Controls/Intern/GuildWarsControls.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace Blish_HUD.Controls.Intern
using System;

namespace Blish_HUD.Controls.Intern
{
[Obsolete("Controls.Intern.GuildWarsControls is obsolete. Please use Common.Gw2.GuildWarsControls instead.", true)]
public enum GuildWarsControls
{
None,
Expand Down
2 changes: 2 additions & 0 deletions Blish HUD/Controls/Intern/Keyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Blish_HUD.Controls.Extern;
namespace Blish_HUD.Controls.Intern
{
[Obsolete("Keyboard is obsolete. Please use KeyboardUtil instead.", true)]
public static class Keyboard
{
private const uint WM_KEYDOWN = 0x0100;
Expand Down Expand Up @@ -179,6 +180,7 @@ public static void Stroke(VirtualKeyShort key, bool sendToSystem = false)
Release(key, sendToSystem);
}
}
[Obsolete("Controls.Intern.ExtraKeyInfo is obsolete. Please use ExtraKeyInfo instead.", true)]
class ExtraKeyInfo
{
public ushort repeatCount;
Expand Down
2 changes: 2 additions & 0 deletions Blish HUD/Controls/Intern/Mouse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
using Blish_HUD.Controls.Extern;
namespace Blish_HUD.Controls.Intern
{
[Obsolete("Controls.Intern.MouseButton is obsolete. Please use MouseButton instead.", true)]
public enum MouseButton
{
LEFT,
RIGHT,
MIDDLE,
XBUTTON
}
[Obsolete("Mouse is obsolete. Please use MouseUtil instead.", true)]
public static class Mouse
{
private const uint WM_MOUSEWHEEL = 0x020A;
Expand Down
36 changes: 17 additions & 19 deletions Blish HUD/GameServices/GameIntegrationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using Blish_HUD.Controls.Extern;
using Blish_HUD.Controls.Intern;
using Blish_HUD.GameIntegration;
using Blish_HUD.Settings;
using Microsoft.Xna.Framework;
Expand Down Expand Up @@ -164,11 +162,11 @@ await ClipboardUtil.WindowsClipboardService.SetTextAsync(message)
else
Task.Run(() => {
Focus();
Keyboard.Press(VirtualKeyShort.LCONTROL, true);
Keyboard.Stroke(VirtualKeyShort.KEY_V, true);
KeyboardUtil.Press(0xA2, true);
KeyboardUtil.Stroke(0x56, true);
Thread.Sleep(50);
Keyboard.Release(VirtualKeyShort.LCONTROL, true);
Keyboard.Stroke(VirtualKeyShort.RETURN);
KeyboardUtil.Release(0xA2, true);
KeyboardUtil.Stroke(0x0D);
}).ContinueWith(result => {
if (result.IsFaulted) {
Logger.Warn(result.Exception, "Failed to send message {message}", message);
Expand All @@ -191,10 +189,10 @@ await ClipboardUtil.WindowsClipboardService.SetTextAsync(text)
else
Task.Run(() => {
Focus();
Keyboard.Press(VirtualKeyShort.LCONTROL, true);
Keyboard.Stroke(VirtualKeyShort.KEY_V, true);
KeyboardUtil.Press(0xA2, true);
KeyboardUtil.Stroke(0x56, true);
Thread.Sleep(50);
Keyboard.Release(VirtualKeyShort.LCONTROL, true);
KeyboardUtil.Release(0xA2, true);
}).ContinueWith(result => {
if (result.IsFaulted) {
Logger.Warn(result.Exception, "Failed to paste {text}", text);
Expand All @@ -210,11 +208,11 @@ public async Task<string> GetInputText() {
byte[] prevClipboardContent = await ClipboardUtil.WindowsClipboardService.GetAsUnicodeBytesAsync();
await Task.Run(() => {
Focus();
Keyboard.Press(VirtualKeyShort.LCONTROL, true);
Keyboard.Stroke(VirtualKeyShort.KEY_A, true);
Keyboard.Stroke(VirtualKeyShort.KEY_C, true);
KeyboardUtil.Press(0xA2, true);
KeyboardUtil.Stroke(0x41, true);
KeyboardUtil.Stroke(0x43, true);
Thread.Sleep(50);
Keyboard.Release(VirtualKeyShort.LCONTROL, true);
KeyboardUtil.Release(0xA2, true);
Unfocus();
});
string inputText = await ClipboardUtil.WindowsClipboardService.GetTextAsync()
Expand All @@ -231,22 +229,22 @@ public void Clear() {
if (IsBusy()) return;
Task.Run(() => {
Focus();
Keyboard.Press(VirtualKeyShort.LCONTROL, true);
Keyboard.Stroke(VirtualKeyShort.KEY_A, true);
KeyboardUtil.Press(0xA2, true);
KeyboardUtil.Stroke(0x41, true);
Thread.Sleep(50);
Keyboard.Release(VirtualKeyShort.LCONTROL, true);
Keyboard.Stroke(VirtualKeyShort.BACK);
KeyboardUtil.Release(0xA2, true);
KeyboardUtil.Stroke(0x08);
Unfocus();
});
}

private void Focus() {
Unfocus();
Keyboard.Stroke(VirtualKeyShort.RETURN);
KeyboardUtil.Stroke(0x0D);
}

private void Unfocus() {
Mouse.Click(MouseButton.LEFT, Graphics.GraphicsDevice.Viewport.Width / 2, 0);
MouseUtil.Click(0, Graphics.GraphicsDevice.Viewport.Width / 2, 0);
}

private bool IsTextValid(string text) {
Expand Down
32 changes: 32 additions & 0 deletions Blish HUD/GameServices/Input/WinApi/Input.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Runtime.InteropServices;
namespace Blish_HUD.Input.WinApi {
[StructLayout(LayoutKind.Sequential)]
internal struct Input {
internal InputType type;
internal InputUnion U;
internal static int Size => Marshal.SizeOf(typeof(Input));
}

internal enum InputType : uint {
MOUSE = 0,
KEYBOARD = 1,
HARDWARE = 2
}

[StructLayout(LayoutKind.Explicit)]
internal struct InputUnion {
[FieldOffset(0)]
internal MouseUtil.MouseInput mi;
[FieldOffset(0)]
internal KeyboardUtil.KeybdInput ki;
[FieldOffset(0)]
internal HardwareInput hi;
}

[StructLayout(LayoutKind.Sequential)]
internal struct HardwareInput {
internal int uMsg;
internal short wParamL;
internal short wParamH;
}
}
Loading