#include "allegropro.h" //Shortest possible code to start getting some form of keyboard input. void main() { allegro_pro_init(); ali_create_driver_autodetect(); ali_device_t *the_keyboard_device = ali_get_keyboard_device(); ali_virt_gamepad_t *the_keyboard_pad = ali_get_device_vgp(the_keyboard_device); //Poll for input. while(true) { ali_update_all_devices_and_controllers(); if(ali_get_vgp_button_data(the_keyboard_pad, ALI_CTRL_KEY_A)) { printf("A\n"); } if(ali_get_vgp_button_data(the_keyboard_pad, ALI_CTRL_KEY_ESC)) break; } ali_destroy_driver(); allegro_pro_exit(); } //Code for analysing the nature of a game controller. void main() { allegro_pro_init(); ali_create_driver_autodetect(); { int num_pads = ali_get_num_gamecont_devices(); for(int loop_ix = 0; loop_ix < num_pads; loop_ix++) { ali_device_t *curr_pad = ali_get_gamecont_device(curr_pad); printf("Current game controller: \"%s\"\n", ali_get_gamecont_display_name(curr_pad)); if(ali_does_gamecont_need_calibration(curr_pad)) { printf("\tThis controller needs calibration.\n"); } //Now, loop over the controls on the game pad, and describe each control. int num_ctrls = ali_get_num_ctrls(curr_pad); for(int ctrl_ix = 0; ctrl_ix < num_ctrls; ctrl_ix++) { ali_ctrl_name_t curr_ctrl = ali_get_dev_ctrl_name(curr_pad, ctrl_ix); printf("\t\tControl index #%i is a "); ali_dev_ctrl_types_t ctrl_type = ali_get_dev_ctrl_type(curr_ctrl); switch(ctrl_type) { case ALI_BUTTON_CTRL: printf("button"); break; case ALI_POINTER_AXIS_CTRL: printf("pointer-axis"); break; case ALI_STICK_AXIS_CTRL: printf("stick-axis"); break; } printf(" kind of control\n"); printf("\t\t\tIt can be described as follows: \"%s\".\n", ali_get_dev_ctrl_string_desc(curr_pad, curr_ctrl)); } } } }