Get OSK works on vsh mode?

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

Moderators: cheriff, TyRaNiD

Post Reply
poison
Posts: 17
Joined: Thu Dec 14, 2006 11:07 pm

Get OSK works on vsh mode?

Post by poison »

I get the osk works on game mode now ...

but when i compile it into a prx..and load it in vsh mode by a module loader....
the background animate shows normally.
and sceUtilityOskInitStart() successfully load..
but i cant see the osk keyboard...
if I turn off the psp now... I could see the osk keyboard flash up while the
XMB shutting down...


here is the code

main.c

Code: Select all

#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <psprtc.h>
#include <pspgu.h>
#include <psputils.h>
#include <pspmath.h>

#include <string.h>

#include <psputility_osk.h>

PSP_MODULE_INFO&#40;"pspmath_demo", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_VFPU&#41;;

typedef struct &#123;
	unsigned int c;
	float x, y, z;
&#125; CVertex;

u32 __attribute__&#40;&#40;aligned&#40;16&#41;&#41;&#41; list&#91;1024&#93;;
CVertex __attribute__&#40;&#40;aligned&#40;16&#41;&#41;&#41; stars&#91;1000&#93;;
ScePspFMatrix4 projection3d, view, model;
ScePspQuatMatrix qcam, qa, qb;
int running = 1;

int exitCallback&#40;int arg1, int arg2, void *common&#41;
&#123;
	running = 0;
	return 0;
&#125;

int callbackThread&#40;SceSize args, void *argp&#41;
&#123;
	int cbid;

	cbid = sceKernelCreateCallback&#40;"Exit Callback", exitCallback, NULL&#41;;
	sceKernelRegisterExitCallback&#40;cbid&#41;;
	sceKernelSleepThreadCB&#40;&#41;;
	return 0;
&#125;

int setupCallbacks&#40;void&#41;
&#123;
	int thid = 0;

	thid = sceKernelCreateThread&#40;"callbackThread", callbackThread, 0x11, 0xFA0, 0, 0&#41;;
	if&#40;thid >= 0&#41;
		sceKernelStartThread&#40;thid, 0, 0&#41;;
	return thid;
&#125;

void initGU&#40;&#41; &#123;
	sceGuInit&#40;&#41;;
	sceGuStart&#40;GU_DIRECT,list&#41;;
	sceGuDrawBuffer&#40;GU_PSM_8888,&#40;void *&#41;0,512&#41;;
	sceGuDispBuffer&#40;480,272,&#40;void*&#41;0x88000,512&#41;;
	sceGuOffset&#40;2048 - &#40;480/2&#41;,2048 - &#40;272/2&#41;&#41;;
	sceGuViewport&#40;2048,2048,480,272&#41;;
	sceGuScissor&#40;0,0,480,272&#41;;
	sceGuEnable&#40;GU_SCISSOR_TEST&#41;;
	sceGuShadeModel&#40;GU_SMOOTH&#41;;
	sceGuDisable&#40;GU_DEPTH_TEST&#41;;
	sceGuDisable&#40;GU_CULL_FACE&#41;;
	sceGuDisable&#40;GU_LIGHTING&#41;;
	sceGuDisable&#40;GU_TEXTURE_2D&#41;;
	sceGuFinish&#40;&#41;;
	sceGuSync&#40;0,0&#41;;
	sceDisplayWaitVblankStart&#40;&#41;;
	sceGuDisplay&#40;1&#41;;
&#125;

int main&#40;int argc, char *argv&#91;&#93;&#41; &#123;
	u64 tick;
	int n;
	SceCtrlData pad;
	float t;
	
	char input&#91;128&#93;="";

	// vfpu has a random number generator,
	// and it needs to be seeded

	sceRtcGetCurrentTick&#40;&tick&#41;;
	vfpu_srand&#40;&#40;u32&#41;tick / 10000.0f&#41;;

	//setupCallbacks&#40;&#41;;
	initGU&#40;&#41;;

	vfpu_perspective_matrix&#40;&projection3d, 60.0f, 480.0f/272.0f, 0.5f, 1000.0f&#41;;
	vfpu_identity_matrix&#40;&view&#41;;
	vfpu_identity_matrix&#40;&model&#41;;

	// build a random starfield, using sphere to cartesian coordinate conversions
	// note how we use vfpu_randf here to generate random radian angles,
	// and how we use vfpu_rand_8888 to generate random colors for the stars

	for &#40;n=0; n<1000; n++&#41; &#123;
		vfpu_sphere_to_cartesian&#40;vfpu_randf&#40;0.0f, 6.28319f&#41;, vfpu_randf&#40;0.0f, 3.14159f&#41;, 1000.0f, &#40;ScePspFVector4 *&#41;&&#40;stars&#91;n&#93;&#41;&#41;;
		stars&#91;n&#93;.c = vfpu_rand_8888&#40;160, 255&#41;;
	&#125;

	n = 0;

	// start off with 2 random rotations for the interpolation
	vfpu_quaternion_from_euler&#40;&qa, vfpu_randf&#40;0.0f, 360.0f&#41;, vfpu_randf&#40;0.0f, 360.0f&#41;, vfpu_randf&#40;0.0f, 360.0f&#41;&#41;;
	vfpu_quaternion_ln&#40;&qa, &qa&#41;;
	vfpu_quaternion_from_euler&#40;&qb, vfpu_randf&#40;0.0f, 360.0f&#41;, vfpu_randf&#40;0.0f, 360.0f&#41;, vfpu_randf&#40;0.0f, 360.0f&#41;&#41;;
	vfpu_quaternion_ln&#40;&qb, &qb&#41;;

	sceCtrlSetSamplingCycle&#40;0&#41;;
	sceCtrlSetSamplingMode&#40;PSP_CTRL_MODE_ANALOG&#41;;
	


	   // INIT OSK 
	unsigned short intext&#91;128&#93;  = &#123; 0 &#125;; // text already in the edit box on start 
	unsigned short outtext&#91;128&#93; = &#123; 0 &#125;; // text after input 
	unsigned short desc&#91;128&#93;    = &#123; 'E', 'n', 't', 'e', 'r', ' ', 'T', 'e', 'x', 't', 0 &#125;; // description 



	SceUtilityOskData data; 
	memset&#40;&data, 0, sizeof&#40;data&#41;&#41;; 
	data.language = 2; // english 
	data.lines = 1; // just one line 
	data.unk_24 = 1; // set to 1 
	data.desc = desc; 
	data.intext = intext; 
	data.outtextlength = 128; // sizeof&#40;outtext&#41; / sizeof&#40;unsigned short&#41; 
	data.outtextlimit = 50; // just allow 50 chars 
	data.outtext = &#40;unsigned short*&#41;outtext; 

	SceUtilityOskParams osk; 
	memset&#40;&osk, 0, sizeof&#40;osk&#41;&#41;; 
	osk.size = sizeof&#40;osk&#41;; 
	osk.language = 1; 
	osk.buttonswap = 0; //X button&#58; 1 
	osk.unk_12 = 17; 
	osk.unk_16 = 19; //tester a 1 pour les chiffres 
	osk.unk_20 = 18; 
	osk.unk_24 = 16; 
	osk.unk_48 = 1; 
	osk.data = &data; 


	int rc = sceUtilityOskInitStart&#40;&osk&#41;; 
	if&#40;rc&#41; &#123; 
		return 0; 
	&#125;

	while &#40;running&#41; &#123;

		n++;

		// when we reach the limit of our interpolation&#58;
		//		copy qb to qa
		//		generate a new random quaternion in qb
		//		take the log of quaternion qb
		//		reset the time counter

		if &#40;n >= 300&#41; &#123;
			n = 0;
			vfpu_quaternion_copy&#40;&qa, &qb&#41;;
			vfpu_quaternion_from_euler&#40;&qb, vfpu_randf&#40;0.0f, 360.0f&#41;, vfpu_randf&#40;0.0f, 360.0f&#41;, vfpu_randf&#40;0.0f, 360.0f&#41;&#41;;
			vfpu_quaternion_ln&#40;&qb, &qb&#41;;
		&#125;

		// to build the view matrix&#58;
		//		get the interpolated quaternion in qcam
		//		take the exp of qcam
		//		build a rotation matrix from qcam, place into view matrix
		//
		// here we use the function .5 + &#40;cos&#40;t&#41; * .5&#41; for our 'time' variable
		// this gives us the smooth ease in/ease out motion you see as the demo
		// interpolates between qa and qb
		//
		// this is why we must do 300-n, as cos&#40;0&#41; = 1, cos&#40;PI&#41; = -1, we want
		// the reverse, -1 to 1

		t = n/300.0f;
		vfpu_quaternion_sample_linear&#40;&qcam, &qa, &qb, vfpu_ease_in_out&#40;t&#41;&#41;;
		vfpu_quaternion_exp&#40;&qcam, &qcam&#41;;
		vfpu_quaternion_to_matrix&#40;&qcam, &view&#41;;

		sceGuStart&#40;GU_DIRECT, list&#41;;
		sceGuClearColor&#40;0&#41;;
		sceGuClear&#40;GU_COLOR_BUFFER_BIT|GU_FAST_CLEAR_BIT&#41;;

		// load our generated matrix data into the display list

		sceGuSetMatrix&#40;GU_PROJECTION, &projection3d&#41;;
		sceGuSetMatrix&#40;GU_VIEW, &view&#41;;
		sceGuSetMatrix&#40;GU_MODEL, &model&#41;;

		sceGuDrawArray&#40;GU_POINTS, GU_VERTEX_32BITF | GU_COLOR_8888 | GU_TRANSFORM_3D, 1000, 0, stars&#41;;

		sceGuFinish&#40;&#41;;
		sceGuSync&#40;0,0&#41;;
	
		switch&#40;sceUtilityOskGetStatus&#40;&#41;&#41; &#123; 
	         case PSP_OSK_INIT &#58; 
	            break; 
	         case PSP_OSK_VISIBLE &#58; 
	            sceUtilityOskUpdate&#40;2&#41;; // 2 is taken from ps2dev.org recommendation 
	            break; 
	         case PSP_OSK_QUIT &#58; 
	            sceUtilityOskShutdownStart&#40;&#41;; 
	            break; 
	         case PSP_OSK_FINISHED &#58; 
	            running = 0; 
	            break; 
	         case PSP_OSK_NONE &#58; 
	         default &#58; 
	            break; 
	      &#125; 

	      int i,j=0; 
	      for&#40;i = 0; data.outtext&#91;i&#93;; i++&#41; &#123; 

	         if &#40;data.outtext&#91;i&#93;!='\0' && data.outtext&#91;i&#93;!='\n' && data.outtext&#91;i&#93;!='\r'&#41;&#123; 
	            input&#91;j&#93; = data.outtext&#91;i&#93;; 
	            j++; 
	         &#125; 
	      &#125;
		sceGuSwapBuffers&#40;&#41;;
	
		//sceCtrlPeekBufferPositive&#40;&pad, 1&#41;;

		//if &#40;pad.Buttons & PSP_CTRL_CROSS&#41; &#123;
		//	break;
		//&#125;
		sceDisplayWaitVblankStart&#40;&#41;;
	&#125;

	sceGuTerm&#40;&#41;;
	//sceKernelExitGame&#40;&#41;;
	return 0;
&#125;

makefile

Code: Select all

TARGET = sample
OBJS = main.o

BUILD_PRX = 1

USE_PSPSDK_LIBC = 1

INCDIR =
CFLAGS = -G0 -Wall -O2 -fno-strict-aliasing
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti 
ASFLAGS = $&#40;CFLAGS&#41;

LIBDIR =
LDFLAGS =
LIBS= -lpspgu -lpsprtc -lpspctrl -lpspmath

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
Need a hand~~~[/code]
Last edited by poison on Mon Feb 12, 2007 1:31 am, edited 1 time in total.
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

I don't think anyone has managed to get GU working in VSH at all yet, not how you want to at least.
poison
Posts: 17
Joined: Thu Dec 14, 2006 11:07 pm

Post by poison »

Insert_witty_name wrote:I don't think anyone has managed to get GU working in VSH at all yet, not how you want to at least.
I get it work in VSH if the osk part is not added..
you can just copy the code and have a try....

and actually ... the osk keyboard is draw successfully...
but maybe in the layer under the XMB or something like that, i think.
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

If it's like my inital testing with it, it'll run for a few seconds and then power off the PSP, I don't consider this 'working'.
poison
Posts: 17
Joined: Thu Dec 14, 2006 11:07 pm

Post by poison »

Insert_witty_name wrote:If it's like my inital testing with it, it'll run for a few seconds and then power off the PSP, I don't consider this 'working'.
I pack it
http://www.2alien.info/stuff/no_name.zip

I get it work on 3.10OEA'.
Post Reply