|
From: Elias N. <eli...@us...> - 2003-12-15 11:49:20
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv8597/src/native/macosx Modified Files: hid.cpp org_lwjgl_Sys.cpp org_lwjgl_input_Keyboard.cpp org_lwjgl_input_Mouse.cpp Log Message: Replaced debug libraries with runtime debug condition Index: hid.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/hid.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/hid.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- hid.cpp 23 Oct 2003 18:21:56 -0000 1.2 +++ hid.cpp 15 Dec 2003 11:49:17 -0000 1.3 @@ -123,9 +123,7 @@ static void addToDeviceQueue(hid_device_t *hid_dev, IOHIDElementCookie cookie, int index) { HRESULT result = (*hid_dev->device_queue)->addElement(hid_dev->device_queue, cookie, 0); if (result != S_OK) { -#ifdef _DEBUG - printf("Could not add cookie to queue\n"); -#endif + printfDebug("Could not add cookie to queue\n"); return; } CFDictionaryAddValue(hid_dev->cookie_map, cookie, (void *)index); @@ -193,9 +191,7 @@ CFDictionaryRef matching_dic = IOServiceMatching(kIOHIDDeviceKey); IOReturn err = IOServiceGetMatchingServices(kIOMasterPortDefault, matching_dic, &device_iterator); if (err != kIOReturnSuccess) { -#ifdef _DEBUG - printf("Could not find matching devices\n"); -#endif + printfDebug("Could not find matching devices\n"); return false; } while (!success && (hid_device = IOIteratorNext(device_iterator)) != NULL) { @@ -205,11 +201,11 @@ long usage_page; if (getDictLong(dev_props, CFSTR(kIOHIDPrimaryUsageKey), &usage) && getDictLong(dev_props, CFSTR(kIOHIDPrimaryUsagePageKey), &usage_page)) { -#ifdef _DEBUG - printf("Considering device '"); - printProperty(dev_props, CFSTR(kIOHIDProductKey)); - printf("', usage page %ld usage %ld\n", usage_page, usage); -#endif + if (ATDEBUGLEVEL()) { + printf("Considering device '"); + printProperty(dev_props, CFSTR(kIOHIDProductKey)); + printf("', usage page %ld usage %ld\n", usage_page, usage); + } if (usage_page == device_usage_page && usage == device_usage) { success = initDevice(hid_dev, hid_device, dev_props, num_cookies, hid_cookies, buffer_size); } Index: org_lwjgl_Sys.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_Sys.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_Sys.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- org_lwjgl_Sys.cpp 6 Nov 2003 14:30:25 -0000 1.9 +++ org_lwjgl_Sys.cpp 15 Dec 2003 11:49:17 -0000 1.10 @@ -44,6 +44,7 @@ #include <sys/resource.h> #include <Carbon/Carbon.h> #include "org_lwjgl_Sys.h" +#include "common_tools.h" long int hires_timer_freq; // Hires timer frequency long int hires_timer_start; // Hires timer start @@ -63,15 +64,17 @@ static long queryTime(void) { struct timeval tv; if (gettimeofday(&tv, NULL) == -1) { -#ifdef _DEBUG - printf("Could not read current time\n"); -#endif + printfDebug("Could not read current time\n"); } long result = tv.tv_sec * 1000000l + tv.tv_usec; return result; } +JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setDebugLevel(JNIEnv *env, jclass clazz, jint debug_level) { + setDebugLevel(debug_level); +} + /* * Class: org_lwjgl_Sys * Method: getTime @@ -107,9 +110,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setProcessPriority (JNIEnv * env, jclass clazz, jint priority) { -#ifdef _DEBUG - printf("Unsupported\n"); -#endif + printfDebug("WARNING: setProcessPriority unsupported\n"); } /* Index: org_lwjgl_input_Keyboard.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Keyboard.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- org_lwjgl_input_Keyboard.cpp 6 Nov 2003 14:30:25 -0000 1.18 +++ org_lwjgl_input_Keyboard.cpp 15 Dec 2003 11:49:17 -0000 1.19 @@ -70,16 +70,12 @@ static bool handleKey(UInt32 key_code, unsigned char state) { if (key_code >= KEYBOARD_SIZE) { -#ifdef _DEBUG - printf("Key code >= %d %x\n", KEYBOARD_SIZE, (unsigned int)key_code); -#endif + printfDebug("Key code >= %d %x\n", KEYBOARD_SIZE, (unsigned int)key_code); return false; } unsigned char mapped_code = key_map[key_code]; if (mapped_code == 0) { -#ifdef _DEBUG - printf("unknown key code: %x\n", (unsigned int)key_code); -#endif + printfDebug("unknown key code: %x\n", (unsigned int)key_code); return false; } return handleMappedKey(mapped_code, state); @@ -133,9 +129,7 @@ KeyboardLayoutRef layout; OSStatus err = KLGetCurrentKeyboardLayout(&layout); if (err != noErr) { -#ifdef _DEBUG - printf("Could not get current keyboard layout\n"); -#endif + printfDebug("Could not get current keyboard layout\n"); return false; } @@ -149,9 +143,7 @@ success = success && GetEventParameter(event, kEventParamKeyboardType, typeUInt32, NULL, sizeof(keyboardType), NULL, &keyboardType) == noErr; success = success && GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(modifierKeyState), NULL, &modifierKeyState) == noErr; if (!success) { -#ifdef _DEBUG - printf("Could not get event parameters for character translation\n"); -#endif + printfDebug("Could not get event parameters for character translation\n"); return false; } err = KLGetKeyboardLayoutProperty(layout, kKLuchrData, (const void **)&uchrHandle); @@ -183,9 +175,7 @@ if (state) return writeAsciiChars(count, ascii_buffer); } else { -#ifdef _DEBUG - printf("Could not translate key\n"); -#endif + printfDebug("Could not translate key\n"); return false; } } @@ -196,9 +186,7 @@ UInt32 key_code; OSStatus err = GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(key_code), NULL, &key_code); if (err != noErr) { -#ifdef _DEBUG - printf("Could not get event key code\n"); -#endif + printfDebug("Could not get event key code\n"); return; } if (handleKey(key_code, 1) && !handleTranslation(event, true)) { @@ -211,9 +199,7 @@ UInt32 key_code; OSStatus err = GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(key_code), NULL, &key_code); if (err != noErr) { -#ifdef _DEBUG - printf("Could not get event key code\n"); -#endif + printfDebug("Could not get event key code\n"); return; } if (handleKey(key_code, 0) && !handleTranslation(event, false)) { @@ -236,9 +222,7 @@ UInt32 modifier_bits; OSStatus err = GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(modifier_bits), NULL, &modifier_bits); if (err != noErr) { -#ifdef _DEBUG - printf("Could not get event key code\n"); -#endif + printfDebug("Could not get event key code\n"); return; } handleModifier(modifier_bits, controlKey, 0x1d); Index: org_lwjgl_input_Mouse.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- org_lwjgl_input_Mouse.cpp 26 Oct 2003 08:44:19 -0000 1.21 +++ org_lwjgl_input_Mouse.cpp 15 Dec 2003 11:49:17 -0000 1.22 @@ -70,9 +70,7 @@ static void handleButton(unsigned char button_index, jbyte state) { if (button_index >= NUM_BUTTONS) { -#ifdef _DEBUG - printf("Button index %d out of range [0..%d]\n", button_index, NUM_BUTTONS); -#endif + printfDebug("Button index %d out of range [0..%d]\n", button_index, NUM_BUTTONS); return; } button_states[button_index] = state; @@ -108,9 +106,7 @@ } } } -#ifdef _DEBUG - printf("Recieved an unknown HID device event\n"); -#endif + printfDebug("Recieved an unknown HID device event\n"); } } */ @@ -124,9 +120,7 @@ EventMouseButton button; OSStatus err = GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(button), NULL, &button); if (err != noErr) { -#ifdef _DEBUG - printf("Could not get button parameter from event\n"); -#endif + printfDebug("Could not get button parameter from event\n"); return; } handleButton(button - 1, state); @@ -136,9 +130,7 @@ HIPoint delta; OSStatus err = GetEventParameter(event, kEventParamMouseDelta, typeHIPoint, NULL, sizeof(delta), NULL, &delta); if (err != noErr) { -#ifdef _DEBUG - printf("Could not delta parameter from event\n"); -#endif + printfDebug("Could not delta parameter from event\n"); return; } last_dx += (int)delta.x; @@ -149,9 +141,7 @@ long delta; OSStatus err = GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(delta), NULL, &delta); if (err != noErr) { -#ifdef _DEBUG - printf("Could not delta parameter from event\n"); -#endif + printfDebug("Could not delta parameter from event\n"); return; } last_dz += (int)delta; |