BriansUsbQuizBoxApi 1.0.1
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package BriansUsbQuizBoxApi --version 1.0.1
NuGet\Install-Package BriansUsbQuizBoxApi -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BriansUsbQuizBoxApi" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BriansUsbQuizBoxApi" Version="1.0.1" />
<PackageReference Include="BriansUsbQuizBoxApi" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BriansUsbQuizBoxApi --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: BriansUsbQuizBoxApi, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BriansUsbQuizBoxApi@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BriansUsbQuizBoxApi&version=1.0.1
#tool nuget:?package=BriansUsbQuizBoxApi&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Brian's USB Quiz Box API
About
An API for interfacing with a USB Quiz Box by Brian's Boxes
How to Use
Create an instance of 'QuizBoxApi'. Register with events and then call 'Connect'.
using BriansUsbQuizBoxApi;
Console.WriteLine("--- Brian's USB Quiz Box Test App ---");
using var api = new QuizBoxApi(new QuizBoxCoreApi());
api.BuzzIn += Api_BuzzIn;
api.FiveSecondTimerStarted += Api_FiveSecondTimerStarted;
api.FiveSecondTimerExpired += Api_FiveSecondTimerExpired;
api.LockoutTimerStarted += Api_LockoutTimerStarted;
api.LockoutTimerExpired += Api_LockoutTimerExpired;
api.GameStarted += Api_GameStarted;
api.GameLightOn += Api_GameLightOn;
api.GameDone += Api_GameDone;
api.BuzzInStats += Api_BuzzInStats;
api.DisconnectionDetected += Api_DisconnectionDetected;
void Api_DisconnectionDetected(object? sender, DisconnectionEventArgs e)
{
Console.WriteLine("ERROR: Disconnection from quiz box detected! Program will need to be restarted...");
}
void Api_GameStarted(object? sender, EventArgs e)
{
Console.WriteLine("Game mode started. Wait for yellow light to turn on and press a paddle!");
}
void Api_GameLightOn(object? sender, EventArgs e)
{
Console.WriteLine("Yellow light on!");
}
void Api_GameDone(object? sender, GameDoneEventArgs e)
{
Console.WriteLine("Game done!");
Console.WriteLine($"Red 1 Time = {(e.Red1Time.HasValue ? e.Red1Time + "ms" : "-no buzz in-")}");
Console.WriteLine($"Red 2 Time = {(e.Red2Time.HasValue ? e.Red2Time + "ms" : "-no buzz in-")}");
Console.WriteLine($"Red 3 Time = {(e.Red3Time.HasValue ? e.Red3Time + "ms" : "-no buzz in-")}");
Console.WriteLine($"Red 4 Time = {(e.Red4Time.HasValue ? e.Red4Time + "ms" : "-no buzz in-")}");
Console.WriteLine($"Green 1 Time = {(e.Green1Time.HasValue ? e.Green1Time + "ms" : "-no buzz in-")}");
Console.WriteLine($"Green 2 Time = {(e.Green2Time.HasValue ? e.Green2Time + "ms" : "-no buzz in-")}");
Console.WriteLine($"Green 3 Time = {(e.Green3Time.HasValue ? e.Green3Time + "ms" : "-no buzz in-")}");
Console.WriteLine($"Green 4 Time = {(e.Green4Time.HasValue ? e.Green4Time + "ms" : "-no buzz in-")}");
Console.WriteLine();
Console.WriteLine("Press Reset to continue...");
}
void Api_BuzzInStats(object? sender, BuzzInStatsEventArgs e)
{
Console.WriteLine("Buzz in statistics:");
Console.WriteLine($"Red 1 Time = {(e.Red1TimeDelta.HasValue ? e.Red1TimeDelta + "ms" : "-no buzz in-")}");
Console.WriteLine($"Red 2 Time = {(e.Red2TimeDelta.HasValue ? e.Red2TimeDelta + "ms" : "-no buzz in-")}");
Console.WriteLine($"Red 3 Time = {(e.Red3TimeDelta.HasValue ? e.Red3TimeDelta + "ms" : "-no buzz in-")}");
Console.WriteLine($"Red 4 Time = {(e.Red4TimeDelta.HasValue ? e.Red4TimeDelta + "ms" : "-no buzz in-")}");
Console.WriteLine($"Green 1 Time = {(e.Green1TimeDelta.HasValue ? e.Green1TimeDelta + "ms" : "-no buzz in-")}");
Console.WriteLine($"Green 2 Time = {(e.Green2TimeDelta.HasValue ? e.Green2TimeDelta + "ms" : "-no buzz in-")}");
Console.WriteLine($"Green 3 Time = {(e.Green3TimeDelta.HasValue ? e.Green3TimeDelta + "ms" : "-no buzz in-")}");
Console.WriteLine($"Green 4 Time = {(e.Green4TimeDelta.HasValue ? e.Green4TimeDelta + "ms" : "-no buzz in-")}");
}
void Api_BuzzIn(object? sender, BuzzInEventArgs e)
{
Console.WriteLine($"Buzz in on paddle: {e.Paddle}");
}
void Api_FiveSecondTimerStarted(object? sender, EventArgs e)
{
Console.WriteLine("Five second timer started");
}
void Api_FiveSecondTimerExpired(object? sender, EventArgs e)
{
Console.WriteLine("Five second timer expired");
}
void Api_LockoutTimerStarted(object? sender, EventArgs e)
{
Console.WriteLine("Paddle lockout timer started");
}
void Api_LockoutTimerExpired(object? sender, EventArgs e)
{
Console.WriteLine("Paddle lockout timer expired");
}
if (api.Connect() == false)
{
Console.WriteLine("ERROR: Unable to connect to a quiz box");
Console.WriteLine("Press [ENTER] to exit program...");
}
else
{
Console.WriteLine("Press 'G' to start reaction timing game. Press [ENTER] to exit program...");
}
var key = Console.ReadKey();
while(key.Key != ConsoleKey.Enter)
{
if(key.Key == ConsoleKey.G)
{
Console.WriteLine("Starting reaction time game...");
api.StartReactionTimingGame();
}
key = Console.ReadKey();
}
Complete example located at: https://github.com/pvoelker/BriansUsbQuizBoxApi/tree/main/BriansUsbQuizBoxApi.TestApp
Notes
- Do not block on events from QuizBoxApi. This will prevent the background read thread from running
- Do not make call command methods (like 'Reset') from events on QuizBoxApi. An exception will be thrown if this is attempted. Using Task.Run is a way to get around this limitation
- On MacOS / Mac Catalyst if the application is running in a 'sandbox' (com.apple.security.app-sandbox), you will need to apply the 'com.apple.security.device.usb' entitlement. Otherwise quiz boxes will not be detected
Credits
- Brian McKevett bmckevett@yahoo.com for providing technical documentation about the quiz boxes
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- HidSharp (>= 2.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.1.0-alpha | 116 | 6/18/2024 |
1.0.1 | 269 | 3/8/2024 |
1.0.0 | 593 | 12/6/2023 |
1.0.0-beta.3 | 96 | 12/5/2023 |
1.0.0-beta.2 | 105 | 11/26/2023 |
1.0.0-beta | 493 | 11/25/2023 |
1.0.0-alpha.3 | 103 | 11/14/2023 |
1.0.0-alpha.2 | 85 | 11/13/2023 |
1.0.0-alpha | 479 | 11/12/2023 |