Exemplo n.º 1
0
static bool ljoy_detect_device_name(int num, ALLEGRO_USTR *device_name)
{
    char key[80];
    const char *value;
    struct stat stbuf;

    al_ustr_truncate(device_name, 0);

    snprintf(key, sizeof(key), "device%d", num);
    value = al_get_config_value(al_get_system_config(), "joystick", key);
    if (value)
        al_ustr_assign_cstr(device_name, value);

    if (al_ustr_size(device_name) == 0)
        al_ustr_appendf(device_name, "/dev/input/event%d", num);

    return (stat(al_cstr(device_name), &stbuf) == 0);
}
Exemplo n.º 2
0
/* Test al_ustr_newf, al_ustr_appendf, al_ustr_vappendf. */
static void t46(void)
{
   ALLEGRO_USTR *us;

   us = al_ustr_newf("%s %c %.2f %.02d", "hõljuk", 'c', ALLEGRO_PI, 42);
   CHECK(0 == strcmp(al_cstr(us), "hõljuk c 3.14 42"));

   CHECK(al_ustr_appendf(us, " %s", "Luftchüssiboot"));
   CHECK(0 == strcmp(al_cstr(us), "hõljuk c 3.14 42 Luftchüssiboot"));

   CHECK(call_vappendf(us, " %s", "χόβερκράφτ"));
   CHECK(0 == strcmp(al_cstr(us), "hõljuk c 3.14 42 Luftchüssiboot χόβερκράφτ"));

   al_ustr_free(us);

   us = al_ustr_new("");
   call_vappendf(us, "%s", "test");
   CHECK(0 == strcmp(al_cstr(us), "test"));
   al_ustr_free(us);
}