evq.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* MegaZeux
  2. *
  3. * Copyright (C) 2004 Gilead Kutnick <exophase@adelphia.net>
  4. * Copyright (C) 2009 Kevin Vance <kvance@kvance.com>
  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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. /* Simple event queue for NDS input events */
  21. #ifndef __ARCH_NDS_EVQ_H
  22. #define __ARCH_NDS_EVQ_H
  23. #include "../../src/compat.h"
  24. enum NDSEventType
  25. {
  26. NDS_EVENT_NOP = 0,
  27. NDS_EVENT_KEY_DOWN, // Hardware key down
  28. NDS_EVENT_KEY_UP, // Hardware key up
  29. NDS_EVENT_KEYBOARD_DOWN, // Software key down
  30. NDS_EVENT_KEYBOARD_UP, // Software key up
  31. NDS_EVENT_TOUCH_DOWN, // Touchscreen pen down
  32. NDS_EVENT_TOUCH_MOVE, // Touchscreen pen move
  33. NDS_EVENT_TOUCH_UP, // Touchscreen pen up
  34. };
  35. typedef struct NDSEvent_tag
  36. {
  37. enum NDSEventType type;
  38. // On NDS_EVENT_KEY_DOWN and NDS_EVENT_KEY_UP, a keyboard bit e.g. KEY_LEFT.
  39. // On NDS_EVENT_KEYBOARD_PRESSED, the ASCII character pressed (not held).
  40. int key;
  41. // NDS_EVENT_TOUCH_MOVE touch coordinates.
  42. int x;
  43. int y;
  44. // Implementation: next event in the list.
  45. struct NDSEvent_tag *_next;
  46. } NDSEvent;
  47. // Return true if an event is available, fill dest with this event.
  48. bool nds_event_poll(NDSEvent *dest);
  49. // Push a copy of this event onto the queue.
  50. void nds_event_push(NDSEvent *src);
  51. // Fill in different event structures.
  52. void nds_event_fill_key_down(NDSEvent *dest, int key);
  53. void nds_event_fill_key_up(NDSEvent *dest, int key);
  54. void nds_event_fill_keyboard_down(NDSEvent *dest, int key);
  55. void nds_event_fill_keyboard_up(NDSEvent *dest, int key);
  56. void nds_event_fill_touch_down(NDSEvent *dest);
  57. void nds_event_fill_touch_move(NDSEvent *dest, int x, int y);
  58. void nds_event_fill_touch_up(NDSEvent *dest);
  59. #endif /* __ARCH_NDS_EVQ_H */