ps3からボタンの状態を受け取るプログラム

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
yosino_adati
Date:
Fri Jul 13 07:52:12 2018 +0000
Commit message:
ps3??????????????????

Changed in this revision

PS3.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r f7b14a62d165 PS3.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PS3.lib	Fri Jul 13 07:52:12 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/INCTRC-Information-Sgaring-Test/code/PS3/#2e81f7d32c67
diff -r 000000000000 -r f7b14a62d165 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jul 13 07:52:12 2018 +0000
@@ -0,0 +1,124 @@
+#include "mbed.h"
+#include "PS3.h"
+
+#define pr pc.printf
+
+PS3 ps3(D8,D2);
+//Serial pc(USBTX,USBRX);
+DigitalOut myled(LED1);
+bool Ue;
+bool Sita;
+bool Migi;
+bool Hidari;
+bool Sankaku;
+bool Sikaku;
+bool Maru;
+bool Batu;
+bool l1;
+bool l2;
+bool r1;
+bool r2;
+
+
+int main()
+{
+  //  pc.baud(9600);
+    while(1) {
+
+
+        //ps3.printdata();
+
+
+        int RX = ps3.getRightJoystickXaxis();//右スティックX軸
+        int RY = ps3.getRightJoystickYaxis();//右スティックY軸
+        int LX = ps3.getLeftJoystickXaxis();//左スティックX軸
+        int LY = ps3.getLeftJoystickYaxis();//左スティックY軸
+
+        bool Select = ps3.getSELECTState();
+        bool Start = ps3.getSTARTState();
+
+        Ue      = ps3.getButtonState(ue);
+        Sita    = ps3.getButtonState(sita);
+        Migi    = ps3.getButtonState(migi);
+        Hidari  = ps3.getButtonState(hidari);
+
+        Sankaku = ps3.getButtonState(sankaku);
+        Maru    = ps3.getButtonState(maru);
+        Sikaku  = ps3.getButtonState(sikaku);
+        Batu    = ps3.getButtonState(batu);
+
+        r1      = ps3.getButtonState(R1);
+        r2      = ps3.getButtonState(R2);
+        l1      = ps3.getButtonState(L1);
+        l2      = ps3.getButtonState(L2);
+
+
+        if(RX>50||RY<-50) {
+            //pr("RJ:%3d_%3d_",RX,RY);
+            myled = 1;
+        }
+        else if(LX>50||LY<-50) {
+            //pr("LJ:%3d_%3d_",LX,LY);
+            myled = 1;
+        }
+        else if((Ue==1)&&(Start!=1)) {
+            //pr("ue ");
+            myled = 1;
+        }
+        else if((Sita==1)&&(Start!=1)) {
+            //pr("sita ");
+            myled = 1;
+        }
+        else if((Migi==1)&&(Select!=1)) {
+            //pr("migi ");
+            myled = 1;
+        }
+        else if((Hidari==1)&&(Select!=1)) {
+            //pr("hidari ");
+            myled = 1;
+        }
+        else if(Sankaku==1) {
+            //pr("sankaku ");
+            myled = 1;
+        }
+        else if(Maru==1) {
+            //pr("maru ");
+            myled = 1;
+        }
+        else if(Sikaku==1) {
+            //pr("sikaku ");
+            myled = 1;
+        }
+        else if(Batu==1) {
+            //pr("batu ");
+            myled = 1;
+        }
+        else if(r1==1) {
+            //pr("r1 ");
+            myled = 1;
+        }
+        else if(r2==1) {
+            //pr("r2 ");
+            myled = 1;
+        }
+        else if(l1==1) {
+            //pr("l1 ");
+            myled = 1;
+        }
+        else if(l2==1) {
+            //pr("l2 ");
+            myled = 1;
+        }
+        else if(Select==1) {
+            //pr("SELECT ");
+            myled = 1;
+        }
+        else if(Start==1) {
+            //pr("START ");
+            myled = 1;
+        }else{
+            myled = 0;
+        }
+        //pr("\n");
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r f7b14a62d165 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jul 13 07:52:12 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file