Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Joystick.h 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. LUFA Library
  3. Copyright (C) Dean Camera, 2012.
  4. dean [at] fourwalledcubicle [dot] com
  5. www.lufa-lib.org
  6. */
  7. /*
  8. Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
  9. Permission to use, copy, modify, distribute, and sell this
  10. software and its documentation for any purpose is hereby granted
  11. without fee, provided that the above copyright notice appear in
  12. all copies and that both that the copyright notice and this
  13. permission notice and warranty disclaimer appear in supporting
  14. documentation, and that the name of the author not be used in
  15. advertising or publicity pertaining to distribution of the
  16. software without specific, written prior permission.
  17. The author disclaim all warranties with regard to this
  18. software, including all implied warranties of merchantability
  19. and fitness. In no event shall the author be liable for any
  20. special, indirect or consequential damages or any damages
  21. whatsoever resulting from loss of use, data or profits, whether
  22. in an action of contract, negligence or other tortious action,
  23. arising out of or in connection with the use or performance of
  24. this software.
  25. */
  26. /** \file
  27. * \brief LUFA Custom Board Joystick Hardware Driver (Template)
  28. *
  29. * This is a stub driver header file, for implementing custom board
  30. * layout hardware with compatible LUFA board specific drivers. If
  31. * the library is configured to use the BOARD_USER board mode, this
  32. * driver file should be completed and copied into the "/Board/" folder
  33. * inside the application's folder.
  34. *
  35. * This stub is for the board-specific component of the LUFA Joystick
  36. * driver, for a digital four-way (plus button) joystick.
  37. */
  38. #ifndef __JOYSTICK_USER_H__
  39. #define __JOYSTICK_USER_H__
  40. /* Includes: */
  41. // TODO: Add any required includes here
  42. /* Enable C linkage for C++ Compilers: */
  43. #if defined(__cplusplus)
  44. extern "C" {
  45. #endif
  46. /* Preprocessor Checks: */
  47. #if !defined(__INCLUDE_FROM_JOYSTICK_H)
  48. #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead.
  49. #endif
  50. /* Public Interface - May be used in end-application: */
  51. /* Macros: */
  52. /** Mask for the joystick being pushed in the left direction. */
  53. #define JOY_LEFT // TODO: Add mask to indicate joystick left position here
  54. /** Mask for the joystick being pushed in the right direction. */
  55. #define JOY_RIGHT // TODO: Add mask to indicate joystick right position here
  56. /** Mask for the joystick being pushed in the upward direction. */
  57. #define JOY_UP // TODO: Add mask to indicate joystick up position here
  58. /** Mask for the joystick being pushed in the downward direction. */
  59. #define JOY_DOWN // TODO: Add mask to indicate joystick down position here
  60. /** Mask for the joystick being pushed inward. */
  61. #define JOY_PRESS // TODO: Add mask to indicate joystick pressed position here
  62. /* Inline Functions: */
  63. #if !defined(__DOXYGEN__)
  64. static inline void Joystick_Init(void)
  65. {
  66. // TODO: Initialize joystick port pins as inputs with pull-ups
  67. }
  68. static inline void Joystick_Disable(void)
  69. {
  70. // TODO: Clear the joystick pins as high impedance inputs here
  71. }
  72. static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
  73. static inline uint8_t Joystick_GetStatus(void)
  74. {
  75. // TODO: Return current joystick position data which can be obtained by masking against the JOY_* macros
  76. }
  77. #endif
  78. /* Disable C linkage for C++ Compilers: */
  79. #if defined(__cplusplus)
  80. }
  81. #endif
  82. #endif