Page 1 of 1

[NXC] Mindsensors PSP-Nx Incorrect Constants

Posted: 20 Aug 2011, 22:35
by muntoo
They should be:

Code: Select all

#define 	PSP_BTNSET2_SQUARE   0x80
#define 	PSP_BTNSET2_CROSS   0x40
#define 	PSP_BTNSET2_CIRCLE   0x20
#define 	PSP_BTNSET2_TRIANGLE   0x10
#define 	PSP_BTNSET2_R1   0x08
#define 	PSP_BTNSET2_L1   0x04
#define 	PSP_BTNSET2_R2   0x02
#define 	PSP_BTNSET2_L2   0x01
Possibly the same with PSP_BTNSET1_xxx.

Re: [NXC] Mindsensors PSP-Nx Incorrect Constants

Posted: 21 Aug 2011, 16:06
by afanofosc
This will be fixed in the next release. Thanks for reporting the problem.

John Hansen

Re: [NXC] Mindsensors PSP-Nx Incorrect Constants

Posted: 22 Aug 2011, 22:50
by mattallen37
Before I learned how to use constants and bitwise operators/comparators, I designed my own set of code to determine what buttons are pressed. Here is the code that is more than just tried and true to work (used it in hundreds of programs).

Code: Select all

    ReadSensorMSPlayStation(PSP_Port, PSP_Addr, b1, b2, lx, ly, rx, ry);

    B2=b2*(-1)+255;
    if (B2>=128){squ =1;B2-=128;}else{squ =0;}
    if (B2>=64) {crs =1;B2-=64;} else{crs =0;}
    if (B2>=32) {cir =1;B2-=32;} else{cir =0;}
    if (B2>=16) {tri =1;B2-=16;} else{tri =0;}
    if (B2>=8)  {R1  =1;B2-=8;}  else{R1  =0;}
    if (B2>=4)  {L1  =1;B2-=4;}  else{L1  =0;}
    if (B2>=2)  {R2  =1;B2-=2;}  else{R2  =0;}
    if (B2>=1)  {L2  =1;B2-=1;}  else{L2  =0;}

    B1=b1*(-1)+255;
    if (B1>=128){lft =1;B1-=128;}else{lft =0;}
    if (B1>=64) {dwn =1;B1-=64;} else{dwn =0;}
    if (B1>=32) {rght=1;B1-=32;} else{rght=0;}
    if (B1>=16) {up  =1;B1-=16;} else{up  =0;}
    if (B1>=8)  {str =1;B1-=8;}  else{str =0;}
    if (B1>=4)  {sr  =1;B1-=4;}  else{sr  =0;}
    if (B1>=2)  {sl  =1;B1-=2;}  else{sl  =0;}
    if (B1>=1)  {sel =1;B1-=1;}  else{sel =0;}
Just because I have been using this for so long, and don't want to go back and change all my programs, I still haven't updated to a better method yet.

According to that, the constants should be like this for button set 1(based on doing *(-1)+255 which inverts all the bits like a NOT would do, like Muntoo must be doing).

Code: Select all

#define 	PSP_BTNSET1_LEFT   0x80
#define 	PSP_BTNSET1_DOWN   0x40
#define 	PSP_BTNSET1_RIGHT  0x20
#define 	PSP_BTNSET1_UP     0x10
#define 	PSP_BTNSET1_STR    0x08
#define 	PSP_BTNSET1_R3     0x04
#define 	PSP_BTNSET1_L3     0x02
#define 	PSP_BTNSET1_SEL    0x01

Re: [NXC] Mindsensors PSP-Nx Incorrect Constants

Posted: 23 Aug 2011, 01:10
by afanofosc
What are STR and SEL? These two buttons aren't listed in the docs that I have from mindsensors.com.

John Hansen

Re: [NXC] Mindsensors PSP-Nx Incorrect Constants

Posted: 23 Aug 2011, 01:21
by muntoo
afanofosc wrote:What are STR and SEL?
Start and select buttons respectively. The mindsensors demo program didn't include them either, for some reason. They work OK, though.

Re: [NXC] Mindsensors PSP-Nx Incorrect Constants

Posted: 23 Aug 2011, 03:59
by mattallen37
Muntoo is right. However, I though it was the l3 and r3 that were left out of the mindsensors docs... I guess I was probably wrong.

Anyhow, they should be included in the NXC and the mindsensors docs.

Re: [NXC] Mindsensors PSP-Nx Incorrect Constants

Posted: 23 Aug 2011, 06:01
by mightor
Matt,

Pop a mail to [email protected] and let them know about the omission in the docs :)

- Xander

Re: [NXC] Mindsensors PSP-Nx Incorrect Constants

Posted: 23 Aug 2011, 07:49
by muntoo
mattallen37 wrote:l3 and r3 that were left out of the mindsensors docs...
Those were missing too, IIRC. :)

Re: [NXC] Mindsensors PSP-Nx Incorrect Constants

Posted: 23 Aug 2011, 15:12
by mattallen37
Xander,

I thought I had told Deepak, but maybe I forgot. He is away on vacation right now anyhow, but I'll (try to remember to) mention it in my next email.