1 /* 2 * input.h - input management 3 * Copyright (C) 2008-2009 Alexandre Martins <alemartf(at)gmail(dot)com> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License along 16 * with this program; if not, write to the Free Software Foundation, Inc., 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 20 #ifndef _INPUT_H 21 #define _INPUT_H 22 23 #include "v2d.h" 24 25 /* forward declarations */ 26 typedef enum inputbutton_t inputbutton_t; 27 typedef struct input_t input_t; 28 29 /* available buttons */ 30 #define IB_MAX 8 /* number of buttons */ 31 enum inputbutton_t { 32 IB_UP, /* up */ 33 IB_DOWN, /* down */ 34 IB_RIGHT, /* right */ 35 IB_LEFT, /* left */ 36 IB_FIRE1, /* jump */ 37 IB_FIRE2, /* switch character */ 38 IB_FIRE3, /* pause */ 39 IB_FIRE4 /* quit */ 40 }; 41 42 /* public methods */ 43 void input_init(); 44 void input_update(); 45 void input_release(); 46 int input_joystick_available(); /* a joystick is available AND the user wants to use it */ 47 void input_ignore_joystick(int ignore); /* ignores the input received from a joystick (if available) */ 48 int input_is_joystick_ignored(); 49 50 input_t *input_create_computer(); /* computer-controlled "input" */ 51 input_t *input_create_keyboard(int keybmap[]); /* keyboard */ 52 input_t *input_create_mouse(); /* mouse */ 53 input_t *input_create_joystick(); /* joystick */ 54 input_t *input_create_user(); /* user's custom input device */ 55 void input_destroy(input_t *in); 56 57 int input_button_down(input_t *in, inputbutton_t button); 58 int input_button_pressed(input_t *in, inputbutton_t button); 59 int input_button_up(input_t *in, inputbutton_t button); 60 float input_button_howlong(input_t *in, inputbutton_t button); 61 void input_simulate_button_down(input_t *in, inputbutton_t button); 62 void input_ignore(input_t *in); 63 void input_restore(input_t *in); 64 int input_is_ignored(input_t *in); 65 void input_clear(input_t *in); 66 v2d_t input_get_xy(input_t *in); 67 68 #endif 69