Revision: 17634
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 11, 2009 01:47 by wearetherock
Initial Code
use Linux::Input::Wiimote; require RPC::XML; require RPC::XML::Client; print "remote control ...\n"; my $cli = RPC::XML::Client->new("http://localhost:9191"); my $wii = new Linux::Input::Wiimote; ############################## sub get_device_id { my $dev = $wii->wiimote_discover(); print $dev; if ($dev eq 0){ print "Not found device, exit now\n"; #exit(0); }else{ print "Found dev $dev"; } return $dev; } ############################## my $dev = 0; while ($dev eq 0){ print "Press 1+2 ...\n"; $dev = get_device_id(); } $wii->wiimote_connect("00:1$dev"); while (1){ $wii->wiimote_update(); my $keys = "RELEASE"; if($wii->get_wiimote_keys_down && $wii->get_wiimote_keys_b){ $keys = "B-DOWN"; }elsif ($wii->get_wiimote_keys_up && $wii->get_wiimote_keys_b){ $keys = "B-UP"; }elsif ($wii->get_wiimote_keys_left && $wii->get_wiimote_keys_b){ $keys = "B-LEFT"; }elsif ($wii->get_wiimote_keys_right && $wii->get_wiimote_keys_b){ $keys = "B-RIGHT"; }elsif ($wii->get_wiimote_keys_a && $wii->get_wiimote_keys_b){ $keys = "B-A"; }elsif($wii->get_wiimote_keys_down()){ $keys = "DOWN"; }elsif ($wii->get_wiimote_keys_right()){ $keys = "RIGHT"; }elsif ($wii->get_wiimote_keys_up()){ $keys = "UP"; }elsif ($wii->get_wiimote_keys_left()){ $keys = "LEFT"; }elsif ($wii->get_wiimote_keys_a()){ $keys = "A"; }elsif ($wii->get_wiimote_keys_b()){ $keys = "B"; }elsif ($wii->get_wiimote_keys_1()){ $keys = "1"; }elsif ($wii->get_wiimote_keys_2()){ $key = "2"; }elsif ($wii->get_wiimote_keys_home()){ $keys = "HOME"; }elsif ($wii->get_wiimote_keys_minus()){ $keys = "MINUS"; }elsif ($wii->get_wiimote_keys_plus()){ $keys = "PLUS"; }else { $keys = "RELEASE"; } #print $keys; print "wearetherock ok $keys\n"; $cli->send_request("updateState", $keys); }
Initial URL
Initial Description
Initial Title
Send Wiimote Signal Through XML-RPC
Initial Tags
perl
Initial Language
Perl