Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of PS3_BlueUSB_user_ver2 by
User.cpp
00001 #include "Utils.h" 00002 #include "USBHost.h" 00003 #include "hci.h" 00004 #include "ps3.h" 00005 #include "User.h" 00006 #include "mbed.h" 00007 00008 int RSX,RSY,LSX,LSY,BSU,BSL; 00009 //これより下に関数外に書く要素を記入する 00010 //spi通信用 00011 SPI spi(p5,p6,p7); 00012 DigitalOut cs(p8); 00013 00014 00015 void UserLoopSetting() 00016 { 00017 spi.format(16,3); 00018 spi.frequency(1000000); 00019 } 00020 00021 void UserLoop(char n,const u8* data) 00022 { 00023 u16 ButtonState; 00024 if(n==0) { //有線Ps3USB.cpp 00025 RSX = ((ps3report*)data)->RightStickX; 00026 RSY = ((ps3report*)data)->RightStickY; 00027 LSX = ((ps3report*)data)->LeftStickX; 00028 LSY = ((ps3report*)data)->LeftStickY; 00029 BSU = (u8)(((ps3report*)data)->ButtonState & 0x00ff); 00030 BSL = (u8)(((ps3report*)data)->ButtonState >> 8); 00031 //ボタンの処理 00032 ButtonState = ((ps3report*)data)->ButtonState; 00033 } else {//無線TestShell.cpp 00034 RSX = ((ps3report*)(data + 1))->RightStickX; 00035 RSY = ((ps3report*)(data + 1))->RightStickY; 00036 LSX = ((ps3report*)(data + 1))->LeftStickX; 00037 LSY = ((ps3report*)(data + 1))->LeftStickY; 00038 BSU = (u8)(((ps3report*)(data + 1))->ButtonState & 0x00ff); 00039 BSL = (u8)(((ps3report*)(data + 1))->ButtonState >> 8); 00040 //ボタンの処理 00041 ButtonState = ((ps3report*)(data + 1))->ButtonState; 00042 } 00043 //ここより下にプログラムを書く 00044 //spi通信用プログラム 00045 00046 int a,b,c,d,e,f,g,h,i,j; 00047 int send = 0; 00048 00049 00050 while(1) { 00051 if((ButtonState >> BUTTONTRIANGEL)&1 == 1) { //フォトトランジスタ1 00052 a = 1; 00053 } else { 00054 a = 0; 00055 } 00056 00057 if((ButtonState >> BUTTONCIRCLE)&1 == 1) {//フォトトランジスタ2 00058 b = 2; 00059 } else { 00060 b = 0; 00061 } 00062 00063 if((ButtonState >> BUTTONUP)&1 == 1) {//対応するボタンを書く(今回上ボタン 00064 c = 4; 00065 } else { 00066 c = 0; 00067 } 00068 00069 if((ButtonState >> BUTTONDOWN)&1 == 1) {//対応するボタンを書く(今回下ボタン 00070 d = 8; 00071 } else { 00072 d = 0; 00073 } 00074 00075 if((ButtonState >> BUTTONL1)&1 == 1) {//対応するボタンを書く(今回L1ボタン 00076 e = 16; 00077 } else { 00078 e = 0; 00079 } 00080 00081 if((ButtonState >> BUTTONL2)&1 == 1) {//対応するボタンを書く(今回L2ボタン 00082 f = 32; 00083 } else { 00084 f = 0; 00085 } 00086 00087 if((ButtonState >> BUTTONTRIANGEL)&1 == 1) {//対応するボタンを書く(今回△ボタン 00088 g = 64; 00089 } else { 00090 g = 0; 00091 } 00092 00093 if((ButtonState >> BUTTONCROSS)&1 == 1) {//対応するボタンを書く(今回×ボタン 00094 h = 128; 00095 } else { 00096 h = 0; 00097 } 00098 00099 if((ButtonState >> BUTTONR1)&1 == 1) {//対応するボタンを書く(今回R1ボタン 00100 i = 256; 00101 } else { 00102 i = 0; 00103 } 00104 00105 if((ButtonState >> BUTTONR2)&1 == 1) {//対応するボタンを書く(今回R2ボタン 00106 j = 512; 00107 } else { 00108 j = 0; 00109 } 00110 00111 00112 00113 send = a+b+c+d+e+f+g+h+i+j; 00114 00115 cs = 0; 00116 spi. write(send); 00117 cs = 1; 00118 printf("%d\r\n",send); 00119 00120 } 00121 }
Generated on Sat Jul 16 2022 22:57:24 by
