|
1 | 1 | //////////////////////////////////////////////////////////////////////////////// |
2 | 2 | // The MIT License (MIT) |
3 | 3 | // |
4 | | -// Copyright (c) 2019 Tim Stair |
| 4 | +// Copyright (c) 2021 Tim Stair |
5 | 5 | // |
6 | 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy |
7 | 7 | // of this software and associated documentation files (the "Software"), to deal |
|
30 | 30 | namespace KeyCap.Format |
31 | 31 | { |
32 | 32 | /// <summary> |
33 | | - /// Definition of a pair of inputs, the captured input and actual input to pass to the os |
| 33 | + /// Definition of a pair of inputs, the captured input and actual input (OutputConfigs) to pass to the os |
34 | 34 | /// </summary> |
35 | 35 | public class RemapEntry |
36 | 36 | { |
@@ -63,15 +63,16 @@ public RemapEntry(InputConfig zInputConfig, OutputConfig zOutputConfig) |
63 | 63 | public RemapEntry(FileStream zFileStream) |
64 | 64 | { |
65 | 65 | InputConfig = new InputConfig(zFileStream); |
66 | | - m_nHash = (int)(InputConfig.Flags & 0xFF) + (int)((InputConfig.VirtualKey & 0xFF) << 8); |
| 66 | + m_nHash = CalculateHashCode(InputConfig); |
67 | 67 |
|
68 | 68 | var nOutputConfigs = zFileStream.ReadByte(); |
69 | 69 | if (0 >= nOutputConfigs) |
70 | 70 | { |
71 | 71 | throw new Exception("Output definition length must be > 0. Invalid File!"); |
72 | 72 | } |
73 | 73 |
|
74 | | - // TODO: comment on why this is |
| 74 | + // read the 3 additional bytes representing the 32bit int containing the nOutputConfigs above (limited to 255) |
| 75 | + // See RemapEntry struct inkeycapturestructs.h for the padding bytes |
75 | 76 | zFileStream.Read(new byte[3], 0, 3); |
76 | 77 |
|
77 | 78 | try |
@@ -104,7 +105,7 @@ public byte[] SerializeToBytes() |
104 | 105 | var zStream = new MemoryStream(); |
105 | 106 | InputConfig.SerializeToStream(zStream); |
106 | 107 | zStream.WriteByte((byte)OutputConfigs.Count); |
107 | | - // TODO: comment on padding |
| 108 | + // output count is only 1 byte, pad out to a 32bit int |
108 | 109 | zStream.Write(new byte[3], 0, 3); |
109 | 110 | OutputConfigs.ForEach(oc => oc.SerializeToStream(zStream)); |
110 | 111 | return zStream.ToArray(); |
|
0 commit comments