var item = args.RowIndex < ButtonConfig.Count ? ButtonConfig[args.RowIndex] : null;
if (item == null)
return;
- (new CecButtonConfigUI(item)).ShowDialog();
+ if (args.ColumnIndex >= 0)
+ {
+ (new CecButtonConfigUI(item)).ShowDialog();
+ }
+ else
+ {
+ var mappedButton = ButtonConfig[item.Key];
+ if (mappedButton == null || mappedButton.Value.Empty())
+ return;
+
+ var controlWindow = FindInstance();
+ if (controlWindow != IntPtr.Zero && item.Key.Duration == 0)
+ mappedButton.Value.Transmit(controlWindow);
+ }
};
foreach (var item in _buttonConfig)
return false;
var controlWindow = FindInstance();
- if (controlWindow != IntPtr.Zero && key.Duration == 0)
+ if (controlWindow != IntPtr.Zero && (key.Duration == 0 || key.Duration > 500))
return mappedButton.Value.Transmit(controlWindow);
return false;
{
if (input != null)
{
- foreach (var item in input._input)
- _input.Add(item);
+ bool foundModifier = false;
+ if (KeyCount > 0)
+ {
+ for (int i = _input.Count - 1; i >= 0; i--)
+ {
+
+ if (_input[i].Data.Keyboard.Flags == 0 && (
+ (ushort)WindowsAPI.VirtualKeyCode.VK_SHIFT == _input[i].Data.Keyboard.KeyCode ||
+ (ushort)WindowsAPI.VirtualKeyCode.VK_LSHIFT == _input[i].Data.Keyboard.KeyCode ||
+ (ushort)WindowsAPI.VirtualKeyCode.VK_RSHIFT == _input[i].Data.Keyboard.KeyCode ||
+
+ (ushort)WindowsAPI.VirtualKeyCode.VK_CONTROL == _input[i].Data.Keyboard.KeyCode ||
+ (ushort)WindowsAPI.VirtualKeyCode.VK_LCONTROL == _input[i].Data.Keyboard.KeyCode ||
+ (ushort)WindowsAPI.VirtualKeyCode.VK_RCONTROL == _input[i].Data.Keyboard.KeyCode ||
+
+ (ushort)WindowsAPI.VirtualKeyCode.VK_MENU == _input[i].Data.Keyboard.KeyCode ||
+ (ushort)WindowsAPI.VirtualKeyCode.VK_LMENU == _input[i].Data.Keyboard.KeyCode ||
+ (ushort)WindowsAPI.VirtualKeyCode.VK_RMENU == _input[i].Data.Keyboard.KeyCode
+ ))
+ {
+ foundModifier = true;
+ _input.Insert(i+1, input._input[0]);
+ _input.Insert(i+2, input._input[1]);
+ break;
+ }
+ }
+ }
+
+ if (!foundModifier)
+ {
+ _input.Add(input._input[0]);
+ _input.Add(input._input[1]);
+ }
}
return this;
}
public ApplicationAction RemoveItem(int index)
{
- //both keyup and keydown
- if (index * 2 + 1 < _input.Count)
+ var current = 0;
+ var downKeyIndex = 0;
+ var upKeyIndex = 0;
+ bool downFound = false;
+
+ for (int i = 0; i < _input.Count; i++)
{
- _input.RemoveAt(index * 2);
- _input.RemoveAt(index * 2);
+ if (_input[i].Data.Keyboard.Flags == 0 && !downFound)
+ {
+ if (index == current)
+ {
+ downKeyIndex = i;
+ downFound = true;
+ }
+ current++;
+ }
+ else if(_input[i].Data.Keyboard.Flags != 0 && downFound)
+ {
+ if (_input[i].Data.Keyboard.KeyCode == _input[downKeyIndex].Data.Keyboard.KeyCode)
+ {
+ upKeyIndex = i;
+ break;
+ }
+ }
}
+
+ WindowsAPI.Input downKey = _input[downKeyIndex];
+ WindowsAPI.Input upKey = _input[upKeyIndex];
+
+ _input.Remove(downKey);
+ _input.Remove(upKey);
+
return this;
}
{
var tmp = string.Format(KeyCount > 1 ? "[{0}] " : "{0} ",
WindowsAPI.GetVirtualKeyName((WindowsAPI.VirtualKeyCode) input.Data.Keyboard.KeyCode));
- current += tmp.Length + 1;
+ current += tmp.Length;
if (index <= current)
return RemoveItem(item);
item++;