and the command ReadSensorMSPlayStation(); command. I have it in Analog mode.
I have some code:
Code: Select all
until(b2 == BTN_SET2_SQUARE);
Does anybody know the problem?
Code: Select all
until(b2 == BTN_SET2_SQUARE);
Code: Select all
int sel,str,up,dwn,lft,rght,L2,R2,L1,R1,tri,cir,crs,squ,sl,sr,b1,b2,B1,B2,lx,ly,rx,ry;
task main()
{
SetSensorLowspeed(S3);
while (true)
{
ReadSensorMSPlayStation(S3, 0x02, b1, b2, lx, ly, rx, ry);
B2=b2*(-1)+255;
if (B2>=128){squ=1;B2=B2-128;}else{squ=0;}
if (B2>=64){crs=1;B2=B2-64;}else{crs=0;}
if (B2>=32){cir=1;B2=B2-32;}else{cir=0;}
if (B2>=16){tri=1;B2=B2-16;}else{tri=0;}
if (B2>=8){R1=1;B2=B2-8;}else{R1 =0;}
if (B2>=4){L1=1;B2=B2-4;}else{L1 =0;}
if (B2>=2){R2=1;B2=B2-2;}else{R2 =0;}
if (B2>=1){L2=1;B2=B2-1;}else{L2 =0;}
B1=b1*(-1)+255;
if (B1>=128){lft=1;B1=B1-128;}else{lft=0;}
if (B1>=64){dwn=1;B1=B1-64;}else{dwn=0;}
if (B1>=32){rght=1;B1=B1-32;}else{rght=0;}
if (B1>=16){up=1;B1=B1-16;}else{up=0;}
if (B1>=8){str=1;B1=B1-8;}else{str=0;}
if (B1>=4){sr=1;B1=B1-4;}else{sr =0;}
if (B1>=2){sl=1;B1=B1-2;}else{sl =0;}
if (B1>=1){sel=1;B1=B1-1;}else{sel=0;}
ClearScreen(); // ___________________
NumOut(15,60,L2); // | L2* *R2 |
NumOut(78,60,R2); // | L1* *R1 |
NumOut(15,50,L1); // | up tri |
NumOut(78,50,R1); // | * selstr * |
NumOut(78,35,tri); // |lft * * cir|
NumOut(93,20,cir); // |* *rght *squ *|
NumOut(78,0,crs); // | dwn sl sr crs |
NumOut(63,20,squ); // | * * * * |
NumOut(40,30,sel);
NumOut(35,0,sl);
NumOut(58,0,sr);
NumOut(53,30,str);
NumOut(15,35,up);
NumOut(30,20,rght);
NumOut(15,0,dwn);
NumOut(0,20,lft);
NumOut(21,LCD_LINE1,ly);
NumOut(21,LCD_LINE2,lx);
NumOut(50,LCD_LINE1,ry);
NumOut(50,LCD_LINE2,rx);
}
}
/*
b1 series
sel =1
sl =2
sr =4
str =8
up =16
rght =32
dwn =64
lft =128
b2 series
L2 =1
R2 =2
L1 =4
R1 =8
tri =16
cir =32
crs =64
squ =128
Code: Select all
B2=~b2;
squ = (B2 >> 7) & 0x01;
crs = (B2 >> 6) & 0x01;
cir = (B2 >> 5) & 0x01;
tri = (B2 >> 4) & 0x01;
R1 = (B2 >> 3) & 0x01;
L1 = (B2 >> 2) & 0x01;
R2 = (B2 >> 1) & 0x01;
L2 = (B2 >> 0) & 0x01;
B1=~b1;
lft = (B1 >> 7) & 0x01;
dwn = (B1 >> 6) & 0x01;
rght= (B1 >> 5) & 0x01;
up = (B1 >> 4) & 0x01;
str = (B1 >> 3) & 0x01;
sr = (B1 >> 2) & 0x01;
sl = (B1 >> 1) & 0x01;
sel = (B1 >> 0) & 0x01;
Code: Select all
squ = (~b2 >> 7) & 0x01;
crs = (~b2 >> 6) & 0x01;
cir = (~b2 >> 5) & 0x01;
tri = (~b2 >> 4) & 0x01;
R1 = (~b2 >> 3) & 0x01;
L1 = (~b2 >> 2) & 0x01;
R2 = (~b2 >> 1) & 0x01;
L2 = (~b2 >> 0) & 0x01;
lft = (~b2 >> 7) & 0x01;
dwn = (~b2 >> 6) & 0x01;
rght= (~b2 >> 5) & 0x01;
up = (~b2 >> 4) & 0x01;
str = (~b2 >> 3) & 0x01;
sr = (~b2 >> 2) & 0x01;
sl = (~b2 >> 1) & 0x01;
sel = (~b2 >> 0) & 0x01;
That is why I use the bitwise NOT operator before I begin.nxtboyiii wrote:...BTW, when a button is pressed on the PSP-nx, the value equals zero, or false. So instead of doing, for example,
if(psp.square == true), it would be if(psp.square == false).
Users browsing this forum: Semrush [Bot] and 1 guest