change PAD_ScanPads()s behaviour. the return value now contains a bitmask of the...
[libogc.git] / wiiuse / definitions.h
blob04dc5be6d8437ac4e3ab9f923610246ab1f8b95e
1 #ifndef __DEFINITIONS_H__
2 #define __DEFINITIONS_H__
4 #include "os.h"
6 #define WIIMOTE_PI 3.14159265f
8 //#define WITH_WIIUSE_DEBUG
10 /* Error output macros */
11 #define WIIUSE_ERROR(fmt, ...) fprintf(stderr, "[ERROR] " fmt "\n", ##__VA_ARGS__)
13 /* Warning output macros */
14 #define WIIUSE_WARNING(fmt, ...) fprintf(stderr, "[WARNING] " fmt "\n", ##__VA_ARGS__)
16 /* Information output macros */
17 #define WIIUSE_INFO(fmt, ...) fprintf(stderr, "[INFO] " fmt "\n", ##__VA_ARGS__)
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
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
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))
48 /* Convert to big endian */
49 #define BIG_ENDIAN_LONG(i) (htonl(i))
50 #define BIG_ENDIAN_SHORT(i) (htons(i))
52 #define absf(x) ((x >= 0) ? (x) : (x * -1.0f))
53 #define diff_f(x, y) ((x >= y) ? (absf(x - y)) : (absf(y - x)))
55 #endif