Getting the Sony On SCreen Keyboard To Work
-
- Posts: 87
- Joined: Mon Jan 08, 2007 12:16 pm
- Location: Australia
Getting the Sony On SCreen Keyboard To Work
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
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
-
- Posts: 376
- Joined: Wed May 10, 2006 11:31 pm
-
- Posts: 87
- Joined: Mon Jan 08, 2007 12:16 pm
- Location: Australia
-
- Posts: 376
- Joined: Wed May 10, 2006 11:31 pm
Here's a mirror of McZonk's code mate.
It's pretty easy to understand.
http://www.psp-programming.com/animate/psposk.zip
It's pretty easy to understand.
http://www.psp-programming.com/animate/psposk.zip
-
- Posts: 87
- Joined: Mon Jan 08, 2007 12:16 pm
- Location: Australia
Work only with 1.50
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
THX
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).
-
- Posts: 87
- Joined: Mon Jan 08, 2007 12:16 pm
- Location: Australia
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.
OSK for 303OE
Ok guys, let's go :
1. Create new main.c in a new directory paste this code :
2. create your Makefile like that:
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
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("MsgDialog Sample", 0, 1, 0);
#define printf pspDebugScreenPrintf
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common)
{
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if (thid >= 0)
sceKernelStartThread(thid, 0, 0);
return thid;
}
/* Graphics stuff, based on cube sample */
static unsigned int __attribute__((aligned(16))) list[262144];
struct Vertex
{
float u, v;
unsigned int color;
float x,y,z;
};
struct Vertex __attribute__((aligned(16))) vertices[12*3] =
{
{0, 0, 0xff7f0000,-1,-1, 1}, // 0
{1, 0, 0xff7f0000,-1, 1, 1}, // 4
{1, 1, 0xff7f0000, 1, 1, 1}, // 5
{0, 0, 0xff7f0000,-1,-1, 1}, // 0
{1, 1, 0xff7f0000, 1, 1, 1}, // 5
{0, 1, 0xff7f0000, 1,-1, 1}, // 1
{0, 0, 0xff7f0000,-1,-1,-1}, // 3
{1, 0, 0xff7f0000, 1,-1,-1}, // 2
{1, 1, 0xff7f0000, 1, 1,-1}, // 6
{0, 0, 0xff7f0000,-1,-1,-1}, // 3
{1, 1, 0xff7f0000, 1, 1,-1}, // 6
{0, 1, 0xff7f0000,-1, 1,-1}, // 7
{0, 0, 0xff007f00, 1,-1,-1}, // 0
{1, 0, 0xff007f00, 1,-1, 1}, // 3
{1, 1, 0xff007f00, 1, 1, 1}, // 7
{0, 0, 0xff007f00, 1,-1,-1}, // 0
{1, 1, 0xff007f00, 1, 1, 1}, // 7
{0, 1, 0xff007f00, 1, 1,-1}, // 4
{0, 0, 0xff007f00,-1,-1,-1}, // 0
{1, 0, 0xff007f00,-1, 1,-1}, // 3
{1, 1, 0xff007f00,-1, 1, 1}, // 7
{0, 0, 0xff007f00,-1,-1,-1}, // 0
{1, 1, 0xff007f00,-1, 1, 1}, // 7
{0, 1, 0xff007f00,-1,-1, 1}, // 4
{0, 0, 0xff00007f,-1, 1,-1}, // 0
{1, 0, 0xff00007f, 1, 1,-1}, // 1
{1, 1, 0xff00007f, 1, 1, 1}, // 2
{0, 0, 0xff00007f,-1, 1,-1}, // 0
{1, 1, 0xff00007f, 1, 1, 1}, // 2
{0, 1, 0xff00007f,-1, 1, 1}, // 3
{0, 0, 0xff00007f,-1,-1,-1}, // 4
{1, 0, 0xff00007f,-1,-1, 1}, // 7
{1, 1, 0xff00007f, 1,-1, 1}, // 6
{0, 0, 0xff00007f,-1,-1,-1}, // 4
{1, 1, 0xff00007f, 1,-1, 1}, // 6
{0, 1, 0xff00007f, 1,-1,-1}, // 5
};
#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? */
static void SetupGu()
{
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);
}
static void DrawStuff(void)
{
static int val = 0;
sceGuStart(GU_DIRECT,list);
// clear screen
sceGuClearColor(0xff554433);
sceGuClearDepth(0);
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
// setup matrices for cube
sceGumMatrixMode(GU_PROJECTION);
sceGumLoadIdentity();
sceGumPerspective(75.0f,16.0f/9.0f,0.5f,1000.0f);
sceGumMatrixMode(GU_VIEW);
sceGumLoadIdentity();
sceGumMatrixMode(GU_MODEL);
sceGumLoadIdentity();
{
ScePspFVector3 pos = { 0, 0, -2.5f };
ScePspFVector3 rot = { val * 0.79f * (M_PI/180.0f), val * 0.98f * (M_PI/180.0f), val * 1.32f * (M_PI/180.0f) };
sceGumRotateXYZ(&rot);
sceGumTranslate(&pos);
}
// draw cube
sceGuAmbientColor(0xffffffff);
sceGumDrawArray(GU_TRIANGLES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,12*3,0,vertices);
sceGuFinish();
sceGuSync(0,0);
val ++;
}
int keyboard(char *input){
int done=0;
// 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 = 2;
osk.buttonswap = 1; //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(!done) {
DrawStuff();
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 :
done = 1;
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++;
}
}
/**/
sceDisplayWaitVblankStart();
sceGuSwapBuffers();
}
return 1;
}
/* main routine */
int main(int argc, char *argv[])
{
char input[128]="";
SetupCallbacks();
SetupGu();
keyboard(input);
pspDebugScreenInit();
pspDebugScreenClear();
printf("osk return:\n\n%s\n", input);
sceKernelDelayThread(10000000);
sceKernelExitGame();
return 0;
}
Code: Select all
TARGET = OSK_SAMPLE
OBJS = main.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
BUILD_PRX = 1
LIBDIR =
LDFLAGS =
LIBS= -lpsputility -lpspgum -lpspgu -lm
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = OSK_SAMPLE
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
release: 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
4. When all done type "make release" and paste "303" directory in your "GAME303" or "GAME".... as you want
hey guys,
when i try to make the stuff posted above by blondin then i get following error :
Does somebody know how to get rid of this error?
EDIT:
Did nobody hear something about this error, yet?
when i try to make the stuff posted above by blondin then i get following error :
Code: Select all
$ make release
make: *** /usr/local/pspdev/psp/sdk: Is a directory. Stop.
EDIT:
Did nobody hear something about this error, yet?
I've modified blondin's code from above for the latest SDK. This works peachy on my 3.71 M33-2 Slim.
main.c
Note the comments on the two language fields. I figured those out by changing the values and observing the results.
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("MsgDialog Sample", 0, 1, 0);
#define printf pspDebugScreenPrintf
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common)
{
sceKernelExitGame();
return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
if (thid >= 0)
sceKernelStartThread(thid, 0, 0);
return thid;
}
/* Graphics stuff, based on cube sample */
static unsigned int __attribute__((aligned(16))) list[262144];
struct Vertex
{
float u, v;
unsigned int color;
float x,y,z;
};
struct Vertex __attribute__((aligned(16))) vertices[12*3] =
{
{0, 0, 0xff7f0000,-1,-1, 1}, // 0
{1, 0, 0xff7f0000,-1, 1, 1}, // 4
{1, 1, 0xff7f0000, 1, 1, 1}, // 5
{0, 0, 0xff7f0000,-1,-1, 1}, // 0
{1, 1, 0xff7f0000, 1, 1, 1}, // 5
{0, 1, 0xff7f0000, 1,-1, 1}, // 1
{0, 0, 0xff7f0000,-1,-1,-1}, // 3
{1, 0, 0xff7f0000, 1,-1,-1}, // 2
{1, 1, 0xff7f0000, 1, 1,-1}, // 6
{0, 0, 0xff7f0000,-1,-1,-1}, // 3
{1, 1, 0xff7f0000, 1, 1,-1}, // 6
{0, 1, 0xff7f0000,-1, 1,-1}, // 7
{0, 0, 0xff007f00, 1,-1,-1}, // 0
{1, 0, 0xff007f00, 1,-1, 1}, // 3
{1, 1, 0xff007f00, 1, 1, 1}, // 7
{0, 0, 0xff007f00, 1,-1,-1}, // 0
{1, 1, 0xff007f00, 1, 1, 1}, // 7
{0, 1, 0xff007f00, 1, 1,-1}, // 4
{0, 0, 0xff007f00,-1,-1,-1}, // 0
{1, 0, 0xff007f00,-1, 1,-1}, // 3
{1, 1, 0xff007f00,-1, 1, 1}, // 7
{0, 0, 0xff007f00,-1,-1,-1}, // 0
{1, 1, 0xff007f00,-1, 1, 1}, // 7
{0, 1, 0xff007f00,-1,-1, 1}, // 4
{0, 0, 0xff00007f,-1, 1,-1}, // 0
{1, 0, 0xff00007f, 1, 1,-1}, // 1
{1, 1, 0xff00007f, 1, 1, 1}, // 2
{0, 0, 0xff00007f,-1, 1,-1}, // 0
{1, 1, 0xff00007f, 1, 1, 1}, // 2
{0, 1, 0xff00007f,-1, 1, 1}, // 3
{0, 0, 0xff00007f,-1,-1,-1}, // 4
{1, 0, 0xff00007f,-1,-1, 1}, // 7
{1, 1, 0xff00007f, 1,-1, 1}, // 6
{0, 0, 0xff00007f,-1,-1,-1}, // 4
{1, 1, 0xff00007f, 1,-1, 1}, // 6
{0, 1, 0xff00007f, 1,-1,-1}, // 5
};
#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? */
static void SetupGu()
{
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);
}
static void DrawStuff(void)
{
static int val = 0;
sceGuStart(GU_DIRECT,list);
// clear screen
sceGuClearColor(0xff554433);
sceGuClearDepth(0);
sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
// setup matrices for cube
sceGumMatrixMode(GU_PROJECTION);
sceGumLoadIdentity();
sceGumPerspective(75.0f,16.0f/9.0f,0.5f,1000.0f);
sceGumMatrixMode(GU_VIEW);
sceGumLoadIdentity();
sceGumMatrixMode(GU_MODEL);
sceGumLoadIdentity();
{
ScePspFVector3 pos = { 0, 0, -2.5f };
ScePspFVector3 rot = { val * 0.79f * (M_PI/180.0f), val * 0.98f * (M_PI/180.0f), val * 1.32f * (M_PI/180.0f) };
sceGumRotateXYZ(&rot);
sceGumTranslate(&pos);
}
// draw cube
sceGuAmbientColor(0xffffffff);
sceGumDrawArray(GU_TRIANGLES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,12*3,0,vertices);
sceGuFinish();
sceGuSync(0,0);
val ++;
}
int keyboard(char *input){
int done=0;
// 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; // key glyphs: 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(outtext) / sizeof(unsigned short)
data.outtextlimit = 50; // just allow 50 chars
data.outtext = (unsigned short*)outtext;
SceUtilityOskParams osk;
memset(&osk, 0, sizeof(osk));
osk.base.size = sizeof(osk);
// dialog language: 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: 1
osk.base.graphicsThread = 17; // gfx thread pri
osk.base.unknown = 19; // unknown thread pri (?)
osk.base.fontThread = 18;
osk.base.soundThread = 16;
osk.unk_48 = 1;
osk.data = &data;
int rc = sceUtilityOskInitStart(&osk);
if(rc) {
return 0;
}
while(!done) {
DrawStuff();
switch(sceUtilityOskGetStatus()) {
case PSP_UTILITY_DIALOG_INIT :
break;
case PSP_UTILITY_DIALOG_VISIBLE :
sceUtilityOskUpdate(2); // 2 is taken from ps2dev.org recommendation
break;
case PSP_UTILITY_DIALOG_QUIT :
sceUtilityOskShutdownStart();
break;
case PSP_UTILITY_DIALOG_FINISHED :
done = 1;
break;
case PSP_UTILITY_DIALOG_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++;
}
}
/**/
sceDisplayWaitVblankStart();
sceGuSwapBuffers();
}
return 1;
}
/* main routine */
int main(int argc, char *argv[])
{
char input[128]="";
SetupCallbacks();
SetupGu();
keyboard(input);
pspDebugScreenInit();
pspDebugScreenClear();
printf("osk return:\n\n%s\n", input);
sceKernelDelayThread(10000000);
sceKernelExitGame();
return 0;
}
Am also having that exact same error, could somebody with more experience look at this? i only started this week :PAnalCobra wrote:hey guys,
when i try to make the stuff posted above by blondin then i get following error :Does somebody know how to get rid of this error?Code: Select all
$ make release make: *** /usr/local/pspdev/psp/sdk: Is a directory. Stop.
EDIT:
Did nobody hear something about this error, yet?
-
- Posts: 88
- Joined: Fri Aug 24, 2007 8:23 pm
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?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
-
- Posts: 376
- Joined: Wed May 10, 2006 11:31 pm