Closed okyeron closed 5 years ago
Yes, I think I removed that property when cleaning up vport library, you can use vport.device ~= nil
instead.
Could I ask for it to be added back? Not a big fan of vport.device ~= nil
as replacement.
That would be a flag which does nothing but being a duplicate of vport.device ~= nil
, a potential source of problems if we forget to update it. You can use vport.device
as a shortcut, which will evaluate to true, if the device is attached.
Maybe I'm not exactly sure how to use it then, first time I hear of vport
. I just want to check if the grid is connected to the norns. It's currently connected:
g = grid.connect()
g.key = on_grid_key
g.add = on_grid_add
g.remove = on_grid_remove
print(vport) # nil
print(g.vport) # nil
print(grid.vport) # nil
print(norns.vport) # nil
Right, grid.connect(x)
returns a vport instance, see https://github.com/monome/norns/blob/master/lua/core/grid.lua#L107
Currently scripts only deal with vports (assigned in devices menu), and we connect to them using grid.connect
. A vport instance keeps a reference to the physical device, in your example above that would be g.device
.
Hope this helps!
Some time back in 1.0 grid and midi devices could be checked if
attached
- Study 4 specifically uses this.Now I'm searching all the code and can't find it at all.
What happened here? Did this get tossed for some other better way to determine if a device is connected?