event.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* $Id$
  2. * MegaZeux
  3. *
  4. * Copyright (C) 2002 Gilead Kutnick - exophase@adelphia.net
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This program 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 GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20. #ifndef EVENT_H
  21. #define EVENT_H
  22. #include "SDL.h"
  23. #define KEY_REPEAT_START 250
  24. #define KEY_REPEAT_RATE 33
  25. #define MOUSE_REPEAT_START 200
  26. #define MOUSE_REPEAT_RATE 10
  27. #define UPDATE_DELAY 5
  28. typedef struct
  29. {
  30. Uint8 SDL_keymap[512];
  31. SDLKey last_SDL_pressed;
  32. SDLKey last_SDL;
  33. SDLKey last_SDL_repeat;
  34. SDLKey last_SDL_release;
  35. Uint16 last_unicode;
  36. Uint16 last_unicode_repeat;
  37. Uint32 last_keypress_time;
  38. Uint32 mouse_x;
  39. Uint32 mouse_y;
  40. Uint32 mouse_moved;
  41. Uint32 last_mouse_button;
  42. Uint32 last_mouse_repeat;
  43. Uint32 last_mouse_repeat_state;
  44. Uint32 last_mouse_time;
  45. Uint32 mouse_button_state;
  46. Uint32 caps_status;
  47. } input_status;
  48. typedef enum
  49. {
  50. keycode_pc_xt,
  51. keycode_SDL,
  52. keycode_unicode
  53. } keycode_type;
  54. Uint32 process_event(SDL_Event event);
  55. void wait_event();
  56. Uint32 update_autorepeat();
  57. Uint32 update_event_status();
  58. Uint32 update_event_status_delay();
  59. Uint32 get_key(keycode_type type);
  60. Uint32 get_last_key(keycode_type type);
  61. void force_last_key(keycode_type type, int val);
  62. Uint32 get_key_status(keycode_type type, Uint32 index);
  63. Uint32 get_mouse_movement(int *x, int *y);
  64. void get_mouse_position(int *x, int *y);
  65. Uint32 get_mouse_press();
  66. Uint32 get_mouse_status();
  67. void warp_mouse(Uint32 x, Uint32 y);
  68. void warp_mouse_x(Uint32 x);
  69. void warp_mouse_y(Uint32 y);
  70. Uint32 get_mouse_x();
  71. Uint32 get_mouse_y();
  72. Uint32 convert_SDL_xt(SDLKey key);
  73. SDLKey convert_xt_SDL(Uint32 key, SDLKey *second);
  74. Uint32 get_last_key_released(keycode_type type);
  75. int get_alt_status(keycode_type type);
  76. int get_shift_status(keycode_type type);
  77. int get_ctrl_status(keycode_type type);
  78. #endif