/// <summary> /// Constructor based on an input stream /// </summary> /// <param name="zFileStream">The file stream to read the config from</param> public RemapEntry(FileStream zFileStream) { InputConfig = new InputConfig(zFileStream); m_nHash = CalculateHashCode(InputConfig); var nOutputConfigs = zFileStream.ReadByte(); if (0 >= nOutputConfigs) { throw new Exception("Output definition length must be > 0. Invalid File!"); } // read the 3 additional bytes representing the 32bit int containing the nOutputConfigs above (limited to 255) // See RemapEntry struct inkeycapturestructs.h for the padding bytes zFileStream.Read(new byte[3], 0, 3); try { OutputConfigs = new List <OutputConfig>(nOutputConfigs); for (int nIdx = 0; nIdx < nOutputConfigs; nIdx++) { OutputConfigs.Add(new OutputConfig(zFileStream)); } } catch (Exception e) { throw new Exception("Invalid File! The number of outputs does not match the data in the file.", e); } }
/// <summary> /// Constructor based on an input stream /// </summary> /// <param name="zFileStream">The file stream to read the config from</param> public RemapEntry(FileStream zFileStream) { InputConfig = new InputConfig(zFileStream); m_nHash = (int)(InputConfig.Flags & 0xFF) + (int)((InputConfig.VirtualKey & 0xFF) << 8); var nOutputConfigs = zFileStream.ReadByte(); if (0 >= nOutputConfigs) { throw new Exception("Output definition length must be > 0. Invalid File!"); } // TODO: comment on why this is zFileStream.Read(new byte[3], 0, 3); try { OutputConfigs = new List <OutputConfig>(nOutputConfigs); for (int nIdx = 0; nIdx < nOutputConfigs; nIdx++) { OutputConfigs.Add(new OutputConfig(zFileStream)); } } catch (Exception e) { throw new Exception("Invalid File! The number of outputs does not match the data in the file.", e); } }
public byte[] SerializeToBytes() { var zStream = new MemoryStream(); InputConfig.SerializeToStream(zStream); zStream.WriteByte((byte)OutputConfigs.Count); // TODO: comment on padding zStream.Write(new byte[3], 0, 3); OutputConfigs.ForEach(oc => oc.SerializeToStream(zStream)); return(zStream.ToArray()); }
public byte[] SerializeToBytes() { var zStream = new MemoryStream(); InputConfig.SerializeToStream(zStream); zStream.WriteByte((byte)OutputConfigs.Count); // output count is only 1 byte, pad out to a 32bit int zStream.Write(new byte[3], 0, 3); OutputConfigs.ForEach(oc => oc.SerializeToStream(zStream)); return(zStream.ToArray()); }
/// <summary> /// Copy constructor /// </summary> /// <param name="config"></param> public InputConfig(InputConfig config) : base(config) { }
/// <summary> /// Constructor based on input/output definitions /// </summary> /// <param name="zInputConfig">the input definition</param> /// <param name="zOutputConfig">the output definition</param> public RemapEntry(InputConfig zInputConfig, OutputConfig zOutputConfig) { InputConfig = zInputConfig; OutputConfigs = new List <OutputConfig>(new [] { zOutputConfig }); m_nHash = CalculateHashCode(InputConfig); }
protected static int CalculateHashCode(InputConfig zInputConfig) { return((int)(zInputConfig.Flags & 0xFF) + (int)((zInputConfig.VirtualKey & 0xFF) << 8)); }
/// <summary> /// Returns the input string representation /// </summary> /// <returns>string representation</returns> public string GetInputString() { return(InputConfig.GetDescription()); }