Strange problems with built-in osk
Strange problems with built-in osk
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:
Here a screen:
Get Xplora!
-
- Posts: 388
- Joined: Tue Aug 12, 2008 12:46 am
-
- Posts: 376
- Joined: Wed May 10, 2006 11:31 pm
-
- Posts: 388
- Joined: Tue Aug 12, 2008 12:46 am
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(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(¶ms, 0, sizeof(params));
params.base.size = sizeof(params);
sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, ¶ms.base.language);
sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_UNKNOWN, ¶ms.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(¶ms);
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!
-
- Posts: 376
- Joined: Wed May 10, 2006 11:31 pm
Now I've no one problem...and I haven't modified a lot the src...
Anyway, this is the rename function:
Anyway, this is the rename function:
Code: Select all
[...]
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!