forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Strange problems with built-in osk

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Thu Dec 25, 2008 2:40 am    Post subject: Strange problems with built-in osk Reply with quote

I've added to my programs the support for the sony osk, it has worked perfectly, but now sometimes is blitted in a strage mode...
Here a screen:

_________________
Get Xplora!
Back to top
View user's profile Send private message
Dariusc123456



Joined: 12 Aug 2008
Posts: 394

PostPosted: Thu Dec 25, 2008 3:14 am    Post subject: Reply with quote

Thats strange. Are you using gu and gum? That can sometimes cause problems.
Back to top
View user's profile Send private message AIM Address
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Thu Dec 25, 2008 5:12 am    Post subject: Reply with quote

mmm...
No, only sceGu...
_________________
Get Xplora!
Back to top
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Thu Dec 25, 2008 5:55 am    Post subject: Reply with quote

You're either using un-aligned memory which should be aligned, or you're trashing your display list somehow.

Show some code.
Back to top
View user's profile Send private message
Dariusc123456



Joined: 12 Aug 2008
Posts: 394

PostPosted: Thu Dec 25, 2008 6:04 am    Post subject: Reply with quote

Show the sony osk code, and maybe we can help you more.
Back to top
View user's profile Send private message AIM Address
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Thu Dec 25, 2008 10:09 am    Post subject: Reply with quote

Interesting,
I've had the same problem a few times, but not with the OSK.
The picture split into four (not just two), and the same effect with the colours.
_________________
If not actually, then potentially.
Back to top
View user's profile Send private message
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Thu Dec 25, 2008 11:30 pm    Post subject: Reply with quote

This is the code: ( not my )
Code:

#define BUF_WIDTH (512)
#define SCR_WIDTH (480)
#define SCR_HEIGHT (272)
#define PIXEL_SIZE (4) /* change this if you change to another screenmode */
#define FRAME_SIZE (BUF_WIDTH * SCR_HEIGHT * PIXEL_SIZE)
#define ZBUF_SIZE (BUF_WIDTH SCR_HEIGHT * 2) /* zbuffer seems to be 16-bit? */

#define NUM_INPUT_FIELDS (1)
#define TEXT_LENGTH (128)
static unsigned int __attribute__((aligned(16))) list[262144];


// setupGu and resetGU:


static void setupGu(void)
{
    sceGuInit();
    sceGuStart(GU_DIRECT, list);
    sceGuDrawBuffer(GU_PSM_8888, (void*)0, BUF_WIDTH);
    sceGuDispBuffer(SCR_WIDTH, SCR_HEIGHT, (void*)0x88000, BUF_WIDTH);
    sceGuDepthBuffer((void*)0x110000, BUF_WIDTH);
    sceGuOffset(2048 - (SCR_WIDTH / 2), 2048 - (SCR_HEIGHT / 2));
    sceGuViewport(2048, 2048, SCR_WIDTH, SCR_HEIGHT);
    sceGuDepthRange(0xc350, 0x2710);
    sceGuScissor(0, 0, SCR_WIDTH, SCR_HEIGHT);
    sceGuEnable(GU_SCISSOR_TEST);
    sceGuDepthFunc(GU_GEQUAL);
    sceGuEnable(GU_DEPTH_TEST);
    sceGuFrontFace(GU_CW);
    sceGuShadeModel(GU_SMOOTH);
    sceGuEnable(GU_CULL_FACE);
    sceGuEnable(GU_CLIP_PLANES);
    sceGuFinish();
    sceGuSync(0, 0);
    sceDisplayWaitVblankStart();
    sceGuDisplay(GU_TRUE);
}


// Get text from OSK:


int get_text_osk(char *input, unsigned short *intext, unsigned short *desc)
{
    int done = 0;
    setupGu();

    // unsigned short intext[NUM_INPUT_FIELDS][TEXT_LENGTH];
    unsigned short outtext[NUM_INPUT_FIELDS][TEXT_LENGTH];
    // unsigned short desc[NUM_INPUT_FIELDS][TEXT_LENGTH];

    SceUtilityOskData data[NUM_INPUT_FIELDS];

    int i;

    for(i = 0; i < NUM_INPUT_FIELDS; i++)
    {
        memset(&data[i], 0, sizeof(SceUtilityOskData));
        data[i].language = PSP_UTILITY_OSK_LANGUAGE_DEFAULT; // Use system default for text input
        data[i].lines = 1;
        data[i].unk_24 = 1;
        data[i].inputtype = PSP_UTILITY_OSK_INPUTTYPE_LATIN_DIGIT | PSP_UTILITY_OSK_INPUTTYPE_LATIN_LOWERCASE | PSP_UTILITY_OSK_INPUTTYPE_LATIN_UPPERCASE; // Allow all input types
        data[i].desc = desc;
        data[i].intext = intext;
        data[i].outtextlength = TEXT_LENGTH;
        data[i].outtextlimit = 128; // Limit input
        data[i].outtext = outtext[i];
    }

    SceUtilityOskParams params;
    memset(&params, 0, sizeof(params));
    params.base.size = sizeof(params);
    sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, &params.base.language);
    sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_UNKNOWN, &params.base.buttonSwap);
    params.base.graphicsThread = 17;
    params.base.accessThread = 19;
    params.base.fontThread = 18;
    params.base.soundThread = 16;
    params.datacount = NUM_INPUT_FIELDS;
    params.data = data;

    sceUtilityOskInitStart(&params);

    while(!done)
    {
        sceGuStart(GU_DIRECT, list);
        sceGuClearColor(0);
        sceGuClearDepth(0);
        sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT);

        sceGuFinish();
        sceGuSync(0, 0);

        switch(sceUtilityOskGetStatus())
        {
            case PSP_UTILITY_DIALOG_INIT:
                break;

            case PSP_UTILITY_DIALOG_VISIBLE:
                sceUtilityOskUpdate(1);
                break;

            case PSP_UTILITY_DIALOG_QUIT:
                sceUtilityOskShutdownStart();
                break;

            case PSP_UTILITY_DIALOG_FINISHED:
                break;

            case PSP_UTILITY_DIALOG_NONE:
                done = 1;

            default:
                break;
        }

        sceDisplayWaitVblankStart();
        sceGuSwapBuffers();
    }

    pspDebugScreenInit();
    pspDebugScreenSetXY(0, 0);

    int j;

    for(i = 0; i < NUM_INPUT_FIELDS; i++)
    {
        switch(data[i].result)
        {
            case PSP_UTILITY_OSK_RESULT_UNCHANGED:
                break;

            case PSP_UTILITY_OSK_RESULT_CANCELLED:
                input = "\0";
                sceGuTerm();
                return 1;

            case PSP_UTILITY_OSK_RESULT_CHANGED:
                break;

            default:
                break;
        }
       
        int n = 0;

        for(j = 0; data[i].outtext[j]; j++)
        {
            if(data[i].outtext[j] != '\0' && data[i].outtext[j] != '\n' && data[i].outtext[j] != '\r')
            {
                input[j] = data[i].outtext[j];
                n++;
            }
        }
        input[n] = '\0';
    }
    sceGuTerm();

    return 1;
}


char *requestString(char *initialStr, char* initialDesc)
{
    int ok, i;
    char* str = (char*)malloc(128);
    unsigned short intext[128] = {0}; // text already in the edit box on start
    unsigned short desc[128] = {0}; // description

    if(initialStr[0] != 0)
        for(i = 0; i <= strlen(initialStr); i++)
            intext[i] = (unsigned short)initialStr[i];

    if(initialDesc[0] != 0)
        for(i = 0; i <= strlen(initialDesc); i++)
            desc[i] = (unsigned short)initialDesc[i];

    ok = get_text_osk(str, intext, desc);

    if(ok)
        return str;

    return 0;
}

_________________
Get Xplora!
Back to top
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Sat Dec 27, 2008 10:18 am    Post subject: Reply with quote

We need the rest of the code you use to draw.

My original statement still stands.
Back to top
View user's profile Send private message
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Sat Dec 27, 2008 11:57 pm    Post subject: Reply with quote

Now I've no one problem...and I haven't modified a lot the src...
Anyway, this is the rename function:
Code:

[...]
XgeInit();
while(running)
{
    ...
    Rinomina();
    ...
    // Blit some images
    ...
    XgeRequestScreenRefresh(); // sceGuSwapBuffers is called
}
[...]
void Rinomina()
{
    F* fileselez = X_engine.GetCurrentFile();

    char* temp_file = requestString(fileselez->nome, language->menu_operazioni.rename);
    if(strcmp(temp_file, "\0") != 0)
    {
        sceIoRename(fileselez->nome, temp_file);
    }
    free(temp_file);
    XgeInit();
    X_engine.Refresh();
}

_________________
Get Xplora!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group