Fix bug 2034: replace printf by SDL_Log in tests; update loopwave VS solution: copy missing dependency

This commit is contained in:
Andreas Schiffler committed 2013-08-14 23:30:10 -07:00
1 parent 67367be019
commit 65728477af
47 files changed
+616 -505

No files matched your search

+31 -28
View File
@@ -52,13 +52,13 @@ WatchJoystick(SDL_Joystick * joystick)
SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH,
SCREEN_HEIGHT, 0);
if (window == NULL) {
fprintf(stderr, "Couldn't create window: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
return SDL_FALSE;
}
screen = SDL_CreateRenderer(window, -1, 0);
if (screen == NULL) {
fprintf(stderr, "Couldn't create renderer: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
SDL_DestroyWindow(window);
return SDL_FALSE;
}
@@ -70,9 +70,9 @@ WatchJoystick(SDL_Joystick * joystick)
/* Print info about the joystick we are watching */
name = SDL_JoystickName(joystick);
printf("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick),
SDL_Log("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick),
name ? name : "Unknown Joystick");
printf("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
SDL_Log("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick),
SDL_JoystickNumBalls(joystick), SDL_JoystickNumButtons(joystick));
@@ -85,36 +85,36 @@ WatchJoystick(SDL_Joystick * joystick)
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_JOYAXISMOTION:
printf("Joystick %d axis %d value: %d\n",
SDL_Log("Joystick %d axis %d value: %d\n",
event.jaxis.which,
event.jaxis.axis, event.jaxis.value);
break;
case SDL_JOYHATMOTION:
printf("Joystick %d hat %d value:",
SDL_Log("Joystick %d hat %d value:",
event.jhat.which, event.jhat.hat);
if (event.jhat.value == SDL_HAT_CENTERED)
printf(" centered");
SDL_Log(" centered");
if (event.jhat.value & SDL_HAT_UP)
printf(" up");
SDL_Log(" up");
if (event.jhat.value & SDL_HAT_RIGHT)
printf(" right");
SDL_Log(" right");
if (event.jhat.value & SDL_HAT_DOWN)
printf(" down");
SDL_Log(" down");
if (event.jhat.value & SDL_HAT_LEFT)
printf(" left");
printf("\n");
SDL_Log(" left");
SDL_Log("\n");
break;
case SDL_JOYBALLMOTION:
printf("Joystick %d ball %d delta: (%d,%d)\n",
SDL_Log("Joystick %d ball %d delta: (%d,%d)\n",
event.jball.which,
event.jball.ball, event.jball.xrel, event.jball.yrel);
break;
case SDL_JOYBUTTONDOWN:
printf("Joystick %d button %d down\n",
SDL_Log("Joystick %d button %d down\n",
event.jbutton.which, event.jbutton.button);
break;
case SDL_JOYBUTTONUP:
printf("Joystick %d button %d up\n",
SDL_Log("Joystick %d button %d up\n",
event.jbutton.which, event.jbutton.button);
break;
case SDL_KEYDOWN:
@@ -211,31 +211,34 @@ main(int argc, char *argv[])
int i;
SDL_Joystick *joystick;
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Initialize SDL (Note: video is required to start event loop) */
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
exit(1);
}
/* Print information about the joysticks */
printf("There are %d joysticks attached\n", SDL_NumJoysticks());
SDL_Log("There are %d joysticks attached\n", SDL_NumJoysticks());
for (i = 0; i < SDL_NumJoysticks(); ++i) {
name = SDL_JoystickNameForIndex(i);
printf("Joystick %d: %s\n", i, name ? name : "Unknown Joystick");
SDL_Log("Joystick %d: %s\n", i, name ? name : "Unknown Joystick");
joystick = SDL_JoystickOpen(i);
if (joystick == NULL) {
fprintf(stderr, "SDL_JoystickOpen(%d) failed: %s\n", i,
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_JoystickOpen(%d) failed: %s\n", i,
SDL_GetError());
} else {
char guid[64];
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick),
guid, sizeof (guid));
printf(" axes: %d\n", SDL_JoystickNumAxes(joystick));
printf(" balls: %d\n", SDL_JoystickNumBalls(joystick));
printf(" hats: %d\n", SDL_JoystickNumHats(joystick));
printf(" buttons: %d\n", SDL_JoystickNumButtons(joystick));
printf("instance id: %d\n", SDL_JoystickInstanceID(joystick));
printf(" guid: %s\n", guid);
SDL_Log(" axes: %d\n", SDL_JoystickNumAxes(joystick));
SDL_Log(" balls: %d\n", SDL_JoystickNumBalls(joystick));
SDL_Log(" hats: %d\n", SDL_JoystickNumHats(joystick));
SDL_Log(" buttons: %d\n", SDL_JoystickNumButtons(joystick));
SDL_Log("instance id: %d\n", SDL_JoystickInstanceID(joystick));
SDL_Log(" guid: %s\n", guid);
SDL_JoystickClose(joystick);
}
}
@@ -256,7 +259,7 @@ main(int argc, char *argv[])
while ( keepGoing ) {
if (joystick == NULL) {
if ( !reportederror ) {
printf("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError());
SDL_Log("Couldn't open joystick %d: %s\n", atoi(argv[1]), SDL_GetError());
keepGoing = SDL_FALSE;
reportederror = SDL_TRUE;
}
@@ -268,7 +271,7 @@ main(int argc, char *argv[])
joystick = NULL;
if (keepGoing) {
printf("Waiting for attach\n");
SDL_Log("Waiting for attach\n");
}
while (keepGoing) {
SDL_WaitEvent(&event);
@@ -296,7 +299,7 @@ main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
fprintf(stderr, "SDL compiled without Joystick support.\n");
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick support.\n");
exit(1);
}