[AD] set_config_file() and joysticks

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Hi,

The program code quoted below is a stripped-down version of the start-up code 
of my upcoming game. I need to call install_joystick() after set_gfx_mode() 
in order to display the goofy message. I need to call set_gfx_mode() after 
set_config_file() because the resolution is stored in my config file.

This code works fine with Allegro 4.0.0, on both DOS and Windows. The first 
time it is run, it displays the goofy message, detects the joystick and (on 
DOS) goes through the calibration steps later on. On subsequent executions it 
uses the saved joystick data perfectly; no goofy message. (This relies on 
save_joystick_data() being called of course; I left that out for a good 
reason.)

My testers have reported this procedure failing. I've confirmed that for one 
person it fails to detect the joystick with Allegro 4.1.8 but works with 
Allegro 4.0.0. With Allegro 4.1.8, this person was able to make the procedure 
work by creating the config file in advance and setting 'joytype'. Who can 
reproduce this bug?

Commenting out the call to set_config_file() alleviates this problem, from 
what I gather. (I left out the save_joystick_data() so you could run the test 
repeatedly like this without problems.) Can anyone confirm this?

Commenting out the call to load_joystick_data() (and replacing it with 1) 
does not alleviate the bug, to the best of my knowledge. Again, may as well 
try this and check it's the case.

If you're wondering why I seem slightly unsure about certain things, it's 
because my joystick doesn't work on Linux (where I am now), and I only 
earlier today got it to work on Windows. So I haven't been able to do too 
many tests of my own yet.

Anyhow, does anyone remember any recent changes that might be responsible for 
this problem? Any chance of a bugfix?

Thanks

Ben

---

#include <allegro.h>

static void display_goofy_message_saying_to_centre_the_joysticks(void)
{
    textout_centre(screen, font, "Centre the joysticks and press a key! :B",
        320, 236, 14);
    readkey();
}

static int joystick_installed;

int main(void)
{
    set_uformat(U_ASCII);
    allegro_init();

    set_config_file("anything.ini");
    install_timer();
    install_keyboard();
    install_mouse();

    set_config_int("sound", "quality", 2);

    reserve_voices(64, -1);
    set_volume_per_voice(1);
    install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL);

    set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);

    if (load_joystick_data(NULL)) {
        display_goofy_message_saying_to_centre_the_joysticks();
        if (install_joystick(JOY_TYPE_AUTODETECT))
            joystick_installed = 0;
        else
            joystick_installed = num_joysticks > 0;
    } else
        joystick_installed = num_joysticks > 0;

    /* Right, that's as far as we're going; now display the outcome */

    set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);

    if (joystick_installed)
        allegro_message("Joystick initialised successfully.");
    else
        allegro_message("Joystick could not be initialised!");

    return 0;
}
END_OF_MAIN();




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/