You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(134) |
Sep
(52) |
Oct
(13) |
Nov
(342) |
Dec
(163) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(44) |
Feb
(62) |
Mar
(158) |
Apr
(38) |
May
(70) |
Jun
(58) |
Jul
(104) |
Aug
(207) |
Sep
(83) |
Oct
(122) |
Nov
(23) |
Dec
(49) |
| 2004 |
Jan
(119) |
Feb
(132) |
Mar
(192) |
Apr
(140) |
May
(77) |
Jun
(74) |
Jul
(201) |
Aug
(63) |
Sep
(102) |
Oct
(70) |
Nov
(173) |
Dec
(78) |
| 2005 |
Jan
(174) |
Feb
(197) |
Mar
(105) |
Apr
(59) |
May
(77) |
Jun
(43) |
Jul
(21) |
Aug
(18) |
Sep
(47) |
Oct
(37) |
Nov
(74) |
Dec
(50) |
| 2006 |
Jan
(44) |
Feb
(19) |
Mar
(32) |
Apr
(24) |
May
(31) |
Jun
(55) |
Jul
(138) |
Aug
(28) |
Sep
(12) |
Oct
(41) |
Nov
(58) |
Dec
(24) |
| 2007 |
Jan
(28) |
Feb
(14) |
Mar
(10) |
Apr
(68) |
May
(30) |
Jun
(26) |
Jul
(18) |
Aug
(63) |
Sep
(19) |
Oct
(29) |
Nov
(20) |
Dec
(10) |
| 2008 |
Jan
(38) |
Feb
(7) |
Mar
(37) |
Apr
(120) |
May
(41) |
Jun
(36) |
Jul
(39) |
Aug
(24) |
Sep
(28) |
Oct
(30) |
Nov
(36) |
Dec
(75) |
| 2009 |
Jan
(46) |
Feb
(22) |
Mar
(50) |
Apr
(70) |
May
(134) |
Jun
(105) |
Jul
(75) |
Aug
(34) |
Sep
(38) |
Oct
(34) |
Nov
(19) |
Dec
(20) |
| 2010 |
Jan
(11) |
Feb
(20) |
Mar
(65) |
Apr
(83) |
May
(104) |
Jun
(73) |
Jul
(78) |
Aug
(57) |
Sep
(43) |
Oct
(35) |
Nov
(9) |
Dec
(4) |
| 2011 |
Jan
(21) |
Feb
(11) |
Mar
(18) |
Apr
(10) |
May
(18) |
Jun
(15) |
Jul
(48) |
Aug
(25) |
Sep
(17) |
Oct
(45) |
Nov
(15) |
Dec
(12) |
| 2012 |
Jan
(21) |
Feb
(9) |
Mar
(12) |
Apr
(9) |
May
(9) |
Jun
(5) |
Jul
(1) |
Aug
(10) |
Sep
(12) |
Oct
(1) |
Nov
(28) |
Dec
(5) |
| 2013 |
Jan
(4) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2014 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2016 |
Jan
(2) |
Feb
(1) |
Mar
(1) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
|
1
(3) |
2
|
3
(1) |
4
|
|
5
|
6
(5) |
7
(11) |
8
(7) |
9
|
10
(3) |
11
(12) |
|
12
|
13
(2) |
14
(7) |
15
(3) |
16
(3) |
17
|
18
|
|
19
|
20
(11) |
21
(5) |
22
(12) |
23
(10) |
24
(8) |
25
(4) |
|
26
(1) |
27
|
28
(13) |
29
(1) |
30
|
31
|
|
|
From: Elias N. <eli...@us...> - 2003-10-21 17:27:17
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv14892/src/native/macosx Modified Files: Makefile.am Window.h org_lwjgl_Display.cpp org_lwjgl_input_Keyboard.cpp org_lwjgl_input_Mouse.cpp org_lwjgl_opengl_Window.cpp tools.cpp tools.h Added Files: hid.cpp hid.h Removed Files: org_lwjgl_opengl_MacOSX.cpp org_lwjgl_opengl_MacOSX.h Log Message: --- NEW FILE: hid.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/hid.cpp /* * Copyright (c) 2002 Light Weight Java Game Library Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of 'Light Weight Java Game Library' nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * $Id: hid.cpp,v 1.1 2003/10/21 15:11:59 elias_naur Exp $ * * Mac OS X mouse handling. * * @author elias_naur <eli...@us...> * @version $Revision: 1.1 $ */ #include "hid.h" #include "tools.h" static void searchDictionary(CFDictionaryRef dict, hid_device_t *hid_dev, int num_cookies, hid_cookie_t *hid_cookies); static void searchObject(CFTypeRef object, hid_device_t *hid_dev, int num_cookies, hid_cookie_t *hid_cookies); /*static void printCFString(CFStringRef str) { CFIndex buffer_size = CFStringGetLength(str) + 1; char * buffer = (char *)malloc(buffer_size); if (buffer != NULL) { if (CFStringGetCString(str, buffer, buffer_size, CFStringGetSystemEncoding())) printf("%s", buffer); free(buffer); } } static void printCFNumber(CFNumberRef num) { long number; if (CFNumberGetValue(num, kCFNumberLongType, &number)) printf("0x%lx (%ld)", number, number); } */ /*static void printProperty(CFDictionaryRef dict, CFStringRef key) { CFTypeRef val = CFDictionaryGetValue(dict, key); if (val != NULL) { CFTypeID type = CFGetTypeID(val); if (type == CFArrayGetTypeID()) printf("array\n"); else if (type == CFBooleanGetTypeID()) printf("boolean\n"); else if (type == CFDictionaryGetTypeID()) printf("dictionary\n"); else if (type == CFNumberGetTypeID()) printCFNumber((CFNumberRef)val); else if (type == CFStringGetTypeID()) printCFString((CFStringRef)val); else printf("<unknown object type>\n"); } } */ static void closeDeviceAndQueue(hid_device_t *hid_dev) { (*hid_dev->device_queue)->dispose(hid_dev->device_queue); (*hid_dev->device_queue)->Release(hid_dev->device_queue); (*hid_dev->device_interface)->close(hid_dev->device_interface); } static void closeDeviceAll(hid_device_t *hid_dev) { closeDeviceAndQueue(hid_dev); CFRelease(hid_dev->cookie_map); } static IOHIDQueueInterface **allocDeviceQueue(IOHIDDeviceInterface **device_interface, int buffer_size) { IOHIDQueueInterface **device_queue = (*device_interface)->allocQueue(device_interface); if (device_queue == NULL) return false; HRESULT err = (*device_queue)->create(device_queue, 0, buffer_size); if (err != S_OK) { (*device_queue)->Release(device_queue); return NULL; } return device_queue; } static void searchArray(CFArrayRef array, hid_device_t *hid_dev, int num_cookies, hid_cookie_t *hid_cookies) { int size = CFArrayGetCount(array); for (int i = 0; i < size; i++) { CFTypeRef value = (CFTypeRef)CFArrayGetValueAtIndex(array, i); searchObject(value, hid_dev, num_cookies, hid_cookies); } } static void searchObject(CFTypeRef object, hid_device_t *hid_dev, int num_cookies, hid_cookie_t *hid_cookies) { CFTypeID type = CFGetTypeID(object); if (type == CFArrayGetTypeID()) searchArray((CFArrayRef)object, hid_dev, num_cookies, hid_cookies); else if (type == CFDictionaryGetTypeID()) searchDictionary((CFDictionaryRef)object, hid_dev, num_cookies, hid_cookies); else printf("<unknown object>\n"); } static void searchDictionaryElement(CFDictionaryRef dict, CFStringRef key, hid_device_t *hid_dev, int num_cookies, hid_cookie_t *hid_cookies) { CFTypeRef object = CFDictionaryGetValue(dict, key); if (object != NULL) searchObject(object, hid_dev, num_cookies, hid_cookies); } 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 return; } CFDictionaryAddValue(hid_dev->cookie_map, cookie, (void *)index); } static void searchDictionary(CFDictionaryRef dict, hid_device_t *hid_dev, int num_cookies, hid_cookie_t *hid_cookies) { searchDictionaryElement(dict, CFSTR(kIOHIDElementKey), hid_dev, num_cookies, hid_cookies); long cookie_num; long usage; long usage_page; if (!getDictLong(dict, CFSTR(kIOHIDElementCookieKey), &cookie_num) || !getDictLong(dict, CFSTR(kIOHIDElementUsageKey), &usage) || !getDictLong(dict, CFSTR(kIOHIDElementUsagePageKey), &usage_page)) return; for (int i = 0; i < num_cookies; i++) { if (hid_cookies[i].usage_page != kHIDPage_Undefined && hid_cookies[i].usage != kHIDUsage_Undefined && usage_page == hid_cookies[i].usage_page && usage == hid_cookies[i].usage) { addToDeviceQueue(hid_dev, (IOHIDElementCookie)cookie_num, i); } } } static bool initDevice(hid_device_t *hid_dev, io_object_t hid_device, CFDictionaryRef dict, int num_cookies, hid_cookie_t *hid_cookies, int buffer_size) { io_name_t class_name; IOCFPlugInInterface **plugin_interface; SInt32 score; IOReturn io_err = IOObjectGetClass(hid_device, class_name); if (io_err != kIOReturnSuccess) return false; io_err = IOCreatePlugInInterfaceForService(hid_device, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugin_interface, &score); if (io_err != kIOReturnSuccess) return false; HRESULT plugin_err = (*plugin_interface)->QueryInterface(plugin_interface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (LPVOID *)(&(hid_dev->device_interface))); (*plugin_interface)->Release(plugin_interface); if (plugin_err != S_OK) return false; io_err = (*hid_dev->device_interface)->open(hid_dev->device_interface, 0); if (io_err != kIOReturnSuccess) return false; hid_dev->device_queue = allocDeviceQueue(hid_dev->device_interface, buffer_size); if (hid_dev->device_queue == NULL) { (*hid_dev->device_interface)->close(hid_dev->device_interface); return false; } hid_dev->cookie_map = CFDictionaryCreateMutable(NULL, 0, NULL, NULL); if (hid_dev->cookie_map == NULL) { closeDeviceAndQueue(hid_dev); return false; } searchDictionary(dict, hid_dev, num_cookies, hid_cookies); HRESULT err = (*hid_dev->device_queue)->start(hid_dev->device_queue); if (err != S_OK) { closeDeviceAll(hid_dev); return false; } return true; } bool findDevice(hid_device_t *hid_dev, long device_usage_page, long device_usage, int num_cookies, hid_cookie_t *hid_cookies, int buffer_size) { io_iterator_t device_iterator; io_object_t hid_device; kern_return_t kern_err; bool success = false; CFMutableDictionaryRef dev_props; 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 return false; } while (!success && (hid_device = IOIteratorNext(device_iterator)) != NULL) { kern_err = IORegistryEntryCreateCFProperties(hid_device, &dev_props, kCFAllocatorDefault, kNilOptions); if (kern_err == KERN_SUCCESS && dev_props != NULL) { long usage; long usage_page; if (getDictLong(dev_props, CFSTR(kIOHIDPrimaryUsageKey), &usage) && getDictLong(dev_props, CFSTR(kIOHIDPrimaryUsagePageKey), &usage_page) && usage_page == device_usage_page && usage == device_usage) { success = initDevice(hid_dev, hid_device, dev_props, num_cookies, hid_cookies, buffer_size); } CFRelease(dev_props); } IOObjectRelease(hid_device); if (success) break; } IOObjectRelease(device_iterator); return success; } void shutdownDevice(hid_device_t *hid_dev) { (*hid_dev->device_queue)->stop(hid_dev->device_queue); closeDeviceAll(hid_dev); } bool nextDeviceEvent(hid_device_t *hid_dev, hid_event_t *hid_event) { IOHIDEventStruct event; AbsoluteTime zero_time = {0, 0}; HRESULT err = (*hid_dev->device_queue)->getNextEvent(hid_dev->device_queue, &event, zero_time, 0); if (err != S_OK) return false; const void *mapped_index = CFDictionaryGetValue(hid_dev->cookie_map, event.elementCookie); hid_event->cookie_index = mapped_index; hid_event->value = (int)event.value; return true; } --- NEW FILE: hid.h --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/hid.h /* * Copyright (c) 2002 Light Weight Java Game Library Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of 'Light Weight Java Game Library' nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * $Id: hid.h,v 1.1 2003/10/21 15:11:59 elias_naur Exp $ * * Mac OS X HID tools. * * @author elias_naur <eli...@us...> * @version $Revision: 1.1 $ */ #ifndef _HID_H #define _HID_H #include <IOKit/IOKitLib.h> #include <IOKit/hid/IOHIDKeys.h> #include <IOKit/hid/IOHIDLib.h> #include <IOKit/hid/IOHIDUsageTables.h> #include <IOKit/IOCFPlugIn.h> #include <CoreServices/CoreServices.h> typedef struct { IOHIDDeviceInterface **device_interface; IOHIDQueueInterface **device_queue; CFMutableDictionaryRef cookie_map; } hid_device_t; typedef struct { long usage_page; long usage; } hid_cookie_t; typedef struct { int cookie_index; long value; } hid_event_t; extern void shutdownDevice(hid_device_t *hid_dev); extern bool findDevice(hid_device_t *hid_dev, long usage_page_match, long usage_match, int num_cookies, hid_cookie_t *device_cookies, int buffer_size); extern bool nextDeviceEvent(hid_device_t *hid_dev, hid_event_t *hid_event); #endif Index: Makefile.am CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/Makefile.am =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/Makefile.am,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- Makefile.am 15 Oct 2003 08:49:36 -0000 1.11 +++ Makefile.am 21 Oct 2003 15:11:59 -0000 1.12 @@ -8,8 +8,8 @@ org_lwjgl_Sys.cpp \ org_lwjgl_input_Controller.cpp \ org_lwjgl_input_Keyboard.cpp \ - org_lwjgl_opengl_MacOSX.cpp \ tools.cpp \ + hid.cpp \ org_lwjgl_input_Mouse.cpp \ org_lwjgl_input_Cursor.cpp \ org_lwjgl_opengl_Window.cpp Index: Window.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/Window.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Window.h 15 Oct 2003 08:49:36 -0000 1.6 +++ Window.h 21 Oct 2003 15:11:59 -0000 1.7 @@ -43,10 +43,8 @@ #define _LWJGL_WINDOW_H_INCLUDED_ #include <jni.h> - #include <Carbon/Carbon.h> extern void setQuitRequested(void); - extern bool registerKeyboardHandler(JNIEnv* env, WindowRef win_ref); -// extern bool registerMouseHandler(JNIEnv* env, WindowRef win_ref); - extern bool isMouseCreated(void); + extern void resetMode(JNIEnv *env); + extern void switchMode(JNIEnv *env, long width, long height, long bpp, long freq); #endif /* _LWJGL_WINDOW_H_INCLUDED_ */ Index: org_lwjgl_Display.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_Display.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_Display.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- org_lwjgl_Display.cpp 15 Oct 2003 11:49:24 -0000 1.20 +++ org_lwjgl_Display.cpp 21 Oct 2003 15:11:59 -0000 1.21 @@ -39,14 +39,24 @@ * @version $Revision$ */ +#include <ApplicationServices/ApplicationServices.h> #include "org_lwjgl_Display.h" #include "common_tools.h" #include "tools.h" static CFDictionaryRef original_mode; +static bool initialized = false; -static void init(JNIEnv *env, jclass clazz) { - original_mode = CGDisplayCurrentMode(kCGDirectMainDisplay); +static void saveMode(JNIEnv *env, long width, long height, long bpp, long freq) { + jclass display_class = env->FindClass("org/lwjgl/Display"); + jclass jclass_DisplayMode = env->FindClass("org/lwjgl/DisplayMode"); + jmethodID ctor = env->GetMethodID(jclass_DisplayMode, "<init>", "(IIII)V"); + jobject newMode = env->NewObject(jclass_DisplayMode, ctor, width, height, bpp, freq); + jfieldID fid_initialMode = env->GetStaticFieldID(display_class, "mode", "Lorg/lwjgl/DisplayMode;"); + env->SetStaticObjectField(display_class, fid_initialMode, newMode); +} + +static void saveOriginalMode(JNIEnv *env) { long width; long height; long bpp; @@ -55,15 +65,33 @@ getDictLong(original_mode, kCGDisplayHeight, &height); getDictLong(original_mode, kCGDisplayBitsPerPixel, &bpp); getDictLong(original_mode, kCGDisplayRefreshRate, &freq); - jclass jclass_DisplayMode = env->FindClass("org/lwjgl/DisplayMode"); - jmethodID ctor = env->GetMethodID(jclass_DisplayMode, "<init>", "(IIII)V"); - jobject newMode = env->NewObject(jclass_DisplayMode, ctor, width, height, bpp, freq); - jfieldID fid_initialMode = env->GetStaticFieldID(clazz, "mode", "Lorg/lwjgl/DisplayMode;"); - env->SetStaticObjectField(clazz, fid_initialMode, newMode); + saveMode(env, width, height, bpp, freq); +} + +static void init(JNIEnv *env) { + if (!initialized) { + initialized = true; + original_mode = CGDisplayCurrentMode(kCGDirectMainDisplay); + saveOriginalMode(env); + } +} + +void switchMode(JNIEnv *env, long width, long height, long bpp, long freq) { + init(env); + CGDisplayCapture(kCGDirectMainDisplay); + CFDictionaryRef displayMode = CGDisplayBestModeForParametersAndRefreshRate(kCGDirectMainDisplay, bpp, width, height, freq, NULL); + CGDisplaySwitchToMode(kCGDirectMainDisplay, displayMode); + saveMode(env, width, height, bpp, freq); +} + +void resetMode(JNIEnv *env) { + CGDisplaySwitchToMode(kCGDirectMainDisplay, original_mode); + CGDisplayRelease(kCGDirectMainDisplay); + saveOriginalMode(env); } JNIEXPORT void JNICALL Java_org_lwjgl_Display_init(JNIEnv * env, jclass clazz) { - init(env, clazz); + init(env); } JNIEXPORT void JNICALL Java_org_lwjgl_Display_setDisplayMode(JNIEnv * env, jclass clazz, jobject mode) { @@ -76,14 +104,7 @@ int height = env->GetIntField(mode, fid_height); int bpp = env->GetIntField(mode, fid_bpp); int freq = env->GetIntField(mode, fid_freq); - CGDisplayCapture(kCGDirectMainDisplay); - CFDictionaryRef displayMode = CGDisplayBestModeForParametersAndRefreshRate(kCGDirectMainDisplay, bpp, width, height, freq, NULL); - CGDisplaySwitchToMode(kCGDirectMainDisplay, displayMode); - - jmethodID ctor = env->GetMethodID(cls_displayMode, "<init>", "(IIII)V"); - jobject newMode = env->NewObject(cls_displayMode, ctor, width, height, bpp, freq); - jfieldID fid_initialMode = env->GetStaticFieldID(clazz, "mode", "Lorg/lwjgl/DisplayMode;"); - env->SetStaticObjectField(clazz, fid_initialMode, newMode); + switchMode(env, width, height, bpp, freq); } JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_Display_nGetAvailableDisplayModes(JNIEnv * env, jclass clazz) { @@ -130,9 +151,7 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_Display_resetDisplayMode(JNIEnv *env, jclass clazz) { - CGDisplaySwitchToMode(kCGDirectMainDisplay, original_mode); - CGDisplayRelease(kCGDirectMainDisplay); - init(env, clazz); + resetMode(env); } JNIEXPORT jstring JNICALL Java_org_lwjgl_Display_getAdapter(JNIEnv * , jclass) { 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.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- org_lwjgl_input_Keyboard.cpp 13 Oct 2003 11:54:44 -0000 1.14 +++ org_lwjgl_input_Keyboard.cpp 21 Oct 2003 15:11:59 -0000 1.15 @@ -39,19 +39,20 @@ * @version $Revision$ */ +#include "org_lwjgl_input_Keyboard.h" #include "Window.h" #include "tools.h" -#include "org_lwjgl_input_Keyboard.h" #include "common_tools.h" +#include "hid.h" #define KEYBOARD_SIZE 256 #define UNICODE_BUFFER_SIZE 10 static unsigned char key_buf[KEYBOARD_SIZE]; -static unsigned char key_map[KEYBOARD_SIZE]; static bool buffer_enabled = false; static bool translation_enabled = false; static event_queue_t event_queue; +static hid_device_t hid_dev; static bool handleMappedKey(unsigned char mapped_code, unsigned char state) { unsigned char old_state = key_buf[mapped_code]; @@ -60,12 +61,13 @@ if (buffer_enabled) { putEventElement(&event_queue, mapped_code); putEventElement(&event_queue, state); - return true; + return translation_enabled; } } return false; } +/* static bool handleKey(UInt32 key_code, unsigned char state) { if (key_code >= KEYBOARD_SIZE) { #ifdef _DEBUG @@ -146,7 +148,6 @@ #endif return eventNotHandledErr; } - lock(); if (handleKey(key_code, 1)) { if (translation_enabled) { if (!handleUnicode(event)) { @@ -158,7 +159,6 @@ putEventElement(&event_queue, 0); } } - unlock(); return noErr; } @@ -171,12 +171,10 @@ #endif return eventNotHandledErr; } - lock(); if (handleKey(key_code, 0)) { putEventElement(&event_queue, 0); putEventElement(&event_queue, 0); } - unlock(); return noErr; } @@ -211,13 +209,6 @@ return noErr; } -bool registerKeyboardHandler(JNIEnv* env, WindowRef win_ref) { - bool error = registerHandler(env, win_ref, doKeyUp, kEventClassKeyboard, kEventRawKeyUp); - error = error || registerHandler(env, win_ref, doKeyDown, kEventClassKeyboard, kEventRawKeyDown); - error = error || registerHandler(env, win_ref, doKeyModifier, kEventClassKeyboard, kEventRawKeyModifiersChanged); - return !error; -} - static void setupMappings(void) { memset(key_map, 0, KEYBOARD_SIZE*sizeof(unsigned char)); key_map[0x35] = org_lwjgl_input_Keyboard_KEY_ESCAPE; @@ -309,40 +300,195 @@ key_map[0x7d] = org_lwjgl_input_Keyboard_KEY_DOWN; key_map[0x79] = org_lwjgl_input_Keyboard_KEY_NEXT; } +*/ + +static void initCookie(hid_cookie_t *hid_cookies, int index, long usage) { + hid_cookies[index].usage_page = kHIDPage_KeyboardOrKeypad; + hid_cookies[index].usage = usage; +} + +static void initCookies(hid_cookie_t *hid_cookies) { + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_ESCAPE, kHIDUsage_KeyboardEscape); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_1, kHIDUsage_Keyboard1); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_2, kHIDUsage_Keyboard2); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_3, kHIDUsage_Keyboard3); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_4, kHIDUsage_Keyboard4); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_5, kHIDUsage_Keyboard5); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_6, kHIDUsage_Keyboard6); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_7, kHIDUsage_Keyboard7); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_8, kHIDUsage_Keyboard8); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_9, kHIDUsage_Keyboard9); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_0, kHIDUsage_Keyboard0); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_MINUS, kHIDUsage_KeyboardHyphen); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_EQUALS, kHIDUsage_KeyboardEqualSign); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_BACK, kHIDUsage_KeyboardDeleteOrBackspace); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_TAB, kHIDUsage_KeyboardTab); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_Q, kHIDUsage_KeyboardQ); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_W, kHIDUsage_KeyboardW); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_E, kHIDUsage_KeyboardE); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_R, kHIDUsage_KeyboardR); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_T, kHIDUsage_KeyboardT); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_Y, kHIDUsage_KeyboardY); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_U, kHIDUsage_KeyboardU); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_I, kHIDUsage_KeyboardI); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_O, kHIDUsage_KeyboardO); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_P, kHIDUsage_KeyboardP); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_LBRACKET, kHIDUsage_KeyboardOpenBracket); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_RBRACKET, kHIDUsage_KeyboardCloseBracket); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_RETURN, kHIDUsage_KeyboardReturnOrEnter); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_LCONTROL, kHIDUsage_KeyboardLeftControl); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_A, kHIDUsage_KeyboardA); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_S, kHIDUsage_KeyboardS); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_D, kHIDUsage_KeyboardD); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F, kHIDUsage_KeyboardF); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_G, kHIDUsage_KeyboardG); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_H, kHIDUsage_KeyboardH); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_J, kHIDUsage_KeyboardJ); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_K, kHIDUsage_KeyboardK); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_L, kHIDUsage_KeyboardL); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_SEMICOLON, kHIDUsage_KeyboardSemicolon); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_APOSTROPHE, kHIDUsage_KeyboardQuote); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_GRAVE, kHIDUsage_KeyboardGraveAccentAndTilde); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_LSHIFT, kHIDUsage_KeyboardLeftShift); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_BACKSLASH, kHIDUsage_KeyboardBackslash); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_Z, kHIDUsage_KeyboardZ); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_X, kHIDUsage_KeyboardX); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_C, kHIDUsage_KeyboardC); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_V, kHIDUsage_KeyboardV); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_B, kHIDUsage_KeyboardB); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_N, kHIDUsage_KeyboardN); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_M, kHIDUsage_KeyboardM); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_COMMA, kHIDUsage_KeyboardComma); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_PERIOD, kHIDUsage_KeyboardPeriod); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_SLASH, kHIDUsage_KeyboardSlash); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_RSHIFT, kHIDUsage_KeyboardRightShift); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_MULTIPLY, kHIDUsage_KeypadAsterisk); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_LMENU, kHIDUsage_KeyboardLeftGUI); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_SPACE, kHIDUsage_KeyboardSpacebar); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_CAPITAL, kHIDUsage_KeyboardCapsLock); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F1, kHIDUsage_KeyboardF1); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F2, kHIDUsage_KeyboardF2); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F3, kHIDUsage_KeyboardF3); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F4, kHIDUsage_KeyboardF4); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F5, kHIDUsage_KeyboardF5); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F6, kHIDUsage_KeyboardF6); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F7, kHIDUsage_KeyboardF7); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F8, kHIDUsage_KeyboardF8); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F9, kHIDUsage_KeyboardF9); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F10, kHIDUsage_KeyboardF10); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMLOCK, kHIDUsage_KeypadNumLock); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_SCROLL, kHIDUsage_KeyboardScrollLock); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD7, kHIDUsage_Keypad7); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD8, kHIDUsage_Keypad8); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD9, kHIDUsage_Keypad9); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_SUBTRACT, kHIDUsage_KeypadHyphen); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD4, kHIDUsage_Keypad4); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD5, kHIDUsage_Keypad5); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD6, kHIDUsage_Keypad6); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_ADD, kHIDUsage_KeypadPlus); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD1, kHIDUsage_Keypad1); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD2, kHIDUsage_Keypad2); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD3, kHIDUsage_Keypad3); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPAD0, kHIDUsage_Keypad0); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_DECIMAL, kHIDUsage_KeypadPeriod); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F11, kHIDUsage_KeyboardF11); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F12, kHIDUsage_KeyboardF12); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F13, kHIDUsage_KeyboardF13); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F14, kHIDUsage_KeyboardF14); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_F15, kHIDUsage_KeyboardF15); +/* initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_KANA, kHIDUsage_KeyboardKANA); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_CONVERT, kHIDUsage_KeyboardCONVERT); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NOCONVERT, kHIDUsage_KeyboardNOCONVERT); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_YEN, kHIDUsage_KeyboardYEN); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPADEQUALS, kHIDUsage_KeyboardNUMPADEQUALS); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_CIRCUMFLEX, kHIDUsage_KeyboardCIRCUMFLEX); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_AT, kHIDUsage_KeyboardAT); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_COLON, kHIDUsage_KeyboardCOLON); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_UNDERLINE, kHIDUsage_KeyboardUNDERLINE); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_KANJI, kHIDUsage_KeyboardKANJI); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_STOP, kHIDUsage_KeyboardSTOP); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_AX, kHIDUsage_KeyboardAX); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_UNLABELED, kHIDUsage_KeyboardUNLABELED);*/ + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPADENTER, kHIDUsage_KeypadEnter); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_RCONTROL, kHIDUsage_KeyboardRightControl); +// initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NUMPADCOMMA, kHIDUsage_KeyboardNUMPADCOMMA); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_DIVIDE, kHIDUsage_KeypadSlash); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_SYSRQ, kHIDUsage_KeyboardSysReqOrAttention); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_RMENU, kHIDUsage_KeyboardRightGUI); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_PAUSE, kHIDUsage_KeyboardPause); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_HOME, kHIDUsage_KeyboardHome); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_UP, kHIDUsage_KeyboardUpArrow); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_PRIOR, kHIDUsage_KeyboardPageUp); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_LEFT, kHIDUsage_KeyboardLeftArrow); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_RIGHT, kHIDUsage_KeyboardRightArrow); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_END, kHIDUsage_KeyboardEnd); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_DOWN, kHIDUsage_KeyboardDownArrow); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_NEXT, kHIDUsage_KeyboardPageDown); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_INSERT, kHIDUsage_KeyboardInsert); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_DELETE, kHIDUsage_KeyboardDeleteForward); +/* initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_LWIN, kHIDUsage_KeyboardLWIN); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_RWIN, kHIDUsage_KeyboardRWIN);*/ + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_APPS, kHIDUsage_KeyboardApplication); + initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_POWER, kHIDUsage_KeyboardPower); + //initCookie(hid_cookies, org_lwjgl_input_Keyboard_KEY_SLEEP, kHIDUsage_KeyboardSleep); +} + +static void pollKeyboardDevice(void) { + hid_event_t event; + while (nextDeviceEvent(&hid_dev, &event)) { + if (event.cookie_index >= KEYBOARD_SIZE) { +#ifdef _DEBUG + printf("Uknown key code\n"); +#endif + return; + } + unsigned char key_code = (unsigned char)event.cookie_index; + unsigned char state = event.value != 0 ? 1 : 0; + if (handleMappedKey(key_code, state)) { + putEventElement(&event_queue, 0); + putEventElement(&event_queue, 0); + } + } +} JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_initIDs(JNIEnv * env, jclass clazz) { } JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nCreate(JNIEnv * env, jclass clazz) { - lock(); buffer_enabled = false; translation_enabled = false; initEventQueue(&event_queue); memset(key_buf, 0, KEYBOARD_SIZE*sizeof(unsigned char)); - setupMappings(); - unlock(); + hid_cookie_t hid_cookies[KEYBOARD_SIZE]; + for (int i = 0; i < KEYBOARD_SIZE; i++) { + hid_cookies[i].usage_page = kHIDPage_Undefined; + hid_cookies[i].usage = kHIDUsage_Undefined; + } + initCookies(hid_cookies); + if (!findDevice(&hid_dev, kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard, KEYBOARD_SIZE, hid_cookies, EVENT_BUFFER_SIZE)) { + throwException(env, "Could not find a keyboard device"); + return; + } } JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nDestroy(JNIEnv * env, jclass clazz) { + shutdownDevice(&hid_dev); } JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_nPoll(JNIEnv * env, jclass clazz, jobject buffer) { + pollKeyboardDevice(); unsigned char *new_keyboard_buffer = (unsigned char *)env->GetDirectBufferAddress(buffer); - lock(); memcpy(new_keyboard_buffer, key_buf, KEYBOARD_SIZE*sizeof(unsigned char)); - unlock(); } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Keyboard_nRead(JNIEnv * env, jclass clazz) { int num_events = 0; - lock(); int event_size; if (translation_enabled) event_size = 4; else event_size = 2; num_events = copyEvents(&event_queue, event_size); - unlock(); return num_events; } 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.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- org_lwjgl_input_Mouse.cpp 15 Oct 2003 11:44:04 -0000 1.14 +++ org_lwjgl_input_Mouse.cpp 21 Oct 2003 15:11:59 -0000 1.15 @@ -39,18 +39,15 @@ * @version $Revision$ */ -#include <IOKit/IOKitLib.h> -#include <IOKit/hid/IOHIDKeys.h> -#include <IOKit/hid/IOHIDLib.h> -#include <IOKit/hid/IOHIDUsageTables.h> -#include <IOKit/IOCFPlugIn.h> +#include <ApplicationServices/ApplicationServices.h> +#include "org_lwjgl_input_Mouse.h" #include "Window.h" #include "tools.h" #include "common_tools.h" -#include "org_lwjgl_input_Mouse.h" -#include "common_tools.h" +#include "hid.h" -#define NUM_BUTTONS 7 +static const int NUM_BUTTONS = 7; +static const int NUM_COOKIES = NUM_BUTTONS + 3; static jfieldID fid_dx; static jfieldID fid_dy; @@ -58,237 +55,18 @@ static jfieldID fid_buttons; static unsigned char button_states[NUM_BUTTONS]; -/*static int last_x; -static int last_y;*/ -//static bool native_cursor; static bool created; static bool buffer_enabled; -static IOHIDDeviceInterface **device_interface; -static IOHIDQueueInterface **device_queue; -static IOHIDElementCookie x_axis_cookie; -static IOHIDElementCookie y_axis_cookie; -static IOHIDElementCookie z_axis_cookie; -static IOHIDElementCookie button_cookies[NUM_BUTTONS]; - +static int x_axis_index = NUM_BUTTONS; +static int y_axis_index = NUM_BUTTONS + 1; +static int z_axis_index = NUM_BUTTONS + 2; +static hid_device_t hid_dev; static event_queue_t event_queue; static int last_dx; static int last_dy; static int last_dz; -static void searchDictionary(CFDictionaryRef dict); -static void searchObject(CFTypeRef object); - -bool isMouseCreated(void) { - return created/* && !native_cursor*/; -} - -/*static pascal OSStatus doMouseMoved(EventHandlerCallRef next_handler, EventRef event, void *user_data) { -printf("Mouse moved\n"); - return eventNotHandledErr; // allow the event to propagate -} - -static pascal OSStatus doMouseDown(EventHandlerCallRef next_handler, EventRef event, void *user_data) { -printf("Mouse down\n"); - lock(); - unlock(); - return eventNotHandledErr; // allow the event to propagate -} - -static pascal OSStatus doMouseUp(EventHandlerCallRef next_handler, EventRef event, void *user_data) { -printf("Mouse up\n"); - lock(); - unlock(); - return eventNotHandledErr; // allow the event to propagate -} - -static pascal OSStatus doMouseWheel(EventHandlerCallRef next_handler, EventRef event, void *user_data) { -printf("Mouse wheel\n"); - lock(); - unlock(); - return noErr; -} - -bool registerMouseHandler(JNIEnv* env, WindowRef win_ref) { - bool error = registerHandler(env, win_ref, doMouseDown, kEventClassMouse, kEventMouseDown); - error = error || registerHandler(env, win_ref, doMouseUp, kEventClassMouse, kEventMouseUp); - //error = error || registerHandler(env, win_ref, doMouseMoved, kEventClassMouse, kEventMouseMoved); - error = error || registerHandler(env, win_ref, doMouseWheel, kEventClassMouse, kEventMouseWheelMoved); - return !error; -} -*/ -/*static void printCFString(CFStringRef str) { - CFIndex buffer_size = CFStringGetLength(str) + 1; - char * buffer = (char *)malloc(buffer_size); - if (buffer != NULL) { - if (CFStringGetCString(str, buffer, buffer_size, CFStringGetSystemEncoding())) - printf("%s", buffer); - free(buffer); - } -} - -static void printCFNumber(CFNumberRef num) { - long number; - - if (CFNumberGetValue(num, kCFNumberLongType, &number)) - printf("0x%lx (%ld)", number, number); -} -*/ - -/*static void printProperty(CFDictionaryRef dict, CFStringRef key) { - CFTypeRef val = CFDictionaryGetValue(dict, key); - if (val != NULL) { - CFTypeID type = CFGetTypeID(val); - if (type == CFArrayGetTypeID()) printf("array\n"); - else if (type == CFBooleanGetTypeID()) printf("boolean\n"); - else if (type == CFDictionaryGetTypeID()) printf("dictionary\n"); - else if (type == CFNumberGetTypeID()) printCFNumber((CFNumberRef)val); - else if (type == CFStringGetTypeID()) printCFString((CFStringRef)val); - else printf("<unknown object type>\n"); - } -} -*/ -static void closeDevice(void) { - (*device_queue)->dispose(device_queue); - (*device_queue)->Release(device_queue); - (*device_interface)->close(device_interface); -} - -static void shutdownDevice(void) { - (*device_queue)->stop(device_queue); - closeDevice(); -} - -static bool allocDeviceQueue(void) { - device_queue = (*device_interface)->allocQueue(device_interface); - if (device_queue == NULL) - return false; - HRESULT err = (*device_queue)->create(device_queue, 0, EVENT_BUFFER_SIZE); - if (err != S_OK) { - (*device_queue)->Release(device_queue); - return false; - } - return true; -} - -static void searchArrayElement(const void * value, void * parameter) { - searchObject((CFTypeRef)value); -} - -static void searchArray(CFArrayRef array) { - CFRange range = {0, CFArrayGetCount(array)}; - CFArrayApplyFunction(array, range, searchArrayElement, 0); -} - -static void searchObject(CFTypeRef object) { - CFTypeID type = CFGetTypeID(object); - if (type == CFArrayGetTypeID()) searchArray((CFArrayRef)object); - else if (type == CFDictionaryGetTypeID()) searchDictionary((CFDictionaryRef)object); - else printf("<unknown object>\n"); -} - -static void searchDictionaryElement(CFDictionaryRef dict, CFStringRef key) { - CFTypeRef object = CFDictionaryGetValue(dict, key); - if (object != NULL) - searchObject(object); -} - -static void addToDeviceQueue(IOHIDElementCookie cookie) { - HRESULT result = (*device_queue)->addElement(device_queue, cookie, 0); - if (result != S_OK) { -#ifdef _DEBUG - printf("Could not add cookie to queue\n"); -#endif - } -} - -static void testCookie(long usage_page, long usage, IOHIDElementCookie cookie, IOHIDElementCookie *store_cookie, long desired_usage_page, long desired_usage) { - if (usage_page == desired_usage_page && usage == desired_usage && *store_cookie == NULL) { - *store_cookie = cookie; - addToDeviceQueue(cookie); - } -} - -static void searchDictionary(CFDictionaryRef dict) { - searchDictionaryElement(dict, CFSTR(kIOHIDElementKey)); - long cookie_num; - long usage; - long usage_page; - if (!getDictLong(dict, CFSTR(kIOHIDElementCookieKey), &cookie_num) || - !getDictLong(dict, CFSTR(kIOHIDElementUsageKey), &usage) || - !getDictLong(dict, CFSTR(kIOHIDElementUsagePageKey), &usage_page)) - return; - testCookie(usage_page, usage, (IOHIDElementCookie)cookie_num, &x_axis_cookie, kHIDPage_GenericDesktop, kHIDUsage_GD_X); - testCookie(usage_page, usage, (IOHIDElementCookie)cookie_num, &y_axis_cookie, kHIDPage_GenericDesktop, kHIDUsage_GD_Y); - testCookie(usage_page, usage, (IOHIDElementCookie)cookie_num, &z_axis_cookie, kHIDPage_GenericDesktop, kHIDUsage_GD_Wheel); - for (int i = 0; i < NUM_BUTTONS; i++) - testCookie(usage_page, usage, (IOHIDElementCookie)cookie_num, &button_cookies[i], kHIDPage_Button, i + 1); -} - -static bool initDevice(io_object_t hid_device, CFDictionaryRef dict) { - io_name_t class_name; - IOCFPlugInInterface **plugin_interface; - SInt32 score; - IOReturn io_err = IOObjectGetClass(hid_device, class_name); - if (io_err != kIOReturnSuccess) - return false; - io_err = IOCreatePlugInInterfaceForService(hid_device, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugin_interface, &score); - if (io_err != kIOReturnSuccess) - return false; - HRESULT plugin_err = (*plugin_interface)->QueryInterface(plugin_interface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (LPVOID *)(&device_interface)); - (*plugin_interface)->Release(plugin_interface); - if (plugin_err != S_OK) - return false; - io_err = (*device_interface)->open(device_interface, 0); - if (io_err != kIOReturnSuccess) - return false; - if (!allocDeviceQueue()) { - (*device_interface)->close(device_interface); - return false; - } - searchDictionary(dict); - HRESULT err = (*device_queue)->start(device_queue); - if (err != S_OK) { - closeDevice(); - return false; - } - return true; -} - -static bool findDevice(void) { - io_iterator_t device_iterator; - io_object_t hid_device; - kern_return_t kern_err; - bool success = false; - CFMutableDictionaryRef dev_props; - CFMutableDictionaryRef 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 - return false; - } - while (!success && (hid_device = IOIteratorNext(device_iterator)) != NULL) { - kern_err = IORegistryEntryCreateCFProperties(hid_device, &dev_props, kCFAllocatorDefault, kNilOptions); - if (kern_err == KERN_SUCCESS && dev_props != NULL) { - long usage; - long usage_page; - if (getDictLong(dev_props, CFSTR(kIOHIDPrimaryUsageKey), &usage) && - getDictLong(dev_props, CFSTR(kIOHIDPrimaryUsagePageKey), &usage_page) && - usage_page == kHIDPage_GenericDesktop && usage == kHIDUsage_GD_Mouse) { - success = initDevice(hid_device, dev_props); - } - CFRelease(dev_props); - } - IOObjectRelease(hid_device); - if (success) - break; - } - IOObjectRelease(device_iterator); - return success; -} - static void handleButton(unsigned char button_index, unsigned char state) { button_states[button_index] = state; if (buffer_enabled) { @@ -297,31 +75,30 @@ } } -static void pollDevice() { - IOHIDEventStruct event; - AbsoluteTime zero_time = {0, 0}; +static void pollMouseDevice() { + hid_event_t event; cont: - while ((*device_queue)->getNextEvent(device_queue, &event, zero_time, 0) == S_OK) { - IOHIDElementCookie cookie = event.elementCookie; - if (cookie == x_axis_cookie) { + while (nextDeviceEvent(&hid_dev, &event)) { + if (event.cookie_index == x_axis_index) { last_dx += event.value; continue; } - if (cookie == y_axis_cookie) { + else if (event.cookie_index == y_axis_index) { last_dy += event.value; continue; } - if (cookie == z_axis_cookie) { + else if (event.cookie_index == z_axis_index) { last_dz += event.value; continue; - } - for (int i = 0; i < NUM_BUTTONS; i++) { - if (cookie == button_cookies[i]) { - if (event.value != 0) - handleButton(i, 1); - else - handleButton(i, 0); - goto cont; + } else { + for (int i = 0; i < NUM_BUTTONS; i++) { + if (event.cookie_index == i) { + if (event.value != 0) + handleButton(i, 1); + else + handleButton(i, 0); + goto cont; + } } } #ifdef _DEBUG @@ -369,16 +146,23 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nCreate(JNIEnv * env, jclass clazz) { // native_cursor = false; buffer_enabled = false; - x_axis_cookie = NULL; - y_axis_cookie = NULL; - z_axis_cookie = NULL; resetDeltas(); for (int i = 0; i < NUM_BUTTONS; i++) { button_states[i] = 0; - button_cookies[i] = NULL; } initEventQueue(&event_queue); - if (!findDevice()) { + hid_cookie_t hid_cookies[NUM_COOKIES]; + for (int i = 0; i < NUM_BUTTONS; i++) { + hid_cookies[i].usage_page = kHIDPage_Button; + hid_cookies[i].usage = i + 1; + } + hid_cookies[x_axis_index].usage_page = kHIDPage_GenericDesktop; + hid_cookies[x_axis_index].usage = kHIDUsage_GD_X; + hid_cookies[y_axis_index].usage_page = kHIDPage_GenericDesktop; + hid_cookies[y_axis_index].usage = kHIDUsage_GD_Y; + hid_cookies[z_axis_index].usage_page = kHIDPage_GenericDesktop; + hid_cookies[z_axis_index].usage = kHIDUsage_GD_Wheel; + if (!findDevice(&hid_dev, kHIDPage_GenericDesktop, kHIDUsage_GD_Mouse, NUM_COOKIES, hid_cookies, EVENT_BUFFER_SIZE)) { throwException(env, "Could not find HID muse device"); return; } @@ -388,7 +172,7 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nDestroy(JNIEnv * env, jclass clazz) { - shutdownDevice(); + shutdownDevice(&hid_dev); // if (!native_cursor) { CGAssociateMouseAndMouseCursorPosition(TRUE); CGDisplayShowCursor(CGMainDisplayID()); @@ -398,7 +182,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nPoll(JNIEnv * env, jclass clazz) { int dx, dy, dz; - pollDevice(); + pollMouseDevice(); dz = last_dz; //if (!native_cursor) { dx = last_dx; @@ -426,6 +210,6 @@ } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nRead(JNIEnv *env, jclass clazz) { - pollDevice(); + pollMouseDevice(); return copyEvents(&event_queue, 2); } Index: org_lwjgl_opengl_Window.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- org_lwjgl_opengl_Window.cpp 16 Oct 2003 13:56:22 -0000 1.23 +++ org_lwjgl_opengl_Window.cpp 21 Oct 2003 15:11:59 -0000 1.24 @@ -39,167 +39,27 @@ * @version $Revision$ */ -#include "Window.h" -#include <QuickTime/Movies.h> #include <OpenGL/OpenGL.h> #include "org_lwjgl_opengl_Window.h" +#include "Window.h" #include "extgl.h" #include "tools.h" #include "common_tools.h" -static WindowRef win_ref; -static AGLContext windowed_context; -static CGLContextObj fullscreen_context; -static bool close_requested; -static Ptr fullscreen_ptr; +static CGLContextObj context; +static bool vsync_enabled; static bool current_fullscreen; -static bool miniaturized; -static bool activated; -static int center_x; -static int center_y; -static void setWindowTitle(JNIEnv *env, jstring title_obj) { - const char* title = env->GetStringUTFChars(title_obj, NULL); - CFStringRef cf_title = CFStringCreateWithCString(NULL, title, kCFStringEncodingUTF8); - if (cf_title == NULL) { -#ifdef _DEBUG - printf("Could not set window title\n"); -#endif - return; - } - SetWindowTitleWithCFString(win_ref, cf_title); - CFRelease(cf_title); - env->ReleaseStringUTFChars(title_obj, title); -} - -void setQuitRequested(void) { - lock(); - close_requested = true; - unlock(); -} - -static pascal OSStatus doMiniaturized(EventHandlerCallRef next_handler, EventRef event, void *user_data) { - lock(); - miniaturized = true; - unlock(); - return eventNotHandledErr; -} - -static pascal OSStatus doMaximize(EventHandlerCallRef next_handler, EventRef event, void *user_data) { - lock(); - miniaturized = false; - unlock(); - return eventNotHandledErr; -} - -static void warpCursorToCenter(void) { - CGPoint p = {center_x, center_y}; - CGWarpMouseCursorPosition(p); -} - -static pascal OSStatus doActivate(EventHandlerCallRef next_handler, EventRef event, void *user_data) { - lock(); - miniaturized = false; - activated = true; - if (isMouseCreated()) - warpCursorToCenter(); - unlock(); - return eventNotHandledErr; -} - -static pascal OSStatus doDeactivate(EventHandlerCallRef next_handler, EventRef event, void *user_data) { - lock(); - activated = false; - unlock(); - return eventNotHandledErr; -} - -static pascal OSStatus doQuit(EventHandlerCallRef next_handler, EventRef event, void *user_data) { - setQuitRequested(); - return noErr; -} - -static pascal OSStatus doBoundsChanged(EventHandlerCallRef next_handler, EventRef event, void *user_data) { - Rect rect; - OSStatus err = GetEventParameter(event, kEventParamCurrentBounds, typeQDRectangle, NULL, sizeof(rect), NULL, &rect); - if (err != noErr) { -#ifdef _DEBUG - printf("Could not get bounds from bounds changed event\n"); -#endif - return eventNotHandledErr; - } - lock(); - center_x = (rect.left + rect.right)/2; - center_y = (rect.top + rect.bottom)/2; - unlock(); - return noErr; -} - -static bool registerEventHandlers(JNIEnv *env) { - bool error; - error = registerHandler(env, win_ref, doQuit, kEventClassWindow, kEventWindowClose); - error = error || registerHandler(env, win_ref, doActivate, kEventClassWindow, kEventWindowActivated); - error = error || registerHandler(env, win_ref, doDeactivate, kEventClassWindow, kEventWindowDeactivated); - error = error || registerHandler(env, win_ref, doMiniaturized, kEventClassWindow, kEventWindowCollapsed); - error = error || registerHandler(env, win_ref, doMaximize, kEventClassWindow, kEventWindowExpanded); - error = error || registerHandler(env, win_ref, doBoundsChanged, kEventClassWindow, kEventWindowBoundsChanged); - return !error && registerKeyboardHandler(env, win_ref)/* && registerMouseHandler(env, win_ref)*/; -} - -static void destroyWindow(void) { - if (current_fullscreen) - EndFullScreen(fullscreen_ptr, 0); - else - DisposeWindow(win_ref); +static void destroyMode(JNIEnv *env, jclass clazz) { + if (current_fullscreen); + resetMode(env); } -static void destroy(void) { - if (current_fullscreen) { - CGLSetCurrentContext(NULL); - CGLDestroyContext(fullscreen_context); - } else { - aglSetCurrentContext(NULL); - aglDestroyContext(windowed_context); - } - destroyWindow(); +static void destroy(JNIEnv *env, jclass clazz) { + CGLSetCurrentContext(NULL); + CGLDestroyContext(context); + destroyMode(env, clazz); extgl_Close(); - destroyLock(); -} - -static bool createWindowedContext(JNIEnv *env, jint bpp, jint alpha, jint depth, jint stencil) { - AGLDrawable drawable = GetWindowPort(win_ref); - SetPort(drawable); - GLint attrib[] = {AGL_RGBA, - AGL_DOUBLEBUFFER, - AGL_ACCELERATED, - AGL_MINIMUM_POLICY, - AGL_PIXEL_SIZE, bpp, - AGL_DEPTH_SIZE, depth, - AGL_ALPHA_SIZE, alpha, - AGL_STENCIL_SIZE, stencil, - AGL_NONE}; - AGLPixelFormat format = aglChoosePixelFormat(NULL, 0, attrib); - if (format == NULL) { - throwException(env, "Could not find matching pixel format"); - return false; - } - windowed_context = aglCreateContext (format, NULL); - aglDestroyPixelFormat(format); - if (windowed_context == NULL) { - throwException(env, "Could not create context"); - return false; - } - if (aglSetDrawable(windowed_context, drawable) == GL_FALSE) { - aglDestroyContext(windowed_context); - throwException(env, "Could not attach context"); - return false; - } - if (aglSetCurrentContext(windowed_context) == GL_FALSE) { - aglDestroyContext(windowed_context); - throwException(env, "Could not set current context"); - return false; - } - return true; } static bool createFullscreenContext(JNIEnv *env, jint bpp, jint alpha, jint depth, jint stencil) { @@ -226,39 +86,24 @@ throwException(env, "Could not find matching pixel format"); return false; } - CGLCreateContext(pixel_format, NULL, &fullscreen_context); + CGLCreateContext(pixel_format, NULL, &context); CGLDestroyPixelFormat(pixel_format); - if (fullscreen_context == NULL) { + if (context == NULL) { throwException(env, "Could not create fullscreen context"); return false; } - CGLSetFullScreen(fullscreen_context); - CGLSetCurrentContext(fullscreen_context); + CGLSetFullScreen(context); + CGLSetCurrentContext(context); return true; } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsCloseRequested(JNIEnv *, jclass) { - bool saved; - lock(); - saved = close_requested; - close_requested = false; - unlock(); - return saved; + return JNI_FALSE; } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nCreate(JNIEnv *env, jclass clazz, jstring title, jint x, jint y, jint width, jint height, jboolean fullscreen, jint bpp, jint alpha, jint depth, jint stencil, jobject ext_set) { - Rect rect; - OSStatus status; - const WindowAttributes window_attr = kWindowCloseBoxAttribute| - kWindowCollapseBoxAttribute| - kWindowStandardHandlerAttribute; - SetRect(&rect, x, y, x + width, y + height); - center_x = x + width/2; - center_y = y + height/2; - current_fullscreen = fullscreen == JNI_TRUE; - miniaturized = false; - activated = true; - close_requested = false; + vsync_enabled = false; + current_fullscreen = fullscreen == JNI_FALSE; if (!extgl_Open()) { throwException(env, "Could not load gl library"); return; @@ -268,65 +113,27 @@ return; } if (current_fullscreen) - status = BeginFullScreen(&fullscreen_ptr, NULL, NULL, NULL, &win_ref, NULL, 0); - else - status = CreateNewWindow(kDocumentWindowClass, window_attr, &rect, &win_ref); - if (noErr != status) { - extgl_Close(); - throwException(env, "Could not create window"); - return; - } - if (!initLock(env)) { - destroyWindow(); - extgl_Close(); - return; - } - if (!registerEventHandlers(env)) { - destroyWindow(); - extgl_Close(); - return; - } - setWindowTitle(env, title); - const RGBColor background_color = {0, 0, 0}; - SetWindowContentColor(win_ref, &background_color); - bool success; - if (current_fullscreen) { - success = createFullscreenContext(env, bpp, alpha, depth, stencil); - } else { - success = createWindowedContext(env, bpp, alpha, depth, stencil); - } - if (!success) { - destroyLock(); - destroyWindow(); + switchMode(env, width, height, bpp, 60); + if (!createFullscreenContext(env, bpp, alpha, depth, stencil)) { + destroyMode(env, clazz); extgl_Close(); return; } if (!extgl_Initialize(env, ext_set)) { - destroy(); + destroy(env, clazz); throwException(env, "Could not load gl function pointers"); return; } - ShowWindow(win_ref); - SelectWindow(win_ref); - warpCursorToCenter(); - CGPoint p = {center_x, center_y}; - CGPostMouseEvent(p, FALSE, 1, TRUE); - CGPostMouseEvent(p, FALSE, 1, FALSE); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nSetTitle(JNIEnv * env, jclass clazz, jstring title_obj) { - setWindowTitle(env, title_obj); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_update(JNIEnv *env, jclass clazz) { } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_swapBuffers(JNIEnv * env, jclass clazz) { - if (current_fullscreen) { - CGLFlushDrawable(fullscreen_context); - } else { - aglSwapBuffers(windowed_context); - } + CGLFlushDrawable(context); } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_minimize(JNIEnv *env, jclass clazz) { @@ -336,15 +143,11 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nDestroy(JNIEnv *env, jclass clazz) { - destroy(); + destroy(env, clazz); } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsFocused(JNIEnv *env, jclass clazz) { - bool result; - lock(); - result = activated; - unlock(); - return result; + return JNI_TRUE; } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsDirty(JNIEnv *env, jclass clazz) { @@ -352,9 +155,18 @@ } JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsMinimized(JNIEnv *env, jclass clazz) { - bool result; - lock(); - result = miniaturized; - unlock(); - return result; + return JNI_FALSE; +} + +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsVSyncEnabled(JNIEnv *env, jclass clazz) { + return vsync_enabled; +} + +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nSetVSyncEnabled(JNIEnv *env, jclass clazz, jboolean enable) { + bool should_enable = enable == JNI_TRUE; + if (vsync_enabled != should_enable) { + vsync_enabled = should_enable; + long swap_interval = vsync_enabled ? 1 : 0; + CGLSetParameter(context, kCGLCPSwapInterval, &swap_interval); + } } Index: tools.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/tools.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/tools.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- tools.cpp 15 Oct 2003 11:44:05 -0000 1.8 +++ tools.cpp 21 Oct 2003 15:11:59 -0000 1.9 @@ -14,53 +14,3 @@ } return false; } - -bool registerHandler(JNIEnv* env, WindowRef win_ref, EventHandlerProcPtr func, UInt32 event_class, UInt32 event_kind) { - EventTypeSpec event_type; - EventHandlerUPP handler_upp = NewEventHandlerUPP(func); - event_type.eventClass = event_class; - event_type.eventKind = event_kind; - OSStatus err = InstallWindowEventHandler(win_ref, handler_upp, 1, &event_type, NULL, NULL); - DisposeEventHandlerUPP(handler_upp); - if (noErr != err) { - throwException(env, "Could not register window event handler"); - return true; - } - return false; -} - -bool initLock(JNIEnv* env) { - OSStatus err = MPCreateCriticalRegion(&critical_region); - if (err != noErr) { - throwException(env, "Could not init lock"); - return false; - } - return true; -} - -void destroyLock(void) { - OSStatus err = MPDeleteCriticalRegion(critical_region); - if (err != noErr) { -#ifdef _DEBUG - printf("Could not delete lock\n"); -#endif - } -} - -void lockLWJGL(void) { - OSStatus err = MPEnterCriticalRegion(critical_region, kDurationForever); - if (err != noErr) { -#ifdef _DEBUG - printf("Could not lock\n"); -#endif - } -} - -void unlockLWJGL(void) { - OSStatus err = MPExitCriticalRegion(critical_region); - if (err != noErr) { -#ifdef _DEBUG - printf("Could not unlock\n"); -#endif - } -} Index: tools.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/tools.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/tools.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- tools.h 15 Oct 2003 11:44:05 -0000 1.8 +++ tools.h 21 Oct 2003 15:11:59 -0000 1.9 @@ -2,16 +2,11 @@ #define TOOLS_H #include <JavaVM/jni.h> -#include <Carbon/Carbon.h> +#include <CoreFoundation/CoreFoundation.h> #define lock() {lockLWJGL(); #define unlock() unlockLWJGL();} extern bool getDictLong(CFDictionaryRef dict, CFStringRef key, long *key_value); -extern bool registerHandler(JNIEnv* env, WindowRef win_ref, EventHandlerProcPtr func, UInt32 event_class, UInt32 event_kind); -extern bool initLock(JNIEnv* env); -extern void destroyLock(void); -extern void lockLWJGL(void); -extern void unlockLWJGL(void); #endif --- org_lwjgl_opengl_MacOSX.cpp DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_MacOSX.cpp --- org_lwjgl_opengl_MacOSX.h DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_MacOSX.h |
|
From: Elias N. <eli...@us...> - 2003-10-21 17:11:48
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl In directory sc8-pr-cvs1:/tmp/cvs-serv14892/src/java/org/lwjgl/test/opengl Modified Files: FullScreenWindowedTest.java Log Message: Index: FullScreenWindowedTest.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/FullScreenWindowedTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/FullScreenWindowedTest.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- FullScreenWindowedTest.java 20 Oct 2003 14:17:47 -0000 1.20 +++ FullScreenWindowedTest.java 21 Oct 2003 15:11:58 -0000 1.21 @@ -140,6 +140,7 @@ } } } + Display.resetDisplayMode(); } /** @@ -292,7 +293,7 @@ for (int i = 0; i < modes.length; i++) { if (modes[i].width == width && modes[i].height == height - && modes[i].bpp >= bpp) { + && modes[i].bpp >= bpp && modes[i].freq <= 60) { return modes[i]; } } |
|
From: Elias N. <eli...@us...> - 2003-10-21 16:30:53
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1:/tmp/cvs-serv14892/src/java/org/lwjgl/opengl Modified Files: Window.java Removed Files: MacOSX.java Log Message: Index: Window.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Window.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Window.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- Window.java 20 Oct 2003 14:17:47 -0000 1.15 +++ Window.java 21 Oct 2003 15:11:58 -0000 1.16 @@ -30,32 +30,6 @@ static { System.loadLibrary(Sys.getLibraryName()); - /* - * elias: Mac OS X hacks. We need to fetch the toolkit to acquire a Dock icon, a system menu - * and to make windows behave normally. We also need to intercept the quit event from - * Swing. Luckily, Swing can be assumed to be present on Mac OS X. Because some of this - * is apple extensions to java, we need stub files to successfully compile on other platforms. - * - * Additionally, because of the way swing works, applications now need to do an - * explicit System.exit() to quit. Returning from the main thread is not enough any - * more. - * - * I've wasted a significant amount of time searching for an acceptable solution, without - * finding a way to avoid Swing. AFAIK, - * - * 1. There's no way to acquire the Dock icon, system menu and normal window behaviour. - * For that, you either need a proper bundled, native application or initialize Swing. - * 2. Even if there were a way around it, Swing is automatically started anyway if you - * use Java Web Start. - * 3. Swing gains total control over the main event loop, so the native library need to - * work around by maintaining an internal event queue. That's really boring stuff, indeed. - * - * I have posted a bug report to apple regarding the behaviour. - * - */ - if (Display.getPlatform() == Display.PLATFORM_AGL) { - MacOSX.initMacOSX(); - } } /** Whether the window is currently created, ie. has a native peer */ --- MacOSX.java DELETED --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/MacOSX.java |
|
From: Elias N. <eli...@us...> - 2003-10-21 16:00:52
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1:/tmp/cvs-serv14892/src/native/common Modified Files: extal.cpp Log Message: Index: extal.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/extal.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/extal.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- extal.cpp 8 Sep 2003 14:40:46 -0000 1.9 +++ extal.cpp 21 Oct 2003 15:11:59 -0000 1.10 @@ -127,7 +127,8 @@ void* handleOAL; #endif #ifdef _AGL -#include <Carbon/Carbon.h> +#include <CoreFoundation/CoreFoundation.h> +#include <CoreServices/CoreServices.h> OSStatus oalInitEntryPoints (void); void oalDellocEntryPoints (void); CFBundleRef handleOAL = NULL; |
|
From: Caspian Rychlik-P. <ci...@us...> - 2003-10-20 19:54:34
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1:/tmp/cvs-serv6988/src/java/org/lwjgl/opengl Modified Files: GLCaps.java Log Message: Added ARB_texture_non_power_of_two Index: GLCaps.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/GLCaps.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/GLCaps.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- GLCaps.java 10 Oct 2003 14:18:20 -0000 1.9 +++ GLCaps.java 20 Oct 2003 14:22:03 -0000 1.10 @@ -67,6 +67,7 @@ public static boolean GL_ARB_texture_border_clamp; public static boolean GL_ARB_texture_cube_map; public static boolean GL_ARB_texture_mirrored_repeat; + public static boolean GL_ARB_texture_non_power_of_two; public static boolean GL_ARB_transpose_matrix; public static boolean GL_ARB_vertex_blend; public static boolean GL_ARB_vertex_program; |
|
From: Caspian Rychlik-P. <ci...@us...> - 2003-10-20 19:33:04
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1:/tmp/cvs-serv10129/src/java/org/lwjgl/opengl Modified Files: GLConstants.java GLCaps.java Log Message: EXT_texture_rectangle added Index: GLConstants.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/GLConstants.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/GLConstants.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- GLConstants.java 10 Oct 2003 14:18:20 -0000 1.17 +++ GLConstants.java 20 Oct 2003 14:36:05 -0000 1.18 @@ -109,6 +109,7 @@ EXTTextureEnvDot3, EXTTextureFilterAnisotropic, EXTTextureLODBias, + EXTTextureRectangle, EXTVertexArray, EXTVertexShader, EXTVertexWeighting, Index: GLCaps.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/GLCaps.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/GLCaps.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- GLCaps.java 20 Oct 2003 14:22:03 -0000 1.10 +++ GLCaps.java 20 Oct 2003 14:36:05 -0000 1.11 @@ -101,6 +101,7 @@ public static boolean GL_EXT_texture_env_dot3; public static boolean GL_EXT_texture_filter_anisotropic; public static boolean GL_EXT_texture_lod_bias; + public static boolean GL_EXT_texture_rectangle; public static boolean GL_EXT_vertex_array; public static boolean GL_EXT_vertex_shader; public static boolean GL_EXT_vertex_weighting; |
|
From: Caspian Rychlik-P. <ci...@us...> - 2003-10-20 17:46:03
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/ext In directory sc8-pr-cvs1:/tmp/cvs-serv10129/src/java/org/lwjgl/opengl/ext Added Files: EXTTextureRectangle.java Log Message: EXT_texture_rectangle added --- NEW FILE: EXTTextureRectangle.java --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/ext/EXTTextureRectangle.java /* * Copyright (c) 2003 Lightweight Java Game Library Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of 'Light Weight Java Game Library' nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.lwjgl.opengl.ext; /** * $Id: EXTTextureRectangle.java,v 1.1 2003/10/20 14:36:05 cix_foo Exp $ * * EXT_texture_rectangle extension * * @author cix_foo <ci...@us...> * @version $Revision: 1.1 $ */ public interface EXTTextureRectangle { public static final int GL_TEXTURE_RECTANGLE_EXT = 0x84F5; public static final int GL_TEXTURE_BINDING_RECTANGLE_EXT = 0x84F6; public static final int GL_PROXY_TEXTURE_RECTANGLE_EXT = 0x84F7; public static final int GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT = 0x84F8; } |
|
From: Caspian Rychlik-P. <ci...@us...> - 2003-10-20 17:00:10
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv5998/src/native/linux Modified Files: org_lwjgl_opengl_Window.cpp Log Message: New vsync code Index: org_lwjgl_opengl_Window.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- org_lwjgl_opengl_Window.cpp 11 Oct 2003 16:29:40 -0000 1.9 +++ org_lwjgl_opengl_Window.cpp 20 Oct 2003 14:17:47 -0000 1.10 @@ -559,3 +559,26 @@ (JNIEnv *env, jclass clazz) { return focused; } + +/* + * Class: org_lwjgl_opengl_Window + * Method: nIsVSyncEnabled + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsVSyncEnabled + (JNIEnv * env, jclass clazz) +{ + // Always return false + return false; +} + +/* + * Class: org_lwjgl_opengl_Window + * Method: nSetVSyncEnabled + * Signature: (Z)V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nSetVSyncEnabled + (JNIEnv * env, jclass clazz, jboolean sync) +{ + // Do nothing on Linux +} |
|
From: Caspian Rychlik-P. <ci...@us...> - 2003-10-20 16:36:09
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1:/tmp/cvs-serv5998/src/native/common Modified Files: org_lwjgl_opengl_GL.cpp org_lwjgl_opengl_Window.h org_lwjgl_opengl_GL.h Log Message: New vsync code Index: org_lwjgl_opengl_GL.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/org_lwjgl_opengl_GL.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_opengl_GL.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- org_lwjgl_opengl_GL.cpp 23 Aug 2003 11:34:14 -0000 1.18 +++ org_lwjgl_opengl_GL.cpp 20 Oct 2003 14:17:47 -0000 1.19 @@ -3373,7 +3373,6 @@ /* * Class: org_lwjgl_opengl_GL * Method: wglGetSwapIntervalEXT - */ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GL_wglGetSwapIntervalEXT(JNIEnv * env, jclass clazz) { #ifdef _WIN32 @@ -3385,6 +3384,7 @@ return JNI_FALSE; #endif } + */ /* * Class: org_lwjgl_opengl_GL @@ -3504,7 +3504,6 @@ /* * Class: org_lwjgl_opengl_GL * Method: wglSwapIntervalEXT - */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_GL_wglSwapIntervalEXT(JNIEnv * env, jclass clazz, jint p0) { #ifdef _WIN32 @@ -3516,6 +3515,7 @@ return JNI_FALSE; #endif } + */ /* * Class: org_lwjgl_opengl_GL Index: org_lwjgl_opengl_Window.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/org_lwjgl_opengl_Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_opengl_Window.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- org_lwjgl_opengl_Window.h 26 Sep 2003 13:59:50 -0000 1.6 +++ org_lwjgl_opengl_Window.h 20 Oct 2003 14:17:47 -0000 1.7 @@ -19,8 +19,9 @@ /* Inaccessible static: depth */ /* Inaccessible static: stencil */ /* Inaccessible static: fullscreen */ +/* Inaccessible static: vsync */ /* Inaccessible static: vbo_tracker */ -/* Inaccessible static: class_00024org_00024lwjgl_00024opengl_00024Window */ +/* Inaccessible static: class_000240 */ /* * Class: org_lwjgl_opengl_Window * Method: nSetTitle @@ -88,7 +89,7 @@ /* * Class: org_lwjgl_opengl_Window * Method: nCreate - * Signature: (Ljava/lang/String;IIIIZIIIILjava/util/Vector;)V + * Signature: (Ljava/lang/String;IIIIZIIIILjava/util/HashSet;)V */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nCreate (JNIEnv *, jclass, jstring, jint, jint, jint, jint, jboolean, jint, jint, jint, jint, jobject); @@ -108,6 +109,22 @@ */ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_update (JNIEnv *, jclass); + +/* + * Class: org_lwjgl_opengl_Window + * Method: nIsVSyncEnabled + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsVSyncEnabled + (JNIEnv *, jclass); + +/* + * Class: org_lwjgl_opengl_Window + * Method: nSetVSyncEnabled + * Signature: (Z)V + */ +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nSetVSyncEnabled + (JNIEnv *, jclass, jboolean); #ifdef __cplusplus } Index: org_lwjgl_opengl_GL.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/org_lwjgl_opengl_GL.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/org_lwjgl_opengl_GL.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- org_lwjgl_opengl_GL.h 23 Aug 2003 11:34:14 -0000 1.14 +++ org_lwjgl_opengl_GL.h 20 Oct 2003 14:17:47 -0000 1.15 @@ -2217,27 +2217,11 @@ /* * Class: org_lwjgl_opengl_GL - * Method: wglGetSwapIntervalEXT - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GL_wglGetSwapIntervalEXT - (JNIEnv *, jclass); - -/* - * Class: org_lwjgl_opengl_GL * Method: wglReleaseTexImageARB * Signature: (II)Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_GL_wglReleaseTexImageARB (JNIEnv *, jclass, jint, jint); - -/* - * Class: org_lwjgl_opengl_GL - * Method: wglSwapIntervalEXT - * Signature: (I)Z - */ -JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_GL_wglSwapIntervalEXT - (JNIEnv *, jclass, jint); /* * Class: org_lwjgl_opengl_GL |
|
From: Caspian Rychlik-P. <ci...@us...> - 2003-10-20 16:35:29
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input In directory sc8-pr-cvs1:/tmp/cvs-serv5998/src/java/org/lwjgl/test/input Modified Files: HWCursorTest.java Log Message: New vsync code Index: HWCursorTest.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/HWCursorTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/input/HWCursorTest.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- HWCursorTest.java 14 Oct 2003 14:29:23 -0000 1.19 +++ HWCursorTest.java 20 Oct 2003 14:17:47 -0000 1.20 @@ -338,9 +338,7 @@ GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //sync frame (only works on windows) - if (GLCaps.WGL_EXT_swap_control) { - GL.wglSwapIntervalEXT(1); - } + Window.setVSyncEnabled(true); } /** |
|
From: Caspian Rychlik-P. <ci...@us...> - 2003-10-20 15:49:30
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1:/tmp/cvs-serv5998/src/java/org/lwjgl/opengl Modified Files: Window.java GL.java Log Message: New vsync code Index: Window.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Window.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Window.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- Window.java 13 Oct 2003 11:54:44 -0000 1.14 +++ Window.java 20 Oct 2003 14:17:47 -0000 1.15 @@ -25,7 +25,6 @@ import org.lwjgl.Sys; import java.util.HashSet; -import java.lang.reflect.Method; public final class Window { @@ -54,8 +53,9 @@ * I have posted a bug report to apple regarding the behaviour. * */ - if (Display.getPlatform() == Display.PLATFORM_AGL) + if (Display.getPlatform() == Display.PLATFORM_AGL) { MacOSX.initMacOSX(); + } } /** Whether the window is currently created, ie. has a native peer */ @@ -93,6 +93,9 @@ /** Fullscreen */ private static boolean fullscreen; + + /** Vsync */ + private static boolean vsync; /** Tracks VBO state for the window context */ private static VBOTracker vbo_tracker; @@ -364,4 +367,35 @@ * to handle window close requests, moves, paints, etc. */ public static native void update(); + + /** + * Determines to the best of the platform's ability whether monitor vysnc is enabled on + * this window. The failsafe assumption is that when vsync cannot be determined, this + * method returns false, and you should rely on using a hires timer to throttle your + * framerate rather than relying on monitor sync (even if monitor sync is actually working). + * Therefore you can guarantee that if we return true from this method that we're pretty + * certain vsync is enabled. + * @return boolean + */ + public static boolean isVSyncEnabled() { + assert isCreated() : "Cannot determine sync of uncreated window"; + return nIsVSyncEnabled(); + } + + private static native boolean nIsVSyncEnabled(); + + /** + * Enable or disable vertical monitor synchronization. This call is a best-attempt at changing + * the vertical refresh synchronization of the monitor, and is not guaranteed to be successful. + * To check whether the call <em>might</em> have been successful, call isVSyncEnabled(). + * @param sync true to synchronize; false to ignore synchronization + */ + public static void setVSyncEnabled(boolean sync) { + assert isCreated() : "Cannot set sync of uncreated window"; + nSetVSyncEnabled(sync); + } + + private static native boolean nSetVSyncEnabled(boolean sync); + + } Index: GL.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/GL.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/GL.java,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- GL.java 23 Aug 2003 11:34:14 -0000 1.42 +++ GL.java 20 Oct 2003 14:17:47 -0000 1.43 @@ -1407,24 +1407,6 @@ // public static native int wglGetPbufferDCARB(int hPbuffer); -/* public static native boolean wglGetPixelFormatAttribfvARB( - int hdc, - int iPixelFormat, - int iLayerPlane, - int nAttributes, - int piAttributes, - int pfValues); - - public static native boolean wglGetPixelFormatAttribivARB( - int hdc, - int iPixelFormat, - int iLayerPlane, - int nAttributes, - int piAttributes, - int piValues); -*/ - public static native int wglGetSwapIntervalEXT(); - /* public static native boolean wglMakeContextCurrentARB( int hDrawDC, int hReadDC, @@ -1441,29 +1423,7 @@ int hPbuffer, int iBuffer); -/* public static native boolean wglRestoreBufferRegionARB( - Buffer hRegion, - int x, - int y, - int width, - int height, - int xSrc, - int ySrc); - - public static native boolean wglSaveBufferRegionARB( - Buffer hRegion, - int x, - int y, - int width, - int height); -*/ -/* public static native boolean wglSetPbufferAttribARB( - int hPbuffer, - int piAttribList); -*/ - public static native boolean wglSwapIntervalEXT(int interval); - - public static native void glWindowPos2fARB(float x, float y); +public static native void glWindowPos2fARB(float x, float y); public static native void glWindowPos2iARB(int x, int y); |
|
From: Caspian Rychlik-P. <ci...@us...> - 2003-10-20 15:13:53
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl In directory sc8-pr-cvs1:/tmp/cvs-serv5998/src/java/org/lwjgl/test/opengl Modified Files: FullScreenWindowedTest.java PbufferTest.java Log Message: New vsync code Index: FullScreenWindowedTest.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/FullScreenWindowedTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/FullScreenWindowedTest.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- FullScreenWindowedTest.java 26 Sep 2003 13:59:49 -0000 1.19 +++ FullScreenWindowedTest.java 20 Oct 2003 14:17:47 -0000 1.20 @@ -315,9 +315,7 @@ GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //sync frame (only works on windows) - if (GLCaps.WGL_EXT_swap_control) { - GL.wglSwapIntervalEXT(1); - } + Window.setVSyncEnabled(true); } /** Index: PbufferTest.java CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/PbufferTest.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/test/opengl/PbufferTest.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- PbufferTest.java 3 Oct 2003 14:33:27 -0000 1.18 +++ PbufferTest.java 20 Oct 2003 14:17:47 -0000 1.19 @@ -386,9 +386,8 @@ */ private void glInit() { //sync frame (only works on windows) - if (GLCaps.WGL_EXT_swap_control) { - GL.wglSwapIntervalEXT(1); - } + Window.setVSyncEnabled(true); + GL.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE); GL.glEnable(GL.GL_TEXTURE_2D); // Create shared texture |
|
From: Elias N. <eli...@us...> - 2003-10-20 15:08:51
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv21953/linux Modified Files: org_lwjgl_input_Mouse.cpp Log Message: Fixed linux mouse creation Index: org_lwjgl_input_Mouse.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- org_lwjgl_input_Mouse.cpp 20 Oct 2003 12:40:51 -0000 1.40 +++ org_lwjgl_input_Mouse.cpp 20 Oct 2003 12:49:50 -0000 1.41 @@ -307,7 +307,6 @@ { int i; current_z = last_z = 0; - doWarpPointer(); for (i = 0; i < NUM_BUTTONS; i++) buttons[i] = 0; if (!blankCursor()) { @@ -323,6 +322,7 @@ updateGrab(); initEventQueue(&event_queue); loadXcursor(); + doWarpPointer(); } JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nDestroy |
|
From: Caspian Rychlik-P. <ci...@us...> - 2003-10-20 14:42:21
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1:/tmp/cvs-serv5998/src/native/win32 Modified Files: org_lwjgl_opengl_Window.cpp Log Message: New vsync code Index: org_lwjgl_opengl_Window.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- org_lwjgl_opengl_Window.cpp 11 Oct 2003 16:29:40 -0000 1.10 +++ org_lwjgl_opengl_Window.cpp 20 Oct 2003 14:17:47 -0000 1.11 @@ -58,6 +58,7 @@ static bool minimized; static bool focused; static bool dirty; +static jboolean vsync; //CAS: commented these out as no longer used //extern void tempRestoreDisplayMode(); @@ -444,6 +445,8 @@ } + vsync = JNI_FALSE; + return true; } @@ -592,8 +595,8 @@ * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsDirty - (JNIEnv *env, jclass clazz) { - bool result = dirty; + (JNIEnv *env, jclass clazz) { + bool result = dirty; dirty = false; return result; } @@ -628,4 +631,33 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsFocused (JNIEnv *env, jclass clazz) { return focused; +} + +/* + * Class: org_lwjgl_opengl_Window + * Method: nIsVSyncEnabled + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsVSyncEnabled + (JNIEnv * env, jclass clazz) +{ + return vsync; +} + +/* + * Class: org_lwjgl_opengl_Window + * Method: nSetVSyncEnabled + * Signature: (Z)Z + */ +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_nSetVSyncEnabled + (JNIEnv * env, jclass clazz, jboolean sync) +{ + if (extgl_Extensions.WGL_EXT_swap_control) { + if (sync == JNI_TRUE) { + wglSwapIntervalEXT(1); + } else { + wglSwapIntervalEXT(0); + } + vsync = sync; + } } |
|
From: Elias N. <eli...@us...> - 2003-10-20 12:44:16
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv20100/linux Modified Files: org_lwjgl_input_Mouse.cpp Log Message: Fixed mouse creation Index: org_lwjgl_input_Mouse.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- org_lwjgl_input_Mouse.cpp 11 Oct 2003 16:29:40 -0000 1.39 +++ org_lwjgl_input_Mouse.cpp 20 Oct 2003 12:40:51 -0000 1.40 @@ -106,11 +106,6 @@ last_y = current_y; } -/* - * Class: org_lwjgl_input_Mouse - * Method: initIDs - * Signature: ()V - */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_initIDs (JNIEnv * env, jclass clazz) { @@ -307,17 +302,12 @@ return NUM_BUTTONS; } -/* - * Class: org_lwjgl_input_Mouse - * Method: nCreate - * Signature: ()Z - */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nCreate (JNIEnv * env, jclass clazz) { int i; - centerCursor(); current_z = last_z = 0; + doWarpPointer(); for (i = 0; i < NUM_BUTTONS; i++) buttons[i] = 0; if (!blankCursor()) { @@ -335,11 +325,6 @@ loadXcursor(); } -/* - * Class: org_lwjgl_input_Mouse - * Method: nDestroy - * Signature: ()V - */ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nDestroy (JNIEnv * env, jclass clazz) { |
|
From: Elias N. <eli...@us...> - 2003-10-16 13:56:34
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv18032/macosx Modified Files: org_lwjgl_opengl_Window.cpp Log Message: Index: org_lwjgl_opengl_Window.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- org_lwjgl_opengl_Window.cpp 16 Oct 2003 13:29:29 -0000 1.22 +++ org_lwjgl_opengl_Window.cpp 16 Oct 2003 13:56:22 -0000 1.23 @@ -172,7 +172,6 @@ GLint attrib[] = {AGL_RGBA, AGL_DOUBLEBUFFER, AGL_ACCELERATED, - AGL_NO_RECOVERY, AGL_MINIMUM_POLICY, AGL_PIXEL_SIZE, bpp, AGL_DEPTH_SIZE, depth, |
|
From: Elias N. <eli...@us...> - 2003-10-16 13:31:02
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv13334/macosx Modified Files: org_lwjgl_opengl_Window.cpp Log Message: Index: org_lwjgl_opengl_Window.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- org_lwjgl_opengl_Window.cpp 15 Oct 2003 11:44:04 -0000 1.21 +++ org_lwjgl_opengl_Window.cpp 16 Oct 2003 13:29:29 -0000 1.22 @@ -41,13 +41,15 @@ #include "Window.h" #include <QuickTime/Movies.h> +#include <OpenGL/OpenGL.h> #include "org_lwjgl_opengl_Window.h" #include "extgl.h" #include "tools.h" #include "common_tools.h" static WindowRef win_ref; -static AGLContext context; +static AGLContext windowed_context; +static CGLContextObj fullscreen_context; static bool close_requested; static Ptr fullscreen_ptr; static bool current_fullscreen; @@ -152,14 +154,19 @@ } static void destroy(void) { - aglSetCurrentContext(NULL); - aglDestroyContext(context); + if (current_fullscreen) { + CGLSetCurrentContext(NULL); + CGLDestroyContext(fullscreen_context); + } else { + aglSetCurrentContext(NULL); + aglDestroyContext(windowed_context); + } destroyWindow(); extgl_Close(); destroyLock(); } -static bool createContext(JNIEnv *env, jint bpp, jint alpha, jint depth, jint stencil) { +static bool createWindowedContext(JNIEnv *env, jint bpp, jint alpha, jint depth, jint stencil) { AGLDrawable drawable = GetWindowPort(win_ref); SetPort(drawable); GLint attrib[] = {AGL_RGBA, @@ -177,25 +184,60 @@ throwException(env, "Could not find matching pixel format"); return false; } - context = aglCreateContext (format, NULL); + windowed_context = aglCreateContext (format, NULL); aglDestroyPixelFormat(format); - if (context == NULL) { + if (windowed_context == NULL) { throwException(env, "Could not create context"); return false; } - if (aglSetDrawable(context, drawable) == GL_FALSE) { - aglDestroyContext(context); + if (aglSetDrawable(windowed_context, drawable) == GL_FALSE) { + aglDestroyContext(windowed_context); throwException(env, "Could not attach context"); return false; } - if (aglSetCurrentContext(context) == GL_FALSE) { - aglDestroyContext(context); + if (aglSetCurrentContext(windowed_context) == GL_FALSE) { + aglDestroyContext(windowed_context); throwException(env, "Could not set current context"); return false; } return true; } +static bool createFullscreenContext(JNIEnv *env, jint bpp, jint alpha, jint depth, jint stencil) { + CGOpenGLDisplayMask display_mask = CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay); + CGLPixelFormatObj pixel_format; + long num_formats; + CGLPixelFormatAttribute attribs[] = {kCGLPFAFullScreen, + kCGLPFADoubleBuffer, + kCGLPFAMinimumPolicy, + kCGLPFAAccelerated, + kCGLPFADisplayMask, + (CGLPixelFormatAttribute)display_mask, + kCGLPFAColorSize, + (CGLPixelFormatAttribute)bpp, + kCGLPFAAlphaSize, + (CGLPixelFormatAttribute)alpha, + kCGLPFADepthSize, + (CGLPixelFormatAttribute)depth, + kCGLPFAStencilSize, + (CGLPixelFormatAttribute)stencil, + (CGLPixelFormatAttribute)NULL}; + CGLChoosePixelFormat(attribs, &pixel_format, &num_formats); + if (pixel_format == NULL) { + throwException(env, "Could not find matching pixel format"); + return false; + } + CGLCreateContext(pixel_format, NULL, &fullscreen_context); + CGLDestroyPixelFormat(pixel_format); + if (fullscreen_context == NULL) { + throwException(env, "Could not create fullscreen context"); + return false; + } + CGLSetFullScreen(fullscreen_context); + CGLSetCurrentContext(fullscreen_context); + return true; +} + JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_Window_nIsCloseRequested(JNIEnv *, jclass) { bool saved; lock(); @@ -235,12 +277,12 @@ throwException(env, "Could not create window"); return; } - if (!registerEventHandlers(env)) { + if (!initLock(env)) { destroyWindow(); extgl_Close(); return; } - if (!initLock(env)) { + if (!registerEventHandlers(env)) { destroyWindow(); extgl_Close(); return; @@ -248,7 +290,13 @@ setWindowTitle(env, title); const RGBColor background_color = {0, 0, 0}; SetWindowContentColor(win_ref, &background_color); - if (!createContext(env, bpp, alpha, depth, stencil)) { + bool success; + if (current_fullscreen) { + success = createFullscreenContext(env, bpp, alpha, depth, stencil); + } else { + success = createWindowedContext(env, bpp, alpha, depth, stencil); + } + if (!success) { destroyLock(); destroyWindow(); extgl_Close(); @@ -275,7 +323,11 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_swapBuffers(JNIEnv * env, jclass clazz) { - aglSwapBuffers(context); + if (current_fullscreen) { + CGLFlushDrawable(fullscreen_context); + } else { + aglSwapBuffers(windowed_context); + } } JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_minimize(JNIEnv *env, jclass clazz) { |
|
From: Elias N. <eli...@us...> - 2003-10-16 13:30:53
|
Update of /cvsroot/java-game-lib/LWJGL/src/native In directory sc8-pr-cvs1:/tmp/cvs-serv13334 Modified Files: configure.in ltmain.sh Log Message: Index: configure.in CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/configure.in =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/configure.in,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- configure.in 6 Oct 2003 14:00:40 -0000 1.45 +++ configure.in 16 Oct 2003 13:29:28 -0000 1.46 @@ -17,7 +17,7 @@ AC_PROG_CXX AC_ARG_ENABLE(debug, -AC_HELP_STRING([--disable-buidl], [Disable debug build]), +AC_HELP_STRING([--disable-debug], [Disable debug build]), [build_debug=$enableval], [build_debug=no]) if test $build_debug = yes; then Index: ltmain.sh CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/ltmain.sh =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/ltmain.sh,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ltmain.sh 10 Oct 2003 14:18:20 -0000 1.2 +++ ltmain.sh 16 Oct 2003 13:29:28 -0000 1.3 @@ -49,14 +49,14 @@ fi # The name of this program. -progname=`$echo "$0" | ${SED} 's%^.*/%%'` +progname=`$echo "$0" | sed 's%^.*/%%'` modename="$progname" # Constants. PROGRAM=ltmain.sh PACKAGE=libtool -VERSION=1.4.3 -TIMESTAMP=" (1.922.2.111 2002/10/23 02:54:36)" +VERSION=1.4.2 +TIMESTAMP=" (1.4 2001/11/19 00:06:02)" default_mode= help="Try \`$progname --help' for more information." @@ -67,19 +67,10 @@ # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. -Xsed="${SED}"' -e 1s/^X//' +Xsed='sed -e 1s/^X//' sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' -# test EBCDIC or ASCII -case `echo A|od -x` in - *[Cc]1*) # EBCDIC based system - SP2NL="tr '\100' '\n'" - NL2SP="tr '\r\n' '\100\100'" - ;; - *) # Assume ASCII based system - SP2NL="tr '\040' '\012'" - NL2SP="tr '\015\012' '\040\040'" - ;; -esac +SP2NL='tr \040 \012' +NL2SP='tr \015\012 \040\040' # NLS nuisances. # Only set LANG and LC_ALL to C if already set. @@ -153,7 +144,7 @@ ;; --config) - ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0 + sed -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0 exit 0 ;; @@ -186,8 +177,6 @@ --mode) prevopt="--mode" prev=mode ;; --mode=*) mode="$optarg" ;; - --preserve-dup-deps) duplicate_deps="yes" ;; - --quiet | --silent) show=: ;; @@ -226,7 +215,7 @@ # Infer the operation mode. if test -z "$mode"; then case $nonopt in - *cc | *++ | gcc* | *-gcc* | xlc*) + *cc | *++ | gcc* | *-gcc*) mode=link for arg do @@ -478,7 +467,7 @@ pic_mode=default ;; esac - if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then + if test $pic_mode = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi @@ -1003,7 +992,7 @@ # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in - no/*-*-irix* | no/*-*-nonstopux*) + no/*-*-irix*) compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" ;; @@ -1054,14 +1043,14 @@ # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; - *-*-openbsd* | *-*-freebsd*) + *-*-openbsd*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in - *-*-openbsd* | *-*-freebsd*) + *-*-openbsd*) # Do not include libc_r directly, use -pthread flag. continue ;; @@ -1314,11 +1303,11 @@ output_objdir="$output_objdir/$objdir" fi # Create the object directory. - if test ! -d "$output_objdir"; then + if test ! -d $output_objdir; then $show "$mkdir $output_objdir" - $run $mkdir "$output_objdir" + $run $mkdir $output_objdir status=$? - if test $status -ne 0 && test ! -d "$output_objdir"; then + if test $status -ne 0 && test ! -d $output_objdir; then exit $status fi fi @@ -1341,11 +1330,9 @@ # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do - if test "X$duplicate_deps" = "Xyes" ; then - case "$libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi + case "$libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac libs="$libs $deplib" done deplibs= @@ -1474,12 +1461,10 @@ lib) if test "$deplibs_check_method" != pass_all; then echo - echo "*** Warning: Trying to link with static lib archive $deplib." + echo "*** Warning: This library needs some functionality provided by $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because the file extensions .$libext of this argument makes me believe" - echo "*** that it is just a static archive that I should not used here." + echo "*** shared version of the library, which you do not appear to have." else echo echo "*** Warning: Linking the shared library $output against the" @@ -1523,7 +1508,7 @@ fi # Check to see that this really is a libtool archive. - if (${SED} -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + if (sed -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit 1 @@ -1550,7 +1535,7 @@ if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || - { test $linkmode != lib && test $linkmode != prog; }; then + { test $linkmode = oldlib && test $linkmode = obj; }; then # Add dl[pre]opened files of deplib test -n "$dlopen" && dlfiles="$dlfiles $dlopen" test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" @@ -1558,7 +1543,9 @@ if test $pass = conv; then # Only check for convenience libraries - deplibs="$lib $deplibs" + if test "$libdir"; then + deplibs="$lib $deplibs" + fi if test -z "$libdir"; then if test -z "$old_library"; then $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 @@ -1570,11 +1557,9 @@ tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" - if test "X$duplicate_deps" = "Xyes" ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac tmp_libs="$tmp_libs $deplib" done elif test $linkmode != prog && test $linkmode != lib; then @@ -1697,11 +1682,9 @@ # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi - if test "X$duplicate_deps" = "Xyes" ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac tmp_libs="$tmp_libs $deplib" done # for deplib continue @@ -1785,8 +1768,8 @@ # Make a new name for the extract_expsyms_cmds to use soroot="$soname" - soname=`echo $soroot | ${SED} -e 's/^.*\///'` - newlib="libimp-`echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" + soname=`echo $soroot | sed -e 's/^.*\///'` + newlib="libimp-`echo $soname | sed 's/^lib//;s/\.dll$//'`.a" # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : @@ -1903,11 +1886,7 @@ add="-l$name" else # We cannot seem to hardcode it, guess we'll fake it. - if test "X$installed" = Xyes; then - add_dir="-L$libdir" - else - add_dir="-L$DESTDIR$libdir" - fi + add_dir="-L$libdir" add="-l$name" fi @@ -1949,14 +1928,13 @@ # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo - echo "*** Warning: This system can not link to static lib archive $lib." + echo "*** Warning: This library needs some functionality provided by $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then - echo "*** But as you try to build a module library, libtool will still create " - echo "*** a static module, that should work as long as the dlopening application" - echo "*** is linked with the -dlopen flag to resolve symbols at runtime." + echo "*** Therefore, libtool will create a static module, that should work " + echo "*** as long as the dlopening application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" @@ -2005,11 +1983,9 @@ tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" - if test "X$duplicate_deps" = "Xyes" ; then - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac - fi + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac tmp_libs="$tmp_libs $deplib" done @@ -2035,7 +2011,7 @@ if grep "^installed=no" $deplib > /dev/null; then path="-L$absdir/$objdir" else - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` if test -z "$libdir"; then $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 exit 1 @@ -2299,21 +2275,16 @@ versuffix=".$current"; ;; - irix | nonstopux) + irix) major=`expr $current - $age + 1` - - case $version_type in - nonstopux) verstring_prefix=nonstopux ;; - *) verstring_prefix=sgi ;; - esac - verstring="$verstring_prefix$major.$revision" + verstring="sgi$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test $loop != 0; do iface=`expr $revision - $loop` loop=`expr $loop - 1` - verstring="$verstring_prefix$major.$iface:$verstring" + verstring="sgi$major.$iface:$verstring" done # Before this point, $major must not contain `.'. @@ -2327,7 +2298,7 @@ ;; osf) - major=.`expr $current - $age` + major=`expr $current - $age` versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" @@ -2419,9 +2390,9 @@ # Eliminate all temporary directories. for path in $notinst_path; do - lib_search_path=`echo "$lib_search_path " | ${SED} -e 's% $path % %g'` - deplibs=`echo "$deplibs " | ${SED} -e 's% -L$path % %g'` - dependency_libs=`echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'` + lib_search_path=`echo "$lib_search_path " | sed -e 's% $path % %g'` + deplibs=`echo "$deplibs " | sed -e 's% -L$path % %g'` + dependency_libs=`echo "$dependency_libs " | sed -e 's% -L$path % %g'` done if test -n "$xrpath"; then @@ -2472,7 +2443,7 @@ *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; - *-*-openbsd* | *-*-freebsd*) + *-*-openbsd*) # Do not include libc due to us having libc/libc_r. ;; *) @@ -2533,20 +2504,18 @@ else droppeddeps=yes echo - echo "*** Warning: dynamic linker does not accept needed library $i." + echo "*** Warning: This library needs some functionality provided by $i." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which I believe you do not have" - echo "*** because a test_compile did reveal that the linker did not use it for" - echo "*** its dynamic dependency list that programs get resolved with at runtime." + echo "*** shared version of the library, which you do not appear to have." fi else newdeplibs="$newdeplibs $i" fi done else - # Error occured in the first compile. Let's try to salvage - # the situation: Compile a separate program for each library. + # Error occured in the first compile. Let's try to salvage the situation: + # Compile a seperate program for each library. for i in $deplibs; do name="`expr $i : '-l\(.*\)'`" # If $name is empty we are operating on a -L argument. @@ -2565,12 +2534,10 @@ else droppeddeps=yes echo - echo "*** Warning: dynamic linker does not accept needed library $i." + echo "*** Warning: This library needs some functionality provided by $i." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because a test_compile did reveal that the linker did not use this one" - echo "*** as a dynamic dependency that programs can get resolved with at runtime." + echo "*** shared version of the library, which you do not appear to have." fi else droppeddeps=yes @@ -2609,21 +2576,14 @@ # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do - potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` + potliblink=`ls -ld $potlib | sed 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; esac done - # It is ok to link against an archive when - # building a shared library. - if $AR -t $potlib > /dev/null 2>&1; then - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - break 2 - fi if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ - | ${SED} 10q \ + | sed 10q \ | egrep "$file_magic_regex" > /dev/null; then newdeplibs="$newdeplibs $a_deplib" a_deplib="" @@ -2634,17 +2594,10 @@ if test -n "$a_deplib" ; then droppeddeps=yes echo - echo "*** Warning: linker path does not have real file for library $a_deplib." + echo "*** Warning: This library needs some functionality provided by $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - echo "*** with $libname but no candidates were found. (...for file magic test)" - else - echo "*** with $libname and none of the candidates passed a file format test" - echo "*** using a file magic. Last file checked: $potlib" - fi + echo "*** shared version of the library, which you do not appear to have." fi else # Add a -L argument. @@ -2663,9 +2616,8 @@ for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do - potlib="$potent_lib" # see symlink-check below in file_magic test if eval echo \"$potent_lib\" 2>/dev/null \ - | ${SED} 10q \ + | sed 10q \ | egrep "$match_pattern_regex" > /dev/null; then newdeplibs="$newdeplibs $a_deplib" a_deplib="" @@ -2676,17 +2628,10 @@ if test -n "$a_deplib" ; then droppeddeps=yes echo - echo "*** Warning: linker path does not have real file for library $a_deplib." + echo "*** Warning: This library needs some functionality provided by $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have" - echo "*** because I did check the linker path looking for a file starting" - if test -z "$potlib" ; then - echo "*** with $libname but no candidates were found. (...for regex pattern test)" - else - echo "*** with $libname and none of the candidates passed a file format test" - echo "*** using a regex pattern. Last file checked: $potlib" - fi + echo "*** shared version of the library, which you do not appear to have." fi else # Add a -L argument. @@ -2951,18 +2896,7 @@ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval cmds=\"$archive_expsym_cmds\" else - save_deplibs="$deplibs" - for conv in $convenience; do - tmp_deplibs= - for test_deplib in $deplibs; do - if test "$test_deplib" != "$conv"; then - tmp_deplibs="$tmp_deplibs $test_deplib" - fi - done - deplibs="$tmp_deplibs" - done eval cmds=\"$archive_cmds\" - deplibs="$save_deplibs" fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do @@ -3161,7 +3095,7 @@ prog) case $host in - *cygwin*) output=`echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; + *cygwin*) output=`echo $output | sed -e 's,.exe$,,;s,$,.exe,'` ;; esac if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 @@ -3183,13 +3117,6 @@ # On Rhapsody replace the C library is the System framework compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` - case $host in - *darwin*) - # Don't allow lazy linking, it breaks C++ global constructors - compile_command="$compile_command ${wl}-bind_at_load" - finalize_command="$finalize_command ${wl}-bind_at_load" - ;; - esac ;; esac @@ -3356,9 +3283,9 @@ if test -z "$export_symbols"; then export_symbols="$output_objdir/$output.exp" $run $rm $export_symbols - $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' else - $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' + $run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' $run eval 'mv "$nlist"T "$nlist"' fi @@ -3366,7 +3293,7 @@ for arg in $dlprefiles; do $show "extracting global C symbols from \`$arg'" - name=`echo "$arg" | ${SED} -e 's%^.*/%%'` + name=`echo "$arg" | sed -e 's%^.*/%%'` $run eval 'echo ": $name " >> "$nlist"' $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" done @@ -3381,13 +3308,7 @@ fi # Try sorting and uniquifying the output. - if grep -v "^: " < "$nlist" | - if sort -k 3 </dev/null >/dev/null 2>&1; then - sort -k 3 - else - sort +2 - fi | - uniq > "$nlist"S; then + if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then : else grep -v "^: " < "$nlist" > "$nlist"S @@ -3609,7 +3530,7 @@ relink_command="$var=\"$var_value\"; export $var; $relink_command" fi done - relink_command="(cd `pwd`; $relink_command)" + relink_command="cd `pwd`; $relink_command" relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` fi @@ -3629,7 +3550,7 @@ # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in - *.exe) output=`echo $output|${SED} 's,.exe$,,'` ;; + *.exe) output=`echo $output|sed 's,.exe$,,'` ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in @@ -3653,7 +3574,7 @@ # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. -Xsed="${SED}"' -e 1s/^X//' +Xsed='sed -e 1s/^X//' sed_quote_subst='$sed_quote_subst' # The HP-UX ksh and POSIX shell print the target directory to stdout @@ -3691,7 +3612,7 @@ test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. - file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` + file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` @@ -3704,7 +3625,7 @@ fi file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` - file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` + file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\` done # Try to get the absolute directory name. @@ -3718,7 +3639,7 @@ progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || \\ - { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" @@ -3764,7 +3685,7 @@ $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var - # The second colon is a workaround for a bug in BeOS R4 ${SED} + # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` export $shlibpath_var @@ -3939,7 +3860,7 @@ fi done # Quote the link command for shipping. - relink_command="(cd `pwd`; $SHELL $0 --mode=relink $libtool_args)" + relink_command="cd `pwd`; $SHELL $0 --mode=relink $libtool_args" relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` # Only create the output if not a dry run. @@ -3956,7 +3877,7 @@ case $deplib in *.la) name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` if test -z "$libdir"; then $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 exit 1 @@ -3970,7 +3891,7 @@ newdlfiles= for lib in $dlfiles; do name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib` if test -z "$libdir"; then $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit 1 @@ -3981,7 +3902,7 @@ newdlprefiles= for lib in $dlprefiles; do name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib` if test -z "$libdir"; then $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit 1 @@ -4205,7 +4126,7 @@ *.la) # Check to see that this really is a libtool archive. - if (${SED} -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 $echo "$help" 1>&2 @@ -4222,21 +4143,12 @@ esac # Add the libdir to current_libdirs if it is the destination. - DESTDIR= if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) current_libdirs="$current_libdirs $libdir" ;; esac else - case "$destdir" in - *"$libdir") - DESTDIR=`$echo "$destdir" | sed -e 's!'"$libdir"'$!!'` - if test "X$destdir" != "X$DESTDIR$libdir"; then - DESTDIR= - fi - ;; - esac # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; @@ -4250,7 +4162,6 @@ if test -n "$relink_command"; then $echo "$modename: warning: relinking \`$file'" 1>&2 - export DESTDIR $show "$relink_command" if $run eval "$relink_command"; then : else @@ -4258,7 +4169,6 @@ continue fi fi - unset DESTDIR # See the names of the shared library. set dummy $library_names @@ -4365,27 +4275,19 @@ fi # Do a test to see if this is really a libtool program. - case $host in - *cygwin*|*mingw*) - wrapper=`echo $file | ${SED} -e 's,.exe$,,'` - ;; - *) - wrapper=$file - ;; - esac - if (${SED} -e '4q' $wrapper | egrep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then + if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then notinst_deplibs= relink_command= # If there is no directory component, then add one. case $file in - */* | *\\*) . $wrapper ;; - *) . ./$wrapper ;; + */* | *\\*) . $file ;; + *) . ./$file ;; esac # Check the variables that should have been set. if test -z "$notinst_deplibs"; then - $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 + $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2 exit 1 fi @@ -4410,8 +4312,8 @@ relink_command= # If there is no directory component, then add one. case $file in - */* | *\\*) . $wrapper ;; - *) . ./$wrapper ;; + */* | *\\*) . $file ;; + *) . ./$file ;; esac outputname= @@ -4419,11 +4321,7 @@ if test "$finalize" = yes && test -z "$run"; then tmpdir="/tmp" test -n "$TMPDIR" && tmpdir="$TMPDIR" - tmpdir=`mktemp -d $tmpdir/libtool-XXXXXX 2> /dev/null` - if test $? = 0 ; then : - else - tmpdir="$tmpdir/libtool-$$" - fi + tmpdir="$tmpdir/libtool-$$" if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then : else $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 @@ -4463,7 +4361,7 @@ destfile=$destfile.exe ;; *:*.exe) - destfile=`echo $destfile | ${SED} -e 's,.exe$,,'` + destfile=`echo $destfile | sed -e 's,.exe$,,'` ;; esac ;; @@ -4611,7 +4509,7 @@ case $file in *.la) # Check to see that this really is a libtool archive. - if (${SED} -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 $echo "$help" 1>&2 @@ -4682,7 +4580,7 @@ -*) ;; *) # Do a test to see if this is really a libtool program. - if (${SED} -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then # If there is no directory component, then add one. case $file in */* | *\\*) . $file ;; @@ -4714,7 +4612,7 @@ fi # Now prepare to actually exec the command. - exec_cmd="\$cmd$args" + exec_cmd='"$cmd"$args' else # Display what would be done. if test -n "$shlibpath_var"; then @@ -4791,7 +4689,7 @@ case $name in *.la) # Possibly a libtool archive, so verify it. - if (${SED} -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then . $dir/$name # Delete the libtool libraries and symlinks. @@ -4837,30 +4735,16 @@ ;; *.lo) - # Possibly a libtool object, so verify it. - if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - - # Read the .lo file - . $dir/$name - - # Add PIC object to the list of files to remove. - if test -n "$pic_object" \ - && test "$pic_object" != none; then - rmfiles="$rmfiles $dir/$pic_object" - fi - - # Add non-PIC object to the list of files to remove. - if test -n "$non_pic_object" \ - && test "$non_pic_object" != none; then - rmfiles="$rmfiles $dir/$non_pic_object" - fi + if test "$build_old_libs" = yes; then + oldobj=`$echo "X$name" | $Xsed -e "$lo2o"` + rmfiles="$rmfiles $dir/$oldobj" fi ;; *) # Do a test to see if this is a libtool program. if test $mode = clean && - (${SED} -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then relink_command= . $dir/$file |
|
From: Elias N. <eli...@us...> - 2003-10-15 11:49:28
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv7664/src/native/macosx Modified Files: org_lwjgl_Display.cpp Log Message: Index: org_lwjgl_Display.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_Display.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_Display.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- org_lwjgl_Display.cpp 15 Oct 2003 11:44:04 -0000 1.19 +++ org_lwjgl_Display.cpp 15 Oct 2003 11:49:24 -0000 1.20 @@ -45,7 +45,7 @@ static CFDictionaryRef original_mode; -JNIEXPORT void JNICALL Java_org_lwjgl_Display_init(JNIEnv * env, jclass clazz) { +static void init(JNIEnv *env, jclass clazz) { original_mode = CGDisplayCurrentMode(kCGDirectMainDisplay); long width; long height; @@ -62,6 +62,10 @@ env->SetStaticObjectField(clazz, fid_initialMode, newMode); } +JNIEXPORT void JNICALL Java_org_lwjgl_Display_init(JNIEnv * env, jclass clazz) { + init(env, clazz); +} + JNIEXPORT void JNICALL Java_org_lwjgl_Display_setDisplayMode(JNIEnv * env, jclass clazz, jobject mode) { jclass cls_displayMode = env->FindClass("org/lwjgl/DisplayMode"); jfieldID fid_width = env->GetFieldID(cls_displayMode, "width", "I"); @@ -125,9 +129,10 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_setGammaRamp(JNIEnv *env, jclass clazz, jobject gamma_ramp_buffer) { } -JNIEXPORT void JNICALL Java_org_lwjgl_Display_resetDisplayMode(JNIEnv *, jclass) { +JNIEXPORT void JNICALL Java_org_lwjgl_Display_resetDisplayMode(JNIEnv *env, jclass clazz) { CGDisplaySwitchToMode(kCGDirectMainDisplay, original_mode); CGDisplayRelease(kCGDirectMainDisplay); + init(env, clazz); } JNIEXPORT jstring JNICALL Java_org_lwjgl_Display_getAdapter(JNIEnv * , jclass) { |
|
From: Elias N. <eli...@us...> - 2003-10-15 11:44:09
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv6646/src/native/macosx Modified Files: org_lwjgl_Display.cpp org_lwjgl_input_Mouse.cpp org_lwjgl_opengl_Window.cpp tools.cpp tools.h Log Message: Index: org_lwjgl_Display.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_Display.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_Display.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- org_lwjgl_Display.cpp 14 Oct 2003 12:42:04 -0000 1.18 +++ org_lwjgl_Display.cpp 15 Oct 2003 11:44:04 -0000 1.19 @@ -39,16 +39,80 @@ * @version $Revision$ */ -#include <JavaVM/jni.h> #include "org_lwjgl_Display.h" +#include "common_tools.h" +#include "tools.h" + +static CFDictionaryRef original_mode; JNIEXPORT void JNICALL Java_org_lwjgl_Display_init(JNIEnv * env, jclass clazz) { + original_mode = CGDisplayCurrentMode(kCGDirectMainDisplay); + long width; + long height; + long bpp; + long freq; + getDictLong(original_mode, kCGDisplayWidth, &width); + getDictLong(original_mode, kCGDisplayHeight, &height); + getDictLong(original_mode, kCGDisplayBitsPerPixel, &bpp); + getDictLong(original_mode, kCGDisplayRefreshRate, &freq); + jclass jclass_DisplayMode = env->FindClass("org/lwjgl/DisplayMode"); + jmethodID ctor = env->GetMethodID(jclass_DisplayMode, "<init>", "(IIII)V"); + jobject newMode = env->NewObject(jclass_DisplayMode, ctor, width, height, bpp, freq); + jfieldID fid_initialMode = env->GetStaticFieldID(clazz, "mode", "Lorg/lwjgl/DisplayMode;"); + env->SetStaticObjectField(clazz, fid_initialMode, newMode); } JNIEXPORT void JNICALL Java_org_lwjgl_Display_setDisplayMode(JNIEnv * env, jclass clazz, jobject mode) { + jclass cls_displayMode = env->FindClass("org/lwjgl/DisplayMode"); + jfieldID fid_width = env->GetFieldID(cls_displayMode, "width", "I"); + jfieldID fid_height = env->GetFieldID(cls_displayMode, "height", "I"); + jfieldID fid_bpp = env->GetFieldID(cls_displayMode, "bpp", "I"); + jfieldID fid_freq = env->GetFieldID(cls_displayMode, "freq", "I"); + int width = env->GetIntField(mode, fid_width); + int height = env->GetIntField(mode, fid_height); + int bpp = env->GetIntField(mode, fid_bpp); + int freq = env->GetIntField(mode, fid_freq); + CGDisplayCapture(kCGDirectMainDisplay); + CFDictionaryRef displayMode = CGDisplayBestModeForParametersAndRefreshRate(kCGDirectMainDisplay, bpp, width, height, freq, NULL); + CGDisplaySwitchToMode(kCGDirectMainDisplay, displayMode); + + jmethodID ctor = env->GetMethodID(cls_displayMode, "<init>", "(IIII)V"); + jobject newMode = env->NewObject(cls_displayMode, ctor, width, height, bpp, freq); + jfieldID fid_initialMode = env->GetStaticFieldID(clazz, "mode", "Lorg/lwjgl/DisplayMode;"); + env->SetStaticObjectField(clazz, fid_initialMode, newMode); } JNIEXPORT jobjectArray JNICALL Java_org_lwjgl_Display_nGetAvailableDisplayModes(JNIEnv * env, jclass clazz) { + CFArrayRef modes = CGDisplayAvailableModes(kCGDirectMainDisplay); + int size = CFArrayGetCount(modes); + int avail_modes = 0; + for (int i = 0; i < size; i++) { + CFDictionaryRef mode = (CFDictionaryRef)CFArrayGetValueAtIndex(modes, i); + long bpp; + getDictLong(mode, kCGDisplayBitsPerPixel, &bpp); + if (bpp > 8) + avail_modes++; + } + jclass displayModeClass = env->FindClass("org/lwjgl/DisplayMode"); + jobjectArray ret = env->NewObjectArray(avail_modes, displayModeClass, NULL); + jmethodID displayModeConstructor = env->GetMethodID(displayModeClass, "<init>", "(IIII)V"); + int array_index = 0; + for (int i = 0; i < size; i++) { + CFDictionaryRef mode = (CFDictionaryRef)CFArrayGetValueAtIndex(modes, i); + long width; + long height; + long bpp; + long freq; + getDictLong(mode, kCGDisplayWidth, &width); + getDictLong(mode, kCGDisplayHeight, &height); + getDictLong(mode, kCGDisplayBitsPerPixel, &bpp); + getDictLong(mode, kCGDisplayRefreshRate, &freq); + if (bpp > 8) { + jobject displayMode = env->NewObject(displayModeClass, displayModeConstructor, width, height, bpp, freq); + env->SetObjectArrayElement(ret, array_index++, displayMode); + } + } + return ret; } JNIEXPORT jint JNICALL Java_org_lwjgl_Display_getPlatform(JNIEnv * env, jclass clazz) { @@ -62,6 +126,8 @@ } JNIEXPORT void JNICALL Java_org_lwjgl_Display_resetDisplayMode(JNIEnv *, jclass) { + CGDisplaySwitchToMode(kCGDirectMainDisplay, original_mode); + CGDisplayRelease(kCGDirectMainDisplay); } JNIEXPORT jstring JNICALL Java_org_lwjgl_Display_getAdapter(JNIEnv * , jclass) { 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.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- org_lwjgl_input_Mouse.cpp 15 Oct 2003 08:49:36 -0000 1.13 +++ org_lwjgl_input_Mouse.cpp 15 Oct 2003 11:44:04 -0000 1.14 @@ -134,16 +134,6 @@ printf("0x%lx (%ld)", number, number); } */ -static bool getLongProperty(CFDictionaryRef dict, CFStringRef key, long *key_value) { - CFTypeRef val = CFDictionaryGetValue(dict, key); - if (val != NULL) { - CFTypeID type = CFGetTypeID(val); - if (type == CFNumberGetTypeID()) - if (CFNumberGetValue((CFNumberRef)val, kCFNumberLongType, key_value)) - return true; - } - return false; -} /*static void printProperty(CFDictionaryRef dict, CFStringRef key) { CFTypeRef val = CFDictionaryGetValue(dict, key); @@ -224,9 +214,9 @@ long cookie_num; long usage; long usage_page; - if (!getLongProperty(dict, CFSTR(kIOHIDElementCookieKey), &cookie_num) || - !getLongProperty(dict, CFSTR(kIOHIDElementUsageKey), &usage) || - !getLongProperty(dict, CFSTR(kIOHIDElementUsagePageKey), &usage_page)) + if (!getDictLong(dict, CFSTR(kIOHIDElementCookieKey), &cookie_num) || + !getDictLong(dict, CFSTR(kIOHIDElementUsageKey), &usage) || + !getDictLong(dict, CFSTR(kIOHIDElementUsagePageKey), &usage_page)) return; testCookie(usage_page, usage, (IOHIDElementCookie)cookie_num, &x_axis_cookie, kHIDPage_GenericDesktop, kHIDUsage_GD_X); testCookie(usage_page, usage, (IOHIDElementCookie)cookie_num, &y_axis_cookie, kHIDPage_GenericDesktop, kHIDUsage_GD_Y); @@ -284,8 +274,8 @@ if (kern_err == KERN_SUCCESS && dev_props != NULL) { long usage; long usage_page; - if (getLongProperty(dev_props, CFSTR(kIOHIDPrimaryUsageKey), &usage) && - getLongProperty(dev_props, CFSTR(kIOHIDPrimaryUsagePageKey), &usage_page) && + if (getDictLong(dev_props, CFSTR(kIOHIDPrimaryUsageKey), &usage) && + getDictLong(dev_props, CFSTR(kIOHIDPrimaryUsagePageKey), &usage_page) && usage_page == kHIDPage_GenericDesktop && usage == kHIDUsage_GD_Mouse) { success = initDevice(hid_device, dev_props); } Index: org_lwjgl_opengl_Window.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- org_lwjgl_opengl_Window.cpp 15 Oct 2003 08:49:36 -0000 1.20 +++ org_lwjgl_opengl_Window.cpp 15 Oct 2003 11:44:04 -0000 1.21 @@ -162,8 +162,8 @@ static bool createContext(JNIEnv *env, jint bpp, jint alpha, jint depth, jint stencil) { AGLDrawable drawable = GetWindowPort(win_ref); SetPort(drawable); - GLint attrib[] = {AGL_RGBA, - AGL_DOUBLEBUFFER, + GLint attrib[] = {AGL_RGBA, + AGL_DOUBLEBUFFER, AGL_ACCELERATED, AGL_NO_RECOVERY, AGL_MINIMUM_POLICY, @@ -227,7 +227,7 @@ return; } if (current_fullscreen) - status = BeginFullScreen(&fullscreen_ptr, NULL, 0, 0, &win_ref, NULL, 0); + status = BeginFullScreen(&fullscreen_ptr, NULL, NULL, NULL, &win_ref, NULL, 0); else status = CreateNewWindow(kDocumentWindowClass, window_attr, &rect, &win_ref); if (noErr != status) { @@ -274,7 +274,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_update(JNIEnv *env, jclass clazz) { } -JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_swapBuffers(JNIEnv * env, jclass clazz) { +JNIEXPORT void JNICALL Java_org_lwjgl_opengl_Window_swapBuffers(JNIEnv * env, jclass clazz) { aglSwapBuffers(context); } Index: tools.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/tools.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/tools.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- tools.cpp 13 Oct 2003 11:54:45 -0000 1.7 +++ tools.cpp 15 Oct 2003 11:44:05 -0000 1.8 @@ -4,6 +4,17 @@ MPCriticalRegionID critical_region; +bool getDictLong(CFDictionaryRef dict, CFStringRef key, long *key_value) { + CFTypeRef val = CFDictionaryGetValue(dict, key); + if (val != NULL) { + CFTypeID type = CFGetTypeID(val); + if (type == CFNumberGetTypeID()) + if (CFNumberGetValue((CFNumberRef)val, kCFNumberLongType, key_value)) + return true; + } + return false; +} + bool registerHandler(JNIEnv* env, WindowRef win_ref, EventHandlerProcPtr func, UInt32 event_class, UInt32 event_kind) { EventTypeSpec event_type; EventHandlerUPP handler_upp = NewEventHandlerUPP(func); Index: tools.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/tools.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/tools.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- tools.h 11 Oct 2003 16:29:40 -0000 1.7 +++ tools.h 15 Oct 2003 11:44:05 -0000 1.8 @@ -7,6 +7,7 @@ #define lock() {lockLWJGL(); #define unlock() unlockLWJGL();} +extern bool getDictLong(CFDictionaryRef dict, CFStringRef key, long *key_value); extern bool registerHandler(JNIEnv* env, WindowRef win_ref, EventHandlerProcPtr func, UInt32 event_class, UInt32 event_kind); extern bool initLock(JNIEnv* env); extern void destroyLock(void); |
|
From: Elias N. <eli...@us...> - 2003-10-15 08:49:46
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv11551/macosx Modified Files: Makefile.am Window.h org_lwjgl_input_Mouse.cpp org_lwjgl_opengl_Window.cpp Added Files: org_lwjgl_input_Controller.cpp Log Message: --- NEW FILE: org_lwjgl_input_Controller.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Controller.cpp /* * Copyright (c) 2002 Lightweight Java Game Library Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of 'Light Weight Java Game Library' nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * $Id: org_lwjgl_input_Controller.cpp,v 1.1 2003/10/15 08:49:36 elias_naur Exp $ * * Mac OS X controller handling. * * @author Elias Naur <br...@ma...> * @version $Revision: 1.1 $ */ #include "org_lwjgl_input_Controller.h" #include "common_tools.h" JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_initIDs(JNIEnv * env, jclass clazz) { } JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nCreate(JNIEnv *env, jclass clazz) { throwException(env, "Controller not implemented"); } JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nDestroy(JNIEnv *env, jclass clazz) { } JNIEXPORT void JNICALL Java_org_lwjgl_input_Controller_nPoll(JNIEnv * env, jclass clazz) { } Index: Makefile.am CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/Makefile.am =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/Makefile.am,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- Makefile.am 14 Oct 2003 14:29:23 -0000 1.10 +++ Makefile.am 15 Oct 2003 08:49:36 -0000 1.11 @@ -6,7 +6,7 @@ NATIVE = \ org_lwjgl_Display.cpp \ org_lwjgl_Sys.cpp \ -# org_lwjgl_input_Controller.cpp \ + org_lwjgl_input_Controller.cpp \ org_lwjgl_input_Keyboard.cpp \ org_lwjgl_opengl_MacOSX.cpp \ tools.cpp \ Index: Window.h CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/Window.h =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/Window.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Window.h 14 Oct 2003 12:42:04 -0000 1.5 +++ Window.h 15 Oct 2003 08:49:36 -0000 1.6 @@ -47,6 +47,6 @@ extern void setQuitRequested(void); extern bool registerKeyboardHandler(JNIEnv* env, WindowRef win_ref); // extern bool registerMouseHandler(JNIEnv* env, WindowRef win_ref); - extern bool isMouseCreatedAndNotNativeCursor(void); + extern bool isMouseCreated(void); #endif /* _LWJGL_WINDOW_H_INCLUDED_ */ 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.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- org_lwjgl_input_Mouse.cpp 14 Oct 2003 14:29:23 -0000 1.12 +++ org_lwjgl_input_Mouse.cpp 15 Oct 2003 08:49:36 -0000 1.13 @@ -60,7 +60,7 @@ static unsigned char button_states[NUM_BUTTONS]; /*static int last_x; static int last_y;*/ -static bool native_cursor; +//static bool native_cursor; static bool created; static bool buffer_enabled; static IOHIDDeviceInterface **device_interface; @@ -79,8 +79,8 @@ static void searchDictionary(CFDictionaryRef dict); static void searchObject(CFTypeRef object); -bool isMouseCreatedAndNotNativeCursor(void) { - return created && !native_cursor; +bool isMouseCreated(void) { + return created/* && !native_cursor*/; } /*static pascal OSStatus doMouseMoved(EventHandlerCallRef next_handler, EventRef event, void *user_data) { @@ -362,19 +362,22 @@ } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps(JNIEnv *env, jclass clazz) { + return 0; } JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor(JNIEnv *env, jclass clazz, jlong cursor_handle) { } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetMinCursorSize(JNIEnv *env, jclass clazz) { + return 16; } JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetMaxCursorSize(JNIEnv *env, jclass clazz) { + return 16; } JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nCreate(JNIEnv * env, jclass clazz) { - native_cursor = false; +// native_cursor = false; buffer_enabled = false; x_axis_cookie = NULL; y_axis_cookie = NULL; @@ -396,10 +399,10 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nDestroy(JNIEnv * env, jclass clazz) { shutdownDevice(); - if (!native_cursor) { +// if (!native_cursor) { CGAssociateMouseAndMouseCursorPosition(TRUE); CGDisplayShowCursor(CGMainDisplayID()); - } +// } created = false; } @@ -407,17 +410,17 @@ int dx, dy, dz; pollDevice(); dz = last_dz; - if (!native_cursor) { + //if (!native_cursor) { dx = last_dx; dy = -last_dy; - } else { - /* Point cursor_pos; + /*} else { + Point cursor_pos; GetMouse(&cursor_pos); dx = cursor_pos.v - last_x; dy = cursor_pos.h - last_y; last_x += dx; - last_y += dy;*/ - } + last_y += dy; + }*/ env->SetStaticIntField(clazz, fid_dx, (jint)dx); env->SetStaticIntField(clazz, fid_dy, (jint)dy); env->SetStaticIntField(clazz, fid_dwheel, (jint)dz); Index: org_lwjgl_opengl_Window.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_opengl_Window.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- org_lwjgl_opengl_Window.cpp 14 Oct 2003 12:42:04 -0000 1.19 +++ org_lwjgl_opengl_Window.cpp 15 Oct 2003 08:49:36 -0000 1.20 @@ -99,7 +99,7 @@ lock(); miniaturized = false; activated = true; - if (isMouseCreatedAndNotNativeCursor()) + if (isMouseCreated()) warpCursorToCenter(); unlock(); return eventNotHandledErr; |
|
From: Elias N. <eli...@us...> - 2003-10-14 14:29:28
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/common In directory sc8-pr-cvs1:/tmp/cvs-serv16237/src/native/common Modified Files: common_tools.cpp Log Message: Index: common_tools.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/common/common_tools.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/common/common_tools.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- common_tools.cpp 11 Oct 2003 16:29:40 -0000 1.1 +++ common_tools.cpp 14 Oct 2003 14:29:23 -0000 1.2 @@ -48,7 +48,7 @@ int next_index = (queue->list_end + 1)%EVENT_BUFFER_SIZE; if (next_index == queue->list_start) { #ifdef _DEBUG - printf("Keyboard buffer overflow!\n"); + printf("Event buffer overflow!\n"); #endif return; } |
|
From: Elias N. <eli...@us...> - 2003-10-14 14:29:28
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/linux In directory sc8-pr-cvs1:/tmp/cvs-serv16237/src/native/linux Modified Files: org_lwjgl_input_Cursor.cpp Log Message: Index: org_lwjgl_input_Cursor.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Cursor.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Cursor.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- org_lwjgl_input_Cursor.cpp 11 Oct 2003 16:29:40 -0000 1.6 +++ org_lwjgl_input_Cursor.cpp 14 Oct 2003 14:29:23 -0000 1.7 @@ -1,3 +1,44 @@ +/* + * Copyright (c) 2002 Light Weight Java Game Library Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'Light Weight Java Game Library' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * $Id$ + * + * Linux cursor handling. + * + * @author elias_naur <eli...@us...> + * @version $Revision$ + */ + #include "org_lwjgl_input_Cursor.h" #include "extxcursor.h" #include "Window.h" |
|
From: Elias N. <eli...@us...> - 2003-10-14 14:29:28
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/win32 In directory sc8-pr-cvs1:/tmp/cvs-serv16237/src/native/win32 Modified Files: org_lwjgl_input_Cursor.cpp Log Message: Index: org_lwjgl_input_Cursor.cpp CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Cursor.cpp =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/win32/org_lwjgl_input_Cursor.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- org_lwjgl_input_Cursor.cpp 11 Oct 2003 16:29:40 -0000 1.7 +++ org_lwjgl_input_Cursor.cpp 14 Oct 2003 14:29:23 -0000 1.8 @@ -1,3 +1,44 @@ +/* + * Copyright (c) 2002 Light Weight Java Game Library Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'Light Weight Java Game Library' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * $Id$ + * + * win32 mouse handling. + * + * @author elias_naur <eli...@us...> + * @version $Revision$ + */ + #include <windows.h> #include "org_lwjgl_input_Cursor.h" #include "Window.h" |
|
From: Elias N. <eli...@us...> - 2003-10-14 14:29:28
|
Update of /cvsroot/java-game-lib/LWJGL/src/native/macosx In directory sc8-pr-cvs1:/tmp/cvs-serv16237/src/native/macosx Modified Files: Makefile.am org_lwjgl_input_Mouse.cpp Added Files: org_lwjgl_input_Cursor.cpp Log Message: --- NEW FILE: org_lwjgl_input_Cursor.cpp --- CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/org_lwjgl_input_Cursor.cpp /* * Copyright (c) 2002 Light Weight Java Game Library Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * * Neither the name of 'Light Weight Java Game Library' nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * $Id: org_lwjgl_input_Cursor.cpp,v 1.1 2003/10/14 14:29:23 elias_naur Exp $ * * Mac OS X cursor handling. * * @author elias_naur <eli...@us...> * @version $Revision: 1.1 $ */ #include "org_lwjgl_input_Cursor.h" JNIEXPORT jlong JNICALL Java_org_lwjgl_input_Cursor_nCreateCursor(JNIEnv *env, jclass clazz, jint width, jint height, jint x_hotspot, jint y_hotspot, jint num_images, jobject image_buffer, jint images_offset, jobject delay_buffer, jint delays_offset) { } JNIEXPORT void JNICALL Java_org_lwjgl_input_Cursor_nDestroyCursor(JNIEnv *env, jclass clazz, jlong cursor_handle) { } Index: Makefile.am CVS Browser: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/java-game-lib/LWJGL/src/native/macosx/Makefile.am =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/native/macosx/Makefile.am,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Makefile.am 7 Oct 2003 12:12:08 -0000 1.9 +++ Makefile.am 14 Oct 2003 14:29:23 -0000 1.10 @@ -11,7 +11,7 @@ org_lwjgl_opengl_MacOSX.cpp \ tools.cpp \ org_lwjgl_input_Mouse.cpp \ -# org_lwjgl_input_Cursor.cpp \ + org_lwjgl_input_Cursor.cpp \ org_lwjgl_opengl_Window.cpp # org_lwjgl_opengl_Pbuffer.cpp 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.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- org_lwjgl_input_Mouse.cpp 14 Oct 2003 12:42:04 -0000 1.11 +++ org_lwjgl_input_Mouse.cpp 14 Oct 2003 14:29:23 -0000 1.12 @@ -277,7 +277,7 @@ #ifdef _DEBUG printf("Could not find matching devices\n"); #endif - return; + return false; } while (!success && (hid_device = IOIteratorNext(device_iterator)) != NULL) { kern_err = IORegistryEntryCreateCFProperties(hid_device, &dev_props, kCFAllocatorDefault, kNilOptions); @@ -301,8 +301,10 @@ static void handleButton(unsigned char button_index, unsigned char state) { button_states[button_index] = state; - putEventElement(&event_queue, button_index); - putEventElement(&event_queue, state); + if (buffer_enabled) { + putEventElement(&event_queue, button_index); + putEventElement(&event_queue, state); + } } static void pollDevice() { @@ -388,13 +390,16 @@ return; } CGAssociateMouseAndMouseCursorPosition(FALSE); + CGDisplayHideCursor(CGMainDisplayID()); created = true; } JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nDestroy(JNIEnv * env, jclass clazz) { shutdownDevice(); - if (!native_cursor) + if (!native_cursor) { CGAssociateMouseAndMouseCursorPosition(TRUE); + CGDisplayShowCursor(CGMainDisplayID()); + } created = false; } |