wiiuse
definitions.h
Go to the documentation of this file.
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 
34 #ifndef DEFINITIONS_H_INCLUDED
35 #define DEFINITIONS_H_INCLUDED
36 
37 /* this is wiiuse - used to distinguish from third party programs using wiiuse.h */
38 #include "definitions_os.h"
39 #include <stdio.h>
43 #define WIIMOTE_PI 3.14159265f
44 
45 /* #define WITH_WIIUSE_DEBUG */
46 
47 extern FILE *logtarget[];
48 
49 #define OUTF_ERROR logtarget[0]
50 #define OUTF_WARNING logtarget[1]
51 #define OUTF_INFO logtarget[2]
52 #define OUTF_DEBUG logtarget[3]
53 
54 /* Error output macros */
55 #define WIIUSE_ERROR(fmt, ...) \
56  do \
57  { \
58  if (OUTF_ERROR) \
59  fprintf(OUTF_ERROR, "[ERROR] " fmt "\n", ##__VA_ARGS__); \
60  } while (0)
61 
62 /* Warning output macros */
63 #define WIIUSE_WARNING(fmt, ...) \
64  do \
65  { \
66  if (OUTF_WARNING) \
67  fprintf(OUTF_WARNING, "[WARNING] " fmt "\n", ##__VA_ARGS__); \
68  } while (0)
69 
70 /* Information output macros */
71 #define WIIUSE_INFO(fmt, ...) \
72  do \
73  { \
74  if (OUTF_INFO) \
75  fprintf(OUTF_INFO, "[INFO] " fmt "\n", ##__VA_ARGS__); \
76  } while (0)
77 
78 #ifdef WITH_WIIUSE_DEBUG
79 #ifdef WIIUSE_WIN32
80 #define WIIUSE_DEBUG(fmt, ...) \
81  do \
82  { \
83  if (OUTF_DEBUG) \
84  { \
85  char *___filename = __FILE__; \
86  int ___i = strlen(___filename) - 1; \
87  for (; ___i && (___filename[___i] != '\\'); --___i) \
88  ; \
89  fprintf(OUTF_DEBUG, "[DEBUG] %s:%i: " fmt "\n", ___filename + ___i + 1, __LINE__, ##__VA_ARGS__); \
90  } \
91  } while (0)
92 #else
93 #define WIIUSE_DEBUG(fmt, ...) \
94  do \
95  { \
96  if (OUTF_DEBUG) \
97  fprintf(OUTF_DEBUG, "[DEBUG] " __FILE__ ":%i: " fmt "\n", __LINE__, ##__VA_ARGS__); \
98  } while (0)
99 #endif
100 #else
101 #define WIIUSE_DEBUG(fmt, ...)
102 #endif
103 
104 /* Convert between radians and degrees */
105 #define RAD_TO_DEGREE(r) ((r * 180.0f) / WIIMOTE_PI)
106 #define DEGREE_TO_RAD(d) (d * (WIIMOTE_PI / 180.0f))
107 
108 #define absf(x) ((x >= 0) ? (x) : (x * -1.0f))
109 #define diff_f(x, y) ((x >= y) ? (absf(x - y)) : (absf(y - x)))
110 
113 #endif /* DEFINITIONS_H_INCLUDED */
Operating system related definitions.
FILE * logtarget[]
Output FILE stream for each wiiuse_loglevel.
Definition: wiiuse.c:57