Original Post
OK, so I switched to a buffered keyboard. The codes that come in however are almost nonsensical garbage. The keys do not match up to any ASCII or Unicode chart but rather to whatever the hardware sends. So I have been mapping each letter, number, and control key (shift, enter, insert, etc.) into an array, and now I have a massive class that handles all things keyboard related. The struct for each key is as follows: Is this the best way to go about this? is there no function that will do this for me (give me the character (or string) represented by the key pressed or the keycode (as I require) that is affected by caps lock and shift as necessary)?
[source language = "c#"]
public struct OneKey
{
public enum State
{
Norm = 0,
Shift= 1
}
public bool hasChar;
public byte KeyCode;
public char [] KeyChar;
public OneKey(byte kCode,char kChar, char ShiftChar)
{
hasChar = true;
KeyCode = kCode;
KeyChar = new Char [2];
KeyChar[State.Norm] = kChar;
KeyChar[State.Shift] = ShiftChar;
}
public OneKey(byte kCode, char kChar)
{
hasChar = true;
KeyCode = kCode;
KeyChar = new Char[1];
KeyChar[State.Norm] = kChar;
}
public OneKey(byte kCode)
{
hasChar = false;
KeyCode = kCode;
}
}