Skip to content

Commit 341f954

Browse files
committed
Copyright update as well as some minor tweaks.
1 parent 1fd5231 commit 341f954

33 files changed

+55
-58
lines changed

Format/BaseIOConfig.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
////////////////////////////////////////////////////////////////////////////////
22
// The MIT License (MIT)
33
//
4-
// Copyright (c) 2019 Tim Stair
4+
// Copyright (c) 2021 Tim Stair
55
//
66
// Permission is hereby granted, free of charge, to any person obtaining a copy
77
// of this software and associated documentation files (the "Software"), to deal
@@ -51,6 +51,7 @@ public BaseIOConfig(Stream zStream)
5151
{
5252
Flags = StreamUtil.ReadIntFromStream(zStream);
5353
VirtualKey = StreamUtil.ReadByteFromStream(zStream);
54+
// VirtualKey is only a byte so read the remaining padding bytes for the 32bit int
5455
StreamUtil.ReadBytesFromStream(zStream, 3);
5556
Parameter = StreamUtil.ReadIntFromStream(zStream);
5657
}

Format/ConfigFileManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
////////////////////////////////////////////////////////////////////////////////
22
// The MIT License (MIT)
33
//
4-
// Copyright (c) 2019 Tim Stair
4+
// Copyright (c) 2021 Tim Stair
55
//
66
// Permission is hereby granted, free of charge, to any person obtaining a copy
77
// of this software and associated documentation files (the "Software"), to deal

Format/InputConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
////////////////////////////////////////////////////////////////////////////////
22
// The MIT License (MIT)
33
//
4-
// Copyright (c) 2019 Tim Stair
4+
// Copyright (c) 2021 Tim Stair
55
//
66
// Permission is hereby granted, free of charge, to any person obtaining a copy
77
// of this software and associated documentation files (the "Software"), to deal

Format/OutputConfig.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
////////////////////////////////////////////////////////////////////////////////
22
// The MIT License (MIT)
33
//
4-
// Copyright (c) 2019 Tim Stair
4+
// Copyright (c) 2021 Tim Stair
55
//
66
// Permission is hereby granted, free of charge, to any person obtaining a copy
77
// of this software and associated documentation files (the "Software"), to deal
@@ -56,7 +56,6 @@ public enum OutputFlag
5656
Up = 1 << 8,
5757
Repeat = 1 << 9,
5858
CancelActiveOutputs = 1 << 10,
59-
// all ThreadKill ?
6059
// supports up to 32 entries
6160
}
6261

Format/RemapEntry.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
////////////////////////////////////////////////////////////////////////////////
22
// The MIT License (MIT)
33
//
4-
// Copyright (c) 2019 Tim Stair
4+
// Copyright (c) 2021 Tim Stair
55
//
66
// Permission is hereby granted, free of charge, to any person obtaining a copy
77
// of this software and associated documentation files (the "Software"), to deal
@@ -30,7 +30,7 @@
3030
namespace KeyCap.Format
3131
{
3232
/// <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
3434
/// </summary>
3535
public class RemapEntry
3636
{
@@ -63,15 +63,16 @@ public RemapEntry(InputConfig zInputConfig, OutputConfig zOutputConfig)
6363
public RemapEntry(FileStream zFileStream)
6464
{
6565
InputConfig = new InputConfig(zFileStream);
66-
m_nHash = (int)(InputConfig.Flags & 0xFF) + (int)((InputConfig.VirtualKey & 0xFF) << 8);
66+
m_nHash = CalculateHashCode(InputConfig);
6767

6868
var nOutputConfigs = zFileStream.ReadByte();
6969
if (0 >= nOutputConfigs)
7070
{
7171
throw new Exception("Output definition length must be > 0. Invalid File!");
7272
}
7373

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
7576
zFileStream.Read(new byte[3], 0, 3);
7677

7778
try
@@ -104,7 +105,7 @@ public byte[] SerializeToBytes()
104105
var zStream = new MemoryStream();
105106
InputConfig.SerializeToStream(zStream);
106107
zStream.WriteByte((byte)OutputConfigs.Count);
107-
// TODO: comment on padding
108+
// output count is only 1 byte, pad out to a 32bit int
108109
zStream.Write(new byte[3], 0, 3);
109110
OutputConfigs.ForEach(oc => oc.SerializeToStream(zStream));
110111
return zStream.ToArray();

Forms/KeyCaptureConfig.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
////////////////////////////////////////////////////////////////////////////////
22
// The MIT License (MIT)
33
//
4-
// Copyright (c) 2019 Tim Stair
4+
// Copyright (c) 2021 Tim Stair
55
//
66
// Permission is hereby granted, free of charge, to any person obtaining a copy
77
// of this software and associated documentation files (the "Software"), to deal
@@ -175,9 +175,9 @@ private void KeyCaptureConfig_Resize(object sender, EventArgs e)
175175
}
176176
}
177177

178-
#endregion
178+
#endregion
179179

180-
#region Text Capture Handling
180+
#region Text Capture Handling
181181

182182
private void txtKeyIn_KeyDown(object sender, KeyEventArgs e)
183183
{
@@ -210,9 +210,9 @@ private void txtKey_Leave(object sender, EventArgs e)
210210
((TextBox)sender).BackColor = SystemColors.Control;
211211
}
212212

213-
#endregion
213+
#endregion
214214

215-
#region AbstractDirtyForm overrides
215+
#region AbstractDirtyForm overrides
216216

217217
protected override bool SaveFormData(string sFileName)
218218
{
@@ -255,9 +255,9 @@ protected override bool OpenFormData(string sFileName)
255255
return true;
256256
}
257257

258-
#endregion
258+
#endregion
259259

260-
#region Menu Events
260+
#region Menu Events
261261

262262
private void loadToolStripMenuItem_Click(object sender, EventArgs e)
263263
{
@@ -296,9 +296,9 @@ private void recentConfiguration_Click(object sender, EventArgs e)
296296
InitOpen(zItem.Text);
297297
}
298298

299-
#endregion
299+
#endregion
300300

301-
#region Control Events
301+
#region Control Events
302302

303303
private void listViewKeys_SelectedIndexChanged(object sender, EventArgs e)
304304
{

KeyCapLib/KeyCapture.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
////////////////////////////////////////////////////////////////////////////////
22
// The MIT License (MIT)
33
//
4-
// Copyright (c) 2019 Tim Stair
4+
// Copyright (c) 2021 Tim Stair
55
//
66
// Permission is hereby granted, free of charge, to any person obtaining a copy
77
// of this software and associated documentation files (the "Software"), to deal
@@ -76,6 +76,7 @@ __declspec(dllexport) int LoadAndCaptureFromFile(HINSTANCE hInstance, char* sFil
7676
bool bValidTranslationSet = false;
7777

7878
// The translation table contains linked lists of all the output sets for a given key due to the flag keys (shift/alt/ctrl)
79+
// Example: input 'a' will be in the same list as 'shift+a' 'alt+a' 'ctrl+a' (or any combos like 'alt+shift+a')
7980
while(NULL != pEntry)
8081
{
8182
if(0 == pEntry->outputCount)
@@ -129,21 +130,16 @@ __declspec(dllexport) int LoadAndCaptureFromFile(HINSTANCE hInstance, char* sFil
129130
{
130131
// Note: This fails in VisualStudio if managed debugging is NOT enabled in the project(!)
131132
g_hookMain = SetWindowsHookEx( WH_KEYBOARD_LL, LowLevelKeyboardProc, hInstance, NULL);
132-
if(NULL == g_hookMain)
133-
{
134-
ShutdownCapture();
135-
return HOOK_CREATION_FAILURE;
136-
}
137-
else
133+
if(NULL != g_hookMain)
138134
{
139135
return HOOK_CREATION_SUCCESS;
140136
}
141-
}
142-
else
143-
{
144137
ShutdownCapture();
145-
return INPUT_BAD;
138+
return HOOK_CREATION_FAILURE;
146139
}
140+
141+
ShutdownCapture();
142+
return INPUT_BAD;
147143
}
148144

149145
void InitiallizeEntryContainerListItem(RemapEntryContainerListItem* pKeyItem, RemapEntry* pEntry)

KeyCapLib/KeyCapture.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
////////////////////////////////////////////////////////////////////////////////
22
// The MIT License (MIT)
33
//
4-
// Copyright (c) 2019 Tim Stair
4+
// Copyright (c) 2021 Tim Stair
55
//
66
// Permission is hereby granted, free of charge, to any person obtaining a copy
77
// of this software and associated documentation files (the "Software"), to deal

KeyCapLib/KeyCaptureUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
////////////////////////////////////////////////////////////////////////////////
22
// The MIT License (MIT)
33
//
4-
// Copyright (c) 2019 Tim Stair
4+
// Copyright (c) 2021 Tim Stair
55
//
66
// Permission is hereby granted, free of charge, to any person obtaining a copy
77
// of this software and associated documentation files (the "Software"), to deal

KeyCapLib/KeyCaptureUtil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
////////////////////////////////////////////////////////////////////////////////
22
// The MIT License (MIT)
33
//
4-
// Copyright (c) 2019 Tim Stair
4+
// Copyright (c) 2021 Tim Stair
55
//
66
// Permission is hereby granted, free of charge, to any person obtaining a copy
77
// of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)