Danzeff keyboard on sio sample

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

Moderators: cheriff, TyRaNiD

Post Reply
everlasting
Posts: 41
Joined: Mon Mar 19, 2007 6:27 pm

Danzeff keyboard on sio sample

Post by everlasting »

I'm trying to add the danzeff keyboard into the sio sample of the pspsdk but i'm having several problems, until the point that i have get lost, so if any of you could help me i would be very greatfull.

So far my problems come when i try to compile the program, this is what i get:

Laura@LAURITA ~/projects/SIO_project
$ make

psp-gcc -I/usr/local/pspdev/psp/sdk/include/libc -I. -I/usr/local/pspdev/psp/sdk
/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150 -L. -L/usr/local/pspdev/psp/sdk/li
b main.o danzeff.o -lpspgu -lm -lpspdebug -lpspdisplay -lpspge -lpspctrl -lps
psdk -lpsplibc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputil
ity -lpspuser -lpspkernel -lpsphprm_driver -o SIO_project.elf
danzeff.o: In function `surface_draw_offset':
danzeff.c:(.text+0x324): undefined reference to `SDL_UpperBlit'
danzeff.o: In function `danzeff_load':
danzeff.c:(.text+0x394): undefined reference to `IMG_Load'
danzeff.c:(.text+0x414): undefined reference to `SDL_FreeSurface'
danzeff.o: In function `danzeff_free':
danzeff.c:(.text+0x460): undefined reference to `SDL_FreeSurface'
collect2: ld returned 1 exit status
make: *** [SIO_project.elf] Error 1


It seems that the problems have something to do with SDL but i've already added <SDL/SDL.h> and <SDL/SDL_image> in the program.

My Makefile is at follows:

TARGET = SIO_project
OBJS = main.o danzeff.o

USE_PSPSDK_LIBC = 1

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

LIBDIR =
LDFLAGS =
LIBS = -lpspgu -lm


EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = SIO Project

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

LIBS += -lpsphprm_driver


I quited -lpng and -lz from libs because i reported a problem that says they weren't found and i wasn't sure to need them.

Thank you
everlasting
Posts: 41
Joined: Mon Mar 19, 2007 6:27 pm

Post by everlasting »

May be i haven't given enough clues in my previous post. I have to say that i'm using the danzeff osk source code, you can download it from: http://dl.qj.net/Danzeff-OSK-Source-PSP ... /catid/203

Once you unzip it you have:danzeff.c, danzeff.h, pspctrl_emu.c, pspctrl_emu.h and a graphic folder. I've not changed anything on any of them except for adding ( #include <SDL/SDL.h> ) at the beggining of the danzeff.c. I hope this info will be enough for any of you to try to help me.

One last thing is that i solved the problem with adding -lpng and -lz and now it doesn't give any error.

Thanks a lot.
everlasting
Posts: 41
Joined: Mon Mar 19, 2007 6:27 pm

Post by everlasting »

#include <SDL/SDL.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspsdk.h>
//#include <pspctrl.h>
//the SDL implementation needs the pspctrl_emu wrapper to convert
//a SDL_Joystick into a SceCtrlData
#include "pspctrl_emu.h"
//------------fin de lo añadido
#include <stdio.h>
#include <string.h>
#include "danzeff.h"
#include "danzeff.c"

PSP_MODULE_INFO("REMOTE", 0x1000, 1, 1);
/* Define the main thread's attribute value (optional) */
PSP_MAIN_THREAD_ATTR(0);

int main(void)
{
pspDebugScreenInit();

sceCtrlSetSamplingCycle(0);
//sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);

/* Initialise SIO and install a kprintf handler */
pspDebugSioInit();
pspDebugSioInstallKprintf();

/* Install a stdout handler */
pspDebugInstallStdoutHandler(pspDebugSioPutData);

Kprintf("Hi from %s!\n", "Kprintf");
printf("Also hi from stdio\r\n");

pspDebugScreenPrintf("Press X to exit, tap away on your terminal to echo\n");
sceDisplayWaitVblankStart();

while(1)
{
SceCtrlData pad;
int ch;

sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CROSS)
{
break;
}
//-----------------------------------------------
//nueva rutina para que cargue el teclado de danzeff si presiono start
//-----------------------------------------------
if(pad.Buttons & PSP_CTRL_START){
danzeff_load();

}
//fin de la nueva rutina

ch = pspDebugSioGetchar();
if(ch >= 0)
{
pspDebugScreenPrintf("ColdFire dice: %c", ch);
if(ch == '\r')
{
pspDebugSioPutchar('\r');
pspDebugSioPutchar('\n');
}
else
{
pspDebugSioPutchar(ch);
}
}

sceDisplayWaitVblankStart();
}

sceKernelExitGame();

return 0;
}


And the error message is:

$ make
psp-gcc -I/usr/local/pspdev/psp/sdk/include/libc -I. -I/usr/local/pspdev/psp/sdk
/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150 -L. -L/usr/local/pspdev/psp/sdk/li
b main.o -lpspgu -lm -lpng -lz -lpspdebug -lpspdisplay -lpspge -lpspctrl -lps
psdk -lpsplibc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputil
ity -lpspuser -lpspkernel -lpsphprm_driver -o SIO_project.elf
main.o: In function `surface_draw_offset':
main.c:(.text+0x324): undefined reference to `SDL_UpperBlit'
main.o: In function `danzeff_load':
main.c:(.text+0x394): undefined reference to `IMG_Load'
main.c:(.text+0x414): undefined reference to `SDL_FreeSurface'
main.o: In function `danzeff_free':
main.c:(.text+0x460): undefined reference to `SDL_FreeSurface'

collect2: ld returned 1 exit status
make: *** [SIO_project.elf] Error 1


WHY??
Thanks again.
danzel
Posts: 182
Joined: Fri Nov 04, 2005 11:03 pm

Post by danzel »

Add "-lSDL_image -lSDL" to the "LIBS=" line in your Makefile.

The latest danzeff code is in the pspradio SVN:
http://sourceforge.net/svn/?group_id=166538
http://pspradio.svn.sourceforge.net/vie ... b/danzeff/
It has changed slightly from the version you have, minor fixes etc.
There are now also SDL/GU/Framebuffer versions, depending on your needs :)
Use the different makefiles to build each one. (may need minor modification to build outside of the pspradio directory)
everlasting
Posts: 41
Joined: Mon Mar 19, 2007 6:27 pm

Post by everlasting »

Thank you very much Danzel, I've reinstalled cygwin and now I'm reinstalling the toolchain and then the libs, I'm sure it will work with your help so thank you again
everlasting
Posts: 41
Joined: Mon Mar 19, 2007 6:27 pm

Post by everlasting »

I have still problems, it seems that something is wrong with my libs, when i try to compile i get the next errors:



/home/Laura/trunk/sdl/src/video/psp/SDL_pspvideo.c:630: undefined reference to `
sceGuTexFunc'
/home/Laura/trunk/sdl/src/video/psp/SDL_pspvideo.c:631: undefined reference to `
sceGuTexFilter'
/home/Laura/trunk/sdl/src/video/psp/SDL_pspvideo.c:632: undefined reference to `
sceGuTexImage'
/home/Laura/trunk/sdl/src/video/psp/SDL_pspvideo.c:633: undefined reference to `
sceGuTexSync'
/home/Laura/trunk/sdl/src/video/psp/SDL_pspvideo.c:674: undefined reference to `
sceGuFinish'
/home/Laura/trunk/sdl/src/video/psp/SDL_pspvideo.c:670: undefined reference to `
sceGuDrawArray'
/home/Laura/trunk/sdl/src/video/psp/SDL_pspvideo.c:637: undefined reference to `
sceGuGetMemory'
/home/Laura/trunk/sdl/src/video/psp/SDL_pspvideo.c:645: undefined reference to `
sceGuTexImage'
/home/Laura/trunk/sdl/src/video/psp/SDL_pspvideo.c:647: undefined reference to `
sceGuTexSync'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libSDL.a(SDL_pspvideo.o)
: In function `PSP_FlipHWSurface':
/home/Laura/trunk/sdl/src/video/psp/SDL_pspvideo.c:556: undefined reference to `
sceGuSwapBuffers'
/home/Laura/trunk/sdl/src/video/psp/SDL_pspvideo.c:549: undefined reference to `
sceGuSync'
/home/Laura/trunk/sdl/src/video/psp/SDL_pspvideo.c:556: undefined reference to `
sceGuSwapBuffers'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libSDL.a(SDL_pspvideo.o)
: In function `HWAccelBlit':
/home/Laura/trunk/sdl/src/video/psp/SDL_pspvideo.c:585: undefined reference to `
sceGuStart'
/home/Laura/trunk/sdl/src/video/psp/SDL_pspvideo.c:587: undefined reference to `
sceGuCopyImage'
/home/Laura/trunk/sdl/src/video/psp/SDL_pspvideo.c:593: undefined reference to `
sceGuFinish'
/home/Laura/trunk/sdl/src/video/psp/SDL_pspvideo.c:597: undefined reference to `
sceGuSync'
/home/Laura/trunk/sdl/src/video/psp/SDL_pspvideo.c:597: undefined reference to `
sceGuSync'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libSDL.a(SDL_pspvideo.o)
: In function `PSP_GuUpdateRects':
/home/Laura/trunk/sdl/src/video/psp/SDL_pspvideo.c:732: undefined reference to `
sceGuSync'
/usr/local/pspdev/lib/gcc/psp/4.0.2/../../../../psp/lib/libSDL.a(SDL_pspevents.o
): In function `EventUpdate':
/home/Laura/trunk/sdl/src/video/psp/SDL_pspevents.c:61: undefined reference to `
sceHprmPeekCurrentKey'
collect2: ld returned 1 exit status
make: *** [.elf] Error 1


and more but all of this kind, is something wrong with my libs?
danzel
Posts: 182
Joined: Fri Nov 04, 2005 11:03 pm

Post by danzel »

no, you just need to add even more to the makefile...

try just make the line as follows (from the afkim makefile)

LIBS = -lSDL_image -lSDL -lfreetype -ldanzeffpuresdl -lpng -lz -lm -ljpeg -lpspaudio -lpsphprm -lpspgu -lpspwlan -lpsppower -lpsprtc -lstdc++

should be enough :) lol
everlasting
Posts: 41
Joined: Mon Mar 19, 2007 6:27 pm

Post by everlasting »

Thanks a lot for your help danzel, at this time after n hours without sleeping i have made some progress, a huge progress for me, now i can load your keyboard and show it on screen.

My problems were the next:

Consider i'm a noob so may be some problems are stupid things.

1.-ldanzeffpuresdl .If you download the osk you don't get that lib do you? I ended up downloading trunk/PSP from pspradio svn and compiling all my projects in /home/USER/trunk/PSP/Sharedlib/"My folder" and put into "My folder" all the files contained in danzeff folder.

2. I didn't manage to use the sdl, i made danzeff_readInput() and danzeff_render(), but nothing happened so I decided to use the gu version.

3.It was a problem to know how to make the setup gu required for the danzeff, in the end i copied the one from the sample/gu/text/ from the sdk and it worked following your readme, but i don't know if it is a lot easier and it would be enough to load a couple of functions of the gu and not about twenty sceGuWhatever as i did.

And that's all. I'm very grateful, thanks for the time you spend on me,hope this will be useful for other people, and also congratulations for the work you have done, it's really amazing!.

Adios
danzel
Posts: 182
Joined: Fri Nov 04, 2005 11:03 pm

Post by danzel »

Good to hear you go it working.
Thanks :)
everlasting
Posts: 41
Joined: Mon Mar 19, 2007 6:27 pm

Post by everlasting »

Hi again!Another easy question, please Danzel.
I have detected a poblem when in my program i call danzeff_readInput. In danzeff.c you change the holding value(see the line in bold letters).This is your code(if you don't remember ;-p):

unsigned int danzeff_readInput(SceCtrlData pspctrl)
{
//For rotated keyboards
u32 up_key, down_key, left_key, right_key;

if (orientation == DANZEFF_ORIENT_RIGHT)
{
up_key = PSP_CTRL_RIGHT;
down_key = PSP_CTRL_LEFT;
left_key = PSP_CTRL_UP;
right_key = PSP_CTRL_DOWN;
}
else
{
up_key = PSP_CTRL_UP;
down_key = PSP_CTRL_DOWN;
left_key = PSP_CTRL_LEFT;
right_key = PSP_CTRL_RIGHT;
}

//Work out where the analog stick is selecting
int x = 1;
int y = 1;
if (pspctrl.Lx < 85) x -= 1;
else if (pspctrl.Lx > 170) x += 1;

if (pspctrl.Ly < 85) y -= 1;
else if (pspctrl.Ly > 170) y += 1;

if (selected_x != x || selected_y != y) //If they've moved, update dirty
{
dirty = true;
selected_x = x;
selected_y = y;
}
//if they are changing shift then that makes it dirty too
if ((!shifted && (pspctrl.Buttons & PSP_CTRL_RTRIGGER)) || (shifted && !(pspctrl.Buttons & PSP_CTRL_RTRIGGER)))
dirty = true;

unsigned int pressed = 0; //character they have entered, 0 as that means 'nothing'
shifted = (pspctrl.Buttons & PSP_CTRL_RTRIGGER)?true:false;

if (!holding)
{
if (pspctrl.Buttons& (PSP_CTRL_CROSS|PSP_CTRL_CIRCLE|PSP_CTRL_TRIANGLE|PSP_CTRL_SQUARE)) //pressing a char select button
{
int innerChoice = 0;
if (pspctrl.Buttons & PSP_CTRL_TRIANGLE)
innerChoice = 0;
else if (pspctrl.Buttons & PSP_CTRL_SQUARE)
innerChoice = 1;
else if (pspctrl.Buttons & PSP_CTRL_CROSS)
innerChoice = 2;
else //if (pspctrl.Buttons & PSP_CTRL_CIRCLE)
innerChoice = 3;

//Now grab the value out of the array
if (orientation == DANZEFF_ORIENT_RIGHT)
{
pressed = modeCharRight[ mode*2 + shifted][y][x][innerChoice];
}
else
{
pressed = modeChar[ mode*2 + shifted][y][x][innerChoice];
}
}
else if (pspctrl.Buttons& PSP_CTRL_LTRIGGER) //toggle mode
{
dirty = true;
mode++;
mode %= MODE_COUNT;
}
else if (pspctrl.Buttons& down_key)
{
pressed = '\n';
}
else if (pspctrl.Buttons& up_key)
{
pressed = 8; //backspace
}
else if (pspctrl.Buttons& left_key)
{
pressed = DANZEFF_LEFT; //LEFT
}
else if (pspctrl.Buttons& right_key)
{
pressed = DANZEFF_RIGHT; //RIGHT
}
else if (pspctrl.Buttons& PSP_CTRL_SELECT)
{
pressed = DANZEFF_SELECT; //SELECT
}
else if (pspctrl.Buttons& PSP_CTRL_START)
{
pressed = DANZEFF_START; //START
}
}

holding = pspctrl.Buttons & ~PSP_CTRL_RTRIGGER; //RTRIGGER doesn't set holding

return pressed;
}


This makes that the next time i call readInput holding will be different than 0, so i won't be able to get into the if(!holding) to get the character i am pressing. I have tried to quit the line in bold letters and everything seems to work fine but i'm sure you wrote that for any reason.And sure there will be a cleaner way than quiting the line.
If you could waist your time once again ;-)
Last edited by everlasting on Mon Apr 16, 2007 8:08 pm, edited 1 time in total.
danzel
Posts: 182
Joined: Fri Nov 04, 2005 11:03 pm

Post by danzel »

'holding' gets unset when you release the buttons. This prevents the same letter coming through continuously while holding an input.

If you are in kernel mode or something then that line does mess it up however, change it to um....
holding = psp.ctrl.Buttons & (PSP_CTRL_SELECT|PSP_CTRL_START|PSP_CTRL_LTRIGGER|PSP_CTRL_CIRCLE|PSP_CTRL_CROSS|PSP_CTRL_SQUARE|PSP_CTRL_TRIANGLE|PSP_CTRL_UP|PSP_CTRL_DOWN|PSP_CTRL_LEFT|PSP_CTRL_RIGHT);

That should fix it.
everlasting
Posts: 41
Joined: Mon Mar 19, 2007 6:27 pm

Post by everlasting »

thanks for the help once more danzel
everlasting
Posts: 41
Joined: Mon Mar 19, 2007 6:27 pm

Alpha release

Post by everlasting »

This is a Chat app that can be used either with Hyperterminal (extra-Hardware needed, see nil page), either with other PSP using Irda standard.
The application is in a very early stage, but still have a few cool things. It works fully under Gu mode, and it is possible to rotate the screen at any time.
I will continue working on improving it and on adding extra features.
Test it and let me know what you think.
Thanks.
Download
Post Reply