terraria-source-code/Terraria/keyBoardInput.cs
TheVamp 0462173018 Version 1.2.0.3.1
Decompiled with IlSpy
Fixes Source Code
2013-10-12 11:25:17 +02:00

41 lines
966 B
C#

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Terraria
{
public class keyBoardInput
{
public class inKey : IMessageFilter
{
public bool PreFilterMessage(ref Message m)
{
if (m.Msg == 258)
{
char c = (char)((int)m.WParam);
Console.WriteLine(c);
if (keyBoardInput.newKeyEvent != null)
{
keyBoardInput.newKeyEvent(c);
}
}
else
{
if (m.Msg == 256)
{
IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(m));
Marshal.StructureToPtr(m, intPtr, true);
keyBoardInput.TranslateMessage(intPtr);
}
}
return false;
}
}
public static event Action<char> newKeyEvent;
[DllImport("user32.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Auto)]
public static extern bool TranslateMessage(IntPtr message);
static keyBoardInput()
{
Application.AddMessageFilter(new keyBoardInput.inKey());
}
}
}