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_ver_circlewar by
Diff: User.cpp
- Revision:
- 14:639d019dfee8
- Parent:
- 12:d35077f98a08
- Child:
- 15:d9485d4c3b8c
--- a/User.cpp Mon Feb 15 08:36:10 2016 +0000 +++ b/User.cpp Wed Feb 17 08:34:51 2016 +0000 @@ -1,14 +1,13 @@ /*分かれ!J!*/ - - #include "Utils.h" #include "USBHost.h" #include "hci.h" #include "ps3.h" #include "User.h" #include "mbed.h" +#define DEBUG_MODE int RSX,RSY,LSX,LSY,BSU,BSL; //これより下に関数外に書く要素を記入する @@ -78,25 +77,43 @@ LH=1; } if((ButtonState >> BUTTONR1)&1){ - M=+32768; + M+=1 << 15; } - else if((ButtonState >> BUTTONL2)&1){ - M=+16384; + else if((ButtonState >> BUTTONL1)&1){ + M+=1 << 14; } if(LSX-128>=0){ - M=+8192; - M=+(LSX-128)*64; + M+=1 << 13; + M+=((LSX-128)/2) << 7; } else if(LSX-128<0){ - M=+(-1)*((LSX-128)*64); + if(128-LSX==128)M+=63 << 7; + else M+=((128-LSX)/2) << 7; + } + if(LSY-127<=0){ + M+=1 << 6; + M+=((127-LSY)/2); + } + else if(LSY-127>0){ + if(LSY-127==128)M+=63; + else M+=(LSY-127)/2; } - if(LSY-128>=0){ - M=+64; - M=+((LSY-128)/2); - } - else if(LSY-128<0){ - M=+((-1)*(LSY-128)); - } + #ifdef DEBUG_MODE + int MM,i,MA[16]; + MM=M; + for(i=0;MM>0;i++){ + MA[i]=MM % 2; + MM=MM/2; + } + for(i=i+1;i<16;i++){ + MA[i]=0; + } + for(i=15;i>=0;i--){printf("%d",MA[i]);} + printf("\r\n"); + #endif + //printf("LSX=%d,LSY=%d\r\n",LSX,LSY); + printf("M=%d \r\n",M); + m.write(M); led1=LSX/256.0f; @@ -104,5 +121,5 @@ led3=ButtonState & 0x0400; //L1の状態 led4=ButtonState & 0x0800; //R1の状態 //値の取得はps3.hを参照 - cs=1; + cs=1; } \ No newline at end of file