Introducing the simple_wiimote gem

require 'simple_wiimote'

swm = SimpleWiimote.new

swm.led = 1
swm.rumble = true
sleep 0.2
swm.rumble = false

# activate the loop to detect key press events
swm.activate # deactivate by pressing button A

swm.events[WiiMote::BTN_1] = -> {puts 'sunny'}
swm.terminator = WiiMote::BTN_B
swm.activate # deactive by pressing button B

swm.activate {|wiimote| puts "[ %3d, %3d, %3d ]" % wiimote.acc}

# deactiving the loop without pressing a button
swm.activate {|wiimote| puts "[ %3d, %3d, %3d ]" % wiimote.acc;  wiimote.active = false}

swm.close

Resources

Tags:
Source:
0101hrs.txt
Published:
16-12-2011 01:01