/ Published in: Perl
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
use Linux::Input::Wiimote; my $cli = RPC::XML::Client->new("http://localhost:9191"); my $wii = new Linux::Input::Wiimote; ############################## sub get_device_id { my $dev = $wii->wiimote_discover(); if ($dev eq 0){ #exit(0); } ############################## my $dev = 0; while ($dev eq 0){ $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; $cli->send_request("updateState", $keys); }