您好,登錄后才能下訂單哦!
網(wǎng)上沒有直接用3藍(lán)牙連接樹莓派的教程,看到一篇用2b 和 藍(lán)牙適配器一起用 連接PS3 手柄的,所以先安裝一下試試。
http://tieba.baidu.com/p/3237051512
下面就是安裝必要的軟件了:
pi@raspberrypi ~ $ sudo apt-get install libusb-dev libbluetooth-dev libjack-dev
注:上面lib這個(gè)三個(gè)是必須裝的,是為了后面編譯要用到的 否則各種報(bào)錯(cuò)
可以在qtsixa官網(wǎng)下載
下載完畢后解壓:
pi@raspberrypi ~/tools/sixa $ tar -xvf QtSixA-src.tar.gz
進(jìn)入解壓文件夾:
pi@raspberrypi ~/tools/sixa $ cd QtSixA-1.5.1/
我們先編譯配對(duì)工具:
pi@raspberrypi ~/tools/sixa/QtSixA-1.5.1 $ cd utils/
打開“Makefile”, 把“WANT_JACK = false” 改為 “WANT_JACK = true”。
輸入“make”編譯工具:
pi@raspberrypi ~/tools/sixa/QtSixA-1.5.1/utils $ make
mkdir -p bins
cc -O2 -Wall -Wl,-Bsymbolic-functions hidraw-dump.c -o bins/hidraw-dump
cc -O2 -Wall -Wl,-Bsymbolic-functions sixpair.c -o bins/sixpair `pkg-config --cflags --libs libusb`
cc -O2 -Wall -Wl,-Bsymbolic-functions sixpair_kbd.c -o bins/sixpair-kbd `pkg-config --cflags --libs libusb`
編譯完后, 你可以在“./bins” 文件家里看到這些文件:
pi@raspberrypi ~/tools/sixa/QtSixA-1.5.1/utils $ ls bins
hidraw-dump sixad-jack sixpair sixpair-kbd
下面進(jìn)行配對(duì),將手柄用數(shù)據(jù)線接入樹莓派。 按下“ps”按鍵。
運(yùn)行“./bins/sixpair”。成功你會(huì)看到以下類似信息, 然后可以拔出你的手柄了:
pi@raspberrypi ~/tools/sixa/QtSixA-1.5.1/utils $ sudo ./bins/sixpair
Current Bluetooth master: xx:xx:xx:xx:xx:xx
Setting master bd_addr to: xx:xx:xx:xx:xx:xx
然后我們進(jìn)入”../sixad/“, 編譯“sixad“:
pi@raspberrypi ~/tools/sixa/QtSixA-1.5.1/utils $ cd ../sixad/
編譯并安裝”sixad“:
pi@raspberrypi ~/tools/sixa/QtSixA-1.5.1/sixad $ make
如果你的樹莓派版本比較新,gcc版本大于等于4.7以上的,make會(huì)報(bào)錯(cuò)
mkdir -p bins
g++ -O2 -Wall -Wl,-Bsymbolic-functions sixad-bin.cpp bluetooth.cpp shared.cpp textfile.cpp -o bins/sixad-bin `pkg-config --cflags --libs bluez` -lpthread -fpermissive
sixad-bin.cpp: In function ‘int main(int, char**)’:
sixad-bin.cpp:84:20: warning: taking address of temporary [-fpermissive]
sixad-bin.cpp:89:18: error: ‘close’ was not declared in this scope
sixad-bin.cpp:100:20: error: ‘sleep’ was not declared in this scope
sixad-bin.cpp:109:22: error: ‘close’ was not declared in this scopepi
其實(shí)有很多錯(cuò)誤 我截取了一段,都是類似這樣的錯(cuò)誤,需要改以下share.h的文件內(nèi)容就可以了
/* * shared.h * * This file is part of the QtSixA, the Sixaxis Joystick Manager * Copyright 2008-2011 Filipe Coelho <falktx@gmail.com> * * QtSixA can be redistributed and/or modified under the terms of the GNU General * Public License (Version 2), as published by the Free Software Foundation. * A copy of the license is included in the QtSixA source code, or can be found * online at www.gnu.org/licenses. * * QtSixA is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU General Public License for more details. * */ #ifndef SHARED_H #define SHARED_H #include <unistd.h> struct dev_led { bool enabled; bool anim; bool auto_sel; int number; }; struct dev_joystick { bool enabled; bool buttons; bool axis; bool sbuttons; bool accel; bool accon; bool speed; bool pos; }; struct dev_remote { bool enabled; bool numeric; bool dvd; bool directional; bool multimedia; }; struct dev_input { bool enabled; int key_select, key_l3, key_r3, key_start, key_up, key_right, key_down, key_left; int key_l2, key_r2, key_l1, key_r1, key_tri, key_cir, key_squ, key_cro, key_ps; int axis_l_type, axis_r_type, axis_speed; int axis_l_up, axis_l_right, axis_l_down, axis_l_left; int axis_r_up, axis_r_right, axis_r_down, axis_r_left; bool use_lr3; }; struct dev_rumble { bool enabled; bool old_mode; }; struct dev_timeout { bool enabled; int timeout; }; struct device_settings { bool auto_disconnect; struct dev_led led; struct dev_joystick joystick; struct dev_remote remote; struct dev_input input; struct dev_rumble rumble; struct dev_timeout timeout; }; bool was_active(); void set_active(int active); bool io_canceled(); void sig_term(int sig); void open_log(const char *app_name); struct device_settings init_values(const char *mac); int get_joystick_number(); void enable_sixaxis(int csk); #endif // SHARED_H
這是完整文件內(nèi)容,完全覆蓋就可以使用
@raspberrypi ~/tools/sixa/QtSixA-1.5.1/sixad $ sudo make install
啟動(dòng)”sixad“, 按下手柄”ps“鍵, 等待出現(xiàn)以下信息就成功了:
pi@raspberrypi ~/tools/sixa/QtSixA-1.5.1/sixad $ sudo sixad --start
sixad-bin[6117]: started
sixad-bin[6117]: sixad started, press the PS button now
sixad-bin[6117]: unable to connect to sdp session
sixad-bin[6117]: Connected Sony Computer Entertainment Wireless Controller (xx:xx:xx:xx:xx:xx)
之后就沒有錯(cuò)誤了 按照步驟 就可以連上ps3手柄
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。