bbeardsley / buzzio Goto Github PK
View Code? Open in Web Editor NEWC# library to use Sony PS2/PS3 buzz usb controllers in Windows
License: The Unlicense
C# library to use Sony PS2/PS3 buzz usb controllers in Windows
License: The Unlicense
Original issue:
new BuzzHandsetFinder().FindHandsets() still found controllers even if they were detached in the meanwhile.
Background:
I had an issue with my game when no controllers were connected. So I added a "rescan for controllers" feature in order to be able to detect controllers that were connected to the PC recently. For testing purposes, I started without a controller. After attaching the controller, the newly attached controller was found. After removing the controller, I pressed the rescan button again, but the controller still appeared.
Source Code:
I looked at BuzzHandsetDevice.cs, FindBuzzHandsets(), which does not use caching. Also, HIDDevice.cs, FindDevices() does not seem to use caching. So I expected a problem somewhere in my code. I wrote the following minimal example - but its output confuses me even more.
using System;
using System.Linq;
using System.Threading;
using BuzzIO;
namespace ControllerScanTest
{
class Program
{
static void Main()
{
while (true)
{
var h = new BuzzHandsetFinder().FindHandsets();
Console.WriteLine(h.Count());
Thread.Sleep(2000);
}
}
}
}
Output:
0
0
0
1
0
0
0
0
1
0
0
The output is just 1 when I insert the controller. Even when I leave it connected, the next loop it returns 0. That's the opposite of what I found out in my game.
Another try:
I saw that HIDDevice is disposable. BuzzHandsetDevice inherits from HIDDevice, is it's also disposable. However, from the interface we get back from FindHandsets(), it's not possible to dispose the objects.
Adding the following code inside the loop results in exceptions:
foreach (var device in h)
{
((HIDDevice) device)?.Dispose();
}
Question:
What is the correct way to rescan for controllers?
What licence is BuzzIO under? I'm particularly interested in the HID code...
Hi,
The device path is detected, but the Initialise function of HIDDevice.cs the CreateFile function returns -1 as handle. The controllers work fine in the Windows control panel.
I'm using Visual Studio Community 2015 and the latest version of the code.
My system is Windows 10 64 bit.
Kind regards,
Bert
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.