test/testaudioinfo.c
author Jørgen P. Tjernø <jorgen@valvesoftware.com>
Wed, 05 Jun 2013 12:48:44 -0700
changeset 7277 1290cd7f34af
parent 7034 3a5a53435ebd
child 7434 ef8810ae03ec
permissions -rw-r--r--
Mac: Fix invalid PS3 controller mapping.

PS3 controller had swapped D-Pad down & left buttons, as well as X & Y buttons.
Thanks to Alex Szpakowski for the bug report and fix.

Fixes http://bugzilla.libsdl.org/show_bug.cgi?id=1891
slouken@5535
     1
/*
slouken@5535
     2
  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
slouken@5535
     3
slouken@5535
     4
  This software is provided 'as-is', without any express or implied
slouken@5535
     5
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     6
  arising from the use of this software.
slouken@5535
     7
slouken@5535
     8
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
     9
  including commercial applications, and to alter it and redistribute it
slouken@5535
    10
  freely.
slouken@5535
    11
*/
slouken@3338
    12
#include <stdio.h>
icculus@2049
    13
#include "SDL.h"
icculus@2049
    14
slouken@2060
    15
static void
slouken@2060
    16
print_devices(int iscapture)
icculus@2049
    17
{
icculus@2049
    18
    const char *typestr = ((iscapture) ? "capture" : "output");
icculus@2049
    19
    int n = SDL_GetNumAudioDevices(iscapture);
icculus@2049
    20
icculus@2049
    21
    printf("%s devices:\n", typestr);
icculus@2049
    22
icculus@2049
    23
    if (n == -1)
icculus@2049
    24
        printf("  Driver can't detect specific devices.\n\n", typestr);
icculus@2049
    25
    else if (n == 0)
icculus@2049
    26
        printf("  No %s devices found.\n\n", typestr);
slouken@2060
    27
    else {
icculus@2049
    28
        int i;
icculus@2049
    29
        for (i = 0; i < n; i++) {
icculus@2049
    30
            printf("  %s\n", SDL_GetAudioDeviceName(i, iscapture));
icculus@2049
    31
        }
icculus@2049
    32
        printf("\n");
icculus@2049
    33
    }
icculus@2049
    34
}
icculus@2049
    35
slouken@2060
    36
int
slouken@2060
    37
main(int argc, char **argv)
icculus@2049
    38
{
icculus@7034
    39
    int n;
icculus@7034
    40
icculus@3635
    41
    /* Load the SDL library */
icculus@3635
    42
    if (SDL_Init(SDL_INIT_AUDIO) < 0) {
icculus@3635
    43
        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
icculus@3635
    44
        return (1);
icculus@3635
    45
    }
icculus@3635
    46
icculus@2049
    47
    /* Print available audio drivers */
icculus@7034
    48
    n = SDL_GetNumAudioDrivers();
icculus@2049
    49
    if (n == 0) {
icculus@2049
    50
        printf("No built-in audio drivers\n\n");
icculus@2049
    51
    } else {
icculus@2049
    52
        int i;
icculus@2049
    53
        printf("Built-in audio drivers:\n");
icculus@2049
    54
        for (i = 0; i < n; ++i) {
icculus@2049
    55
            printf("  %s\n", SDL_GetAudioDriver(i));
icculus@2049
    56
        }
icculus@2049
    57
        printf("\n");
icculus@2049
    58
    }
icculus@2049
    59
icculus@2049
    60
    printf("Using audio driver: %s\n\n", SDL_GetCurrentAudioDriver());
icculus@2049
    61
icculus@2049
    62
    print_devices(0);
icculus@2049
    63
    print_devices(1);
icculus@2049
    64
icculus@2049
    65
    SDL_Quit();
icculus@2049
    66
    return 0;
icculus@2049
    67
}