我有2个Playstation 巴斯! USB控制器,所以8人可以并行参与。我也知道这些蜂鸣器可以连接到电脑上。
用例:我正在为各种事情进行培训(Wireshark,调试,.)课后,我想和参与者一起做一个小测验。参与者可以赢得一些小东西,例如糖果。在过去,我每件事都是手工完成的,但有时会讨论谁是第一个给出答案的人。因为所有的训练都是深层次的技术训练,我认为使用蜂鸣器会是一个很好的噱头。
我现在在找一个软件
已经是这样了。我不需要支持其余的4个按钮,因为回答问题将由我处理。
我知道Buzzmania,但这已经太自动化了,我不想提前产生问题。我不能让你不了解JackBuzz工作。
发布于 2016-01-26 21:24:40
哇,我没想到会那么容易。我使用BuzzIO Nuget包装 for .NET在45分钟内完成了所有操作。
这是一个没有面向对象设计的最小应用程序。
using System;
using System.Collections.Generic;
using System.Linq;
using BuzzIO;
namespace BuzzExample
{
class Program
{
private static IEnumerable<IBuzzHandsetDevice> _handsets;
static void Main()
{
_handsets = new BuzzHandsetFinder().FindHandsets();
foreach (var handset in _handsets)
{
handset.SetLights(true, true, true, true);
handset.ButtonChanged += HandsetOnButtonChanged;
}
Console.WriteLine("Press Enter to end");
Console.ReadLine();
}
private static void HandsetOnButtonChanged(object sender, BuzzButtonChangedEventArgs args)
{
for (int i = 0; i < args.Buttons.Length; i++)
{
Console.Write($"{i}: ");
if (!args.Buttons[i].Any) Console.Write("None");
if (args.Buttons[i].Blue) Console.Write("Blue ");
if (args.Buttons[i].Green) Console.Write("Green ");
if (args.Buttons[i].Yellow) Console.Write("Yellow ");
if (args.Buttons[i].Orange) Console.Write("Orange ");
if (args.Buttons[i].Red) Console.Write("Buzzer ");
Console.WriteLine();
}
Console.WriteLine();
var lights = new bool[4];
for (int i = 0; i < args.Buttons.Length; i++)
{
lights[i] = args.Buttons[i].Any;
}
_handsets.First().SetLights(lights[0], lights[1], lights[2], lights[3]);
}
}
}Windows 10提示:控制器可以安装为“符合HID的游戏控制器”。在这种情况下,库可能找不到连接的控制器。要解决这个问题,请转到设备管理器,并将驱动程序切换到“HID兼容设备”。我的公司有索尼的供应商ID (VID) 054C和产品ID (PID) 1000。
对于蜂鸣器的声音,我使用了胆量,并产生了以下声音
要播放声音,可以使用嵌入式资源和SoundPlayer:
// Playing sound from embedded resource
Stream buzzerStream = Resource.buzz;
buzzPlayer = new SoundPlayer(buzzerStream);
...
buzzPlayer.Play();https://softwarerecs.stackexchange.com/questions/28306
复制相似问题