@@ -1677,13 +1677,17 @@ def getMeta(self):
1677
1677
return self .mouseWatcherNode .getModifierButtons ().isDown (
1678
1678
KeyboardButton .meta ())
1679
1679
1680
- def attachInputDevice (self , device , prefix = None ):
1680
+ def attachInputDevice (self , device , prefix = None , gui = False ):
1681
1681
"""
1682
1682
This function attaches an input device to the data graph, which will
1683
1683
cause the device to be polled and generate events. If a prefix is
1684
1684
given and not None, it is used to prefix events generated by this
1685
1685
device, separated by a hyphen.
1686
1686
1687
+ The gui argument can be set to True (as of Panda3D 1.10.3) to set up
1688
+ the default MouseWatcher to receive inputs from this device, allowing
1689
+ it to control user interfaces.
1690
+
1687
1691
If you call this, you should consider calling detachInputDevice when
1688
1692
you are done with the device or when it is disconnected.
1689
1693
"""
@@ -1694,13 +1698,17 @@ def attachInputDevice(self, device, prefix=None):
1694
1698
idn = self .dataRoot .attachNewNode (InputDeviceNode (device , device .name ))
1695
1699
1696
1700
# Setup the button thrower to generate events for the device.
1697
- bt = idn .attachNewNode (ButtonThrower (device .name ))
1698
- if prefix is not None :
1699
- bt .node ().setPrefix (prefix + '-' )
1701
+ if prefix is not None or not gui :
1702
+ bt = idn .attachNewNode (ButtonThrower (device .name ))
1703
+ if prefix is not None :
1704
+ bt .node ().setPrefix (prefix + '-' )
1705
+ self .deviceButtonThrowers .append (bt )
1700
1706
1701
1707
assert self .notify .debug ("Attached input device {0} with prefix {1}" .format (device , prefix ))
1702
1708
self .__inputDeviceNodes [device ] = idn
1703
- self .deviceButtonThrowers .append (bt )
1709
+
1710
+ if gui :
1711
+ idn .node ().addChild (self .mouseWatcherNode )
1704
1712
1705
1713
def detachInputDevice (self , device ):
1706
1714
"""
0 commit comments