Permalink
Browse files

Merge branch 'develop' of https://github.com/vvvv/vvvv into develop

  • Loading branch information...
2 parents 7264a91 + 2040bca commit efcab89a58d8e91b8fe5da86ac499fe75ec73eb3 @joreg joreg committed Feb 26, 2014
@@ -11,7 +11,8 @@ public enum KeyNotificationKind
{
KeyDown,
KeyPress,
- KeyUp
+ KeyUp,
+ DeviceLost
}
public abstract class KeyNotification
@@ -58,4 +59,12 @@ public KeyUpNotification(Keys keyCode)
{
}
}
+
+ public class KeyboardLostNotification : KeyNotification
+ {
+ public KeyboardLostNotification()
+ : base(KeyNotificationKind.DeviceLost)
+ {
+ }
+ }
}
@@ -1,6 +1,6 @@
-<!DOCTYPE PATCH SYSTEM "http://vvvv.org/versions/vvvv45alpha31.5.dtd" >
- <PATCH nodename="C:\Work\anton-vvvv-sdk\vvvv45\lib\nodes\plugins\Keyboard (Devices Desktop) help.v4p">
- <BOUNDS height="10530" left="0" top="0" type="Window" width="14010">
+<!DOCTYPE PATCH SYSTEM "http://vvvv.org/versions/vvvv45debug31.7.dtd" >
+ <PATCH nodename="D:\dev\v45\vvvv\public\vvvv45\lib\nodes\plugins\Keyboard (Devices Desktop) help.v4p">
+ <BOUNDS height="10530" left="600" top="4620" type="Window" width="14010">
</BOUNDS>
<NODE componentmode="InABox" id="99" nodename="IOBOX (VALUE ADVANCED)" systemname="IOBox (Value Advanced)">
<BOUNDS height="0" left="3465" top="2685" type="Node" width="0">
@@ -195,7 +195,7 @@
</PIN>
<PIN pinname="Queue Mode" visible="1">
</PIN>
- <PIN pinname="Index" slicecount="5" values="0,1,2,3,4">
+ <PIN pinname="Index" slicecount="1" values="0">
</PIN>
<PIN pinname="Key Name Bin Size" visible="1" pintype="Output">
</PIN>
@@ -50,6 +50,7 @@ public void Evaluate(int spreadMax)
Output[slice] = new string(keyPress.KeyChar, 1);
break;
case KeyNotificationKind.KeyUp:
+ case KeyNotificationKind.DeviceLost:
Output[slice] = string.Empty;
break;
}
@@ -134,7 +134,12 @@ public void Subscribe()
throw new NotImplementedException();
}
- FSubscription = result.ObserveOn(FScheduler)
+ //on keyboard lost: keep toggle state when in toggle mode; in any other case just release the key
+ if (FKeyMode != KeyMode.Toggle)
+ result = result.Merge(FKeyboard.KeyNotifications.OfType<KeyboardLostNotification>().Select(_ => false));
+
+ FSubscription = result
+ .ObserveOn(FScheduler)
.Subscribe(v => Output = v);
}
@@ -26,13 +26,31 @@ namespace VVVV.Nodes.Input
Category = "Devices",
Version = "Window",
Help = "Returns the keyboard of the current render window.")]
- public class KeyboardNode : WindowMessageNode, IPluginEvaluate
+ public class KeyboardNode : WindowMessageNode, IPluginEvaluate, IPartImportsSatisfiedNotification
{
[Output("Device", IsSingle = true)]
public ISpread<Keyboard> KeyboardOut;
private PluginContainer FKeyboardStatesSplitNode;
+ [Import]
+ protected IHDEHost FHost;
+ private IObservable<KeyNotification> FDeviceLostNotifications;
+
+ public override void OnImportsSatisfied()
+ {
+ FDeviceLostNotifications =
+ Observable.FromEventPattern<WindowEventArgs>(FHost, "WindowSelectionChanged")
+ .Select(p => p.EventArgs.Window)
+ .OfType<Window>()
+ .Select(w => w.UserInputWindow != null)
+ .DistinctUntilChanged()
+ .Where(assigned => !assigned)
+ .Select(_ => new KeyboardLostNotification());
+
+ base.OnImportsSatisfied();
+ }
+
protected override void Initialize(IObservable<WMEventArgs> windowMessages)
{
var keyNotifications = windowMessages
@@ -54,7 +72,7 @@ protected override void Initialize(IObservable<WMEventArgs> windowMessages)
}
)
.OfType<KeyNotification>();
- KeyboardOut[0] = new Keyboard(keyNotifications);
+ KeyboardOut[0] = new Keyboard(keyNotifications.Merge(FDeviceLostNotifications));
// Create a keyboard states node for us and connect our keyboard out to its keyboard in
var nodeInfo = FIOFactory.NodeInfos.First(n => n.Name == "KeyStates" && n.Category == "Keyboard" && n.Version == "Split");
@@ -186,6 +204,9 @@ public void Evaluate(int spreadMax)
case KeyNotificationKind.KeyUp:
notification = new KeyUpNotification((Keys)KeyCodeIn[bin][i]);
break;
+ case KeyNotificationKind.DeviceLost:
+ notification = new KeyboardLostNotification();
+ break;
default:
throw new NotImplementedException();
}
@@ -209,17 +230,21 @@ public bool Equals(KeyNotification x, KeyNotification y)
{
if (x.Kind == y.Kind)
{
- if (x.Kind == KeyNotificationKind.KeyPress)
+ switch (x.Kind)
{
- var xPress = x as KeyPressNotification;
- var yPress = y as KeyPressNotification;
- return xPress.KeyChar == yPress.KeyChar;
- }
- else
- {
- var xCode = x as KeyCodeNotification;
- var yCode = y as KeyCodeNotification;
- return xCode.KeyCode == yCode.KeyCode;
+ case KeyNotificationKind.KeyDown:
+ case KeyNotificationKind.KeyUp:
+ var xCode = x as KeyCodeNotification;
+ var yCode = y as KeyCodeNotification;
+ return xCode.KeyCode == yCode.KeyCode;
+ case KeyNotificationKind.KeyPress:
+ var xPress = x as KeyPressNotification;
+ var yPress = y as KeyPressNotification;
+ return xPress.KeyChar == yPress.KeyChar;
+ case KeyNotificationKind.DeviceLost:
+ return true;
+ default:
+ break;
}
}
return false;
@@ -297,6 +322,11 @@ public void Evaluate(int spreadMax)
keyNameOut.RemoveAll(k => k == keyUp.KeyCode.ToString());
KeyCharOut[slice] = string.Empty;
break;
+ case KeyNotificationKind.DeviceLost:
+ keyCodeOut.SliceCount = 0;
+ keyNameOut.SliceCount = 0;
+ KeyCharOut[slice] = string.Empty;
+ break;
default:
throw new NotImplementedException();
}
@@ -420,6 +450,10 @@ public void Evaluate(int spreadMax)
KeyCodeOut[bin][i] = (int)keyUp.KeyCode;
KeyCharOut[bin][i] = null;
break;
+ case KeyNotificationKind.DeviceLost:
+ KeyCodeOut[bin][i] = 0;
+ KeyCharOut[bin][i] = null;
+ break;
default:
throw new NotImplementedException();
}
@@ -29,7 +29,7 @@ public abstract class WindowMessageNode : IPluginBase, IPartImportsSatisfiedNoti
private readonly List<Subclass> FSubclasses = new List<Subclass>();
- public void OnImportsSatisfied()
+ public virtual void OnImportsSatisfied()
{
var windowMessages = Observable.FromEventPattern<WindowEventArgs>(FHost, "WindowAdded")
.Select(p => p.EventArgs.Window)

0 comments on commit efcab89

Please sign in to comment.