Getting the Sony On SCreen Keyboard To Work

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

Moderators: cheriff, TyRaNiD

Post Reply
reefbarman
Posts: 87
Joined: Mon Jan 08, 2007 12:16 pm
Location: Australia

Getting the Sony On SCreen Keyboard To Work

Post by reefbarman »

Hi, everyone

i would really love to see sony's on screen keyboard work in homebrew & my program but i dont really have a clue how to set it all up,

i have these in so far
Code:
#include <psputility_osk.h>
SceUtilityOskParams * myKeyboard;
SceUtilityOskData * myKeyboardData;
SceOskState keyboardState;


now my problem is how do i use all this
i want a function called keyboard() that displays this keyboard, makes it work and then stores the entered text in a char * array, then shuts the keyboard down allowing my program to return to it previous place

thanks in advance also if anyone know what any of the variable in the structs related to this do please post them thanks again
Bytrix
Posts: 72
Joined: Wed Sep 14, 2005 7:26 pm
Location: England

Post by Bytrix »

I was wondering how to use this too, I ended up writing my own.
adrahil
Posts: 274
Joined: Thu Mar 16, 2006 1:55 am

Post by adrahil »

Search the forums.... there is some post related...
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

McZonk's sample that he posted is pretty self explanatory.
reefbarman
Posts: 87
Joined: Mon Jan 08, 2007 12:16 pm
Location: Australia

Post by reefbarman »

i read the example but the link are all broken so i cant get any of the code so a refresher here would be good or if i was reading the topic can some one post a link thanks, but still if anyone has a clue and could do a mock up function for me that would be great
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Here's a mirror of McZonk's code mate.

It's pretty easy to understand.

http://www.psp-programming.com/animate/psposk.zip
reefbarman
Posts: 87
Joined: Mon Jan 08, 2007 12:16 pm
Location: Australia

Post by reefbarman »

cheers thanks alot
reefbarman
Posts: 87
Joined: Mon Jan 08, 2007 12:16 pm
Location: Australia

Post by reefbarman »

okay im compiled the mczonk sample copied it to my psp and no that im running it all i get is a grey screen and a crash whats going on there??
User avatar
blondin
Posts: 18
Joined: Tue Mar 07, 2006 12:16 am
Location: France (Grenoble)

Work only with 1.50

Post by blondin »

This exemple work fine with firmware 1.50 but there is a solution to make it usable on a 2.71, 3.02 or 3.03OE ???
THX
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

The reason it doesn't work on the SE/OE firmwares in 1.5 mode (where you get the gray screen and crash) is cause the 1.5 vsh modules are not available which the OSK requires. As for why it doesn't work on 3.03oe it does with abit of prodding :P You need to build it as a PRX (for 3.02/3.03 at least) and you should remove the use of the osk lib which comes with the sample and use the one which comes with the sdk. Then it all works fine (sort of, the language it appears in is not my specified language so there is possibly some weirdness with the language settings).
Bytrix
Posts: 72
Joined: Wed Sep 14, 2005 7:26 pm
Location: England

Post by Bytrix »

Thanks for that TyRaNiD, I too had been wondering how to get this to work in OE. Trying to add as many of these features as I can to my games to make them look a little bit more professional.
reefbarman
Posts: 87
Joined: Mon Jan 08, 2007 12:16 pm
Location: Australia

Post by reefbarman »

is anyone able to compile a prx for me and give me instructions on how to add it into my code, its probably not too hard to do my self but i have never tried it before and dont know where to find good tutorials on how to do it so if someone is kind enough, cause while i have been developing my own keyboard system which is kinda cool it still has a lot of work and i would like to release a beta of my app asap, so using the sony one will be my temporary fix.
User avatar
blondin
Posts: 18
Joined: Tue Mar 07, 2006 12:16 am
Location: France (Grenoble)

Post by blondin »

Thx TyRaNid but I can't load the osk... the sceUtilityOskInitStart return NULL all the time :(
Can you post a little example of your prx please ;) ... thx again for your help
User avatar
blondin
Posts: 18
Joined: Tue Mar 07, 2006 12:16 am
Location: France (Grenoble)

Post by blondin »

It's ok I made it, i will post an exemple asap....
reefbarman
Posts: 87
Joined: Mon Jan 08, 2007 12:16 pm
Location: Australia

Post by reefbarman »

excellent
User avatar
blondin
Posts: 18
Joined: Tue Mar 07, 2006 12:16 am
Location: France (Grenoble)

OSK for 303OE

Post by blondin »

Ok guys, let's go :

1. Create new main.c in a new directory paste this code :

Code: Select all

#include <pspkernel.h>
#include <pspdisplay.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <pspmoduleinfo.h>
#include <psputility.h>
#include <pspgu.h>
#include <pspgum.h>

#include <psputility_osk.h>

/* Define the module info section */
PSP_MODULE_INFO&#40;"MsgDialog Sample", 0, 1, 0&#41;;

#define printf pspDebugScreenPrintf

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41;
&#123;
    sceKernelExitGame&#40;&#41;;
    return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41;
&#123;
    int cbid;
    cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
    sceKernelRegisterExitCallback&#40;cbid&#41;;
    sceKernelSleepThreadCB&#40;&#41;;

    return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41;
&#123;
    int thid = 0;
    thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
    if &#40;thid >= 0&#41;
        sceKernelStartThread&#40;thid, 0, 0&#41;;
    return thid;
&#125;


/* Graphics stuff, based on cube sample */

static unsigned int __attribute__&#40;&#40;aligned&#40;16&#41;&#41;&#41; list&#91;262144&#93;;

struct Vertex
&#123;
    float u, v;
    unsigned int color;
    float x,y,z;
&#125;;

struct Vertex __attribute__&#40;&#40;aligned&#40;16&#41;&#41;&#41; vertices&#91;12*3&#93; =
&#123;
    &#123;0, 0, 0xff7f0000,-1,-1, 1&#125;, // 0
    &#123;1, 0, 0xff7f0000,-1, 1, 1&#125;, // 4
    &#123;1, 1, 0xff7f0000, 1, 1, 1&#125;, // 5
    
    &#123;0, 0, 0xff7f0000,-1,-1, 1&#125;, // 0
    &#123;1, 1, 0xff7f0000, 1, 1, 1&#125;, // 5
    &#123;0, 1, 0xff7f0000, 1,-1, 1&#125;, // 1
    
    &#123;0, 0, 0xff7f0000,-1,-1,-1&#125;, // 3
    &#123;1, 0, 0xff7f0000, 1,-1,-1&#125;, // 2
    &#123;1, 1, 0xff7f0000, 1, 1,-1&#125;, // 6
    
    &#123;0, 0, 0xff7f0000,-1,-1,-1&#125;, // 3
    &#123;1, 1, 0xff7f0000, 1, 1,-1&#125;, // 6
    &#123;0, 1, 0xff7f0000,-1, 1,-1&#125;, // 7
    
    &#123;0, 0, 0xff007f00, 1,-1,-1&#125;, // 0
    &#123;1, 0, 0xff007f00, 1,-1, 1&#125;, // 3
    &#123;1, 1, 0xff007f00, 1, 1, 1&#125;, // 7
    
    &#123;0, 0, 0xff007f00, 1,-1,-1&#125;, // 0
    &#123;1, 1, 0xff007f00, 1, 1, 1&#125;, // 7
    &#123;0, 1, 0xff007f00, 1, 1,-1&#125;, // 4
    
    &#123;0, 0, 0xff007f00,-1,-1,-1&#125;, // 0
    &#123;1, 0, 0xff007f00,-1, 1,-1&#125;, // 3
    &#123;1, 1, 0xff007f00,-1, 1, 1&#125;, // 7
    
    &#123;0, 0, 0xff007f00,-1,-1,-1&#125;, // 0
    &#123;1, 1, 0xff007f00,-1, 1, 1&#125;, // 7
    &#123;0, 1, 0xff007f00,-1,-1, 1&#125;, // 4
    
    &#123;0, 0, 0xff00007f,-1, 1,-1&#125;, // 0
    &#123;1, 0, 0xff00007f, 1, 1,-1&#125;, // 1
    &#123;1, 1, 0xff00007f, 1, 1, 1&#125;, // 2
    
    &#123;0, 0, 0xff00007f,-1, 1,-1&#125;, // 0
    &#123;1, 1, 0xff00007f, 1, 1, 1&#125;, // 2
    &#123;0, 1, 0xff00007f,-1, 1, 1&#125;, // 3
    
    &#123;0, 0, 0xff00007f,-1,-1,-1&#125;, // 4
    &#123;1, 0, 0xff00007f,-1,-1, 1&#125;, // 7
    &#123;1, 1, 0xff00007f, 1,-1, 1&#125;, // 6
    
    &#123;0, 0, 0xff00007f,-1,-1,-1&#125;, // 4
    &#123;1, 1, 0xff00007f, 1,-1, 1&#125;, // 6
    &#123;0, 1, 0xff00007f, 1,-1,-1&#125;, // 5
&#125;;

#define BUF_WIDTH &#40;512&#41;
#define SCR_WIDTH &#40;480&#41;
#define SCR_HEIGHT &#40;272&#41;
#define PIXEL_SIZE &#40;4&#41; /* change this if you change to another screenmode */
#define FRAME_SIZE &#40;BUF_WIDTH * SCR_HEIGHT * PIXEL_SIZE&#41;
#define ZBUF_SIZE &#40;BUF_WIDTH SCR_HEIGHT * 2&#41; /* zbuffer seems to be 16-bit? */

static void SetupGu&#40;&#41;
&#123;
    sceGuInit&#40;&#41;;

    sceGuStart&#40;GU_DIRECT,list&#41;;
    sceGuDrawBuffer&#40;GU_PSM_8888,&#40;void*&#41;0,BUF_WIDTH&#41;;
    sceGuDispBuffer&#40;SCR_WIDTH,SCR_HEIGHT,&#40;void*&#41;0x88000,BUF_WIDTH&#41;;
    sceGuDepthBuffer&#40;&#40;void*&#41;0x110000,BUF_WIDTH&#41;;
    sceGuOffset&#40;2048 - &#40;SCR_WIDTH/2&#41;,2048 - &#40;SCR_HEIGHT/2&#41;&#41;;
    sceGuViewport&#40;2048,2048,SCR_WIDTH,SCR_HEIGHT&#41;;
    sceGuDepthRange&#40;0xc350,0x2710&#41;;
    sceGuScissor&#40;0,0,SCR_WIDTH,SCR_HEIGHT&#41;;
    sceGuEnable&#40;GU_SCISSOR_TEST&#41;;
    sceGuDepthFunc&#40;GU_GEQUAL&#41;;
    sceGuEnable&#40;GU_DEPTH_TEST&#41;;
    sceGuFrontFace&#40;GU_CW&#41;;
    sceGuShadeModel&#40;GU_SMOOTH&#41;;
    sceGuEnable&#40;GU_CULL_FACE&#41;;
    sceGuEnable&#40;GU_CLIP_PLANES&#41;;
    sceGuFinish&#40;&#41;;
    sceGuSync&#40;0,0&#41;;
    
    sceDisplayWaitVblankStart&#40;&#41;;
    sceGuDisplay&#40;GU_TRUE&#41;;
&#125;

static void DrawStuff&#40;void&#41;
&#123;
    static int val = 0;

    sceGuStart&#40;GU_DIRECT,list&#41;;

    // clear screen
    
    sceGuClearColor&#40;0xff554433&#41;;
    sceGuClearDepth&#40;0&#41;;
    sceGuClear&#40;GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT&#41;;
    
    // setup matrices for cube
    
    sceGumMatrixMode&#40;GU_PROJECTION&#41;;
    sceGumLoadIdentity&#40;&#41;;
    sceGumPerspective&#40;75.0f,16.0f/9.0f,0.5f,1000.0f&#41;;
    
    sceGumMatrixMode&#40;GU_VIEW&#41;;
    sceGumLoadIdentity&#40;&#41;;
    
    sceGumMatrixMode&#40;GU_MODEL&#41;;
    sceGumLoadIdentity&#40;&#41;;
    &#123;
        ScePspFVector3 pos = &#123; 0, 0, -2.5f &#125;;
        ScePspFVector3 rot = &#123; val * 0.79f * &#40;M_PI/180.0f&#41;, val * 0.98f * &#40;M_PI/180.0f&#41;, val * 1.32f * &#40;M_PI/180.0f&#41; &#125;;
        sceGumRotateXYZ&#40;&rot&#41;;
        sceGumTranslate&#40;&pos&#41;;
    &#125;
    
    // draw cube
    
    sceGuAmbientColor&#40;0xffffffff&#41;;
    sceGumDrawArray&#40;GU_TRIANGLES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,12*3,0,vertices&#41;;
    
    sceGuFinish&#40;&#41;;
    sceGuSync&#40;0,0&#41;;

    val ++;
&#125;


int keyboard&#40;char *input&#41;&#123;
	
	int done=0;

	// 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 = 2;
	osk.buttonswap = 1; //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;!done&#41; &#123;
		
		DrawStuff&#40;&#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;
				done = 1;
				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;

		/**/
		sceDisplayWaitVblankStart&#40;&#41;;
		sceGuSwapBuffers&#40;&#41;;
	&#125;
	return 1;
&#125;
/* main routine */
int main&#40;int argc, char *argv&#91;&#93;&#41;
&#123;
	char input&#91;128&#93;="";

    SetupCallbacks&#40;&#41;;
    SetupGu&#40;&#41;;
	
    keyboard&#40;input&#41;;
	

	pspDebugScreenInit&#40;&#41;;
	pspDebugScreenClear&#40;&#41;;

	printf&#40;"osk return&#58;\n\n%s\n", input&#41;;

	sceKernelDelayThread&#40;10000000&#41;;
	sceKernelExitGame&#40;&#41;;
    return 0;
&#125;
2. create your Makefile like that:

Code: Select all

TARGET = OSK_SAMPLE
OBJS = main.o

INCDIR =

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

BUILD_PRX = 1

LIBDIR =
LDFLAGS =
LIBS= -lpsputility -lpspgum -lpspgu -lm

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = OSK_SAMPLE

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak

release&#58; all
	mksfo OSK_SAMPLE PARAM.SFO
	pack-pbp EBOOT.PBP PARAM.SFO NULL NULL NULL NULL NULL OSK_SAMPLE.prx NULL
	cp EBOOT.PBP ./303
3. You have to create "303" directory before compiling

4. When all done type "make release" and paste "303" directory in your "GAME303" or "GAME".... as you want
AnalCobra
Posts: 1
Joined: Sat Mar 03, 2007 12:41 am

Post by AnalCobra »

hey guys,

when i try to make the stuff posted above by blondin then i get following error :

Code: Select all

$ make release
make&#58; *** /usr/local/pspdev/psp/sdk&#58; Is a directory.  Stop.
Does somebody know how to get rid of this error?

EDIT:
Did nobody hear something about this error, yet?
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

I've modified blondin's code from above for the latest SDK. This works peachy on my 3.71 M33-2 Slim.

main.c

Code: Select all

#include <pspkernel.h>
#include <pspdisplay.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <pspmoduleinfo.h>
#include <psputility.h>
#include <pspgu.h>
#include <pspgum.h>

#include <psputility_osk.h>

/* Define the module info section */
PSP_MODULE_INFO&#40;"MsgDialog Sample", 0, 1, 0&#41;;

#define printf pspDebugScreenPrintf

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41;
&#123;
	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41;
&#123;
	int cbid;
	cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
	sceKernelRegisterExitCallback&#40;cbid&#41;;
	sceKernelSleepThreadCB&#40;&#41;;

	return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41;
&#123;
	int thid = 0;
	thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
	if &#40;thid >= 0&#41;
		 sceKernelStartThread&#40;thid, 0, 0&#41;;
	return thid;
&#125;


/* Graphics stuff, based on cube sample */

static unsigned int __attribute__&#40;&#40;aligned&#40;16&#41;&#41;&#41; list&#91;262144&#93;;

struct Vertex
&#123;
	float u, v;
	unsigned int color;
	float x,y,z;
&#125;;

struct Vertex __attribute__&#40;&#40;aligned&#40;16&#41;&#41;&#41; vertices&#91;12*3&#93; =
&#123;
	&#123;0, 0, 0xff7f0000,-1,-1, 1&#125;, // 0
	&#123;1, 0, 0xff7f0000,-1, 1, 1&#125;, // 4
	&#123;1, 1, 0xff7f0000, 1, 1, 1&#125;, // 5

	&#123;0, 0, 0xff7f0000,-1,-1, 1&#125;, // 0
	&#123;1, 1, 0xff7f0000, 1, 1, 1&#125;, // 5
	&#123;0, 1, 0xff7f0000, 1,-1, 1&#125;, // 1

	&#123;0, 0, 0xff7f0000,-1,-1,-1&#125;, // 3
	&#123;1, 0, 0xff7f0000, 1,-1,-1&#125;, // 2
	&#123;1, 1, 0xff7f0000, 1, 1,-1&#125;, // 6

	&#123;0, 0, 0xff7f0000,-1,-1,-1&#125;, // 3
	&#123;1, 1, 0xff7f0000, 1, 1,-1&#125;, // 6
	&#123;0, 1, 0xff7f0000,-1, 1,-1&#125;, // 7

	&#123;0, 0, 0xff007f00, 1,-1,-1&#125;, // 0
	&#123;1, 0, 0xff007f00, 1,-1, 1&#125;, // 3
	&#123;1, 1, 0xff007f00, 1, 1, 1&#125;, // 7

	&#123;0, 0, 0xff007f00, 1,-1,-1&#125;, // 0
	&#123;1, 1, 0xff007f00, 1, 1, 1&#125;, // 7
	&#123;0, 1, 0xff007f00, 1, 1,-1&#125;, // 4

	&#123;0, 0, 0xff007f00,-1,-1,-1&#125;, // 0
	&#123;1, 0, 0xff007f00,-1, 1,-1&#125;, // 3
	&#123;1, 1, 0xff007f00,-1, 1, 1&#125;, // 7

	&#123;0, 0, 0xff007f00,-1,-1,-1&#125;, // 0
	&#123;1, 1, 0xff007f00,-1, 1, 1&#125;, // 7
	&#123;0, 1, 0xff007f00,-1,-1, 1&#125;, // 4

	&#123;0, 0, 0xff00007f,-1, 1,-1&#125;, // 0
	&#123;1, 0, 0xff00007f, 1, 1,-1&#125;, // 1
	&#123;1, 1, 0xff00007f, 1, 1, 1&#125;, // 2

	&#123;0, 0, 0xff00007f,-1, 1,-1&#125;, // 0
	&#123;1, 1, 0xff00007f, 1, 1, 1&#125;, // 2
	&#123;0, 1, 0xff00007f,-1, 1, 1&#125;, // 3

	&#123;0, 0, 0xff00007f,-1,-1,-1&#125;, // 4
	&#123;1, 0, 0xff00007f,-1,-1, 1&#125;, // 7
	&#123;1, 1, 0xff00007f, 1,-1, 1&#125;, // 6

	&#123;0, 0, 0xff00007f,-1,-1,-1&#125;, // 4
	&#123;1, 1, 0xff00007f, 1,-1, 1&#125;, // 6
	&#123;0, 1, 0xff00007f, 1,-1,-1&#125;, // 5
&#125;;

#define BUF_WIDTH &#40;512&#41;
#define SCR_WIDTH &#40;480&#41;
#define SCR_HEIGHT &#40;272&#41;
#define PIXEL_SIZE &#40;4&#41; /* change this if you change to another screenmode */
#define FRAME_SIZE &#40;BUF_WIDTH * SCR_HEIGHT * PIXEL_SIZE&#41;
#define ZBUF_SIZE &#40;BUF_WIDTH SCR_HEIGHT * 2&#41; /* zbuffer seems to be 16-bit? */

static void SetupGu&#40;&#41;
&#123;
	sceGuInit&#40;&#41;;

	sceGuStart&#40;GU_DIRECT,list&#41;;
	sceGuDrawBuffer&#40;GU_PSM_8888,&#40;void*&#41;0,BUF_WIDTH&#41;;
	sceGuDispBuffer&#40;SCR_WIDTH,SCR_HEIGHT,&#40;void*&#41;0x88000,BUF_WIDTH&#41;;
	sceGuDepthBuffer&#40;&#40;void*&#41;0x110000,BUF_WIDTH&#41;;
	sceGuOffset&#40;2048 - &#40;SCR_WIDTH/2&#41;,2048 - &#40;SCR_HEIGHT/2&#41;&#41;;
	sceGuViewport&#40;2048,2048,SCR_WIDTH,SCR_HEIGHT&#41;;
	sceGuDepthRange&#40;0xc350,0x2710&#41;;
	sceGuScissor&#40;0,0,SCR_WIDTH,SCR_HEIGHT&#41;;
	sceGuEnable&#40;GU_SCISSOR_TEST&#41;;
	sceGuDepthFunc&#40;GU_GEQUAL&#41;;
	sceGuEnable&#40;GU_DEPTH_TEST&#41;;
	sceGuFrontFace&#40;GU_CW&#41;;
	sceGuShadeModel&#40;GU_SMOOTH&#41;;
	sceGuEnable&#40;GU_CULL_FACE&#41;;
	sceGuEnable&#40;GU_CLIP_PLANES&#41;;
	sceGuFinish&#40;&#41;;
	sceGuSync&#40;0,0&#41;;

	sceDisplayWaitVblankStart&#40;&#41;;
	sceGuDisplay&#40;GU_TRUE&#41;;
&#125;

static void DrawStuff&#40;void&#41;
&#123;
	static int val = 0;

	sceGuStart&#40;GU_DIRECT,list&#41;;

	// clear screen

	sceGuClearColor&#40;0xff554433&#41;;
	sceGuClearDepth&#40;0&#41;;
	sceGuClear&#40;GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT&#41;;

	// setup matrices for cube

	sceGumMatrixMode&#40;GU_PROJECTION&#41;;
	sceGumLoadIdentity&#40;&#41;;
	sceGumPerspective&#40;75.0f,16.0f/9.0f,0.5f,1000.0f&#41;;

	sceGumMatrixMode&#40;GU_VIEW&#41;;
	sceGumLoadIdentity&#40;&#41;;

	sceGumMatrixMode&#40;GU_MODEL&#41;;
	sceGumLoadIdentity&#40;&#41;;
	&#123;
		 ScePspFVector3 pos = &#123; 0, 0, -2.5f &#125;;
		 ScePspFVector3 rot = &#123; val * 0.79f * &#40;M_PI/180.0f&#41;, val * 0.98f * &#40;M_PI/180.0f&#41;, val * 1.32f * &#40;M_PI/180.0f&#41; &#125;;
		 sceGumRotateXYZ&#40;&rot&#41;;
		 sceGumTranslate&#40;&pos&#41;;
	&#125;

	// draw cube

	sceGuAmbientColor&#40;0xffffffff&#41;;
	sceGumDrawArray&#40;GU_TRIANGLES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,12*3,0,vertices&#41;;

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

	val ++;
&#125;


int keyboard&#40;char *input&#41;&#123;

	int done=0;

	// 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;			// key glyphs&#58; 0-1=hiragana, 2+=western
	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.base.size = sizeof&#40;osk&#41;;
	// dialog language&#58; 0=Japanese, 1=English, 2=French, 3=Spanish, 4=German,
	// 5=Italian, 6=Dutch, 7=Portuguese, 8=Russian, 9=Korean, 10-11=Chinese, 12+=default
	osk.base.language = 1;
	osk.base.buttonSwap = 1;		// X button&#58; 1
	osk.base.graphicsThread = 17;	// gfx thread pri
	osk.base.unknown = 19;			// unknown thread pri &#40;?&#41;
	osk.base.fontThread = 18;
	osk.base.soundThread = 16;
	osk.unk_48 = 1;
	osk.data = &data;


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

	while&#40;!done&#41; &#123;

		DrawStuff&#40;&#41;;

		switch&#40;sceUtilityOskGetStatus&#40;&#41;&#41; &#123;
			case PSP_UTILITY_DIALOG_INIT &#58;
				break;
			case PSP_UTILITY_DIALOG_VISIBLE &#58;
				sceUtilityOskUpdate&#40;2&#41;; // 2 is taken from ps2dev.org recommendation
				break;
			case PSP_UTILITY_DIALOG_QUIT &#58;
				sceUtilityOskShutdownStart&#40;&#41;;
				break;
			case PSP_UTILITY_DIALOG_FINISHED &#58;
				done = 1;
				break;
			case PSP_UTILITY_DIALOG_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;

		/**/
		sceDisplayWaitVblankStart&#40;&#41;;
		sceGuSwapBuffers&#40;&#41;;
	&#125;
	return 1;
&#125;
/* main routine */
int main&#40;int argc, char *argv&#91;&#93;&#41;
&#123;
	char input&#91;128&#93;="";

	SetupCallbacks&#40;&#41;;
	SetupGu&#40;&#41;;

	keyboard&#40;input&#41;;


	pspDebugScreenInit&#40;&#41;;
	pspDebugScreenClear&#40;&#41;;

	printf&#40;"osk return&#58;\n\n%s\n", input&#41;;

	sceKernelDelayThread&#40;10000000&#41;;
	sceKernelExitGame&#40;&#41;;
	return 0;
&#125;
Note the comments on the two language fields. I figured those out by changing the values and observing the results.
capz
Posts: 6
Joined: Tue May 20, 2008 4:15 am

Post by capz »

AnalCobra wrote:hey guys,

when i try to make the stuff posted above by blondin then i get following error :

Code: Select all

$ make release
make&#58; *** /usr/local/pspdev/psp/sdk&#58; Is a directory.  Stop.
Does somebody know how to get rid of this error?

EDIT:
Did nobody hear something about this error, yet?
Am also having that exact same error, could somebody with more experience look at this? i only started this week :P
Question_dev
Posts: 88
Joined: Fri Aug 24, 2007 8:23 pm

Post by Question_dev »

Search for libosk, a easy-to-use osk lib. Just use the sample as basic. Easy to understand, only 4 lines of code and u got an advanced keyboard with text stored in char, etc. .

Cu
capz
Posts: 6
Joined: Tue May 20, 2008 4:15 am

Post by capz »

Question_dev wrote:Search for libosk, a easy-to-use osk lib. Just use the sample as basic. Easy to understand, only 4 lines of code and u got an advanced keyboard with text stored in char, etc. .

Cu
hi, i did a little searching for that lib, but i found nothing. Nothing in google (that i could read at least), this forum, or the svn. would you/anyone be so kind to give me some directions?
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

I commited an updated osk header file and a sample recently.

Update your SDK.
Post Reply