Please, help me creat conditions

I'm pretty sure you can "use the device" only when a particular .exe is running. This would help me to connect or disconnect devices automatically when moonlight opens or closes, for example.

For instance I have a mouse with many buttons. These functions can only be used by windows. The mouse is connected to the raspberry and only the basic buttons work. Now if I "use the device" raspberry stops recognizing it. That is why I would like it to only "use the device" when I am streaming the moonlight session. And, of course, it will stop "being used" when leaving the session.

I think that this type of condition can be used for many other projects, and I ask your excuses if they are well known but I cannot find them in the forum. A greeting.

#2

1. On the raspberry pi stop the virtualhere server process if it is running (sudo pkill vhusbdarm)
2. Edit the server config.ini file and add the line AutoAttachToKernel=1. That will enable the mouse to be used again on the pi when it has stopped being used by VirtualHere
3. On the client you will need to run vhui64.exe -t "LIST" to get the address of the mouse.Make a note of the address
4. Create a batch file on the client to vhui64.exe -t "USE,<address of mouse from step 3>"and start moonlight also via the batch file
5. When you've finished you need to call vhui64.exe -t "STOP USING,<address of mouse from step 3>"

#3

1. Done
2. Done (config.ini is in the same folder where I downloaded the program)
3. By client do you mean my windows pc? How can i run vhui64.exe -t "LIST"?
4. How can i create a batch file? In wich folder? What name I put it? How can i start moonlight via that batch file? do you mean by: moonlight stream -app "name_of_the_batch_file"?
5. How can i call vhui64.exe -t "STOP USING,,
"

Thank you so much Michael.

#4

3. OK dont do that, just right click on the mouse in the virtualhere client and select Properties and note the address here instead

I dont know how to start moonlight you will have to figure this out yourself, do you click something to start it? Just see what that icon is linked to in windows e.g the shortcut. And you will have to read about batch files. This forum is not really for understanding how to write batch files. Have a look here https://www.virtualhere.com/client_api for examples

#5

Hello Michael. I've been investigating!

Step two works for me with a 2.4 ghz Chinese keyboard. When I "stop using device" the keyboard connects to the raspberry in normal mode and when I "use device" the keyboard works. In fact I tried to eliminate AutoAttachToKernel = 1 and when I stop using device the keyboard does not connect anymore.

This means that this step is well done and passed, however, when I stop using the mouse it crashes and stops working. The mouse is connected in 2.4 ghz.

I've been researching the .bat and I know how to do it. The problem is that I get a vhui64.exe FAIL message.

It is not the bat. I was able to successfully run in powershell vhui64.exe -t "LIST" but with vhui64.exe -t "USE,
" (like 112 111 etc) i always get FAIL. Tried on different devices, I always get this error. Also for vhui64.exe -t "STOP USING,
"

Thank you Michael.

#6

The address is the value between the ( and ) when you run LIST

E.g

C:\Users\msbro>VirtualHere Client IPC, below are the available devices:
(Value in brackets = address, * = Auto-Use)

DS120j (ds120j:17570)
   --> iLok (ds120j.11)
Pi4_CloudHub (CloudHub_00298f:7575)
   --> Logitech Webcam C930e (CloudHub_00298f.114)
ReadyNAS Hub (readynas:7575)
   --> TOSHIBA USB DRV (readynas.11)
QNAP Hub (QNAP:7575)
   --> iLok (QNAP.11)
Main Server (SERVER:7575)
   --> Token JC (SERVER.71) (In-use by: (michael) at 192.168.1.233)
DS113j (ds113j:17570)
   --> STORE N GO (ds113j.21)
MyCloud PR4100 (MyCloudPR4100:7575)
   --> Ultra Fit (MyCloudPR4100.13)
MyCloudEX2Ultra (MyCloudEX2Ultra:7575)
   --> RTL2838UHIDIR (MyCloudEX2Ultra.11)

Auto-Find currently on
Auto-Use All currently off
Reverse Lookup currently off
Reverse SSL Lookup currently off
VirtualHere Client not running as a service

C:\Users\msbro>vhui64.exe -t "USE,readynas.11"

C:\Users\msbro>OK
#7

Hello Michael.

It works!!! vhui64.exe -t "USE, (retropie.111 , retropie.1113, etc)" . Also for vhui64.exe -t "STOP USING, "

Now the only problem is that the mouse do not work when i stop using it. And remember my keyboard works perfectly and i can "use the device" or "stop using" thank to AutoAttachToKernel=1

So there should be a problem with my mouse Logitech M720. Can i see any log or something like that? Where is it? in windows or raspbian? Could you tell me the file path?

I almost got it. Thanks you so much Michael.

#8

Have a look in /var/log/syslog on the server when you stop using the mouse, messages will be written there. What do they say?

#9

Hi Michael This is what i got.

Nov 5 00:14:45 retropie thd[383]: Error reading device '/dev/input/event5'
Nov 5 00:14:45 retropie kernel: [ 439.490200] usb 1-1.1.3: reset full-speed USB device number 6 using dwc_otg
Nov 5 00:14:45 retropie vhusbdarm[443]: Device 1113 [046d:c52b] BOUND to connection 1
Nov 5 00:14:46 retropie kernel: [ 439.910200] usb 1-1.1.3: reset full-speed USB device number 6 using dwc_otg
Nov 5 00:14:53 retropie kernel: [ 446.951973] logitech-djreceiver 0003:046D:C52B.0009: hiddev97,hidraw2: USB HID v1.11 Device [Logitech US$Nov 5 00:14:53 retropie vhusbdarm[443]: Device 1113 [046d:c52b] UNBOUND from connection 1
Nov 5 00:14:53 retropie kernel: [ 447.190249] usb 1-1.1.3: reset full-speed USB device number 6 using dwc_otg
Nov 5 00:17:01 retropie CRON[1476]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)

#10

After you stop using the mouse via virtualhere and its not working again on the pi, can you open terminal on the pi and type

sudo udevadm trigger

Does the mouse start working again on the pi now?

#11

Hello Michael.

sudo udevadm trigger did not work. I bring you the log.

Nov 5 10:51:44 retropie systemd[1]: systemd-hostnamed.service: Succeeded.
Nov 5 10:52:31 retropie kernel: [ 91.856508] usb 1-1.1.3: reset full-speed USB device number 7 using dwc_otg
Nov 5 10:52:31 retropie vhusbdarm[512]: Device 1113 [046d:c52b] BOUND to connection 1
Nov 5 10:52:31 retropie kernel: [ 92.276506] usb 1-1.1.3: reset full-speed USB device number 7 using dwc_otg
Nov 5 10:52:42 retropie kernel: [ 102.338862] logitech-djreceiver 0003:046D:C52B.000A: hiddev97,hidraw2: USB HID v1.11 Device [Logitech USB Receiver] on usb-3f980000.usb-1.1.3/input2
Nov 5 10:52:42 retropie vhusbdarm[512]: Device 1113 [046d:c52b] UNBOUND from connection 1
Nov 5 10:52:42 retropie kernel: [ 102.576471] usb 1-1.1.3: reset full-speed USB device number 7 using dwc_otg
Nov 5 10:53:25 retropie systemd[1]: Started Session c2 of user pi.
Nov 5 10:54:43 retropie systemd-udevd[1211]: Process '/sbin/crda' failed with exit code 234.
Nov 5 10:54:53 retropie systemd-udevd[1247]: Using default interface naming scheme 'v240'.
Nov 5 10:54:53 retropie systemd-udevd[1257]: Using default interface naming scheme 'v240'.

Thanks for helping.

#12

Ok im not sure then. I think that the mouse driver needs to be reloaded on the pi, so you need to read up on that.

#13

Hello Michael.

The mouse also has bluetooth connectivity. And 3 connection modes that you can activate with a physical button. Maybe I can use mode 1 to connect via otg 2.4 ghz (with auto use this device) and mode 2 bluetooth to connect with raspberry.

I have to try. Anyway, what you taught me about the .bat can be used for this and other devices.

With what I get I will make a guide so that any newbie -like me- can better control moonlight and virtual here. It will go in the forum section that you indicate.

For now I want to say that when you run moonlight from any device, the process that is created in windows is "Nvidia Streamer Server Component" and the executable that is activated is "nvstreamer.exe" which is by default in "C:\Program Files\NVIDIA Corporation\NvStreamSrv\".

The question would be to create conditions. Maybe with the windows task scheduler? it would be as follows. When nvstream.exe run "use this device" when nvstreamer.exe closes "stop using this device". That would allow you to "use the device" only when you are in moonlight and to be able to use it normally when you have left the moonlight session.

These would join the activation of the mentioned exe with the activation of "use" or "stop using device" that you have taught us here Michael.

Thanks a lot.

#14

Yes that sounds correct