Does anyone know if it’s possible to read mouse HID? I’ve seen documentation on how to read HID from PS4 controllers etc.
So my common sense tells me that it’s possible to read a Mouse HID. I want to read mouse HID because I have two mice connected to my computer.
I’m making a two-player game, where each player will physically sit next to each other and play the game using the separate mouse to point and shoot enemies.
That was a clever suggestion. Unfortunately, Unity’s Input system ignores Multiple Mouse. I currently have Two mice plugged into my computer, one keyboard, and one USB Gamepad. However, from debugging the InputSystem, it only reads one mouse.
I got the Multiple Asset from Unity Store. It works and does what it says it’s supposed to do.
However, I’m actually using a Lightgun as a Mouse in my game. I have two USB IR Lightguns, when plugged into my PC, Windows 10 recognizes them as a USB Mouse. I can move the Lightguns around just as a regular mouse for pointing and clicking.
The Multiple Asset package I purchased from the Unity store seems to have a hard time reading the X-Y of the Lightguns.
For the C++ .dll.
Do you know how that’s supposed to work. I read the thread and downloaded the C++ code and tried compiling it but I don’t understand how it’s supposed to be used. The owner doesn’t have much documentation.
i think it should produce dll when compiled, then place dll to your project (in Plugins/ and or project root if dll not found), and c# script calls the dll.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using RavingBots.MultiInput; // Purchase the MultiInput Asset from Unity Asset store
using UnityEngine.Events;
using System.Linq;
using UnityEngine.UI;
public class DisplayMultipleLightGuns
{
// InputeState class is available when you purchase the MultiInput asset from Unity Asset store.
// Create an empty gameobject in the editor and attach a MultiInput.cs to the empty gameobject
// Attache the empty gameobject here.
public InputeState InputManager;
public IDevice Gun1, Gun2;
private IVirtualAxis Gun1InfraredXValue, Gun1InfraredYValue, Gun2InfraredXValue, Gun2InfraredYValue;
void Start()
{
if(InputManager.devices.Count() > 0)
{
foreach(IDevice thisDevice in InputManager.Devices)
{
if(thisDevice.ProductID == abc123) // To get the actual product ID, you should use Windows Device Manager.
{
Gun1 = thisDevice;
}
if(thisDevice.ProductID == xyz123)
{
Gun2 = thisDevice;
}
}
}
}
void Update()
{
if(Gun1 != null)
{
Gun1InfraredXValue = Gun1[InputCode.MouseX];
Gun1InfraredYValue = Gun1[InputCode.MouseY];
}
if(Gun2 != null)
{
Gun2InfraredXValue = Gun2[InputCode.MouseX];
Gun2InfraredYValue = Gun2[InputCode.MouseY];
}
// From here on you can do whatever you want with Gun1InfraredX/YValue and Gun2InfraredX/YValue
// such as move cursors, laser, gameobjects etc.
}
}
How do you get the positional values in sync with the actual pointer device? The input value of x and y are relative, so you can add those to a previous position to get your current position. However, they start at 0 no matter where the actual mouse is on screen, so the position is always off.