#include "global_defs.h" #include "handle_devices.h" int main(void) { system("clear"); setvbuf(stdout, NULL, _IONBF, BUFSIZ); int controller_event_fptrs[NUM_EVENTS]; uint64_t connected_controllers = 0; open_wii(controller_event_fptrs, &connected_controllers); open_ps4_bt(controller_event_fptrs, &connected_controllers); open_ps4_wired(controller_event_fptrs, &connected_controllers); open_steam(controller_event_fptrs, &connected_controllers); open_xbox_360(controller_event_fptrs, &connected_controllers); if (connected_controllers == 0) { fprintf(stderr, "No device matching the programs requirments (DualShock 4, Xbox 360, Valve Steam, or Wii Controller) was found, please double check the connection if you do not think that this is the case.\n"); return(-1); } DUMB_USER: printf("\n\nPress the number corresponding to the device above that you would like to use and then press ENTER.\n"); short choice; scanf("%d", &choice); struct input_event event1, event2, event3, event4; int ievt_size = sizeof(struct input_event); size_t start_sec; switch (choice) { case 1: //valve steam controller { close_unneeded_files(1, controller_event_fptrs, VALVE_STEAM); print_one_event(controller_event_fptrs, VALVE_STEAM, 1); break; } case 2: //xbox 360 controller { close_unneeded_files(1, controller_event_fptrs, XBOX_360); print_one_event(controller_event_fptrs, XBOX_360, 1); break; } case PS4_WIRED_TOUCH_BIT: { close_unneeded_files(1, controller_event_fptrs, PS4_WIRED_TOUCH); print_one_event(controller_event_fptrs, PS4_WIRED_TOUCH, 1); break; } case PS4_WIRED_GYRO_BIT: { close_unneeded_files(1, controller_event_fptrs, PS4_WIRED_GYRO); print_one_event(controller_event_fptrs, PS4_WIRED_GYRO, 2); break; } case PS4_WIRED_BUTTONS_BIT: { close_unneeded_files(1, controller_event_fptrs, PS4_WIRED_BUTTONS); print_one_event(controller_event_fptrs, PS4_WIRED_BUTTONS, 3); break; } case PS4_WIRED_TOUCH_AND_GYRO: { close_unneeded_files(2, controller_event_fptrs, PS4_WIRED_TOUCH, PS4_WIRED_GYRO); struct event_pairs first_event = {PS4_WIRED_TOUCH, 1}, second_event = {PS4_WIRED_GYRO, 2}; print_multiple_events(2, controller_event_fptrs, first_event, second_event); break; } case PS4_WIRED_TOUCH_AND_BUTTONS: { close_unneeded_files(2, controller_event_fptrs, PS4_WIRED_TOUCH, PS4_WIRED_BUTTONS); struct event_pairs first_event = {PS4_WIRED_TOUCH, 1}, second_event = {PS4_WIRED_BUTTONS, 3}; print_multiple_events(2, controller_event_fptrs, first_event, second_event); break; } case PS4_WIRED_GYRO_AND_BUTTONS: { close_unneeded_files(2, controller_event_fptrs, PS4_WIRED_GYRO, PS4_WIRED_BUTTONS); struct event_pairs first_event = {PS4_WIRED_GYRO, 2}, second_event = {PS4_WIRED_BUTTONS, 3}; print_multiple_events(2, controller_event_fptrs, first_event, second_event); break; } case PS4_WIRED_ALL_BITS: { close_unneeded_files(3, controller_event_fptrs, PS4_WIRED_TOUCH, PS4_WIRED_GYRO, PS4_WIRED_BUTTONS); struct event_pairs first_event = {PS4_WIRED_TOUCH, 1}, second_event = {PS4_WIRED_GYRO, 2}, third_event = {PS4_WIRED_BUTTONS, 3}; print_multiple_events(3, controller_event_fptrs, first_event, second_event, third_event); break; } case PS4_BT_TOUCH_BIT: { close_unneeded_files(1, controller_event_fptrs, PS4_BT_TOUCH ); print_one_event(controller_event_fptrs, PS4_BT_TOUCH, 1); break; } case PS4_BT_GYRO_BIT: { close_unneeded_files(1, controller_event_fptrs, PS4_BT_GYRO ); print_one_event(controller_event_fptrs, PS4_BT_GYRO, 2); break; } case PS4_BT_BUTTONS_BIT: { close_unneeded_files(1, controller_event_fptrs, PS4_BT_BUTTONS ); print_one_event(controller_event_fptrs, PS4_BT_BUTTONS, 3); break; } case PS4_BT_TOUCH_AND_GYRO: { close_unneeded_files(2, controller_event_fptrs, PS4_BT_TOUCH, PS4_BT_GYRO); struct event_pairs first_event = {PS4_BT_TOUCH, 1}, second_event = {PS4_BT_GYRO, 2}; print_multiple_events(2, controller_event_fptrs, first_event, second_event); break; } case PS4_BT_TOUCH_AND_BUTTONS: { close_unneeded_files(2, controller_event_fptrs, PS4_BT_TOUCH, PS4_BT_BUTTONS); struct event_pairs first_event = {PS4_BT_TOUCH, 1}, second_event = {PS4_BT_BUTTONS, 3}; print_multiple_events(2, controller_event_fptrs, first_event, second_event); break; } case PS4_BT_GYRO_AND_BUTTONS: { close_unneeded_files(2, controller_event_fptrs, PS4_BT_GYRO, PS4_BT_BUTTONS); struct event_pairs first_event = {PS4_BT_GYRO, 2}, second_event = {PS4_BT_BUTTONS, 3}; print_multiple_events(2, controller_event_fptrs, first_event, second_event); break; } case PS4_BT_ALL_BITS: { close_unneeded_files(3, controller_event_fptrs, PS4_BT_TOUCH, PS4_BT_GYRO, PS4_BT_BUTTONS); struct event_pairs first_event = {PS4_BT_TOUCH, 1}, second_event = {PS4_BT_GYRO, 2}, third_event = {PS4_BT_BUTTONS, 3}; print_multiple_events(3, controller_event_fptrs, first_event, second_event, third_event); break; } case NINTENDO_GYRO_BIT: { close_unneeded_files(1, controller_event_fptrs, WII_GYRO); print_one_event(controller_event_fptrs, WII_GYRO, 1); break; } case NINTENDO_IR_BIT: { close_unneeded_files(1, controller_event_fptrs, WII_IR); print_one_event(controller_event_fptrs, WII_IR, 2); break; } case NINTENDO_BUTTONS_BIT: { close_unneeded_files(1, controller_event_fptrs, WII_BUTTONS); print_one_event(controller_event_fptrs, WII_BUTTONS, 3); break; } case NINTENDO_NUNCHUK_BIT: { close_unneeded_files(1, controller_event_fptrs, WII_NUNCHUK); print_one_event(controller_event_fptrs, WII_NUNCHUK, 4); break; } case NINTENDO_GYRO_AND_IR: { close_unneeded_files(2, controller_event_fptrs, WII_GYRO, WII_IR); struct event_pairs first_event = {WII_GYRO, 1}, second_event = {WII_IR, 2}; print_multiple_events(2, controller_event_fptrs, first_event, second_event); break; } case NINTENDO_GYRO_AND_BUTTONS: { close_unneeded_files(2, controller_event_fptrs, WII_GYRO, WII_BUTTONS); struct event_pairs first_event = {WII_GYRO, 1}, second_event = {WII_BUTTONS, 3}; print_multiple_events(2, controller_event_fptrs, first_event, second_event); break; } case NINTENDO_GYRO_AND_NUNCHUK: { close_unneeded_files(2, controller_event_fptrs, WII_GYRO, WII_NUNCHUK); struct event_pairs first_event = {WII_GYRO, 1}, second_event = {WII_NUNCHUK, 4}; print_multiple_events(2, controller_event_fptrs, first_event, second_event); break; } case NINTENDO_IR_AND_BUTTONS: { close_unneeded_files(2, controller_event_fptrs, WII_IR, WII_BUTTONS); struct event_pairs first_event = {WII_IR, 2}, second_event = {WII_BUTTONS, 3}; print_multiple_events(2, controller_event_fptrs, first_event, second_event); break; } case NINTENDO_IR_AND_NUNCHUK: { close_unneeded_files(2, controller_event_fptrs, WII_IR, WII_NUNCHUK); struct event_pairs first_event = {WII_IR, 2}, second_event = {WII_NUNCHUK, 4}; print_multiple_events(2, controller_event_fptrs, first_event, second_event); break; } case NINTENDO_BUTTONS_AND_NUNCHUK: { close_unneeded_files(2, controller_event_fptrs, WII_BUTTONS, WII_NUNCHUK); struct event_pairs first_event = {WII_BUTTONS, 3}, second_event = {WII_NUNCHUK, 4}; print_multiple_events(2, controller_event_fptrs, first_event, second_event); break; } case NINTENDO_GYRO_IR_AND_BUTTONS: { close_unneeded_files(3, controller_event_fptrs, WII_GYRO, WII_IR, WII_BUTTONS); struct event_pairs first_event = {WII_GYRO, 1}, second_event = {WII_IR, 2}, third_event = {WII_BUTTONS, 3}; print_multiple_events(3, controller_event_fptrs, first_event, second_event, third_event); break; } case NINTENDO_GYRO_IR_AND_NUNCHUK: { close_unneeded_files(3, controller_event_fptrs, WII_GYRO, WII_IR, WII_NUNCHUK); struct event_pairs first_event = {WII_GYRO, 1}, second_event = {WII_IR, 2}, third_event = {WII_NUNCHUK, 4}; print_multiple_events(3, controller_event_fptrs, first_event, second_event, third_event); break; } case NINTENDO_GYRO_BUTTONS_AND_NUNCHUK: { close_unneeded_files(3, controller_event_fptrs, WII_GYRO, WII_BUTTONS, WII_NUNCHUK); struct event_pairs first_event = {WII_GYRO, 1}, second_event = {WII_BUTTONS, 3}, third_event = {WII_NUNCHUK, 4}; print_multiple_events(3, controller_event_fptrs, first_event, second_event, third_event); break; } case NINTENDO_IR_BUTTONS_AND_NUNCHUK: { close_unneeded_files(3, controller_event_fptrs, WII_IR, WII_BUTTONS, WII_NUNCHUK); struct event_pairs first_event = {WII_IR, 2}, second_event = {WII_BUTTONS, 3}, third_event = {WII_NUNCHUK, 4}; print_multiple_events(3, controller_event_fptrs, first_event, second_event, third_event); break; } case NINTENDO_ALL_BITS: { close_unneeded_files(4, controller_event_fptrs, WII_GYRO, WII_IR, WII_BUTTONS, WII_NUNCHUK); struct event_pairs first_event = {WII_GYRO, 1}, second_event = {WII_IR, 2}, third_event = {WII_BUTTONS, 3}, fourth_event = {WII_NUNCHUK, 4}; print_multiple_events(4, controller_event_fptrs, first_event, second_event, third_event, fourth_event); break; } default: { fprintf(stderr, "ERROR: You entered an invalid number!\n"); goto DUMB_USER; break; } } return 0; }