Optional Joystick Config Definitions?

edited June 2015 in Help request
Here's an interesting problem I need to solve. As part of having worked with the Android Accelerometer I still have the following config:
[MainInput]
JOY_X_1     = AccelX
JOY_Y_1     = AccelY
JOY_Z_1     = AccelZ

Running the same code on windows again, I don't have a joystick or accelerometer connected to the laptop, so the console log freaks out constantly giving:
[orxJoystick.c:orxJoystick_GLFW_GetAxisValue():264] Requested joystick ID <0> is not connected.

Which is fair enough. But I want to suppress this.

I did try removing the JOY_?_1 lines from the config and injecting them conditionally in with code when the game starts with:
if(orxConfig_PushSection("ExtraInputs")) {
    orxConfig_SetString("JOY_X_1", "AccelX");
    orxConfig_SetString("JOY_Y_1", "AccelY");
    orxConfig_SetString("JOY_Z_1", "AccelZ");
    orxConfig_PopSection();
}

But that doesn't work because the config has already loaded into memory.

orxConfig_ReloadHistory() does reload the config but still doesn't work.

Not sure what else to try at the moment. There is no way to have optional keys in the config. It would be great if I could set a boolean key in the config that causes a section to load or not.

Though, any way to work this out would be great.

Comments

  • edited June 2015
    You'd need to reload the inputs as well. A call to orxInput_Load(orxNULL) should do the trick.

    Instead of hardcoding the inputs like you do, you can also include config files conditionnally. For example you'd load android.ini only on android, and so on. If you do it through the init bootstrap that has been added recently, there won't be any need to call orxInput_Load(orxNULL). If you do it after the engine init phase, you'll need to refresh the inputs with the aforementioned call.
  • edited June 2015
    Thanks, Iarwain. That's perfect.
Sign In or Register to comment.