| View previous topic :: View next topic |
| Author |
Message |
ne0h
Joined: 21 Feb 2008 Posts: 386
|
Posted: Sat Mar 15, 2008 7:10 am Post subject: Help with prx plugin... |
|
|
I try to make my first prx plugin, but the compiler give me some errors,
please help me...
Here is the complete source code:
http://nopaste.com/p/atfRrFUwJ
And here is the error:
In function 'unloadStopModule':
[Warning] assignment from incompatible pointer type
In function 'loadUsb':
[Warning] no return statement in function returning non-void
In function 'threadMain':
Line:292 invalid operands to binary |
Line:292 invalid operands to binary |
Line:297 invalid operands to binary |
Line:297 invalid operands to binary |
Line:303 invalid operands to binary |
Line:303 invalid operands to binary |
Line:308 invalid operands to binary |
Line:308 invalid operands to binary |
[Build Error] [main.o] Error 1
Please, someone give me help... |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sat Mar 15, 2008 8:22 am Post subject: |
|
|
| Code: | | if((pad.Buttons & ("HOME"|"NOTE")) == ("HOME"|"NOTE")) |
GREAT GALLOPING GHOSTS! I guess you've never bothered to look at any PSP code for using the pads. You want something that looks more like this:
| Code: | | if((pad.Buttons & (PSP_CTRL_HOME|PSP_CTRL_NOTE)) == (PSP_CTRL_HOME|PSP_CTRL_NOTE)) |
.Buttons is a field whose individual bits represent a particular button. They all have defines with names like PSP_CTRL_SQUARE. They make INTERGER VALUES, not strings. |
|
| Back to top |
|
 |
CpuWhiz
Joined: 04 Jun 2007 Posts: 42
|
Posted: Sat Mar 15, 2008 8:29 am Post subject: |
|
|
J.F. beat me to it :(
You are trying to binary or two strings and then binary and them with a unsigned integer. First off, to compare a or b it's a || b, not a | b. Second, you can't compare a string like that unless you are using the std::string class. Third, pad.Buttons is a bitmask (you should look up some information on binary math and bitmasks/bitfields to understand what is going on), you don't check it against strings. Look at the controller/basic sample for how to check button presses.
Wrong:
| Code: | | if((pad.Buttons & ("HOME"|"NOTE")) == ("HOME"|"NOTE") |
Right:
| Code: | if( (pad.Buttons & (PSP_CTRL_HOME | PSP_CTRL_NOTE)) == (PSP_CTRL_HOME | PSP_CTRL_NOTE) )
--or--
if( (pad.Buttons & PSP_CTRL_HOME) && (pad.Buttons & PSP_CTRL_NOTE) )
|
|
|
| Back to top |
|
 |
FreePlay
Joined: 04 Jan 2006 Posts: 71 Location: Schenectady, New York, USA
|
Posted: Sat Mar 15, 2008 8:35 am Post subject: |
|
|
Alternative:
| Code: | | if( pad.Buttons & (PSP_CTRL_HOME | PSP_CTRL_NOTE)){...} |
since that does the same thing.
Also,
| Code: | char tmp[32];
strcpy(tmp, "lsm: Error loading module ");
strcat(tmp, name);
doBlit(tmp); |
If 'name' is over 5 characters long, you will have a buffer overflow. 'tmp' starts with 26 chars, you add name, plus a null. 26+5+1=32. More than 5 chars... bad.
Also, you never change 'kill_display'... is this for debugging only?
Also, precisely what is the point of this?
| Code: | sprintf(strBuf0, "%s + %s = Shutdown PSP", "NOTE", "HOME");
sprintf(strBuf4, "%s + %s = Set Max Brightness", "NOTE", "DOWN");
sprintf(strBuf5, "%s + %s = Start/Stop Usb Mass", "NOTE", "L");
sprintf(strBuf8, "%s + %s = Show this help", "NOTE", "VOL_DOWN");
|
Especially when all the strings are used for is this:
| Code: | blit_string(1, 12, strBuf0,0xffffff,0x000000);
|
Just do this:
| Code: | | blit_string(1, 12, "NOTE + DOWN = Shutdown PSP",0xffffff,0x000000); |
Last edited by FreePlay on Sat Mar 15, 2008 8:39 am; edited 1 time in total |
|
| Back to top |
|
 |
CpuWhiz
Joined: 04 Jun 2007 Posts: 42
|
Posted: Sat Mar 15, 2008 8:39 am Post subject: |
|
|
| @FreePlay How does that require both buttons to be down? If only one of the two bits was set, it would still evaluate to > 0 and execute the if block. Or am I missing something? |
|
| Back to top |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
Posted: Sat Mar 15, 2008 8:51 am Post subject: |
|
|
Nope, you are correct CpuWhiz.
Freeplay's method only requires one of the two buttons to be pressed.
The correct method was posted by yourself and J.F. |
|
| Back to top |
|
 |
FreePlay
Joined: 04 Jan 2006 Posts: 71 Location: Schenectady, New York, USA
|
Posted: Sat Mar 15, 2008 8:56 am Post subject: |
|
|
| heh, you're absolutely right. I don't know what I was thinking. |
|
| Back to top |
|
 |
a_noob
Joined: 17 Sep 2006 Posts: 97 Location: _start: jr 0xDEADBEEF
|
Posted: Sat Mar 15, 2008 4:24 pm Post subject: |
|
|
the or operator means or for a reason ;) _________________
| Code: | .øOº'ºOø.
'ºOo.oOº' |
|
|
| Back to top |
|
 |
jean

Joined: 05 Jan 2008 Posts: 489
|
Posted: Sat Mar 15, 2008 8:13 pm Post subject: |
|
|
| Quote: | | the or operator means or for a reason ;) |
the funny thing -if you think of it- is that's not always so easy...
e.g. !(a|b)=!a&!b |
|
| Back to top |
|
 |
Cpasjuste
Joined: 29 May 2005 Posts: 214
|
Posted: Sat Mar 15, 2008 9:26 pm Post subject: |
|
|
Hehe i saw this code somewhere in the past :) |
|
| Back to top |
|
 |
ne0h
Joined: 21 Feb 2008 Posts: 386
|
Posted: Sat Mar 15, 2008 10:41 pm Post subject: |
|
|
The buttons are defined by me in translateButtons.h!
But i use it wrong:
"NOTE" = wrong
NOTE = true |
|
| Back to top |
|
 |
|