Beispiel #1
0
int LPP_UtilsOskUpdate(char *outtext)
{
    int res = -1;

    switch(sceUtilityOskGetStatus())
    {
    case PSP_UTILITY_DIALOG_NONE:
        res = lpp_UtilsOskDialogData.result;

        if(lpp_UtilsOskDialogData.desc) free(lpp_UtilsOskDialogData.desc);
        if(lpp_UtilsOskDialogData.intext) free(lpp_UtilsOskDialogData.intext);

        LPP_UtilsConvertToAscii(outtext, lpp_UtilsOskDialogParams.data->outtext);
        break;

    case PSP_UTILITY_DIALOG_VISIBLE:
        sceUtilityOskUpdate(1);
        break;
    case PSP_UTILITY_DIALOG_QUIT:
        sceUtilityOskShutdownStart();
        break;
    case PSP_UTILITY_DIALOG_FINISHED:
        break;
    default:
        break;
    }

    return(res);
}
Beispiel #2
0
char *SonyOSK(int len, const char *_desc, const char *inittext, triImage* img)
{
	unsigned short intext[MAX_TEXT_LENGTH];
	unsigned short outtext[MAX_TEXT_LENGTH];
	unsigned short desc[MAX_TEXT_LENGTH];
	
	memset(intext, 0, MAX_TEXT_LENGTH * sizeof(unsigned short));
	memset(outtext, 0, MAX_TEXT_LENGTH * sizeof(unsigned short));
	memset(desc, 0, MAX_TEXT_LENGTH * sizeof(unsigned short));
	
	int i;
	int txt_len = strlen(_desc);
	for(i=0;i<txt_len;i++)
	{
		desc[i] = _desc[i];
	}
	desc[txt_len] = 0;

	txt_len = strlen(inittext);
	for(i=0;i<txt_len;i++)
	{
		intext[i] = inittext[i];
	}
	intext[txt_len] = 0;	
	
	SceUtilityOskData data;
	
	memset(&data, 0, sizeof(SceUtilityOskData));
	data.language = PSP_UTILITY_OSK_LANGUAGE_DEFAULT; // Use system default for text input
	data.lines = 1;
	data.unk_24 = 1;
	data.inputtype = PSP_UTILITY_OSK_INPUTTYPE_ALL; // Allow all input types
	data.desc = desc;
	data.intext = intext;
	data.outtextlength = MAX_TEXT_LENGTH;
	data.outtextlimit = len;
	data.outtext = outtext;
	
	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.buttonSwap = 1;
	params.base.graphicsThread = 17;
	params.base.accessThread = 19;
	params.base.fontThread = 18;
	params.base.soundThread = 16;
	params.datacount = 1;
	params.data = &data;

	sceUtilityOskInitStart(&params);

	int done = 0;
	while(!done)
	{
		triClear( 0 );
		if(img)
			triDrawImage2( 0.f, 0.f, img );

		sceGuFinish();
		sceGuSync(0,0);
		int stat = sceUtilityOskGetStatus();
		switch(stat)
		{
			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;
		}

		triSwapbuffers();
	}

	int j;
	char buf[sizeof(unsigned)];
	char *ret = new char[len+1];
	memset(ret, 0, len+1);
	for(j = 0; data.outtext[j]; j++)
	{
		unsigned c = data.outtext[j];
		
		if(32 <= c && c <= 127) // print ascii only
		{
			sprintf(buf, "%c", data.outtext[j]);
			strcat(ret, buf);
		}
	}
	ret[j] = 0;
	triLogPrint("ret: %s (%d)\n", ret, strlen(ret));
	return ret;
}
Beispiel #3
0
/*
  Returns a string typed through the PSP built-in keyboard.
*/
VALUE Joyau_gets(VALUE self)
{
   SceUtilityOskData data;
   SceUtilityOskParams params;

   unsigned short input[128]  = { 'E', 'n', 't', 'e', 'r', ' ',
                                  'y', 'o', 'u', 'r', ' ',
                                  't', 'e','x', 't', 0 };
   unsigned short output[128] = { 0 };

   memset(&data, 0, sizeof(data));
   data.lines = 1;
   data.unk_24 = 1;
   data.inputtype = PSP_UTILITY_OSK_INPUTTYPE_ALL;
   data.desc = input;
   data.intext = input;
   data.outtextlength = 128;
   data.outtextlimit = 128;
   data.outtext = output;

   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 = 1;
   params.data = &data;

   sceUtilityOskInitStart(&params);

   bool done = false;
   while (!done)
   {
      oslStartDrawing();
      oslDrawFillRect(0, 0, 480, 272, RGBA(0, 0, 0, 255));
      oslEndDrawing();
      
      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 = true;
         default :
            break;
      }

      oslEndDrawing();
      oslEndFrame();
      oslSyncFrame();
   }

   char *ret = new char[128];
   for (int i = 0; i < 128; ++i)
      ret[i] = (char)data.outtext[i];

   return rb_str_new2(ret);
}
Beispiel #4
0
/*
  call-seq: run(input_type, language, text, desc, output_size) { ... }

  Shows the OSK (Sony's default keyboard), and returns the input text.
  Example:
    Joyau::OSK.run(Joyau::OSK::ALL, Joyau::OSK::DEFAULT,
                   "Anonymous", "Enter your nickame", 16) do
      Joyau.clearScreen # this is suffisant to avoid glitches,
                        # Although you might copy the old screen buffer,
			# and draw it here.
 */
VALUE Osk_run(VALUE self, VALUE type, VALUE lang, VALUE rb_input, 
	      VALUE rb_desc, VALUE output_size)
{
   SceUtilityOskData data;
   SceUtilityOskParams params;

   char *char_input = StringValuePtr(rb_input);
   int char_size = strlen(char_input);
   
   unsigned short *input = new unsigned short[char_size + 1];
   for (int i = 0; i < char_size + 1; ++i)
      input[i] = char_input[i];
   
   char *char_desc = StringValuePtr(rb_desc);
   char_size = strlen(char_desc);
   
   unsigned short *desc = new unsigned short[char_size + 1];
   for (int i = 0; i < char_size + 1; ++i)
      desc[i] = char_desc[i];

   unsigned short *output = new unsigned short[FIX2INT(output_size)];

   memset(&data, 0, sizeof(data));
   data.lines = 1;
   data.unk_24 = 1;
   data.inputtype = INT2FIX(type);
   data.desc = desc;
   data.intext = input;
   data.outtextlength = FIX2INT(output_size);
   data.outtextlimit = FIX2INT(output_size);
   data.outtext = output;

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

   sceUtilityOskInitStart(&params);

   bool done = false;
   while (!done)
   {
      oslStartDrawing();
      rb_yield(Qnil);
      oslEndDrawing();
      
      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 = true;
         default :
            break;
      }

      oslEndDrawing();
      oslEndFrame();
      oslSyncFrame();
   }

   char *ret = new char[FIX2INT(output_size)];
   for (int i = 0; i < FIX2INT(output_size); ++i)
      ret[i] = (char)data.outtext[i];

   delete[] input;
   delete[] desc;
   delete[] output;

   return rb_str_new2(ret);
}
Beispiel #5
0
int GetTextOSK(char *buf,int buflen,int mode,const char *title,const char *init)
{
	if(buf == NULL)return -1;

	u16 *winit,*wtitle,*wresult;
	char nulstr[] = "";
	if(init == NULL)init = nulstr;
	if(title == NULL)title = nulstr;
	winit = (u16*)malloc((strlen(init) + 1) * 2);
	wtitle = (u16*)malloc((strlen(title) + 1) * 2);
	wresult = (u16*)malloc((buflen + 1) * 2);
	if(winit == NULL || wtitle == NULL || wresult == NULL)
	{
		free(winit);
		free(wtitle);
		free(wresult);
		return -1;
	}


	dxpCpCode_toUcs2(winit,strlen(init) + 1,(const dxpChar*)init,dxpGeneralData.charset);
	dxpCpCode_toUcs2(wtitle,strlen(title) + 1,(const dxpChar*)title,dxpGeneralData.charset);

	SceUtilityOskData data;
	memset(&data, 0, sizeof(SceUtilityOskData));
	sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, &data.language);
	data.unk_00 = 1;	//ATOK
	data.lines = 1;
	data.unk_24 = 1;
	data.inputtype = mode;
	data.desc = wtitle;
	data.intext = winit;
	data.outtextlength = buflen;
	data.outtextlimit = buflen;
	data.outtext = wresult;

	SceUtilityOskParams params;
	memset(&params,0x00,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 = 0x11;
	params.base.accessThread = 0x13;
	params.base.fontThread = 0x12;
	params.base.soundThread = 0x10;
	params.datacount = 1;
	params.data = &data;

	sceUtilityOskInitStart(&params);

	int done = 0;
	while(ProcessMessage() != -1 && !done)
	{
		ClearDrawScreen();
		if ( dxpDialogDrawScene != NULL ) dxpDialogDrawScene();
		GUFINISH
		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_NONE:
			case PSP_UTILITY_DIALOG_FINISHED:
				done = 1;
				break;
				
			default:
				break;
		}
		ScreenFlip();
	}

//	dxpCpSJIS_fromUcs2((dxpChar*)buf,buflen,wresult);
	dxpCpCode_fromUcs2((dxpChar*)buf,buflen,wresult,dxpGeneralData.charset);
	free(winit);
	free(wtitle);
	free(wresult);
	return 0;
}