Advertising (This ad goes away for registered users. You can Login or Register)

printf doesn't seem to work

Open discussions on programming specifically for the PS Vita.
Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
Post Reply
TheHebro
Posts: 2
Joined: Thu Aug 11, 2016 4:10 pm

printf doesn't seem to work

Post by TheHebro » Thu Aug 11, 2016 4:23 pm

Weird question, perhaps, but has anyone else had any issues getting the C function printf() to display text on the Vita's screen (as seen in the following example: https://github.com/vitasdk/samples/blob ... src/main.c)?

I've put together a simple program that's supposed to print the name of the current button being pressed. My program is able to compile and be installed on my Vita without issue, but I'm met with a black screen whenever I run it. The program exits when I press both start and select as it should (just like VitaTester), so I can tell that this isn't a matter of input going unrecognized.

Here's my code:

Code: Select all

#include <psp2/kernel/processmgr.h>
#include <psp2/ctrl.h>
#include <stdio.h>

#define TRUE 1
#define FALSE 0

#define EXIT_COMBO (SCE_CTRL_START | SCE_CTRL_SELECT)

SceCtrlData gamepad;

int main(int argc, char *argv[]) 
{
	sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG_WIDE);
	fflush(stdout);
	
	while (TRUE)
	{
		sceKernelPowerTick(0);
		sceCtrlPeekBufferPositive(0, &gamepad, 1);
		
		if (gamepad.buttons == EXIT_COMBO)
		{
			break;
		}
		
		if (gamepad.buttons & SCE_CTRL_UP)
		{
			printf("DPAD Up\n");
		}
		else if (gamepad.buttons & SCE_CTRL_DOWN)
		{
			printf("DPAD Down\n");
		}
		else if (gamepad.buttons & SCE_CTRL_LEFT)
		{
			printf("DPAD Left\n");
		}
		else if (gamepad.buttons & SCE_CTRL_RIGHT)
		{
			printf("DPAD Right\n");
		}
		else if (gamepad.buttons & SCE_CTRL_CROSS)
		{
			printf("X\n");
		}
		else if (gamepad.buttons & SCE_CTRL_CIRCLE)
		{
			printf("O\n");
		}
		else if (gamepad.buttons & SCE_CTRL_SQUARE)
		{
			printf("[]\n");
		}
		else if (gamepad.buttons & SCE_CTRL_TRIANGLE)
		{
			printf("^\n");
		}
		else if (gamepad.buttons & SCE_CTRL_SELECT)
		{
			printf("Select\n");
		}
		else if (gamepad.buttons & SCE_CTRL_START)
		{
			printf("Start\n");
		}
		else if (gamepad.buttons & SCE_CTRL_LTRIGGER)
		{
			printf("L\n");
		}
		else if (gamepad.buttons & SCE_CTRL_RTRIGGER)
		{
			printf("R\n");
		}
	}
	
	sceKernelExitProcess(0);
	return 0;
}
Any ideas would be greatly appreciated, thanks.
Advertising

Jhon Doe or John Doe
Posts: 27
Joined: Tue May 12, 2015 8:28 am

Re: printf doesn't seem to work

Post by Jhon Doe or John Doe » Thu Aug 11, 2016 5:41 pm

printf does not output to the screen.

On Rejuvenate it printed to the command prompt on the computer.
Advertising

TheHebro
Posts: 2
Joined: Thu Aug 11, 2016 4:10 pm

Re: printf doesn't seem to work

Post by TheHebro » Thu Aug 11, 2016 7:48 pm

Thanks for the tip, friend. Your tip led me to try the vita2d library instead, and that got the ball rolling. Onto the next project I go.

User avatar
Dmitry Work
Posts: 4
Joined: Sun Aug 14, 2016 1:32 pm
Contact:

Re: printf doesn't seem to work

Post by Dmitry Work » Sun Aug 14, 2016 3:45 pm

why it not work(as you wish): coz u make crosscompiling -> coz STANDART lib for i386->coz lib by lib use oun output function, so your lib(sdk) must use some adress/api/console (something to output). As Vita SDK tool is "arm-eabi" it use (i think) newlib or similar :-D and printf output to UART or etc.

Post Reply

Return to “Programming and Security”