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 

Get OSK works on vsh mode?

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



Joined: 14 Dec 2006
Posts: 17

PostPosted: Sun Feb 11, 2007 8:42 pm    Post subject: Get OSK works on vsh mode? Reply with quote

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:

#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("pspmath_demo", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_VFPU);

typedef struct {
   unsigned int c;
   float x, y, z;
} CVertex;

u32 __attribute__((aligned(16))) list[1024];
CVertex __attribute__((aligned(16))) stars[1000];
ScePspFMatrix4 projection3d, view, model;
ScePspQuatMatrix qcam, qa, qb;
int running = 1;

int exitCallback(int arg1, int arg2, void *common)
{
   running = 0;
   return 0;
}

int callbackThread(SceSize args, void *argp)
{
   int cbid;

   cbid = sceKernelCreateCallback("Exit Callback", exitCallback, NULL);
   sceKernelRegisterExitCallback(cbid);
   sceKernelSleepThreadCB();
   return 0;
}

int setupCallbacks(void)
{
   int thid = 0;

   thid = sceKernelCreateThread("callbackThread", callbackThread, 0x11, 0xFA0, 0, 0);
   if(thid >= 0)
      sceKernelStartThread(thid, 0, 0);
   return thid;
}

void initGU() {
   sceGuInit();
   sceGuStart(GU_DIRECT,list);
   sceGuDrawBuffer(GU_PSM_8888,(void *)0,512);
   sceGuDispBuffer(480,272,(void*)0x88000,512);
   sceGuOffset(2048 - (480/2),2048 - (272/2));
   sceGuViewport(2048,2048,480,272);
   sceGuScissor(0,0,480,272);
   sceGuEnable(GU_SCISSOR_TEST);
   sceGuShadeModel(GU_SMOOTH);
   sceGuDisable(GU_DEPTH_TEST);
   sceGuDisable(GU_CULL_FACE);
   sceGuDisable(GU_LIGHTING);
   sceGuDisable(GU_TEXTURE_2D);
   sceGuFinish();
   sceGuSync(0,0);
   sceDisplayWaitVblankStart();
   sceGuDisplay(1);
}

int main(int argc, char *argv[]) {
   u64 tick;
   int n;
   SceCtrlData pad;
   float t;
   
   char input[128]="";

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

   sceRtcGetCurrentTick(&tick);
   vfpu_srand((u32)tick / 10000.0f);

   //setupCallbacks();
   initGU();

   vfpu_perspective_matrix(&projection3d, 60.0f, 480.0f/272.0f, 0.5f, 1000.0f);
   vfpu_identity_matrix(&view);
   vfpu_identity_matrix(&model);

   // 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 (n=0; n<1000; n++) {
      vfpu_sphere_to_cartesian(vfpu_randf(0.0f, 6.28319f), vfpu_randf(0.0f, 3.14159f), 1000.0f, (ScePspFVector4 *)&(stars[n]));
      stars[n].c = vfpu_rand_8888(160, 255);
   }

   n = 0;

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

   sceCtrlSetSamplingCycle(0);
   sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
   


      // INIT OSK
   unsigned short intext[128]  = { 0 }; // text already in the edit box on start
   unsigned short outtext[128] = { 0 }; // text after input
   unsigned short desc[128]    = { 'E', 'n', 't', 'e', 'r', ' ', 'T', 'e', 'x', 't', 0 }; // description



   SceUtilityOskData data;
   memset(&data, 0, sizeof(data));
   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(outtext) / sizeof(unsigned short)
   data.outtextlimit = 50; // just allow 50 chars
   data.outtext = (unsigned short*)outtext;

   SceUtilityOskParams osk;
   memset(&osk, 0, sizeof(osk));
   osk.size = sizeof(osk);
   osk.language = 1;
   osk.buttonswap = 0; //X button: 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(&osk);
   if(rc) {
      return 0;
   }

   while (running) {

      n++;

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

      if (n >= 300) {
         n = 0;
         vfpu_quaternion_copy(&qa, &qb);
         vfpu_quaternion_from_euler(&qb, vfpu_randf(0.0f, 360.0f), vfpu_randf(0.0f, 360.0f), vfpu_randf(0.0f, 360.0f));
         vfpu_quaternion_ln(&qb, &qb);
      }

      // to build the view matrix:
      //      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 + (cos(t) * .5) 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(0) = 1, cos(PI) = -1, we want
      // the reverse, -1 to 1

      t = n/300.0f;
      vfpu_quaternion_sample_linear(&qcam, &qa, &qb, vfpu_ease_in_out(t));
      vfpu_quaternion_exp(&qcam, &qcam);
      vfpu_quaternion_to_matrix(&qcam, &view);

      sceGuStart(GU_DIRECT, list);
      sceGuClearColor(0);
      sceGuClear(GU_COLOR_BUFFER_BIT|GU_FAST_CLEAR_BIT);

      // load our generated matrix data into the display list

      sceGuSetMatrix(GU_PROJECTION, &projection3d);
      sceGuSetMatrix(GU_VIEW, &view);
      sceGuSetMatrix(GU_MODEL, &model);

      sceGuDrawArray(GU_POINTS, GU_VERTEX_32BITF | GU_COLOR_8888 | GU_TRANSFORM_3D, 1000, 0, stars);

      sceGuFinish();
      sceGuSync(0,0);
   
      switch(sceUtilityOskGetStatus()) {
            case PSP_OSK_INIT :
               break;
            case PSP_OSK_VISIBLE :
               sceUtilityOskUpdate(2); // 2 is taken from ps2dev.org recommendation
               break;
            case PSP_OSK_QUIT :
               sceUtilityOskShutdownStart();
               break;
            case PSP_OSK_FINISHED :
               running = 0;
               break;
            case PSP_OSK_NONE :
            default :
               break;
         }

         int i,j=0;
         for(i = 0; data.outtext[i]; i++) {

            if (data.outtext[i]!='\0' && data.outtext[i]!='\n' && data.outtext[i]!='\r'){
               input[j] = data.outtext[i];
               j++;
            }
         }
      sceGuSwapBuffers();
   
      //sceCtrlPeekBufferPositive(&pad, 1);

      //if (pad.Buttons & PSP_CTRL_CROSS) {
      //   break;
      //}
      sceDisplayWaitVblankStart();
   }

   sceGuTerm();
   //sceKernelExitGame();
   return 0;
}



makefile
Code:

TARGET = sample
OBJS = main.o

BUILD_PRX = 1

USE_PSPSDK_LIBC = 1

INCDIR =
CFLAGS = -G0 -Wall -O2 -fno-strict-aliasing
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

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

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak


Need a hand~~~[/code]


Last edited by poison on Mon Feb 12, 2007 1:31 am; edited 1 time in total
Back to top
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Mon Feb 12, 2007 1:16 am    Post subject: Reply with quote

I don't think anyone has managed to get GU working in VSH at all yet, not how you want to at least.
Back to top
View user's profile Send private message
poison



Joined: 14 Dec 2006
Posts: 17

PostPosted: Mon Feb 12, 2007 1:28 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Mon Feb 12, 2007 1:47 am    Post subject: Reply with quote

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'.
Back to top
View user's profile Send private message
poison



Joined: 14 Dec 2006
Posts: 17

PostPosted: Mon Feb 12, 2007 1:59 am    Post subject: Reply with quote

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'.
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