public override string GetCodeStr(IKeyGetter keyGetter) { string result = string.Empty; for (int column = 0; column < Hardware.Keyboard.NumColumns; column++) { byte thisValue = 0; for (int row = 0; row < Hardware.Keyboard.NumRows; row++) { if (Hardware.Keyboard.IsValidKey(column, row)) { KeyBase xkey = keyGetter.GetKey(column, row); if (!xkey.IsDown) { continue; } KeyBase singleXkey = keyGetter.GetSingleKey(column, row); if (singleXkey != null) { thisValue += singleXkey.GetRowDataValue(); } } } result += thisValue + "."; } return(result.TrimEnd('.')); }
public override List <KeyBase> GetPressedKeys(string customData, IKeyGetter keyGetter) { List <KeyBase> keysPressed = new List <KeyBase>(); string[] columns = customData.Split('.'); for (int column = 0; column < columns.Length; column++) { int value; if (int.TryParse(columns[column], out value)) { if (value == 0) { continue; } for (int row = 0; row < Hardware.Keyboard.NumRows; row++) { byte rowMask = (byte)(Math.Pow(2, row)); if ((rowMask & value) == rowMask) { KeyBase keyPressed = keyGetter.GetKey(column, row); if (keysPressed.Contains(keyPressed)) { continue; } keysPressed.Add(keyPressed); } } } } return(keysPressed); }