Example #1
0
void pi_parse_config_file(void) {
    int i = 0;

    open_config_file();

    config_options.display_smooth_stretch = get_integer_conf("Graphics", "DisplaySmoothStretch", 1);
    config_options.option_display_border = get_integer_conf("Graphics", "DisplayBorder", 0);
    config_options.display_effect = get_integer_conf("Graphics", "DisplayEffect", 0);
    config_options.maintain_aspect_ratio = get_integer_conf("Graphics", "MaintainAspectRatio", 1);
    config_options.rotate = get_integer_conf("Graphics", "RotateScreen", 1);

    close_config_file();

}
Example #2
0
void pi_initialize_input() {
    memset(joy_buttons, 0, 32 * 4);
    memset(joy_axes, 0, 8 * 4 * sizeof(int));
    memset(joy_hats, 0, 4 * sizeof(int));
    memset(pi_key, 0, NUMKEYS * 2);
    memset(pi_joy, 0, NUMKEYS * 2 * 4);

    //Open config file for reading below
    open_config_file();

    //Configure keys from config file or defaults
    pi_key[A_1] = get_integer_conf("Keyboard", "A_1", RPI_KEY_A);
    pi_key[B_1] = get_integer_conf("Keyboard", "B_1", RPI_KEY_B);
    pi_key[X_1] = get_integer_conf("Keyboard", "X_1", RPI_KEY_X);
    pi_key[Y_1] = get_integer_conf("Keyboard", "Y_1", RPI_KEY_Y);
    pi_key[L_1] = get_integer_conf("Keyboard", "L_1", RPI_KEY_L);
    pi_key[R_1] = get_integer_conf("Keyboard", "R_1", RPI_KEY_R);
    pi_key[START_1] = get_integer_conf("Keyboard", "START_1", RPI_KEY_START);
    pi_key[SELECT_1] = get_integer_conf("Keyboard", "SELECT_1", RPI_KEY_SELECT);
    pi_key[LEFT_1] = get_integer_conf("Keyboard", "LEFT_1", RPI_KEY_LEFT);
    pi_key[RIGHT_1] = get_integer_conf("Keyboard", "RIGHT_1", RPI_KEY_RIGHT);
    pi_key[UP_1] = get_integer_conf("Keyboard", "UP_1", RPI_KEY_UP);
    pi_key[DOWN_1] = get_integer_conf("Keyboard", "DOWN_1", RPI_KEY_DOWN);

    pi_key[A_2] = get_integer_conf("Keyboard", "A_2", RPI_KEY_A_2);
    pi_key[B_2] = get_integer_conf("Keyboard", "B_2", RPI_KEY_B_2);
    pi_key[X_2] = get_integer_conf("Keyboard", "X_2", RPI_KEY_X_2);
    pi_key[Y_2] = get_integer_conf("Keyboard", "Y_2", RPI_KEY_Y_2);
    pi_key[L_2] = get_integer_conf("Keyboard", "L_2", RPI_KEY_L_2);
    pi_key[R_2] = get_integer_conf("Keyboard", "R_2", RPI_KEY_R_2);
    pi_key[START_2] = get_integer_conf("Keyboard", "START_2", RPI_KEY_START_2);
    pi_key[SELECT_2] = get_integer_conf("Keyboard", "SELECT_2", RPI_KEY_SELECT_2);
    pi_key[LEFT_2] = get_integer_conf("Keyboard", "LEFT_2", RPI_KEY_LEFT_2);
    pi_key[RIGHT_2] = get_integer_conf("Keyboard", "RIGHT_2", RPI_KEY_RIGHT_2);
    pi_key[UP_2] = get_integer_conf("Keyboard", "UP_2", RPI_KEY_UP_2);
    pi_key[DOWN_2] = get_integer_conf("Keyboard", "DOWN_2", RPI_KEY_DOWN_2);


    pi_key[A_2] = get_integer_conf("Keyboard", "A_2", RPI_KEY_A_2);
    pi_key[B_2] = get_integer_conf("Keyboard", "B_2", RPI_KEY_B_2);
    pi_key[X_2] = get_integer_conf("Keyboard", "X_2", RPI_KEY_X_2);
    pi_key[Y_2] = get_integer_conf("Keyboard", "Y_2", RPI_KEY_Y_2);
    pi_key[L_2] = get_integer_conf("Keyboard", "L_2", RPI_KEY_L_2);
    pi_key[R_2] = get_integer_conf("Keyboard", "R_2", RPI_KEY_R_2);
    pi_key[START_2] = get_integer_conf("Keyboard", "START_2", RPI_KEY_START_2);
    pi_key[SELECT_2] = get_integer_conf("Keyboard", "SELECT_2", RPI_KEY_SELECT_2);
    pi_key[LEFT_2] = get_integer_conf("Keyboard", "LEFT_2", RPI_KEY_LEFT_2);
    pi_key[RIGHT_2] = get_integer_conf("Keyboard", "RIGHT_2", RPI_KEY_RIGHT_2);
    pi_key[UP_2] = get_integer_conf("Keyboard", "UP_2", RPI_KEY_UP_2);
    pi_key[DOWN_2] = get_integer_conf("Keyboard", "DOWN_2", RPI_KEY_DOWN_2);
    pi_key[QUIT] = get_integer_conf("Keyboard", "QUIT", RPI_KEY_QUIT);


    //Configure joysticks from config file or defaults
    joy_indexes[0] = get_integer_conf("Joystick", "SDLID_1", -1);
    joy_indexes[1] = get_integer_conf("Joystick", "SDLID_2", -1);
    joy_indexes[2] = get_integer_conf("Joystick", "SDLID_3", -1);
    joy_indexes[3] = get_integer_conf("Joystick", "SDLID_4", -1);

    char configName[10];
    for (int player = 0; player < 4; player++) {
        logoutput("Setting player %d input\n", player + 1);

        sprintf(configName, "A_%d", player + 1);
        pi_joy[player][J_A] = get_integer_conf("Joystick", configName, 200);
        logoutput("Setted J_A : %d\n", pi_joy[player][J_A]);

        sprintf(configName, "B_%d", player + 1);
        pi_joy[player][J_B] = get_integer_conf("Joystick", configName, RPI_JOY_B);
        sprintf(configName, "X_%d", player + 1);
        pi_joy[player][J_X] = get_integer_conf("Joystick", configName, RPI_JOY_X);
        sprintf(configName, "Y_%d", player + 1);
        pi_joy[player][J_Y] = get_integer_conf("Joystick", configName, RPI_JOY_Y);
        sprintf(configName, "L_%d", player + 1);
        pi_joy[player][J_L] = get_integer_conf("Joystick", configName, RPI_JOY_L);
        sprintf(configName, "R_%d", player + 1);
        pi_joy[player][J_R] = get_integer_conf("Joystick", configName, RPI_JOY_R);


        sprintf(configName, "UP_%d", player + 1);
        pi_joy[player][J_UP] = get_integer_conf("Joystick", configName, RPI_JOY_UP);

        sprintf(configName, "DOWN_%d", player + 1);
        pi_joy[player][J_DOWN] = get_integer_conf("Joystick", configName, RPI_JOY_DOWN);

        sprintf(configName, "LEFT_%d", player + 1);
        pi_joy[player][J_LEFT] = get_integer_conf("Joystick", configName, RPI_JOY_LEFT);

        sprintf(configName, "RIGHT_%d", player + 1);
        pi_joy[player][J_RIGHT] = get_integer_conf("Joystick", configName, RPI_JOY_RIGHT);


        sprintf(configName, "START_%d", player + 1);
        pi_joy[player][J_START] = get_integer_conf("Joystick", configName, RPI_JOY_START);

        sprintf(configName, "SELECT_%d", player + 1);
        pi_joy[player][J_SELECT] = get_integer_conf("Joystick", configName, RPI_JOY_SELECT);

        sprintf(configName, "JA_LR_%d", player + 1);
        pi_joy[player][J_AXIS_LR] = get_integer_conf("Joystick", configName, RPI_JOY_AXIS_LR);
        sprintf(configName, "JA_UD_%d", player + 1);
        pi_joy[player][J_AXIS_UD] = get_integer_conf("Joystick", configName, RPI_JOY_AXIS_UD);

    }

    pi_specials[HOTKEY] = get_integer_conf("Joystick", "HOTKEY", RPI_JOY_HOTKEY);

    pi_specials[QUIT] = get_integer_conf("Joystick", "QUIT", RPI_JOY_QUIT);
    pi_specials[ACCEL] = get_integer_conf("Joystick", "ACCEL", RPI_JOY_ACCEL);

    pi_specials[QLOAD] = get_integer_conf("Joystick", "QLOAD", RPI_JOY_QLOAD);
    pi_specials[QSAVE] = get_integer_conf("Joystick", "QSAVE", RPI_JOY_QSAVE);

//	Read joystick axis to use, default to 0 & 1 (keep it for hats...)
//	joyaxis_LR_1 = get_integer_conf("Joystick", "JA_LR_1", 0);
//	joyaxis_UD_1 = get_integer_conf("Joystick", "JA_UD_1", 1);
//
//	joyaxis_LR_2 = get_integer_conf("Joystick", "JA_LR_2", 0);
//	joyaxis_UD_2 = get_integer_conf("Joystick", "JA_UD_2", 1);
//        
//	joyaxis_LR_3 = get_integer_conf("Joystick", "JA_LR_3", 0);
//	joyaxis_UD_3 = get_integer_conf("Joystick", "JA_UD_3", 1);
//        
//	joyaxis_LR_4 = get_integer_conf("Joystick", "JA_LR_4", 0);
//	joyaxis_UD_4 = get_integer_conf("Joystick", "JA_UD_4", 1);

    close_config_file();

}
Example #3
0
void pi_initialize_input()
{
    memset(joy_buttons, 0, 32*2);
    memset(joy_axes, 0, 4*2);
    memset(pi_key, 0, NUMKEYS*2);
    memset(pi_joy, 0, NUMKEYS*2);

    //Open config file for reading below
    open_config_file();

    //Configure keys from config file or defaults
    pi_key[A_1] = get_integer_conf("Keyboard", "A_1", RPI_KEY_A);
    pi_key[B_1] = get_integer_conf("Keyboard", "B_1", RPI_KEY_B);
    pi_key[X_1] = get_integer_conf("Keyboard", "X_1", RPI_KEY_X);
    pi_key[Y_1] = get_integer_conf("Keyboard", "Y_1", RPI_KEY_Y);
    pi_key[L_1] = get_integer_conf("Keyboard", "L_1", RPI_KEY_L);
    pi_key[R_1] = get_integer_conf("Keyboard", "R_1", RPI_KEY_R);
    pi_key[START_1] = get_integer_conf("Keyboard", "START_1", RPI_KEY_START);
    pi_key[SELECT_1] = get_integer_conf("Keyboard", "SELECT_1", RPI_KEY_SELECT);
    pi_key[LEFT_1] = get_integer_conf("Keyboard", "LEFT_1", RPI_KEY_LEFT);
    pi_key[RIGHT_1] = get_integer_conf("Keyboard", "RIGHT_1", RPI_KEY_RIGHT);
    pi_key[UP_1] = get_integer_conf("Keyboard", "UP_1", RPI_KEY_UP);
    pi_key[DOWN_1] = get_integer_conf("Keyboard", "DOWN_1", RPI_KEY_DOWN);

    pi_key[A_2] = get_integer_conf("Keyboard", "A_2", RPI_KEY_A_2);
    pi_key[B_2] = get_integer_conf("Keyboard", "B_2", RPI_KEY_B_2);
    pi_key[X_2] = get_integer_conf("Keyboard", "X_2", RPI_KEY_X_2);
    pi_key[Y_2] = get_integer_conf("Keyboard", "Y_2", RPI_KEY_Y_2);
    pi_key[L_2] = get_integer_conf("Keyboard", "L_2", RPI_KEY_L_2);
    pi_key[R_2] = get_integer_conf("Keyboard", "R_2", RPI_KEY_R_2);
    pi_key[START_2] = get_integer_conf("Keyboard", "START_2", RPI_KEY_START_2);
    pi_key[SELECT_2] = get_integer_conf("Keyboard", "SELECT_2", RPI_KEY_SELECT_2);
    pi_key[LEFT_2] = get_integer_conf("Keyboard", "LEFT_2", RPI_KEY_LEFT_2);
    pi_key[RIGHT_2] = get_integer_conf("Keyboard", "RIGHT_2", RPI_KEY_RIGHT_2);
    pi_key[UP_2] = get_integer_conf("Keyboard", "UP_2", RPI_KEY_UP_2);
    pi_key[DOWN_2] = get_integer_conf("Keyboard", "DOWN_2", RPI_KEY_DOWN_2);

    pi_key[QUIT] = get_integer_conf("Keyboard", "QUIT", RPI_KEY_QUIT);

    //Configure joysticks from config file or defaults
    pi_joy[A_1] = get_integer_conf("Joystick", "A_1", RPI_JOY_A);
    pi_joy[B_1] = get_integer_conf("Joystick", "B_1", RPI_JOY_B);
    pi_joy[X_1] = get_integer_conf("Joystick", "X_1", RPI_JOY_X);
    pi_joy[Y_1] = get_integer_conf("Joystick", "Y_1", RPI_JOY_Y);
    pi_joy[L_1] = get_integer_conf("Joystick", "L_1", RPI_JOY_L);
    pi_joy[R_1] = get_integer_conf("Joystick", "R_1", RPI_JOY_R);

    pi_joy[UP_1] = get_integer_conf("Joystick", "UP_1", RPI_JOY_UP);
    pi_joy[DOWN_1] = get_integer_conf("Joystick", "DOWN_1", RPI_JOY_DOWN);
    pi_joy[LEFT_1] = get_integer_conf("Joystick", "LEFT_1", RPI_JOY_LEFT);
    pi_joy[RIGHT_1] = get_integer_conf("Joystick", "RIGHT_1", RPI_JOY_RIGHT);

    pi_joy[START_1] = get_integer_conf("Joystick", "START_1", RPI_JOY_START);
    pi_joy[SELECT_1] = get_integer_conf("Joystick", "SELECT_1", RPI_JOY_SELECT);

    pi_joy[A_2] = get_integer_conf("Joystick", "A_2", RPI_JOY_A);
    pi_joy[B_2] = get_integer_conf("Joystick", "B_2", RPI_JOY_B);
    pi_joy[X_2] = get_integer_conf("Joystick", "X_2", RPI_JOY_X);
    pi_joy[Y_2] = get_integer_conf("Joystick", "Y_2", RPI_JOY_Y);
    pi_joy[L_2] = get_integer_conf("Joystick", "L_2", RPI_JOY_L);
    pi_joy[R_2] = get_integer_conf("Joystick", "R_2", RPI_JOY_R);

    pi_joy[UP_2] = get_integer_conf("Joystick", "UP_2", RPI_JOY_UP);
    pi_joy[DOWN_2] = get_integer_conf("Joystick", "DOWN_2", RPI_JOY_DOWN);
    pi_joy[LEFT_2] = get_integer_conf("Joystick", "LEFT_2", RPI_JOY_LEFT);
    pi_joy[RIGHT_2] = get_integer_conf("Joystick", "RIGHT_2", RPI_JOY_RIGHT);

    pi_joy[START_2] = get_integer_conf("Joystick", "START_2", RPI_JOY_START);
    pi_joy[SELECT_2] = get_integer_conf("Joystick", "SELECT_2", RPI_JOY_SELECT);

    pi_joy[A_3] = get_integer_conf("Joystick", "A_3", RPI_JOY_A);
    pi_joy[B_3] = get_integer_conf("Joystick", "B_3", RPI_JOY_B);
    pi_joy[X_3] = get_integer_conf("Joystick", "X_3", RPI_JOY_X);
    pi_joy[Y_3] = get_integer_conf("Joystick", "Y_3", RPI_JOY_Y);
    pi_joy[L_3] = get_integer_conf("Joystick", "L_3", RPI_JOY_L);
    pi_joy[R_3] = get_integer_conf("Joystick", "R_3", RPI_JOY_R);

    pi_joy[UP_3] = get_integer_conf("Joystick", "UP_3", RPI_JOY_UP);
    pi_joy[DOWN_3] = get_integer_conf("Joystick", "DOWN_3", RPI_JOY_DOWN);
    pi_joy[LEFT_3] = get_integer_conf("Joystick", "LEFT_3", RPI_JOY_LEFT);
    pi_joy[RIGHT_3] = get_integer_conf("Joystick", "RIGHT_3", RPI_JOY_RIGHT);

    pi_joy[START_3] = get_integer_conf("Joystick", "START_3", RPI_JOY_START);
    pi_joy[SELECT_3] = get_integer_conf("Joystick", "SELECT_3", RPI_JOY_SELECT);

    pi_joy[A_4] = get_integer_conf("Joystick", "A_4", RPI_JOY_A);
    pi_joy[B_4] = get_integer_conf("Joystick", "B_4", RPI_JOY_B);
    pi_joy[X_4] = get_integer_conf("Joystick", "X_4", RPI_JOY_X);
    pi_joy[Y_4] = get_integer_conf("Joystick", "Y_4", RPI_JOY_Y);
    pi_joy[L_4] = get_integer_conf("Joystick", "L_4", RPI_JOY_L);
    pi_joy[R_4] = get_integer_conf("Joystick", "R_4", RPI_JOY_R);

    pi_joy[UP_4] = get_integer_conf("Joystick", "UP_4", RPI_JOY_UP);
    pi_joy[DOWN_4] = get_integer_conf("Joystick", "DOWN_4", RPI_JOY_DOWN);
    pi_joy[LEFT_4] = get_integer_conf("Joystick", "LEFT_4", RPI_JOY_LEFT);
    pi_joy[RIGHT_4] = get_integer_conf("Joystick", "RIGHT_4", RPI_JOY_RIGHT);

    pi_joy[START_4] = get_integer_conf("Joystick", "START_4", RPI_JOY_START);
    pi_joy[SELECT_4] = get_integer_conf("Joystick", "SELECT_4", RPI_JOY_SELECT);

    pi_joy[QUIT] = get_integer_conf("Joystick", "QUIT", RPI_JOY_QUIT);
    pi_joy[ACCEL] = get_integer_conf("Joystick", "ACCEL", RPI_JOY_ACCEL);

    pi_joy[QLOAD] = get_integer_conf("Joystick", "QLOAD", RPI_JOY_QLOAD);
    pi_joy[QSAVE] = get_integer_conf("Joystick", "QSAVE", RPI_JOY_QSAVE);

    //Read joystick axis to use, default to 0 & 1
    joyaxis_LR[0] = get_integer_conf("Joystick", "JA_LR_1", 0);
    joyaxis_UD[0] = get_integer_conf("Joystick", "JA_UD_1", 1);
    joyaxis_LR[1] = get_integer_conf("Joystick", "JA_LR_2", 0);
    joyaxis_UD[1] = get_integer_conf("Joystick", "JA_UD_2", 1);
    joyaxis_LR[2] = get_integer_conf("Joystick", "JA_LR_3", 0);
    joyaxis_UD[2] = get_integer_conf("Joystick", "JA_UD_3", 1);
    joyaxis_LR[3] = get_integer_conf("Joystick", "JA_LR_4", 0);
    joyaxis_UD[3] = get_integer_conf("Joystick", "JA_UD_4", 1);

    close_config_file();

}