definitions.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * wiiuse
  3. *
  4. * Written By:
  5. * Michael Laforest < para >
  6. * Email: < thepara (--AT--) g m a i l [--DOT--] com >
  7. *
  8. * Copyright 2006-2007
  9. *
  10. * This file is part of wiiuse.
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 3 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. * $Header$
  26. *
  27. */
  28. /**
  29. * @file
  30. * @brief General definitions.
  31. */
  32. #ifndef DEFINITIONS_H_INCLUDED
  33. #define DEFINITIONS_H_INCLUDED
  34. /* this is wiiuse - used to distinguish from third party programs using wiiuse.h */
  35. #include <stdio.h>
  36. #include "definitions_os.h"
  37. /** @addtogroup internal_general */
  38. /** @{ */
  39. #define WIIMOTE_PI 3.14159265f
  40. /* #define WITH_WIIUSE_DEBUG */
  41. extern FILE* logtarget[];
  42. #define OUTF_ERROR logtarget[0]
  43. #define OUTF_WARNING logtarget[1]
  44. #define OUTF_INFO logtarget[2]
  45. #define OUTF_DEBUG logtarget[3]
  46. /* Error output macros */
  47. #define WIIUSE_ERROR(fmt, ...) do { if (OUTF_ERROR) fprintf(OUTF_ERROR, "[ERROR] " fmt "\n", ##__VA_ARGS__); } while(0)
  48. /* Warning output macros */
  49. #define WIIUSE_WARNING(fmt, ...) do { if (OUTF_WARNING) fprintf(OUTF_WARNING, "[WARNING] " fmt "\n", ##__VA_ARGS__); } while(0)
  50. /* Information output macros */
  51. #define WIIUSE_INFO(fmt, ...) do { if (OUTF_INFO) fprintf(OUTF_INFO, "[INFO] " fmt "\n", ##__VA_ARGS__); } while(0)
  52. #ifdef WITH_WIIUSE_DEBUG
  53. #ifdef WIIUSE_WIN32
  54. #define WIIUSE_DEBUG(fmt, ...) do { \
  55. if (OUTF_DEBUG) { \
  56. char* file = __FILE__; \
  57. int i = strlen(file) - 1; \
  58. for (; i && (file[i] != '\\'); --i); \
  59. fprintf(OUTF_DEBUG, "[DEBUG] %s:%i: " fmt "\n", file+i+1, __LINE__, ##__VA_ARGS__); \
  60. } \
  61. } while (0)
  62. #else
  63. #define WIIUSE_DEBUG(fmt, ...) do { if (OUTF_DEBUG) fprintf(OUTF_DEBUG, "[DEBUG] " __FILE__ ":%i: " fmt "\n", __LINE__, ##__VA_ARGS__); } while (0)
  64. #endif
  65. #else
  66. #define WIIUSE_DEBUG(fmt, ...)
  67. #endif
  68. /* Convert between radians and degrees */
  69. #define RAD_TO_DEGREE(r) ((r * 180.0f) / WIIMOTE_PI)
  70. #define DEGREE_TO_RAD(d) (d * (WIIMOTE_PI / 180.0f))
  71. #define absf(x) ((x >= 0) ? (x) : (x * -1.0f))
  72. #define diff_f(x, y) ((x >= y) ? (absf(x - y)) : (absf(y - x)))
  73. #define WCONST
  74. /** @} */
  75. #endif /* DEFINITIONS_H_INCLUDED */