static gboolean joystick_handler (GIOChannel *source, GIOCondition cond, CustomData *data) { #define JS_EVENT_BUTTON 0x01 /* button pressed/released */ #define JS_EVENT_AXIS 0x02 /* joystick moved */ #define JS_EVENT_INIT 0x80 /* initial state of device */ int joyfd; struct js_event { uint32_t time; /* event timestamp in milliseconds */ int16_t value; /* value */ uint8_t type; /* event type */ uint8_t number; /* axis/button number */ } e; joyfd = g_io_channel_unix_get_fd(source); read(joyfd, &e, sizeof(struct js_event)); if ((e.type & ~JS_EVENT_INIT) == JS_EVENT_BUTTON) { if (e.number < NUM_PLAYERS) { if (e.value) { audio_play_player (&data[e.number]); } else { stop_cb (NULL, &data[e.number]); } } g_print ("joystick button %d = %d\n", e.number, e.value); } return TRUE; }
static void keyboard_handler(CustomData *data) { g_print ("Keyboard interaction, calling handler\n"); if (audio_is_playing(data)) { stop_cb (NULL, data); } else { audio_play_player (data); } }
/* This function is called when the main window is closed */ static void delete_event_cb (GtkWidget *widget, GdkEvent *event, CustomData *data) { stop_cb (NULL, data); gtk_main_quit (); }
/* * @brief callback when main window is closed * */ static void delete_event_cb (GtkWidget *widget, GdkEvent *event, CustomData *data){ stop_cb(NULL, data); /* stop playback*/ gtk_main_quit(); /* huh, what?? */ }