通过XML-RPC发送远程信号
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通过XML-RPC发送远程信号相关的知识,希望对你有一定的参考价值。
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); }
以上是关于通过XML-RPC发送远程信号的主要内容,如果未能解决你的问题,请参考以下文章
XML-RPC(remote procedure call 远程过程调用远端程序呼叫)(一种通过XML将调用函数封装,并使用HTTP协议作为传送机制的分布式计算协议)