1 // -----------------------------------------------------------------------
4 // -----------------------------------------------------------------------
5 // This class handles a generic controller.
6 // Simulates a 8 way gamepad with 6 buttons using keyboard,joystick,mouse
7 // By Kronoman - In loving memory of my father
8 // Copyright (c) 2003 - Released under the MIT license
12 // Modified 04-MAR-2004 to add customize control interface.
13 // This class is arcane, I have a better implementation.
15 // We will use this in this game, in future games, we will use the new implementation.
18 // THIS PARTICULAR GAME, KBALL DOES NOT NEED BUTTONS, SO IS DISABLED IN INTERACTIVE CONFIGURATION!
19 // ** NOTICE ** I CHANGED SOME DATA TO PUBLIC DUE TO KBALL REQUIREMENTS!
20 // -----------------------------------------------------------------------
28 // This are the return values of the controller
29 // they are returned as a bit mask
30 // So, all joystick input is DIGITAL
37 // buttons (there is room left, for adding more axis in future)
55 void set_default_keyboard(); // we have a 'default' configuration for keyboard
56 void set_keyboard_par(int value
, int index
); // this sets one value for key_val[] array
57 void set_use_keyboard(bool use
); // set if you want to use keyboard input or not
58 void interactive_configuration_keyboard(FONT
*font
, int color
); // to interactive configure keyboard
61 void set_mouse_sens(int s
); // set mouse sensitiviness
62 void set_use_mouse(bool use
); // use the mouse?
63 void interactive_configuration_mouse(FONT
*font
, int color
); // interactive configure mouse
66 void set_joystick_number(int n
); // wich joystick you want to input?
67 void set_use_joystick(bool use
); // use the joystick?
68 void interactive_configuration_joystick(FONT
*font
, int color
); // interactive configure joystick
73 // this is the one that does the actual input from user
76 int get_keyboard_par(int value
, int index
); // get keyboard key, -1 on error (bad index passed)
77 bool get_use_keyboard() { return this->use_keyboard
; }
79 bool get_use_mouse() { return this->use_mouse
; }
80 int get_mouse_sens() { return this->mouse_sens
; }
82 bool get_use_joystick() { return this->use_joystick
; }
83 int get_joystick_number() { return this->joy_num
; }
85 int get_controller_id() { return this->controller_id
; } // unique controller ID (assigned by creation)
87 // Config saving stuff
88 // NOTICE: you have to _previously_ call to allegro's set_config_file
89 void save_configuration_of_controller(char *cfg_section
); // save current configuration in a file (cfg_section = section)
90 void load_configuration_of_controller(char *cfg_section
); // load configuration from a config file (cfg_section = section)
92 // Static members (available from the class itself)
95 static int get_controller_count() { return CController::controller_count
; }
97 // ** NOTICE ** I CHANGED SOME DATA TO PUBLIC DUE TO KBALL REQUIREMENTS!
98 bool use_keyboard
; // want to use keyboard input? (default=true)
99 bool use_joystick
; // want to use joystick? (default=false)
100 bool use_mouse
; // use mouse input? (default=true)
104 int key_val
[15]; // keys to input: 0..3= up,down,left,right | 4..7= reserved | 8..13= buttons | 14= reserved
108 int joy_num
; // wich joystick to use? 0..num_joysticks (default=0)
112 int mouse_sens
; // square of 'dead' until mouse movement is detected; (default 10, smaller is more sens)
115 int controller_id
; // controller ID: automated (useful for saving configuration, you can have different sections, well, use it for something... )
117 // static members, available to all
118 static int controller_count
;