Advertising (This ad goes away for registered users. You can Login or Register)

How to use SceCtrlPeekBufferPositiveExtra()?

Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
Post Reply
User avatar
reprep
Posts: 1074
Joined: Tue Dec 17, 2013 4:38 pm

How to use SceCtrlPeekBufferPositiveExtra()?

Post by reprep » Tue Feb 10, 2015 7:38 pm

First of all, i should say i don't know much about PSP programming. I will shoot it anyways.

I want to write an application which reads Dualshock 3 buttons input on a PSP go and display the result. here is one:

http://en.wikibooks.org/wiki/PSP_Progra ... tton_Input

but the problem is i need one using sceCtrlPeekBufferPositiveExtra() instead of sceCtrlPeekBufferPositive() as sceCtrlPeekBufferPositive() only returns psp pad values. I know that if you pass arg 1 as "1" to sceCtrlPeekBufferPositiveExtra() it reads ds3 inputs. You might ask how you know this as it isn't documented even in uofw. It is from the DS3 Remapper source code. http://uofw.github.io/uofw/group__Contr ... 4606e13027 viewtopic.php?f=28&t=39588&start=50 (have a look at the spoiler part and see how the sceCtrlReadBuf is patched to pass arg1 (a2) as 1. This works for DS3. have a look at line 980 https://github.com/uofw/uofw/blob/maste ... trl/ctrl.c)

anyways the problem is i have to use SceCtrlExtendInternalCtrlBuffers() before calling sceCtrlPeekBufferPositive() but i have no idea how to do that.

thanks in advance.


tldr; i need a sample button input program which uses SceCtrlPeekBufferPositiveExtra()

EDIT: Tried something but still getting errors. here is my main.c
[spoiler]#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>

#include "callback.h"
#define VERS 1
#define REVS 1

PSP_MODULE_INFO("Button Input", PSP_MODULE_USER, VERS, REVS);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
PSP_HEAP_SIZE_MAX();
#define printf pspDebugScreenPrintf
int main()
{
pspDebugScreenInit();
setupExitCallback();

int running = isRunning();

SceCtrlDataExt buttonInput;

sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
while(running)
{
running = isRunning();

pspDebugScreenSetXY(0, 0);
printf("Analog X = %d ", buttonInput.Lx);
printf("Analog Y = %d \n", buttonInput.Ly);
sceCtrlPeekBufferPositiveExtra (1, &buttonInput, 1);

if(buttonInput.Buttons != 0)
{
if(buttonInput.Buttons & PSP_CTRL_START){
printf("Start");
running = 0;
}
if(buttonInput.Buttons & PSP_CTRL_SELECT) printf("Select");
if(buttonInput.Buttons & PSP_CTRL_UP) printf("Up");
if(buttonInput.Buttons & PSP_CTRL_DOWN) printf("Down");
if(buttonInput.Buttons & PSP_CTRL_RIGHT) printf("Right");
if(buttonInput.Buttons & PSP_CTRL_LEFT) printf("Left");

if(buttonInput.Buttons & PSP_CTRL_CROSS) printf("Cross");
if(buttonInput.Buttons & PSP_CTRL_CIRCLE) printf("Circle");
if(buttonInput.Buttons & PSP_CTRL_SQUARE) printf("Square");
if(buttonInput.Buttons & PSP_CTRL_TRIANGLE) printf("Triangle");

if(buttonInput.Buttons & PSP_CTRL_RTRIGGER) printf("R-Trigger");
if(buttonInput.Buttons & PSP_CTRL_LTRIGGER) printf("L-Trigger");
}
}

sceKernelExitGame();
return 0;
}[/spoiler]

i added these lines to pspctrl.h

[spoiler]typedef struct SceCtrlDataExt {
/** The current read frame. */
unsigned int TimeStamp;
/** Bit mask containing zero or more of ::PspCtrlButtons. */
unsigned int Buttons;
/** Analogue stick, X axis. */
unsigned char Lx;
/** Analogue stick, Y axis. */
unsigned char Ly;
/** Reserved. */
unsigned char Rsrv[6];
unsigned int unk1;
unsigned int unk2;
unsigned int unk3;
unsigned int unk4;
unsigned int unk5;
unsigned int unk6;
unsigned int unk7;
unsigned int unk8;
} SceCtrlDataExt;
int sceCtrlPeekBufferPositiveExtra(int arg1, SceCtrlDataExt *pad_data, int count);

int sceCtrlPeekBufferNegativeExtra(int arg1, SceCtrlDataExt *pad_data, int count);

int sceCtrlReadBufferPositiveExtra(int arg1, SceCtrlDataExt *pad_data, int count);

int sceCtrlReadBufferNegativeExtra(int arg1, SceCtrlDataExt *pad_data, int count);[/spoiler]
i still get this. What is wrong?
main.c:(.text+0xcc): undefined reference to `sceCtrlPeekBufferPositiveExtra'
make: *** [ButtonInput.elf] Error 1
Advertising

User avatar
Yoti
VIP
Posts: 360
Joined: Sun Oct 17, 2010 4:49 am
Location: Russia

Re: How to use SceCtrlPeekBufferPositiveExtra()?

Post by Yoti » Thu Feb 12, 2015 9:29 am

There is no such func in controller library, as I understand.
Advertising
IF SOMEONE HAS AN 07G PSP-3000 PLZ CONTACT ME VIA PM.

Image
Do not forget about adb kill-server. Really.

User avatar
reprep
Posts: 1074
Joined: Tue Dec 17, 2013 4:38 pm

Re: How to use SceCtrlPeekBufferPositiveExtra()?

Post by reprep » Thu Feb 12, 2015 10:21 am

Yoti wrote:There is no such func in controller library, as I understand.
thanks for the comment. It is in uOFW and i am pretty sure POPS use it to read extra inputs from DS3 controller for PS1 games. https://github.com/uofw/uofw/blob/maste ... trl/ctrl.c (line 970)

though i have no idea how to use it.

User avatar
Yoti
VIP
Posts: 360
Joined: Sun Oct 17, 2010 4:49 am
Location: Russia

Re: How to use SceCtrlPeekBufferPositiveExtra()?

Post by Yoti » Sat Feb 14, 2015 9:44 am

You must import it by NID. Smth like SceCtrl_1A2B3C4D. I also have PSPgo and DS3.
IF SOMEONE HAS AN 07G PSP-3000 PLZ CONTACT ME VIA PM.

Image
Do not forget about adb kill-server. Really.

Post Reply

Return to “Programming and Security”