# How to get the device when callback is called?

**URL:** <https://forums.unrealengine.com/t/how-to-get-the-device-when-callback-is-called/1321233>\
**Category:** Verse\
**Tags:** fortnite-creative, unreal-editor-for-fortnite, question, fortnite\
**Created:** [October 3, 2023, 3:46pm UTC](https://forums.unrealengine.com/t/how-to-get-the-device-when-callback-is-called/1321233 "2023-10-03T15:46:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lite\_Gold](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lite\_Gold](https://forums.unrealengine.com/u/Lite_Gold)\
**Post date:** [October 3, 2023, 3:46pm UTC](https://forums.unrealengine.com/t/how-to-get-the-device-when-callback-is-called/1321233/1 "2023-10-03T15:46:32Z")

</div>

Hey Team,

I am using subscribe to create callbacks on all my devices in the level. One thing I would like to do is know which device the callback is coming from, however it seems verse does not want me to pass additional parameters (such as an int) into the callback of my subscribe.  
The only other way I can think of doing this would be to create an individual callback for every single device which would hurt my soul

Code here:

```auto
    @editable
    var CaptureDevices : []capture_area_device = array{}

    OnBegin<override>()<suspends>:void=
        for (CaptureDevice : CaptureDevices):
            CaptureDevice.ControlChangeEvent.Subscribe(OnCaptureAreaChangeOwner)

    OnCaptureAreaChangeOwner(InPlayer : agent): void = 
        Print("Capture area taken")
        #Do something depending on which capture device was captured

```

---

<div class="post-metadata">

**Author:** ![GraemeBB](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/graemebb/32/1106150_2.png) [@GraemeBB](https://forums.unrealengine.com/u/GraemeBB)\
**Post date:** [October 3, 2023, 4:14pm UTC](https://forums.unrealengine.com/t/how-to-get-the-device-when-callback-is-called/1321233/2 "2023-10-03T16:14:07Z")

</div>

You can’t, it’s a severe limitation of Verse at the moment. I’m sure somebody is working on it though. What you can do is wrap them up in a custom class and then call out from that class (as we can’t make proper listeners yet either…)

---

<div class="post-metadata">

**Author:** ![Lite\_Gold](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lite\_Gold](https://forums.unrealengine.com/u/Lite_Gold)\
**Post date:** [October 4, 2023, 12:03am UTC](https://forums.unrealengine.com/t/how-to-get-the-device-when-callback-is-called/1321233/3 "2023-10-04T00:03:22Z")

</div>

Ah I see, well thank you for the info

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [October 4, 2023, 10:30am UTC](https://forums.unrealengine.com/t/how-to-get-the-device-when-callback-is-called/1321233/4 "2023-10-04T10:30:59Z")

</div>

Hey, yes it’s not supported yet, as GraemeBB said, you can take a look at handlers [Guide to Event Subscribing with Additional Parameters (Handler Functions)](https://forums.unrealengine.com/t/guide-to-event-subscribing-with-additional-parameters-handler-functions/793925)

You can either use an handler class like this

```auto
# Handler for a button InteractedWithEvent but could be used for any listenable requiring a (agent -> void) signature
on_prop_pickedup_function := type{_(:agent, :int) : void}
pickup_prop_button_handler := class:
    AdditionalData: int
    Callback: on_prop_pickedup_function

    HandleInteractedWithEvent(Agent:agent):void=
        Callback(Agent, AdditionalData)

```

Or you could use spawn as a quick lightweight solution

```auto
for (CaptureDevice : CaptureDevices):
    spawn{WaitForZoneToBeCaptured(CaptureDevice)}

WaitForZoneToBeCaptured(CaptureDevice : capture_area_device)<suspends>:void=
    loop:
        Agent := CaptureDevice.ControlChangeEvent.Await()
        # Agent is the new owner

```

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [November 3, 2023, 10:31am UTC](https://forums.unrealengine.com/t/how-to-get-the-device-when-callback-is-called/1321233/5 "2023-11-03T10:31:25Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
