Strange problems with built-in osk

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Strange problems with built-in osk

Post by ne0h »

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:
Image
Dariusc123456
Posts: 388
Joined: Tue Aug 12, 2008 12:46 am

Post by Dariusc123456 »

Thats strange. Are you using gu and gum? That can sometimes cause problems.
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

mmm...
No, only sceGu...
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

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

Show some code.
Dariusc123456
Posts: 388
Joined: Tue Aug 12, 2008 12:46 am

Post by Dariusc123456 »

Show the sony osk code, and maybe we can help you more.
Art
Posts: 642
Joined: Wed Nov 09, 2005 8:01 am

Post by Art »

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.
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

This is the code: ( not my )

Code: Select all

#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&#40;i = 0; i < NUM_INPUT_FIELDS; i++&#41;
    &#123;
        memset&#40;&data&#91;i&#93;, 0, sizeof&#40;SceUtilityOskData&#41;&#41;;
        data&#91;i&#93;.language = PSP_UTILITY_OSK_LANGUAGE_DEFAULT; // Use system default for text input
        data&#91;i&#93;.lines = 1;
        data&#91;i&#93;.unk_24 = 1;
        data&#91;i&#93;.inputtype = PSP_UTILITY_OSK_INPUTTYPE_LATIN_DIGIT | PSP_UTILITY_OSK_INPUTTYPE_LATIN_LOWERCASE | PSP_UTILITY_OSK_INPUTTYPE_LATIN_UPPERCASE; // Allow all input types
        data&#91;i&#93;.desc = desc;
        data&#91;i&#93;.intext = intext;
        data&#91;i&#93;.outtextlength = TEXT_LENGTH;
        data&#91;i&#93;.outtextlimit = 128; // Limit input
        data&#91;i&#93;.outtext = outtext&#91;i&#93;;
    &#125;

    SceUtilityOskParams params;
    memset&#40;&params, 0, sizeof&#40;params&#41;&#41;;
    params.base.size = sizeof&#40;params&#41;;
    sceUtilityGetSystemParamInt&#40;PSP_SYSTEMPARAM_ID_INT_LANGUAGE, &params.base.language&#41;;
    sceUtilityGetSystemParamInt&#40;PSP_SYSTEMPARAM_ID_INT_UNKNOWN, &params.base.buttonSwap&#41;;
    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&#40;&params&#41;;

    while&#40;!done&#41;
    &#123;
        sceGuStart&#40;GU_DIRECT, list&#41;;
        sceGuClearColor&#40;0&#41;;
        sceGuClearDepth&#40;0&#41;;
        sceGuClear&#40;GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT&#41;;

        sceGuFinish&#40;&#41;;
        sceGuSync&#40;0, 0&#41;;

        switch&#40;sceUtilityOskGetStatus&#40;&#41;&#41;
        &#123;
            case PSP_UTILITY_DIALOG_INIT&#58;
                break;

            case PSP_UTILITY_DIALOG_VISIBLE&#58;
                sceUtilityOskUpdate&#40;1&#41;;
                break;

            case PSP_UTILITY_DIALOG_QUIT&#58;
                sceUtilityOskShutdownStart&#40;&#41;;
                break;

            case PSP_UTILITY_DIALOG_FINISHED&#58;
                break;

            case PSP_UTILITY_DIALOG_NONE&#58;
                done = 1;

            default&#58;
                break;
        &#125;

        sceDisplayWaitVblankStart&#40;&#41;;
        sceGuSwapBuffers&#40;&#41;;
    &#125;

    pspDebugScreenInit&#40;&#41;;
    pspDebugScreenSetXY&#40;0, 0&#41;;

    int j;

    for&#40;i = 0; i < NUM_INPUT_FIELDS; i++&#41;
    &#123;
        switch&#40;data&#91;i&#93;.result&#41;
        &#123;
            case PSP_UTILITY_OSK_RESULT_UNCHANGED&#58;
                break;

            case PSP_UTILITY_OSK_RESULT_CANCELLED&#58;
                input = "\0";
                sceGuTerm&#40;&#41;;
                return 1;

            case PSP_UTILITY_OSK_RESULT_CHANGED&#58;
                break;

            default&#58;
                break;
        &#125;
        
        int n = 0;

        for&#40;j = 0; data&#91;i&#93;.outtext&#91;j&#93;; j++&#41;
        &#123;
            if&#40;data&#91;i&#93;.outtext&#91;j&#93; != '\0' && data&#91;i&#93;.outtext&#91;j&#93; != '\n' && data&#91;i&#93;.outtext&#91;j&#93; != '\r'&#41;
            &#123;
                input&#91;j&#93; = data&#91;i&#93;.outtext&#91;j&#93;;
                n++;
            &#125;
        &#125;
        input&#91;n&#93; = '\0';
    &#125;
    sceGuTerm&#40;&#41;;

    return 1;
&#125;


char *requestString&#40;char *initialStr, char* initialDesc&#41;
&#123;
    int ok, i;
    char* str = &#40;char*&#41;malloc&#40;128&#41;;
    unsigned short intext&#91;128&#93; = &#123;0&#125;; // text already in the edit box on start
    unsigned short desc&#91;128&#93; = &#123;0&#125;; // description

    if&#40;initialStr&#91;0&#93; != 0&#41;
        for&#40;i = 0; i <= strlen&#40;initialStr&#41;; i++&#41;
            intext&#91;i&#93; = &#40;unsigned short&#41;initialStr&#91;i&#93;;

    if&#40;initialDesc&#91;0&#93; != 0&#41;
        for&#40;i = 0; i <= strlen&#40;initialDesc&#41;; i++&#41;
            desc&#91;i&#93; = &#40;unsigned short&#41;initialDesc&#91;i&#93;;

    ok = get_text_osk&#40;str, intext, desc&#41;;

    if&#40;ok&#41;
        return str;

    return 0;
&#125;
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

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

My original statement still stands.
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

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

Code: Select all

&#91;...&#93;
XgeInit&#40;&#41;;
while&#40;running&#41;
&#123;
    ...
    Rinomina&#40;&#41;;
    ...
    // Blit some images
    ...
    XgeRequestScreenRefresh&#40;&#41;; // sceGuSwapBuffers is called
&#125;
&#91;...&#93;
void Rinomina&#40;&#41;
&#123;
    F* fileselez = X_engine.GetCurrentFile&#40;&#41;;

    char* temp_file = requestString&#40;fileselez->nome, language->menu_operazioni.rename&#41;;
    if&#40;strcmp&#40;temp_file, "\0"&#41; != 0&#41;
    &#123;
        sceIoRename&#40;fileselez->nome, temp_file&#41;;
    &#125;
    free&#40;temp_file&#41;;
    XgeInit&#40;&#41;;
    X_engine.Refresh&#40;&#41;;
&#125;
Post Reply