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 /** 30 * @file 31 * @brief General definitions. 32 */ 33 34 #pragma once 35 36 /* this is wiiuse - used to distinguish from third party programs using wiiuse.h */ 37 #include "os.h" 38 39 #define WIIMOTE_PI 3.14159265f 40 41 //#define WITH_WIIUSE_DEBUG 42 43 /* Error output macros */ 44 #define WIIUSE_ERROR(fmt, ...) fprintf(stderr, "[ERROR] " fmt "\n", ##__VA_ARGS__) 45 46 /* Warning output macros */ 47 #define WIIUSE_WARNING(fmt, ...) fprintf(stderr, "[WARNING] " fmt "\n", ##__VA_ARGS__) 48 49 /* Information output macros */ 50 #define WIIUSE_INFO(fmt, ...) fprintf(stderr, "[INFO] " fmt "\n", ##__VA_ARGS__) 51 52 #ifdef WITH_WIIUSE_DEBUG 53 #ifdef WIN32 54 #define WIIUSE_DEBUG(fmt, ...) do { \ 55 char* file = __FILE__; \ 56 int i = strlen(file) - 1; \ 57 for (; i && (file[i] != '\\'); --i); \ 58 fprintf(stderr, "[DEBUG] %s:%i: " fmt "\n", file+i+1, __LINE__, ##__VA_ARGS__); \ 59 } while (0) 60 #else 61 #define WIIUSE_DEBUG(fmt, ...) fprintf(stderr, "[DEBUG] " __FILE__ ":%i: " fmt "\n", __LINE__, ##__VA_ARGS__) 62 #endif 63 #else 64 #define WIIUSE_DEBUG(fmt, ...) 65 #endif 66 67 /* Convert between radians and degrees */ 68 #define RAD_TO_DEGREE(r) ((r * 180.0f) / WIIMOTE_PI) 69 #define DEGREE_TO_RAD(d) (d * (WIIMOTE_PI / 180.0f)) 70 71 /* Convert to big endian */ 72 #define BIG_ENDIAN_LONG(i) (htonl(i)) 73 #define BIG_ENDIAN_SHORT(i) (htons(i)) 74 75 #define absf(x) ((x >= 0) ? (x) : (x * -1.0f)) 76 #define diff_f(x, y) ((x >= y) ? (absf(x - y)) : (absf(y - x))) 77 78