static void NoJoystick(void) { TXT_MessageBox(NULL, "No joysticks or gamepads could be found.\n\n" "Try configuring your controller from within\n" "your OS first. Maybe you need to install\n" "some drivers or otherwise configure it."); joystick_index = -1; SetJoystickButtonLabel(); }
void ConfigJoystick(void) { txt_window_t *window; txt_table_t *button_table, *axis_table; txt_table_t *joystick_table; window = TXT_NewWindow("Gamepad/Joystick configuration"); TXT_AddWidgets(window, TXT_NewCheckBox("Enable gamepad/joystick", &usejoystick), joystick_table = TXT_NewTable(2), TXT_NewSeparator("Axes"), axis_table = TXT_NewTable(2), TXT_NewSeparator("Buttons"), button_table = TXT_NewTable(4), NULL); TXT_SetColumnWidths(axis_table, 20, 15); TXT_AddWidgets(axis_table, TXT_NewLabel("Forward/backward"), y_axis_widget = TXT_NewJoystickAxis(&joystick_y_axis, &joystick_y_invert, JOYSTICK_AXIS_VERTICAL), TXT_NewLabel("Turn left/right"), x_axis_widget = TXT_NewJoystickAxis(&joystick_x_axis, &joystick_x_invert, JOYSTICK_AXIS_HORIZONTAL), TXT_NewLabel("Strafe left/right"), TXT_NewJoystickAxis(&joystick_strafe_axis, &joystick_strafe_invert, JOYSTICK_AXIS_HORIZONTAL), NULL); TXT_SetColumnWidths(joystick_table, 20, 15); TXT_AddWidgets(joystick_table, TXT_NewLabel("Current controller"), joystick_button = TXT_NewButton("zzzz"), NULL); TXT_SetColumnWidths(button_table, 16, 12, 14, 11); AddJoystickControl(button_table, "Fire/Attack", &joybfire); AddJoystickControl(button_table, "Strafe Left", &joybstrafeleft); AddJoystickControl(button_table, "Use", &joybuse); AddJoystickControl(button_table, "Strafe Right", &joybstraferight); AddJoystickControl(button_table, "Previous weapon", &joybprevweapon); AddJoystickControl(button_table, "Strafe", &joybstrafe); AddJoystickControl(button_table, "Next weapon", &joybnextweapon); // High values of joybspeed are used to activate the "always run mode" // trick in Vanilla Doom. If this has been enabled, not only is the // joybspeed value meaningless, but the control itself is useless. if (joybspeed < 20) { AddJoystickControl(button_table, "Speed", &joybspeed); } if (gamemission == hexen || gamemission == strife) { AddJoystickControl(button_table, "Jump", &joybjump); } AddJoystickControl(button_table, "Activate menu", &joybmenu); TXT_SignalConnect(joystick_button, "pressed", CalibrateJoystick, NULL); TXT_SetWindowAction(window, TXT_HORIZ_CENTER, TestConfigAction()); SetJoystickButtonLabel(); }
static void CalibrateWindowClosed(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) { CloseAllJoysticks(); TXT_SDL_SetEventCallback(NULL, NULL); SetJoystickButtonLabel(); }
void ConfigJoystick(void) { txt_window_t *window; txt_table_t *button_table; txt_table_t *joystick_table; if (!joystick_initted) { joystick_initted = SDL_Init(SDL_INIT_JOYSTICK) >= 0; } window = TXT_NewWindow("Gamepad/Joystick configuration"); TXT_AddWidgets(window, TXT_NewCheckBox("Enable gamepad/joystick", &usejoystick), joystick_table = TXT_NewTable(2), TXT_NewSeparator("Buttons"), button_table = TXT_NewTable(2), NULL); TXT_SetColumnWidths(joystick_table, 20, 15); TXT_AddWidgets(joystick_table, TXT_NewLabel("Current controller"), joystick_button = TXT_NewButton("zzzz"), NULL); TXT_SetColumnWidths(button_table, 20, 15); AddJoystickControl(button_table, "Fire/Attack", &joybfire); AddJoystickControl(button_table, "Use", &joybuse); // High values of joybspeed are used to activate the "always run mode" // trick in Vanilla Doom. If this has been enabled, not only is the // joybspeed value meaningless, but the control itself is useless. if (joybspeed < 20) { AddJoystickControl(button_table, "Speed", &joybspeed); } AddJoystickControl(button_table, "Strafe", &joybstrafe); AddJoystickControl(button_table, "Strafe Left", &joybstrafeleft); AddJoystickControl(button_table, "Strafe Right", &joybstraferight); AddJoystickControl(button_table, "Previous weapon", &joybprevweapon); AddJoystickControl(button_table, "Next weapon", &joybnextweapon); if (gamemission == hexen || gamemission == strife) { AddJoystickControl(button_table, "Jump", &joybjump); } AddJoystickControl(button_table, "Activate menu", &joybmenu); TXT_SignalConnect(joystick_button, "pressed", CalibrateJoystick, NULL); TXT_SignalConnect(window, "closed", JoystickWindowClosed, NULL); TXT_SetWindowAction(window, TXT_HORIZ_CENTER, TestConfigAction()); SetJoystickButtonLabel(); }