RetroArch
definitions.h
Go to the documentation of this file.
1 #ifndef __DEFINITIONS_H__
2 #define __DEFINITIONS_H__
3 
4 #include "os.h"
5 
6 #define WIIMOTE_PI 3.14159265f
7 
8 //#define WITH_WIIUSE_DEBUG
9 
10 /* Error output macros */
11 #define WIIUSE_ERROR(fmt, ...) fprintf(stderr, "[ERROR] " fmt "\n", ##__VA_ARGS__)
12 
13 /* Warning output macros */
14 #define WIIUSE_WARNING(fmt, ...) fprintf(stderr, "[WARNING] " fmt "\n", ##__VA_ARGS__)
15 
16 /* Information output macros */
17 #define WIIUSE_INFO(fmt, ...) fprintf(stderr, "[INFO] " fmt "\n", ##__VA_ARGS__)
18 
19 #ifdef WITH_WIIUSE_DEBUG
20  #ifdef WIN32
21  #define WIIUSE_DEBUG(fmt, ...) do { \
22  char* file = __FILE__; \
23  int i = strlen(file) - 1; \
24  for (; i && (file[i] != '\\'); --i); \
25  fprintf(stderr, "[DEBUG] %s:%i: " fmt "\n", file+i+1, __LINE__, ##__VA_ARGS__); \
26  } while (0)
27  #else
28  #define WIIUSE_DEBUG(fmt, ...) fprintf(stderr, "[DEBUG] " __FILE__ ":%i: " fmt "\n", __LINE__, ##__VA_ARGS__)
29  #endif
30 #else
31  #define WIIUSE_DEBUG(fmt, ...)
32 #endif
33 
34 #if 1
35 #define WII_DEBUG(fmt, ...) do { \
36  printf("[WDEBUG] " __FILE__ ":%i: " fmt "\n", __LINE__, ##__VA_ARGS__); \
37  usleep(3000000); \
38  } while (0)
39 #else
40  #define WII_DEBUG(fmt, ...)
41 #endif
42 
43 
44 /* Convert between radians and degrees */
45 #define RAD_TO_DEGREE(r) ((r * 180.0f) / WIIMOTE_PI)
46 #define DEGREE_TO_RAD(d) (d * (WIIMOTE_PI / 180.0f))
47 
48 /* Convert to big endian */
49 #define BIG_ENDIAN_LONG(i) (htonl(i))
50 #define BIG_ENDIAN_SHORT(i) (htons(i))
51 
52 #define absf(x) ((x >= 0) ? (x) : (x * -1.0f))
53 #define diff_f(x, y) ((x >= y) ? (absf(x - y)) : (absf(y - x)))
54 
55 #endif