示例#1
0
static UI_MENU_CALLBACK(JoyPort5Device_dynmenu_callback)
{
    joyport_desc_t *devices = joyport_get_valid_devices(JOYPORT_5);
    int i;

    /* rebuild menu if it already exists. */
    if (joyport5_dyn_menu_init != 0) {
        sdl_menu_joyport5_free();
    } else {
        joyport5_dyn_menu_init = 1;
    }

    for (i = 0; devices[i].name; ++i) {
        joyport5_dyn_menu[i].string = (char *)lib_stralloc(devices[i].name);
        joyport5_dyn_menu[i].type = MENU_ENTRY_RESOURCE_RADIO;
        joyport5_dyn_menu[i].callback = radio_JoyPort5Device_callback;
        joyport5_dyn_menu[i].data = (ui_callback_data_t)int_to_void_ptr(devices[i].id);
    }

    joyport5_dyn_menu[i].string = NULL;
    joyport5_dyn_menu[i].type = 0;
    joyport5_dyn_menu[i].callback = NULL;
    joyport5_dyn_menu[i].data = NULL;

    lib_free(devices);

    return MENU_SUBMENU_STRING;
}
示例#2
0
static char *build_joyport_string(int port)
{
    int i = 0;
    char *tmp1;
    char *tmp2;
    char number[4];
    joyport_desc_t *devices = joyport_get_valid_devices(port);

    tmp1 = lib_msprintf(translate_text(IDGS_SET_JOYPORT_S_DEVICE), translate_text(port_props[port].trans_name));

    for (i = 1; devices[i].name; ++i) {
        sprintf(number, "%d", devices[i].id);
        tmp2 = util_concat(tmp1, ", ", number, ": ", translate_text(devices[i].trans_name), NULL);
        lib_free(tmp1);
        tmp1 = tmp2;
    }
    tmp2 = util_concat(tmp1, ")", NULL);
    lib_free(tmp1);
    lib_free(devices);
    return tmp2;
}
示例#3
0
void ui_joyport_settings_dialog(int port1, int port2, int port3, int port4, int port5)
{
    APTR window;
    int i;
    int j = 0;
    joyport_desc_t *devices_port_1;
    joyport_desc_t *devices_port_2;
    joyport_desc_t *devices_port_3;
    joyport_desc_t *devices_port_4;
    joyport_desc_t *devices_port_5;

    ports[JOYPORT_1] = port1;
    ports[JOYPORT_2] = port2;
    ports[JOYPORT_3] = port3;
    ports[JOYPORT_4] = port4;
    ports[JOYPORT_5] = port5;

    if (ports[JOYPORT_1]) {
        devices_port_1 = joyport_get_valid_devices(JOYPORT_1);
        for (i = 0; devices_port_1[i].name; ++i) {
            ui_joyport_1[i] = translate_text(devices_port_1[i].trans_name);
            ui_joyport_1_values[i] = devices_port_1[i].id;
        }
        ui_joyport_1[i] = NULL;
        ui_joyport_1_values[i] = -1;
        lib_free(devices_port_1);
        ui_to_from[j].object = NULL;
        ui_to_from[j].type = MUI_TYPE_CYCLE;
        ui_to_from[j].resource = "JoyPort1Device";
        ui_to_from[j].strings = ui_joyport_1;
        ui_to_from[j].values = ui_joyport_1_values;
        ui_to_from[j].string_choices = NULL;
        ++j;
    }

    if (ports[JOYPORT_2]) {
        devices_port_2 = joyport_get_valid_devices(JOYPORT_2);
        for (i = 0; devices_port_2[i].name; ++i) {
            ui_joyport_2[i] = translate_text(devices_port_2[i].trans_name);
            ui_joyport_2_values[i] = devices_port_2[i].id;
        }
        ui_joyport_2[i] = NULL;
        ui_joyport_2_values[i] = -1;
        lib_free(devices_port_2);
        ui_to_from[j].object = NULL;
        ui_to_from[j].type = MUI_TYPE_CYCLE;
        ui_to_from[j].resource = "JoyPort2Device";
        ui_to_from[j].strings = ui_joyport_2;
        ui_to_from[j].values = ui_joyport_2_values;
        ui_to_from[j].string_choices = NULL;
        ++j;
    }

    if (ports[JOYPORT_3]) {
        devices_port_3 = joyport_get_valid_devices(JOYPORT_3);
        for (i = 0; devices_port_3[i].name; ++i) {
            ui_joyport_3[i] = translate_text(devices_port_3[i].trans_name);
            ui_joyport_3_values[i] = devices_port_3[i].id;
        }
        ui_joyport_3[i] = NULL;
        ui_joyport_3_values[i] = -1;
        lib_free(devices_port_3);
        ui_to_from[j].object = NULL;
        ui_to_from[j].type = MUI_TYPE_CYCLE;
        ui_to_from[j].resource = "JoyPort3Device";
        ui_to_from[j].strings = ui_joyport_3;
        ui_to_from[j].values = ui_joyport_3_values;
        ui_to_from[j].string_choices = NULL;
        ++j;
    }

    if (ports[JOYPORT_4]) {
        devices_port_4 = joyport_get_valid_devices(JOYPORT_4);
        for (i = 0; devices_port_4[i].name; ++i) {
            ui_joyport_4[i] = translate_text(devices_port_4[i].trans_name);
            ui_joyport_4_values[i] = devices_port_4[i].id;
        }
        ui_joyport_4[i] = NULL;
        ui_joyport_4_values[i] = -1;
        lib_free(devices_port_4);
        ui_to_from[j].object = NULL;
        ui_to_from[j].type = MUI_TYPE_CYCLE;
        ui_to_from[j].resource = "JoyPort4Device";
        ui_to_from[j].strings = ui_joyport_4;
        ui_to_from[j].values = ui_joyport_4_values;
        ui_to_from[j].string_choices = NULL;
        ++j;
    }

    if (ports[JOYPORT_5]) {
        devices_port_5 = joyport_get_valid_devices(JOYPORT_5);
        for (i = 0; devices_port_5[i].name; ++i) {
            ui_joyport_5[i] = translate_text(devices_port_5[i].trans_name);
            ui_joyport_5_values[i] = devices_port_5[i].id;
        }
        ui_joyport_5[i] = NULL;
        ui_joyport_5_values[i] = -1;
        lib_free(devices_port_5);
        ui_to_from[j].object = NULL;
        ui_to_from[j].type = MUI_TYPE_CYCLE;
        ui_to_from[j].resource = "JoyPort5Device";
        ui_to_from[j].strings = ui_joyport_5;
        ui_to_from[j].values = ui_joyport_5_values;
        ui_to_from[j].string_choices = NULL;
        ++j;
    }

    ui_to_from[j].object = NULL;
    ui_to_from[j].type = MUI_TYPE_NONE;
    ui_to_from[j].resource = NULL;
    ui_to_from[j].strings = NULL;
    ui_to_from[j].values = NULL;
    ui_to_from[j].string_choices = NULL;

    window = mui_make_simple_window(build_gui(), translate_text(IDS_JOYPORT_SETTINGS));

    if (window != NULL) {
        mui_add_window(window);
        ui_get_to(ui_to_from);
        set(window, MUIA_Window_Open, TRUE);
        if (mui_run() == BTN_OK) {
            ui_get_from(ui_to_from);
        }
        set(window, MUIA_Window_Open, FALSE);
        mui_rem_window(window);
        MUI_DisposeObject(window);
    }
}