A minimalist JRuby module for using USB Buzz!™ controllers (the non-wireless flavour).
With cross-platform support thanks to "javahidapi".
You will need Java and JRuby obviously.
Register for keypress events, switch on and off the buzzer lights and create awesome games! Here is how:
require'jbuzzr'buzzer=JBuzzr.devices.values.firstpbuzzer.lights.status# => [false, false, false, false]# let there be lightpbuzzer.lights.updatetrue,true,true,true# => [true, true, true, true]sleep2# ...except for player 1pbuzzer.lights.updatefalse,nil,nil,nil# => [false, true, true, true]sleep2# ok, enough goofing aroundbuzzer.lights.updatefalse,false,false,false# now let's couple the lights to buzzer events buzzer.status.listeners << Proc.newdo |event|
ifevent[:button] == :buzzerlight_command=[nil,nil,nil,nil]light_command[event[:controller]-1]=(event[:action] == :pressed)buzzer.lights.update *light_commandendend# now let's prepare our main looplooping=true# let's also get debug output and add exit_on_yellow_button buzzer.status.listeners << Proc.newdo |event|
peventlooping= !(event[:button] == :yellow)endwhileloopingdosleep1endDistributed under the "New BSD" license - because it's not the GPL and it is offered by javahidapi, too.