void VControl_RemoveJoyButtonBinding (int port, int button, int *target) { #ifdef HAVE_JOYSTICK if (port >= 0 && port < joycount) { joystick *j = &joysticks[port]; if (!(j->stick)) create_joystick (port); if ((button >= 0) && (button < j->numbuttons)) { remove_binding (&joysticks[port].buttons[button], target); } else { log_add (log_Debug, "VControl: Attempted to unbind from illegal button %d", button); } } else #else (void) port; (void) button; (void) target; #endif /* HAVE_JOYSTICK */ { log_add (log_Debug, "VControl: Attempted to unbind from illegal port %d", port); } }
int VControl_AddJoyButtonBinding (int port, int button, int *target) { #ifdef HAVE_JOYSTICK if (port >= 0 && (unsigned int) port < joycount) { joystick *j = &joysticks[port]; if (!(j->stick)) create_joystick (port); if ((button >= 0) && (button < j->numbuttons)) { add_binding(&joysticks[port].buttons[button], target); return 0; } else { // log_add (log_Debug, "VControl: Attempted to bind to illegal button %d", button); return -1; } } else #else (void) port; (void) button; (void) target; #endif /* HAVE_JOYSTICK */ { // log_add (log_Debug, "VControl: Attempted to bind to illegal port %d", port); return -1; } }
int VControl_AddJoyHatBinding (int port, int which, Uint8 dir, int *target) { #ifdef HAVE_JOYSTICK if (port >= 0 && port < joycount) { joystick *j = &joysticks[port]; if (!(j->stick)) create_joystick (port); if ((which >= 0) && (which < j->numhats)) { if (dir == SDL_HAT_LEFT) { add_binding(&joysticks[port].hats[which].left, target); } else if (dir == SDL_HAT_RIGHT) { add_binding(&joysticks[port].hats[which].right, target); } else if (dir == SDL_HAT_UP) { add_binding(&joysticks[port].hats[which].up, target); } else if (dir == SDL_HAT_DOWN) { add_binding(&joysticks[port].hats[which].down, target); } else { // log_add (log_Debug, "VControl: Attempted to bind to illegal direction"); return -1; } return 0; } else { // log_add (log_Debug, "VControl: Attempted to bind to illegal hat %d", which); return -1; } } else #else (void) port; (void) which; (void) dir; (void) target; #endif /* HAVE_JOYSTICK */ { // log_add (log_Debug, "VControl: Attempted to bind to illegal port %d", port); return -1; } }
int VControl_AddJoyAxisBinding (int port, int axis, int polarity, int *target) { #ifdef HAVE_JOYSTICK if (port >= 0 && port < joycount) { joystick *j = &joysticks[port]; if (!(j->stick)) create_joystick (port); if ((axis >= 0) && (axis < j->numaxes)) { if (polarity < 0) { add_binding(&joysticks[port].axes[axis].neg, target); } else if (polarity > 0) { add_binding(&joysticks[port].axes[axis].pos, target); } else { log_add (log_Debug, "VControl: Attempted to bind to polarity zero"); return -1; } } else { // log_add (log_Debug, "VControl: Attempted to bind to illegal axis %d", axis); return -1; } } else #else (void) port; (void) axis; (void) polarity; (void) target; #endif /* HAVE_JOYSTICK */ { // log_add (log_Debug, "VControl: Attempted to bind to illegal port %d", port); return -1; } return 0; }
void VControl_RemoveJoyAxisBinding (int port, int axis, int polarity, int *target) { #ifdef HAVE_JOYSTICK if (port >= 0 && (unsigned int) port < joycount) { joystick *j = &joysticks[port]; if (!(j->stick)) create_joystick (port); if ((axis >= 0) && (axis < j->numaxes)) { if (polarity < 0) { remove_binding(&joysticks[port].axes[axis].neg, target); } else if (polarity > 0) { remove_binding(&joysticks[port].axes[axis].pos, target); } else { log_add (log_Debug, "VControl: Attempted to unbind from polarity zero"); } } else { log_add (log_Debug, "VControl: Attempted to unbind from illegal axis %d", axis); } } else #else (void) port; (void) axis; (void) polarity; (void) target; #endif /* HAVE_JOYSTICK */ { log_add (log_Debug, "VControl: Attempted to unbind from illegal port %d", port); } }
int main(int argc, char *argv[]) { CustomData data[NUM_PLAYERS]; GtkWidget *main_window; GtkWidget *main_grid; GIOChannel *io_joystick; GError *error = NULL; gboolean fullscreen = FALSE; int autoconnect = 0; GOptionEntry option_entries[] = { { "fullscreen", 'f', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &fullscreen, "Fullscreen", NULL }, { "autoconnect", 'a', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &autoconnect, "Autoconnect to jackd", NULL }, { "green", 'g', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &green, "Background colour until 50\% elapsed", "#00ff00" }, { "yellow", 'y', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &yellow, "Background colour until 75\% elapsed", "#ffff00" }, { "red", 'r', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING, &red, "Background colour until 100\% elapsed", "#ff0000" }, { NULL, ' ', 0, 0, NULL, NULL, NULL } }; /* Initialize GTK */ if ( gtk_init_with_args (&argc, &argv, NULL, option_entries, NULL, &error) != TRUE ) { if (error != NULL) { g_fprintf(stderr, "%s\nTry --help to see a full list of available command line options.\n", error->message); g_error_free(error); } return 1; } /* Initialize GStreamer */ gst_init (&argc, &argv); /* Initialize our data structure */ memset (&data, 0, sizeof (data)); main_window = create_mainwindow(); main_grid = gtk_grid_new(); /* Load config */ load_configfile(data); gtk_grid_set_row_spacing (GTK_GRID (main_grid), 30); gtk_grid_set_column_spacing (GTK_GRID (main_grid), 30); for (int i=0; i < NUM_PLAYERS; i++) { GtkWidget *playerUI = init_player (&data[i], i, autoconnect); data[i].mainwindow = main_window; /* two columns (i%2) in (i/2) rows */ gtk_grid_attach (GTK_GRID (main_grid), playerUI, i % 2, i / 2, 1, 1); } /* force main_grid to be homogeneous, so all player UIs remain stable * and don't resize unintentionally (e.g., when selecting a long * filename in the filechooser) */ gtk_grid_set_row_homogeneous(GTK_GRID (main_grid), TRUE); gtk_grid_set_column_homogeneous(GTK_GRID (main_grid), TRUE); gtk_container_add (GTK_CONTAINER (main_window), main_grid); if (TRUE == fullscreen) { gtk_window_fullscreen (GTK_WINDOW (main_window)); } else { gtk_window_maximize (GTK_WINDOW (main_window)); } gtk_widget_show_all (main_window); { /* ugly hack to expose the jack ports until jackaudiosink is fixed */ gchar *tmpfileuri = make_silence(); /* enable file selection signals */ for (int i=0; i < NUM_PLAYERS; i++) { g_signal_handler_unblock (data[i].filechooser, data[i].file_selection_signal_id); audio_set_uri(&data[i], tmpfileuri); audio_pause_player(&data[i]); } g_free (tmpfileuri); } create_hotkeys(main_window, data); io_joystick = create_joystick(data); /* Start the GTK main loop. We will not regain control until gtk_main_quit is called. */ gtk_main (); if (NULL != io_joystick) { g_io_channel_shutdown (io_joystick, FALSE, NULL); g_io_channel_unref (io_joystick); } save_configfile (data); /* Free resources */ for (int i=0; i < NUM_PLAYERS; i++) { gst_element_set_state (data[i].pipeline, GST_STATE_NULL); gst_object_unref (data[i].pipeline); } return 0; }