1 /* 2 XorGramana Copyright 2009 James W. Morris, james@jwm-art.net 3 4 This file is part of XorGramana. 5 6 XorGramana is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 XorGramana is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with XorGramana. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 #ifndef _INPUT_H 20 #define _INPUT_H 21 22 #include <SDL.h> 23 24 #include "types.h" 25 26 /* 27 only one keypress at any one time processed. 28 we'll see... 29 */ 30 31 #define DEF_KEY_RATE_MS 50 32 33 enum INP_MVS 34 { 35 INP_LEFT=0x01, 36 INP_RIGHT=0x02, 37 INP_UP=0x04, 38 INP_DOWN=0x08, 39 /* repeat? */ 40 INP_REP=0xff 41 }; 42 43 struct xg_key 44 { 45 SDLKey key; 46 bool pressed; 47 }; 48 49 struct xg_input 50 { 51 struct xg_key** keys; 52 int r_delay; 53 int r_interval; 54 int mouse_x; 55 int mouse_y; 56 bool mouse_b1; 57 bool mouse_b2; 58 bool quit; 59 bool exit; 60 }; 61 62 extern struct xg_input xginput; 63 64 struct xg_key** create_key_list_array(int count); 65 void destroy_key_list_array(struct xg_key** keylist); 66 67 void set_keys(struct xg_key** keys); 68 69 void key_repeat(); 70 void key_repeat_on(); 71 void key_repeat_off(); 72 73 bool simple_poll_event(); 74 void wait_till_pressed(); 75 #endif 76