diff --git a/jni/SDL2-2.0.1/include/SDL_name.h b/jni/SDL2-2.0.1/include/SDL_name.h deleted file mode 100644 index d0469e1f..00000000 --- a/jni/SDL2-2.0.1/include/SDL_name.h +++ /dev/null @@ -1,11 +0,0 @@ - -#ifndef _SDLname_h_ -#define _SDLname_h_ - -#if defined(__STDC__) || defined(__cplusplus) -#define NeedFunctionPrototypes 1 -#endif - -#define SDL_NAME(X) SDL_##X - -#endif /* _SDLname_h_ */ diff --git a/jni/SDL2-2.0.1/src/file/cocoa/SDL_rwopsbundlesupport.h b/jni/SDL2-2.0.1/src/file/cocoa/SDL_rwopsbundlesupport.h deleted file mode 100644 index 6929904c..00000000 --- a/jni/SDL2-2.0.1/src/file/cocoa/SDL_rwopsbundlesupport.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifdef __APPLE__ - -#include - -#ifndef SDL_rwopsbundlesupport_h -#define SDL_rwopsbundlesupport_h -FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode); -#endif -#endif diff --git a/jni/SDL2-2.0.1/src/joystick/darwin/SDL_sysjoystick.c b/jni/SDL2-2.0.1/src/joystick/darwin/SDL_sysjoystick.c deleted file mode 100644 index ace65970..00000000 --- a/jni/SDL2-2.0.1/src/joystick/darwin/SDL_sysjoystick.c +++ /dev/null @@ -1,1152 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "../../SDL_internal.h" - -#ifdef SDL_JOYSTICK_IOKIT - -/* SDL joystick driver for Darwin / Mac OS X, based on the IOKit HID API */ -/* Written 2001 by Max Horn */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* for NewPtrClear, DisposePtr */ -#include - -/* For force feedback testing. */ -#include -#include - -#include "SDL_joystick.h" -#include "../SDL_sysjoystick.h" -#include "../SDL_joystick_c.h" -#include "SDL_sysjoystick_c.h" -#include "SDL_events.h" -#if !SDL_EVENTS_DISABLED -#include "../../events/SDL_events_c.h" -#endif - - -/* Linked list of all available devices */ -static recDevice *gpDeviceList = NULL; -/* OSX reference to the notification object that tells us about device insertion/removal */ -IONotificationPortRef notificationPort = 0; -/* if 1 then a device was added since the last update call */ -static SDL_bool s_bDeviceAdded = SDL_FALSE; -static SDL_bool s_bDeviceRemoved = SDL_FALSE; - -/* static incrementing counter for new joystick devices seen on the system. Devices should start with index 0 */ -static int s_joystick_instance_id = -1; - -static void -HIDReportErrorNum(char *strError, long numError) -{ - SDL_SetError(strError); -} - -static void HIDGetCollectionElements(CFMutableDictionaryRef deviceProperties, - recDevice * pDevice); - -/* returns current value for element, polling element - * will return 0 on error conditions which should be accounted for by application - */ - -static SInt32 -HIDGetElementValue(recDevice * pDevice, recElement * pElement) -{ - IOReturn result = kIOReturnSuccess; - IOHIDEventStruct hidEvent; - hidEvent.value = 0; - - if (NULL != pDevice && NULL != pElement && NULL != pDevice->interface) { - result = - (*(pDevice->interface))->getElementValue(pDevice->interface, - pElement->cookie, - &hidEvent); - if (kIOReturnSuccess == result) { - /* record min and max for auto calibration */ - if (hidEvent.value < pElement->minReport) - pElement->minReport = hidEvent.value; - if (hidEvent.value > pElement->maxReport) - pElement->maxReport = hidEvent.value; - } - } - - /* auto user scale */ - return hidEvent.value; -} - -static SInt32 -HIDScaledCalibratedValue(recDevice * pDevice, recElement * pElement, - long min, long max) -{ - float deviceScale = max - min; - float readScale = pElement->maxReport - pElement->minReport; - SInt32 value = HIDGetElementValue(pDevice, pElement); - if (readScale == 0) - return value; /* no scaling at all */ - else - return ((value - pElement->minReport) * deviceScale / readScale) + - min; -} - - -static void -HIDRemovalCallback(void *target, IOReturn result, void *refcon, void *sender) -{ - recDevice *device = (recDevice *) refcon; - device->removed = 1; - s_bDeviceRemoved = SDL_TRUE; -} - - -/* Called by the io port notifier on removal of this device - */ -void JoystickDeviceWasRemovedCallback( void * refcon, io_service_t service, natural_t messageType, void * messageArgument ) -{ - if( messageType == kIOMessageServiceIsTerminated && refcon ) - { - recDevice *device = (recDevice *) refcon; - device->removed = 1; - s_bDeviceRemoved = SDL_TRUE; - } -} - - -/* Create and open an interface to device, required prior to extracting values or building queues. - * Note: application now owns the device and must close and release it prior to exiting - */ - -static IOReturn -HIDCreateOpenDeviceInterface(io_object_t hidDevice, recDevice * pDevice) -{ - IOReturn result = kIOReturnSuccess; - HRESULT plugInResult = S_OK; - SInt32 score = 0; - IOCFPlugInInterface **ppPlugInInterface = NULL; - - if (NULL == pDevice->interface) { - result = - IOCreatePlugInInterfaceForService(hidDevice, - kIOHIDDeviceUserClientTypeID, - kIOCFPlugInInterfaceID, - &ppPlugInInterface, &score); - if (kIOReturnSuccess == result) { - /* Call a method of the intermediate plug-in to create the device interface */ - plugInResult = - (*ppPlugInInterface)->QueryInterface(ppPlugInInterface, - CFUUIDGetUUIDBytes - (kIOHIDDeviceInterfaceID), - (void *) - &(pDevice->interface)); - if (S_OK != plugInResult) - HIDReportErrorNum - ("Couldn't query HID class device interface from plugInInterface", - plugInResult); - (*ppPlugInInterface)->Release(ppPlugInInterface); - } else - HIDReportErrorNum - ("Failed to create **plugInInterface via IOCreatePlugInInterfaceForService.", - result); - } - if (NULL != pDevice->interface) { - result = (*(pDevice->interface))->open(pDevice->interface, 0); - if (kIOReturnSuccess != result) - HIDReportErrorNum - ("Failed to open pDevice->interface via open.", result); - else - { - pDevice->portIterator = 0; - - /* It's okay if this fails, we have another detection method below */ - (*(pDevice->interface))->setRemovalCallback(pDevice->interface, - HIDRemovalCallback, - pDevice, pDevice); - - /* now connect notification for new devices */ - pDevice->notificationPort = IONotificationPortCreate(kIOMasterPortDefault); - - CFRunLoopAddSource(CFRunLoopGetCurrent(), - IONotificationPortGetRunLoopSource(pDevice->notificationPort), - kCFRunLoopDefaultMode); - - /* Register for notifications when a serial port is added to the system */ - result = IOServiceAddInterestNotification(pDevice->notificationPort, - hidDevice, - kIOGeneralInterest, - JoystickDeviceWasRemovedCallback, - pDevice, - &pDevice->portIterator); - if (kIOReturnSuccess != result) { - HIDReportErrorNum - ("Failed to register for removal callback.", result); - } - } - - } - return result; -} - -/* Closes and releases interface to device, should be done prior to exiting application - * Note: will have no affect if device or interface do not exist - * application will "own" the device if interface is not closed - * (device may have to be plug and re-plugged in different location to get it working again without a restart) - */ - -static IOReturn -HIDCloseReleaseInterface(recDevice * pDevice) -{ - IOReturn result = kIOReturnSuccess; - - if ((NULL != pDevice) && (NULL != pDevice->interface)) { - /* close the interface */ - result = (*(pDevice->interface))->close(pDevice->interface); - if (kIOReturnNotOpen == result) { - /* do nothing as device was not opened, thus can't be closed */ - } else if (kIOReturnSuccess != result) - HIDReportErrorNum("Failed to close IOHIDDeviceInterface.", - result); - /* release the interface */ - result = (*(pDevice->interface))->Release(pDevice->interface); - if (kIOReturnSuccess != result) - HIDReportErrorNum("Failed to release IOHIDDeviceInterface.", - result); - pDevice->interface = NULL; - - if ( pDevice->portIterator ) - { - IOObjectRelease( pDevice->portIterator ); - pDevice->portIterator = 0; - } - } - return result; -} - -/* extracts actual specific element information from each element CF dictionary entry */ - -static void -HIDGetElementInfo(CFTypeRef refElement, recElement * pElement) -{ - long number; - CFTypeRef refType; - - refType = CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementCookieKey)); - if (refType && CFNumberGetValue(refType, kCFNumberLongType, &number)) - pElement->cookie = (IOHIDElementCookie) number; - refType = CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementMinKey)); - if (refType && CFNumberGetValue(refType, kCFNumberLongType, &number)) - pElement->minReport = pElement->min = number; - pElement->maxReport = pElement->min; - refType = CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementMaxKey)); - if (refType && CFNumberGetValue(refType, kCFNumberLongType, &number)) - pElement->maxReport = pElement->max = number; -/* - TODO: maybe should handle the following stuff somehow? - - refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementScaledMinKey)); - if (refType && CFNumberGetValue (refType, kCFNumberLongType, &number)) - pElement->scaledMin = number; - refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementScaledMaxKey)); - if (refType && CFNumberGetValue (refType, kCFNumberLongType, &number)) - pElement->scaledMax = number; - refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementSizeKey)); - if (refType && CFNumberGetValue (refType, kCFNumberLongType, &number)) - pElement->size = number; - refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementIsRelativeKey)); - if (refType) - pElement->relative = CFBooleanGetValue (refType); - refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementIsWrappingKey)); - if (refType) - pElement->wrapping = CFBooleanGetValue (refType); - refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementIsNonLinearKey)); - if (refType) - pElement->nonLinear = CFBooleanGetValue (refType); - refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementHasPreferedStateKey)); - if (refType) - pElement->preferredState = CFBooleanGetValue (refType); - refType = CFDictionaryGetValue (refElement, CFSTR(kIOHIDElementHasNullStateKey)); - if (refType) - pElement->nullState = CFBooleanGetValue (refType); -*/ -} - -/* examines CF dictionary value in device element hierarchy to determine if it is element of interest or a collection of more elements - * if element of interest allocate storage, add to list and retrieve element specific info - * if collection then pass on to deconstruction collection into additional individual elements - */ - -static void -HIDAddElement(CFTypeRef refElement, recDevice * pDevice) -{ - recElement *element = NULL; - recElement **headElement = NULL; - long elementType, usagePage, usage; - CFTypeRef refElementType = - CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementTypeKey)); - CFTypeRef refUsagePage = - CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementUsagePageKey)); - CFTypeRef refUsage = - CFDictionaryGetValue(refElement, CFSTR(kIOHIDElementUsageKey)); - - - if ((refElementType) - && - (CFNumberGetValue(refElementType, kCFNumberLongType, &elementType))) { - /* look at types of interest */ - if ((elementType == kIOHIDElementTypeInput_Misc) - || (elementType == kIOHIDElementTypeInput_Button) - || (elementType == kIOHIDElementTypeInput_Axis)) { - if (refUsagePage - && CFNumberGetValue(refUsagePage, kCFNumberLongType, - &usagePage) && refUsage - && CFNumberGetValue(refUsage, kCFNumberLongType, &usage)) { - switch (usagePage) { /* only interested in kHIDPage_GenericDesktop and kHIDPage_Button */ - case kHIDPage_GenericDesktop: - { - switch (usage) { /* look at usage to determine function */ - case kHIDUsage_GD_X: - case kHIDUsage_GD_Y: - case kHIDUsage_GD_Z: - case kHIDUsage_GD_Rx: - case kHIDUsage_GD_Ry: - case kHIDUsage_GD_Rz: - case kHIDUsage_GD_Slider: - case kHIDUsage_GD_Dial: - case kHIDUsage_GD_Wheel: - element = (recElement *) - NewPtrClear(sizeof(recElement)); - if (element) { - pDevice->axes++; - headElement = &(pDevice->firstAxis); - } - break; - case kHIDUsage_GD_Hatswitch: - element = (recElement *) - NewPtrClear(sizeof(recElement)); - if (element) { - pDevice->hats++; - headElement = &(pDevice->firstHat); - } - break; - } - } - break; - case kHIDPage_Simulation: - switch (usage) { - case kHIDUsage_Sim_Rudder: - case kHIDUsage_Sim_Throttle: - element = (recElement *) - NewPtrClear(sizeof(recElement)); - if (element) { - pDevice->axes++; - headElement = &(pDevice->firstAxis); - } - break; - - default: - break; - } - break; - case kHIDPage_Button: - element = (recElement *) - NewPtrClear(sizeof(recElement)); - if (element) { - pDevice->buttons++; - headElement = &(pDevice->firstButton); - } - break; - default: - break; - } - } - } else if (kIOHIDElementTypeCollection == elementType) - HIDGetCollectionElements((CFMutableDictionaryRef) refElement, - pDevice); - } - - if (element && headElement) { /* add to list */ - recElement *elementPrevious = NULL; - recElement *elementCurrent = *headElement; - while (elementCurrent && usage >= elementCurrent->usage) { - elementPrevious = elementCurrent; - elementCurrent = elementCurrent->pNext; - } - if (elementPrevious) { - elementPrevious->pNext = element; - } else { - *headElement = element; - } - element->usagePage = usagePage; - element->usage = usage; - element->pNext = elementCurrent; - HIDGetElementInfo(refElement, element); - pDevice->elements++; - } -} - -/* collects information from each array member in device element list (each array member = element) */ - -static void -HIDGetElementsCFArrayHandler(const void *value, void *parameter) -{ - if (CFGetTypeID(value) == CFDictionaryGetTypeID()) - HIDAddElement((CFTypeRef) value, (recDevice *) parameter); -} - -/* handles retrieval of element information from arrays of elements in device IO registry information */ - -static void -HIDGetElements(CFTypeRef refElementCurrent, recDevice * pDevice) -{ - CFTypeID type = CFGetTypeID(refElementCurrent); - if (type == CFArrayGetTypeID()) { /* if element is an array */ - CFRange range = { 0, CFArrayGetCount(refElementCurrent) }; - /* CountElementsCFArrayHandler called for each array member */ - CFArrayApplyFunction(refElementCurrent, range, - HIDGetElementsCFArrayHandler, pDevice); - } -} - -/* handles extracting element information from element collection CF types - * used from top level element decoding and hierarchy deconstruction to flatten device element list - */ - -static void -HIDGetCollectionElements(CFMutableDictionaryRef deviceProperties, - recDevice * pDevice) -{ - CFTypeRef refElementTop = - CFDictionaryGetValue(deviceProperties, CFSTR(kIOHIDElementKey)); - if (refElementTop) - HIDGetElements(refElementTop, pDevice); -} - -/* use top level element usage page and usage to discern device usage page and usage setting appropriate vlaues in device record */ - -static void -HIDTopLevelElementHandler(const void *value, void *parameter) -{ - CFTypeRef refCF = 0; - if (CFGetTypeID(value) != CFDictionaryGetTypeID()) - return; - refCF = CFDictionaryGetValue(value, CFSTR(kIOHIDElementUsagePageKey)); - if (!CFNumberGetValue - (refCF, kCFNumberLongType, &((recDevice *) parameter)->usagePage)) - SDL_SetError("CFNumberGetValue error retrieving pDevice->usagePage."); - refCF = CFDictionaryGetValue(value, CFSTR(kIOHIDElementUsageKey)); - if (!CFNumberGetValue - (refCF, kCFNumberLongType, &((recDevice *) parameter)->usage)) - SDL_SetError("CFNumberGetValue error retrieving pDevice->usage."); -} - -/* extracts device info from CF dictionary records in IO registry */ - -static void -HIDGetDeviceInfo(io_object_t hidDevice, CFMutableDictionaryRef hidProperties, - recDevice * pDevice) -{ - CFMutableDictionaryRef usbProperties = 0; - io_registry_entry_t parent1, parent2; - - /* Mac OS X currently is not mirroring all USB properties to HID page so need to look at USB device page also - * get dictionary for USB properties: step up two levels and get CF dictionary for USB properties - */ - if ((KERN_SUCCESS == IORegistryEntryGetParentEntry(hidDevice, kIOServicePlane, &parent1)) - && (KERN_SUCCESS == IORegistryEntryGetParentEntry(parent1, kIOServicePlane, &parent2)) - && (KERN_SUCCESS == IORegistryEntryCreateCFProperties(parent2, &usbProperties, kCFAllocatorDefault, kNilOptions))) { - if (usbProperties) { - CFTypeRef refCF = 0; - /* get device info - * try hid dictionary first, if fail then go to usb dictionary - */ - - /* get product name */ - refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey)); - if (!refCF) { - refCF = CFDictionaryGetValue(usbProperties, CFSTR("USB Product Name")); - } - if (refCF) { - if (!CFStringGetCString(refCF, pDevice->product, 256, CFStringGetSystemEncoding())) { - SDL_SetError("CFStringGetCString error retrieving pDevice->product."); - } - } - - /* get usage page and usage */ - refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDPrimaryUsagePageKey)); - if (refCF) { - if (!CFNumberGetValue (refCF, kCFNumberLongType, &pDevice->usagePage)) { - SDL_SetError("CFNumberGetValue error retrieving pDevice->usagePage."); - } - - refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDPrimaryUsageKey)); - if (refCF) { - if (!CFNumberGetValue (refCF, kCFNumberLongType, &pDevice->usage)) { - SDL_SetError("CFNumberGetValue error retrieving pDevice->usage."); - } - } - } - - refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDVendorIDKey)); - if (refCF) { - if (!CFNumberGetValue(refCF, kCFNumberLongType, &pDevice->guid.data[0])) { - SDL_SetError("CFNumberGetValue error retrieving pDevice->guid[0]"); - } - } - - refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductIDKey)); - if (refCF) { - if (!CFNumberGetValue(refCF, kCFNumberLongType, &pDevice->guid.data[8])) { - SDL_SetError("CFNumberGetValue error retrieving pDevice->guid[8]"); - } - } - - /* Check to make sure we have a vendor and product ID - If we don't, use the same algorithm as the Linux code for Bluetooth devices */ - { - Uint32 *guid32 = (Uint32*)pDevice->guid.data; - if (!guid32[0] && !guid32[1]) { - const Uint16 BUS_BLUETOOTH = 0x05; - Uint16 *guid16 = (Uint16 *)guid32; - *guid16++ = BUS_BLUETOOTH; - *guid16++ = 0; - SDL_strlcpy((char*)guid16, pDevice->product, sizeof(pDevice->guid.data) - 4); - } - } - - /* If we don't have a vendor and product ID this is probably a Bluetooth device */ - - if (NULL == refCF) { /* get top level element HID usage page or usage */ - /* use top level element instead */ - CFTypeRef refCFTopElement = 0; - refCFTopElement = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDElementKey)); - { - /* refCFTopElement points to an array of element dictionaries */ - CFRange range = { 0, CFArrayGetCount(refCFTopElement) }; - CFArrayApplyFunction(refCFTopElement, range, HIDTopLevelElementHandler, pDevice); - } - } - - CFRelease(usbProperties); - } else { - SDL_SetError("IORegistryEntryCreateCFProperties failed to create usbProperties."); - } - - if (kIOReturnSuccess != IOObjectRelease(parent2)) { - SDL_SetError("IOObjectRelease error with parent2"); - } - if (kIOReturnSuccess != IOObjectRelease(parent1)) { - SDL_SetError("IOObjectRelease error with parent1"); - } - } -} - - -static recDevice * -HIDBuildDevice(io_object_t hidDevice) -{ - recDevice *pDevice = (recDevice *) NewPtrClear(sizeof(recDevice)); - if (pDevice) { - /* get dictionary for HID properties */ - CFMutableDictionaryRef hidProperties = 0; - kern_return_t result = - IORegistryEntryCreateCFProperties(hidDevice, &hidProperties, - kCFAllocatorDefault, - kNilOptions); - if ((result == KERN_SUCCESS) && hidProperties) { - /* create device interface */ - result = HIDCreateOpenDeviceInterface(hidDevice, pDevice); - if (kIOReturnSuccess == result) { - HIDGetDeviceInfo(hidDevice, hidProperties, pDevice); /* hidDevice used to find parents in registry tree */ - HIDGetCollectionElements(hidProperties, pDevice); - } else { - DisposePtr((Ptr) pDevice); - pDevice = NULL; - } - CFRelease(hidProperties); - } else { - DisposePtr((Ptr) pDevice); - pDevice = NULL; - } - } - return pDevice; -} - -/* disposes of the element list associated with a device and the memory associated with the list - */ - -static void -HIDDisposeElementList(recElement ** elementList) -{ - recElement *pElement = *elementList; - while (pElement) { - recElement *pElementNext = pElement->pNext; - DisposePtr((Ptr) pElement); - pElement = pElementNext; - } - *elementList = NULL; -} - -/* disposes of a single device, closing and releaseing interface, freeing memory fro device and elements, setting device pointer to NULL - * all your device no longer belong to us... (i.e., you do not 'own' the device anymore) - */ - -static recDevice * -HIDDisposeDevice(recDevice ** ppDevice) -{ - kern_return_t result = KERN_SUCCESS; - recDevice *pDeviceNext = NULL; - if (*ppDevice) { - /* save next device prior to disposing of this device */ - pDeviceNext = (*ppDevice)->pNext; - - /* free posible io_service_t */ - if ((*ppDevice)->ffservice) { - IOObjectRelease((*ppDevice)->ffservice); - (*ppDevice)->ffservice = 0; - } - - /* free element lists */ - HIDDisposeElementList(&(*ppDevice)->firstAxis); - HIDDisposeElementList(&(*ppDevice)->firstButton); - HIDDisposeElementList(&(*ppDevice)->firstHat); - - result = HIDCloseReleaseInterface(*ppDevice); /* function sanity checks interface value (now application does not own device) */ - if (kIOReturnSuccess != result) - HIDReportErrorNum - ("HIDCloseReleaseInterface failed when trying to dipose device.", - result); - DisposePtr((Ptr) * ppDevice); - *ppDevice = NULL; - } - return pDeviceNext; -} - - -/* Given an io_object_t from OSX adds a joystick device to our list if appropriate - */ -int -AddDeviceHelper( io_object_t ioHIDDeviceObject ) -{ - recDevice *device; - - /* build a device record */ - device = HIDBuildDevice(ioHIDDeviceObject); - if (!device) - return 0; - - /* Filter device list to non-keyboard/mouse stuff */ - if ((device->usagePage != kHIDPage_GenericDesktop) || - ((device->usage != kHIDUsage_GD_Joystick && - device->usage != kHIDUsage_GD_GamePad && - device->usage != kHIDUsage_GD_MultiAxisController))) { - - /* release memory for the device */ - HIDDisposeDevice(&device); - DisposePtr((Ptr) device); - return 0; - } - - /* Allocate an instance ID for this device */ - device->instance_id = ++s_joystick_instance_id; - - /* We have to do some storage of the io_service_t for - * SDL_HapticOpenFromJoystick */ - if (FFIsForceFeedback(ioHIDDeviceObject) == FF_OK) { - device->ffservice = ioHIDDeviceObject; - } else { - device->ffservice = 0; - } - - device->send_open_event = 1; - s_bDeviceAdded = SDL_TRUE; - - /* Add device to the end of the list */ - if ( !gpDeviceList ) - { - gpDeviceList = device; - } - else - { - recDevice *curdevice; - - curdevice = gpDeviceList; - while ( curdevice->pNext ) - { - curdevice = curdevice->pNext; - } - curdevice->pNext = device; - } - - return 1; -} - - -/* Called by our IO port notifier on the master port when a HID device is inserted, we iterate - * and check for new joysticks - */ -void JoystickDeviceWasAddedCallback( void *refcon, io_iterator_t iterator ) -{ - io_object_t ioHIDDeviceObject = 0; - - while ( ( ioHIDDeviceObject = IOIteratorNext(iterator) ) ) - { - if ( ioHIDDeviceObject ) - { - AddDeviceHelper( ioHIDDeviceObject ); - } - } -} - - -/* Function to scan the system for joysticks. - * Joystick 0 should be the system default joystick. - * This function should return the number of available joysticks, or -1 - * on an unrecoverable fatal error. - */ -int -SDL_SYS_JoystickInit(void) -{ - IOReturn result = kIOReturnSuccess; - mach_port_t masterPort = 0; - io_iterator_t hidObjectIterator = 0; - CFMutableDictionaryRef hidMatchDictionary = NULL; - io_object_t ioHIDDeviceObject = 0; - io_iterator_t portIterator = 0; - - if (gpDeviceList) { - return SDL_SetError("Joystick: Device list already inited."); - } - - result = IOMasterPort(bootstrap_port, &masterPort); - if (kIOReturnSuccess != result) { - return SDL_SetError("Joystick: IOMasterPort error with bootstrap_port."); - } - - /* Set up a matching dictionary to search I/O Registry by class name for all HID class devices. */ - hidMatchDictionary = IOServiceMatching(kIOHIDDeviceKey); - if (hidMatchDictionary) { - /* Add key for device type (joystick, in this case) to refine the matching dictionary. */ - - /* NOTE: we now perform this filtering later - UInt32 usagePage = kHIDPage_GenericDesktop; - UInt32 usage = kHIDUsage_GD_Joystick; - CFNumberRef refUsage = NULL, refUsagePage = NULL; - - refUsage = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &usage); - CFDictionarySetValue (hidMatchDictionary, CFSTR (kIOHIDPrimaryUsageKey), refUsage); - refUsagePage = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &usagePage); - CFDictionarySetValue (hidMatchDictionary, CFSTR (kIOHIDPrimaryUsagePageKey), refUsagePage); - */ - } else { - return SDL_SetError - ("Joystick: Failed to get HID CFMutableDictionaryRef via IOServiceMatching."); - } - - /* Now search I/O Registry for matching devices. */ - result = - IOServiceGetMatchingServices(masterPort, hidMatchDictionary, - &hidObjectIterator); - /* Check for errors */ - if (kIOReturnSuccess != result) { - return SDL_SetError("Joystick: Couldn't create a HID object iterator."); - } - if (!hidObjectIterator) { /* there are no joysticks */ - gpDeviceList = NULL; - return 0; - } - /* IOServiceGetMatchingServices consumes a reference to the dictionary, so we don't need to release the dictionary ref. */ - - /* build flat linked list of devices from device iterator */ - - gpDeviceList = NULL; - - while ((ioHIDDeviceObject = IOIteratorNext(hidObjectIterator))) { - AddDeviceHelper( ioHIDDeviceObject ); - } - result = IOObjectRelease(hidObjectIterator); /* release the iterator */ - - /* now connect notification for new devices */ - notificationPort = IONotificationPortCreate(masterPort); - hidMatchDictionary = IOServiceMatching(kIOHIDDeviceKey); - - CFRunLoopAddSource(CFRunLoopGetCurrent(), - IONotificationPortGetRunLoopSource(notificationPort), - kCFRunLoopDefaultMode); - - /* Register for notifications when a serial port is added to the system */ - result = IOServiceAddMatchingNotification(notificationPort, - kIOFirstMatchNotification, - hidMatchDictionary, - JoystickDeviceWasAddedCallback, - NULL, - &portIterator); - while (IOIteratorNext(portIterator)) {}; /* Run out the iterator or notifications won't start (you can also use it to iterate the available devices). */ - - return SDL_SYS_NumJoysticks(); -} - -/* Function to return the number of joystick devices plugged in right now */ -int -SDL_SYS_NumJoysticks() -{ - recDevice *device = gpDeviceList; - int nJoySticks = 0; - - while ( device ) - { - if ( !device->removed ) - nJoySticks++; - device = device->pNext; - } - - return nJoySticks; -} - -/* Function to cause any queued joystick insertions to be processed - */ -void -SDL_SYS_JoystickDetect() -{ - if ( s_bDeviceAdded || s_bDeviceRemoved ) - { - recDevice *device = gpDeviceList; - s_bDeviceAdded = SDL_FALSE; - s_bDeviceRemoved = SDL_FALSE; - int device_index = 0; - /* send notifications */ - while ( device ) - { - if ( device->send_open_event ) - { - device->send_open_event = 0; -#if !SDL_EVENTS_DISABLED - SDL_Event event; - event.type = SDL_JOYDEVICEADDED; - - if (SDL_GetEventState(event.type) == SDL_ENABLE) { - event.jdevice.which = device_index; - if ((SDL_EventOK == NULL) - || (*SDL_EventOK) (SDL_EventOKParam, &event)) { - SDL_PushEvent(&event); - } - } -#endif /* !SDL_EVENTS_DISABLED */ - - } - - if ( device->removed ) - { - recDevice *removeDevice = device; - if ( gpDeviceList == removeDevice ) - { - device = device->pNext; - gpDeviceList = device; - } - else - { - device = gpDeviceList; - while ( device->pNext != removeDevice ) - { - device = device->pNext; - } - - device->pNext = removeDevice->pNext; - } - -#if !SDL_EVENTS_DISABLED - SDL_Event event; - event.type = SDL_JOYDEVICEREMOVED; - - if (SDL_GetEventState(event.type) == SDL_ENABLE) { - event.jdevice.which = removeDevice->instance_id; - if ((SDL_EventOK == NULL) - || (*SDL_EventOK) (SDL_EventOKParam, &event)) { - SDL_PushEvent(&event); - } - } - - DisposePtr((Ptr) removeDevice); -#endif /* !SDL_EVENTS_DISABLED */ - - } - else - { - device = device->pNext; - device_index++; - } - } - } -} - -SDL_bool -SDL_SYS_JoystickNeedsPolling() -{ - return s_bDeviceAdded || s_bDeviceRemoved; -} - -/* Function to get the device-dependent name of a joystick */ -const char * -SDL_SYS_JoystickNameForDeviceIndex(int device_index) -{ - recDevice *device = gpDeviceList; - - for (; device_index > 0; device_index--) - device = device->pNext; - - return device->product; -} - -/* Function to return the instance id of the joystick at device_index - */ -SDL_JoystickID -SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index) -{ - recDevice *device = gpDeviceList; - int index; - - for (index = device_index; index > 0; index--) - device = device->pNext; - - return device->instance_id; -} - -/* Function to open a joystick for use. - * The joystick to open is specified by the index field of the joystick. - * This should fill the nbuttons and naxes fields of the joystick structure. - * It returns 0, or -1 if there is an error. - */ -int -SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) -{ - recDevice *device = gpDeviceList; - int index; - - for (index = device_index; index > 0; index--) - device = device->pNext; - - joystick->instance_id = device->instance_id; - joystick->hwdata = device; - joystick->name = device->product; - - joystick->naxes = device->axes; - joystick->nhats = device->hats; - joystick->nballs = 0; - joystick->nbuttons = device->buttons; - return 0; -} - -/* Function to query if the joystick is currently attached - * It returns 1 if attached, 0 otherwise. - */ -SDL_bool -SDL_SYS_JoystickAttached(SDL_Joystick * joystick) -{ - recDevice *device = gpDeviceList; - - while ( device ) - { - if ( joystick->instance_id == device->instance_id ) - return SDL_TRUE; - - device = device->pNext; - } - - return SDL_FALSE; -} - -/* Function to update the state of a joystick - called as a device poll. - * This function shouldn't update the joystick structure directly, - * but instead should call SDL_PrivateJoystick*() to deliver events - * and update joystick device state. - */ -void -SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) -{ - recDevice *device = joystick->hwdata; - recElement *element; - SInt32 value, range; - int i; - - if ( !device ) - return; - - if (device->removed) { /* device was unplugged; ignore it. */ - recDevice *devicelist = gpDeviceList; - joystick->closed = 1; - joystick->uncentered = 1; - - if ( devicelist == device ) - { - gpDeviceList = device->pNext; - } - else - { - while ( devicelist->pNext != device ) - { - devicelist = devicelist->pNext; - } - - devicelist->pNext = device->pNext; - } - - DisposePtr((Ptr) device); - joystick->hwdata = NULL; - -#if !SDL_EVENTS_DISABLED - SDL_Event event; - event.type = SDL_JOYDEVICEREMOVED; - - if (SDL_GetEventState(event.type) == SDL_ENABLE) { - event.jdevice.which = joystick->instance_id; - if ((SDL_EventOK == NULL) - || (*SDL_EventOK) (SDL_EventOKParam, &event)) { - SDL_PushEvent(&event); - } - } -#endif /* !SDL_EVENTS_DISABLED */ - - return; - } - - element = device->firstAxis; - i = 0; - while (element) { - value = HIDScaledCalibratedValue(device, element, -32768, 32767); - if (value != joystick->axes[i]) - SDL_PrivateJoystickAxis(joystick, i, value); - element = element->pNext; - ++i; - } - - element = device->firstButton; - i = 0; - while (element) { - value = HIDGetElementValue(device, element); - if (value > 1) /* handle pressure-sensitive buttons */ - value = 1; - if (value != joystick->buttons[i]) - SDL_PrivateJoystickButton(joystick, i, value); - element = element->pNext; - ++i; - } - - element = device->firstHat; - i = 0; - while (element) { - Uint8 pos = 0; - - range = (element->max - element->min + 1); - value = HIDGetElementValue(device, element) - element->min; - if (range == 4) /* 4 position hatswitch - scale up value */ - value *= 2; - else if (range != 8) /* Neither a 4 nor 8 positions - fall back to default position (centered) */ - value = -1; - switch (value) { - case 0: - pos = SDL_HAT_UP; - break; - case 1: - pos = SDL_HAT_RIGHTUP; - break; - case 2: - pos = SDL_HAT_RIGHT; - break; - case 3: - pos = SDL_HAT_RIGHTDOWN; - break; - case 4: - pos = SDL_HAT_DOWN; - break; - case 5: - pos = SDL_HAT_LEFTDOWN; - break; - case 6: - pos = SDL_HAT_LEFT; - break; - case 7: - pos = SDL_HAT_LEFTUP; - break; - default: - /* Every other value is mapped to center. We do that because some - * joysticks use 8 and some 15 for this value, and apparently - * there are even more variants out there - so we try to be generous. - */ - pos = SDL_HAT_CENTERED; - break; - } - if (pos != joystick->hats[i]) - SDL_PrivateJoystickHat(joystick, i, pos); - element = element->pNext; - ++i; - } - - return; -} - -/* Function to close a joystick after use */ -void -SDL_SYS_JoystickClose(SDL_Joystick * joystick) -{ - joystick->closed = 1; -} - -/* Function to perform any system-specific joystick related cleanup */ -void -SDL_SYS_JoystickQuit(void) -{ - while (NULL != gpDeviceList) - gpDeviceList = HIDDisposeDevice(&gpDeviceList); - - if ( notificationPort ) - { - IONotificationPortDestroy( notificationPort ); - notificationPort = 0; - } -} - - -SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) -{ - recDevice *device = gpDeviceList; - int index; - - for (index = device_index; index > 0; index--) - device = device->pNext; - - return device->guid; -} - -SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick *joystick) -{ - return joystick->hwdata->guid; -} - -#endif /* SDL_JOYSTICK_IOKIT */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.1/src/joystick/darwin/SDL_sysjoystick_c.h b/jni/SDL2-2.0.1/src/joystick/darwin/SDL_sysjoystick_c.h deleted file mode 100644 index a44d9a4b..00000000 --- a/jni/SDL2-2.0.1/src/joystick/darwin/SDL_sysjoystick_c.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "../../SDL_internal.h" - -#ifndef SDL_JOYSTICK_IOKIT_H - - -#include -#include -#include - - -struct recElement -{ - IOHIDElementCookie cookie; /* unique value which identifies element, will NOT change */ - long usagePage, usage; /* HID usage */ - long min; /* reported min value possible */ - long max; /* reported max value possible */ -#if 0 - /* TODO: maybe should handle the following stuff somehow? */ - - long scaledMin; /* reported scaled min value possible */ - long scaledMax; /* reported scaled max value possible */ - long size; /* size in bits of data return from element */ - Boolean relative; /* are reports relative to last report (deltas) */ - Boolean wrapping; /* does element wrap around (one value higher than max is min) */ - Boolean nonLinear; /* are the values reported non-linear relative to element movement */ - Boolean preferredState; /* does element have a preferred state (such as a button) */ - Boolean nullState; /* does element have null state */ -#endif /* 0 */ - - /* runtime variables used for auto-calibration */ - long minReport; /* min returned value */ - long maxReport; /* max returned value */ - - struct recElement *pNext; /* next element in list */ -}; -typedef struct recElement recElement; - -struct joystick_hwdata -{ - io_service_t ffservice; /* Interface for force feedback, 0 = no ff */ - IOHIDDeviceInterface **interface; /* interface to device, NULL = no interface */ - IONotificationPortRef notificationPort; /* port to be notified on joystick removal */ - io_iterator_t portIterator; /* iterator for removal callback */ - - char product[256]; /* name of product */ - long usage; /* usage page from IOUSBHID Parser.h which defines general usage */ - long usagePage; /* usage within above page from IOUSBHID Parser.h which defines specific usage */ - - long axes; /* number of axis (calculated, not reported by device) */ - long buttons; /* number of buttons (calculated, not reported by device) */ - long hats; /* number of hat switches (calculated, not reported by device) */ - long elements; /* number of total elements (should be total of above) (calculated, not reported by device) */ - - recElement *firstAxis; - recElement *firstButton; - recElement *firstHat; - - int removed; - int uncentered; - - int instance_id; - SDL_JoystickGUID guid; - Uint8 send_open_event; /* 1 if we need to send an Added event for this device */ - - struct joystick_hwdata *pNext; /* next device */ -}; -typedef struct joystick_hwdata recDevice; - - -#endif /* SDL_JOYSTICK_IOKIT_H */ diff --git a/jni/SDL2-2.0.1/src/render/software/SDL_rotate.h b/jni/SDL2-2.0.1/src/render/software/SDL_rotate.h deleted file mode 100644 index 31d12a48..00000000 --- a/jni/SDL2-2.0.1/src/render/software/SDL_rotate.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef MIN -#define MIN(a,b) (((a) < (b)) ? (a) : (b)) -#endif - -extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle); -extern void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, int *dstwidth, int *dstheight, double *cangle, double *sangle); - diff --git a/jni/SDL2-2.0.1/Android.mk b/jni/SDL2-2.0.3/Android.mk similarity index 91% rename from jni/SDL2-2.0.1/Android.mk rename to jni/SDL2-2.0.3/Android.mk index 37fda25d..af8f3dad 100755 --- a/jni/SDL2-2.0.1/Android.mk +++ b/jni/SDL2-2.0.3/Android.mk @@ -43,12 +43,13 @@ LOCAL_SRC_FILES := \ $(wildcard $(LOCAL_PATH)/src/timer/*.c) \ $(wildcard $(LOCAL_PATH)/src/timer/unix/*.c) \ $(wildcard $(LOCAL_PATH)/src/video/*.c) \ - $(wildcard $(LOCAL_PATH)/src/video/android/*.c)) + $(wildcard $(LOCAL_PATH)/src/video/android/*.c) \ + $(wildcard $(LOCAL_PATH)/src/test/*.c)) LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -llog -landroid -# include $(BUILD_SHARED_LIBRARY) +include $(BUILD_SHARED_LIBRARY) ########################### # @@ -60,7 +61,7 @@ LOCAL_MODULE := SDL2_static LOCAL_MODULE_FILENAME := libSDL2 -LOCAL_SRC_FILES += src/main/android/SDL_android_main.c +LOCAL_SRC_FILES += ./src/main/android/SDL_android_main.c LOCAL_LDLIBS := LOCAL_EXPORT_LDLIBS := -Wl,--undefined=Java_org_libsdl_app_SDLActivity_nativeInit -ldl -lGLESv1_CM -lGLESv2 -llog -landroid diff --git a/jni/SDL2-2.0.1/BUGS.txt b/jni/SDL2-2.0.3/BUGS.txt similarity index 100% rename from jni/SDL2-2.0.1/BUGS.txt rename to jni/SDL2-2.0.3/BUGS.txt diff --git a/jni/SDL2-2.0.1/CMakeLists.txt b/jni/SDL2-2.0.3/CMakeLists.txt similarity index 92% rename from jni/SDL2-2.0.1/CMakeLists.txt rename to jni/SDL2-2.0.3/CMakeLists.txt index 08c56589..75a89378 100644 --- a/jni/SDL2-2.0.1/CMakeLists.txt +++ b/jni/SDL2-2.0.3/CMakeLists.txt @@ -29,17 +29,20 @@ include(${SDL2_SOURCE_DIR}/cmake/sdlchecks.cmake) # set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0. set(SDL_MAJOR_VERSION 2) set(SDL_MINOR_VERSION 0) -set(SDL_MICRO_VERSION 1) +set(SDL_MICRO_VERSION 3) set(SDL_INTERFACE_AGE 1) -set(SDL_BINARY_AGE 1) +set(SDL_BINARY_AGE 3) set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}") # Calculate a libtool-like version number math(EXPR LT_CURRENT "${SDL_MICRO_VERSION} - ${SDL_INTERFACE_AGE}") math(EXPR LT_AGE "${SDL_BINARY_AGE} - ${SDL_INTERFACE_AGE}") +math(EXPR LT_MAJOR "${LT_CURRENT}- ${LT_AGE}") set(LT_REVISION "${SDL_INTERFACE_AGE}") set(LT_RELEASE "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}") -set(LT_VERSION "${LT_CURRENT}.${LT_REVISION}.${LT_AGE}") +set(LT_VERSION "${LT_MAJOR}.${LT_AGE}.${LT_REVISION}") + +message(STATUS "${LT_VERSION} :: ${LT_AGE} :: ${LT_REVISION} :: ${LT_CURRENT} :: ${LT_RELEASE}") # General settings & flags set(LIBRARY_OUTPUT_DIRECTORY "build") @@ -51,17 +54,17 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8) else() set(ARCH_64 FALSE) set(PROCESSOR_ARCH "x86") -endif(CMAKE_SIZEOF_VOID_P EQUAL 8) +endif() set(LIBNAME SDL2) if(NOT LIBTYPE) set(LIBTYPE SHARED) -endif(NOT LIBTYPE) +endif() # Get the platform if(WIN32) if(NOT WINDOWS) set(WINDOWS TRUE) - endif(NOT WINDOWS) + endif() elseif(UNIX AND NOT APPLE) if(CMAKE_SYSTEM_NAME MATCHES ".*Linux") set(LINUX TRUE) @@ -106,13 +109,13 @@ if(UNIX AND NOT APPLE) set(UNIX_SYS ON) else() set(UNIX_SYS OFF) -endif(UNIX AND NOT APPLE) +endif() if(UNIX OR APPLE) set(UNIX_OR_MAC_SYS ON) else() set(UNIX_OR_MAC_SYS OFF) -endif(UNIX OR APPLE) +endif() # Default option knobs if(APPLE OR ARCH_64) @@ -120,7 +123,7 @@ if(APPLE OR ARCH_64) endif() if(UNIX OR MINGW OR MSYS) set(OPT_DEF_LIBC ON) -endif(UNIX OR MINGW OR MSYS) +endif() # Compiler info if(CMAKE_COMPILER_IS_GNUCC) @@ -134,20 +137,33 @@ elseif(MSVC_VERSION GREATER 1400) # VisualStudio 8.0+ #set(CMAKE_C_FLAGS "/ZI /WX- / else() set(OPT_DEF_ASM FALSE) -endif(CMAKE_COMPILER_IS_GNUCC) +endif() # Default flags, if not set otherwise if("$ENV{CFLAGS}" STREQUAL "") if(USE_GCC OR USE_CLANG) set(CMAKE_C_FLAGS "-g -O3") - endif(USE_GCC OR USE_CLANG) + endif() else("$ENV{CFLAGS}" STREQUAL "") set(CMAKE_C_FLAGS "$ENV{CFLAGS}") list(APPEND EXTRA_CFLAGS "$ENV{CFLAGS}") -endif("$ENV{CFLAGS}" STREQUAL "") +endif() if(NOT ("$ENV{CFLAGS}" STREQUAL "")) # Hackish, but does the trick on Win32 list(APPEND EXTRA_LDFLAGS "$ENV{LDFLAGS}") -endif(NOT ("$ENV{CFLAGS}" STREQUAL "")) +endif() + +if(MSVC) + option(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF) + if(FORCE_STATIC_VCRT) + foreach(flag_var + CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE + CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) + if(${flag_var} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") + endif() + endforeach(flag_var) + endif() +endif() # Those are used for pkg-config and friends, so that the SDL2.pc, sdl2-config, # etc. are created correctly. @@ -164,9 +180,9 @@ if(CYGWIN) if(HAVE_GCC_NO_CYGWIN) list(APPEND EXTRA_LDFLAGS "-mno-cygwin") list(APPEND SDL_LIBS "-mno-cygwin") - endif(HAVE_GCC_NO_CYGWIN) + endif() set(SDL_CFLAGS "${SDL_CFLAGS} -I/usr/include/mingw") -endif(CYGWIN) +endif() add_definitions(-DUSING_GENERATED_CONFIG_H) # General includes @@ -219,7 +235,8 @@ set_option(RPATH "Use an rpath when linking SDL" ${UNIX_SYS}) set_option(CLOCK_GETTIME "Use clock_gettime() instead of gettimeofday()" OFF) set_option(INPUT_TSLIB "Use the Touchscreen library for input" ${UNIX_SYS}) set_option(VIDEO_X11 "Use X11 video driver" ${UNIX_SYS}) -set_option(VIDEO_WAYLAND "Use Wayland video driver" ${UNIX_SYS}) +set_option(VIDEO_WAYLAND "Use Wayland video driver" OFF) #${UNIX_SYS}) +set_option(VIDEO_MIR "Use Mir video driver" OFF) #${UNIX_SYS}) dep_option(X11_SHARED "Dynamically load X11 support" ON "VIDEO_X11" OFF) set(SDL_X11_OPTIONS Xcursor Xinerama XInput Xrandr Xscrnsaver XShape Xvm) foreach(_SUB ${SDL_X11_OPTIONS}) @@ -265,7 +282,7 @@ elseif(ASSERTIONS STREQUAL "paranoid") set(SDL_DEFAULT_ASSERT_LEVEL 3) else() message_error("unknown assertion level") -endif(ASSERTIONS STREQUAL "auto") +endif() set(HAVE_ASSERTIONS ${ASSERTIONS}) # Compiler option evaluation @@ -276,7 +293,7 @@ if(USE_GCC OR USE_CLANG) #error Dependency tracking requires GCC 3.0 or newer #endif int main(int argc, char **argv) { }" HAVE_DEPENDENCY_TRACKING) - endif(DEPENDENCY_TRACKING) + endif() if(GCC_ATOMICS) check_c_source_compiles("int main(int argc, char **argv) { @@ -292,8 +309,8 @@ if(USE_GCC OR USE_CLANG) int a; __sync_lock_test_and_set(&a, 1); __sync_lock_release(&a); }" HAVE_GCC_SYNC_LOCK_TEST_AND_SET) - endif(NOT HAVE_GCC_ATOMICS) - endif(GCC_ATOMICS) + endif() + endif() set(CMAKE_REQUIRED_FLAGS "-mpreferred-stack-boundary=2") check_c_source_compiles("int x = 0; int main(int argc, char **argv) {}" @@ -308,16 +325,16 @@ if(USE_GCC OR USE_CLANG) int main(int argc, char **argv) {}" HAVE_GCC_FVISIBILITY) if(HAVE_GCC_FVISIBILITY) list(APPEND EXTRA_CFLAGS "-fvisibility=hidden") - endif(HAVE_GCC_FVISIBILITY) + endif() set(CMAKE_REQUIRED_FLAGS) check_c_compiler_flag(-Wall HAVE_GCC_WALL) if(HAVE_GCC_WALL) if(HAIKU) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar") - endif(HAIKU) - endif(HAVE_GCC_WALL) -endif(USE_GCC OR USE_CLANG) + endif() + endif() +endif() if(ASSEMBLY) if(USE_GCC OR USE_CLANG) @@ -344,9 +361,9 @@ if(ASSEMBLY) int main(int argc, char **argv) { }" HAVE_MMX) if(HAVE_MMX) list(APPEND EXTRA_CFLAGS "-mmmx") - endif(HAVE_MMX) + endif() set(CMAKE_REQUIRED_FLAGS) - endif(MMX) + endif() if(3DNOW) set(CMAKE_REQUIRED_FLAGS "-m3dnow") @@ -361,9 +378,9 @@ if(ASSEMBLY) }" HAVE_3DNOW) if(HAVE_3DNOW) list(APPEND EXTRA_CFLAGS "-m3dnow") - endif(HAVE_3DNOW) + endif() set(CMAKE_REQUIRED_FLAGS) - endif(3DNOW) + endif() if(SSE) set(CMAKE_REQUIRED_FLAGS "-msse") @@ -384,9 +401,9 @@ if(ASSEMBLY) int main(int argc, char **argv) { }" HAVE_SSE) if(HAVE_SSE) list(APPEND EXTRA_CFLAGS "-msse") - endif(HAVE_SSE) + endif() set(CMAKE_REQUIRED_FLAGS) - endif(SSE) + endif() if(SSE2) set(CMAKE_REQUIRED_FLAGS "-msse2") @@ -407,18 +424,18 @@ if(ASSEMBLY) int main(int argc, char **argv) { }" HAVE_SSE2) if(HAVE_SSE2) list(APPEND EXTRA_CFLAGS "-msse2") - endif(HAVE_SSE2) + endif() set(CMAKE_REQUIRED_FLAGS) - endif(SSE2) + endif() if(SSEMATH) if(SSE OR SSE2) if(USE_GCC) list(APPEND EXTRA_CFLAGS "-mfpmath=387") - endif(USE_GCC) + endif() set(HAVE_SSEMATH TRUE) - endif(SSE OR SSE2) - endif(SSEMATH) + endif() + endif() if(ALTIVEC) set(CMAKE_REQUIRED_FLAGS "-maltivec") @@ -440,26 +457,26 @@ if(ASSEMBLY) set(SDL_ALTIVEC_BLITTERS 1) if(HAVE_ALTIVEC_H_HDR) set(HAVE_ALTIVEC_H 1) - endif(HAVE_ALTIVEC_H_HDR) - endif(HAVE_ALTIVEC OR HAVE_ALTIVEC_H_HDR) - endif(ALTIVEC) + endif() + endif() + endif() elseif(MSVC_VERSION GREATER 1500) # TODO: SDL_cpuinfo.h needs to support the user's configuration wish # for MSVC - right now it is always activated if(NOT ARCH_64) set(HAVE_MMX TRUE) set(HAVE_3DNOW TRUE) - endif(NOT ARCH_64) + endif() set(HAVE_SSE TRUE) set(HAVE_SSE2 TRUE) set(SDL_ASSEMBLY_ROUTINES 1) - endif(USE_GCC OR USE_CLANG) + endif() # TODO: #else(ASSEMBLY) # if(USE_GCC OR USE_CLANG) # list(APPEND EXTRA_CFLAGS "-mno-sse" "-mno-sse2" "-mno-mmx") -# endif(USE_GCC OR USE_CLANG) -endif(ASSEMBLY) +# endif() +endif() # TODO: Can't deactivate on FreeBSD? w/o LIBC, SDL_stdinc.h can't define # anything. @@ -483,7 +500,7 @@ if(LIBC) endforeach() if(NOT CYGWIN AND NOT MINGW) set(HAVE_ALLOCA 1) - endif(NOT CYGWIN AND NOT MINGW) + endif() set(HAVE_M_PI 1) add_definitions(-D_USE_MATH_DEFINES) # needed for M_PI set(STDC_HEADERS 1) @@ -531,21 +548,21 @@ if(LIBC) endforeach() set(CMAKE_REQUIRED_LIBRARIES) list(APPEND EXTRA_LIBS m) - endif(HAVE_LIBM) + endif() check_library_exists(iconv iconv_open "" HAVE_LIBICONV) if(HAVE_LIBICONV) list(APPEND EXTRA_LIBS iconv) - endif(HAVE_LIBICONV) + endif() check_struct_has_member("struct sigaction" "sa_sigaction" "signal.h" HAVE_SA_SIGACTION) - endif(WINDOWS AND NOT MINGW) + endif() else(LIBC) if(WINDOWS) set(HAVE_STDARG_H 1) set(HAVE_STDDEF_H 1) - endif(WINDOWS) -endif(LIBC) + endif() +endif() # Enable/disable various subsystems of the SDL library @@ -553,24 +570,24 @@ foreach(_SUB ${SDL_SUBSYSTEMS}) string(TOUPPER ${_SUB} _OPT) if(NOT SDL_${_OPT}) set(SDL_${_OPT}_DISABLED 1) - endif(NOT SDL_${_OPT}) + endif() endforeach() if(SDL_JOYSTICK) file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES}) -endif(SDL_JOYSTICK) +endif() if(SDL_HAPTIC) if(NOT SDL_JOYSTICK) # Haptic requires some private functions from the joystick subsystem. message_error("SDL_HAPTIC requires SDL_JOYSTICK, which is not enabled") - endif(NOT SDL_JOYSTICK) + endif() file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES}) -endif(SDL_HAPTIC) +endif() if(SDL_POWER) file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES}) -endif(SDL_POWER) +endif() # TODO: in configure.in, the test for LOADSO and SDL_DLOPEN is a bit weird: # if LOADSO is not wanted, SDL_LOADSO_DISABLED is set # If however on Unix or APPLE dlopen() is detected via CheckDLOPEN(), @@ -584,21 +601,21 @@ if(SDL_AUDIO) file(GLOB DUMMYAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/dummy/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${DUMMYAUDIO_SOURCES}) set(HAVE_DUMMYAUDIO TRUE) - endif(DUMMYAUDIO) + endif() if(DISKAUDIO) set(SDL_AUDIO_DRIVER_DISK 1) file(GLOB DISKAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/disk/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${DISKAUDIO_SOURCES}) set(HAVE_DISKAUDIO TRUE) - endif(DISKAUDIO) -endif(SDL_AUDIO) + endif() +endif() if(SDL_DLOPEN) # Relevant for Unix/Darwin only if(UNIX OR APPLE) CheckDLOPEN() - endif(UNIX OR APPLE) -endif(SDL_DLOPEN) + endif() +endif() if(SDL_VIDEO) if(VIDEO_DUMMY) @@ -607,8 +624,8 @@ if(SDL_VIDEO) set(SOURCE_FILES ${SOURCE_FILES} ${VIDEO_DUMMY_SOURCES}) set(HAVE_VIDEO_DUMMY TRUE) set(HAVE_SDL_VIDEO TRUE) - endif(VIDEO_DUMMY) -endif(SDL_VIDEO) + endif() +endif() # Platform-specific options and settings if(UNIX AND NOT APPLE) @@ -637,15 +654,16 @@ if(UNIX AND NOT APPLE) CheckNAS() CheckSNDIO() CheckFusionSound() - endif(SDL_AUDIO) + endif() if(SDL_VIDEO) CheckX11() + CheckMir() CheckDirectFB() CheckOpenGLX11() CheckOpenGLESX11() CheckWayland() - endif(SDL_VIDEO) + endif() if(LINUX) check_c_source_compiles(" @@ -671,24 +689,24 @@ if(UNIX AND NOT APPLE) if(HAVE_INPUT_EVENTS) set(SDL_INPUT_LINUXEV 1) - endif(HAVE_INPUT_EVENTS) + endif() if(SDL_HAPTIC AND HAVE_INPUT_EVENTS) set(SDL_HAPTIC_LINUX 1) file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/linux/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES}) set(HAVE_SDL_HAPTIC TRUE) - endif(SDL_HAPTIC AND HAVE_INPUT_EVENTS) + endif() if(HAVE_INPUT_KD) set(SDL_INPUT_LINUXKD 1) - endif(HAVE_INPUT_KD) + endif() check_include_file("libudev.h" HAVE_LIBUDEV_H) # !!! FIXME: this needs pkg-config to find the include path, I think. check_include_file("dbus/dbus.h" HAVE_DBUS_DBUS_H) - endif(LINUX) + endif() if(INPUT_TSLIB) check_c_source_compiles(" @@ -697,8 +715,8 @@ if(UNIX AND NOT APPLE) if(HAVE_INPUT_TSLIB) set(SDL_INPUT_TSLIB 1) list(APPEND EXTRA_LIBS ts) - endif(HAVE_INPUT_TSLIB) - endif(INPUT_TSLIB) + endif() + endif() if(SDL_JOYSTICK) CheckUSBHID() # seems to be BSD specific - limit the test to BSD only? @@ -707,8 +725,8 @@ if(UNIX AND NOT APPLE) file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/linux/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES}) set(HAVE_SDL_JOYSTICK TRUE) - endif(LINUX) - endif(SDL_JOYSTICK) + endif() + endif() CheckPTHREAD() @@ -721,14 +739,14 @@ if(UNIX AND NOT APPLE) check_library_exists(c clock_gettime "" FOUND_CLOCK_GETTIME) if(FOUND_CLOCK_GETTIME) set(HAVE_CLOCK_GETTIME 1) - endif(FOUND_CLOCK_GETTIME) - endif(HAVE_CLOCK_GETTIME) - endif(CLOCK_GETTIME) + endif() + endif() + endif() check_include_file(linux/version.h HAVE_LINUX_VERSION_H) if(HAVE_LINUX_VERSION_H) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_LINUX_VERSION_H") - endif(HAVE_LINUX_VERSION_H) + endif() if(SDL_POWER) if(LINUX) @@ -736,22 +754,22 @@ if(UNIX AND NOT APPLE) file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/linux/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES}) set(HAVE_SDL_POWER TRUE) - endif(LINUX) - endif(SDL_POWER) + endif() + endif() if(SDL_FILESYSTEM) set(SDL_FILESYSTEM_UNIX 1) file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/unix/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES}) set(HAVE_SDL_FILESYSTEM TRUE) - endif(SDL_FILESYSTEM) + endif() if(SDL_TIMERS) set(SDL_TIMER_UNIX 1) file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES}) set(HAVE_SDL_TIMERS TRUE) - endif(SDL_TIMERS) + endif() if(RPATH) set(SDL_RLD_FLAGS "") @@ -762,7 +780,7 @@ if(UNIX AND NOT APPLE) endif() set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(HAVE_RPATH TRUE) - endif(RPATH) + endif() elseif(WINDOWS) find_program(WINDRES windres) @@ -778,21 +796,22 @@ elseif(WINDOWS) if(DIRECTX) if("$ENV{DXSDK_DIR}" STREQUAL "") message_error("DIRECTX requires the \$DXSDK_DIR environment variable to be set") - endif("$ENV{DXSDK_DIR}" STREQUAL "") + endif() set(CMAKE_REQUIRED_FLAGS "/I\"$ENV{DXSDK_DIR}\\Include\"") check_include_file(d3d9.h HAVE_D3D_H) + check_include_file(d3d11_1.h HAVE_D3D11_H) check_include_file(ddraw.h HAVE_DDRAW_H) check_include_file(dsound.h HAVE_DSOUND_H) check_include_file(dinput.h HAVE_DINPUT_H) check_include_file(xaudio2.h HAVE_XAUDIO2_H) - if(HAVE_D3D_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H) + if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H) set(HAVE_DIRECTX TRUE) # TODO: change $ENV{DXSDL_DIR} to get the path from the include checks link_directories($ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH}) include_directories($ENV{DXSDK_DIR}\\Include) endif() set(CMAKE_REQUIRED_FLAGS) - endif(DIRECTX) + endif() if(SDL_AUDIO) set(SDL_AUDIO_DRIVER_WINMM 1) @@ -804,20 +823,20 @@ elseif(WINDOWS) set(SDL_AUDIO_DRIVER_DSOUND 1) file(GLOB DSOUND_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/directsound/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${DSOUND_AUDIO_SOURCES}) - endif(HAVE_DSOUND_H) + endif() if(HAVE_XAUDIO2_H) set(SDL_AUDIO_DRIVER_XAUDIO2 1) file(GLOB XAUDIO2_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/xaudio2/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${XAUDIO2_AUDIO_SOURCES}) - endif(HAVE_XAUDIO2_H) - endif(SDL_AUDIO) + endif() + endif() if(SDL_VIDEO) # requires SDL_LOADSO on Windows (IME, DX, etc.) if(NOT SDL_LOADSO) message_error("SDL_VIDEO requires SDL_LOADSO, which is not enabled") - endif(NOT SDL_LOADSO) + endif() set(SDL_VIDEO_DRIVER_WINDOWS 1) file(GLOB WIN_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/windows/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${WIN_VIDEO_SOURCES}) @@ -825,9 +844,13 @@ elseif(WINDOWS) if(RENDER_D3D AND HAVE_D3D_H) set(SDL_VIDEO_RENDER_D3D 1) set(HAVE_RENDER_D3D TRUE) - endif(RENDER_D3D AND HAVE_D3D_H) + endif() + if(RENDER_D3D AND HAVE_D3D11_H) + set(SDL_VIDEO_RENDER_D3D11 1) + set(HAVE_RENDER_D3D TRUE) + endif() set(HAVE_SDL_VIDEO TRUE) - endif(SDL_VIDEO) + endif() if(SDL_THREADS) set(SDL_THREAD_WINDOWS 1) @@ -838,20 +861,20 @@ elseif(WINDOWS) ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_systls.c ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syscond.c) set(HAVE_SDL_THREADS TRUE) - endif(SDL_THREADS) + endif() if(SDL_POWER) set(SDL_POWER_WINDOWS 1) set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/power/windows/SDL_syspower.c) set(HAVE_SDL_POWER TRUE) - endif(SDL_POWER) + endif() if(SDL_FILESYSTEM) set(SDL_FILESYSTEM_WINDOWS 1) file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/windows/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES}) set(HAVE_SDL_FILESYSTEM TRUE) - endif(SDL_FILESYSTEM) + endif() # Libraries for Win32 native and MinGW list(APPEND EXTRA_LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid) @@ -863,14 +886,14 @@ elseif(WINDOWS) file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/windows/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES}) set(HAVE_SDL_TIMERS TRUE) - endif(SDL_TIMERS) + endif() if(SDL_LOADSO) set(SDL_LOADSO_WINDOWS 1) file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/windows/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES}) set(HAVE_SDL_LOADSO TRUE) - endif(SDL_LOADSO) + endif() file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/windows/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES}) @@ -881,8 +904,8 @@ elseif(WINDOWS) set(SDL_VIDEO_OPENGL_WGL 1) set(SDL_VIDEO_RENDER_OGL 1) set(HAVE_VIDEO_OPENGL TRUE) - endif(VIDEO_OPENGL) - endif(SDL_VIDEO) + endif() + endif() if(SDL_JOYSTICK) if(HAVE_DINPUT_H) @@ -892,15 +915,15 @@ elseif(WINDOWS) else() set(SDL_JOYSTICK_WINMM 1) set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/joystick/windows/SDL_mmjoystick.c) - endif(HAVE_DINPUT_H) + endif() set(HAVE_SDL_JOYSTICK TRUE) - endif(SDL_JOYSTICK) + endif() if(SDL_HAPTIC AND HAVE_DINPUT_H) set(SDL_HAPTIC_DINPUT 1) set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/haptic/windows/SDL_syshaptic.c) set(HAVE_SDL_HAPTIC TRUE) - endif(SDL_HAPTIC AND HAVE_DINPUT_H) + endif() file(GLOB VERSION_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.rc) file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.c) @@ -909,7 +932,7 @@ elseif(WINDOWS) list(APPEND EXTRA_LDFLAGS "-mwindows") set(SDL_CFLAGS "${SDL_CFLAGS} -Dmain=SDL_main") list(APPEND SDL_LIBS "-lmingw32" "-lSDL2main" "-mwindows") - endif(MINGW OR CYGWIN) + endif() elseif(APPLE) # TODO: rework this for proper MacOS X, iOS and Darwin support @@ -963,9 +986,17 @@ elseif(APPLE) set(SDL_FRAMEWORK_IOKIT 1) endif() + if(SDL_TIMERS) + set(SDL_TIMER_UNIX 1) + file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES}) + set(HAVE_SDL_TIMERS TRUE) + endif(SDL_TIMERS) + if(SDL_FILESYSTEM) set(SDL_FILESYSTEM_COCOA 1) file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/cocoa/*.m) + set_source_files_properties(${FILESYSTEM_SOURCES} PROPERTIES LANGUAGE C) set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES}) set(HAVE_SDL_FILESYSTEM TRUE) endif() @@ -1006,10 +1037,10 @@ elseif(APPLE) if(DARWIN) find_library(OpenGL_LIBRARY OpenGL) list(APPEND EXTRA_LIBRARIES ${OpenGL_LIBRARY}) - endif(DARWIN) + endif() set(HAVE_VIDEO_OPENGL TRUE) - endif(VIDEO_OPENGL) - endif(SDL_VIDEO) + endif() + endif() CheckPTHREAD() elseif(HAIKU) @@ -1024,6 +1055,13 @@ elseif(HAIKU) set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES}) set(HAVE_SDL_FILESYSTEM TRUE) + if(SDL_TIMERS) + set(SDL_TIMER_HAIKU 1) + file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/haiku/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES}) + set(HAVE_SDL_TIMERS TRUE) + endif(SDL_TIMERS) + if(VIDEO_OPENGL) # TODO: Use FIND_PACKAGE(OpenGL) instead set(SDL_VIDEO_OPENGL 1) @@ -1031,8 +1069,8 @@ elseif(HAIKU) set(SDL_VIDEO_RENDER_OGL 1) list(APPEND EXTRA_LIBS GL) set(HAVE_VIDEO_OPENGL TRUE) - endif(VIDEO_OPENGL) - endif(SDL_VIDEO) + endif() + endif() CheckPTHREAD() endif() @@ -1052,45 +1090,45 @@ if(NOT HAVE_SDL_JOYSTICK) file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/dummy/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES}) endif() -endif(NOT HAVE_SDL_JOYSTICK) +endif() if(NOT HAVE_SDL_HAPTIC) set(SDL_HAPTIC_DISABLED 1) file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/dummy/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES}) -endif(NOT HAVE_SDL_HAPTIC) +endif() if(NOT HAVE_SDL_LOADSO) set(SDL_LOADSO_DISABLED 1) file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dummy/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES}) -endif(NOT HAVE_SDL_LOADSO) +endif() if(NOT HAVE_SDL_FILESYSTEM) set(SDL_FILESYSTEM_DISABLED 1) file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/dummy/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES}) -endif(NOT HAVE_SDL_FILESYSTEM) +endif() # We always need to have threads and timers around if(NOT HAVE_SDL_THREADS) set(SDL_THREADS_DISABLED 1) file(GLOB THREADS_SOURCES ${SDL2_SOURCE_DIR}/src/thread/generic/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${THREADS_SOURCES}) -endif(NOT HAVE_SDL_THREADS) +endif() if(NOT HAVE_SDL_TIMERS) set(SDL_TIMERS_DISABLED 1) file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/dummy/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES}) -endif(NOT HAVE_SDL_TIMERS) +endif() if(NOT SDLMAIN_SOURCES) file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/dummy/*.c) -endif(NOT SDLMAIN_SOURCES) +endif() # Append the -MMD -MT flags # if(DEPENDENCY_TRACKING) # if(COMPILER_IS_GNUCC) # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MMD -MT \$@") -# endif(COMPILER_IS_GNUCC) -# endif(DEPENDENCY_TRACKING) +# endif() +# endif() configure_file("${SDL2_SOURCE_DIR}/include/SDL_config.h.cmake" "${SDL2_BINARY_DIR}/include/SDL_config.h") @@ -1098,13 +1136,13 @@ configure_file("${SDL2_SOURCE_DIR}/include/SDL_config.h.cmake" # Prepare the flags and remove duplicates if(EXTRA_LDFLAGS) list(REMOVE_DUPLICATES EXTRA_LDFLAGS) -endif(EXTRA_LDFLAGS) +endif() if(EXTRA_LIBS) list(REMOVE_DUPLICATES EXTRA_LIBS) -endif(EXTRA_LIBS) +endif() if(EXTRA_CFLAGS) list(REMOVE_DUPLICATES EXTRA_CFLAGS) -endif(EXTRA_CFLAGS) +endif() listtostr(EXTRA_CFLAGS _EXTRA_CFLAGS) set(EXTRA_CFLAGS ${_EXTRA_CFLAGS}) @@ -1124,14 +1162,14 @@ if(NOT WINDOWS OR CYGWIN) else(SDL_STATIC) set(ENABLE_STATIC_TRUE "#") set(ENABLE_STATIC_FALSE "") - endif(SDL_STATIC) + endif() if(SDL_SHARED) set(ENABLE_SHARED_TRUE "") set(ENABLE_SHARED_FALSE "#") else(SDL_SHARED) set(ENABLE_SHARED_TRUE "#") set(ENABLE_SHARED_FALSE "") - endif(SDL_SHARED) + endif() # Clean up the different lists listtostr(EXTRA_LIBS _EXTRA_LIBS "-l") @@ -1153,7 +1191,7 @@ if(NOT WINDOWS OR CYGWIN) "${SDL2_BINARY_DIR}/sdl2-config" @ONLY) configure_file("${SDL2_SOURCE_DIR}/SDL2.spec.in" "${SDL2_BINARY_DIR}/SDL2.spec" @ONLY) -endif(NOT WINDOWS OR CYGWIN) +endif() ##### Info output ##### message(STATUS "") @@ -1193,7 +1231,7 @@ if(UNIX) message(STATUS "were installed, then make sure you have set the") message(STATUS "CFLAGS and LDFLAGS environment variables correctly.") message(STATUS "") -endif(UNIX) +endif() # Ensure that the extra cflags are used at compile time set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") @@ -1207,26 +1245,32 @@ if(SDL_SHARED) if(UNIX) set_target_properties(SDL2 PROPERTIES VERSION ${LT_VERSION} - SOVERSION ${LT_CURRENT} + SOVERSION ${LT_REVISION} OUTPUT_NAME "SDL2-${LT_RELEASE}") else(UNIX) set_target_properties(SDL2 PROPERTIES VERSION ${SDL_VERSION} - SOVERSION ${LT_CURRENT} + SOVERSION ${LT_REVISION} OUTPUT_NAME "SDL2") - endif(UNIX) + endif() set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS}) target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS}) -endif(SDL_SHARED) +endif() if(SDL_STATIC) + set (BUILD_SHARED_LIBS FALSE) add_library(SDL2-static STATIC ${SOURCE_FILES}) set_target_properties(SDL2-static PROPERTIES OUTPUT_NAME "SDL2") + if(MSVC) + set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB") + set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB") + set_target_properties(SDL2-static PROPERTIES STATIC_LIBRARY_FLAGS "/NODEFAULTLIB") + endif() # TODO: Win32 platforms keep the same suffix .lib for import and static # libraries - do we need to consider this? set(_INSTALL_LIBS "SDL2-static" ${_INSTALL_LIBS}) target_link_libraries(SDL2-static ${EXTRA_LIBS} ${EXTRA_LDFLAGS}) -endif(SDL_STATIC) +endif() ##### Installation targets ##### install(TARGETS ${_INSTALL_LIBS} @@ -1242,22 +1286,24 @@ endforeach() list(APPEND INCLUDE_FILES ${BIN_INCLUDE_FILES}) install(FILES ${INCLUDE_FILES} DESTINATION include/SDL2) -if(SDL_SHARED) - install(CODE " - execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink - \"libSDL2-2.0.so\" \"libSDL2.so\")") - install(FILES ${SDL2_BINARY_DIR}/libSDL2.so DESTINATION "lib${LIB_SUFFIX}") -endif(SDL_SHARED) - if(NOT WINDOWS OR CYGWIN) + if(SDL_SHARED) + install(CODE " + execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink + \"libSDL2-2.0.so\" \"libSDL2.so\")") + install(FILES ${SDL2_BINARY_DIR}/libSDL2.so DESTINATION "lib${LIB_SUFFIX}") + endif() if(FREEBSD) # FreeBSD uses ${PREFIX}/libdata/pkgconfig install(FILES ${SDL2_BINARY_DIR}/sdl2.pc DESTINATION "libdata/pkgconfig") else(FREEBSD) install(FILES ${SDL2_BINARY_DIR}/sdl2.pc DESTINATION "lib${LIB_SUFFIX}/pkgconfig") - endif(FREEBSD) + endif() install(PROGRAMS ${SDL2_BINARY_DIR}/sdl2-config DESTINATION bin) # TODO: what about the .spec file? Is it only needed for RPM creation? install(FILES "${SDL2_SOURCE_DIR}/sdl2.m4" DESTINATION "share/aclocal") -endif(NOT WINDOWS OR CYGWIN) +else() + install(TARGETS SDL2 RUNTIME DESTINATION bin) +endif() + diff --git a/jni/SDL2-2.0.1/COPYING.txt b/jni/SDL2-2.0.3/COPYING.txt similarity index 91% rename from jni/SDL2-2.0.1/COPYING.txt rename to jni/SDL2-2.0.3/COPYING.txt index 391424f7..e0d7cc43 100644 --- a/jni/SDL2-2.0.1/COPYING.txt +++ b/jni/SDL2-2.0.3/COPYING.txt @@ -1,6 +1,6 @@ Simple DirectMedia Layer -Copyright (C) 1997-2013 Sam Lantinga +Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/CREDITS.txt b/jni/SDL2-2.0.3/CREDITS.txt similarity index 100% rename from jni/SDL2-2.0.1/CREDITS.txt rename to jni/SDL2-2.0.3/CREDITS.txt diff --git a/jni/SDL2-2.0.1/INSTALL.txt b/jni/SDL2-2.0.3/INSTALL.txt similarity index 100% rename from jni/SDL2-2.0.1/INSTALL.txt rename to jni/SDL2-2.0.3/INSTALL.txt diff --git a/jni/SDL2-2.0.1/Makefile.in b/jni/SDL2-2.0.3/Makefile.in similarity index 100% rename from jni/SDL2-2.0.1/Makefile.in rename to jni/SDL2-2.0.3/Makefile.in diff --git a/jni/SDL2-2.0.1/Makefile.minimal b/jni/SDL2-2.0.3/Makefile.minimal similarity index 100% rename from jni/SDL2-2.0.1/Makefile.minimal rename to jni/SDL2-2.0.3/Makefile.minimal diff --git a/jni/SDL2-2.0.1/Makefile.pandora b/jni/SDL2-2.0.3/Makefile.pandora similarity index 100% rename from jni/SDL2-2.0.1/Makefile.pandora rename to jni/SDL2-2.0.3/Makefile.pandora diff --git a/jni/SDL2-2.0.1/Makefile.psp b/jni/SDL2-2.0.3/Makefile.psp similarity index 100% rename from jni/SDL2-2.0.1/Makefile.psp rename to jni/SDL2-2.0.3/Makefile.psp diff --git a/jni/SDL2-2.0.1/Makefile.wiz b/jni/SDL2-2.0.3/Makefile.wiz similarity index 100% rename from jni/SDL2-2.0.1/Makefile.wiz rename to jni/SDL2-2.0.3/Makefile.wiz diff --git a/jni/SDL2-2.0.1/README-SDL.txt b/jni/SDL2-2.0.3/README-SDL.txt similarity index 100% rename from jni/SDL2-2.0.1/README-SDL.txt rename to jni/SDL2-2.0.3/README-SDL.txt diff --git a/jni/SDL2-2.0.1/README-android.txt b/jni/SDL2-2.0.3/README-android.txt similarity index 100% rename from jni/SDL2-2.0.1/README-android.txt rename to jni/SDL2-2.0.3/README-android.txt diff --git a/jni/SDL2-2.0.1/README-cmake.txt b/jni/SDL2-2.0.3/README-cmake.txt similarity index 100% rename from jni/SDL2-2.0.1/README-cmake.txt rename to jni/SDL2-2.0.3/README-cmake.txt diff --git a/jni/SDL2-2.0.1/README-directfb.txt b/jni/SDL2-2.0.3/README-directfb.txt similarity index 100% rename from jni/SDL2-2.0.1/README-directfb.txt rename to jni/SDL2-2.0.3/README-directfb.txt diff --git a/jni/SDL2-2.0.1/README-dynapi.txt b/jni/SDL2-2.0.3/README-dynapi.txt similarity index 100% rename from jni/SDL2-2.0.1/README-dynapi.txt rename to jni/SDL2-2.0.3/README-dynapi.txt diff --git a/jni/SDL2-2.0.1/README-gesture.txt b/jni/SDL2-2.0.3/README-gesture.txt similarity index 100% rename from jni/SDL2-2.0.1/README-gesture.txt rename to jni/SDL2-2.0.3/README-gesture.txt diff --git a/jni/SDL2-2.0.1/README-hg.txt b/jni/SDL2-2.0.3/README-hg.txt similarity index 100% rename from jni/SDL2-2.0.1/README-hg.txt rename to jni/SDL2-2.0.3/README-hg.txt diff --git a/jni/SDL2-2.0.1/README-ios.txt b/jni/SDL2-2.0.3/README-ios.txt similarity index 100% rename from jni/SDL2-2.0.1/README-ios.txt rename to jni/SDL2-2.0.3/README-ios.txt diff --git a/jni/SDL2-2.0.1/README-linux.txt b/jni/SDL2-2.0.3/README-linux.txt similarity index 100% rename from jni/SDL2-2.0.1/README-linux.txt rename to jni/SDL2-2.0.3/README-linux.txt diff --git a/jni/SDL2-2.0.1/README-macosx.txt b/jni/SDL2-2.0.3/README-macosx.txt similarity index 93% rename from jni/SDL2-2.0.1/README-macosx.txt rename to jni/SDL2-2.0.3/README-macosx.txt index 021b1402..895b9d14 100644 --- a/jni/SDL2-2.0.1/README-macosx.txt +++ b/jni/SDL2-2.0.3/README-macosx.txt @@ -17,15 +17,19 @@ process: sudo make install You can also build SDL as a Universal library (a single binary for both -PowerPC and Intel architectures), on Mac OS X 10.4 and newer, by using +32-bit and 64-bit Intel architectures), on Mac OS X 10.7 and newer, by using the fatbuild.sh script in build-scripts: sh build-scripts/fatbuild.sh sudo build-scripts/fatbuild.sh install -This script builds SDL with 10.2 ABI compatibility on PowerPC and 10.4 -ABI compatibility on Intel architectures. For best compatibility you +This script builds SDL with 10.5 ABI compatibility on i386 and 10.6 +ABI compatibility on x86_64 architectures. For best compatibility you should compile your application the same way. A script which wraps gcc to make this easy is provided in test/gcc-fat.sh +Please note that building SDL requires at least Xcode 4.6 and the 10.7 SDK +(even if you target back to 10.5 systems). PowerPC support for Mac OS X has +been officially dropped as of SDL 2.0.2. + To use the library once it's built, you essential have two possibilities: use the traditional autoconf/automake/make method, or use Xcode. diff --git a/jni/SDL2-2.0.1/README-pandora.txt b/jni/SDL2-2.0.3/README-pandora.txt similarity index 100% rename from jni/SDL2-2.0.1/README-pandora.txt rename to jni/SDL2-2.0.3/README-pandora.txt diff --git a/jni/SDL2-2.0.1/README-platforms.txt b/jni/SDL2-2.0.3/README-platforms.txt similarity index 100% rename from jni/SDL2-2.0.1/README-platforms.txt rename to jni/SDL2-2.0.3/README-platforms.txt diff --git a/jni/SDL2-2.0.1/README-porting.txt b/jni/SDL2-2.0.3/README-porting.txt similarity index 100% rename from jni/SDL2-2.0.1/README-porting.txt rename to jni/SDL2-2.0.3/README-porting.txt diff --git a/jni/SDL2-2.0.1/README-psp.txt b/jni/SDL2-2.0.3/README-psp.txt similarity index 100% rename from jni/SDL2-2.0.1/README-psp.txt rename to jni/SDL2-2.0.3/README-psp.txt diff --git a/jni/SDL2-2.0.1/README-raspberrypi.txt b/jni/SDL2-2.0.3/README-raspberrypi.txt similarity index 96% rename from jni/SDL2-2.0.1/README-raspberrypi.txt rename to jni/SDL2-2.0.3/README-raspberrypi.txt index af1ccea6..22b4bbc9 100644 --- a/jni/SDL2-2.0.1/README-raspberrypi.txt +++ b/jni/SDL2-2.0.3/README-raspberrypi.txt @@ -124,7 +124,7 @@ Reference: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=5062 The Text Input API is supported, with translation of scan codes done via the kernel symbol tables. For this to work, SDL needs access to a valid console. -If you notice there's no SDL_TEXTINPUT message being emmited, double check that +If you notice there's no SDL_TEXTINPUT message being emitted, double check that your app has read access to one of the following: * /proc/self/fd/0 diff --git a/jni/SDL2-2.0.1/README-touch.txt b/jni/SDL2-2.0.3/README-touch.txt similarity index 100% rename from jni/SDL2-2.0.1/README-touch.txt rename to jni/SDL2-2.0.3/README-touch.txt diff --git a/jni/SDL2-2.0.1/README-wince.txt b/jni/SDL2-2.0.3/README-wince.txt similarity index 58% rename from jni/SDL2-2.0.1/README-wince.txt rename to jni/SDL2-2.0.3/README-wince.txt index eaacc498..b7fd3f12 100644 --- a/jni/SDL2-2.0.1/README-wince.txt +++ b/jni/SDL2-2.0.3/README-wince.txt @@ -2,8 +2,7 @@ Windows CE is no longer supported by SDL. We have left the CE support in SDL 1.2 for those that must have it, and we -will accept patches that support more modern Windows Mobile platforms for -SDL 2.0. +have support for Windows Phone 8 and WinRT in SDL2, as of SDL 2.0.3. --ryan. diff --git a/jni/SDL2-2.0.1/README-windows.txt b/jni/SDL2-2.0.3/README-windows.txt similarity index 96% rename from jni/SDL2-2.0.1/README-windows.txt rename to jni/SDL2-2.0.3/README-windows.txt index f59b2661..7f9c4a35 100644 --- a/jni/SDL2-2.0.1/README-windows.txt +++ b/jni/SDL2-2.0.3/README-windows.txt @@ -32,7 +32,7 @@ d3dcompiler_* DLL at all (for details on this, see their documentation). However, by default SDL will try to preload the d3dcompiler_46.dll to comply with ANGLE's requirements. If you wish SDL to preload d3dcompiler_43.dll (to support Windows XP) or to skip this step at all, you can use the -SDL_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more details). +SDL_HINT_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more details). Known Bugs: diff --git a/jni/SDL2-2.0.1/README.txt b/jni/SDL2-2.0.3/README.txt similarity index 100% rename from jni/SDL2-2.0.1/README.txt rename to jni/SDL2-2.0.3/README.txt diff --git a/jni/SDL2-2.0.1/SDL.tag b/jni/SDL2-2.0.3/SDL.tag similarity index 100% rename from jni/SDL2-2.0.1/SDL.tag rename to jni/SDL2-2.0.3/SDL.tag diff --git a/jni/SDL2-2.0.1/SDL2.spec.in b/jni/SDL2-2.0.3/SDL2.spec.in similarity index 100% rename from jni/SDL2-2.0.1/SDL2.spec.in rename to jni/SDL2-2.0.3/SDL2.spec.in diff --git a/jni/SDL2-2.0.1/TODO.txt b/jni/SDL2-2.0.3/TODO.txt similarity index 100% rename from jni/SDL2-2.0.1/TODO.txt rename to jni/SDL2-2.0.3/TODO.txt diff --git a/jni/SDL2-2.0.1/VisualC.html b/jni/SDL2-2.0.3/VisualC.html similarity index 100% rename from jni/SDL2-2.0.1/VisualC.html rename to jni/SDL2-2.0.3/VisualC.html diff --git a/jni/SDL2-2.0.1/WhatsNew.txt b/jni/SDL2-2.0.3/WhatsNew.txt similarity index 59% rename from jni/SDL2-2.0.1/WhatsNew.txt rename to jni/SDL2-2.0.3/WhatsNew.txt index db2ad8fb..bcbdcd10 100644 --- a/jni/SDL2-2.0.1/WhatsNew.txt +++ b/jni/SDL2-2.0.3/WhatsNew.txt @@ -1,29 +1,56 @@ This is a list of major changes in SDL's version history. +--------------------------------------------------------------------------- +2.0.3: +--------------------------------------------------------------------------- + +Mac OS X: +* Fixed creating an OpenGL context by default on Mac OS X 10.6 + + --------------------------------------------------------------------------- 2.0.2: --------------------------------------------------------------------------- General: -* Added an API to load a database of Game Controller mappings from a file: - SDL_GameControllerAddMappingsFromFile +* Added SDL_GL_ResetAttributes() to reset OpenGL attributes to default values +* Added an API to load a database of game controller mappings from a file: + SDL_GameControllerAddMappingsFromFile(), SDL_GameControllerAddMappingsFromRW() +* Added game controller mappings for the PS4 and OUYA controllers +* Added SDL_GetDefaultAssertionHandler() and SDL_GetAssertionHandler() +* Added SDL_DetachThread() +* Added SDL_HasAVX() to determine if the CPU has AVX features +* Added SDL_vsscanf(), SDL_acos(), and SDL_asin() to the stdlib routines * EGL can now create/manage OpenGL and OpenGL ES 1.x/2.x contexts, and share them using SDL_GL_SHARE_WITH_CURRENT_CONTEXT -* Added testgles2. testgl2 does not need to link with libGL anymore. - +* Added a field "clicks" to the mouse button event which records whether the event is a single click, double click, etc. +* The screensaver is now disabled by default, and there is a hint SDL_HINT_VIDEO_ALLOW_SCREENSAVER that can change that behavior. +* Added a hint SDL_HINT_MOUSE_RELATIVE_MODE_WARP to specify whether mouse relative mode should be emulated using mouse warping. +* testgl2 does not need to link with libGL anymore +* Added testgles2 test program to demonstrate working with OpenGL ES 2.0 +* Added controllermap test program to visually map a game controller + Windows: * Support for OpenGL ES 2.x contexts using either WGL or EGL (natively via the driver or emulated through ANGLE) +* Added a hint SDL_HINT_VIDEO_WIN_D3DCOMPILER to specify which D3D shader compiler to use for OpenGL ES 2 support through ANGLE +* Added a hint SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT that is useful when creating multiple windows that should share the same OpenGL context. +* Added an event SDL_RENDER_TARGETS_RESET that is sent when D3D9 render targets are reset after the device has been restored. + +Mac OS X: +* Added a hint SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK to control whether Ctrl+click should be treated as a right click on Mac OS X. This is off by default. + +Linux: +* Fixed fullscreen and focused behavior when receiving NotifyGrab events +* Added experimental Wayland and Mir support, disabled by default Android: * Joystick support (minimum SDK version required to build SDL is now 12, the required runtime version remains at 10, but on such devices joystick support won't be available). * Hotplugging support for joysticks +* Added a hint SDL_HINT_ACCELEROMETER_AS_JOYSTICK to control whether the accelerometer should be listed as a 3 axis joystick, which it will by default. -Linux: -* Fixed fullscreen and focused behavior when receiving NotifyGrab events -* Wayland support --------------------------------------------------------------------------- 2.0.1: diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/Default.png b/jni/SDL2-2.0.3/Xcode-iOS/Demos/Default.png similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/Default.png rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/Default.png diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/Demos.xcodeproj/project.pbxproj b/jni/SDL2-2.0.3/Xcode-iOS/Demos/Demos.xcodeproj/project.pbxproj similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/Demos.xcodeproj/project.pbxproj rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/Demos.xcodeproj/project.pbxproj diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/Icon.png b/jni/SDL2-2.0.3/Xcode-iOS/Demos/Icon.png similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/Icon.png rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/Icon.png diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/Info.plist b/jni/SDL2-2.0.3/Xcode-iOS/Demos/Info.plist similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/Info.plist rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/Info.plist diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/README b/jni/SDL2-2.0.3/Xcode-iOS/Demos/README similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/README rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/README diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/data/bitmapfont/kromasky_16x16.bmp b/jni/SDL2-2.0.3/Xcode-iOS/Demos/data/bitmapfont/kromasky_16x16.bmp similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/data/bitmapfont/kromasky_16x16.bmp rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/data/bitmapfont/kromasky_16x16.bmp diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/data/bitmapfont/license.txt b/jni/SDL2-2.0.3/Xcode-iOS/Demos/data/bitmapfont/license.txt similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/data/bitmapfont/license.txt rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/data/bitmapfont/license.txt diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/data/drums/ds_brush_snare.wav b/jni/SDL2-2.0.3/Xcode-iOS/Demos/data/drums/ds_brush_snare.wav similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/data/drums/ds_brush_snare.wav rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/data/drums/ds_brush_snare.wav diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/data/drums/ds_china.wav b/jni/SDL2-2.0.3/Xcode-iOS/Demos/data/drums/ds_china.wav similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/data/drums/ds_china.wav rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/data/drums/ds_china.wav diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/data/drums/ds_kick_big_amb.wav b/jni/SDL2-2.0.3/Xcode-iOS/Demos/data/drums/ds_kick_big_amb.wav similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/data/drums/ds_kick_big_amb.wav rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/data/drums/ds_kick_big_amb.wav diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/data/drums/ds_loose_skin_mute.wav b/jni/SDL2-2.0.3/Xcode-iOS/Demos/data/drums/ds_loose_skin_mute.wav similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/data/drums/ds_loose_skin_mute.wav rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/data/drums/ds_loose_skin_mute.wav diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/data/icon.bmp b/jni/SDL2-2.0.3/Xcode-iOS/Demos/data/icon.bmp similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/data/icon.bmp rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/data/icon.bmp diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/data/ship.bmp b/jni/SDL2-2.0.3/Xcode-iOS/Demos/data/ship.bmp similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/data/ship.bmp rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/data/ship.bmp diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/data/space.bmp b/jni/SDL2-2.0.3/Xcode-iOS/Demos/data/space.bmp similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/data/space.bmp rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/data/space.bmp diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/data/stroke.bmp b/jni/SDL2-2.0.3/Xcode-iOS/Demos/data/stroke.bmp similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/data/stroke.bmp rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/data/stroke.bmp diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/src/accelerometer.c b/jni/SDL2-2.0.3/Xcode-iOS/Demos/src/accelerometer.c similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/src/accelerometer.c rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/src/accelerometer.c diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/src/common.c b/jni/SDL2-2.0.3/Xcode-iOS/Demos/src/common.c similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/src/common.c rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/src/common.c diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/src/common.h b/jni/SDL2-2.0.3/Xcode-iOS/Demos/src/common.h similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/src/common.h rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/src/common.h diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/src/fireworks.c b/jni/SDL2-2.0.3/Xcode-iOS/Demos/src/fireworks.c similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/src/fireworks.c rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/src/fireworks.c diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/src/happy.c b/jni/SDL2-2.0.3/Xcode-iOS/Demos/src/happy.c similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/src/happy.c rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/src/happy.c diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/src/keyboard.c b/jni/SDL2-2.0.3/Xcode-iOS/Demos/src/keyboard.c similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/src/keyboard.c rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/src/keyboard.c diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/src/mixer.c b/jni/SDL2-2.0.3/Xcode-iOS/Demos/src/mixer.c similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/src/mixer.c rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/src/mixer.c diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/src/rectangles.c b/jni/SDL2-2.0.3/Xcode-iOS/Demos/src/rectangles.c similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/src/rectangles.c rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/src/rectangles.c diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Demos/src/touch.c b/jni/SDL2-2.0.3/Xcode-iOS/Demos/src/touch.c similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Demos/src/touch.c rename to jni/SDL2-2.0.3/Xcode-iOS/Demos/src/touch.c diff --git a/jni/SDL2-2.0.1/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj b/jni/SDL2-2.0.3/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj similarity index 99% rename from jni/SDL2-2.0.1/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj rename to jni/SDL2-2.0.3/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj index 8541fa34..c4b95a36 100755 --- a/jni/SDL2-2.0.1/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj +++ b/jni/SDL2-2.0.3/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj @@ -561,6 +561,7 @@ ); name = CustomTemplate; sourceTree = ""; + usesTabs = 0; }; 56A6702F18565E4F0007D20F /* dynapi */ = { isa = PBXGroup; diff --git a/jni/SDL2-2.0.1/Xcode-iOS/SDLtest/SDL2test.xcodeproj/project.pbxproj b/jni/SDL2-2.0.3/Xcode-iOS/SDLtest/SDL2test.xcodeproj/project.pbxproj similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/SDLtest/SDL2test.xcodeproj/project.pbxproj rename to jni/SDL2-2.0.3/Xcode-iOS/SDLtest/SDL2test.xcodeproj/project.pbxproj diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Template/SDL iOS Application/Default.png b/jni/SDL2-2.0.3/Xcode-iOS/Template/SDL iOS Application/Default.png similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Template/SDL iOS Application/Default.png rename to jni/SDL2-2.0.3/Xcode-iOS/Template/SDL iOS Application/Default.png diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Template/SDL iOS Application/Icon.png b/jni/SDL2-2.0.3/Xcode-iOS/Template/SDL iOS Application/Icon.png similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Template/SDL iOS Application/Icon.png rename to jni/SDL2-2.0.3/Xcode-iOS/Template/SDL iOS Application/Icon.png diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Template/SDL iOS Application/Info.plist b/jni/SDL2-2.0.3/Xcode-iOS/Template/SDL iOS Application/Info.plist similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Template/SDL iOS Application/Info.plist rename to jni/SDL2-2.0.3/Xcode-iOS/Template/SDL iOS Application/Info.plist diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/TemplateIcon.icns b/jni/SDL2-2.0.3/Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/TemplateIcon.icns similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/TemplateIcon.icns rename to jni/SDL2-2.0.3/Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/TemplateIcon.icns diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/TemplateInfo.plist b/jni/SDL2-2.0.3/Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/TemplateInfo.plist similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/TemplateInfo.plist rename to jni/SDL2-2.0.3/Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/TemplateInfo.plist diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/project.pbxproj b/jni/SDL2-2.0.3/Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/project.pbxproj similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/project.pbxproj rename to jni/SDL2-2.0.3/Xcode-iOS/Template/SDL iOS Application/___PROJECTNAME___.xcodeproj/project.pbxproj diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Template/SDL iOS Application/main.c b/jni/SDL2-2.0.3/Xcode-iOS/Template/SDL iOS Application/main.c similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Template/SDL iOS Application/main.c rename to jni/SDL2-2.0.3/Xcode-iOS/Template/SDL iOS Application/main.c diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Test/Info.plist b/jni/SDL2-2.0.3/Xcode-iOS/Test/Info.plist similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Test/Info.plist rename to jni/SDL2-2.0.3/Xcode-iOS/Test/Info.plist diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Test/README b/jni/SDL2-2.0.3/Xcode-iOS/Test/README similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Test/README rename to jni/SDL2-2.0.3/Xcode-iOS/Test/README diff --git a/jni/SDL2-2.0.1/Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj b/jni/SDL2-2.0.3/Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj similarity index 100% rename from jni/SDL2-2.0.1/Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj rename to jni/SDL2-2.0.3/Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj diff --git a/jni/SDL2-2.0.1/Xcode/SDL/Info-Framework.plist b/jni/SDL2-2.0.3/Xcode/SDL/Info-Framework.plist similarity index 94% rename from jni/SDL2-2.0.1/Xcode/SDL/Info-Framework.plist rename to jni/SDL2-2.0.3/Xcode/SDL/Info-Framework.plist index 696ef99d..fa55492b 100644 --- a/jni/SDL2-2.0.1/Xcode/SDL/Info-Framework.plist +++ b/jni/SDL2-2.0.3/Xcode/SDL/Info-Framework.plist @@ -19,10 +19,10 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.0.1 + 2.0.3 CFBundleSignature SDLX CFBundleVersion - 2.0.1 + 2.0.3 diff --git a/jni/SDL2-2.0.1/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/jni/SDL2-2.0.3/Xcode/SDL/SDL.xcodeproj/project.pbxproj similarity index 99% rename from jni/SDL2-2.0.1/Xcode/SDL/SDL.xcodeproj/project.pbxproj rename to jni/SDL2-2.0.3/Xcode/SDL/SDL.xcodeproj/project.pbxproj index fa8e4934..61797524 100755 --- a/jni/SDL2-2.0.1/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/jni/SDL2-2.0.3/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -1083,6 +1083,7 @@ D55A1B7F179F262300625D7C /* SDL_cocoamousetap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoamousetap.h; sourceTree = ""; }; D55A1B80179F262300625D7C /* SDL_cocoamousetap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoamousetap.m; sourceTree = ""; }; DB31407717554B71006C0E22 /* libSDL2.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libSDL2.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; + DB89958518A1A5C50092407C /* SDL_syshaptic_c.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SDL_syshaptic_c.h; sourceTree = ""; }; F59C70FF00D5CB5801000001 /* ReadMe.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = ReadMe.txt; sourceTree = ""; }; F59C710000D5CB5801000001 /* Welcome.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = Welcome.txt; sourceTree = ""; }; F59C710300D5CB5801000001 /* ReadMe.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = ReadMe.txt; sourceTree = ""; }; @@ -1401,6 +1402,7 @@ isa = PBXGroup; children = ( 04BDFDF312E6671700899322 /* SDL_syshaptic.c */, + DB89958518A1A5C50092407C /* SDL_syshaptic_c.h */, ); path = darwin; sourceTree = ""; @@ -2771,8 +2773,8 @@ 00CFA622106A567900758660 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; + DYLIB_COMPATIBILITY_VERSION = 1.0.0; + DYLIB_CURRENT_VERSION = 3.1.0; FRAMEWORK_VERSION = A; HEADER_SEARCH_PATHS = /usr/X11R6/include; INFOPLIST_FILE = "Info-Framework.plist"; @@ -2825,8 +2827,8 @@ 00CFA628106A568900758660 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; + DYLIB_COMPATIBILITY_VERSION = 1.0.0; + DYLIB_CURRENT_VERSION = 3.1.0; FRAMEWORK_VERSION = A; HEADER_SEARCH_PATHS = /usr/X11R6/include; INFOPLIST_FILE = "Info-Framework.plist"; diff --git a/jni/SDL2-2.0.1/Xcode/SDL/pkg-support/SDL.info b/jni/SDL2-2.0.3/Xcode/SDL/pkg-support/SDL.info similarity index 100% rename from jni/SDL2-2.0.1/Xcode/SDL/pkg-support/SDL.info rename to jni/SDL2-2.0.3/Xcode/SDL/pkg-support/SDL.info diff --git a/jni/SDL2-2.0.1/Xcode/SDL/pkg-support/codesign-frameworks.sh b/jni/SDL2-2.0.3/Xcode/SDL/pkg-support/codesign-frameworks.sh similarity index 100% rename from jni/SDL2-2.0.1/Xcode/SDL/pkg-support/codesign-frameworks.sh rename to jni/SDL2-2.0.3/Xcode/SDL/pkg-support/codesign-frameworks.sh diff --git a/jni/SDL2-2.0.1/Xcode/SDL/pkg-support/resources/License.txt b/jni/SDL2-2.0.3/Xcode/SDL/pkg-support/resources/License.txt similarity index 93% rename from jni/SDL2-2.0.1/Xcode/SDL/pkg-support/resources/License.txt rename to jni/SDL2-2.0.3/Xcode/SDL/pkg-support/resources/License.txt index 18f109c3..4b6f777e 100644 --- a/jni/SDL2-2.0.1/Xcode/SDL/pkg-support/resources/License.txt +++ b/jni/SDL2-2.0.3/Xcode/SDL/pkg-support/resources/License.txt @@ -1,6 +1,6 @@ Simple DirectMedia Layer -Copyright (C) 1997-2013 Sam Lantinga +Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/Xcode/SDL/pkg-support/resources/ReadMe.txt b/jni/SDL2-2.0.3/Xcode/SDL/pkg-support/resources/ReadMe.txt similarity index 100% rename from jni/SDL2-2.0.1/Xcode/SDL/pkg-support/resources/ReadMe.txt rename to jni/SDL2-2.0.3/Xcode/SDL/pkg-support/resources/ReadMe.txt diff --git a/jni/SDL2-2.0.1/Xcode/SDL/pkg-support/resources/SDL_DS_Store b/jni/SDL2-2.0.3/Xcode/SDL/pkg-support/resources/SDL_DS_Store similarity index 100% rename from jni/SDL2-2.0.1/Xcode/SDL/pkg-support/resources/SDL_DS_Store rename to jni/SDL2-2.0.3/Xcode/SDL/pkg-support/resources/SDL_DS_Store diff --git a/jni/SDL2-2.0.1/Xcode/SDL/pkg-support/sdl_logo.pdf b/jni/SDL2-2.0.3/Xcode/SDL/pkg-support/sdl_logo.pdf similarity index 100% rename from jni/SDL2-2.0.1/Xcode/SDL/pkg-support/sdl_logo.pdf rename to jni/SDL2-2.0.3/Xcode/SDL/pkg-support/sdl_logo.pdf diff --git a/jni/SDL2-2.0.1/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj b/jni/SDL2-2.0.3/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj similarity index 94% rename from jni/SDL2-2.0.1/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj rename to jni/SDL2-2.0.3/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj index 152c3d23..a9d0a47a 100755 --- a/jni/SDL2-2.0.1/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj +++ b/jni/SDL2-2.0.3/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj @@ -577,6 +577,29 @@ DB166E9A16A1D7F700A1396C /* moose.dat in CopyFiles */ = {isa = PBXBuildFile; fileRef = 00794E5E09D20839003FC8A1 /* moose.dat */; }; DB166E9C16A1D80900A1396C /* icon.bmp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 00794E5D09D20839003FC8A1 /* icon.bmp */; }; DB166ED016A1D88100A1396C /* shapes in CopyFiles */ = {isa = PBXBuildFile; fileRef = DB166ECF16A1D87000A1396C /* shapes */; }; + DB89957118A19ABA0092407C /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002F33A709CA188600EBEB88 /* Cocoa.framework */; }; + DB89957218A19ABA0092407C /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863B10730545007319AE /* CoreAudio.framework */; }; + DB89957318A19ABA0092407C /* ForceFeedback.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863C10730545007319AE /* ForceFeedback.framework */; }; + DB89957418A19ABA0092407C /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863D10730545007319AE /* IOKit.framework */; }; + DB89957518A19ABA0092407C /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A869F10730593007319AE /* AudioToolbox.framework */; }; + DB89957618A19ABA0092407C /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A86A010730593007319AE /* CoreFoundation.framework */; }; + DB89957718A19ABA0092407C /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A86F2107305CE007319AE /* OpenGL.framework */; }; + DB89957818A19ABA0092407C /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A871410730623007319AE /* AudioUnit.framework */; }; + DB89957918A19ABA0092407C /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A873910730675007319AE /* Carbon.framework */; }; + DB89957A18A19ABA0092407C /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA645093FFD41000C53B3 /* libSDL2.a */; }; + DB89958418A19B130092407C /* testhotplug.c in Sources */ = {isa = PBXBuildFile; fileRef = DB89958318A19B130092407C /* testhotplug.c */; }; + DB445EEA18184B7000B306B0 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002F33A709CA188600EBEB88 /* Cocoa.framework */; }; + DB445EEB18184B7000B306B0 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863B10730545007319AE /* CoreAudio.framework */; }; + DB445EEC18184B7000B306B0 /* ForceFeedback.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863C10730545007319AE /* ForceFeedback.framework */; }; + DB445EED18184B7000B306B0 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A863D10730545007319AE /* IOKit.framework */; }; + DB445EEE18184B7000B306B0 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A869F10730593007319AE /* AudioToolbox.framework */; }; + DB445EEF18184B7000B306B0 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A86A010730593007319AE /* CoreFoundation.framework */; }; + DB445EF018184B7000B306B0 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A86F2107305CE007319AE /* OpenGL.framework */; }; + DB445EF118184B7000B306B0 /* AudioUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A871410730623007319AE /* AudioUnit.framework */; }; + DB445EF218184B7000B306B0 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A873910730675007319AE /* Carbon.framework */; }; + DB445EF318184B7000B306B0 /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA645093FFD41000C53B3 /* libSDL2.a */; }; + DB445EF418184B7000B306B0 /* libSDL_test.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DB166D7F16A1D12400A1396C /* libSDL_test.a */; }; + DB445EFB18184BB600B306B0 /* testdropfile.c in Sources */ = {isa = PBXBuildFile; fileRef = DB445EFA18184BB600B306B0 /* testdropfile.c */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -1036,36 +1059,36 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 0017958C10741F7900F5D044 /* testatomic */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testatomic; sourceTree = BUILT_PRODUCTS_DIR; }; + 0017958C10741F7900F5D044 /* testatomic */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testatomic; sourceTree = BUILT_PRODUCTS_DIR; }; 0017958F1074216E00F5D044 /* testatomic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testatomic.c; path = ../../test/testatomic.c; sourceTree = SOURCE_ROOT; }; - 001795AD107421BF00F5D044 /* testaudioinfo */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testaudioinfo; sourceTree = BUILT_PRODUCTS_DIR; }; + 001795AD107421BF00F5D044 /* testaudioinfo */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testaudioinfo; sourceTree = BUILT_PRODUCTS_DIR; }; 001795B01074222D00F5D044 /* testaudioinfo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testaudioinfo.c; path = ../../test/testaudioinfo.c; sourceTree = SOURCE_ROOT; }; - 0017972110742F3200F5D044 /* testgl2 */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = testgl2; sourceTree = BUILT_PRODUCTS_DIR; }; + 0017972110742F3200F5D044 /* testgl2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testgl2; sourceTree = BUILT_PRODUCTS_DIR; }; 0017972710742FB900F5D044 /* testgl2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testgl2.c; path = ../../test/testgl2.c; sourceTree = SOURCE_ROOT; }; - 00179748107430D600F5D044 /* testhaptic */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = testhaptic; sourceTree = BUILT_PRODUCTS_DIR; }; + 00179748107430D600F5D044 /* testhaptic */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testhaptic; sourceTree = BUILT_PRODUCTS_DIR; }; 0017974E1074315700F5D044 /* testhaptic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testhaptic.c; path = ../../test/testhaptic.c; sourceTree = SOURCE_ROOT; }; - 0017976E107431B300F5D044 /* testdraw2 */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testdraw2; sourceTree = BUILT_PRODUCTS_DIR; }; + 0017976E107431B300F5D044 /* testdraw2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testdraw2; sourceTree = BUILT_PRODUCTS_DIR; }; 001797711074320D00F5D044 /* testdraw2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testdraw2.c; path = ../../test/testdraw2.c; sourceTree = SOURCE_ROOT; }; - 0017978E107432AE00F5D044 /* testime */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = testime; sourceTree = BUILT_PRODUCTS_DIR; }; + 0017978E107432AE00F5D044 /* testime */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testime; sourceTree = BUILT_PRODUCTS_DIR; }; 00179791107432FA00F5D044 /* testime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testime.c; path = ../../test/testime.c; sourceTree = SOURCE_ROOT; }; - 001797AE1074334C00F5D044 /* testintersections */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testintersections; sourceTree = BUILT_PRODUCTS_DIR; }; + 001797AE1074334C00F5D044 /* testintersections */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testintersections; sourceTree = BUILT_PRODUCTS_DIR; }; 001797B31074339C00F5D044 /* testintersections.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testintersections.c; path = ../../test/testintersections.c; sourceTree = SOURCE_ROOT; }; - 001797D0107433C600F5D044 /* testloadso */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testloadso; sourceTree = BUILT_PRODUCTS_DIR; }; + 001797D0107433C600F5D044 /* testloadso */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testloadso; sourceTree = BUILT_PRODUCTS_DIR; }; 001797D31074343E00F5D044 /* testloadso.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testloadso.c; path = ../../test/testloadso.c; sourceTree = SOURCE_ROOT; }; - 001798121074355200F5D044 /* testmultiaudio */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testmultiaudio; sourceTree = BUILT_PRODUCTS_DIR; }; + 001798121074355200F5D044 /* testmultiaudio */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testmultiaudio; sourceTree = BUILT_PRODUCTS_DIR; }; 001798151074359B00F5D044 /* testmultiaudio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testmultiaudio.c; path = ../../test/testmultiaudio.c; sourceTree = SOURCE_ROOT; }; 0017985A107436ED00F5D044 /* testnative.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testnative.c; path = ../../test/testnative.c; sourceTree = SOURCE_ROOT; }; 0017985B107436ED00F5D044 /* testnative.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = testnative.h; path = ../../test/testnative.h; sourceTree = SOURCE_ROOT; }; 0017985C107436ED00F5D044 /* testnativecocoa.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = testnativecocoa.m; path = ../../test/testnativecocoa.m; sourceTree = SOURCE_ROOT; }; 00179872107438D000F5D044 /* testnativex11.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testnativex11.c; path = ../../test/testnativex11.c; sourceTree = SOURCE_ROOT; }; - 001798941074392D00F5D044 /* testnative */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testnative; sourceTree = BUILT_PRODUCTS_DIR; }; - 001798B5107439DF00F5D044 /* testpower */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testpower; sourceTree = BUILT_PRODUCTS_DIR; }; + 001798941074392D00F5D044 /* testnative */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testnative; sourceTree = BUILT_PRODUCTS_DIR; }; + 001798B5107439DF00F5D044 /* testpower */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testpower; sourceTree = BUILT_PRODUCTS_DIR; }; 001798B910743A4900F5D044 /* testpower.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testpower.c; path = ../../test/testpower.c; sourceTree = SOURCE_ROOT; }; - 001798F210743BEC00F5D044 /* testresample */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testresample; sourceTree = BUILT_PRODUCTS_DIR; }; + 001798F210743BEC00F5D044 /* testresample */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testresample; sourceTree = BUILT_PRODUCTS_DIR; }; 001798F910743E9200F5D044 /* testresample.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testresample.c; path = ../../test/testresample.c; sourceTree = SOURCE_ROOT; }; - 0017991610743F1000F5D044 /* testsprite2 */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testsprite2; sourceTree = BUILT_PRODUCTS_DIR; }; + 0017991610743F1000F5D044 /* testsprite2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testsprite2; sourceTree = BUILT_PRODUCTS_DIR; }; 0017991910743F5300F5D044 /* testsprite2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testsprite2.c; path = ../../test/testsprite2.c; sourceTree = SOURCE_ROOT; }; - 0017993810743FB700F5D044 /* testwm2 */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testwm2; sourceTree = BUILT_PRODUCTS_DIR; }; + 0017993810743FB700F5D044 /* testwm2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testwm2; sourceTree = BUILT_PRODUCTS_DIR; }; 0017993B10743FEF00F5D044 /* testwm2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testwm2.c; path = ../../test/testwm2.c; sourceTree = SOURCE_ROOT; }; 002A863B10730545007319AE /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = /System/Library/Frameworks/CoreAudio.framework; sourceTree = ""; }; 002A863C10730545007319AE /* ForceFeedback.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ForceFeedback.framework; path = /System/Library/Frameworks/ForceFeedback.framework; sourceTree = ""; }; @@ -1076,13 +1099,13 @@ 002A871410730623007319AE /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = /System/Library/Frameworks/AudioUnit.framework; sourceTree = ""; }; 002A873910730675007319AE /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = ""; }; 002F33A709CA188600EBEB88 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; - 002F341209CA1BFF00EBEB88 /* testfile */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testfile; sourceTree = BUILT_PRODUCTS_DIR; }; + 002F341209CA1BFF00EBEB88 /* testfile */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testfile; sourceTree = BUILT_PRODUCTS_DIR; }; 002F341709CA1C5B00EBEB88 /* testfile.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = testfile.c; path = ../../test/testfile.c; sourceTree = SOURCE_ROOT; }; - 002F343109CA1F0300EBEB88 /* testiconv */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testiconv; sourceTree = BUILT_PRODUCTS_DIR; }; + 002F343109CA1F0300EBEB88 /* testiconv */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testiconv; sourceTree = BUILT_PRODUCTS_DIR; }; 002F343609CA1F6F00EBEB88 /* testiconv.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = testiconv.c; path = ../../test/testiconv.c; sourceTree = SOURCE_ROOT; }; - 002F344D09CA1FB300EBEB88 /* testoverlay2 */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testoverlay2; sourceTree = BUILT_PRODUCTS_DIR; }; + 002F344D09CA1FB300EBEB88 /* testoverlay2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testoverlay2; sourceTree = BUILT_PRODUCTS_DIR; }; 002F345209CA201C00EBEB88 /* testoverlay2.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = testoverlay2.c; path = ../../test/testoverlay2.c; sourceTree = SOURCE_ROOT; }; - 002F346A09CA204F00EBEB88 /* testplatform */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testplatform; sourceTree = BUILT_PRODUCTS_DIR; }; + 002F346A09CA204F00EBEB88 /* testplatform */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testplatform; sourceTree = BUILT_PRODUCTS_DIR; }; 002F346F09CA20A600EBEB88 /* testplatform.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = testplatform.c; path = ../../test/testplatform.c; sourceTree = SOURCE_ROOT; }; 003FA63A093FFD41000C53B3 /* SDL.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDL.xcodeproj; path = ../SDL/SDL.xcodeproj; sourceTree = SOURCE_ROOT; }; 00794E5D09D20839003FC8A1 /* icon.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; name = icon.bmp; path = ../../test/icon.bmp; sourceTree = SOURCE_ROOT; }; @@ -1105,18 +1128,18 @@ 4537749212091504002F0F45 /* testshape */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testshape; sourceTree = BUILT_PRODUCTS_DIR; }; 453774A4120915E3002F0F45 /* testshape.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testshape.c; path = ../../test/testshape.c; sourceTree = SOURCE_ROOT; }; BBFC088E164C6820003E6A99 /* testgamecontroller.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testgamecontroller.c; path = ../../test/testgamecontroller.c; sourceTree = ""; }; - BBFC08CD164C6862003E6A99 /* testgamecontroller */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = testgamecontroller; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC566B60761D90300A33029 /* checkkeys */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = checkkeys; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC566D10761D90300A33029 /* loopwave */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = loopwave; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC567060761D90400A33029 /* testerror */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testerror; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC5672E0761D90400A33029 /* testthread */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testthread; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC5673B0761D90400A33029 /* testjoystick */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = testjoystick; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC567480761D90400A33029 /* testkeys */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = testkeys; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC567550761D90400A33029 /* testlock */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testlock; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC5677D0761D90500A33029 /* testsem */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testsem; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC567980761D90500A33029 /* testtimer */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testtimer; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC567B20761D90500A33029 /* testversion */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = testversion; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC567F50761D90600A33029 /* torturethread */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = text; path = torturethread; sourceTree = BUILT_PRODUCTS_DIR; }; + BBFC08CD164C6862003E6A99 /* testgamecontroller */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testgamecontroller; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC566B60761D90300A33029 /* checkkeys */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = checkkeys; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC566D10761D90300A33029 /* loopwave */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = loopwave; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC567060761D90400A33029 /* testerror */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testerror; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC5672E0761D90400A33029 /* testthread */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testthread; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC5673B0761D90400A33029 /* testjoystick */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testjoystick; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC567480761D90400A33029 /* testkeys */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testkeys; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC567550761D90400A33029 /* testlock */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testlock; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC5677D0761D90500A33029 /* testsem */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testsem; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC567980761D90500A33029 /* testtimer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testtimer; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC567B20761D90500A33029 /* testversion */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testversion; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC567F50761D90600A33029 /* torturethread */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = torturethread; sourceTree = BUILT_PRODUCTS_DIR; }; DB0F48D717CA51D2008798C5 /* testdrawchessboard.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testdrawchessboard.c; path = ../../test/testdrawchessboard.c; sourceTree = ""; }; DB0F48D817CA51D2008798C5 /* testfilesystem.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = testfilesystem.c; path = ../../test/testfilesystem.c; sourceTree = ""; }; DB0F48EC17CA51E5008798C5 /* testdrawchessboard */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testdrawchessboard; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -1159,6 +1182,11 @@ DB166E7E16A1D78400A1396C /* testspriteminimal */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testspriteminimal; sourceTree = BUILT_PRODUCTS_DIR; }; DB166E9116A1D78C00A1396C /* teststreaming */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = teststreaming; sourceTree = BUILT_PRODUCTS_DIR; }; DB166ECF16A1D87000A1396C /* shapes */ = {isa = PBXFileReference; lastKnownFileType = folder; name = shapes; path = ../../test/shapes; sourceTree = ""; }; + DB89957E18A19ABA0092407C /* testhotplug */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testhotplug; sourceTree = BUILT_PRODUCTS_DIR; }; + DB89958318A19B130092407C /* testhotplug.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testhotplug.c; path = ../../test/testhotplug.c; sourceTree = ""; }; + DB445EF818184B7000B306B0 /* testdropfile.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testdropfile.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DB445EFA18184BB600B306B0 /* testdropfile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testdropfile.c; path = ../../test/testdropfile.c; sourceTree = ""; }; + DBBC552C182831D700F3CA8D /* TestDropFile-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "TestDropFile-Info.plist"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -1911,6 +1939,41 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + DB89957018A19ABA0092407C /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + DB89957118A19ABA0092407C /* Cocoa.framework in Frameworks */, + DB89957218A19ABA0092407C /* CoreAudio.framework in Frameworks */, + DB89957318A19ABA0092407C /* ForceFeedback.framework in Frameworks */, + DB89957418A19ABA0092407C /* IOKit.framework in Frameworks */, + DB89957518A19ABA0092407C /* AudioToolbox.framework in Frameworks */, + DB89957618A19ABA0092407C /* CoreFoundation.framework in Frameworks */, + DB89957718A19ABA0092407C /* OpenGL.framework in Frameworks */, + DB89957818A19ABA0092407C /* AudioUnit.framework in Frameworks */, + DB89957918A19ABA0092407C /* Carbon.framework in Frameworks */, + DB89957A18A19ABA0092407C /* libSDL2.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + DB445EE918184B7000B306B0 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + DB445EEA18184B7000B306B0 /* Cocoa.framework in Frameworks */, + DB445EEB18184B7000B306B0 /* CoreAudio.framework in Frameworks */, + DB445EEC18184B7000B306B0 /* ForceFeedback.framework in Frameworks */, + DB445EED18184B7000B306B0 /* IOKit.framework in Frameworks */, + DB445EEE18184B7000B306B0 /* AudioToolbox.framework in Frameworks */, + DB445EEF18184B7000B306B0 /* CoreFoundation.framework in Frameworks */, + DB445EF018184B7000B306B0 /* OpenGL.framework in Frameworks */, + DB445EF118184B7000B306B0 /* AudioUnit.framework in Frameworks */, + DB445EF218184B7000B306B0 /* Carbon.framework in Frameworks */, + DB445EF318184B7000B306B0 /* libSDL2.a in Frameworks */, + DB445EF418184B7000B306B0 /* libSDL_test.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -1944,6 +2007,7 @@ 00794E4609D207B4003FC8A1 /* Resources */ = { isa = PBXGroup; children = ( + DBBC552C182831D700F3CA8D /* TestDropFile-Info.plist */, DB166ECF16A1D87000A1396C /* shapes */, 00794E5D09D20839003FC8A1 /* icon.bmp */, 00794E5E09D20839003FC8A1 /* moose.dat */, @@ -1978,6 +2042,7 @@ 001795B01074222D00F5D044 /* testaudioinfo.c */, 001797711074320D00F5D044 /* testdraw2.c */, DB0F48D717CA51D2008798C5 /* testdrawchessboard.c */, + DB445EFA18184BB600B306B0 /* testdropfile.c */, 083E4878006D85357F000001 /* testerror.c */, 002F341709CA1C5B00EBEB88 /* testfile.c */, DB0F48D817CA51D2008798C5 /* testfilesystem.c */, @@ -1986,6 +2051,7 @@ 0017972710742FB900F5D044 /* testgl2.c */, DB166CBC16A1C74100A1396C /* testgles.c */, 0017974E1074315700F5D044 /* testhaptic.c */, + DB89958318A19B130092407C /* testhotplug.c */, 002F343609CA1F6F00EBEB88 /* testiconv.c */, 00179791107432FA00F5D044 /* testime.c */, 001797B31074339C00F5D044 /* testintersections.c */, @@ -2070,6 +2136,8 @@ DB166E9116A1D78C00A1396C /* teststreaming */, DB0F48EC17CA51E5008798C5 /* testdrawchessboard */, DB0F490117CA5212008798C5 /* testfilesystem */, + DB89957E18A19ABA0092407C /* testhotplug */, + DB445EF818184B7000B306B0 /* testdropfile.app */, ); name = Products; sourceTree = ""; @@ -2805,7 +2873,7 @@ dependencies = ( ); name = testspriteminimal; - productName = testsem; + productName = testspriteminimal; productReference = DB166E7E16A1D78400A1396C /* testspriteminimal */; productType = "com.apple.product-type.tool"; }; @@ -2822,10 +2890,42 @@ dependencies = ( ); name = teststreaming; - productName = testsem; + productName = teststreaming; productReference = DB166E9116A1D78C00A1396C /* teststreaming */; productType = "com.apple.product-type.tool"; }; + DB89956D18A19ABA0092407C /* testhotplug */ = { + isa = PBXNativeTarget; + buildConfigurationList = DB89957B18A19ABA0092407C /* Build configuration list for PBXNativeTarget "testhotplug" */; + buildPhases = ( + DB89956E18A19ABA0092407C /* Sources */, + DB89957018A19ABA0092407C /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = testhotplug; + productName = testalpha; + productReference = DB89957E18A19ABA0092407C /* testhotplug */; + productType = "com.apple.product-type.tool"; + }; + DB445EE618184B7000B306B0 /* testdropfile */ = { + isa = PBXNativeTarget; + buildConfigurationList = DB445EF518184B7000B306B0 /* Build configuration list for PBXNativeTarget "testdropfile" */; + buildPhases = ( + DB445EE718184B7000B306B0 /* Sources */, + DB445EE918184B7000B306B0 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = testdropfile; + productName = testdropfile; + productReference = DB445EF818184B7000B306B0 /* testdropfile.app */; + productType = "com.apple.product-type.application"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -2863,6 +2963,7 @@ 00179595107421BF00F5D044 /* testaudioinfo */, 00179756107431B300F5D044 /* testdraw2 */, DB0F48D917CA51E5008798C5 /* testdrawchessboard */, + DB445EE618184B7000B306B0 /* testdropfile */, BEC566FB0761D90300A33029 /* testerror */, 002F340109CA1BFF00EBEB88 /* testfile */, DB0F48EF17CA5212008798C5 /* testfilesystem */, @@ -2870,6 +2971,7 @@ DB166DAD16A1D2F600A1396C /* testgesture */, 0017970910742F3200F5D044 /* testgl2 */, 00179730107430D600F5D044 /* testhaptic */, + DB89956D18A19ABA0092407C /* testhotplug */, 002F342009CA1F0300EBEB88 /* testiconv */, 00179776107432AE00F5D044 /* testime */, 001797961074334C00F5D044 /* testintersections */, @@ -3304,6 +3406,22 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + DB89956E18A19ABA0092407C /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DB89958418A19B130092407C /* testhotplug.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + DB445EE718184B7000B306B0 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DB445EFB18184BB600B306B0 /* testdropfile.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -3737,6 +3855,7 @@ ); GCC_OPTIMIZATION_LEVEL = 0; HEADER_SEARCH_PATHS = ../../include; + MACOSX_DEPLOYMENT_TARGET = 10.5; }; name = Debug; }; @@ -3862,6 +3981,7 @@ ); GCC_GENERATE_DEBUGGING_SYMBOLS = NO; HEADER_SEARCH_PATHS = ../../include; + MACOSX_DEPLOYMENT_TARGET = 10.5; }; name = Release; }; @@ -4189,6 +4309,36 @@ }; name = Release; }; + DB89957C18A19ABA0092407C /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = testhotplug; + }; + name = Debug; + }; + DB89957D18A19ABA0092407C /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = testhotplug; + }; + name = Release; + }; + DB445EF618184B7000B306B0 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + INFOPLIST_FILE = "TestDropFile-Info.plist"; + PRODUCT_NAME = testdropfile; + }; + name = Debug; + }; + DB445EF718184B7000B306B0 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + INFOPLIST_FILE = "TestDropFile-Info.plist"; + PRODUCT_NAME = testdropfile; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -4606,6 +4756,24 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; + DB89957B18A19ABA0092407C /* Build configuration list for PBXNativeTarget "testhotplug" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DB89957C18A19ABA0092407C /* Debug */, + DB89957D18A19ABA0092407C /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; + DB445EF518184B7000B306B0 /* Build configuration list for PBXNativeTarget "testdropfile" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DB445EF618184B7000B306B0 /* Debug */, + DB445EF718184B7000B306B0 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Debug; + }; /* End XCConfigurationList section */ }; rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; diff --git a/jni/SDL2-2.0.3/Xcode/SDLTest/TestDropFile-Info.plist b/jni/SDL2-2.0.3/Xcode/SDLTest/TestDropFile-Info.plist new file mode 100644 index 00000000..03e46b33 --- /dev/null +++ b/jni/SDL2-2.0.3/Xcode/SDLTest/TestDropFile-Info.plist @@ -0,0 +1,35 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleDocumentTypes + + + CFBundleTypeRole + Viewer + LSHandlerRank + Alternate + LSItemContentTypes + + public.data + + + + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + org.libsdl.test-dropfile + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1.0 + LSMinimumSystemVersion + 10.6 + + diff --git a/jni/SDL2-2.0.1/Xcode/XcodeDocSet/Doxyfile b/jni/SDL2-2.0.3/Xcode/XcodeDocSet/Doxyfile similarity index 100% rename from jni/SDL2-2.0.1/Xcode/XcodeDocSet/Doxyfile rename to jni/SDL2-2.0.3/Xcode/XcodeDocSet/Doxyfile diff --git a/jni/SDL2-2.0.1/acinclude/ac_check_define.m4 b/jni/SDL2-2.0.3/acinclude/ac_check_define.m4 similarity index 100% rename from jni/SDL2-2.0.1/acinclude/ac_check_define.m4 rename to jni/SDL2-2.0.3/acinclude/ac_check_define.m4 diff --git a/jni/SDL2-2.0.1/acinclude/alsa.m4 b/jni/SDL2-2.0.3/acinclude/alsa.m4 similarity index 100% rename from jni/SDL2-2.0.1/acinclude/alsa.m4 rename to jni/SDL2-2.0.3/acinclude/alsa.m4 diff --git a/jni/SDL2-2.0.1/acinclude/ax_check_compiler_flags.m4 b/jni/SDL2-2.0.3/acinclude/ax_check_compiler_flags.m4 similarity index 100% rename from jni/SDL2-2.0.1/acinclude/ax_check_compiler_flags.m4 rename to jni/SDL2-2.0.3/acinclude/ax_check_compiler_flags.m4 diff --git a/jni/SDL2-2.0.1/acinclude/ax_gcc_archflag.m4 b/jni/SDL2-2.0.3/acinclude/ax_gcc_archflag.m4 similarity index 100% rename from jni/SDL2-2.0.1/acinclude/ax_gcc_archflag.m4 rename to jni/SDL2-2.0.3/acinclude/ax_gcc_archflag.m4 diff --git a/jni/SDL2-2.0.1/acinclude/ax_gcc_x86_cpuid.m4.htm b/jni/SDL2-2.0.3/acinclude/ax_gcc_x86_cpuid.m4.htm similarity index 100% rename from jni/SDL2-2.0.1/acinclude/ax_gcc_x86_cpuid.m4.htm rename to jni/SDL2-2.0.3/acinclude/ax_gcc_x86_cpuid.m4.htm diff --git a/jni/SDL2-2.0.1/acinclude/esd.m4 b/jni/SDL2-2.0.3/acinclude/esd.m4 similarity index 100% rename from jni/SDL2-2.0.1/acinclude/esd.m4 rename to jni/SDL2-2.0.3/acinclude/esd.m4 diff --git a/jni/SDL2-2.0.1/acinclude/libtool.m4 b/jni/SDL2-2.0.3/acinclude/libtool.m4 similarity index 100% rename from jni/SDL2-2.0.1/acinclude/libtool.m4 rename to jni/SDL2-2.0.3/acinclude/libtool.m4 diff --git a/jni/SDL2-2.0.1/acinclude/ltoptions.m4 b/jni/SDL2-2.0.3/acinclude/ltoptions.m4 similarity index 100% rename from jni/SDL2-2.0.1/acinclude/ltoptions.m4 rename to jni/SDL2-2.0.3/acinclude/ltoptions.m4 diff --git a/jni/SDL2-2.0.1/acinclude/ltsugar.m4 b/jni/SDL2-2.0.3/acinclude/ltsugar.m4 similarity index 100% rename from jni/SDL2-2.0.1/acinclude/ltsugar.m4 rename to jni/SDL2-2.0.3/acinclude/ltsugar.m4 diff --git a/jni/SDL2-2.0.1/acinclude/ltversion.m4 b/jni/SDL2-2.0.3/acinclude/ltversion.m4 similarity index 100% rename from jni/SDL2-2.0.1/acinclude/ltversion.m4 rename to jni/SDL2-2.0.3/acinclude/ltversion.m4 diff --git a/jni/SDL2-2.0.1/acinclude/lt~obsolete.m4 b/jni/SDL2-2.0.3/acinclude/lt~obsolete.m4 similarity index 100% rename from jni/SDL2-2.0.1/acinclude/lt~obsolete.m4 rename to jni/SDL2-2.0.3/acinclude/lt~obsolete.m4 diff --git a/jni/SDL2-2.0.1/android-project/AndroidManifest.xml b/jni/SDL2-2.0.3/android-project/AndroidManifest.xml similarity index 100% rename from jni/SDL2-2.0.1/android-project/AndroidManifest.xml rename to jni/SDL2-2.0.3/android-project/AndroidManifest.xml diff --git a/jni/SDL2-2.0.1/android-project/ant.properties b/jni/SDL2-2.0.3/android-project/ant.properties similarity index 100% rename from jni/SDL2-2.0.1/android-project/ant.properties rename to jni/SDL2-2.0.3/android-project/ant.properties diff --git a/jni/SDL2-2.0.1/android-project/build.properties b/jni/SDL2-2.0.3/android-project/build.properties similarity index 100% rename from jni/SDL2-2.0.1/android-project/build.properties rename to jni/SDL2-2.0.3/android-project/build.properties diff --git a/jni/SDL2-2.0.1/android-project/build.xml b/jni/SDL2-2.0.3/android-project/build.xml similarity index 100% rename from jni/SDL2-2.0.1/android-project/build.xml rename to jni/SDL2-2.0.3/android-project/build.xml diff --git a/jni/SDL2-2.0.1/android-project/default.properties b/jni/SDL2-2.0.3/android-project/default.properties similarity index 100% rename from jni/SDL2-2.0.1/android-project/default.properties rename to jni/SDL2-2.0.3/android-project/default.properties diff --git a/jni/SDL2-2.0.1/android-project/jni/Android.mk b/jni/SDL2-2.0.3/android-project/jni/Android.mk similarity index 100% rename from jni/SDL2-2.0.1/android-project/jni/Android.mk rename to jni/SDL2-2.0.3/android-project/jni/Android.mk diff --git a/jni/SDL2-2.0.1/android-project/jni/Application.mk b/jni/SDL2-2.0.3/android-project/jni/Application.mk similarity index 100% rename from jni/SDL2-2.0.1/android-project/jni/Application.mk rename to jni/SDL2-2.0.3/android-project/jni/Application.mk diff --git a/jni/SDL2-2.0.1/android-project/jni/src/Android.mk b/jni/SDL2-2.0.3/android-project/jni/src/Android.mk similarity index 100% rename from jni/SDL2-2.0.1/android-project/jni/src/Android.mk rename to jni/SDL2-2.0.3/android-project/jni/src/Android.mk diff --git a/jni/SDL2-2.0.1/android-project/jni/src/Android_static.mk b/jni/SDL2-2.0.3/android-project/jni/src/Android_static.mk similarity index 100% rename from jni/SDL2-2.0.1/android-project/jni/src/Android_static.mk rename to jni/SDL2-2.0.3/android-project/jni/src/Android_static.mk diff --git a/jni/SDL2-2.0.1/android-project/proguard-project.txt b/jni/SDL2-2.0.3/android-project/proguard-project.txt similarity index 100% rename from jni/SDL2-2.0.1/android-project/proguard-project.txt rename to jni/SDL2-2.0.3/android-project/proguard-project.txt diff --git a/jni/SDL2-2.0.1/android-project/project.properties b/jni/SDL2-2.0.3/android-project/project.properties similarity index 100% rename from jni/SDL2-2.0.1/android-project/project.properties rename to jni/SDL2-2.0.3/android-project/project.properties diff --git a/jni/SDL2-2.0.1/android-project/res/drawable-hdpi/ic_launcher.png b/jni/SDL2-2.0.3/android-project/res/drawable-hdpi/ic_launcher.png similarity index 100% rename from jni/SDL2-2.0.1/android-project/res/drawable-hdpi/ic_launcher.png rename to jni/SDL2-2.0.3/android-project/res/drawable-hdpi/ic_launcher.png diff --git a/jni/SDL2-2.0.1/android-project/res/drawable-mdpi/ic_launcher.png b/jni/SDL2-2.0.3/android-project/res/drawable-mdpi/ic_launcher.png similarity index 100% rename from jni/SDL2-2.0.1/android-project/res/drawable-mdpi/ic_launcher.png rename to jni/SDL2-2.0.3/android-project/res/drawable-mdpi/ic_launcher.png diff --git a/jni/SDL2-2.0.1/android-project/res/drawable-xhdpi/ic_launcher.png b/jni/SDL2-2.0.3/android-project/res/drawable-xhdpi/ic_launcher.png similarity index 100% rename from jni/SDL2-2.0.1/android-project/res/drawable-xhdpi/ic_launcher.png rename to jni/SDL2-2.0.3/android-project/res/drawable-xhdpi/ic_launcher.png diff --git a/jni/SDL2-2.0.1/android-project/res/drawable-xxhdpi/ic_launcher.png b/jni/SDL2-2.0.3/android-project/res/drawable-xxhdpi/ic_launcher.png similarity index 100% rename from jni/SDL2-2.0.1/android-project/res/drawable-xxhdpi/ic_launcher.png rename to jni/SDL2-2.0.3/android-project/res/drawable-xxhdpi/ic_launcher.png diff --git a/jni/SDL2-2.0.1/android-project/res/layout/main.xml b/jni/SDL2-2.0.3/android-project/res/layout/main.xml similarity index 100% rename from jni/SDL2-2.0.1/android-project/res/layout/main.xml rename to jni/SDL2-2.0.3/android-project/res/layout/main.xml diff --git a/jni/SDL2-2.0.1/android-project/res/values/strings.xml b/jni/SDL2-2.0.3/android-project/res/values/strings.xml similarity index 100% rename from jni/SDL2-2.0.1/android-project/res/values/strings.xml rename to jni/SDL2-2.0.3/android-project/res/values/strings.xml diff --git a/jni/SDL2-2.0.1/android-project/src/org/libsdl/app/SDLActivity.java b/jni/SDL2-2.0.3/android-project/src/org/libsdl/app/SDLActivity.java similarity index 94% rename from jni/SDL2-2.0.1/android-project/src/org/libsdl/app/SDLActivity.java rename to jni/SDL2-2.0.3/android-project/src/org/libsdl/app/SDLActivity.java index a7cb0557..49a1d38f 100644 --- a/jni/SDL2-2.0.1/android-project/src/org/libsdl/app/SDLActivity.java +++ b/jni/SDL2-2.0.3/android-project/src/org/libsdl/app/SDLActivity.java @@ -28,7 +28,7 @@ public class SDLActivity extends Activity { private static final String TAG = "SDL"; // Keep track of the paused state - public static boolean mIsPaused = false, mIsSurfaceReady = false, mHasFocus = true; + public static boolean mIsPaused, mIsSurfaceReady, mHasFocus; public static boolean mExitCalledFromJava; // Main components @@ -42,7 +42,6 @@ public class SDLActivity extends Activity { protected static Thread mSDLThread; // Audio - protected static Thread mAudioThread; protected static AudioTrack mAudioTrack; // Load the .so @@ -54,22 +53,37 @@ public class SDLActivity extends Activity { //System.loadLibrary("SDL2_ttf"); System.loadLibrary("main"); } + + + public static void initialize() { + // The static nature of the singleton and Android quirkyness force us to initialize everything here + // Otherwise, when exiting the app and returning to it, these variables *keep* their pre exit values + mSingleton = null; + mSurface = null; + mTextEdit = null; + mLayout = null; + mJoystickHandler = null; + mSDLThread = null; + mAudioTrack = null; + mExitCalledFromJava = false; + mIsPaused = false; + mIsSurfaceReady = false; + mHasFocus = true; + } // Setup @Override protected void onCreate(Bundle savedInstanceState) { - //Log.v("SDL", "onCreate()"); + Log.v("SDL", "onCreate():" + mSingleton); super.onCreate(savedInstanceState); + SDLActivity.initialize(); // So we can call stuff from static callbacks mSingleton = this; // Set up the surface mSurface = new SDLSurface(getApplication()); - // Make sure this variable is initialized here! - mExitCalledFromJava = false; - if(Build.VERSION.SDK_INT >= 12) { mJoystickHandler = new SDLJoystickHandler_API12(); } @@ -119,7 +133,6 @@ public class SDLActivity extends Activity { @Override protected void onDestroy() { - super.onDestroy(); Log.v("SDL", "onDestroy()"); // Send a quit message to the application SDLActivity.mExitCalledFromJava = true; @@ -136,6 +149,10 @@ public class SDLActivity extends Activity { //Log.v("SDL", "Finished waiting for SDL thread"); } + + super.onDestroy(); + // Reset everything in case the user re opens the app + SDLActivity.initialize(); } @Override @@ -263,6 +280,8 @@ public class SDLActivity extends Activity { public static native int onNativePadUp(int device_id, int keycode); public static native void onNativeJoy(int device_id, int axis, float value); + public static native void onNativeHat(int device_id, int hat_id, + int x, int y); public static native void onNativeKeyDown(int keycode); public static native void onNativeKeyUp(int keycode); public static native void onNativeKeyboardFocusLost(); @@ -924,6 +943,7 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler { public int device_id; public String name; public ArrayList axes; + public ArrayList hats; } class RangeComparator implements Comparator { @@ -957,17 +977,25 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler { joystick.device_id = deviceIds[i]; joystick.name = joystickDevice.getName(); joystick.axes = new ArrayList(); + joystick.hats = new ArrayList(); List ranges = joystickDevice.getMotionRanges(); Collections.sort(ranges, new RangeComparator()); for (InputDevice.MotionRange range : ranges ) { - if ( (range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0 ) { - joystick.axes.add(range); - } + if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0 ) { + if (range.getAxis() == MotionEvent.AXIS_HAT_X || + range.getAxis() == MotionEvent.AXIS_HAT_Y) { + joystick.hats.add(range); + } + else { + joystick.axes.add(range); + } + } } mJoysticks.add(joystick); - SDLActivity.nativeAddJoystick(joystick.device_id, joystick.name, 0, -1, joystick.axes.size(), 0, 0); + SDLActivity.nativeAddJoystick(joystick.device_id, joystick.name, 0, -1, + joystick.axes.size(), joystick.hats.size()/2, 0); } } } @@ -1020,7 +1048,12 @@ class SDLJoystickHandler_API12 extends SDLJoystickHandler { /* Normalize the value to -1...1 */ float value = ( event.getAxisValue( range.getAxis(), actionPointerIndex) - range.getMin() ) / range.getRange() * 2.0f - 1.0f; SDLActivity.onNativeJoy(joystick.device_id, i, value ); - } + } + for (int i = 0; i < joystick.hats.size(); i+=2) { + int hatX = Math.round(event.getAxisValue( joystick.hats.get(i).getAxis(), actionPointerIndex ) ); + int hatY = Math.round(event.getAxisValue( joystick.hats.get(i+1).getAxis(), actionPointerIndex ) ); + SDLActivity.onNativeHat(joystick.device_id, i/2, hatX, hatY ); + } } break; default: diff --git a/jni/SDL2-2.0.1/autogen.sh b/jni/SDL2-2.0.3/autogen.sh similarity index 100% rename from jni/SDL2-2.0.1/autogen.sh rename to jni/SDL2-2.0.3/autogen.sh diff --git a/jni/SDL2-2.0.1/build-scripts/androidbuild.sh b/jni/SDL2-2.0.3/build-scripts/androidbuild.sh similarity index 100% rename from jni/SDL2-2.0.1/build-scripts/androidbuild.sh rename to jni/SDL2-2.0.3/build-scripts/androidbuild.sh diff --git a/jni/SDL2-2.0.1/build-scripts/config.guess b/jni/SDL2-2.0.3/build-scripts/config.guess similarity index 100% rename from jni/SDL2-2.0.1/build-scripts/config.guess rename to jni/SDL2-2.0.3/build-scripts/config.guess diff --git a/jni/SDL2-2.0.1/build-scripts/config.sub b/jni/SDL2-2.0.3/build-scripts/config.sub similarity index 100% rename from jni/SDL2-2.0.1/build-scripts/config.sub rename to jni/SDL2-2.0.3/build-scripts/config.sub diff --git a/jni/SDL2-2.0.1/build-scripts/g++-fat.sh b/jni/SDL2-2.0.3/build-scripts/g++-fat.sh similarity index 100% rename from jni/SDL2-2.0.1/build-scripts/g++-fat.sh rename to jni/SDL2-2.0.3/build-scripts/g++-fat.sh diff --git a/jni/SDL2-2.0.1/build-scripts/gcc-fat.sh b/jni/SDL2-2.0.3/build-scripts/gcc-fat.sh similarity index 100% rename from jni/SDL2-2.0.1/build-scripts/gcc-fat.sh rename to jni/SDL2-2.0.3/build-scripts/gcc-fat.sh diff --git a/jni/SDL2-2.0.1/build-scripts/install-sh b/jni/SDL2-2.0.3/build-scripts/install-sh similarity index 100% rename from jni/SDL2-2.0.1/build-scripts/install-sh rename to jni/SDL2-2.0.3/build-scripts/install-sh diff --git a/jni/SDL2-2.0.1/build-scripts/iosbuild.sh b/jni/SDL2-2.0.3/build-scripts/iosbuild.sh similarity index 100% rename from jni/SDL2-2.0.1/build-scripts/iosbuild.sh rename to jni/SDL2-2.0.3/build-scripts/iosbuild.sh diff --git a/jni/SDL2-2.0.1/build-scripts/ltmain.sh b/jni/SDL2-2.0.3/build-scripts/ltmain.sh similarity index 100% rename from jni/SDL2-2.0.1/build-scripts/ltmain.sh rename to jni/SDL2-2.0.3/build-scripts/ltmain.sh diff --git a/jni/SDL2-2.0.1/build-scripts/mkinstalldirs b/jni/SDL2-2.0.3/build-scripts/mkinstalldirs similarity index 100% rename from jni/SDL2-2.0.1/build-scripts/mkinstalldirs rename to jni/SDL2-2.0.3/build-scripts/mkinstalldirs diff --git a/jni/SDL2-2.0.1/build-scripts/raspberrypi-buildbot.sh b/jni/SDL2-2.0.3/build-scripts/raspberrypi-buildbot.sh similarity index 98% rename from jni/SDL2-2.0.1/build-scripts/raspberrypi-buildbot.sh rename to jni/SDL2-2.0.3/build-scripts/raspberrypi-buildbot.sh index 1cc637c5..db258347 100755 --- a/jni/SDL2-2.0.1/build-scripts/raspberrypi-buildbot.sh +++ b/jni/SDL2-2.0.3/build-scripts/raspberrypi-buildbot.sh @@ -42,7 +42,7 @@ SYSROOT="/opt/rpi-sysroot" export CC="ccache /opt/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc --sysroot=$SYSROOT -I$SYSROOT/opt/vc/include -I$SYSROOT/usr/include -I$SYSROOT/opt/vc/include/interface/vcos/pthreads -I$SYSROOT/opt/vc/include/interface/vmcs_host/linux -L$SYSROOT/opt/vc/lib" # -L$SYSROOT/usr/lib/arm-linux-gnueabihf" # !!! FIXME: shouldn't have to --disable-* things here. -../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd +../configure --with-sysroot=$SYSROOT --host=arm-raspberry-linux-gnueabihf --prefix=$PWD/rpi-sdl2-installed --disable-pulseaudio --disable-esd --disable-video-mir $MAKE $MAKE install # Fix up a few things to a real install path on a real Raspberry Pi... diff --git a/jni/SDL2-2.0.1/build-scripts/showrev.sh b/jni/SDL2-2.0.3/build-scripts/showrev.sh similarity index 100% rename from jni/SDL2-2.0.1/build-scripts/showrev.sh rename to jni/SDL2-2.0.3/build-scripts/showrev.sh diff --git a/jni/SDL2-2.0.1/build-scripts/strip_fPIC.sh b/jni/SDL2-2.0.3/build-scripts/strip_fPIC.sh similarity index 100% rename from jni/SDL2-2.0.1/build-scripts/strip_fPIC.sh rename to jni/SDL2-2.0.3/build-scripts/strip_fPIC.sh diff --git a/jni/SDL2-2.0.1/build-scripts/updaterev.sh b/jni/SDL2-2.0.3/build-scripts/updaterev.sh similarity index 100% rename from jni/SDL2-2.0.1/build-scripts/updaterev.sh rename to jni/SDL2-2.0.3/build-scripts/updaterev.sh diff --git a/jni/SDL2-2.0.1/cmake/macros.cmake b/jni/SDL2-2.0.3/cmake/macros.cmake similarity index 100% rename from jni/SDL2-2.0.1/cmake/macros.cmake rename to jni/SDL2-2.0.3/cmake/macros.cmake diff --git a/jni/SDL2-2.0.1/cmake/sdlchecks.cmake b/jni/SDL2-2.0.3/cmake/sdlchecks.cmake similarity index 96% rename from jni/SDL2-2.0.1/cmake/sdlchecks.cmake rename to jni/SDL2-2.0.3/cmake/sdlchecks.cmake index 0dc549ea..2cd09e6f 100644 --- a/jni/SDL2-2.0.1/cmake/sdlchecks.cmake +++ b/jni/SDL2-2.0.3/cmake/sdlchecks.cmake @@ -505,9 +505,32 @@ macro(CheckX11) endif(VIDEO_X11) endmacro(CheckX11) +macro(CheckMir) +# !!! FIXME: hook up dynamic loading here. + if(VIDEO_MIR) + find_library(MIR_LIB mirclient mircommon egl) + pkg_check_modules(MIR_TOOLKIT mirclient mircommon) + pkg_check_modules(EGL egl) + pkg_check_modules(XKB xkbcommon) + + if (MIR_LIB AND MIR_TOOLKIT_FOUND AND EGL_FOUND AND XKB_FOUND) + set(HAVE_VIDEO_MIR TRUE) + set(HAVE_SDL_VIDEO TRUE) + + file(GLOB MIR_SOURCES ${SDL2_SOURCE_DIR}/src/video/mir/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${MIR_SOURCES}) + set(SDL_VIDEO_DRIVER_MIR 1) + + list(APPEND EXTRA_CFLAGS ${MIR_TOOLKIT_CFLAGS} ${EGL_CLFAGS} ${XKB_CLFLAGS}) + list(APPEND EXTRA_LDFLAGS ${MIR_TOOLKIT_LDFLAGS} ${EGL_LDLAGS} ${XKB_LDLAGS}) + endif (MIR_LIB AND MIR_TOOLKIT_FOUND AND EGL_FOUND AND XKB_FOUND) + endif(VIDEO_MIR) +endmacro(CheckMir) + # Requires: # - EGL macro(CheckWayland) +# !!! FIXME: hook up dynamic loading here. if(VIDEO_WAYLAND) pkg_check_modules(WAYLAND wayland-client wayland-cursor wayland-egl egl xkbcommon) if(WAYLAND_FOUND) @@ -533,9 +556,9 @@ endmacro(CheckWayland) # macro(CheckCOCOA) if(VIDEO_COCOA) - check_objc_source_compiles(" - #import - int main (int argc, char** argv) {}" HAVE_VIDEO_COCOA) + if(APPLE) # Apple always has Cocoa. + set(HAVE_VIDEO_COCOA TRUE) + endif(APPLE) if(HAVE_VIDEO_COCOA) file(GLOB COCOA_SOURCES ${SDL2_SOURCE_DIR}/src/video/cocoa/*.m) set_source_files_properties(${COCOA_SOURCES} PROPERTIES LANGUAGE C) diff --git a/jni/SDL2-2.0.1/configure b/jni/SDL2-2.0.3/configure similarity index 99% rename from jni/SDL2-2.0.1/configure rename to jni/SDL2-2.0.3/configure index 07bc1561..1999cf9a 100755 --- a/jni/SDL2-2.0.1/configure +++ b/jni/SDL2-2.0.3/configure @@ -820,6 +820,8 @@ enable_dummyaudio enable_video_wayland enable_video_wayland_qt_touch enable_wayland_shared +enable_video_mir +enable_mir_shared enable_video_x11 with_x enable_x11_shared @@ -1539,6 +1541,8 @@ Optional Features: QtWayland server support for Wayland video driver [[default=yes]] --enable-wayland-shared dynamically load Wayland support [[default=maybe]] + --enable-video-mir use Mir video driver [[default=yes]] + --enable-mir-shared dynamically load Mir support [[default=maybe]] --enable-video-x11 use X11 video driver [[default=yes]] --enable-x11-shared dynamically load X11 support [[default=maybe]] --enable-video-x11-xcursor @@ -2667,9 +2671,9 @@ orig_CFLAGS="$CFLAGS" # SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=0 -SDL_MICRO_VERSION=1 -SDL_INTERFACE_AGE=0 -SDL_BINARY_AGE=1 +SDL_MICRO_VERSION=3 +SDL_INTERFACE_AGE=1 +SDL_BINARY_AGE=3 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION @@ -18627,7 +18631,6 @@ $as_echo "$have_gcc_preferred_stack_boundary" >&6; } fi } - CheckWarnAll() { { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -Wall option" >&5 @@ -18685,9 +18688,9 @@ CheckWayland() if test "${enable_video_wayland+set}" = set; then : enableval=$enable_video_wayland; else - enable_video_wayland=yes + enable_video_wayland=no fi - + #yes) # Check whether --enable-video-wayland-qt-touch was given. if test "${enable_video_wayland_qt_touch+set}" = set; then : @@ -18788,8 +18791,8 @@ fi fi if test x$have_loadso != xyes && \ test x$enable_wayland_shared = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic WAYLAND loading" >&5 -$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic WAYLAND loading" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic Wayland loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic Wayland loading" >&2;} enable_wayland_shared=no fi if test x$have_loadso = xyes && \ @@ -18801,7 +18804,7 @@ $as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic WA echo "-- dynamic libwayland-client -> $wayland_client_lib" echo "-- dynamic libwayland-egl -> $wayland_egl_lib" echo "-- dynamic libwayland-cursor -> $wayland_cursor_lib" - echo "-- dynamic xkbcommon -> $xkbcommon_lib" + echo "-- dynamic libxkbcommon -> $xkbcommon_lib" cat >>confdefs.h <<_ACEOF #define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC "$wayland_client_lib" @@ -18833,6 +18836,129 @@ _ACEOF fi } +CheckMir() +{ + # Check whether --enable-video-mir was given. +if test "${enable_video_mir+set}" = set; then : + enableval=$enable_video_mir; +else + enable_video_mir=no +fi + #yes) + + if test x$enable_video = xyes -a x$enable_video_mir = xyes; then + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no" + ;; +esac +fi +PKG_CONFIG=$ac_cv_path_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 +$as_echo "$PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mir support" >&5 +$as_echo_n "checking for Mir support... " >&6; } + video_mir=no + if test x$PKG_CONFIG != xno; then + if $PKG_CONFIG --exists mirclient egl xkbcommon ; then + MIR_CFLAGS=`$PKG_CONFIG --cflags mirclient egl xkbcommon` + MIR_LIBS=`$PKG_CONFIG --libs mirclient egl xkbcommon` + video_mir=yes + fi + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_mir" >&5 +$as_echo "$video_mir" >&6; } + + if test x$video_mir = xyes; then + +$as_echo "#define SDL_VIDEO_DRIVER_MIR 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/video/mir/*.c" + EXTRA_CFLAGS="$EXTRA_CFLAGS $MIR_CFLAGS" + # Check whether --enable-mir-shared was given. +if test "${enable_mir_shared+set}" = set; then : + enableval=$enable_mir_shared; +else + enable_mir_shared=maybe +fi + + + case "$host" in + *) + mirclient_lib=`find_lib "libmirclient.so.*" "$MIR_LIBS" | sed 's/.*\/\(.*\)/\1/; q'` + xkbcommon_lib=`find_lib "libxkbcommon.so.*" "$MIR_LIBS" | sed 's/.*\/\(.*\)/\1/; q'` + ;; + esac + + if test x$enable_mir_shared = xmaybe; then + enable_mir_shared=yes + fi + if test x$have_loadso != xyes && \ + test x$enable_mir_shared = xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic Mir loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic Mir loading" >&2;} + enable_mir_shared=no + fi + if test x$have_loadso = xyes && \ + test x$enable_mir_shared = xyes && \ + test x$mirclient_lib != x && \ + test x$xkbcommon_lib != x; then + echo "-- dynamic libmirclient -> $mirclient_lib" + echo "-- dynamic libxkbcommon -> $xkbcommon_lib" + +cat >>confdefs.h <<_ACEOF +#define SDL_VIDEO_DRIVER_MIR_DYNAMIC "$mirclient_lib" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON "$xkbcommon_lib" +_ACEOF + + SUMMARY_video="${SUMMARY_video} mir(dynamic)" + else + enable_mir_shared=no + EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MIR_LIBS" + SUMMARY_video="${SUMMARY_video} mir" + fi + have_video=yes + fi + fi +} + + CheckX11() { @@ -20047,11 +20173,6 @@ main () int event_type = XI_TouchBegin; XITouchClassInfo *t; -Status -XIAllowTouchEvents(Display *a,int b,unsigned int c,Window d,int f) -{ - return (Status)0; -} ; return 0; @@ -20077,17 +20198,30 @@ else fi if test x$enable_video_x11_xrandr = xyes; then - definitely_enable_video_x11_xrandr=no - ac_fn_c_check_header_compile "$LINENO" "X11/extensions/Xrandr.h" "ac_cv_header_X11_extensions_Xrandr_h" "#include + definitely_enable_video_x11_xrandr=no + have_xrandr_h_hdr=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #include + +int +main () +{ + + XRRScreenResources *res = NULL; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + have_xrandr_h_hdr=yes -" -if test "x$ac_cv_header_X11_extensions_Xrandr_h" = xyes; then : - have_xrandr_h_hdr=yes -else - have_xrandr_h_hdr=no fi - - +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test x$have_xrandr_h_hdr = xyes; then if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then echo "-- dynamic libXrandr -> $xrandr_lib" @@ -21746,6 +21880,12 @@ if test "x$ac_cv_header_d3d9_h" = xyes; then : fi + ac_fn_c_check_header_mongrel "$LINENO" "d3d11_1.h" "ac_cv_header_d3d11_1_h" "$ac_includes_default" +if test "x$ac_cv_header_d3d11_1_h" = xyes; then : + have_d3d11=yes +fi + + ac_fn_c_check_header_mongrel "$LINENO" "ddraw.h" "ac_cv_header_ddraw_h" "$ac_includes_default" if test "x$ac_cv_header_ddraw_h" = xyes; then : have_ddraw=yes @@ -22438,6 +22578,7 @@ case "$host" in CheckSNDIO CheckX11 CheckWayland + CheckMir CheckDirectFB CheckFusionSound CheckOpenGLX11 @@ -22581,6 +22722,11 @@ fi $as_echo "#define SDL_VIDEO_RENDER_D3D 1" >>confdefs.h + fi + if test x$enable_render_d3d = xyes -a x$have_d3d11 = xyes; then + +$as_echo "#define SDL_VIDEO_RENDER_D3D11 1" >>confdefs.h + fi fi # Set up files for the audio library @@ -22668,7 +22814,12 @@ $as_echo "#define SDL_LOADSO_WINDOWS 1" >>confdefs.h have_loadso=yes fi # Set up the system libraries we need - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -XCClinker -static-libgcc" + if test -f /lib/w32api/libuuid.a; then + LIBUUID=/lib/w32api/libuuid.a + else + LIBUUID=-luuid + fi + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion $LIBUUID -XCClinker -static-libgcc" # The Windows platform requires special setup VERSION_SOURCES="$srcdir/src/main/windows/*.rc" SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c" @@ -22868,9 +23019,6 @@ $as_echo "#define SDL_FILESYSTEM_HAIKU 1" >>confdefs.h CheckOpenGLX11 CheckPTHREAD - # Need this or things might misbuild on a G3. - EXTRA_CFLAGS="$EXTRA_CFLAGS -force_cpusubtype_ALL" - # Set up files for the audio library if test x$enable_audio = xyes; then diff --git a/jni/SDL2-2.0.1/configure.in b/jni/SDL2-2.0.3/configure.in similarity index 96% rename from jni/SDL2-2.0.1/configure.in rename to jni/SDL2-2.0.3/configure.in index a38abd4b..3d8a2de2 100644 --- a/jni/SDL2-2.0.1/configure.in +++ b/jni/SDL2-2.0.3/configure.in @@ -20,9 +20,9 @@ dnl Set various version strings - taken gratefully from the GTk sources # SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=0 -SDL_MICRO_VERSION=1 -SDL_INTERFACE_AGE=0 -SDL_BINARY_AGE=1 +SDL_MICRO_VERSION=3 +SDL_INTERFACE_AGE=1 +SDL_BINARY_AGE=3 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION AC_SUBST(SDL_MAJOR_VERSION) @@ -1124,7 +1124,6 @@ CheckStackBoundary() fi } - dnl See if GCC's -Wall is supported. CheckWarnAll() { @@ -1165,7 +1164,7 @@ CheckWayland() { AC_ARG_ENABLE(video-wayland, AC_HELP_STRING([--enable-video-wayland], [use Wayland video driver [[default=yes]]]), - ,enable_video_wayland=yes) + ,enable_video_wayland=no) #yes) AC_ARG_ENABLE(video-wayland-qt-touch, AC_HELP_STRING([--enable-video-wayland-qt-touch], [QtWayland server support for Wayland video driver [[default=yes]]]), @@ -1214,7 +1213,7 @@ AC_HELP_STRING([--enable-wayland-shared], [dynamically load Wayland support [[de fi if test x$have_loadso != xyes && \ test x$enable_wayland_shared = xyes; then - AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic WAYLAND loading]) + AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic Wayland loading]) enable_wayland_shared=no fi if test x$have_loadso = xyes && \ @@ -1226,7 +1225,7 @@ AC_HELP_STRING([--enable-wayland-shared], [dynamically load Wayland support [[de echo "-- dynamic libwayland-client -> $wayland_client_lib" echo "-- dynamic libwayland-egl -> $wayland_egl_lib" echo "-- dynamic libwayland-cursor -> $wayland_cursor_lib" - echo "-- dynamic xkbcommon -> $xkbcommon_lib" + echo "-- dynamic libxkbcommon -> $xkbcommon_lib" AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC, "$wayland_client_lib", [ ]) AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL, "$wayland_egl_lib", [ ]) AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR, "$wayland_cursor_lib", [ ]) @@ -1242,6 +1241,70 @@ AC_HELP_STRING([--enable-wayland-shared], [dynamically load Wayland support [[de fi } +dnl Check for Mir +CheckMir() +{ + AC_ARG_ENABLE(video-mir, +AC_HELP_STRING([--enable-video-mir], [use Mir video driver [[default=yes]]]), + ,enable_video_mir=no) #yes) + + if test x$enable_video = xyes -a x$enable_video_mir = xyes; then + AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + AC_MSG_CHECKING(for Mir support) + video_mir=no + if test x$PKG_CONFIG != xno; then + if $PKG_CONFIG --exists mirclient egl xkbcommon ; then + MIR_CFLAGS=`$PKG_CONFIG --cflags mirclient egl xkbcommon` + MIR_LIBS=`$PKG_CONFIG --libs mirclient egl xkbcommon` + video_mir=yes + fi + fi + AC_MSG_RESULT($video_mir) + + if test x$video_mir = xyes; then + AC_DEFINE(SDL_VIDEO_DRIVER_MIR, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/video/mir/*.c" + EXTRA_CFLAGS="$EXTRA_CFLAGS $MIR_CFLAGS" + AC_ARG_ENABLE(mir-shared, +AC_HELP_STRING([--enable-mir-shared], [dynamically load Mir support [[default=maybe]]]), + , enable_mir_shared=maybe) + + dnl FIXME: Do BSD and OS X need special cases? + case "$host" in + *) + mirclient_lib=[`find_lib "libmirclient.so.*" "$MIR_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`] + xkbcommon_lib=[`find_lib "libxkbcommon.so.*" "$MIR_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`] + ;; + esac + + if test x$enable_mir_shared = xmaybe; then + enable_mir_shared=yes + fi + if test x$have_loadso != xyes && \ + test x$enable_mir_shared = xyes; then + AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic Mir loading]) + enable_mir_shared=no + fi + if test x$have_loadso = xyes && \ + test x$enable_mir_shared = xyes && \ + test x$mirclient_lib != x && \ + test x$xkbcommon_lib != x; then + echo "-- dynamic libmirclient -> $mirclient_lib" + echo "-- dynamic libxkbcommon -> $xkbcommon_lib" + AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_MIR_DYNAMIC, "$mirclient_lib", [ ]) + AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON, "$xkbcommon_lib", [ ]) + SUMMARY_video="${SUMMARY_video} mir(dynamic)" + else + enable_mir_shared=no + EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MIR_LIBS" + SUMMARY_video="${SUMMARY_video} mir" + fi + have_video=yes + fi + fi +} + + dnl Find the X11 include and library directories CheckX11() { @@ -1492,11 +1555,6 @@ AC_HELP_STRING([--enable-video-x11-xinput], [enable X11 XInput extension for man ],[ int event_type = XI_TouchBegin; XITouchClassInfo *t; -Status -XIAllowTouchEvents(Display *a,int b,unsigned int c,Window d,int f) -{ - return (Status)0; -} ],[ have_xinput2_multitouch=yes AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH) @@ -1508,12 +1566,17 @@ XIAllowTouchEvents(Display *a,int b,unsigned int c,Window d,int f) AC_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]), , enable_video_x11_xrandr=yes) if test x$enable_video_x11_xrandr = xyes; then + dnl XRRScreenResources is only present in Xrandr >= 1.2, we use that as a test. definitely_enable_video_x11_xrandr=no - AC_CHECK_HEADER(X11/extensions/Xrandr.h, - have_xrandr_h_hdr=yes, - have_xrandr_h_hdr=no, - [#include - ]) + have_xrandr_h_hdr=no + AC_TRY_COMPILE([ + #include + #include + ],[ + XRRScreenResources *res = NULL; + ],[ + have_xrandr_h_hdr=yes + ]) if test x$have_xrandr_h_hdr = xyes; then if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then echo "-- dynamic libXrandr -> $xrandr_lib" @@ -2331,6 +2394,7 @@ AC_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[defaul , enable_directx=yes) if test x$enable_directx = xyes; then AC_CHECK_HEADER(d3d9.h, have_d3d=yes) + AC_CHECK_HEADER(d3d11_1.h, have_d3d11=yes) AC_CHECK_HEADER(ddraw.h, have_ddraw=yes) AC_CHECK_HEADER(dsound.h, have_dsound=yes) AC_CHECK_HEADER(dinput.h, have_dinput=yes) @@ -2607,6 +2671,7 @@ case "$host" in CheckSNDIO CheckX11 CheckWayland + CheckMir CheckDirectFB CheckFusionSound CheckOpenGLX11 @@ -2727,6 +2792,9 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then AC_DEFINE(SDL_VIDEO_RENDER_D3D, 1, [ ]) fi + if test x$enable_render_d3d = xyes -a x$have_d3d11 = xyes; then + AC_DEFINE(SDL_VIDEO_RENDER_D3D11, 1, [ ]) + fi fi # Set up files for the audio library if test x$enable_audio = xyes; then @@ -2791,7 +2859,12 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau have_loadso=yes fi # Set up the system libraries we need - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -luuid -XCClinker -static-libgcc" + if test -f /lib/w32api/libuuid.a; then + LIBUUID=/lib/w32api/libuuid.a + else + LIBUUID=-luuid + fi + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion $LIBUUID -XCClinker -static-libgcc" # The Windows platform requires special setup VERSION_SOURCES="$srcdir/src/main/windows/*.rc" SDLMAIN_SOURCES="$srcdir/src/main/windows/*.c" @@ -2947,9 +3020,6 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau CheckOpenGLX11 CheckPTHREAD - # Need this or things might misbuild on a G3. - EXTRA_CFLAGS="$EXTRA_CFLAGS -force_cpusubtype_ALL" - # Set up files for the audio library if test x$enable_audio = xyes; then AC_DEFINE(SDL_AUDIO_DRIVER_COREAUDIO, 1, [ ]) diff --git a/jni/SDL2-2.0.1/debian/changelog b/jni/SDL2-2.0.3/debian/changelog similarity index 89% rename from jni/SDL2-2.0.1/debian/changelog rename to jni/SDL2-2.0.3/debian/changelog index 8e9dd49b..84d1b878 100644 --- a/jni/SDL2-2.0.1/debian/changelog +++ b/jni/SDL2-2.0.3/debian/changelog @@ -1,3 +1,15 @@ +libsdl2 (2.0.3) UNRELEASED; urgency=low + + * Updated SDL to version 2.0.3 + + -- Sam Lantinga Sun, 9 Mar 2014 10:35:54 -0800 + +libsdl2 (2.0.2) UNRELEASED; urgency=low + + * Updated SDL to version 2.0.2 + + -- Sam Lantinga Sun, 9 Feb 2014 2:55:59 -0800 + libsdl2 (2.0.1) UNRELEASED; urgency=low * Updated SDL to version 2.0.1 diff --git a/jni/SDL2-2.0.1/debian/compat b/jni/SDL2-2.0.3/debian/compat similarity index 100% rename from jni/SDL2-2.0.1/debian/compat rename to jni/SDL2-2.0.3/debian/compat diff --git a/jni/SDL2-2.0.1/debian/control b/jni/SDL2-2.0.3/debian/control similarity index 100% rename from jni/SDL2-2.0.1/debian/control rename to jni/SDL2-2.0.3/debian/control diff --git a/jni/SDL2-2.0.1/debian/copyright b/jni/SDL2-2.0.3/debian/copyright similarity index 98% rename from jni/SDL2-2.0.1/debian/copyright rename to jni/SDL2-2.0.3/debian/copyright index a53d19be..53254644 100644 --- a/jni/SDL2-2.0.1/debian/copyright +++ b/jni/SDL2-2.0.3/debian/copyright @@ -4,7 +4,7 @@ Upstream-Contact: Sam Lantinga Source: http://www.libsdl.org/ Files: * -Copyright: 1997-2012 Sam Lantinga +Copyright: 1997-2014 Sam Lantinga License: zlib/libpng Files: src/libm/* @@ -36,7 +36,7 @@ Copyright: 1998 Gareth McCaughan License: Gareth_McCaughan Files: src/test/SDL_test_md5.c -Copyright: 1997-2012 Sam Lantinga +Copyright: 1997-2014 Sam Lantinga 1990 RSA Data Security, Inc. License: zlib/libpng and RSA_Data_Security @@ -50,12 +50,12 @@ Copyright: 1994-2003 The XFree86 Project, Inc. License: MIT/X11 Files: test/testhaptic.c -Copyright: 1997-2011 Sam Lantinga +Copyright: 1997-2014 Sam Lantinga 2008 Edgar Simo Serra License: BSD_3_clause Files: test/testrumble.c -Copyright: 1997-2011 Sam Lantinga +Copyright: 1997-2014 Sam Lantinga 2011 Edgar Simo Serra License: BSD_3_clause @@ -173,7 +173,7 @@ License: BSD_3_clause (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Comment: - Copyright (C) 1997-2011 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga . This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/debian/docs b/jni/SDL2-2.0.3/debian/docs similarity index 100% rename from jni/SDL2-2.0.1/debian/docs rename to jni/SDL2-2.0.3/debian/docs diff --git a/jni/SDL2-2.0.1/debian/libsdl2-dev.install b/jni/SDL2-2.0.3/debian/libsdl2-dev.install similarity index 100% rename from jni/SDL2-2.0.1/debian/libsdl2-dev.install rename to jni/SDL2-2.0.3/debian/libsdl2-dev.install diff --git a/jni/SDL2-2.0.1/debian/libsdl2-dev.manpages b/jni/SDL2-2.0.3/debian/libsdl2-dev.manpages similarity index 100% rename from jni/SDL2-2.0.1/debian/libsdl2-dev.manpages rename to jni/SDL2-2.0.3/debian/libsdl2-dev.manpages diff --git a/jni/SDL2-2.0.1/debian/libsdl2.install b/jni/SDL2-2.0.3/debian/libsdl2.install similarity index 100% rename from jni/SDL2-2.0.1/debian/libsdl2.install rename to jni/SDL2-2.0.3/debian/libsdl2.install diff --git a/jni/SDL2-2.0.1/debian/rules b/jni/SDL2-2.0.3/debian/rules similarity index 100% rename from jni/SDL2-2.0.1/debian/rules rename to jni/SDL2-2.0.3/debian/rules diff --git a/jni/SDL2-2.0.1/debian/sdl2-config.1 b/jni/SDL2-2.0.3/debian/sdl2-config.1 similarity index 100% rename from jni/SDL2-2.0.1/debian/sdl2-config.1 rename to jni/SDL2-2.0.3/debian/sdl2-config.1 diff --git a/jni/SDL2-2.0.1/debian/source/format b/jni/SDL2-2.0.3/debian/source/format similarity index 100% rename from jni/SDL2-2.0.1/debian/source/format rename to jni/SDL2-2.0.3/debian/source/format diff --git a/jni/SDL2-2.0.1/debian/watch b/jni/SDL2-2.0.3/debian/watch similarity index 100% rename from jni/SDL2-2.0.1/debian/watch rename to jni/SDL2-2.0.3/debian/watch diff --git a/jni/SDL2-2.0.1/doxygen_warn.txt b/jni/SDL2-2.0.3/doxygen_warn.txt similarity index 100% rename from jni/SDL2-2.0.1/doxygen_warn.txt rename to jni/SDL2-2.0.3/doxygen_warn.txt diff --git a/jni/SDL2-2.0.1/include/SDL.h b/jni/SDL2-2.0.3/include/SDL.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL.h rename to jni/SDL2-2.0.3/include/SDL.h index c0c067ca..a9077095 100644 --- a/jni/SDL2-2.0.1/include/SDL.h +++ b/jni/SDL2-2.0.3/include/SDL.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_assert.h b/jni/SDL2-2.0.3/include/SDL_assert.h similarity index 83% rename from jni/SDL2-2.0.1/include/SDL_assert.h rename to jni/SDL2-2.0.3/include/SDL_assert.h index 43294340..42348f7d 100644 --- a/jni/SDL2-2.0.1/include/SDL_assert.h +++ b/jni/SDL2-2.0.3/include/SDL_assert.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -120,7 +120,16 @@ typedef struct SDL_assert_data /* Never call this directly. Use the SDL_assert* macros. */ extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *, const char *, - const char *, int); + const char *, int) +#if defined(__clang__) +#if __has_feature(attribute_analyzer_noreturn) +/* this tells Clang's static analysis that we're a custom assert function, + and that the analyzer should assume the condition was always true past this + SDL_assert test. */ + __attribute__((analyzer_noreturn)) +#endif +#endif +; /* the do {} while(0) avoids dangling else problems: if (x) SDL_assert(y); else blah(); @@ -202,6 +211,35 @@ extern DECLSPEC void SDLCALL SDL_SetAssertionHandler( SDL_AssertionHandler handler, void *userdata); +/** + * \brief Get the default assertion handler. + * + * This returns the function pointer that is called by default when an + * assertion is triggered. This is an internal function provided by SDL, + * that is used for assertions when SDL_SetAssertionHandler() hasn't been + * used to provide a different function. + * + * \return The default SDL_AssertionHandler that is called when an assert triggers. + */ +extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void); + +/** + * \brief Get the current assertion handler. + * + * This returns the function pointer that is called when an assertion is + * triggered. This is either the value last passed to + * SDL_SetAssertionHandler(), or if no application-specified function is + * set, is equivalent to calling SDL_GetDefaultAssertionHandler(). + * + * \param puserdata Pointer to a void*, which will store the "userdata" + * pointer that was passed to SDL_SetAssertionHandler(). + * This value will always be NULL for the default handler. + * If you don't care about this data, it is safe to pass + * a NULL pointer to this function to ignore it. + * \return The SDL_AssertionHandler that is called when an assert triggers. + */ +extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puserdata); + /** * \brief Get a list of all assertion failures. * diff --git a/jni/SDL2-2.0.1/include/SDL_atomic.h b/jni/SDL2-2.0.3/include/SDL_atomic.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_atomic.h rename to jni/SDL2-2.0.3/include/SDL_atomic.h index 43ba7543..bb3a9b65 100644 --- a/jni/SDL2-2.0.1/include/SDL_atomic.h +++ b/jni/SDL2-2.0.3/include/SDL_atomic.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_audio.h b/jni/SDL2-2.0.3/include/SDL_audio.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_audio.h rename to jni/SDL2-2.0.3/include/SDL_audio.h index b9da236f..4c987d51 100644 --- a/jni/SDL2-2.0.1/include/SDL_audio.h +++ b/jni/SDL2-2.0.3/include/SDL_audio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_bits.h b/jni/SDL2-2.0.3/include/SDL_bits.h similarity index 97% rename from jni/SDL2-2.0.1/include/SDL_bits.h rename to jni/SDL2-2.0.3/include/SDL_bits.h index b1ed20bf..341524fd 100644 --- a/jni/SDL2-2.0.1/include/SDL_bits.h +++ b/jni/SDL2-2.0.3/include/SDL_bits.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_blendmode.h b/jni/SDL2-2.0.3/include/SDL_blendmode.h similarity index 97% rename from jni/SDL2-2.0.1/include/SDL_blendmode.h rename to jni/SDL2-2.0.3/include/SDL_blendmode.h index 85aa4745..8c257be9 100644 --- a/jni/SDL2-2.0.1/include/SDL_blendmode.h +++ b/jni/SDL2-2.0.3/include/SDL_blendmode.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_clipboard.h b/jni/SDL2-2.0.3/include/SDL_clipboard.h similarity index 96% rename from jni/SDL2-2.0.1/include/SDL_clipboard.h rename to jni/SDL2-2.0.3/include/SDL_clipboard.h index 1f5742d1..74e2b32f 100644 --- a/jni/SDL2-2.0.1/include/SDL_clipboard.h +++ b/jni/SDL2-2.0.3/include/SDL_clipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_config.h b/jni/SDL2-2.0.3/include/SDL_config.h similarity index 93% rename from jni/SDL2-2.0.1/include/SDL_config.h rename to jni/SDL2-2.0.3/include/SDL_config.h index 4d74bab7..9a2e51c5 100644 --- a/jni/SDL2-2.0.1/include/SDL_config.h +++ b/jni/SDL2-2.0.3/include/SDL_config.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -33,6 +33,8 @@ #include "SDL_config_premake.h" #elif defined(__WIN32__) #include "SDL_config_windows.h" +#elif defined(__WINRT__) +#include "SDL_config_winrt.h" #elif defined(__MACOSX__) #include "SDL_config_macosx.h" #elif defined(__IPHONEOS__) diff --git a/jni/SDL2-2.0.1/include/SDL_config.h.cmake b/jni/SDL2-2.0.3/include/SDL_config.h.cmake similarity index 95% rename from jni/SDL2-2.0.1/include/SDL_config.h.cmake rename to jni/SDL2-2.0.3/include/SDL_config.h.cmake index e4f9f99f..b6fb53aa 100644 --- a/jni/SDL2-2.0.1/include/SDL_config.h.cmake +++ b/jni/SDL2-2.0.3/include/SDL_config.h.cmake @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -259,6 +259,19 @@ #cmakedefine SDL_VIDEO_DRIVER_DUMMY @SDL_VIDEO_DRIVER_DUMMY@ #cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@ #cmakedefine SDL_VIDEO_DRIVER_WAYLAND @SDL_VIDEO_DRIVER_WAYLAND@ + +#if 0 +/* !!! FIXME: in configure script version, missing here: */ +#undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON +#endif + +#cmakedefine SDL_VIDEO_DRIVER_MIR @SDL_VIDEO_DRIVER_MIR@ +#cmakedefine SDL_VIDEO_DRIVER_MIR_DYNAMIC @SDL_VIDEO_DRIVER_MIR_DYNAMIC@ +#cmakedefine SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON @SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON@ #cmakedefine SDL_VIDEO_DRIVER_X11 @SDL_VIDEO_DRIVER_X11@ #cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC @SDL_VIDEO_DRIVER_X11_DYNAMIC@ #cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT @SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT@ @@ -282,6 +295,7 @@ #cmakedefine SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM @SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM@ #cmakedefine SDL_VIDEO_RENDER_D3D @SDL_VIDEO_RENDER_D3D@ +#cmakedefine SDL_VIDEO_RENDER_D3D11 @SDL_VIDEO_RENDER_D3D11@ #cmakedefine SDL_VIDEO_RENDER_OGL @SDL_VIDEO_RENDER_OGL@ #cmakedefine SDL_VIDEO_RENDER_OGL_ES @SDL_VIDEO_RENDER_OGL_ES@ #cmakedefine SDL_VIDEO_RENDER_OGL_ES2 @SDL_VIDEO_RENDER_OGL_ES2@ diff --git a/jni/SDL2-2.0.1/include/SDL_config.h.in b/jni/SDL2-2.0.3/include/SDL_config.h.in similarity index 97% rename from jni/SDL2-2.0.1/include/SDL_config.h.in rename to jni/SDL2-2.0.3/include/SDL_config.h.in index eb7b4b96..689dcf83 100644 --- a/jni/SDL2-2.0.1/include/SDL_config.h.in +++ b/jni/SDL2-2.0.3/include/SDL_config.h.in @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -267,6 +267,9 @@ #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON +#undef SDL_VIDEO_DRIVER_MIR +#undef SDL_VIDEO_DRIVER_MIR_DYNAMIC +#undef SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON #undef SDL_VIDEO_DRIVER_X11 #undef SDL_VIDEO_DRIVER_RPI #undef SDL_VIDEO_DRIVER_X11_DYNAMIC @@ -291,6 +294,7 @@ #undef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM #undef SDL_VIDEO_RENDER_D3D +#undef SDL_VIDEO_RENDER_D3D11 #undef SDL_VIDEO_RENDER_OGL #undef SDL_VIDEO_RENDER_OGL_ES #undef SDL_VIDEO_RENDER_OGL_ES2 diff --git a/jni/SDL2-2.0.1/include/SDL_config_android.h b/jni/SDL2-2.0.3/include/SDL_config_android.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_config_android.h rename to jni/SDL2-2.0.3/include/SDL_config_android.h index d9bd9d1c..738dd94c 100644 --- a/jni/SDL2-2.0.1/include/SDL_config_android.h +++ b/jni/SDL2-2.0.3/include/SDL_config_android.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_config_iphoneos.h b/jni/SDL2-2.0.3/include/SDL_config_iphoneos.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_config_iphoneos.h rename to jni/SDL2-2.0.3/include/SDL_config_iphoneos.h index 348df13c..a0f55b6a 100644 --- a/jni/SDL2-2.0.1/include/SDL_config_iphoneos.h +++ b/jni/SDL2-2.0.3/include/SDL_config_iphoneos.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_config_macosx.h b/jni/SDL2-2.0.3/include/SDL_config_macosx.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_config_macosx.h rename to jni/SDL2-2.0.3/include/SDL_config_macosx.h index 1db36464..e627aef2 100644 --- a/jni/SDL2-2.0.1/include/SDL_config_macosx.h +++ b/jni/SDL2-2.0.3/include/SDL_config_macosx.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_config_minimal.h b/jni/SDL2-2.0.3/include/SDL_config_minimal.h similarity index 97% rename from jni/SDL2-2.0.1/include/SDL_config_minimal.h rename to jni/SDL2-2.0.3/include/SDL_config_minimal.h index 3248bdda..1bddafea 100644 --- a/jni/SDL2-2.0.1/include/SDL_config_minimal.h +++ b/jni/SDL2-2.0.3/include/SDL_config_minimal.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_config_pandora.h b/jni/SDL2-2.0.3/include/SDL_config_pandora.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_config_pandora.h rename to jni/SDL2-2.0.3/include/SDL_config_pandora.h index 4a95de78..ac8b0850 100644 --- a/jni/SDL2-2.0.1/include/SDL_config_pandora.h +++ b/jni/SDL2-2.0.3/include/SDL_config_pandora.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_config_psp.h b/jni/SDL2-2.0.3/include/SDL_config_psp.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_config_psp.h rename to jni/SDL2-2.0.3/include/SDL_config_psp.h index ca7cac60..2f9d023c 100644 --- a/jni/SDL2-2.0.1/include/SDL_config_psp.h +++ b/jni/SDL2-2.0.3/include/SDL_config_psp.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_config_windows.h b/jni/SDL2-2.0.3/include/SDL_config_windows.h similarity index 97% rename from jni/SDL2-2.0.1/include/SDL_config_windows.h rename to jni/SDL2-2.0.3/include/SDL_config_windows.h index 167e26a6..35eda465 100644 --- a/jni/SDL2-2.0.1/include/SDL_config_windows.h +++ b/jni/SDL2-2.0.3/include/SDL_config_windows.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -171,6 +171,9 @@ typedef unsigned int uintptr_t; #ifndef SDL_VIDEO_RENDER_D3D #define SDL_VIDEO_RENDER_D3D 1 #endif +#ifndef SDL_VIDEO_RENDER_D3D11 +#define SDL_VIDEO_RENDER_D3D11 0 +#endif /* Enable OpenGL support */ #ifndef SDL_VIDEO_OPENGL diff --git a/jni/SDL2-2.0.3/include/SDL_config_winrt.h b/jni/SDL2-2.0.3/include/SDL_config_winrt.h new file mode 100644 index 00000000..78b43ab6 --- /dev/null +++ b/jni/SDL2-2.0.3/include/SDL_config_winrt.h @@ -0,0 +1,190 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_config_windows_h +#define _SDL_config_windows_h + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) +#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) +#define HAVE_STDINT_H 1 +#elif defined(_MSC_VER) +typedef signed __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef signed __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef signed __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +#ifndef _UINTPTR_T_DEFINED +#ifdef _WIN64 +typedef unsigned __int64 uintptr_t; +#else +typedef unsigned int uintptr_t; +#endif +#define _UINTPTR_T_DEFINED +#endif +/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ +#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) +#define DWORD_PTR DWORD +#endif +#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) +#define LONG_PTR LONG +#endif +#else /* !__GNUC__ && !_MSC_VER */ +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +#ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef unsigned int size_t; +#endif +typedef unsigned int uintptr_t; +#endif /* __GNUC__ || _MSC_VER */ +#endif /* !_STDINT_H_ && !HAVE_STDINT_H */ + +#ifdef _WIN64 +# define SIZEOF_VOIDP 8 +#else +# define SIZEOF_VOIDP 4 +#endif + +/* Useful headers */ +#define HAVE_LIBC 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_FLOAT_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE__STRREV 1 +#define HAVE__STRUPR 1 +//#define HAVE__STRLWR 1 // TODO, WinRT: consider using _strlwr_s instead +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +//#define HAVE_ITOA 1 // TODO, WinRT: consider using _itoa_s instead +//#define HAVE__LTOA 1 // TODO, WinRT: consider using _ltoa_s instead +//#define HAVE__ULTOA 1 // TODO, WinRT: consider using _ultoa_s instead +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +//#define HAVE_STRTOLL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE__STRICMP 1 +#define HAVE__STRNICMP 1 +#define HAVE_VSNPRINTF 1 +//#define HAVE_SSCANF 1 // TODO, WinRT: consider using sscanf_s instead +#define HAVE_M_PI 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_CEIL 1 +#define HAVE__COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +//#define HAVE_SCALBN 1 +#define HAVE__SCALB 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE__FSEEKI64 1 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_XAUDIO2 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various input drivers */ +// TODO, WinRT: Get haptic support working +#define SDL_HAPTIC_DISABLED 1 + +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#define SDL_JOYSTICK_DISABLED 1 +#else +#define SDL_JOYSTICK_XINPUT 1 +#endif + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_WINDOWS 1 + +/* Enable various threading systems */ +#define SDL_THREAD_STDCPP 1 + +/* Enable various timer systems */ +#define SDL_TIMER_WINDOWS 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_WINRT 1 +#define SDL_VIDEO_DRIVER_DUMMY 1 + +/* Enable OpenGL ES 2.0 (via a modified ANGLE library) */ +#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP /* TODO, WinRT: try adding OpenGL ES 2 support for Windows Phone 8 */ +#define SDL_VIDEO_OPENGL_ES2 1 +#define SDL_VIDEO_OPENGL_EGL 1 +#endif + +/* Enable appropriate renderer(s) */ +#define SDL_VIDEO_RENDER_D3D11 1 + +#if SDL_VIDEO_OPENGL_ES2 +#define SDL_VIDEO_RENDER_OGL_ES2 1 +#endif + +/* Enable system power support */ +#define SDL_POWER_WINRT 1 + +/* Enable assembly routines (Win64 doesn't have inline asm) */ +#ifndef _WIN64 +#define SDL_ASSEMBLY_ROUTINES 1 +#endif + +#endif /* _SDL_config_windows_h */ diff --git a/jni/SDL2-2.0.1/include/SDL_config_wiz.h b/jni/SDL2-2.0.3/include/SDL_config_wiz.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_config_wiz.h rename to jni/SDL2-2.0.3/include/SDL_config_wiz.h index acfe4fcf..7efc20bc 100644 --- a/jni/SDL2-2.0.1/include/SDL_config_wiz.h +++ b/jni/SDL2-2.0.3/include/SDL_config_wiz.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_copying.h b/jni/SDL2-2.0.3/include/SDL_copying.h similarity index 93% rename from jni/SDL2-2.0.1/include/SDL_copying.h rename to jni/SDL2-2.0.3/include/SDL_copying.h index 3a8fb758..0964da84 100644 --- a/jni/SDL2-2.0.1/include/SDL_copying.h +++ b/jni/SDL2-2.0.3/include/SDL_copying.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_cpuinfo.h b/jni/SDL2-2.0.3/include/SDL_cpuinfo.h similarity index 93% rename from jni/SDL2-2.0.1/include/SDL_cpuinfo.h rename to jni/SDL2-2.0.3/include/SDL_cpuinfo.h index 6d72bbb8..1f6efd38 100644 --- a/jni/SDL2-2.0.1/include/SDL_cpuinfo.h +++ b/jni/SDL2-2.0.3/include/SDL_cpuinfo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -32,7 +32,7 @@ /* Need to do this here because intrin.h has C++ code in it */ /* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ -#if defined(_MSC_VER) && (_MSC_VER >= 1500) +#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64)) #include #ifndef _WIN64 #define __MMX__ @@ -134,6 +134,11 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void); */ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); +/** + * This function returns true if the CPU has AVX features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void); + /** * This function returns the amount of RAM configured in the system, in MB. */ diff --git a/jni/SDL2-2.0.1/include/SDL_egl.h b/jni/SDL2-2.0.3/include/SDL_egl.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_egl.h rename to jni/SDL2-2.0.3/include/SDL_egl.h index fc8fde4a..d312f042 100644 --- a/jni/SDL2-2.0.1/include/SDL_egl.h +++ b/jni/SDL2-2.0.3/include/SDL_egl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -391,9 +391,16 @@ typedef enum { #endif #include +#if __WINRT__ +#include +typedef IUnknown * EGLNativeWindowType; +typedef int EGLNativeDisplayType; +typedef HBITMAP EGLNativePixmapType; +#else typedef HDC EGLNativeDisplayType; typedef HBITMAP EGLNativePixmapType; typedef HWND EGLNativeWindowType; +#endif #elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ @@ -1386,4 +1393,4 @@ extern "C" { -#endif /* _MSC_VER */ \ No newline at end of file +#endif /* _MSC_VER */ diff --git a/jni/SDL2-2.0.1/include/SDL_endian.h b/jni/SDL2-2.0.3/include/SDL_endian.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_endian.h rename to jni/SDL2-2.0.3/include/SDL_endian.h index 3450316c..161c418d 100644 --- a/jni/SDL2-2.0.1/include/SDL_endian.h +++ b/jni/SDL2-2.0.3/include/SDL_endian.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_error.h b/jni/SDL2-2.0.3/include/SDL_error.h similarity index 97% rename from jni/SDL2-2.0.1/include/SDL_error.h rename to jni/SDL2-2.0.3/include/SDL_error.h index 2b8bb416..5776cfa2 100644 --- a/jni/SDL2-2.0.1/include/SDL_error.h +++ b/jni/SDL2-2.0.3/include/SDL_error.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_events.h b/jni/SDL2-2.0.3/include/SDL_events.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_events.h rename to jni/SDL2-2.0.3/include/SDL_events.h index 81ff4dd5..fc5a145e 100644 --- a/jni/SDL2-2.0.1/include/SDL_events.h +++ b/jni/SDL2-2.0.3/include/SDL_events.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -134,6 +134,9 @@ typedef enum /* Drag and drop events */ SDL_DROPFILE = 0x1000, /**< The system requests a file open */ + /* Render events */ + SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset */ + /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use, * and should be allocated with SDL_RegisterEvents() */ @@ -254,8 +257,8 @@ typedef struct SDL_MouseWheelEvent Uint32 timestamp; Uint32 windowID; /**< The window with mouse focus, if any */ Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ - Sint32 x; /**< The amount scrolled horizontally */ - Sint32 y; /**< The amount scrolled vertically */ + Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */ + Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */ } SDL_MouseWheelEvent; /** diff --git a/jni/SDL2-2.0.1/include/SDL_filesystem.h b/jni/SDL2-2.0.3/include/SDL_filesystem.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_filesystem.h rename to jni/SDL2-2.0.3/include/SDL_filesystem.h index ea8a1b56..de3e227d 100644 --- a/jni/SDL2-2.0.1/include/SDL_filesystem.h +++ b/jni/SDL2-2.0.3/include/SDL_filesystem.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_gamecontroller.h b/jni/SDL2-2.0.3/include/SDL_gamecontroller.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_gamecontroller.h rename to jni/SDL2-2.0.3/include/SDL_gamecontroller.h index 891f3563..b00ad713 100644 --- a/jni/SDL2-2.0.1/include/SDL_gamecontroller.h +++ b/jni/SDL2-2.0.3/include/SDL_gamecontroller.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_gesture.h b/jni/SDL2-2.0.3/include/SDL_gesture.h similarity index 97% rename from jni/SDL2-2.0.1/include/SDL_gesture.h rename to jni/SDL2-2.0.3/include/SDL_gesture.h index 015fe020..dbc16924 100644 --- a/jni/SDL2-2.0.1/include/SDL_gesture.h +++ b/jni/SDL2-2.0.3/include/SDL_gesture.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_haptic.h b/jni/SDL2-2.0.3/include/SDL_haptic.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_haptic.h rename to jni/SDL2-2.0.3/include/SDL_haptic.h index a029eb99..234975ab 100644 --- a/jni/SDL2-2.0.1/include/SDL_haptic.h +++ b/jni/SDL2-2.0.3/include/SDL_haptic.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_hints.h b/jni/SDL2-2.0.3/include/SDL_hints.h similarity index 71% rename from jni/SDL2-2.0.1/include/SDL_hints.h rename to jni/SDL2-2.0.3/include/SDL_hints.h index 9aad2e32..b98ce683 100644 --- a/jni/SDL2-2.0.1/include/SDL_hints.h +++ b/jni/SDL2-2.0.3/include/SDL_hints.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -105,6 +105,19 @@ extern "C" { */ #define SDL_HINT_RENDER_DIRECT3D_THREADSAFE "SDL_RENDER_DIRECT3D_THREADSAFE" +/** + * \brief A variable controlling whether to enable Direct3D 11+'s Debug Layer. + * + * This variable does not have any effect on the Direct3D 9 based renderer. + * + * This variable can be set to the following values: + * "0" - Disable Debug Layer use + * "1" - Enable Debug Layer use + * + * By default, SDL does not use Direct3D Debug Layer. + */ +#define SDL_HINT_RENDER_DIRECT3D11_DEBUG "SDL_HINT_RENDER_DIRECT3D11_DEBUG" + /** * \brief A variable controlling the scaling quality * @@ -128,6 +141,17 @@ extern "C" { */ #define SDL_HINT_RENDER_VSYNC "SDL_RENDER_VSYNC" +/** + * \brief A variable controlling whether the screensaver is enabled. + * + * This variable can be set to the following values: + * "0" - Disable screensaver + * "1" - Enable screensaver + * + * By default SDL will disable the screensaver. + */ +#define SDL_HINT_VIDEO_ALLOW_SCREENSAVER "SDL_VIDEO_ALLOW_SCREENSAVER" + /** * \brief A variable controlling whether the X11 VidMode extension should be used. * @@ -189,17 +213,6 @@ extern "C" { */ #define SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS" -/** - * \brief Set whether windows go fullscreen in their own spaces on Mac OS X - * - * This variable can be set to the following values: - * "0" - Fullscreen windows will use the classic fullscreen mode - * "1" - Fullscreen windows will use fullscreen spaces - * - * By default SDL will use the classic fullscreen mode. - */ -#define SDL_HINT_VIDEO_FULLSCREEN_SPACES "SDL_VIDEO_FULLSCREEN_SPACES" - /** * \brief A variable controlling whether the idle timer is disabled on iOS. * @@ -233,15 +246,15 @@ extern "C" { * "0" - List only real joysticks and accept input from them * "1" - List real joysticks along with the accelerometer as if it were a 3 axis joystick (the default). */ -#define SDL_HINT_ACCEL_AS_JOY "SDL_ACCEL_AS_JOY" +#define SDL_HINT_ACCELEROMETER_AS_JOYSTICK "SDL_ACCELEROMETER_AS_JOYSTICK" /** * \brief A variable that lets you disable the detection and use of Xinput gamepad devices * * The variable can be set to the following values: - * "0" - Disable XInput timer (only uses direct input) - * "1" - Enable XInput timer (the default) + * "0" - Disable XInput detection (only uses direct input) + * "1" - Enable XInput detection (the default) */ #define SDL_HINT_XINPUT_ENABLED "SDL_XINPUT_ENABLED" @@ -264,7 +277,7 @@ extern "C" { * "0" - Disable joystick & gamecontroller input events when the * application is in the background. * "1" - Enable joystick & gamecontroller input events when the - * application is in the backgroumd. + * application is in the background. * * The default value is "0". This hint may be set at any time. */ @@ -318,7 +331,7 @@ extern "C" { * SDL has EGL and OpenGL ES2 support on Windows via the ANGLE project. It * can use two different sets of binaries, those compiled by the user from source * or those provided by the Chrome browser. In the later case, these binaries require -* that SDL loads +* that SDL loads a DLL providing the shader compiler. * * This variable can be set to the following values: * "d3dcompiler_46.dll" - default, best for Vista or later. @@ -328,6 +341,101 @@ extern "C" { */ #define SDL_HINT_VIDEO_WIN_D3DCOMPILER "SDL_VIDEO_WIN_D3DCOMPILER" +/** +* \brief A variable that is the address of another SDL_Window* (as a hex string formatted with "%p"). +* +* If this hint is set before SDL_CreateWindowFrom() and the SDL_Window* it is set to has +* SDL_WINDOW_OPENGL set (and running on WGL only, currently), then two things will occur on the newly +* created SDL_Window: +* +* 1. Its pixel format will be set to the same pixel format as this SDL_Window. This is +* needed for example when sharing an OpenGL context across multiple windows. +* +* 2. The flag SDL_WINDOW_OPENGL will be set on the new window so it can be used for +* OpenGL rendering. +* +* This variable can be set to the following values: +* The address (as a string "%p") of the SDL_Window* that new windows created with SDL_CreateWindowFrom() should +* share a pixel format with. +*/ +#define SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT" + +/* + * \brief A URL to a WinRT app's privacy policy + * + * All network-enabled WinRT apps must make a privacy policy available to its + * users. On Windows 8, 8.1, and RT, Microsoft mandates that this policy be + * be available in the Windows Settings charm, as accessed from within the app. + * SDL provides code to add a URL-based link there, which can point to the app's + * privacy policy. + * + * To setup a URL to an app's privacy policy, set SDL_HINT_WINRT_PRIVACY_POLICY_URL + * before calling any SDL_Init functions. The contents of the hint should + * be a valid URL. For example, "http://www.example.com". + * + * The default value is "", which will prevent SDL from adding a privacy policy + * link to the Settings charm. This hint should only be set during app init. + * + * The label text of an app's "Privacy Policy" link may be customized via another + * hint, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL. + * + * Please note that on Windows Phone, Microsoft does not provide standard UI + * for displaying a privacy policy link, and as such, SDL_HINT_WINRT_PRIVACY_POLICY_URL + * will not get used on that platform. Network-enabled phone apps should display + * their privacy policy through some other, in-app means. + */ +#define SDL_HINT_WINRT_PRIVACY_POLICY_URL "SDL_HINT_WINRT_PRIVACY_POLICY_URL" + +/** \brief Label text for a WinRT app's privacy policy link + * + * Network-enabled WinRT apps must include a privacy policy. On Windows 8, 8.1, and RT, + * Microsoft mandates that this policy be available via the Windows Settings charm. + * SDL provides code to add a link there, with it's label text being set via the + * optional hint, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL. + * + * Please note that a privacy policy's contents are not set via this hint. A separate + * hint, SDL_HINT_WINRT_PRIVACY_POLICY_URL, is used to link to the actual text of the + * policy. + * + * The contents of this hint should be encoded as a UTF8 string. + * + * The default value is "Privacy Policy". This hint should only be set during app + * initialization, preferably before any calls to SDL_Init. + * + * For additional information on linking to a privacy policy, see the documentation for + * SDL_HINT_WINRT_PRIVACY_POLICY_URL. + */ +#define SDL_HINT_WINRT_PRIVACY_POLICY_LABEL "SDL_HINT_WINRT_PRIVACY_POLICY_LABEL" + +/** \brief If set to 1, back button press events on Windows Phone 8+ will be marked as handled. + * + * TODO, WinRT: document SDL_HINT_WINRT_HANDLE_BACK_BUTTON need and use + * For now, more details on why this is needed can be found at the + * beginning of the following web page: + * http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj247550(v=vs.105).aspx + */ +#define SDL_HINT_WINRT_HANDLE_BACK_BUTTON "SDL_HINT_WINRT_HANDLE_BACK_BUTTON" + +/** + * \brief A variable that dictates policy for fullscreen Spaces on Mac OS X. + * + * This hint only applies to Mac OS X. + * + * The variable can be set to the following values: + * "0" - Disable Spaces support (FULLSCREEN_DESKTOP won't use them and + * SDL_WINDOW_RESIZABLE windows won't offer the "fullscreen" + * button on their titlebars). + * "1" - Enable Spaces support (FULLSCREEN_DESKTOP will use them and + * SDL_WINDOW_RESIZABLE windows will offer the "fullscreen" + * button on their titlebars. + * + * The default value is "1". Spaces are disabled regardless of this hint if + * the OS isn't at least Mac OS X Lion (10.7). This hint must be set before + * any windows are created. + */ +#define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES "SDL_VIDEO_MAC_FULLSCREEN_SPACES" + + /** * \brief An enumeration of hint priorities */ diff --git a/jni/SDL2-2.0.1/include/SDL_joystick.h b/jni/SDL2-2.0.3/include/SDL_joystick.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_joystick.h rename to jni/SDL2-2.0.3/include/SDL_joystick.h index a2843bae..b0b1c667 100644 --- a/jni/SDL2-2.0.1/include/SDL_joystick.h +++ b/jni/SDL2-2.0.3/include/SDL_joystick.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_keyboard.h b/jni/SDL2-2.0.3/include/SDL_keyboard.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_keyboard.h rename to jni/SDL2-2.0.3/include/SDL_keyboard.h index e10f9fd1..586a26cf 100644 --- a/jni/SDL2-2.0.1/include/SDL_keyboard.h +++ b/jni/SDL2-2.0.3/include/SDL_keyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_keycode.h b/jni/SDL2-2.0.3/include/SDL_keycode.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_keycode.h rename to jni/SDL2-2.0.3/include/SDL_keycode.h index de584e12..d5f5dd0a 100644 --- a/jni/SDL2-2.0.1/include/SDL_keycode.h +++ b/jni/SDL2-2.0.3/include/SDL_keycode.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_loadso.h b/jni/SDL2-2.0.3/include/SDL_loadso.h similarity index 97% rename from jni/SDL2-2.0.1/include/SDL_loadso.h rename to jni/SDL2-2.0.3/include/SDL_loadso.h index 790d0a72..0359eae1 100644 --- a/jni/SDL2-2.0.1/include/SDL_loadso.h +++ b/jni/SDL2-2.0.3/include/SDL_loadso.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_log.h b/jni/SDL2-2.0.3/include/SDL_log.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_log.h rename to jni/SDL2-2.0.3/include/SDL_log.h index 79ae4cde..5c2bca59 100644 --- a/jni/SDL2-2.0.1/include/SDL_log.h +++ b/jni/SDL2-2.0.3/include/SDL_log.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_main.h b/jni/SDL2-2.0.3/include/SDL_main.h similarity index 71% rename from jni/SDL2-2.0.1/include/SDL_main.h rename to jni/SDL2-2.0.3/include/SDL_main.h index da80a780..2e8fae95 100644 --- a/jni/SDL2-2.0.1/include/SDL_main.h +++ b/jni/SDL2-2.0.3/include/SDL_main.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -39,6 +39,18 @@ */ #define SDL_MAIN_AVAILABLE +#elif defined(__WINRT__) +/* On WinRT, SDL provides a main function that initializes CoreApplication, + creating an instance of IFrameworkView in the process. + + Please note that #include'ing SDL_main.h is not enough to get a main() + function working. In non-XAML apps, the file, + src/main/winrt/SDL_WinRT_main_NonXAML.cpp, or a copy of it, must be compiled + into the app itself. In XAML apps, the function, SDL_WinRTRunApp must be + called, with a pointer to the Direct3D-hosted XAML control passed in. +*/ +#define SDL_MAIN_NEEDED + #elif defined(__IPHONEOS__) /* On iOS SDL provides a main function that creates an application delegate and starts the iOS application run loop. @@ -115,6 +127,24 @@ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); #endif /* __WIN32__ */ +#ifdef __WINRT__ + +/** + * \brief Initializes and launches an SDL/WinRT application. + * + * \param mainFunction The SDL app's C-style main(). + * \param xamlBackgroundPanel An optional, XAML-based, background panel. + * For Non-XAML apps, this value must be set to NULL. For XAML apps, + * pass in a pointer to a SwapChainBackgroundPanel, casted to an + * IInspectable (via reinterpret_cast). + * \ret 0 on success, -1 on failure. On failure, use SDL_GetError to retrieve more + * information on the failure. + */ +extern DECLSPEC int SDLCALL SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * xamlBackgroundPanel); + +#endif /* __WINRT__ */ + + #ifdef __cplusplus } #endif diff --git a/jni/SDL2-2.0.1/include/SDL_messagebox.h b/jni/SDL2-2.0.3/include/SDL_messagebox.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_messagebox.h rename to jni/SDL2-2.0.3/include/SDL_messagebox.h index cb1a1ccf..6004da0f 100644 --- a/jni/SDL2-2.0.1/include/SDL_messagebox.h +++ b/jni/SDL2-2.0.3/include/SDL_messagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_mouse.h b/jni/SDL2-2.0.3/include/SDL_mouse.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_mouse.h rename to jni/SDL2-2.0.3/include/SDL_mouse.h index 36c29e90..ebfd18fa 100644 --- a/jni/SDL2-2.0.1/include/SDL_mouse.h +++ b/jni/SDL2-2.0.3/include/SDL_mouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_mutex.h b/jni/SDL2-2.0.3/include/SDL_mutex.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_mutex.h rename to jni/SDL2-2.0.3/include/SDL_mutex.h index 2b5df0ec..3e8b4dbe 100644 --- a/jni/SDL2-2.0.1/include/SDL_mutex.h +++ b/jni/SDL2-2.0.3/include/SDL_mutex.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.3/include/SDL_name.h b/jni/SDL2-2.0.3/include/SDL_name.h new file mode 100644 index 00000000..719666ff --- /dev/null +++ b/jni/SDL2-2.0.3/include/SDL_name.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDLname_h_ +#define _SDLname_h_ + +#if defined(__STDC__) || defined(__cplusplus) +#define NeedFunctionPrototypes 1 +#endif + +#define SDL_NAME(X) SDL_##X + +#endif /* _SDLname_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.1/include/SDL_opengl.h b/jni/SDL2-2.0.3/include/SDL_opengl.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_opengl.h rename to jni/SDL2-2.0.3/include/SDL_opengl.h index 2f120aa9..b48ea7ab 100644 --- a/jni/SDL2-2.0.1/include/SDL_opengl.h +++ b/jni/SDL2-2.0.3/include/SDL_opengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_opengles.h b/jni/SDL2-2.0.3/include/SDL_opengles.h similarity index 95% rename from jni/SDL2-2.0.1/include/SDL_opengles.h rename to jni/SDL2-2.0.3/include/SDL_opengles.h index 00e60f5c..d88e1573 100644 --- a/jni/SDL2-2.0.1/include/SDL_opengles.h +++ b/jni/SDL2-2.0.3/include/SDL_opengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_opengles2.h b/jni/SDL2-2.0.3/include/SDL_opengles2.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_opengles2.h rename to jni/SDL2-2.0.3/include/SDL_opengles2.h index f51cfc23..2c054792 100644 --- a/jni/SDL2-2.0.1/include/SDL_opengles2.h +++ b/jni/SDL2-2.0.3/include/SDL_opengles2.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -2787,4 +2787,4 @@ typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask); #ifndef APIENTRY #define APIENTRY GL_APIENTRY -#endif \ No newline at end of file +#endif diff --git a/jni/SDL2-2.0.1/include/SDL_pixels.h b/jni/SDL2-2.0.3/include/SDL_pixels.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_pixels.h rename to jni/SDL2-2.0.3/include/SDL_pixels.h index 99fcd9aa..3131af7b 100644 --- a/jni/SDL2-2.0.1/include/SDL_pixels.h +++ b/jni/SDL2-2.0.3/include/SDL_pixels.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -28,6 +28,8 @@ #ifndef _SDL_pixels_h #define _SDL_pixels_h +#include "SDL_stdinc.h" + #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus diff --git a/jni/SDL2-2.0.1/include/SDL_platform.h b/jni/SDL2-2.0.3/include/SDL_platform.h similarity index 83% rename from jni/SDL2-2.0.1/include/SDL_platform.h rename to jni/SDL2-2.0.3/include/SDL_platform.h index 7e56c45b..c43f4b54 100644 --- a/jni/SDL2-2.0.1/include/SDL_platform.h +++ b/jni/SDL2-2.0.3/include/SDL_platform.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -60,7 +60,7 @@ #undef __LINUX__ #define __LINUX__ 1 #endif -#if defined(ANDROID) +#if defined(ANDROID) || defined(__ANDROID__) #undef __ANDROID__ #undef __LINUX__ /* do we need to do this? */ #define __ANDROID__ 1 @@ -113,10 +113,26 @@ #undef __SOLARIS__ #define __SOLARIS__ 1 #endif + #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) +/* Try to find out if we're compiling for WinRT or non-WinRT */ +/* If _USING_V110_SDK71_ is defined it means we are using the v110_xp or v120_xp toolset. */ +#if defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER >= 1700) && !_USING_V110_SDK71_) /* _MSC_VER==1700 for MSVC 2012 */ +#include +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) #undef __WINDOWS__ #define __WINDOWS__ 1 +/* See if we're compiling for WinRT: */ +#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) +#undef __WINRT__ +#define __WINRT__ 1 #endif +#else +#undef __WINDOWS__ +#define __WINDOWS__ 1 +#endif /* _MSC_VER < 1700 */ +#endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */ + #if defined(__WINDOWS__) #undef __WIN32__ #define __WIN32__ 1 diff --git a/jni/SDL2-2.0.1/include/SDL_power.h b/jni/SDL2-2.0.3/include/SDL_power.h similarity index 97% rename from jni/SDL2-2.0.1/include/SDL_power.h rename to jni/SDL2-2.0.3/include/SDL_power.h index 4f70c5bb..cf71c982 100644 --- a/jni/SDL2-2.0.1/include/SDL_power.h +++ b/jni/SDL2-2.0.3/include/SDL_power.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_quit.h b/jni/SDL2-2.0.3/include/SDL_quit.h similarity index 97% rename from jni/SDL2-2.0.1/include/SDL_quit.h rename to jni/SDL2-2.0.3/include/SDL_quit.h index 485e42db..8a786445 100644 --- a/jni/SDL2-2.0.1/include/SDL_quit.h +++ b/jni/SDL2-2.0.3/include/SDL_quit.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_rect.h b/jni/SDL2-2.0.3/include/SDL_rect.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_rect.h rename to jni/SDL2-2.0.3/include/SDL_rect.h index 7132e1b4..0a95a334 100644 --- a/jni/SDL2-2.0.1/include/SDL_rect.h +++ b/jni/SDL2-2.0.3/include/SDL_rect.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_render.h b/jni/SDL2-2.0.3/include/SDL_render.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_render.h rename to jni/SDL2-2.0.3/include/SDL_render.h index 94bf1e6a..77f706a9 100644 --- a/jni/SDL2-2.0.1/include/SDL_render.h +++ b/jni/SDL2-2.0.3/include/SDL_render.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_revision.h b/jni/SDL2-2.0.3/include/SDL_revision.h similarity index 100% rename from jni/SDL2-2.0.1/include/SDL_revision.h rename to jni/SDL2-2.0.3/include/SDL_revision.h diff --git a/jni/SDL2-2.0.1/include/SDL_rwops.h b/jni/SDL2-2.0.3/include/SDL_rwops.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_rwops.h rename to jni/SDL2-2.0.3/include/SDL_rwops.h index d2574423..4bdd7876 100644 --- a/jni/SDL2-2.0.1/include/SDL_rwops.h +++ b/jni/SDL2-2.0.3/include/SDL_rwops.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_scancode.h b/jni/SDL2-2.0.3/include/SDL_scancode.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_scancode.h rename to jni/SDL2-2.0.3/include/SDL_scancode.h index 00b47a3b..4b3be28f 100644 --- a/jni/SDL2-2.0.1/include/SDL_scancode.h +++ b/jni/SDL2-2.0.3/include/SDL_scancode.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_shape.h b/jni/SDL2-2.0.3/include/SDL_shape.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_shape.h rename to jni/SDL2-2.0.3/include/SDL_shape.h index 63f850c9..53029306 100644 --- a/jni/SDL2-2.0.1/include/SDL_shape.h +++ b/jni/SDL2-2.0.3/include/SDL_shape.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_stdinc.h b/jni/SDL2-2.0.3/include/SDL_stdinc.h similarity index 97% rename from jni/SDL2-2.0.1/include/SDL_stdinc.h rename to jni/SDL2-2.0.3/include/SDL_stdinc.h index 2a217149..31b343d3 100644 --- a/jni/SDL2-2.0.1/include/SDL_stdinc.h +++ b/jni/SDL2-2.0.3/include/SDL_stdinc.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -71,8 +71,18 @@ # include #endif #ifdef HAVE_MATH_H +# if defined(__WINRT__) +/* Defining _USE_MATH_DEFINES is required to get M_PI to be defined on + WinRT. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx + for more information. +*/ +# define _USE_MATH_DEFINES +# endif # include #endif +#ifdef HAVE_FLOAT_H +# include +#endif #if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) # include #endif diff --git a/jni/SDL2-2.0.1/include/SDL_surface.h b/jni/SDL2-2.0.3/include/SDL_surface.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_surface.h rename to jni/SDL2-2.0.3/include/SDL_surface.h index e18153a6..aa8d8217 100644 --- a/jni/SDL2-2.0.1/include/SDL_surface.h +++ b/jni/SDL2-2.0.3/include/SDL_surface.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_system.h b/jni/SDL2-2.0.3/include/SDL_system.h similarity index 59% rename from jni/SDL2-2.0.1/include/SDL_system.h rename to jni/SDL2-2.0.3/include/SDL_system.h index 9af2a4c2..fd929f7f 100644 --- a/jni/SDL2-2.0.1/include/SDL_system.h +++ b/jni/SDL2-2.0.3/include/SDL_system.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -55,6 +55,12 @@ extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex ); typedef struct IDirect3DDevice9 IDirect3DDevice9; extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3D9Device(SDL_Renderer * renderer); +/* Returns the DXGI Adapter and Output indices for the specified display index. + These can be passed to EnumAdapters and EnumOutputs respectively to get the objects + required to create a DX10 or DX11 device and swap chain. + */ +extern DECLSPEC void SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex ); + #endif /* __WIN32__ */ @@ -110,6 +116,70 @@ extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath(); #endif /* __ANDROID__ */ +/* Platform specific functions for WinRT */ +#if defined(__WINRT__) && __WINRT__ + +/** + * \brief WinRT / Windows Phone path types + */ +typedef enum +{ + /** \brief The installed app's root directory. + Files here are likely to be read-only. */ + SDL_WINRT_PATH_INSTALLED_LOCATION, + + /** \brief The app's local data store. Files may be written here */ + SDL_WINRT_PATH_LOCAL_FOLDER, + + /** \brief The app's roaming data store. Unsupported on Windows Phone. + Files written here may be copied to other machines via a network + connection. + */ + SDL_WINRT_PATH_ROAMING_FOLDER, + + /** \brief The app's temporary data store. Unsupported on Windows Phone. + Files written here may be deleted at any time. */ + SDL_WINRT_PATH_TEMP_FOLDER +} SDL_WinRT_Path; + + +/** + * \brief Retrieves a WinRT defined path on the local file system + * + * \note Documentation on most app-specific path types on WinRT + * can be found on MSDN, at the URL: + * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx + * + * \param pathType The type of path to retrieve. + * \ret A UCS-2 string (16-bit, wide-char) containing the path, or NULL + * if the path is not available for any reason. Not all paths are + * available on all versions of Windows. This is especially true on + * Windows Phone. Check the documentation for the given + * SDL_WinRT_Path for more information on which path types are + * supported where. + */ +extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType); + +/** + * \brief Retrieves a WinRT defined path on the local file system + * + * \note Documentation on most app-specific path types on WinRT + * can be found on MSDN, at the URL: + * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx + * + * \param pathType The type of path to retrieve. + * \ret A UTF-8 string (8-bit, multi-byte) containing the path, or NULL + * if the path is not available for any reason. Not all paths are + * available on all versions of Windows. This is especially true on + * Windows Phone. Check the documentation for the given + * SDL_WinRT_Path for more information on which path types are + * supported where. + */ +extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType); + +#endif /* __WINRT__ */ + + /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/jni/SDL2-2.0.1/include/SDL_syswm.h b/jni/SDL2-2.0.3/include/SDL_syswm.h similarity index 90% rename from jni/SDL2-2.0.1/include/SDL_syswm.h rename to jni/SDL2-2.0.3/include/SDL_syswm.h index c43a78d2..a3fe7386 100644 --- a/jni/SDL2-2.0.1/include/SDL_syswm.h +++ b/jni/SDL2-2.0.3/include/SDL_syswm.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -56,6 +56,10 @@ struct SDL_SysWMinfo; #include #endif +#if defined(SDL_VIDEO_DRIVER_WINRT) +#include +#endif + /* This is the structure for custom window manager events */ #if defined(SDL_VIDEO_DRIVER_X11) #if defined(__APPLE__) && defined(__MACH__) @@ -90,9 +94,15 @@ typedef struct _NSWindow NSWindow; #include #else typedef struct _UIWindow UIWindow; +typedef struct _UIViewController UIViewController; #endif #endif +#if defined(SDL_VIDEO_DRIVER_MIR) +#include +#endif + + /** * These are the various supported windowing subsystems */ @@ -101,10 +111,12 @@ typedef enum SDL_SYSWM_UNKNOWN, SDL_SYSWM_WINDOWS, SDL_SYSWM_X11, - SDL_SYSWM_WAYLAND, SDL_SYSWM_DIRECTFB, SDL_SYSWM_COCOA, SDL_SYSWM_UIKIT, + SDL_SYSWM_WAYLAND, + SDL_SYSWM_MIR, + SDL_SYSWM_WINRT, } SDL_SYSWM_TYPE; /** @@ -169,6 +181,12 @@ struct SDL_SysWMinfo HWND window; /**< The window handle */ } win; #endif +#if defined(SDL_VIDEO_DRIVER_WINRT) + struct + { + IInspectable * window; /**< The WinRT CoreWindow */ + } winrt; +#endif #if defined(SDL_VIDEO_DRIVER_X11) struct { @@ -176,14 +194,6 @@ struct SDL_SysWMinfo Window window; /**< The X11 window */ } x11; #endif -#if defined(SDL_VIDEO_DRIVER_WAYLAND) - struct - { - struct wl_display *display; /**< Wayland display */ - struct wl_surface *surface; /**< Wayland surface */ - struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */ - } wl; -#endif #if defined(SDL_VIDEO_DRIVER_DIRECTFB) struct { @@ -204,6 +214,22 @@ struct SDL_SysWMinfo UIWindow *window; /* The UIKit window */ } uikit; #endif +#if defined(SDL_VIDEO_DRIVER_WAYLAND) + struct + { + struct wl_display *display; /**< Wayland display */ + struct wl_surface *surface; /**< Wayland surface */ + struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */ + } wl; +#endif +#if defined(SDL_VIDEO_DRIVER_MIR) + struct + { + MirConnection *connection; /**< Mir display server connection */ + MirSurface *surface; /**< Mir surface */ + } mir; +#endif + /* Can't have an empty union */ int dummy; } info; diff --git a/jni/SDL2-2.0.1/include/SDL_test.h b/jni/SDL2-2.0.3/include/SDL_test.h similarity index 96% rename from jni/SDL2-2.0.1/include/SDL_test.h rename to jni/SDL2-2.0.3/include/SDL_test.h index 7e0de089..ae649a42 100644 --- a/jni/SDL2-2.0.1/include/SDL_test.h +++ b/jni/SDL2-2.0.3/include/SDL_test.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_test_assert.h b/jni/SDL2-2.0.3/include/SDL_test_assert.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_test_assert.h rename to jni/SDL2-2.0.3/include/SDL_test_assert.h index beba16f5..79c84d60 100644 --- a/jni/SDL2-2.0.1/include/SDL_test_assert.h +++ b/jni/SDL2-2.0.3/include/SDL_test_assert.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_test_common.h b/jni/SDL2-2.0.3/include/SDL_test_common.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_test_common.h rename to jni/SDL2-2.0.3/include/SDL_test_common.h index 5f67aa65..45c9edaf 100644 --- a/jni/SDL2-2.0.1/include/SDL_test_common.h +++ b/jni/SDL2-2.0.3/include/SDL_test_common.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_test_compare.h b/jni/SDL2-2.0.3/include/SDL_test_compare.h similarity index 97% rename from jni/SDL2-2.0.1/include/SDL_test_compare.h rename to jni/SDL2-2.0.3/include/SDL_test_compare.h index 98ca8ce8..f1353a8d 100644 --- a/jni/SDL2-2.0.1/include/SDL_test_compare.h +++ b/jni/SDL2-2.0.3/include/SDL_test_compare.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_test_crc32.h b/jni/SDL2-2.0.3/include/SDL_test_crc32.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_test_crc32.h rename to jni/SDL2-2.0.3/include/SDL_test_crc32.h index f0a84a48..a180fe3b 100644 --- a/jni/SDL2-2.0.1/include/SDL_test_crc32.h +++ b/jni/SDL2-2.0.3/include/SDL_test_crc32.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_test_font.h b/jni/SDL2-2.0.3/include/SDL_test_font.h similarity index 74% rename from jni/SDL2-2.0.1/include/SDL_test_font.h rename to jni/SDL2-2.0.3/include/SDL_test_font.h index aa9286b4..8d51d4a9 100644 --- a/jni/SDL2-2.0.1/include/SDL_test_font.h +++ b/jni/SDL2-2.0.3/include/SDL_test_font.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -38,6 +38,20 @@ extern "C" { /* Function prototypes */ +#define FONT_CHARACTER_SIZE 8 + +/** + * \brief Draw a string in the currently set font. + * + * \param renderer The renderer to draw on. + * \param x The X coordinate of the upper left corner of the character. + * \param y The Y coordinate of the upper left corner of the character. + * \param c The character to draw. + * + * \returns Returns 0 on success, -1 on failure. + */ +int SDLTest_DrawCharacter( SDL_Renderer *renderer, int x, int y, char c ); + /** * \brief Draw a string in the currently set font. * @@ -48,7 +62,7 @@ extern "C" { * * \returns Returns 0 on success, -1 on failure. */ -int SDLTest_DrawString(SDL_Renderer * renderer, int x, int y, const char *s); +int SDLTest_DrawString( SDL_Renderer * renderer, int x, int y, const char *s ); /* Ends C function definitions when using C++ */ diff --git a/jni/SDL2-2.0.1/include/SDL_test_fuzzer.h b/jni/SDL2-2.0.3/include/SDL_test_fuzzer.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_test_fuzzer.h rename to jni/SDL2-2.0.3/include/SDL_test_fuzzer.h index a528ddc5..64018039 100644 --- a/jni/SDL2-2.0.1/include/SDL_test_fuzzer.h +++ b/jni/SDL2-2.0.3/include/SDL_test_fuzzer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_test_harness.h b/jni/SDL2-2.0.3/include/SDL_test_harness.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_test_harness.h rename to jni/SDL2-2.0.3/include/SDL_test_harness.h index 935038e9..2c1e2ade 100644 --- a/jni/SDL2-2.0.1/include/SDL_test_harness.h +++ b/jni/SDL2-2.0.3/include/SDL_test_harness.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_test_images.h b/jni/SDL2-2.0.3/include/SDL_test_images.h similarity index 97% rename from jni/SDL2-2.0.1/include/SDL_test_images.h rename to jni/SDL2-2.0.3/include/SDL_test_images.h index 21cf39ff..05627996 100644 --- a/jni/SDL2-2.0.1/include/SDL_test_images.h +++ b/jni/SDL2-2.0.3/include/SDL_test_images.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_test_log.h b/jni/SDL2-2.0.3/include/SDL_test_log.h similarity index 96% rename from jni/SDL2-2.0.1/include/SDL_test_log.h rename to jni/SDL2-2.0.3/include/SDL_test_log.h index a581d2e7..76ce1058 100644 --- a/jni/SDL2-2.0.1/include/SDL_test_log.h +++ b/jni/SDL2-2.0.3/include/SDL_test_log.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_test_md5.h b/jni/SDL2-2.0.3/include/SDL_test_md5.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_test_md5.h rename to jni/SDL2-2.0.3/include/SDL_test_md5.h index b0d4b7b0..029e164b 100644 --- a/jni/SDL2-2.0.1/include/SDL_test_md5.h +++ b/jni/SDL2-2.0.3/include/SDL_test_md5.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_test_random.h b/jni/SDL2-2.0.3/include/SDL_test_random.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_test_random.h rename to jni/SDL2-2.0.3/include/SDL_test_random.h index ce6192c2..6c5660d8 100644 --- a/jni/SDL2-2.0.1/include/SDL_test_random.h +++ b/jni/SDL2-2.0.3/include/SDL_test_random.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_thread.h b/jni/SDL2-2.0.3/include/SDL_thread.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_thread.h rename to jni/SDL2-2.0.3/include/SDL_thread.h index 8f50f6e5..4e48cc34 100644 --- a/jni/SDL2-2.0.1/include/SDL_thread.h +++ b/jni/SDL2-2.0.3/include/SDL_thread.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_timer.h b/jni/SDL2-2.0.3/include/SDL_timer.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_timer.h rename to jni/SDL2-2.0.3/include/SDL_timer.h index 28ab415b..a48e0466 100644 --- a/jni/SDL2-2.0.1/include/SDL_timer.h +++ b/jni/SDL2-2.0.3/include/SDL_timer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_touch.h b/jni/SDL2-2.0.3/include/SDL_touch.h similarity index 97% rename from jni/SDL2-2.0.1/include/SDL_touch.h rename to jni/SDL2-2.0.3/include/SDL_touch.h index 9e6d7c65..017deb28 100644 --- a/jni/SDL2-2.0.1/include/SDL_touch.h +++ b/jni/SDL2-2.0.3/include/SDL_touch.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_types.h b/jni/SDL2-2.0.3/include/SDL_types.h similarity index 94% rename from jni/SDL2-2.0.1/include/SDL_types.h rename to jni/SDL2-2.0.3/include/SDL_types.h index bb485cdb..cd3ba33c 100644 --- a/jni/SDL2-2.0.1/include/SDL_types.h +++ b/jni/SDL2-2.0.3/include/SDL_types.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/SDL_version.h b/jni/SDL2-2.0.3/include/SDL_version.h similarity index 98% rename from jni/SDL2-2.0.1/include/SDL_version.h rename to jni/SDL2-2.0.3/include/SDL_version.h index dc52c85c..d02898bb 100644 --- a/jni/SDL2-2.0.1/include/SDL_version.h +++ b/jni/SDL2-2.0.3/include/SDL_version.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -59,7 +59,7 @@ typedef struct SDL_version */ #define SDL_MAJOR_VERSION 2 #define SDL_MINOR_VERSION 0 -#define SDL_PATCHLEVEL 1 +#define SDL_PATCHLEVEL 3 /** * \brief Macro to determine SDL version program was compiled against. diff --git a/jni/SDL2-2.0.1/include/SDL_video.h b/jni/SDL2-2.0.3/include/SDL_video.h similarity index 99% rename from jni/SDL2-2.0.1/include/SDL_video.h rename to jni/SDL2-2.0.3/include/SDL_video.h index 4a53f9b3..49ea37ad 100644 --- a/jni/SDL2-2.0.1/include/SDL_video.h +++ b/jni/SDL2-2.0.3/include/SDL_video.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -865,6 +865,11 @@ extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void); extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char *extension); +/** + * \brief Reset all previously set OpenGL context attributes to their default values + */ +extern DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void); + /** * \brief Set an OpenGL window attribute before window creation. */ diff --git a/jni/SDL2-2.0.1/include/begin_code.h b/jni/SDL2-2.0.3/include/begin_code.h similarity index 95% rename from jni/SDL2-2.0.1/include/begin_code.h rename to jni/SDL2-2.0.3/include/begin_code.h index 968a540a..f37ee369 100644 --- a/jni/SDL2-2.0.1/include/begin_code.h +++ b/jni/SDL2-2.0.3/include/begin_code.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -43,7 +43,7 @@ /* Some compilers use a special export keyword */ #ifndef DECLSPEC -# if defined(__WIN32__) +# if defined(__WIN32__) || defined(__WINRT__) # ifdef __BORLANDC__ # ifdef BUILD_SDL # define DECLSPEC @@ -66,7 +66,7 @@ /* By default SDL uses the C calling convention */ #ifndef SDLCALL -#if defined(__WIN32__) && !defined(__GNUC__) +#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__) #define SDLCALL __cdecl #else #define SDLCALL diff --git a/jni/SDL2-2.0.1/include/close_code.h b/jni/SDL2-2.0.3/include/close_code.h similarity index 95% rename from jni/SDL2-2.0.1/include/close_code.h rename to jni/SDL2-2.0.3/include/close_code.h index 4901482d..9826f147 100644 --- a/jni/SDL2-2.0.1/include/close_code.h +++ b/jni/SDL2-2.0.3/include/close_code.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/include/doxyfile b/jni/SDL2-2.0.3/include/doxyfile similarity index 100% rename from jni/SDL2-2.0.1/include/doxyfile rename to jni/SDL2-2.0.3/include/doxyfile diff --git a/jni/SDL2-2.0.1/sdl2-config.in b/jni/SDL2-2.0.3/sdl2-config.in similarity index 100% rename from jni/SDL2-2.0.1/sdl2-config.in rename to jni/SDL2-2.0.3/sdl2-config.in diff --git a/jni/SDL2-2.0.1/sdl2.m4 b/jni/SDL2-2.0.3/sdl2.m4 similarity index 100% rename from jni/SDL2-2.0.1/sdl2.m4 rename to jni/SDL2-2.0.3/sdl2.m4 diff --git a/jni/SDL2-2.0.1/sdl2.pc.in b/jni/SDL2-2.0.3/sdl2.pc.in similarity index 100% rename from jni/SDL2-2.0.1/sdl2.pc.in rename to jni/SDL2-2.0.3/sdl2.pc.in diff --git a/jni/SDL2-2.0.1/src/SDL.c b/jni/SDL2-2.0.3/src/SDL.c similarity index 98% rename from jni/SDL2-2.0.1/src/SDL.c rename to jni/SDL2-2.0.3/src/SDL.c index d1a3ab5a..dacd0f7a 100644 --- a/jni/SDL2-2.0.1/src/SDL.c +++ b/jni/SDL2-2.0.3/src/SDL.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -38,7 +38,8 @@ #if !SDL_TIMERS_DISABLED extern int SDL_TimerInit(void); extern void SDL_TimerQuit(void); -extern void SDL_InitTicks(void); +extern void SDL_TicksInit(void); +extern void SDL_TicksQuit(void); #endif #if SDL_VIDEO_DRIVER_WINDOWS extern int SDL_HelperWindowCreate(void); @@ -123,7 +124,7 @@ SDL_InitSubSystem(Uint32 flags) #endif #if !SDL_TIMERS_DISABLED - SDL_InitTicks(); + SDL_TicksInit(); #endif if ((flags & SDL_INIT_GAMECONTROLLER)) { @@ -355,6 +356,10 @@ SDL_Quit(void) #endif SDL_QuitSubSystem(SDL_INIT_EVERYTHING); +#if !SDL_TIMERS_DISABLED + SDL_TicksQuit(); +#endif + SDL_ClearHints(); SDL_AssertionsQuit(); SDL_LogResetPriorities(); diff --git a/jni/SDL2-2.0.1/src/SDL_assert.c b/jni/SDL2-2.0.3/src/SDL_assert.c similarity index 96% rename from jni/SDL2-2.0.1/src/SDL_assert.c rename to jni/SDL2-2.0.3/src/SDL_assert.c index 13e571f5..98e75844 100644 --- a/jni/SDL2-2.0.1/src/SDL_assert.c +++ b/jni/SDL2-2.0.3/src/SDL_assert.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -39,8 +39,10 @@ #else /* fprintf, _exit(), etc. */ #include #include +#if ! defined(__WINRT__) #include #endif +#endif static SDL_assert_state SDL_PromptAssertion(const SDL_assert_data *data, void *userdata); @@ -366,4 +368,17 @@ void SDL_ResetAssertionReport(void) triggered_assertions = NULL; } +SDL_AssertionHandler SDL_GetDefaultAssertionHandler(void) +{ + return SDL_PromptAssertion; +} + +SDL_AssertionHandler SDL_GetAssertionHandler(void **userdata) +{ + if (userdata != NULL) { + *userdata = assertion_userdata; + } + return assertion_handler; +} + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.1/src/SDL_assert_c.h b/jni/SDL2-2.0.3/src/SDL_assert_c.h similarity index 94% rename from jni/SDL2-2.0.1/src/SDL_assert_c.h rename to jni/SDL2-2.0.3/src/SDL_assert_c.h index 29802c04..f94b24c2 100644 --- a/jni/SDL2-2.0.1/src/SDL_assert_c.h +++ b/jni/SDL2-2.0.3/src/SDL_assert_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/SDL_error.c b/jni/SDL2-2.0.3/src/SDL_error.c similarity index 99% rename from jni/SDL2-2.0.1/src/SDL_error.c rename to jni/SDL2-2.0.3/src/SDL_error.c index bc9b10a7..ecbf4507 100644 --- a/jni/SDL2-2.0.1/src/SDL_error.c +++ b/jni/SDL2-2.0.3/src/SDL_error.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/SDL_error_c.h b/jni/SDL2-2.0.3/src/SDL_error_c.h similarity index 97% rename from jni/SDL2-2.0.1/src/SDL_error_c.h rename to jni/SDL2-2.0.3/src/SDL_error_c.h index 49e6c69e..98c20c49 100644 --- a/jni/SDL2-2.0.1/src/SDL_error_c.h +++ b/jni/SDL2-2.0.3/src/SDL_error_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/SDL_hints.c b/jni/SDL2-2.0.3/src/SDL_hints.c similarity index 99% rename from jni/SDL2-2.0.1/src/SDL_hints.c rename to jni/SDL2-2.0.3/src/SDL_hints.c index 837e7387..365459ec 100644 --- a/jni/SDL2-2.0.1/src/SDL_hints.c +++ b/jni/SDL2-2.0.3/src/SDL_hints.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/SDL_internal.h b/jni/SDL2-2.0.3/src/SDL_internal.h similarity index 95% rename from jni/SDL2-2.0.1/src/SDL_internal.h rename to jni/SDL2-2.0.3/src/SDL_internal.h index 3ccae74c..cb66abd8 100644 --- a/jni/SDL2-2.0.1/src/SDL_internal.h +++ b/jni/SDL2-2.0.3/src/SDL_internal.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/SDL_log.c b/jni/SDL2-2.0.3/src/SDL_log.c similarity index 97% rename from jni/SDL2-2.0.1/src/SDL_log.c rename to jni/SDL2-2.0.3/src/SDL_log.c index 7a2d8ac2..39aa3e4b 100644 --- a/jni/SDL2-2.0.1/src/SDL_log.c +++ b/jni/SDL2-2.0.3/src/SDL_log.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -20,7 +20,7 @@ */ #include "./SDL_internal.h" -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(__WINRT__) #include "core/windows/SDL_windows.h" #endif @@ -318,13 +318,15 @@ static void SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, const char *message) { -#if defined(__WIN32__) +#if defined(__WIN32__) || defined(__WINRT__) /* Way too many allocations here, urgh */ /* Note: One can't call SDL_SetError here, since that function itself logs. */ { char *output; size_t length; LPTSTR tstr; + +#ifndef __WINRT__ BOOL attachResult; DWORD attachError; unsigned long charsWritten; @@ -356,6 +358,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, stderrHandle = GetStdHandle(STD_ERROR_HANDLE); } } +#endif /* ifndef __WINRT__ */ length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1 + 1; output = SDL_stack_alloc(char, length); @@ -365,6 +368,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, /* Output to debugger */ OutputDebugString(tstr); +#ifndef __WINRT__ /* Screen output to stderr, if console was attached. */ if (consoleAttached == 1) { if (!WriteConsole(stderrHandle, tstr, lstrlen(tstr), &charsWritten, NULL)) { @@ -374,6 +378,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, OutputDebugString(TEXT("Insufficient heap memory to write message\r\n")); } } +#endif /* ifndef __WINRT__ */ SDL_free(tstr); SDL_stack_free(output); diff --git a/jni/SDL2-2.0.1/src/atomic/SDL_atomic.c b/jni/SDL2-2.0.3/src/atomic/SDL_atomic.c similarity index 99% rename from jni/SDL2-2.0.1/src/atomic/SDL_atomic.c rename to jni/SDL2-2.0.3/src/atomic/SDL_atomic.c index 8be9a474..be3f4002 100644 --- a/jni/SDL2-2.0.1/src/atomic/SDL_atomic.c +++ b/jni/SDL2-2.0.3/src/atomic/SDL_atomic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/atomic/SDL_spinlock.c b/jni/SDL2-2.0.3/src/atomic/SDL_spinlock.c similarity index 97% rename from jni/SDL2-2.0.1/src/atomic/SDL_spinlock.c rename to jni/SDL2-2.0.3/src/atomic/SDL_spinlock.c index f4346c5c..2d8446dc 100644 --- a/jni/SDL2-2.0.1/src/atomic/SDL_spinlock.c +++ b/jni/SDL2-2.0.3/src/atomic/SDL_spinlock.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -20,7 +20,7 @@ */ #include "../SDL_internal.h" -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__WINRT__) #include "../core/windows/SDL_windows.h" #endif diff --git a/jni/SDL2-2.0.1/src/audio/SDL_audio.c b/jni/SDL2-2.0.3/src/audio/SDL_audio.c similarity index 99% rename from jni/SDL2-2.0.1/src/audio/SDL_audio.c rename to jni/SDL2-2.0.3/src/audio/SDL_audio.c index c068887a..40cb5392 100644 --- a/jni/SDL2-2.0.1/src/audio/SDL_audio.c +++ b/jni/SDL2-2.0.3/src/audio/SDL_audio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/SDL_audio_c.h b/jni/SDL2-2.0.3/src/audio/SDL_audio_c.h similarity index 96% rename from jni/SDL2-2.0.1/src/audio/SDL_audio_c.h rename to jni/SDL2-2.0.3/src/audio/SDL_audio_c.h index 71b04cf7..2ea4e148 100644 --- a/jni/SDL2-2.0.1/src/audio/SDL_audio_c.h +++ b/jni/SDL2-2.0.3/src/audio/SDL_audio_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/SDL_audiocvt.c b/jni/SDL2-2.0.3/src/audio/SDL_audiocvt.c similarity index 94% rename from jni/SDL2-2.0.1/src/audio/SDL_audiocvt.c rename to jni/SDL2-2.0.3/src/audio/SDL_audiocvt.c index 92ceeb14..518735bf 100644 --- a/jni/SDL2-2.0.1/src/audio/SDL_audiocvt.c +++ b/jni/SDL2-2.0.3/src/audio/SDL_audiocvt.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -39,7 +39,9 @@ SDL_ConvertMono(SDL_AudioCVT * cvt, SDL_AudioFormat format) #ifdef DEBUG_CONVERT fprintf(stderr, "Converting to mono\n"); #endif - switch (format & (SDL_AUDIO_MASK_SIGNED | SDL_AUDIO_MASK_BITSIZE)) { + switch (format & (SDL_AUDIO_MASK_SIGNED | + SDL_AUDIO_MASK_BITSIZE | + SDL_AUDIO_MASK_DATATYPE)) { case AUDIO_U8: { Uint8 *src, *dst; @@ -331,7 +333,9 @@ SDL_ConvertSurround(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Converting stereo to surround\n"); #endif - switch (format & (SDL_AUDIO_MASK_SIGNED | SDL_AUDIO_MASK_BITSIZE)) { + switch (format & (SDL_AUDIO_MASK_SIGNED | + SDL_AUDIO_MASK_BITSIZE | + SDL_AUDIO_MASK_DATATYPE)) { case AUDIO_U8: { Uint8 *src, *dst, lf, rf, ce; @@ -499,8 +503,8 @@ SDL_ConvertSurround(SDL_AudioCVT * cvt, SDL_AudioFormat format) case AUDIO_S32: { Sint32 lf, rf, ce; - const Uint32 *src = (const Uint32 *) cvt->buf + cvt->len_cvt; - Uint32 *dst = (Uint32 *) cvt->buf + cvt->len_cvt * 3; + const Uint32 *src = (const Uint32 *) (cvt->buf + cvt->len_cvt); + Uint32 *dst = (Uint32 *) (cvt->buf + cvt->len_cvt * 3); if (SDL_AUDIO_ISBIGENDIAN(format)) { for (i = cvt->len_cvt / 8; i; --i) { @@ -537,8 +541,8 @@ SDL_ConvertSurround(SDL_AudioCVT * cvt, SDL_AudioFormat format) case AUDIO_F32: { float lf, rf, ce; - const float *src = (const float *) cvt->buf + cvt->len_cvt; - float *dst = (float *) cvt->buf + cvt->len_cvt * 3; + const float *src = (const float *) (cvt->buf + cvt->len_cvt); + float *dst = (float *) (cvt->buf + cvt->len_cvt * 3); if (SDL_AUDIO_ISBIGENDIAN(format)) { for (i = cvt->len_cvt / 8; i; --i) { @@ -588,7 +592,9 @@ SDL_ConvertSurround_4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Converting stereo to quad\n"); #endif - switch (format & (SDL_AUDIO_MASK_SIGNED | SDL_AUDIO_MASK_BITSIZE)) { + switch (format & (SDL_AUDIO_MASK_SIGNED | + SDL_AUDIO_MASK_BITSIZE | + SDL_AUDIO_MASK_DATATYPE)) { case AUDIO_U8: { Uint8 *src, *dst, lf, rf, ce; @@ -762,6 +768,40 @@ SDL_ConvertSurround_4(SDL_AudioCVT * cvt, SDL_AudioFormat format) } } break; + + case AUDIO_F32: + { + const float *src = (const float *) (cvt->buf + cvt->len_cvt); + float *dst = (float *) (cvt->buf + cvt->len_cvt * 2); + float lf, rf, ce; + + if (SDL_AUDIO_ISBIGENDIAN(format)) { + for (i = cvt->len_cvt / 8; i; --i) { + dst -= 4; + src -= 2; + lf = SDL_SwapFloatBE(src[0]); + rf = SDL_SwapFloatBE(src[1]); + ce = (lf / 2) + (rf / 2); + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = SDL_SwapFloatBE(lf - ce); + dst[3] = SDL_SwapFloatBE(rf - ce); + } + } else { + for (i = cvt->len_cvt / 8; i; --i) { + dst -= 4; + src -= 2; + lf = SDL_SwapFloatLE(src[0]); + rf = SDL_SwapFloatLE(src[1]); + ce = (lf / 2) + (rf / 2); + dst[0] = src[0]; + dst[1] = src[1]; + dst[2] = SDL_SwapFloatLE(lf - ce); + dst[3] = SDL_SwapFloatLE(rf - ce); + } + } + } + break; } cvt->len_cvt *= 2; if (cvt->filters[++cvt->filter_index]) { diff --git a/jni/SDL2-2.0.1/src/audio/SDL_audiodev.c b/jni/SDL2-2.0.3/src/audio/SDL_audiodev.c similarity index 98% rename from jni/SDL2-2.0.1/src/audio/SDL_audiodev.c rename to jni/SDL2-2.0.3/src/audio/SDL_audiodev.c index 0ecb26b9..e9af6211 100644 --- a/jni/SDL2-2.0.1/src/audio/SDL_audiodev.c +++ b/jni/SDL2-2.0.3/src/audio/SDL_audiodev.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/SDL_audiodev_c.h b/jni/SDL2-2.0.3/src/audio/SDL_audiodev_c.h similarity index 95% rename from jni/SDL2-2.0.1/src/audio/SDL_audiodev_c.h rename to jni/SDL2-2.0.3/src/audio/SDL_audiodev_c.h index d2e1ddbb..1ad0dc10 100644 --- a/jni/SDL2-2.0.1/src/audio/SDL_audiodev_c.h +++ b/jni/SDL2-2.0.3/src/audio/SDL_audiodev_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/SDL_audiomem.h b/jni/SDL2-2.0.3/src/audio/SDL_audiomem.h similarity index 94% rename from jni/SDL2-2.0.1/src/audio/SDL_audiomem.h rename to jni/SDL2-2.0.3/src/audio/SDL_audiomem.h index 9e462c47..3711ac94 100644 --- a/jni/SDL2-2.0.1/src/audio/SDL_audiomem.h +++ b/jni/SDL2-2.0.3/src/audio/SDL_audiomem.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/SDL_audiotypecvt.c b/jni/SDL2-2.0.3/src/audio/SDL_audiotypecvt.c similarity index 99% rename from jni/SDL2-2.0.1/src/audio/SDL_audiotypecvt.c rename to jni/SDL2-2.0.3/src/audio/SDL_audiotypecvt.c index 5522041d..18e22773 100644 --- a/jni/SDL2-2.0.1/src/audio/SDL_audiotypecvt.c +++ b/jni/SDL2-2.0.3/src/audio/SDL_audiotypecvt.c @@ -1,7 +1,7 @@ /* DO NOT EDIT! This file is generated by sdlgenaudiocvt.pl */ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/SDL_mixer.c b/jni/SDL2-2.0.3/src/audio/SDL_mixer.c similarity index 99% rename from jni/SDL2-2.0.1/src/audio/SDL_mixer.c rename to jni/SDL2-2.0.3/src/audio/SDL_mixer.c index 87ceac96..42a1c687 100644 --- a/jni/SDL2-2.0.1/src/audio/SDL_mixer.c +++ b/jni/SDL2-2.0.3/src/audio/SDL_mixer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/SDL_sysaudio.h b/jni/SDL2-2.0.3/src/audio/SDL_sysaudio.h similarity index 98% rename from jni/SDL2-2.0.1/src/audio/SDL_sysaudio.h rename to jni/SDL2-2.0.3/src/audio/SDL_sysaudio.h index b4d6069d..9fe31c80 100644 --- a/jni/SDL2-2.0.1/src/audio/SDL_sysaudio.h +++ b/jni/SDL2-2.0.3/src/audio/SDL_sysaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/SDL_wave.c b/jni/SDL2-2.0.3/src/audio/SDL_wave.c similarity index 99% rename from jni/SDL2-2.0.1/src/audio/SDL_wave.c rename to jni/SDL2-2.0.3/src/audio/SDL_wave.c index 4d09cf30..903264ca 100644 --- a/jni/SDL2-2.0.1/src/audio/SDL_wave.c +++ b/jni/SDL2-2.0.3/src/audio/SDL_wave.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/SDL_wave.h b/jni/SDL2-2.0.3/src/audio/SDL_wave.h similarity index 97% rename from jni/SDL2-2.0.1/src/audio/SDL_wave.h rename to jni/SDL2-2.0.3/src/audio/SDL_wave.h index 4fdc8cb0..c53ad590 100644 --- a/jni/SDL2-2.0.1/src/audio/SDL_wave.h +++ b/jni/SDL2-2.0.3/src/audio/SDL_wave.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/alsa/SDL_alsa_audio.c b/jni/SDL2-2.0.3/src/audio/alsa/SDL_alsa_audio.c similarity index 99% rename from jni/SDL2-2.0.1/src/audio/alsa/SDL_alsa_audio.c rename to jni/SDL2-2.0.3/src/audio/alsa/SDL_alsa_audio.c index b60f71dc..1f3def3f 100644 --- a/jni/SDL2-2.0.1/src/audio/alsa/SDL_alsa_audio.c +++ b/jni/SDL2-2.0.3/src/audio/alsa/SDL_alsa_audio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/alsa/SDL_alsa_audio.h b/jni/SDL2-2.0.3/src/audio/alsa/SDL_alsa_audio.h similarity index 95% rename from jni/SDL2-2.0.1/src/audio/alsa/SDL_alsa_audio.h rename to jni/SDL2-2.0.3/src/audio/alsa/SDL_alsa_audio.h index 78e892d8..45353883 100644 --- a/jni/SDL2-2.0.1/src/audio/alsa/SDL_alsa_audio.h +++ b/jni/SDL2-2.0.3/src/audio/alsa/SDL_alsa_audio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/android/SDL_androidaudio.c b/jni/SDL2-2.0.3/src/audio/android/SDL_androidaudio.c similarity index 98% rename from jni/SDL2-2.0.1/src/audio/android/SDL_androidaudio.c rename to jni/SDL2-2.0.3/src/audio/android/SDL_androidaudio.c index ac9fd9de..0c85b83c 100644 --- a/jni/SDL2-2.0.1/src/audio/android/SDL_androidaudio.c +++ b/jni/SDL2-2.0.3/src/audio/android/SDL_androidaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/android/SDL_androidaudio.h b/jni/SDL2-2.0.3/src/audio/android/SDL_androidaudio.h similarity index 95% rename from jni/SDL2-2.0.1/src/audio/android/SDL_androidaudio.h rename to jni/SDL2-2.0.3/src/audio/android/SDL_androidaudio.h index bad6a42a..ab49f000 100644 --- a/jni/SDL2-2.0.1/src/audio/android/SDL_androidaudio.h +++ b/jni/SDL2-2.0.3/src/audio/android/SDL_androidaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/arts/SDL_artsaudio.c b/jni/SDL2-2.0.3/src/audio/arts/SDL_artsaudio.c similarity index 99% rename from jni/SDL2-2.0.1/src/audio/arts/SDL_artsaudio.c rename to jni/SDL2-2.0.3/src/audio/arts/SDL_artsaudio.c index 516602dc..72fba70c 100644 --- a/jni/SDL2-2.0.1/src/audio/arts/SDL_artsaudio.c +++ b/jni/SDL2-2.0.3/src/audio/arts/SDL_artsaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/arts/SDL_artsaudio.h b/jni/SDL2-2.0.3/src/audio/arts/SDL_artsaudio.h similarity index 96% rename from jni/SDL2-2.0.1/src/audio/arts/SDL_artsaudio.h rename to jni/SDL2-2.0.3/src/audio/arts/SDL_artsaudio.h index 94fa5257..fb7706fc 100644 --- a/jni/SDL2-2.0.1/src/audio/arts/SDL_artsaudio.h +++ b/jni/SDL2-2.0.3/src/audio/arts/SDL_artsaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/bsd/SDL_bsdaudio.c b/jni/SDL2-2.0.3/src/audio/bsd/SDL_bsdaudio.c similarity index 99% rename from jni/SDL2-2.0.1/src/audio/bsd/SDL_bsdaudio.c rename to jni/SDL2-2.0.3/src/audio/bsd/SDL_bsdaudio.c index 90fd9a4f..f415fe04 100644 --- a/jni/SDL2-2.0.1/src/audio/bsd/SDL_bsdaudio.c +++ b/jni/SDL2-2.0.3/src/audio/bsd/SDL_bsdaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/bsd/SDL_bsdaudio.h b/jni/SDL2-2.0.3/src/audio/bsd/SDL_bsdaudio.h similarity index 96% rename from jni/SDL2-2.0.1/src/audio/bsd/SDL_bsdaudio.h rename to jni/SDL2-2.0.3/src/audio/bsd/SDL_bsdaudio.h index 2550a9ed..625bdb54 100644 --- a/jni/SDL2-2.0.1/src/audio/bsd/SDL_bsdaudio.h +++ b/jni/SDL2-2.0.3/src/audio/bsd/SDL_bsdaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/coreaudio/SDL_coreaudio.c b/jni/SDL2-2.0.3/src/audio/coreaudio/SDL_coreaudio.c similarity index 99% rename from jni/SDL2-2.0.1/src/audio/coreaudio/SDL_coreaudio.c rename to jni/SDL2-2.0.3/src/audio/coreaudio/SDL_coreaudio.c index 653b8ceb..95011028 100644 --- a/jni/SDL2-2.0.1/src/audio/coreaudio/SDL_coreaudio.c +++ b/jni/SDL2-2.0.3/src/audio/coreaudio/SDL_coreaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/coreaudio/SDL_coreaudio.h b/jni/SDL2-2.0.3/src/audio/coreaudio/SDL_coreaudio.h similarity index 96% rename from jni/SDL2-2.0.1/src/audio/coreaudio/SDL_coreaudio.h rename to jni/SDL2-2.0.3/src/audio/coreaudio/SDL_coreaudio.h index da003aa6..41e8cea2 100644 --- a/jni/SDL2-2.0.1/src/audio/coreaudio/SDL_coreaudio.h +++ b/jni/SDL2-2.0.3/src/audio/coreaudio/SDL_coreaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/directsound/SDL_directsound.c b/jni/SDL2-2.0.3/src/audio/directsound/SDL_directsound.c similarity index 99% rename from jni/SDL2-2.0.1/src/audio/directsound/SDL_directsound.c rename to jni/SDL2-2.0.3/src/audio/directsound/SDL_directsound.c index b3d08736..067683cc 100644 --- a/jni/SDL2-2.0.1/src/audio/directsound/SDL_directsound.c +++ b/jni/SDL2-2.0.3/src/audio/directsound/SDL_directsound.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/directsound/SDL_directsound.h b/jni/SDL2-2.0.3/src/audio/directsound/SDL_directsound.h similarity index 95% rename from jni/SDL2-2.0.1/src/audio/directsound/SDL_directsound.h rename to jni/SDL2-2.0.3/src/audio/directsound/SDL_directsound.h index 46dbd3fc..b873391f 100644 --- a/jni/SDL2-2.0.1/src/audio/directsound/SDL_directsound.h +++ b/jni/SDL2-2.0.3/src/audio/directsound/SDL_directsound.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/directsound/directx.h b/jni/SDL2-2.0.3/src/audio/directsound/directx.h similarity index 65% rename from jni/SDL2-2.0.1/src/audio/directsound/directx.h rename to jni/SDL2-2.0.3/src/audio/directsound/directx.h index 963d2b88..472a0ee0 100644 --- a/jni/SDL2-2.0.1/src/audio/directsound/directx.h +++ b/jni/SDL2-2.0.3/src/audio/directsound/directx.h @@ -1,3 +1,23 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ #ifndef _directx_h #define _directx_h @@ -78,4 +98,5 @@ #include #endif /* _directx_h */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.1/src/audio/disk/SDL_diskaudio.c b/jni/SDL2-2.0.3/src/audio/disk/SDL_diskaudio.c similarity index 98% rename from jni/SDL2-2.0.1/src/audio/disk/SDL_diskaudio.c rename to jni/SDL2-2.0.3/src/audio/disk/SDL_diskaudio.c index 7429c0e6..cc4e3efc 100644 --- a/jni/SDL2-2.0.1/src/audio/disk/SDL_diskaudio.c +++ b/jni/SDL2-2.0.3/src/audio/disk/SDL_diskaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/disk/SDL_diskaudio.h b/jni/SDL2-2.0.3/src/audio/disk/SDL_diskaudio.h similarity index 95% rename from jni/SDL2-2.0.1/src/audio/disk/SDL_diskaudio.h rename to jni/SDL2-2.0.3/src/audio/disk/SDL_diskaudio.h index 94d44abc..9c5a7afa 100644 --- a/jni/SDL2-2.0.1/src/audio/disk/SDL_diskaudio.h +++ b/jni/SDL2-2.0.3/src/audio/disk/SDL_diskaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/dsp/SDL_dspaudio.c b/jni/SDL2-2.0.3/src/audio/dsp/SDL_dspaudio.c similarity index 99% rename from jni/SDL2-2.0.1/src/audio/dsp/SDL_dspaudio.c rename to jni/SDL2-2.0.3/src/audio/dsp/SDL_dspaudio.c index 10426bc3..eea5a5f8 100644 --- a/jni/SDL2-2.0.1/src/audio/dsp/SDL_dspaudio.c +++ b/jni/SDL2-2.0.3/src/audio/dsp/SDL_dspaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/dsp/SDL_dspaudio.h b/jni/SDL2-2.0.3/src/audio/dsp/SDL_dspaudio.h similarity index 95% rename from jni/SDL2-2.0.1/src/audio/dsp/SDL_dspaudio.h rename to jni/SDL2-2.0.3/src/audio/dsp/SDL_dspaudio.h index 5c3204a1..5cbb563b 100644 --- a/jni/SDL2-2.0.1/src/audio/dsp/SDL_dspaudio.h +++ b/jni/SDL2-2.0.3/src/audio/dsp/SDL_dspaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/dummy/SDL_dummyaudio.c b/jni/SDL2-2.0.3/src/audio/dummy/SDL_dummyaudio.c similarity index 96% rename from jni/SDL2-2.0.1/src/audio/dummy/SDL_dummyaudio.c rename to jni/SDL2-2.0.3/src/audio/dummy/SDL_dummyaudio.c index a1130320..671e222c 100644 --- a/jni/SDL2-2.0.1/src/audio/dummy/SDL_dummyaudio.c +++ b/jni/SDL2-2.0.3/src/audio/dummy/SDL_dummyaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/dummy/SDL_dummyaudio.h b/jni/SDL2-2.0.3/src/audio/dummy/SDL_dummyaudio.h similarity index 95% rename from jni/SDL2-2.0.1/src/audio/dummy/SDL_dummyaudio.h rename to jni/SDL2-2.0.3/src/audio/dummy/SDL_dummyaudio.h index 1b948311..18540111 100644 --- a/jni/SDL2-2.0.1/src/audio/dummy/SDL_dummyaudio.h +++ b/jni/SDL2-2.0.3/src/audio/dummy/SDL_dummyaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/esd/SDL_esdaudio.c b/jni/SDL2-2.0.3/src/audio/esd/SDL_esdaudio.c similarity index 99% rename from jni/SDL2-2.0.1/src/audio/esd/SDL_esdaudio.c rename to jni/SDL2-2.0.3/src/audio/esd/SDL_esdaudio.c index 28c45c75..e675272d 100644 --- a/jni/SDL2-2.0.1/src/audio/esd/SDL_esdaudio.c +++ b/jni/SDL2-2.0.3/src/audio/esd/SDL_esdaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/esd/SDL_esdaudio.h b/jni/SDL2-2.0.3/src/audio/esd/SDL_esdaudio.h similarity index 96% rename from jni/SDL2-2.0.1/src/audio/esd/SDL_esdaudio.h rename to jni/SDL2-2.0.3/src/audio/esd/SDL_esdaudio.h index 4f772376..e0d5d4cd 100644 --- a/jni/SDL2-2.0.1/src/audio/esd/SDL_esdaudio.h +++ b/jni/SDL2-2.0.3/src/audio/esd/SDL_esdaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/fusionsound/SDL_fsaudio.c b/jni/SDL2-2.0.3/src/audio/fusionsound/SDL_fsaudio.c similarity index 99% rename from jni/SDL2-2.0.1/src/audio/fusionsound/SDL_fsaudio.c rename to jni/SDL2-2.0.3/src/audio/fusionsound/SDL_fsaudio.c index 452a9a81..b8367715 100644 --- a/jni/SDL2-2.0.1/src/audio/fusionsound/SDL_fsaudio.c +++ b/jni/SDL2-2.0.3/src/audio/fusionsound/SDL_fsaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/fusionsound/SDL_fsaudio.h b/jni/SDL2-2.0.3/src/audio/fusionsound/SDL_fsaudio.h similarity index 95% rename from jni/SDL2-2.0.1/src/audio/fusionsound/SDL_fsaudio.h rename to jni/SDL2-2.0.3/src/audio/fusionsound/SDL_fsaudio.h index 2e3d28d8..1f9d6bd2 100644 --- a/jni/SDL2-2.0.1/src/audio/fusionsound/SDL_fsaudio.h +++ b/jni/SDL2-2.0.3/src/audio/fusionsound/SDL_fsaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/haiku/SDL_haikuaudio.cc b/jni/SDL2-2.0.3/src/audio/haiku/SDL_haikuaudio.cc similarity index 99% rename from jni/SDL2-2.0.1/src/audio/haiku/SDL_haikuaudio.cc rename to jni/SDL2-2.0.3/src/audio/haiku/SDL_haikuaudio.cc index 09549c0e..dddb7792 100644 --- a/jni/SDL2-2.0.1/src/audio/haiku/SDL_haikuaudio.cc +++ b/jni/SDL2-2.0.3/src/audio/haiku/SDL_haikuaudio.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/haiku/SDL_haikuaudio.h b/jni/SDL2-2.0.3/src/audio/haiku/SDL_haikuaudio.h similarity index 95% rename from jni/SDL2-2.0.1/src/audio/haiku/SDL_haikuaudio.h rename to jni/SDL2-2.0.3/src/audio/haiku/SDL_haikuaudio.h index 17621974..c6c019e9 100644 --- a/jni/SDL2-2.0.1/src/audio/haiku/SDL_haikuaudio.h +++ b/jni/SDL2-2.0.3/src/audio/haiku/SDL_haikuaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/nas/SDL_nasaudio.c b/jni/SDL2-2.0.3/src/audio/nas/SDL_nasaudio.c similarity index 99% rename from jni/SDL2-2.0.1/src/audio/nas/SDL_nasaudio.c rename to jni/SDL2-2.0.3/src/audio/nas/SDL_nasaudio.c index 7b09d7ed..a41a480f 100644 --- a/jni/SDL2-2.0.1/src/audio/nas/SDL_nasaudio.c +++ b/jni/SDL2-2.0.3/src/audio/nas/SDL_nasaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/nas/SDL_nasaudio.h b/jni/SDL2-2.0.3/src/audio/nas/SDL_nasaudio.h similarity index 96% rename from jni/SDL2-2.0.1/src/audio/nas/SDL_nasaudio.h rename to jni/SDL2-2.0.3/src/audio/nas/SDL_nasaudio.h index f44d74be..e1ee6a52 100644 --- a/jni/SDL2-2.0.1/src/audio/nas/SDL_nasaudio.h +++ b/jni/SDL2-2.0.3/src/audio/nas/SDL_nasaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/paudio/SDL_paudio.c b/jni/SDL2-2.0.3/src/audio/paudio/SDL_paudio.c similarity index 99% rename from jni/SDL2-2.0.1/src/audio/paudio/SDL_paudio.c rename to jni/SDL2-2.0.3/src/audio/paudio/SDL_paudio.c index 4cbebb0d..032d8d2c 100644 --- a/jni/SDL2-2.0.1/src/audio/paudio/SDL_paudio.c +++ b/jni/SDL2-2.0.3/src/audio/paudio/SDL_paudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/paudio/SDL_paudio.h b/jni/SDL2-2.0.3/src/audio/paudio/SDL_paudio.h similarity index 96% rename from jni/SDL2-2.0.1/src/audio/paudio/SDL_paudio.h rename to jni/SDL2-2.0.3/src/audio/paudio/SDL_paudio.h index f21c21f8..5a1a6488 100644 --- a/jni/SDL2-2.0.1/src/audio/paudio/SDL_paudio.h +++ b/jni/SDL2-2.0.3/src/audio/paudio/SDL_paudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/psp/SDL_pspaudio.c b/jni/SDL2-2.0.3/src/audio/psp/SDL_pspaudio.c similarity index 98% rename from jni/SDL2-2.0.1/src/audio/psp/SDL_pspaudio.c rename to jni/SDL2-2.0.3/src/audio/psp/SDL_pspaudio.c index 8576d95e..5b170592 100644 --- a/jni/SDL2-2.0.1/src/audio/psp/SDL_pspaudio.c +++ b/jni/SDL2-2.0.3/src/audio/psp/SDL_pspaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/psp/SDL_pspaudio.h b/jni/SDL2-2.0.3/src/audio/psp/SDL_pspaudio.h similarity index 95% rename from jni/SDL2-2.0.1/src/audio/psp/SDL_pspaudio.h rename to jni/SDL2-2.0.3/src/audio/psp/SDL_pspaudio.h index 139476c6..8e420f31 100644 --- a/jni/SDL2-2.0.1/src/audio/psp/SDL_pspaudio.h +++ b/jni/SDL2-2.0.3/src/audio/psp/SDL_pspaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/pulseaudio/SDL_pulseaudio.c b/jni/SDL2-2.0.3/src/audio/pulseaudio/SDL_pulseaudio.c similarity index 99% rename from jni/SDL2-2.0.1/src/audio/pulseaudio/SDL_pulseaudio.c rename to jni/SDL2-2.0.3/src/audio/pulseaudio/SDL_pulseaudio.c index 0ac71817..c3e1238b 100644 --- a/jni/SDL2-2.0.1/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/jni/SDL2-2.0.3/src/audio/pulseaudio/SDL_pulseaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/pulseaudio/SDL_pulseaudio.h b/jni/SDL2-2.0.3/src/audio/pulseaudio/SDL_pulseaudio.h similarity index 95% rename from jni/SDL2-2.0.1/src/audio/pulseaudio/SDL_pulseaudio.h rename to jni/SDL2-2.0.3/src/audio/pulseaudio/SDL_pulseaudio.h index 648f29d2..a75409bc 100644 --- a/jni/SDL2-2.0.1/src/audio/pulseaudio/SDL_pulseaudio.h +++ b/jni/SDL2-2.0.3/src/audio/pulseaudio/SDL_pulseaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/qsa/SDL_qsa_audio.c b/jni/SDL2-2.0.3/src/audio/qsa/SDL_qsa_audio.c similarity index 99% rename from jni/SDL2-2.0.1/src/audio/qsa/SDL_qsa_audio.c rename to jni/SDL2-2.0.3/src/audio/qsa/SDL_qsa_audio.c index 7bc91d4e..d6b8a680 100644 --- a/jni/SDL2-2.0.1/src/audio/qsa/SDL_qsa_audio.c +++ b/jni/SDL2-2.0.3/src/audio/qsa/SDL_qsa_audio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/qsa/SDL_qsa_audio.h b/jni/SDL2-2.0.3/src/audio/qsa/SDL_qsa_audio.h similarity index 96% rename from jni/SDL2-2.0.1/src/audio/qsa/SDL_qsa_audio.h rename to jni/SDL2-2.0.3/src/audio/qsa/SDL_qsa_audio.h index e89b2c3a..66650d2a 100644 --- a/jni/SDL2-2.0.1/src/audio/qsa/SDL_qsa_audio.h +++ b/jni/SDL2-2.0.3/src/audio/qsa/SDL_qsa_audio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/sdlgenaudiocvt.pl b/jni/SDL2-2.0.3/src/audio/sdlgenaudiocvt.pl similarity index 99% rename from jni/SDL2-2.0.1/src/audio/sdlgenaudiocvt.pl rename to jni/SDL2-2.0.3/src/audio/sdlgenaudiocvt.pl index 25a6c2e1..73c021aa 100755 --- a/jni/SDL2-2.0.1/src/audio/sdlgenaudiocvt.pl +++ b/jni/SDL2-2.0.3/src/audio/sdlgenaudiocvt.pl @@ -38,7 +38,7 @@ sub outputHeader { /* DO NOT EDIT! This file is generated by sdlgenaudiocvt.pl */ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/sndio/SDL_sndioaudio.c b/jni/SDL2-2.0.3/src/audio/sndio/SDL_sndioaudio.c similarity index 99% rename from jni/SDL2-2.0.1/src/audio/sndio/SDL_sndioaudio.c rename to jni/SDL2-2.0.3/src/audio/sndio/SDL_sndioaudio.c index a8ed63c5..a0e57830 100644 --- a/jni/SDL2-2.0.1/src/audio/sndio/SDL_sndioaudio.c +++ b/jni/SDL2-2.0.3/src/audio/sndio/SDL_sndioaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/sndio/SDL_sndioaudio.h b/jni/SDL2-2.0.3/src/audio/sndio/SDL_sndioaudio.h similarity index 95% rename from jni/SDL2-2.0.1/src/audio/sndio/SDL_sndioaudio.h rename to jni/SDL2-2.0.3/src/audio/sndio/SDL_sndioaudio.h index ca72c712..b8dadb7d 100644 --- a/jni/SDL2-2.0.1/src/audio/sndio/SDL_sndioaudio.h +++ b/jni/SDL2-2.0.3/src/audio/sndio/SDL_sndioaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/sun/SDL_sunaudio.c b/jni/SDL2-2.0.3/src/audio/sun/SDL_sunaudio.c similarity index 99% rename from jni/SDL2-2.0.1/src/audio/sun/SDL_sunaudio.c rename to jni/SDL2-2.0.3/src/audio/sun/SDL_sunaudio.c index 8b867b5b..7efe30ec 100644 --- a/jni/SDL2-2.0.1/src/audio/sun/SDL_sunaudio.c +++ b/jni/SDL2-2.0.3/src/audio/sun/SDL_sunaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/sun/SDL_sunaudio.h b/jni/SDL2-2.0.3/src/audio/sun/SDL_sunaudio.h similarity index 96% rename from jni/SDL2-2.0.1/src/audio/sun/SDL_sunaudio.h rename to jni/SDL2-2.0.3/src/audio/sun/SDL_sunaudio.h index fb47eb84..df05e6fc 100644 --- a/jni/SDL2-2.0.1/src/audio/sun/SDL_sunaudio.h +++ b/jni/SDL2-2.0.3/src/audio/sun/SDL_sunaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/winmm/SDL_winmm.c b/jni/SDL2-2.0.3/src/audio/winmm/SDL_winmm.c similarity index 96% rename from jni/SDL2-2.0.1/src/audio/winmm/SDL_winmm.c rename to jni/SDL2-2.0.3/src/audio/winmm/SDL_winmm.c index 20a9c78a..88a8154e 100644 --- a/jni/SDL2-2.0.1/src/audio/winmm/SDL_winmm.c +++ b/jni/SDL2-2.0.3/src/audio/winmm/SDL_winmm.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -98,12 +98,12 @@ FillSound(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, static int SetMMerror(char *function, MMRESULT code) { - size_t len; + int len; char errbuf[MAXERRORLENGTH]; wchar_t werrbuf[MAXERRORLENGTH]; SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function); - len = SDL_strlen(errbuf); + len = SDL_static_cast(int, SDL_strlen(errbuf)); waveOutGetErrorText(code, werrbuf, MAXERRORLENGTH - len); WideCharToMultiByte(CP_ACP, 0, werrbuf, -1, errbuf + len, @@ -196,7 +196,7 @@ WINMM_CloseDevice(_THIS) } static SDL_bool -PrepWaveFormat(_THIS, UINT_PTR devId, WAVEFORMATEX *pfmt, const int iscapture) +PrepWaveFormat(_THIS, UINT devId, WAVEFORMATEX *pfmt, const int iscapture) { SDL_zerop(pfmt); @@ -226,13 +226,13 @@ WINMM_OpenDevice(_THIS, const char *devname, int iscapture) int valid_datatype = 0; MMRESULT result; WAVEFORMATEX waveformat; - UINT_PTR devId = WAVE_MAPPER; /* WAVE_MAPPER == choose system's default */ + UINT devId = WAVE_MAPPER; /* WAVE_MAPPER == choose system's default */ char *utf8 = NULL; - int i; + UINT i; if (devname != NULL) { /* specific device requested? */ if (iscapture) { - const int devcount = (int) waveInGetNumDevs(); + const UINT devcount = waveInGetNumDevs(); WAVEINCAPS caps; for (i = 0; (i < devcount) && (devId == WAVE_MAPPER); i++) { result = waveInGetDevCaps(i, &caps, sizeof (caps)); @@ -241,11 +241,11 @@ WINMM_OpenDevice(_THIS, const char *devname, int iscapture) else if ((utf8 = WIN_StringToUTF8(caps.szPname)) == NULL) continue; else if (SDL_strcmp(devname, utf8) == 0) - devId = (UINT_PTR) i; + devId = i; SDL_free(utf8); } } else { - const int devcount = (int) waveOutGetNumDevs(); + const UINT devcount = waveOutGetNumDevs(); WAVEOUTCAPS caps; for (i = 0; (i < devcount) && (devId == WAVE_MAPPER); i++) { result = waveOutGetDevCaps(i, &caps, sizeof (caps)); @@ -254,7 +254,7 @@ WINMM_OpenDevice(_THIS, const char *devname, int iscapture) else if ((utf8 = WIN_StringToUTF8(caps.szPname)) == NULL) continue; else if (SDL_strcmp(devname, utf8) == 0) - devId = (UINT_PTR) i; + devId = i; SDL_free(utf8); } } diff --git a/jni/SDL2-2.0.1/src/audio/winmm/SDL_winmm.h b/jni/SDL2-2.0.3/src/audio/winmm/SDL_winmm.h similarity index 96% rename from jni/SDL2-2.0.1/src/audio/winmm/SDL_winmm.h rename to jni/SDL2-2.0.3/src/audio/winmm/SDL_winmm.h index 784f7b8a..47996c1a 100644 --- a/jni/SDL2-2.0.1/src/audio/winmm/SDL_winmm.h +++ b/jni/SDL2-2.0.3/src/audio/winmm/SDL_winmm.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/audio/xaudio2/SDL_xaudio2.c b/jni/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2.c similarity index 76% rename from jni/SDL2-2.0.1/src/audio/xaudio2/SDL_xaudio2.c rename to jni/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2.c index 5ec8abcd..a1a18df6 100644 --- a/jni/SDL2-2.0.1/src/audio/xaudio2/SDL_xaudio2.c +++ b/jni/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -18,6 +18,32 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ + +/* WinRT NOTICE: + + A few changes to SDL's XAudio2 backend were warranted by API + changes to Windows. Many, but not all of these are documented by Microsoft + at: + http://blogs.msdn.com/b/chuckw/archive/2012/04/02/xaudio2-and-windows-8-consumer-preview.aspx + + 1. Windows' thread synchronization function, CreateSemaphore, was removed + from WinRT. SDL's semaphore API was substituted instead. + 2. The method calls, IXAudio2::GetDeviceCount and IXAudio2::GetDeviceDetails + were removed from the XAudio2 API. Microsoft is telling developers to + use APIs in Windows::Foundation instead. + For SDL, the missing methods were reimplemented using the APIs Microsoft + said to use. + 3. CoInitialize and CoUninitialize are not available in WinRT. + These calls were removed, as COM will have been initialized earlier, + at least by the call to the WinRT app's main function + (aka 'int main(Platform::Array^)). (DLudwig: + This was my understanding of how WinRT: the 'main' function uses + a tag of [MTAThread], which should initialize COM. My understanding + of COM is somewhat limited, and I may be incorrect here.) + 4. IXAudio2::CreateMasteringVoice changed its integer-based 'DeviceIndex' + argument to a string-based one, 'szDeviceId'. In WinRT, the + string-based argument will be used. +*/ #include "../../SDL_internal.h" #if SDL_AUDIO_DRIVER_XAUDIO2 @@ -31,6 +57,9 @@ #ifdef __GNUC__ /* The configure script already did any necessary checking */ # define SDL_XAUDIO2_HAS_SDK 1 +#elif defined(__WINRT__) +/* WinRT always has access to the .the XAudio 2 SDK */ +# define SDL_XAUDIO2_HAS_SDK #else /* XAudio2 exists as of the March 2008 DirectX SDK The XAudio2 implementation available in the Windows 8 SDK targets Windows 8 and newer. @@ -42,16 +71,36 @@ #else # define SDL_XAUDIO2_HAS_SDK 1 #endif -#endif /* __GNUC__ */ +#endif #ifdef SDL_XAUDIO2_HAS_SDK +/* Check to see if we're compiling for XAudio 2.8, or higher. */ +#ifdef WINVER +#if WINVER >= 0x0602 /* Windows 8 SDK or higher? */ +#define SDL_XAUDIO2_WIN8 1 +#endif +#endif + +/* The XAudio header file, when #include'd on WinRT, will only compile in C++ + files, but not C. A few preprocessor-based hacks are defined below in order + to get xaudio2.h to compile in the C/non-C++ file, SDL_xaudio2.c. + */ +#ifdef __WINRT__ +#define uuid(x) +#define DX_BUILD +#endif + #define INITGUID 1 #include /* Hidden "this" pointer for the audio functions */ #define _THIS SDL_AudioDevice *this +#ifdef __WINRT__ +#include "SDL_xaudio2_winrthelpers.h" +#endif + /* Fixes bug 1210 where some versions of gcc need named parameters */ #ifdef __GNUC__ #ifdef THIS @@ -69,7 +118,7 @@ struct SDL_PrivateAudioData IXAudio2 *ixa2; IXAudio2SourceVoice *source; IXAudio2MasteringVoice *mastering; - HANDLE semaphore; + SDL_sem * semaphore; Uint8 *mixbuf; int mixlen; Uint8 *nextbuf; @@ -114,7 +163,7 @@ VoiceCBOnBufferEnd(THIS_ void *data) { /* Just signal the SDL audio thread and get out of XAudio2's way. */ SDL_AudioDevice *this = (SDL_AudioDevice *) data; - ReleaseSemaphore(this->hidden->semaphore, 1, NULL); + SDL_SemPost(this->hidden->semaphore); } static void STDMETHODCALLTYPE @@ -180,7 +229,7 @@ static void XAUDIO2_WaitDevice(_THIS) { if (this->enabled) { - WaitForSingleObject(this->hidden->semaphore, INFINITE); + SDL_SemWait(this->hidden->semaphore); } } @@ -191,10 +240,18 @@ XAUDIO2_WaitDone(_THIS) XAUDIO2_VOICE_STATE state; SDL_assert(!this->enabled); /* flag that stops playing. */ IXAudio2SourceVoice_Discontinuity(source); +#if SDL_XAUDIO2_WIN8 + IXAudio2SourceVoice_GetState(source, &state, 0); +#else IXAudio2SourceVoice_GetState(source, &state); +#endif while (state.BuffersQueued > 0) { - WaitForSingleObject(this->hidden->semaphore, INFINITE); + SDL_SemWait(this->hidden->semaphore); +#if SDL_XAUDIO2_WIN8 + IXAudio2SourceVoice_GetState(source, &state, 0); +#else IXAudio2SourceVoice_GetState(source, &state); +#endif } } @@ -223,7 +280,7 @@ XAUDIO2_CloseDevice(_THIS) } SDL_free(this->hidden->mixbuf); if (this->hidden->semaphore != NULL) { - CloseHandle(this->hidden->semaphore); + SDL_DestroySemaphore(this->hidden->semaphore); } SDL_free(this->hidden); @@ -240,7 +297,11 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture) SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format); IXAudio2 *ixa2 = NULL; IXAudio2SourceVoice *source = NULL; +#if defined(SDL_XAUDIO2_WIN8) + LPCWSTR devId = NULL; +#else UINT32 devId = 0; /* 0 == system default device. */ +#endif static IXAudio2VoiceCallbackVtbl callbacks_vtable = { VoiceCBOnVoiceProcessPassStart, @@ -260,6 +321,18 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture) return SDL_SetError("XAudio2: XAudio2Create() failed at open."); } + /* + XAUDIO2_DEBUG_CONFIGURATION debugConfig; + debugConfig.TraceMask = XAUDIO2_LOG_ERRORS; //XAUDIO2_LOG_WARNINGS | XAUDIO2_LOG_DETAIL | XAUDIO2_LOG_FUNC_CALLS | XAUDIO2_LOG_TIMING | XAUDIO2_LOG_LOCKS | XAUDIO2_LOG_MEMORY | XAUDIO2_LOG_STREAMING; + debugConfig.BreakMask = XAUDIO2_LOG_ERRORS; //XAUDIO2_LOG_WARNINGS; + debugConfig.LogThreadID = TRUE; + debugConfig.LogFileline = TRUE; + debugConfig.LogFunctionName = TRUE; + debugConfig.LogTiming = TRUE; + ixa2->SetDebugConfiguration(&debugConfig); + */ + +#if ! defined(__WINRT__) if (devname != NULL) { UINT32 devcount = 0; UINT32 i = 0; @@ -288,6 +361,7 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture) return SDL_SetError("XAudio2: Requested device not found."); } } +#endif /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *) @@ -299,7 +373,7 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture) SDL_memset(this->hidden, 0, (sizeof *this->hidden)); this->hidden->ixa2 = ixa2; - this->hidden->semaphore = CreateSemaphore(NULL, 1, 2, NULL); + this->hidden->semaphore = SDL_CreateSemaphore(1); if (this->hidden->semaphore == NULL) { XAUDIO2_CloseDevice(this); return SDL_SetError("XAudio2: CreateSemaphore() failed!"); @@ -342,9 +416,15 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture) stereo output to appropriate surround sound configurations instead of clamping to 2 channels, even though we'll configure the Source Voice for whatever number of channels you supply. */ +#if SDL_XAUDIO2_WIN8 + result = IXAudio2_CreateMasteringVoice(ixa2, &this->hidden->mastering, + XAUDIO2_DEFAULT_CHANNELS, + this->spec.freq, 0, devId, NULL, AudioCategory_GameEffects); +#else result = IXAudio2_CreateMasteringVoice(ixa2, &this->hidden->mastering, XAUDIO2_DEFAULT_CHANNELS, this->spec.freq, 0, devId, NULL); +#endif if (result != S_OK) { XAUDIO2_CloseDevice(this); return SDL_SetError("XAudio2: Couldn't create mastering voice"); @@ -363,11 +443,23 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture) waveformat.nChannels * (waveformat.wBitsPerSample / 8); waveformat.nAvgBytesPerSec = waveformat.nSamplesPerSec * waveformat.nBlockAlign; + waveformat.cbSize = sizeof(waveformat); +#ifdef __WINRT__ + // DLudwig: for now, make XAudio2 do sample rate conversion, just to + // get the loopwave test to work. + // + // TODO, WinRT: consider removing WinRT-specific source-voice creation code from SDL_xaudio2.c + result = IXAudio2_CreateSourceVoice(ixa2, &source, &waveformat, + 0, + 1.0f, &callbacks, NULL, NULL); +#else result = IXAudio2_CreateSourceVoice(ixa2, &source, &waveformat, XAUDIO2_VOICE_NOSRC | XAUDIO2_VOICE_NOPITCH, 1.0f, &callbacks, NULL, NULL); + +#endif if (result != S_OK) { XAUDIO2_CloseDevice(this); return SDL_SetError("XAudio2: Couldn't create source voice"); @@ -393,7 +485,9 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture) static void XAUDIO2_Deinitialize(void) { +#if defined(__WIN32__) WIN_CoUninitialize(); +#endif } #endif /* SDL_XAUDIO2_HAS_SDK */ @@ -408,13 +502,18 @@ XAUDIO2_Init(SDL_AudioDriverImpl * impl) #else /* XAudio2Create() is a macro that uses COM; we don't load the .dll */ IXAudio2 *ixa2 = NULL; +#if defined(__WIN32__) + // TODO, WinRT: Investigate using CoInitializeEx here if (FAILED(WIN_CoInitialize())) { SDL_SetError("XAudio2: CoInitialize() failed"); return 0; } +#endif if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) { +#if defined(__WIN32__) WIN_CoUninitialize(); +#endif SDL_SetError("XAudio2: XAudio2Create() failed at initialization"); return 0; /* not available. */ } diff --git a/jni/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp b/jni/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp new file mode 100644 index 00000000..69eb5ad1 --- /dev/null +++ b/jni/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2_winrthelpers.cpp @@ -0,0 +1,90 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#include +#include "SDL_xaudio2_winrthelpers.h" + +#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP +using Windows::Devices::Enumeration::DeviceClass; +using Windows::Devices::Enumeration::DeviceInformation; +using Windows::Devices::Enumeration::DeviceInformationCollection; +#endif + +extern "C" HRESULT __cdecl IXAudio2_GetDeviceCount(IXAudio2 * ixa2, UINT32 * devcount) +{ +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + // There doesn't seem to be any audio device enumeration on Windows Phone. + // In lieu of this, just treat things as if there is one and only one + // audio device. + *devcount = 1; + return S_OK; +#else + // TODO, WinRT: make xaudio2 device enumeration only happen once, and in the background + auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender); + while (operation->Status != Windows::Foundation::AsyncStatus::Completed) + { + } + + DeviceInformationCollection^ devices = operation->GetResults(); + *devcount = devices->Size; + return S_OK; +#endif +} + +extern "C" HRESULT IXAudio2_GetDeviceDetails(IXAudio2 * unused, UINT32 index, XAUDIO2_DEVICE_DETAILS * details) +{ +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + // Windows Phone doesn't seem to have the same device enumeration APIs that + // Windows 8/RT has, or it doesn't have them at all. In lieu of this, + // just treat things as if there is one, and only one, default device. + if (index != 0) + { + return XAUDIO2_E_INVALID_CALL; + } + + if (details) + { + wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), L"default", _TRUNCATE); + wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), L"default", _TRUNCATE); + } + return S_OK; +#else + auto operation = DeviceInformation::FindAllAsync(DeviceClass::AudioRender); + while (operation->Status != Windows::Foundation::AsyncStatus::Completed) + { + } + + DeviceInformationCollection^ devices = operation->GetResults(); + if (index >= devices->Size) + { + return XAUDIO2_E_INVALID_CALL; + } + + DeviceInformation^ d = devices->GetAt(index); + if (details) + { + wcsncpy_s(details->DeviceID, ARRAYSIZE(details->DeviceID), d->Id->Data(), _TRUNCATE); + wcsncpy_s(details->DisplayName, ARRAYSIZE(details->DisplayName), d->Name->Data(), _TRUNCATE); + } + return S_OK; +#endif +} diff --git a/jni/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h b/jni/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h new file mode 100644 index 00000000..3db04cf9 --- /dev/null +++ b/jni/SDL2-2.0.3/src/audio/xaudio2/SDL_xaudio2_winrthelpers.h @@ -0,0 +1,70 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +// +// Re-implementation of methods removed from XAudio2 (in WinRT): +// + +typedef struct XAUDIO2_DEVICE_DETAILS +{ + WCHAR DeviceID[256]; + WCHAR DisplayName[256]; + /* Other fields exist in the pre-Windows 8 version of this struct, however + they weren't used by SDL, so they weren't added. + */ +} XAUDIO2_DEVICE_DETAILS; + + +#ifdef __cplusplus +extern "C" { +#endif + +HRESULT IXAudio2_GetDeviceCount(IXAudio2 * unused, UINT32 * devcount); +HRESULT IXAudio2_GetDeviceDetails(IXAudio2 * unused, UINT32 index, XAUDIO2_DEVICE_DETAILS * details); + +#ifdef __cplusplus +} +#endif + + +// +// C-style macros to call XAudio2's methods in C++: +// +#ifdef __cplusplus +/* +#define IXAudio2_CreateMasteringVoice(A, B, C, D, E, F, G) (A)->CreateMasteringVoice((B), (C), (D), (E), (F), (G)) +#define IXAudio2_CreateSourceVoice(A, B, C, D, E, F, G, H) (A)->CreateSourceVoice((B), (C), (D), (E), (F), (G), (H)) +#define IXAudio2_QueryInterface(A, B, C) (A)->QueryInterface((B), (C)) +#define IXAudio2_Release(A) (A)->Release() +#define IXAudio2_StartEngine(A) (A)->StartEngine() +#define IXAudio2_StopEngine(A) (A)->StopEngine() + +#define IXAudio2MasteringVoice_DestroyVoice(A) (A)->DestroyVoice() + +#define IXAudio2SourceVoice_DestroyVoice(A) (A)->DestroyVoice() +#define IXAudio2SourceVoice_Discontinuity(A) (A)->Discontinuity() +#define IXAudio2SourceVoice_FlushSourceBuffers(A) (A)->FlushSourceBuffers() +#define IXAudio2SourceVoice_GetState(A, B) (A)->GetState((B)) +#define IXAudio2SourceVoice_Start(A, B, C) (A)->Start((B), (C)) +#define IXAudio2SourceVoice_Stop(A, B, C) (A)->Stop((B), (C)) +#define IXAudio2SourceVoice_SubmitSourceBuffer(A, B, C) (A)->SubmitSourceBuffer((B), (C)) +*/ +#endif // ifdef __cplusplus diff --git a/jni/SDL2-2.0.1/src/core/android/SDL_android.c b/jni/SDL2-2.0.3/src/core/android/SDL_android.c similarity index 99% rename from jni/SDL2-2.0.1/src/core/android/SDL_android.c rename to jni/SDL2-2.0.3/src/core/android/SDL_android.c index c3944f41..d806208e 100644 --- a/jni/SDL2-2.0.1/src/core/android/SDL_android.c +++ b/jni/SDL2-2.0.3/src/core/android/SDL_android.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -172,6 +172,14 @@ void Java_org_libsdl_app_SDLActivity_onNativeJoy( Android_OnJoy(device_id, axis, value); } +/* POV Hat */ +void Java_org_libsdl_app_SDLActivity_onNativeHat( + JNIEnv* env, jclass jcls, + jint device_id, jint hat_id, jint x, jint y) +{ + Android_OnHat(device_id, hat_id, x, y); +} + int Java_org_libsdl_app_SDLActivity_nativeAddJoystick( JNIEnv* env, jclass jcls, diff --git a/jni/SDL2-2.0.1/src/core/android/SDL_android.h b/jni/SDL2-2.0.3/src/core/android/SDL_android.h similarity index 98% rename from jni/SDL2-2.0.1/src/core/android/SDL_android.h rename to jni/SDL2-2.0.3/src/core/android/SDL_android.h index fc154677..1294cd9c 100644 --- a/jni/SDL2-2.0.1/src/core/android/SDL_android.h +++ b/jni/SDL2-2.0.3/src/core/android/SDL_android.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/core/linux/SDL_evdev.c b/jni/SDL2-2.0.3/src/core/linux/SDL_evdev.c similarity index 99% rename from jni/SDL2-2.0.1/src/core/linux/SDL_evdev.c rename to jni/SDL2-2.0.3/src/core/linux/SDL_evdev.c index 5c424f2a..19333f25 100644 --- a/jni/SDL2-2.0.1/src/core/linux/SDL_evdev.c +++ b/jni/SDL2-2.0.3/src/core/linux/SDL_evdev.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/core/linux/SDL_evdev.h b/jni/SDL2-2.0.3/src/core/linux/SDL_evdev.h similarity index 96% rename from jni/SDL2-2.0.1/src/core/linux/SDL_evdev.h rename to jni/SDL2-2.0.3/src/core/linux/SDL_evdev.h index 0a0f44dd..f6398ea5 100644 --- a/jni/SDL2-2.0.1/src/core/linux/SDL_evdev.h +++ b/jni/SDL2-2.0.3/src/core/linux/SDL_evdev.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/core/linux/SDL_udev.c b/jni/SDL2-2.0.3/src/core/linux/SDL_udev.c similarity index 99% rename from jni/SDL2-2.0.1/src/core/linux/SDL_udev.c rename to jni/SDL2-2.0.3/src/core/linux/SDL_udev.c index c08c287e..da03b733 100644 --- a/jni/SDL2-2.0.1/src/core/linux/SDL_udev.c +++ b/jni/SDL2-2.0.3/src/core/linux/SDL_udev.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/core/linux/SDL_udev.h b/jni/SDL2-2.0.3/src/core/linux/SDL_udev.h similarity index 98% rename from jni/SDL2-2.0.1/src/core/linux/SDL_udev.h rename to jni/SDL2-2.0.3/src/core/linux/SDL_udev.h index f7d48c8b..9a8782a7 100644 --- a/jni/SDL2-2.0.1/src/core/linux/SDL_udev.h +++ b/jni/SDL2-2.0.3/src/core/linux/SDL_udev.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/core/windows/SDL_windows.c b/jni/SDL2-2.0.3/src/core/windows/SDL_windows.c similarity index 73% rename from jni/SDL2-2.0.1/src/core/windows/SDL_windows.c rename to jni/SDL2-2.0.3/src/core/windows/SDL_windows.c index 7580608b..16934d5e 100644 --- a/jni/SDL2-2.0.1/src/core/windows/SDL_windows.c +++ b/jni/SDL2-2.0.3/src/core/windows/SDL_windows.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -20,21 +20,21 @@ */ #include "../../SDL_internal.h" -#ifdef __WIN32__ +#if defined(__WIN32__) || defined(__WINRT__) #include "SDL_windows.h" #include "SDL_error.h" #include "SDL_assert.h" -#include /* for CoInitialize/CoUninitialize */ +#include /* for CoInitialize/CoUninitialize (Win32 only) */ /* Sets an error message based on GetLastError() */ int -WIN_SetError(const char *prefix) +WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr) { TCHAR buffer[1024]; char *message; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, 0, buffer, SDL_arraysize(buffer), NULL); message = WIN_StringToUTF8(buffer); SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message); @@ -42,6 +42,13 @@ WIN_SetError(const char *prefix) return -1; } +/* Sets an error message based on GetLastError() */ +int +WIN_SetError(const char *prefix) +{ + return WIN_SetErrorFromHRESULT(prefix, GetLastError()); +} + HRESULT WIN_CoInitialize(void) { @@ -50,6 +57,14 @@ WIN_CoInitialize(void) If you need multi-threaded mode, call CoInitializeEx() before SDL_Init() */ +#ifdef __WINRT__ + /* DLudwig: On WinRT, it is assumed that COM was initialized in main(). + CoInitializeEx is available (not CoInitialize though), however + on WinRT, main() is typically declared with the [MTAThread] + attribute, which, AFAIK, should initialize COM. + */ + return S_OK; +#else HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); if (hr == RPC_E_CHANGED_MODE) { hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); @@ -62,12 +77,15 @@ WIN_CoInitialize(void) } return hr; +#endif } void WIN_CoUninitialize(void) { +#ifndef __WINRT__ CoUninitialize(); +#endif } #endif /* __WIN32__ */ diff --git a/jni/SDL2-2.0.1/src/core/windows/SDL_windows.h b/jni/SDL2-2.0.3/src/core/windows/SDL_windows.h similarity index 91% rename from jni/SDL2-2.0.1/src/core/windows/SDL_windows.h rename to jni/SDL2-2.0.3/src/core/windows/SDL_windows.h index 90cd6b2a..45c9d734 100644 --- a/jni/SDL2-2.0.1/src/core/windows/SDL_windows.h +++ b/jni/SDL2-2.0.3/src/core/windows/SDL_windows.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -24,6 +24,7 @@ #ifndef _INCLUDED_WINDOWS_H #define _INCLUDED_WINDOWS_H +#if defined(__WIN32__) #define WIN32_LEAN_AND_MEAN #define STRICT #ifndef UNICODE @@ -31,6 +32,7 @@ #endif #undef _WIN32_WINNT #define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */ +#endif #include @@ -44,6 +46,9 @@ #define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1) #endif +/* Sets an error message based on a given HRESULT */ +extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr); + /* Sets an error message based on GetLastError(). Always return -1. */ extern int WIN_SetError(const char *prefix); diff --git a/jni/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_common.cpp b/jni/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_common.cpp new file mode 100644 index 00000000..0758ad92 --- /dev/null +++ b/jni/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_common.cpp @@ -0,0 +1,37 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#include "SDL_system.h" +#include "SDL_winrtapp_direct3d.h" +#include "SDL_winrtapp_xaml.h" + +int (*WINRT_SDLAppEntryPoint)(int, char **) = NULL; + +extern "C" DECLSPEC int +SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * xamlBackgroundPanel) +{ + if (xamlBackgroundPanel) { + return SDL_WinRTInitXAMLApp(mainFunction, xamlBackgroundPanel); + } else { + return SDL_WinRTInitNonXAMLApp(mainFunction); + } +} diff --git a/jni/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_common.h b/jni/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_common.h new file mode 100644 index 00000000..e49e615e --- /dev/null +++ b/jni/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_common.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_winrtapp_common_h +#define _SDL_winrtapp_common_h + +/* A pointer to the app's C-style main() function (which is a different + function than the WinRT app's actual entry point). + */ +extern int (*WINRT_SDLAppEntryPoint)(int, char **); + +#endif // ifndef _SDL_winrtapp_common_h diff --git a/jni/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_direct3d.cpp b/jni/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_direct3d.cpp new file mode 100644 index 00000000..2fd20a89 --- /dev/null +++ b/jni/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_direct3d.cpp @@ -0,0 +1,699 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +/* Standard C++11 includes */ +#include +#include +#include +using namespace std; + + +/* Windows includes */ +#include "ppltasks.h" +using namespace concurrency; +using namespace Windows::ApplicationModel; +using namespace Windows::ApplicationModel::Core; +using namespace Windows::ApplicationModel::Activation; +using namespace Windows::Devices::Input; +using namespace Windows::Graphics::Display; +using namespace Windows::Foundation; +using namespace Windows::System; +using namespace Windows::UI::Core; +using namespace Windows::UI::Input; + +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +using namespace Windows::Phone::UI::Input; +#endif + + +/* SDL includes */ +extern "C" { +#include "../../SDL_internal.h" +#include "SDL_assert.h" +#include "SDL_events.h" +#include "SDL_hints.h" +#include "SDL_log.h" +#include "SDL_main.h" +#include "SDL_stdinc.h" +#include "SDL_render.h" +#include "../../video/SDL_sysvideo.h" +//#include "../../SDL_hints_c.h" +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_windowevents_c.h" +#include "../../render/SDL_sysrender.h" +#include "../windows/SDL_windows.h" +} + +#include "../../video/winrt/SDL_winrtevents_c.h" +#include "../../video/winrt/SDL_winrtvideo_cpp.h" +#include "SDL_winrtapp_common.h" +#include "SDL_winrtapp_direct3d.h" + + +// Compile-time debugging options: +// To enable, uncomment; to disable, comment them out. +//#define LOG_POINTER_EVENTS 1 +//#define LOG_WINDOW_EVENTS 1 +//#define LOG_ORIENTATION_EVENTS 1 + + +// HACK, DLudwig: record a reference to the global, WinRT 'app'/view. +// SDL/WinRT will use this throughout its code. +// +// TODO, WinRT: consider replacing SDL_WinRTGlobalApp with something +// non-global, such as something created inside +// SDL_InitSubSystem(SDL_INIT_VIDEO), or something inside +// SDL_CreateWindow(). +SDL_WinRTApp ^ SDL_WinRTGlobalApp = nullptr; + +ref class SDLApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource +{ +public: + virtual Windows::ApplicationModel::Core::IFrameworkView^ CreateView(); +}; + +IFrameworkView^ SDLApplicationSource::CreateView() +{ + // TODO, WinRT: see if this function (CreateView) can ever get called + // more than once. For now, just prevent it from ever assigning + // SDL_WinRTGlobalApp more than once. + SDL_assert(!SDL_WinRTGlobalApp); + SDL_WinRTApp ^ app = ref new SDL_WinRTApp(); + if (!SDL_WinRTGlobalApp) + { + SDL_WinRTGlobalApp = app; + } + return app; +} + +int SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **)) +{ + WINRT_SDLAppEntryPoint = mainFunction; + auto direct3DApplicationSource = ref new SDLApplicationSource(); + CoreApplication::Run(direct3DApplicationSource); + return 0; +} + +static void WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const char *oldValue, const char *newValue) +{ + SDL_assert(SDL_strcmp(name, SDL_HINT_ORIENTATIONS) == 0); + + // Start with no orientation flags, then add each in as they're parsed + // from newValue. + unsigned int orientationFlags = 0; + if (newValue) { + std::istringstream tokenizer(newValue); + while (!tokenizer.eof()) { + std::string orientationName; + std::getline(tokenizer, orientationName, ' '); + if (orientationName == "LandscapeLeft") { + orientationFlags |= (unsigned int) DisplayOrientations::LandscapeFlipped; + } else if (orientationName == "LandscapeRight") { + orientationFlags |= (unsigned int) DisplayOrientations::Landscape; + } else if (orientationName == "Portrait") { + orientationFlags |= (unsigned int) DisplayOrientations::Portrait; + } else if (orientationName == "PortraitUpsideDown") { + orientationFlags |= (unsigned int) DisplayOrientations::PortraitFlipped; + } + } + } + + // If no valid orientation flags were specified, use a reasonable set of defaults: + if (!orientationFlags) { + // TODO, WinRT: consider seeing if an app's default orientation flags can be found out via some API call(s). + orientationFlags = (unsigned int) ( \ + DisplayOrientations::Landscape | + DisplayOrientations::LandscapeFlipped | + DisplayOrientations::Portrait | + DisplayOrientations::PortraitFlipped); + } + + // Set the orientation/rotation preferences. Please note that this does + // not constitute a 100%-certain lock of a given set of possible + // orientations. According to Microsoft's documentation on WinRT [1] + // when a device is not capable of being rotated, Windows may ignore + // the orientation preferences, and stick to what the device is capable of + // displaying. + // + // [1] Documentation on the 'InitialRotationPreference' setting for a + // Windows app's manifest file describes how some orientation/rotation + // preferences may be ignored. See + // http://msdn.microsoft.com/en-us/library/windows/apps/hh700343.aspx + // for details. Microsoft's "Display orientation sample" also gives an + // outline of how Windows treats device rotation + // (http://code.msdn.microsoft.com/Display-Orientation-Sample-19a58e93). +#if NTDDI_VERSION > NTDDI_WIN8 + DisplayInformation::AutoRotationPreferences = (DisplayOrientations) orientationFlags; +#else + DisplayProperties::AutoRotationPreferences = (DisplayOrientations) orientationFlags; +#endif +} + +static void +WINRT_ProcessWindowSizeChange() +{ + // Make the new window size be the one true fullscreen mode. + // This change was initially done, in part, to allow the Direct3D 11.1 + // renderer to receive window-resize events as a device rotates. + // Before, rotating a device from landscape, to portrait, and then + // back to landscape would cause the Direct3D 11.1 swap buffer to + // not get resized appropriately. SDL would, on the rotation from + // landscape to portrait, re-resize the SDL window to it's initial + // size (landscape). On the subsequent rotation, SDL would drop the + // window-resize event as it appeared the SDL window didn't change + // size, and the Direct3D 11.1 renderer wouldn't resize its swap + // chain. + SDL_DisplayMode newDisplayMode; + if (WINRT_CalcDisplayModeUsingNativeWindow(&newDisplayMode) != 0) { + return; + } + + // Make note of the old display mode, and it's old driverdata. + SDL_DisplayMode oldDisplayMode; + SDL_zero(oldDisplayMode); + if (WINRT_GlobalSDLVideoDevice) { + oldDisplayMode = WINRT_GlobalSDLVideoDevice->displays[0].desktop_mode; + } + + // Setup the new display mode in the appropriate spots. + if (WINRT_GlobalSDLVideoDevice) { + // Make a full copy of the display mode for display_modes[0], + // one with with a separately malloced 'driverdata' field. + // SDL_VideoQuit(), if called, will attempt to free the driverdata + // fields in 'desktop_mode' and each entry in the 'display_modes' + // array. + if (WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0].driverdata) { + // Free the previous mode's memory + SDL_free(WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0].driverdata); + WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0].driverdata = NULL; + } + if (WINRT_DuplicateDisplayMode(&(WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0]), &newDisplayMode) != 0) { + // Uh oh, something went wrong. A malloc call probably failed. + SDL_free(newDisplayMode.driverdata); + return; + } + + // Install 'newDisplayMode' into 'current_mode' and 'desktop_mode'. + WINRT_GlobalSDLVideoDevice->displays[0].current_mode = newDisplayMode; + WINRT_GlobalSDLVideoDevice->displays[0].desktop_mode = newDisplayMode; + } + + if (WINRT_GlobalSDLWindow) { + // Send a window-resize event to the rest of SDL, and to apps: + SDL_SendWindowEvent( + WINRT_GlobalSDLWindow, + SDL_WINDOWEVENT_RESIZED, + newDisplayMode.w, + newDisplayMode.h); + +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + // HACK: On Windows Phone, make sure that orientation changes from + // Landscape to LandscapeFlipped, Portrait to PortraitFlipped, + // or vice-versa on either of those two, lead to the Direct3D renderer + // getting updated. + const DisplayOrientations oldOrientation = ((SDL_DisplayModeData *)oldDisplayMode.driverdata)->currentOrientation; + const DisplayOrientations newOrientation = ((SDL_DisplayModeData *)newDisplayMode.driverdata)->currentOrientation; + + if ((oldOrientation == DisplayOrientations::Landscape && newOrientation == DisplayOrientations::LandscapeFlipped) || + (oldOrientation == DisplayOrientations::LandscapeFlipped && newOrientation == DisplayOrientations::Landscape) || + (oldOrientation == DisplayOrientations::Portrait && newOrientation == DisplayOrientations::PortraitFlipped) || + (oldOrientation == DisplayOrientations::PortraitFlipped && newOrientation == DisplayOrientations::Portrait)) + { + // One of the reasons this event is getting sent out is because SDL + // will ignore requests to send out SDL_WINDOWEVENT_RESIZED events + // if and when the event size doesn't change (and the Direct3D 11.1 + // renderer doesn't get the memo). + // + // Make sure that the display/window size really didn't change. If + // it did, then a SDL_WINDOWEVENT_SIZE_CHANGED event got sent, and + // the Direct3D 11.1 renderer picked it up, presumably. + if (oldDisplayMode.w == newDisplayMode.w && + oldDisplayMode.h == newDisplayMode.h) + { + SDL_SendWindowEvent( + WINRT_GlobalSDLWindow, + SDL_WINDOWEVENT_SIZE_CHANGED, + newDisplayMode.w, + newDisplayMode.h); + } + } +#endif + } + + // Finally, free the 'driverdata' field of the old 'desktop_mode'. + if (oldDisplayMode.driverdata) { + SDL_free(oldDisplayMode.driverdata); + oldDisplayMode.driverdata = NULL; + } +} + +SDL_WinRTApp::SDL_WinRTApp() : + m_windowClosed(false), + m_windowVisible(true) +{ +} + +void SDL_WinRTApp::Initialize(CoreApplicationView^ applicationView) +{ + applicationView->Activated += + ref new TypedEventHandler(this, &SDL_WinRTApp::OnActivated); + + CoreApplication::Suspending += + ref new EventHandler(this, &SDL_WinRTApp::OnSuspending); + + CoreApplication::Resuming += + ref new EventHandler(this, &SDL_WinRTApp::OnResuming); + + CoreApplication::Exiting += + ref new EventHandler(this, &SDL_WinRTApp::OnExiting); +} + +#if NTDDI_VERSION > NTDDI_WIN8 +void SDL_WinRTApp::OnOrientationChanged(DisplayInformation^ sender, Object^ args) +#else +void SDL_WinRTApp::OnOrientationChanged(Object^ sender) +#endif +{ +#if LOG_ORIENTATION_EVENTS==1 + CoreWindow^ window = CoreWindow::GetForCurrentThread(); + if (window) { + SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, CoreWindow Size={%f,%f}\n", + __FUNCTION__, + (int)DisplayProperties::CurrentOrientation, + (int)DisplayProperties::NativeOrientation, + (int)DisplayProperties::AutoRotationPreferences, + window->Bounds.Width, + window->Bounds.Height); + } else { + SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d\n", + __FUNCTION__, + (int)DisplayProperties::CurrentOrientation, + (int)DisplayProperties::NativeOrientation, + (int)DisplayProperties::AutoRotationPreferences); + } +#endif + +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + // On Windows Phone, treat an orientation change as a change in window size. + // The native window's size doesn't seem to change, however SDL will simulate + // a window size change. + WINRT_ProcessWindowSizeChange(); +#endif +} + +void SDL_WinRTApp::SetWindow(CoreWindow^ window) +{ +#if LOG_WINDOW_EVENTS==1 + SDL_Log("%s, current orientation=%d, native orientation=%d, auto rot. pref=%d, window Size={%f,%f}\n", + __FUNCTION__, + (int)DisplayProperties::CurrentOrientation, + (int)DisplayProperties::NativeOrientation, + (int)DisplayProperties::AutoRotationPreferences, + window->Bounds.Width, + window->Bounds.Height); +#endif + + window->SizeChanged += + ref new TypedEventHandler(this, &SDL_WinRTApp::OnWindowSizeChanged); + + window->VisibilityChanged += + ref new TypedEventHandler(this, &SDL_WinRTApp::OnVisibilityChanged); + + window->Closed += + ref new TypedEventHandler(this, &SDL_WinRTApp::OnWindowClosed); + +#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP + window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0); +#endif + + window->PointerPressed += + ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerPressed); + + window->PointerMoved += + ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerMoved); + + window->PointerReleased += + ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerReleased); + + window->PointerWheelChanged += + ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerWheelChanged); + +#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP + // Retrieves relative-only mouse movements: + Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved += + ref new TypedEventHandler(this, &SDL_WinRTApp::OnMouseMoved); +#endif + + window->KeyDown += + ref new TypedEventHandler(this, &SDL_WinRTApp::OnKeyDown); + + window->KeyUp += + ref new TypedEventHandler(this, &SDL_WinRTApp::OnKeyUp); + +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + HardwareButtons::BackPressed += + ref new EventHandler(this, &SDL_WinRTApp::OnBackButtonPressed); +#endif + +#if NTDDI_VERSION > NTDDI_WIN8 + DisplayInformation::GetForCurrentView()->OrientationChanged += + ref new TypedEventHandler(this, &SDL_WinRTApp::OnOrientationChanged); +#else + DisplayProperties::OrientationChanged += + ref new DisplayPropertiesEventHandler(this, &SDL_WinRTApp::OnOrientationChanged); +#endif + + // Register the hint, SDL_HINT_ORIENTATIONS, with SDL. + // TODO, WinRT: see if an app's default orientation can be found out via WinRT API(s), then set the initial value of SDL_HINT_ORIENTATIONS accordingly. + SDL_AddHintCallback(SDL_HINT_ORIENTATIONS, WINRT_SetDisplayOrientationsPreference, NULL); + +#if WINAPI_FAMILY == WINAPI_FAMILY_APP // for Windows 8/8.1/RT apps... (and not Phone apps) + // Make sure we know when a user has opened the app's settings pane. + // This is needed in order to display a privacy policy, which needs + // to be done for network-enabled apps, as per Windows Store requirements. + using namespace Windows::UI::ApplicationSettings; + SettingsPane::GetForCurrentView()->CommandsRequested += + ref new TypedEventHandler + (this, &SDL_WinRTApp::OnSettingsPaneCommandsRequested); +#endif +} + +void SDL_WinRTApp::Load(Platform::String^ entryPoint) +{ +} + +void SDL_WinRTApp::Run() +{ + SDL_SetMainReady(); + if (WINRT_SDLAppEntryPoint) + { + // TODO, WinRT: pass the C-style main() a reasonably realistic + // representation of command line arguments. + int argc = 0; + char **argv = NULL; + WINRT_SDLAppEntryPoint(argc, argv); + } +} + +void SDL_WinRTApp::PumpEvents() +{ + if (!m_windowClosed) + { + if (m_windowVisible) + { + CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); + } + else + { + CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessOneAndAllPending); + } + } +} + +void SDL_WinRTApp::Uninitialize() +{ +} + +#if WINAPI_FAMILY == WINAPI_FAMILY_APP +void SDL_WinRTApp::OnSettingsPaneCommandsRequested( + Windows::UI::ApplicationSettings::SettingsPane ^p, + Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs ^args) +{ + using namespace Platform; + using namespace Windows::UI::ApplicationSettings; + using namespace Windows::UI::Popups; + + String ^privacyPolicyURL = nullptr; // a URL to an app's Privacy Policy + String ^privacyPolicyLabel = nullptr; // label/link text + const char *tmpHintValue = NULL; // SDL_GetHint-retrieved value, used immediately + wchar_t *tmpStr = NULL; // used for UTF8 to UCS2 conversion + + // Setup a 'Privacy Policy' link, if one is available (via SDL_GetHint): + tmpHintValue = SDL_GetHint(SDL_HINT_WINRT_PRIVACY_POLICY_URL); + if (tmpHintValue && tmpHintValue[0] != '\0') { + // Convert the privacy policy's URL to UCS2: + tmpStr = WIN_UTF8ToString(tmpHintValue); + privacyPolicyURL = ref new String(tmpStr); + SDL_free(tmpStr); + + // Optionally retrieve custom label-text for the link. If this isn't + // available, a default value will be used instead. + tmpHintValue = SDL_GetHint(SDL_HINT_WINRT_PRIVACY_POLICY_LABEL); + if (tmpHintValue && tmpHintValue[0] != '\0') { + tmpStr = WIN_UTF8ToString(tmpHintValue); + privacyPolicyLabel = ref new String(tmpStr); + SDL_free(tmpStr); + } else { + privacyPolicyLabel = ref new String(L"Privacy Policy"); + } + + // Register the link, along with a handler to be called if and when it is + // clicked: + auto cmd = ref new SettingsCommand(L"privacyPolicy", privacyPolicyLabel, + ref new UICommandInvokedHandler([=](IUICommand ^) { + Windows::System::Launcher::LaunchUriAsync(ref new Uri(privacyPolicyURL)); + })); + args->Request->ApplicationCommands->Append(cmd); + } +} +#endif // if WINAPI_FAMILY == WINAPI_FAMILY_APP + +void SDL_WinRTApp::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args) +{ +#if LOG_WINDOW_EVENTS==1 + SDL_Log("%s, size={%f,%f}, current orientation=%d, native orientation=%d, auto rot. pref=%d, WINRT_GlobalSDLWindow?=%s\n", + __FUNCTION__, + args->Size.Width, args->Size.Height, + (int)DisplayProperties::CurrentOrientation, + (int)DisplayProperties::NativeOrientation, + (int)DisplayProperties::AutoRotationPreferences, + (WINRT_GlobalSDLWindow ? "yes" : "no")); +#endif + + WINRT_ProcessWindowSizeChange(); +} + +void SDL_WinRTApp::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args) +{ +#if LOG_WINDOW_EVENTS==1 + SDL_Log("%s, visible?=%s, WINRT_GlobalSDLWindow?=%s\n", + __FUNCTION__, + (args->Visible ? "yes" : "no"), + (WINRT_GlobalSDLWindow ? "yes" : "no")); +#endif + + m_windowVisible = args->Visible; + if (WINRT_GlobalSDLWindow) { + SDL_bool wasSDLWindowSurfaceValid = WINRT_GlobalSDLWindow->surface_valid; + + if (args->Visible) { + SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_SHOWN, 0, 0); + } else { + SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_HIDDEN, 0, 0); + } + + // HACK: Prevent SDL's window-hide handling code, which currently + // triggers a fake window resize (possibly erronously), from + // marking the SDL window's surface as invalid. + // + // A better solution to this probably involves figuring out if the + // fake window resize can be prevented. + WINRT_GlobalSDLWindow->surface_valid = wasSDLWindowSurfaceValid; + } +} + +void SDL_WinRTApp::OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args) +{ +#if LOG_WINDOW_EVENTS==1 + SDL_Log("%s\n", __FUNCTION__); +#endif + m_windowClosed = true; +} + +void SDL_WinRTApp::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^ args) +{ + CoreWindow::GetForCurrentThread()->Activate(); +} + +static int SDLCALL RemoveAppSuspendAndResumeEvents(void * userdata, SDL_Event * event) +{ + if (event->type == SDL_WINDOWEVENT) + { + switch (event->window.event) + { + case SDL_WINDOWEVENT_MINIMIZED: + case SDL_WINDOWEVENT_RESTORED: + // Return 0 to indicate that the event should be removed from the + // event queue: + return 0; + default: + break; + } + } + + // Return 1 to indicate that the event should stay in the event queue: + return 1; +} + +void SDL_WinRTApp::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args) +{ + // Save app state asynchronously after requesting a deferral. Holding a deferral + // indicates that the application is busy performing suspending operations. Be + // aware that a deferral may not be held indefinitely. After about five seconds, + // the app will be forced to exit. + SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral(); + create_task([this, deferral]() + { + // Send a window-minimized event immediately to observers. + // CoreDispatcher::ProcessEvents, which is the backbone on which + // SDL_WinRTApp::PumpEvents is built, will not return to its caller + // once it sends out a suspend event. Any events posted to SDL's + // event queue won't get received until the WinRT app is resumed. + // SDL_AddEventWatch() may be used to receive app-suspend events on + // WinRT. + // + // In order to prevent app-suspend events from being received twice: + // first via a callback passed to SDL_AddEventWatch, and second via + // SDL's event queue, the event will be sent to SDL, then immediately + // removed from the queue. + if (WINRT_GlobalSDLWindow) + { + SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0); // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently) + SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0); + } + + SDL_SendAppEvent(SDL_APP_WILLENTERBACKGROUND); + SDL_SendAppEvent(SDL_APP_DIDENTERBACKGROUND); + + deferral->Complete(); + }); +} + +void SDL_WinRTApp::OnResuming(Platform::Object^ sender, Platform::Object^ args) +{ + SDL_SendAppEvent(SDL_APP_WILLENTERFOREGROUND); + SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND); + + // Restore any data or state that was unloaded on suspend. By default, data + // and state are persisted when resuming from suspend. Note that this event + // does not occur if the app was previously terminated. + if (WINRT_GlobalSDLWindow) + { + SDL_SendWindowEvent(WINRT_GlobalSDLWindow, SDL_WINDOWEVENT_RESTORED, 0, 0); // TODO: see if SDL_WINDOWEVENT_SIZE_CHANGED should be getting triggered here (it is, currently) + + // Remove the app-resume event from the queue, as is done with the + // app-suspend event. + // + // TODO, WinRT: consider posting this event to the queue even though + // its counterpart, the app-suspend event, effectively has to be + // processed immediately. + SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0); + } +} + +void SDL_WinRTApp::OnExiting(Platform::Object^ sender, Platform::Object^ args) +{ + SDL_SendAppEvent(SDL_APP_TERMINATING); +} + +static void +WINRT_LogPointerEvent(const char * header, Windows::UI::Core::PointerEventArgs ^ args, Windows::Foundation::Point transformedPoint) +{ + Windows::UI::Input::PointerPoint ^ pt = args->CurrentPoint; + SDL_Log("%s: Position={%f,%f}, Transformed Pos={%f, %f}, MouseWheelDelta=%d, FrameId=%d, PointerId=%d, SDL button=%d\n", + header, + pt->Position.X, pt->Position.Y, + transformedPoint.X, transformedPoint.Y, + pt->Properties->MouseWheelDelta, + pt->FrameId, + pt->PointerId, + WINRT_GetSDLButtonForPointerPoint(pt)); +} + +void SDL_WinRTApp::OnPointerPressed(CoreWindow^ sender, PointerEventArgs^ args) +{ +#if LOG_POINTER_EVENTS + WINRT_LogPointerEvent("pointer pressed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize)); +#endif + + WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint); +} + +void SDL_WinRTApp::OnPointerMoved(CoreWindow^ sender, PointerEventArgs^ args) +{ +#if LOG_POINTER_EVENTS + WINRT_LogPointerEvent("pointer moved", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize)); +#endif + + WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint); +} + +void SDL_WinRTApp::OnPointerReleased(CoreWindow^ sender, PointerEventArgs^ args) +{ +#if LOG_POINTER_EVENTS + WINRT_LogPointerEvent("pointer released", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize)); +#endif + + WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint); +} + +void SDL_WinRTApp::OnPointerWheelChanged(CoreWindow^ sender, PointerEventArgs^ args) +{ +#if LOG_POINTER_EVENTS + WINRT_LogPointerEvent("pointer wheel changed", args, WINRT_TransformCursorPosition(WINRT_GlobalSDLWindow, args->CurrentPoint->Position, TransformToSDLWindowSize)); +#endif + + WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->CurrentPoint); +} + +void SDL_WinRTApp::OnMouseMoved(MouseDevice^ mouseDevice, MouseEventArgs^ args) +{ + WINRT_ProcessMouseMovedEvent(WINRT_GlobalSDLWindow, args); +} + +void SDL_WinRTApp::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args) +{ + WINRT_ProcessKeyDownEvent(args); +} + +void SDL_WinRTApp::OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args) +{ + WINRT_ProcessKeyUpEvent(args); +} + +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +void SDL_WinRTApp::OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args) +{ + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_AC_BACK); + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_AC_BACK); + + const char *hint = SDL_GetHint(SDL_HINT_WINRT_HANDLE_BACK_BUTTON); + if (hint) { + if (*hint == '1') { + args->Handled = true; + } + } +} +#endif + diff --git a/jni/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_direct3d.h b/jni/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_direct3d.h new file mode 100644 index 00000000..6dc9a6c8 --- /dev/null +++ b/jni/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_direct3d.h @@ -0,0 +1,80 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include + +extern int SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **)); + +ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView +{ +public: + SDL_WinRTApp(); + + // IFrameworkView Methods. + virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView); + virtual void SetWindow(Windows::UI::Core::CoreWindow^ window); + virtual void Load(Platform::String^ entryPoint); + virtual void Run(); + virtual void Uninitialize(); + +internal: + // SDL-specific methods + void PumpEvents(); + +protected: + // Event Handlers. + +#if WINAPI_FAMILY == WINAPI_FAMILY_APP // for Windows 8/8.1/RT apps... (and not Phone apps) + void OnSettingsPaneCommandsRequested( + Windows::UI::ApplicationSettings::SettingsPane ^p, + Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs ^args); +#endif // if WINAPI_FAMILY == WINAPI_FAMILY_APP + +#if NTDDI_VERSION > NTDDI_WIN8 + void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args); +#else + void OnOrientationChanged(Platform::Object^ sender); +#endif + void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args); + void OnLogicalDpiChanged(Platform::Object^ sender); + void OnActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args); + void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args); + void OnResuming(Platform::Object^ sender, Platform::Object^ args); + void OnExiting(Platform::Object^ sender, Platform::Object^ args); + void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args); + void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args); + void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); + void OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); + void OnPointerWheelChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); + void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); + void OnMouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args); + void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args); + void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args); + +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + void OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args); +#endif + +private: + bool m_windowClosed; + bool m_windowVisible; +}; + +extern SDL_WinRTApp ^ SDL_WinRTGlobalApp; diff --git a/jni/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_xaml.cpp b/jni/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_xaml.cpp new file mode 100644 index 00000000..38694e11 --- /dev/null +++ b/jni/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_xaml.cpp @@ -0,0 +1,160 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* Windows includes */ +#include +#include + +#if WINAPI_FAMILY == WINAPI_FAMILY_APP +#include +#endif + + +/* SDL includes */ +#include "../../SDL_internal.h" +#include "SDL.h" +#include "../../video/winrt/SDL_winrtevents_c.h" +#include "../../video/winrt/SDL_winrtvideo_cpp.h" +#include "SDL_winrtapp_common.h" +#include "SDL_winrtapp_xaml.h" + + + +/* SDL-internal globals: */ +SDL_bool WINRT_XAMLWasEnabled = SDL_FALSE; + +#if WINAPI_FAMILY == WINAPI_FAMILY_APP +extern "C" +ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNative = NULL; +static Windows::Foundation::EventRegistrationToken WINRT_XAMLAppEventToken; +#endif + + +/* + * Input event handlers (XAML) + */ +#if WINAPI_FAMILY == WINAPI_FAMILY_APP + +static void +WINRT_OnPointerPressedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args) +{ + WINRT_ProcessPointerPressedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); +} + +static void +WINRT_OnPointerMovedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args) +{ + WINRT_ProcessPointerMovedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); +} + +static void +WINRT_OnPointerReleasedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args) +{ + WINRT_ProcessPointerReleasedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); +} + +static void +WINRT_OnPointerWheelChangedViaXAML(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ args) +{ + WINRT_ProcessPointerWheelChangedEvent(WINRT_GlobalSDLWindow, args->GetCurrentPoint(nullptr)); +} + +#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP + + +/* + * XAML-to-SDL Rendering Callback + */ +#if WINAPI_FAMILY == WINAPI_FAMILY_APP + +static void +WINRT_OnRenderViaXAML(_In_ Platform::Object^ sender, _In_ Platform::Object^ args) +{ + WINRT_CycleXAMLThread(); +} + +#endif // WINAPI_FAMILY == WINAPI_FAMILY_APP + + +/* + * SDL + XAML Initialization + */ + +int +SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void * backgroundPanelAsIInspectable) +{ +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + return SDL_SetError("XAML support is not yet available in Windows Phone."); +#else + // Declare C++/CX namespaces: + using namespace Platform; + using namespace Windows::Foundation; + using namespace Windows::UI::Core; + using namespace Windows::UI::Xaml; + using namespace Windows::UI::Xaml::Controls; + using namespace Windows::UI::Xaml::Input; + using namespace Windows::UI::Xaml::Media; + + // Make sure we have a valid XAML element (to draw onto): + if ( ! backgroundPanelAsIInspectable) { + return SDL_SetError("'backgroundPanelAsIInspectable' can't be NULL"); + } + + Platform::Object ^ backgroundPanel = reinterpret_cast((IInspectable *) backgroundPanelAsIInspectable); + SwapChainBackgroundPanel ^swapChainBackgroundPanel = dynamic_cast(backgroundPanel); + if ( ! swapChainBackgroundPanel) { + return SDL_SetError("An unknown or unsupported type of XAML control was specified."); + } + + // Setup event handlers: + swapChainBackgroundPanel->PointerPressed += ref new PointerEventHandler(WINRT_OnPointerPressedViaXAML); + swapChainBackgroundPanel->PointerReleased += ref new PointerEventHandler(WINRT_OnPointerReleasedViaXAML); + swapChainBackgroundPanel->PointerWheelChanged += ref new PointerEventHandler(WINRT_OnPointerWheelChangedViaXAML); + swapChainBackgroundPanel->PointerMoved += ref new PointerEventHandler(WINRT_OnPointerMovedViaXAML); + + // Setup for rendering: + IInspectable *panelInspectable = (IInspectable*) reinterpret_cast(swapChainBackgroundPanel); + panelInspectable->QueryInterface(__uuidof(ISwapChainBackgroundPanelNative), (void **)&WINRT_GlobalSwapChainBackgroundPanelNative); + + WINRT_XAMLAppEventToken = CompositionTarget::Rendering::add(ref new EventHandler(WINRT_OnRenderViaXAML)); + + // Make sure the app is ready to call the SDL-centric main() function: + WINRT_SDLAppEntryPoint = mainFunction; + SDL_SetMainReady(); + + // Make sure video-init knows that we're initializing XAML: + SDL_bool oldXAMLWasEnabledValue = WINRT_XAMLWasEnabled; + WINRT_XAMLWasEnabled = SDL_TRUE; + + // Make sure video modes are detected now, while we still have access to the WinRT + // CoreWindow. WinRT will not allow the app's CoreWindow to be accessed via the + // SDL/WinRT thread. + if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { + // SDL_InitSubSystem will, on error, set the SDL error. Let that propogate to + // the caller to here: + WINRT_XAMLWasEnabled = oldXAMLWasEnabledValue; + return -1; + } + + // All done, for now. + return 0; +#endif // WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP / else +} diff --git a/jni/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_xaml.h b/jni/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_xaml.h new file mode 100644 index 00000000..2296475b --- /dev/null +++ b/jni/SDL2-2.0.3/src/core/winrt/SDL_winrtapp_xaml.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_winrtapp_xaml_h +#define _SDL_winrtapp_xaml_h + +#include "SDL_types.h" + +#ifdef __cplusplus +extern SDL_bool WINRT_XAMLWasEnabled; +extern int SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void * backgroundPanelAsIInspectable); +#endif // ifdef __cplusplus + +#endif // ifndef _SDL_winrtapp_xaml_h diff --git a/jni/SDL2-2.0.1/src/cpuinfo/SDL_cpuinfo.c b/jni/SDL2-2.0.3/src/cpuinfo/SDL_cpuinfo.c similarity index 94% rename from jni/SDL2-2.0.1/src/cpuinfo/SDL_cpuinfo.c rename to jni/SDL2-2.0.3/src/cpuinfo/SDL_cpuinfo.c index c73dd80c..6a529ae0 100644 --- a/jni/SDL2-2.0.1/src/cpuinfo/SDL_cpuinfo.c +++ b/jni/SDL2-2.0.3/src/cpuinfo/SDL_cpuinfo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -18,7 +18,11 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ +#ifdef TEST_MAIN +#include "SDL_config.h" +#else #include "../SDL_internal.h" +#endif #if defined(__WIN32__) #include "../core/windows/SDL_windows.h" @@ -55,6 +59,7 @@ #define CPU_HAS_SSE3 0x00000040 #define CPU_HAS_SSE41 0x00000100 #define CPU_HAS_SSE42 0x00000200 +#define CPU_HAS_AVX 0x00000400 #if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__ && !__OpenBSD__ /* This is the brute force way of detecting instruction sets... @@ -93,7 +98,7 @@ CPU_haveCPUID(void) ); #elif defined(__GNUC__) && defined(__x86_64__) /* Technically, if this is being compiled under __x86_64__ then it has -CPUid by definition. But it's nice to be able to prove it. :) */ + CPUid by definition. But it's nice to be able to prove it. :) */ __asm__ ( " pushfq # Get original EFLAGS \n" " popq %%rax \n" @@ -126,6 +131,8 @@ CPUid by definition. But it's nice to be able to prove it. :) */ mov has_CPUID,1 ; We have CPUID support done: } +#elif defined(_MSC_VER) && defined(_M_X64) + has_CPUID = 1; #elif defined(__sun) && defined(__i386) __asm ( " pushfl \n" @@ -186,7 +193,17 @@ done: __asm mov b, ebx \ __asm mov c, ecx \ __asm mov d, edx \ - } +} +#elif defined(_MSC_VER) && defined(_M_X64) +#define cpuid(func, a, b, c, d) \ +{ \ + int CPUInfo[4]; \ + __cpuid(CPUInfo, func); \ + a = CPUInfo[0]; \ + b = CPUInfo[1]; \ + c = CPUInfo[2]; \ + d = CPUInfo[3]; \ +} #else #define cpuid(func, a, b, c, d) \ a = b = c = d = 0 @@ -329,6 +346,21 @@ CPU_haveSSE42(void) return 0; } +static SDL_INLINE int +CPU_haveAVX(void) +{ + if (CPU_haveCPUID()) { + int a, b, c, d; + + cpuid(1, a, b, c, d); + if (a >= 1) { + cpuid(1, a, b, c, d); + return (c & 0x10000000); + } + } + return 0; +} + static int SDL_CPUCount = 0; int @@ -523,6 +555,9 @@ SDL_GetCPUFeatures(void) if (CPU_haveSSE42()) { SDL_CPUFeatures |= CPU_HAS_SSE42; } + if (CPU_haveAVX()) { + SDL_CPUFeatures |= CPU_HAS_AVX; + } } return SDL_CPUFeatures; } @@ -608,6 +643,15 @@ SDL_HasSSE42(void) return SDL_FALSE; } +SDL_bool +SDL_HasAVX(void) +{ + if (SDL_GetCPUFeatures() & CPU_HAS_AVX) { + return SDL_TRUE; + } + return SDL_FALSE; +} + static int SDL_SystemRAM = 0; int @@ -621,7 +665,7 @@ SDL_GetSystemRAM(void) #endif #ifdef HAVE_SYSCTLBYNAME if (SDL_SystemRAM <= 0) { -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #ifdef HW_REALMEM int mib[2] = {CTL_HW, HW_REALMEM}; #else @@ -630,7 +674,7 @@ SDL_GetSystemRAM(void) #endif /* HW_REALMEM */ #else int mib[2] = {CTL_HW, HW_MEMSIZE}; -#endif /* __FreeBSD__ */ +#endif /* __FreeBSD__ || __FreeBSD_kernel__ */ Uint64 memsize = 0; size_t len = sizeof(memsize); @@ -673,6 +717,7 @@ main() printf("SSE3: %d\n", SDL_HasSSE3()); printf("SSE4.1: %d\n", SDL_HasSSE41()); printf("SSE4.2: %d\n", SDL_HasSSE42()); + printf("AVX: %d\n", SDL_HasAVX()); printf("RAM: %d MB\n", SDL_GetSystemRAM()); return 0; } diff --git a/jni/SDL2-2.0.1/src/dynapi/SDL_dynapi.c b/jni/SDL2-2.0.3/src/dynapi/SDL_dynapi.c similarity index 99% rename from jni/SDL2-2.0.1/src/dynapi/SDL_dynapi.c rename to jni/SDL2-2.0.3/src/dynapi/SDL_dynapi.c index 8266185c..220ec9ba 100644 --- a/jni/SDL2-2.0.1/src/dynapi/SDL_dynapi.c +++ b/jni/SDL2-2.0.3/src/dynapi/SDL_dynapi.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/dynapi/SDL_dynapi.h b/jni/SDL2-2.0.3/src/dynapi/SDL_dynapi.h similarity index 91% rename from jni/SDL2-2.0.1/src/dynapi/SDL_dynapi.h rename to jni/SDL2-2.0.3/src/dynapi/SDL_dynapi.h index 9801ba1c..d318552f 100644 --- a/jni/SDL2-2.0.1/src/dynapi/SDL_dynapi.h +++ b/jni/SDL2-2.0.3/src/dynapi/SDL_dynapi.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -45,6 +45,8 @@ #if TARGET_OS_IPHONE /* probably not useful on iOS. */ #define SDL_DYNAMIC_API 0 +#elif SDL_BUILDING_WINRT /* probaly not useful on WinRT, given current .dll loading restrictions */ +#define SDL_DYNAMIC_API 0 #else /* everyone else. */ #define SDL_DYNAMIC_API 1 #endif diff --git a/jni/SDL2-2.0.1/src/dynapi/SDL_dynapi_overrides.h b/jni/SDL2-2.0.3/src/dynapi/SDL_dynapi_overrides.h similarity index 98% rename from jni/SDL2-2.0.1/src/dynapi/SDL_dynapi_overrides.h rename to jni/SDL2-2.0.3/src/dynapi/SDL_dynapi_overrides.h index 613582d1..5ae7927f 100644 --- a/jni/SDL2-2.0.1/src/dynapi/SDL_dynapi_overrides.h +++ b/jni/SDL2-2.0.3/src/dynapi/SDL_dynapi_overrides.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -570,3 +570,8 @@ #define SDL_GL_DeleteContext SDL_GL_DeleteContext_REAL #define SDL_vsscanf SDL_vsscanf_REAL #define SDL_GameControllerAddMappingsFromRW SDL_GameControllerAddMappingsFromRW_REAL +#define SDL_GL_ResetAttributes SDL_GL_ResetAttributes_REAL +#define SDL_HasAVX SDL_HasAVX_REAL +#define SDL_GetDefaultAssertionHandler SDL_GetDefaultAssertionHandler_REAL +#define SDL_GetAssertionHandler SDL_GetAssertionHandler_REAL +#define SDL_DXGIGetOutputInfo SDL_DXGIGetOutputInfo_REAL diff --git a/jni/SDL2-2.0.1/src/dynapi/SDL_dynapi_procs.h b/jni/SDL2-2.0.3/src/dynapi/SDL_dynapi_procs.h similarity index 99% rename from jni/SDL2-2.0.1/src/dynapi/SDL_dynapi_procs.h rename to jni/SDL2-2.0.3/src/dynapi/SDL_dynapi_procs.h index cf34efc9..301aff38 100644 --- a/jni/SDL2-2.0.1/src/dynapi/SDL_dynapi_procs.h +++ b/jni/SDL2-2.0.3/src/dynapi/SDL_dynapi_procs.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -599,3 +599,10 @@ SDL_DYNAPI_PROC(void,SDL_GL_SwapWindow,(SDL_Window *a),(a),) SDL_DYNAPI_PROC(void,SDL_GL_DeleteContext,(SDL_GLContext a),(a),) SDL_DYNAPI_PROC(int,SDL_vsscanf,(const char *a, const char *b, va_list c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_GameControllerAddMappingsFromRW,(SDL_RWops *a, int b),(a,b),return) +SDL_DYNAPI_PROC(void,SDL_GL_ResetAttributes,(void),(),) +SDL_DYNAPI_PROC(SDL_bool,SDL_HasAVX,(void),(),return) +SDL_DYNAPI_PROC(SDL_AssertionHandler,SDL_GetDefaultAssertionHandler,(void),(),return) +SDL_DYNAPI_PROC(SDL_AssertionHandler,SDL_GetAssertionHandler,(void **a),(a),return) +#ifdef __WIN32__ +SDL_DYNAPI_PROC(void,SDL_DXGIGetOutputInfo,(int a,int *b, int *c),(a,b,c),) +#endif diff --git a/jni/SDL2-2.0.1/src/dynapi/gendynapi.pl b/jni/SDL2-2.0.3/src/dynapi/gendynapi.pl similarity index 98% rename from jni/SDL2-2.0.1/src/dynapi/gendynapi.pl rename to jni/SDL2-2.0.3/src/dynapi/gendynapi.pl index b76afbd8..091a08c7 100755 --- a/jni/SDL2-2.0.1/src/dynapi/gendynapi.pl +++ b/jni/SDL2-2.0.3/src/dynapi/gendynapi.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # Simple DirectMedia Layer -# Copyright (C) 1997-2013 Sam Lantinga +# Copyright (C) 1997-2014 Sam Lantinga # # This software is provided 'as-is', without any express or implied # warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/SDL_clipboardevents.c b/jni/SDL2-2.0.3/src/events/SDL_clipboardevents.c similarity index 95% rename from jni/SDL2-2.0.1/src/events/SDL_clipboardevents.c rename to jni/SDL2-2.0.3/src/events/SDL_clipboardevents.c index 2a2f5ae0..3ef7bed2 100644 --- a/jni/SDL2-2.0.1/src/events/SDL_clipboardevents.c +++ b/jni/SDL2-2.0.3/src/events/SDL_clipboardevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/SDL_clipboardevents_c.h b/jni/SDL2-2.0.3/src/events/SDL_clipboardevents_c.h similarity index 94% rename from jni/SDL2-2.0.1/src/events/SDL_clipboardevents_c.h rename to jni/SDL2-2.0.3/src/events/SDL_clipboardevents_c.h index 9cd19538..c71da2a4 100644 --- a/jni/SDL2-2.0.1/src/events/SDL_clipboardevents_c.h +++ b/jni/SDL2-2.0.3/src/events/SDL_clipboardevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/SDL_dropevents.c b/jni/SDL2-2.0.3/src/events/SDL_dropevents.c similarity index 95% rename from jni/SDL2-2.0.1/src/events/SDL_dropevents.c rename to jni/SDL2-2.0.3/src/events/SDL_dropevents.c index 553d1c3f..4830d14f 100644 --- a/jni/SDL2-2.0.1/src/events/SDL_dropevents.c +++ b/jni/SDL2-2.0.3/src/events/SDL_dropevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/SDL_dropevents_c.h b/jni/SDL2-2.0.3/src/events/SDL_dropevents_c.h similarity index 94% rename from jni/SDL2-2.0.1/src/events/SDL_dropevents_c.h rename to jni/SDL2-2.0.3/src/events/SDL_dropevents_c.h index 0458653a..cb5e1dc5 100644 --- a/jni/SDL2-2.0.1/src/events/SDL_dropevents_c.h +++ b/jni/SDL2-2.0.3/src/events/SDL_dropevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/SDL_events.c b/jni/SDL2-2.0.3/src/events/SDL_events.c similarity index 97% rename from jni/SDL2-2.0.1/src/events/SDL_events.c rename to jni/SDL2-2.0.3/src/events/SDL_events.c index 0510b518..7a98c302 100644 --- a/jni/SDL2-2.0.1/src/events/SDL_events.c +++ b/jni/SDL2-2.0.3/src/events/SDL_events.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -503,17 +503,28 @@ SDL_GetEventFilter(SDL_EventFilter * filter, void **userdata) void SDL_AddEventWatch(SDL_EventFilter filter, void *userdata) { - SDL_EventWatcher *watcher; + SDL_EventWatcher *watcher, *tail; watcher = (SDL_EventWatcher *)SDL_malloc(sizeof(*watcher)); if (!watcher) { /* Uh oh... */ return; } + + /* create the watcher */ watcher->callback = filter; watcher->userdata = userdata; - watcher->next = SDL_event_watchers; - SDL_event_watchers = watcher; + watcher->next = NULL; + + /* add the watcher to the end of the list */ + if (SDL_event_watchers) { + for (tail = SDL_event_watchers; tail->next; tail = tail->next) { + continue; + } + tail->next = watcher; + } else { + SDL_event_watchers = watcher; + } } /* FIXME: This is not thread-safe yet */ diff --git a/jni/SDL2-2.0.1/src/events/SDL_events_c.h b/jni/SDL2-2.0.3/src/events/SDL_events_c.h similarity index 96% rename from jni/SDL2-2.0.1/src/events/SDL_events_c.h rename to jni/SDL2-2.0.3/src/events/SDL_events_c.h index 7ddda192..11d6e304 100644 --- a/jni/SDL2-2.0.1/src/events/SDL_events_c.h +++ b/jni/SDL2-2.0.3/src/events/SDL_events_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/SDL_gesture.c b/jni/SDL2-2.0.3/src/events/SDL_gesture.c similarity index 98% rename from jni/SDL2-2.0.1/src/events/SDL_gesture.c rename to jni/SDL2-2.0.3/src/events/SDL_gesture.c index 6841f730..a47ab7d1 100644 --- a/jni/SDL2-2.0.1/src/events/SDL_gesture.c +++ b/jni/SDL2-2.0.3/src/events/SDL_gesture.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -418,13 +418,8 @@ int SDL_GestureAddTouch(SDL_TouchID touchId) SDL_gestureTouch = gestureTouch; - SDL_gestureTouch[SDL_numGestureTouches].numDownFingers = 0; + SDL_zero(SDL_gestureTouch[SDL_numGestureTouches]); SDL_gestureTouch[SDL_numGestureTouches].id = touchId; - - SDL_gestureTouch[SDL_numGestureTouches].numDollarTemplates = 0; - - SDL_gestureTouch[SDL_numGestureTouches].recording = SDL_FALSE; - SDL_numGestureTouches++; return 0; } diff --git a/jni/SDL2-2.0.1/src/events/SDL_gesture_c.h b/jni/SDL2-2.0.3/src/events/SDL_gesture_c.h similarity index 95% rename from jni/SDL2-2.0.1/src/events/SDL_gesture_c.h rename to jni/SDL2-2.0.3/src/events/SDL_gesture_c.h index d172cba4..3f1ed9b1 100644 --- a/jni/SDL2-2.0.1/src/events/SDL_gesture_c.h +++ b/jni/SDL2-2.0.3/src/events/SDL_gesture_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/SDL_keyboard.c b/jni/SDL2-2.0.3/src/events/SDL_keyboard.c similarity index 99% rename from jni/SDL2-2.0.1/src/events/SDL_keyboard.c rename to jni/SDL2-2.0.3/src/events/SDL_keyboard.c index b56a4661..d5443893 100644 --- a/jni/SDL2-2.0.1/src/events/SDL_keyboard.c +++ b/jni/SDL2-2.0.3/src/events/SDL_keyboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/SDL_keyboard_c.h b/jni/SDL2-2.0.3/src/events/SDL_keyboard_c.h similarity index 97% rename from jni/SDL2-2.0.1/src/events/SDL_keyboard_c.h rename to jni/SDL2-2.0.3/src/events/SDL_keyboard_c.h index 5a99d971..05b52538 100644 --- a/jni/SDL2-2.0.1/src/events/SDL_keyboard_c.h +++ b/jni/SDL2-2.0.3/src/events/SDL_keyboard_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/SDL_mouse.c b/jni/SDL2-2.0.3/src/events/SDL_mouse.c similarity index 98% rename from jni/SDL2-2.0.1/src/events/SDL_mouse.c rename to jni/SDL2-2.0.3/src/events/SDL_mouse.c index 0d17670c..236b8c54 100644 --- a/jni/SDL2-2.0.1/src/events/SDL_mouse.c +++ b/jni/SDL2-2.0.3/src/events/SDL_mouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -538,7 +538,10 @@ SDL_SetRelativeMouseMode(SDL_bool enabled) } else if (enabled && ShouldUseRelativeModeWarp(mouse)) { mouse->relative_mode_warp = SDL_TRUE; } else if (mouse->SetRelativeMouseMode(enabled) < 0) { - return -1; + if (enabled) { + // Fall back to warp mode if native relative mode failed + mouse->relative_mode_warp = SDL_TRUE; + } } mouse->relative_mode = enabled; diff --git a/jni/SDL2-2.0.1/src/events/SDL_mouse_c.h b/jni/SDL2-2.0.3/src/events/SDL_mouse_c.h similarity index 98% rename from jni/SDL2-2.0.1/src/events/SDL_mouse_c.h rename to jni/SDL2-2.0.3/src/events/SDL_mouse_c.h index a8b8aa5e..e0d917cb 100644 --- a/jni/SDL2-2.0.1/src/events/SDL_mouse_c.h +++ b/jni/SDL2-2.0.3/src/events/SDL_mouse_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/SDL_quit.c b/jni/SDL2-2.0.3/src/events/SDL_quit.c similarity index 98% rename from jni/SDL2-2.0.1/src/events/SDL_quit.c rename to jni/SDL2-2.0.3/src/events/SDL_quit.c index 14cf89dc..db7af98f 100644 --- a/jni/SDL2-2.0.1/src/events/SDL_quit.c +++ b/jni/SDL2-2.0.3/src/events/SDL_quit.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/SDL_sysevents.h b/jni/SDL2-2.0.3/src/events/SDL_sysevents.h similarity index 95% rename from jni/SDL2-2.0.1/src/events/SDL_sysevents.h rename to jni/SDL2-2.0.3/src/events/SDL_sysevents.h index a25247f5..a5be7bc3 100644 --- a/jni/SDL2-2.0.1/src/events/SDL_sysevents.h +++ b/jni/SDL2-2.0.3/src/events/SDL_sysevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/SDL_touch.c b/jni/SDL2-2.0.3/src/events/SDL_touch.c similarity index 99% rename from jni/SDL2-2.0.1/src/events/SDL_touch.c rename to jni/SDL2-2.0.3/src/events/SDL_touch.c index d37cee2d..14a337a9 100644 --- a/jni/SDL2-2.0.1/src/events/SDL_touch.c +++ b/jni/SDL2-2.0.3/src/events/SDL_touch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/SDL_touch_c.h b/jni/SDL2-2.0.3/src/events/SDL_touch_c.h similarity index 97% rename from jni/SDL2-2.0.1/src/events/SDL_touch_c.h rename to jni/SDL2-2.0.3/src/events/SDL_touch_c.h index 8786c61e..f9781789 100644 --- a/jni/SDL2-2.0.1/src/events/SDL_touch_c.h +++ b/jni/SDL2-2.0.3/src/events/SDL_touch_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/SDL_windowevents.c b/jni/SDL2-2.0.3/src/events/SDL_windowevents.c similarity index 99% rename from jni/SDL2-2.0.1/src/events/SDL_windowevents.c rename to jni/SDL2-2.0.3/src/events/SDL_windowevents.c index 28041c24..146cbc54 100644 --- a/jni/SDL2-2.0.1/src/events/SDL_windowevents.c +++ b/jni/SDL2-2.0.3/src/events/SDL_windowevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/SDL_windowevents_c.h b/jni/SDL2-2.0.3/src/events/SDL_windowevents_c.h similarity index 95% rename from jni/SDL2-2.0.1/src/events/SDL_windowevents_c.h rename to jni/SDL2-2.0.3/src/events/SDL_windowevents_c.h index c97d2aff..9ad34a34 100644 --- a/jni/SDL2-2.0.1/src/events/SDL_windowevents_c.h +++ b/jni/SDL2-2.0.3/src/events/SDL_windowevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/blank_cursor.h b/jni/SDL2-2.0.3/src/events/blank_cursor.h similarity index 95% rename from jni/SDL2-2.0.1/src/events/blank_cursor.h rename to jni/SDL2-2.0.3/src/events/blank_cursor.h index 6efb4741..423fa138 100644 --- a/jni/SDL2-2.0.1/src/events/blank_cursor.h +++ b/jni/SDL2-2.0.3/src/events/blank_cursor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/default_cursor.h b/jni/SDL2-2.0.3/src/events/default_cursor.h similarity index 97% rename from jni/SDL2-2.0.1/src/events/default_cursor.h rename to jni/SDL2-2.0.3/src/events/default_cursor.h index 8c2dcfcf..6e09380e 100644 --- a/jni/SDL2-2.0.1/src/events/default_cursor.h +++ b/jni/SDL2-2.0.3/src/events/default_cursor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/scancodes_darwin.h b/jni/SDL2-2.0.3/src/events/scancodes_darwin.h similarity index 99% rename from jni/SDL2-2.0.1/src/events/scancodes_darwin.h rename to jni/SDL2-2.0.3/src/events/scancodes_darwin.h index 77c728bc..42fcbdfa 100644 --- a/jni/SDL2-2.0.1/src/events/scancodes_darwin.h +++ b/jni/SDL2-2.0.3/src/events/scancodes_darwin.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/scancodes_linux.h b/jni/SDL2-2.0.3/src/events/scancodes_linux.h similarity index 99% rename from jni/SDL2-2.0.1/src/events/scancodes_linux.h rename to jni/SDL2-2.0.3/src/events/scancodes_linux.h index 4d819da1..dbf7a7a5 100644 --- a/jni/SDL2-2.0.1/src/events/scancodes_linux.h +++ b/jni/SDL2-2.0.3/src/events/scancodes_linux.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/scancodes_windows.h b/jni/SDL2-2.0.3/src/events/scancodes_windows.h similarity index 98% rename from jni/SDL2-2.0.1/src/events/scancodes_windows.h rename to jni/SDL2-2.0.3/src/events/scancodes_windows.h index 3462e14e..fa894e48 100644 --- a/jni/SDL2-2.0.1/src/events/scancodes_windows.h +++ b/jni/SDL2-2.0.3/src/events/scancodes_windows.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/events/scancodes_xfree86.h b/jni/SDL2-2.0.3/src/events/scancodes_xfree86.h similarity index 99% rename from jni/SDL2-2.0.1/src/events/scancodes_xfree86.h rename to jni/SDL2-2.0.3/src/events/scancodes_xfree86.h index fadcfbfd..8b10c3d9 100644 --- a/jni/SDL2-2.0.1/src/events/scancodes_xfree86.h +++ b/jni/SDL2-2.0.3/src/events/scancodes_xfree86.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/file/SDL_rwops.c b/jni/SDL2-2.0.3/src/file/SDL_rwops.c similarity index 91% rename from jni/SDL2-2.0.1/src/file/SDL_rwops.c rename to jni/SDL2-2.0.3/src/file/SDL_rwops.c index c994c8fd..afa35d06 100644 --- a/jni/SDL2-2.0.1/src/file/SDL_rwops.c +++ b/jni/SDL2-2.0.3/src/file/SDL_rwops.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -282,7 +282,7 @@ windows_file_close(SDL_RWops * context) context->hidden.windowsio.buffer.data = NULL; SDL_FreeRW(context); } - return (0); + return 0; } #endif /* __WIN32__ */ @@ -316,9 +316,13 @@ stdio_seek(SDL_RWops * context, Sint64 offset, int whence) if (fseeko(context->hidden.stdio.fp, (off_t)offset, whence) == 0) { return ftello(context->hidden.stdio.fp); } +#elif defined(HAVE__FSEEKI64) + if (_fseeki64(context->hidden.stdio.fp, offset, whence) == 0) { + return _ftelli64(context->hidden.stdio.fp); + } #else if (fseek(context->hidden.stdio.fp, offset, whence) == 0) { - return (ftell(context->hidden.stdio.fp)); + return ftell(context->hidden.stdio.fp); } #endif return SDL_Error(SDL_EFSEEK); @@ -333,7 +337,7 @@ stdio_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) if (nread == 0 && ferror(context->hidden.stdio.fp)) { SDL_Error(SDL_EFREAD); } - return (nread); + return nread; } static size_t SDLCALL @@ -345,7 +349,7 @@ stdio_write(SDL_RWops * context, const void *ptr, size_t size, size_t num) if (nwrote == 0 && ferror(context->hidden.stdio.fp)) { SDL_Error(SDL_EFWRITE); } - return (nwrote); + return nwrote; } static int SDLCALL @@ -432,14 +436,14 @@ mem_write(SDL_RWops * context, const void *ptr, size_t size, size_t num) } SDL_memcpy(context->hidden.mem.here, ptr, num * size); context->hidden.mem.here += num * size; - return (num); + return num; } static size_t SDLCALL mem_writeconst(SDL_RWops * context, const void *ptr, size_t size, size_t num) { SDL_SetError("Can't write to read-only memory"); - return (0); + return 0; } static int SDLCALL @@ -448,7 +452,7 @@ mem_close(SDL_RWops * context) if (context) { SDL_FreeRW(context); } - return (0); + return 0; } @@ -522,6 +526,9 @@ SDL_RWFromFile(const char *file, const char *mode) { #ifdef __APPLE__ FILE *fp = SDL_OpenFPFromBundleOrFallback(file, mode); + #elif __WINRT__ + FILE *fp = NULL; + fopen_s(&fp, file, mode); #else FILE *fp = fopen(file, mode); #endif @@ -535,7 +542,7 @@ SDL_RWFromFile(const char *file, const char *mode) SDL_SetError("SDL not compiled with stdio support"); #endif /* !HAVE_STDIO_H */ - return (rwops); + return rwops; } #ifdef HAVE_STDIO_H @@ -555,7 +562,7 @@ SDL_RWFromFP(FILE * fp, SDL_bool autoclose) rwops->hidden.stdio.autoclose = autoclose; rwops->type = SDL_RWOPS_STDFILE; } - return (rwops); + return rwops; } #else SDL_RWops * @@ -572,11 +579,11 @@ SDL_RWFromMem(void *mem, int size) SDL_RWops *rwops = NULL; if (!mem) { SDL_InvalidParamError("mem"); - return (rwops); + return rwops; } if (!size) { SDL_InvalidParamError("size"); - return (rwops); + return rwops; } rwops = SDL_AllocRW(); @@ -591,7 +598,7 @@ SDL_RWFromMem(void *mem, int size) rwops->hidden.mem.stop = rwops->hidden.mem.base + size; rwops->type = SDL_RWOPS_MEMORY; } - return (rwops); + return rwops; } SDL_RWops * @@ -600,11 +607,11 @@ SDL_RWFromConstMem(const void *mem, int size) SDL_RWops *rwops = NULL; if (!mem) { SDL_InvalidParamError("mem"); - return (rwops); + return rwops; } if (!size) { SDL_InvalidParamError("size"); - return (rwops); + return rwops; } rwops = SDL_AllocRW(); @@ -619,7 +626,7 @@ SDL_RWFromConstMem(const void *mem, int size) rwops->hidden.mem.stop = rwops->hidden.mem.base + size; rwops->type = SDL_RWOPS_MEMORY_RO; } - return (rwops); + return rwops; } SDL_RWops * @@ -633,7 +640,7 @@ SDL_AllocRW(void) } else { area->type = SDL_RWOPS_UNKNOWN; } - return (area); + return area; } void @@ -649,7 +656,7 @@ SDL_ReadU8(SDL_RWops * src) { Uint8 value = 0; - SDL_RWread(src, &value, (sizeof value), 1); + SDL_RWread(src, &value, sizeof (value), 1); return value; } @@ -658,8 +665,8 @@ SDL_ReadLE16(SDL_RWops * src) { Uint16 value = 0; - SDL_RWread(src, &value, (sizeof value), 1); - return (SDL_SwapLE16(value)); + SDL_RWread(src, &value, sizeof (value), 1); + return SDL_SwapLE16(value); } Uint16 @@ -667,8 +674,8 @@ SDL_ReadBE16(SDL_RWops * src) { Uint16 value = 0; - SDL_RWread(src, &value, (sizeof value), 1); - return (SDL_SwapBE16(value)); + SDL_RWread(src, &value, sizeof (value), 1); + return SDL_SwapBE16(value); } Uint32 @@ -676,8 +683,8 @@ SDL_ReadLE32(SDL_RWops * src) { Uint32 value = 0; - SDL_RWread(src, &value, (sizeof value), 1); - return (SDL_SwapLE32(value)); + SDL_RWread(src, &value, sizeof (value), 1); + return SDL_SwapLE32(value); } Uint32 @@ -685,8 +692,8 @@ SDL_ReadBE32(SDL_RWops * src) { Uint32 value = 0; - SDL_RWread(src, &value, (sizeof value), 1); - return (SDL_SwapBE32(value)); + SDL_RWread(src, &value, sizeof (value), 1); + return SDL_SwapBE32(value); } Uint64 @@ -694,8 +701,8 @@ SDL_ReadLE64(SDL_RWops * src) { Uint64 value = 0; - SDL_RWread(src, &value, (sizeof value), 1); - return (SDL_SwapLE64(value)); + SDL_RWread(src, &value, sizeof (value), 1); + return SDL_SwapLE64(value); } Uint64 @@ -703,56 +710,56 @@ SDL_ReadBE64(SDL_RWops * src) { Uint64 value = 0; - SDL_RWread(src, &value, (sizeof value), 1); - return (SDL_SwapBE64(value)); + SDL_RWread(src, &value, sizeof (value), 1); + return SDL_SwapBE64(value); } size_t SDL_WriteU8(SDL_RWops * dst, Uint8 value) { - return (SDL_RWwrite(dst, &value, (sizeof value), 1)); + return SDL_RWwrite(dst, &value, sizeof (value), 1); } size_t SDL_WriteLE16(SDL_RWops * dst, Uint16 value) { - value = SDL_SwapLE16(value); - return (SDL_RWwrite(dst, &value, (sizeof value), 1)); + const Uint16 swapped = SDL_SwapLE16(value); + return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1); } size_t SDL_WriteBE16(SDL_RWops * dst, Uint16 value) { - value = SDL_SwapBE16(value); - return (SDL_RWwrite(dst, &value, (sizeof value), 1)); + const Uint16 swapped = SDL_SwapBE16(value); + return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1); } size_t SDL_WriteLE32(SDL_RWops * dst, Uint32 value) { - value = SDL_SwapLE32(value); - return (SDL_RWwrite(dst, &value, (sizeof value), 1)); + const Uint32 swapped = SDL_SwapLE32(value); + return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1); } size_t SDL_WriteBE32(SDL_RWops * dst, Uint32 value) { - value = SDL_SwapBE32(value); - return (SDL_RWwrite(dst, &value, (sizeof value), 1)); + const Uint32 swapped = SDL_SwapBE32(value); + return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1); } size_t SDL_WriteLE64(SDL_RWops * dst, Uint64 value) { - value = SDL_SwapLE64(value); - return (SDL_RWwrite(dst, &value, (sizeof value), 1)); + const Uint64 swapped = SDL_SwapLE64(value); + return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1); } size_t SDL_WriteBE64(SDL_RWops * dst, Uint64 value) { - value = SDL_SwapBE64(value); - return (SDL_RWwrite(dst, &value, (sizeof value), 1)); + const Uint64 swapped = SDL_SwapBE64(value); + return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1); } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/file/cocoa/SDL_rwopsbundlesupport.h b/jni/SDL2-2.0.3/src/file/cocoa/SDL_rwopsbundlesupport.h new file mode 100644 index 00000000..9a8a9662 --- /dev/null +++ b/jni/SDL2-2.0.3/src/file/cocoa/SDL_rwopsbundlesupport.h @@ -0,0 +1,30 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef __APPLE__ + +#include + +#ifndef SDL_rwopsbundlesupport_h +#define SDL_rwopsbundlesupport_h +FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode); +#endif +#endif diff --git a/jni/SDL2-2.0.1/src/file/cocoa/SDL_rwopsbundlesupport.m b/jni/SDL2-2.0.3/src/file/cocoa/SDL_rwopsbundlesupport.m similarity index 61% rename from jni/SDL2-2.0.1/src/file/cocoa/SDL_rwopsbundlesupport.m rename to jni/SDL2-2.0.3/src/file/cocoa/SDL_rwopsbundlesupport.m index 8ec0220e..682bd74a 100644 --- a/jni/SDL2-2.0.1/src/file/cocoa/SDL_rwopsbundlesupport.m +++ b/jni/SDL2-2.0.3/src/file/cocoa/SDL_rwopsbundlesupport.m @@ -1,3 +1,25 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + #ifdef __APPLE__ #import @@ -42,4 +64,7 @@ FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode) return fp; } -#endif + +#endif /* __MACOSX__ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.1/src/filesystem/cocoa/SDL_sysfilesystem.m b/jni/SDL2-2.0.3/src/filesystem/cocoa/SDL_sysfilesystem.m similarity index 98% rename from jni/SDL2-2.0.1/src/filesystem/cocoa/SDL_sysfilesystem.m rename to jni/SDL2-2.0.3/src/filesystem/cocoa/SDL_sysfilesystem.m index 2b29cc9a..adcebd68 100644 --- a/jni/SDL2-2.0.1/src/filesystem/cocoa/SDL_sysfilesystem.m +++ b/jni/SDL2-2.0.3/src/filesystem/cocoa/SDL_sysfilesystem.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/filesystem/dummy/SDL_sysfilesystem.c b/jni/SDL2-2.0.3/src/filesystem/dummy/SDL_sysfilesystem.c similarity index 95% rename from jni/SDL2-2.0.1/src/filesystem/dummy/SDL_sysfilesystem.c rename to jni/SDL2-2.0.3/src/filesystem/dummy/SDL_sysfilesystem.c index 4c92362e..7e860939 100644 --- a/jni/SDL2-2.0.1/src/filesystem/dummy/SDL_sysfilesystem.c +++ b/jni/SDL2-2.0.3/src/filesystem/dummy/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/filesystem/haiku/SDL_sysfilesystem.cc b/jni/SDL2-2.0.3/src/filesystem/haiku/SDL_sysfilesystem.cc similarity index 97% rename from jni/SDL2-2.0.1/src/filesystem/haiku/SDL_sysfilesystem.cc rename to jni/SDL2-2.0.3/src/filesystem/haiku/SDL_sysfilesystem.cc index 701a98e1..b83d4d0a 100644 --- a/jni/SDL2-2.0.1/src/filesystem/haiku/SDL_sysfilesystem.cc +++ b/jni/SDL2-2.0.3/src/filesystem/haiku/SDL_sysfilesystem.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/filesystem/unix/SDL_sysfilesystem.c b/jni/SDL2-2.0.3/src/filesystem/unix/SDL_sysfilesystem.c similarity index 99% rename from jni/SDL2-2.0.1/src/filesystem/unix/SDL_sysfilesystem.c rename to jni/SDL2-2.0.3/src/filesystem/unix/SDL_sysfilesystem.c index 0046c2d0..0349476e 100644 --- a/jni/SDL2-2.0.1/src/filesystem/unix/SDL_sysfilesystem.c +++ b/jni/SDL2-2.0.3/src/filesystem/unix/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/filesystem/windows/SDL_sysfilesystem.c b/jni/SDL2-2.0.3/src/filesystem/windows/SDL_sysfilesystem.c similarity index 62% rename from jni/SDL2-2.0.1/src/filesystem/windows/SDL_sysfilesystem.c rename to jni/SDL2-2.0.3/src/filesystem/windows/SDL_sysfilesystem.c index 8da41719..2791fb39 100644 --- a/jni/SDL2-2.0.1/src/filesystem/windows/SDL_sysfilesystem.c +++ b/jni/SDL2-2.0.3/src/filesystem/windows/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -69,28 +69,69 @@ SDL_GetPrefPath(const char *org, const char *app) * NULL, &wszPath); */ - TCHAR path[MAX_PATH]; - char *utf8 = NULL; + WCHAR path[MAX_PATH]; char *retval = NULL; + WCHAR* worg = NULL; + WCHAR* wapp = NULL; + size_t new_wpath_len = 0; + BOOL api_result = FALSE; - if (!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, path))) { + if (!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, path))) { WIN_SetError("Couldn't locate our prefpath"); return NULL; } - utf8 = WIN_StringToUTF8(path); - if (utf8) { - const size_t len = SDL_strlen(utf8) + SDL_strlen(org) + SDL_strlen(app) + 4; - retval = (char *) SDL_malloc(len); - if (!retval) { - SDL_free(utf8); - SDL_OutOfMemory(); + worg = WIN_UTF8ToString(org); + if (worg == NULL) { + SDL_OutOfMemory(); + return NULL; + } + + wapp = WIN_UTF8ToString(app); + if (wapp == NULL) { + SDL_free(worg); + SDL_OutOfMemory(); + return NULL; + } + + new_wpath_len = lstrlenW(worg) + lstrlenW(wapp) + lstrlenW(path) + 3; + + if ((new_wpath_len + 1) > MAX_PATH) { + SDL_free(worg); + SDL_free(wapp); + WIN_SetError("Path too long."); + return NULL; + } + + lstrcatW(path, L"\\"); + lstrcatW(path, worg); + SDL_free(worg); + + api_result = CreateDirectoryW(path, NULL); + if (api_result == FALSE) { + if (GetLastError() != ERROR_ALREADY_EXISTS) { + SDL_free(wapp); + WIN_SetError("Couldn't create a prefpath."); return NULL; } - SDL_snprintf(retval, len, "%s\\%s\\%s\\", utf8, org, app); - SDL_free(utf8); } + lstrcatW(path, L"\\"); + lstrcatW(path, wapp); + SDL_free(wapp); + + api_result = CreateDirectoryW(path, NULL); + if (api_result == FALSE) { + if (GetLastError() != ERROR_ALREADY_EXISTS) { + WIN_SetError("Couldn't create a prefpath."); + return NULL; + } + } + + lstrcatW(path, L"\\"); + + retval = WIN_StringToUTF8(path); + return retval; } diff --git a/jni/SDL2-2.0.3/src/filesystem/winrt/SDL_sysfilesystem.cpp b/jni/SDL2-2.0.3/src/filesystem/winrt/SDL_sysfilesystem.cpp new file mode 100644 index 00000000..48c21e10 --- /dev/null +++ b/jni/SDL2-2.0.3/src/filesystem/winrt/SDL_sysfilesystem.cpp @@ -0,0 +1,174 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +/* TODO, WinRT: include copyright info in SDL_winrtpaths.cpp + TODO, WinRT: remove the need to compile this with C++/CX (/ZW) extensions, and if possible, without C++ at all +*/ + +#ifdef __WINRT__ + +extern "C" { +#include "SDL_filesystem.h" +#include "SDL_error.h" +#include "SDL_stdinc.h" +#include "SDL_system.h" +#include "../../core/windows/SDL_windows.h" +} + +#include +#include + +using namespace std; +using namespace Windows::Storage; + +extern "C" const wchar_t * +SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType) +{ + switch (pathType) { + case SDL_WINRT_PATH_INSTALLED_LOCATION: + { + static wstring path; + if (path.empty()) { + path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data(); + } + return path.c_str(); + } + + case SDL_WINRT_PATH_LOCAL_FOLDER: + { + static wstring path; + if (path.empty()) { + path = ApplicationData::Current->LocalFolder->Path->Data(); + } + return path.c_str(); + } + +#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP + case SDL_WINRT_PATH_ROAMING_FOLDER: + { + static wstring path; + if (path.empty()) { + path = ApplicationData::Current->RoamingFolder->Path->Data(); + } + return path.c_str(); + } + + case SDL_WINRT_PATH_TEMP_FOLDER: + { + static wstring path; + if (path.empty()) { + path = ApplicationData::Current->TemporaryFolder->Path->Data(); + } + return path.c_str(); + } +#endif + + default: + break; + } + + SDL_Unsupported(); + return NULL; +} + +extern "C" const char * +SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType) +{ + typedef unordered_map UTF8PathMap; + static UTF8PathMap utf8Paths; + + UTF8PathMap::iterator searchResult = utf8Paths.find(pathType); + if (searchResult != utf8Paths.end()) { + return searchResult->second.c_str(); + } + + const wchar_t * ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType); + if (!ucs2Path) { + return NULL; + } + + char * utf8Path = WIN_StringToUTF8(ucs2Path); + utf8Paths[pathType] = utf8Path; + SDL_free(utf8Path); + return utf8Paths[pathType].c_str(); +} + +extern "C" char * +SDL_GetBasePath(void) +{ + const char * srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_INSTALLED_LOCATION); + size_t destPathLen; + char * destPath = NULL; + + if (!srcPath) { + SDL_SetError("Couldn't locate our basepath: %s", SDL_GetError()); + return NULL; + } + + destPathLen = SDL_strlen(srcPath) + 2; + destPath = (char *) SDL_malloc(destPathLen); + if (!destPath) { + SDL_OutOfMemory(); + return NULL; + } + + SDL_snprintf(destPath, destPathLen, "%s\\", srcPath); + return destPath; +} + +extern "C" char * +SDL_GetPrefPath(const char *org, const char *app) +{ + /* WinRT note: The 'SHGetFolderPath' API that is used in Windows 7 and + * earlier is not available on WinRT or Windows Phone. WinRT provides + * a similar API, but SHGetFolderPath can't be called, at least not + * without violating Microsoft's app-store requirements. + */ + +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + /* A 'Roaming' folder is not available in Windows Phone 8, however a 'Local' folder is. */ + const char * srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_LOCAL_FOLDER); +#else + /* A 'Roaming' folder is available on Windows 8 and 8.1. Use that. */ + const char * srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_ROAMING_FOLDER); +#endif + + size_t destPathLen; + char * destPath = NULL; + + if (!srcPath) { + SDL_SetError("Couldn't locate our basepath: %s", SDL_GetError()); + return NULL; + } + + destPathLen = SDL_strlen(srcPath) + SDL_strlen(org) + SDL_strlen(app) + 4; + destPath = (char *) SDL_malloc(destPathLen); + if (!destPath) { + SDL_OutOfMemory(); + return NULL; + } + + SDL_snprintf(destPath, destPathLen, "%s\\%s\\%s\\", srcPath, org, app); + return destPath; +} + +#endif /* __WINRT__ */ diff --git a/jni/SDL2-2.0.1/src/haptic/SDL_haptic.c b/jni/SDL2-2.0.3/src/haptic/SDL_haptic.c similarity index 87% rename from jni/SDL2-2.0.1/src/haptic/SDL_haptic.c rename to jni/SDL2-2.0.3/src/haptic/SDL_haptic.c index c629deaf..fbfe14f3 100644 --- a/jni/SDL2-2.0.1/src/haptic/SDL_haptic.c +++ b/jni/SDL2-2.0.3/src/haptic/SDL_haptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -25,8 +25,7 @@ #include "../joystick/SDL_joystick_c.h" /* For SDL_PrivateJoystickValid */ #include "SDL_assert.h" -Uint8 SDL_numhaptics = 0; -SDL_Haptic **SDL_haptics = NULL; +SDL_Haptic *SDL_haptics = NULL; /* @@ -35,20 +34,10 @@ SDL_Haptic **SDL_haptics = NULL; int SDL_HapticInit(void) { - int arraylen; int status; - SDL_numhaptics = 0; status = SDL_SYS_HapticInit(); if (status >= 0) { - arraylen = (status + 1) * sizeof(*SDL_haptics); - SDL_haptics = (SDL_Haptic **) SDL_malloc(arraylen); - if (SDL_haptics == NULL) { /* Out of memory. */ - SDL_numhaptics = 0; - } else { - SDL_memset(SDL_haptics, 0, arraylen); - SDL_numhaptics = status; - } status = 0; } @@ -62,16 +51,19 @@ SDL_HapticInit(void) static int ValidHaptic(SDL_Haptic * haptic) { - int i; int valid; + SDL_Haptic *hapticlist; valid = 0; if (haptic != NULL) { - for (i = 0; i < SDL_numhaptics; i++) { - if (SDL_haptics[i] == haptic) { + hapticlist = SDL_haptics; + while ( hapticlist ) + { + if (hapticlist == haptic) { valid = 1; break; } + hapticlist = hapticlist->next; } } @@ -90,7 +82,7 @@ ValidHaptic(SDL_Haptic * haptic) int SDL_NumHaptics(void) { - return SDL_numhaptics; + return SDL_SYS_NumHaptics(); } @@ -100,9 +92,9 @@ SDL_NumHaptics(void) const char * SDL_HapticName(int device_index) { - if ((device_index < 0) || (device_index >= SDL_numhaptics)) { + if ((device_index < 0) || (device_index >= SDL_NumHaptics())) { SDL_SetError("Haptic: There are %d haptic devices available", - SDL_numhaptics); + SDL_NumHaptics()); return NULL; } return SDL_SYS_HapticName(device_index); @@ -115,22 +107,27 @@ SDL_HapticName(int device_index) SDL_Haptic * SDL_HapticOpen(int device_index) { - int i; SDL_Haptic *haptic; + SDL_Haptic *hapticlist; - if ((device_index < 0) || (device_index >= SDL_numhaptics)) { + if ((device_index < 0) || (device_index >= SDL_NumHaptics())) { SDL_SetError("Haptic: There are %d haptic devices available", - SDL_numhaptics); + SDL_NumHaptics()); return NULL; } - /* If the haptic is already open, return it */ - for (i = 0; SDL_haptics[i]; i++) { - if (device_index == SDL_haptics[i]->index) { - haptic = SDL_haptics[i]; + hapticlist = SDL_haptics; + /* If the haptic is already open, return it + * TODO: Should we create haptic instance IDs like the Joystick API? + */ + while ( hapticlist ) + { + if (device_index == hapticlist->index) { + haptic = hapticlist; ++haptic->ref_count; return haptic; } + hapticlist = hapticlist->next; } /* Create the haptic device */ @@ -150,15 +147,10 @@ SDL_HapticOpen(int device_index) } /* Add haptic to list */ - for (i = 0; SDL_haptics[i]; i++) - /* Skip to next haptic */ ; - if (i >= SDL_numhaptics) { - SDL_free(haptic); - SDL_SetError("Haptic: Trying to add device past the number originally detected"); - return NULL; - } - SDL_haptics[i] = haptic; ++haptic->ref_count; + /* Link the haptic in the list */ + haptic->next = SDL_haptics; + SDL_haptics = haptic; /* Disable autocenter and set gain to max. */ if (haptic->supported & SDL_HAPTIC_GAIN) @@ -176,21 +168,26 @@ SDL_HapticOpen(int device_index) int SDL_HapticOpened(int device_index) { - int i, opened; + int opened; + SDL_Haptic *hapticlist; /* Make sure it's valid. */ - if ((device_index < 0) || (device_index >= SDL_numhaptics)) { + if ((device_index < 0) || (device_index >= SDL_NumHaptics())) { SDL_SetError("Haptic: There are %d haptic devices available", - SDL_numhaptics); + SDL_NumHaptics()); return 0; } opened = 0; - for (i = 0; SDL_haptics[i]; i++) { - if (SDL_haptics[i]->index == (Uint8) device_index) { + hapticlist = SDL_haptics; + /* TODO Should this use an instance ID? */ + while ( hapticlist ) + { + if (hapticlist->index == (Uint8) device_index) { opened = 1; break; } + hapticlist = hapticlist->next; } return opened; } @@ -271,13 +268,13 @@ SDL_JoystickIsHaptic(SDL_Joystick * joystick) SDL_Haptic * SDL_HapticOpenFromJoystick(SDL_Joystick * joystick) { - int i; SDL_Haptic *haptic; + SDL_Haptic *hapticlist; /* Make sure there is room. */ - if (SDL_numhaptics <= 0) { + if (SDL_NumHaptics() <= 0) { SDL_SetError("Haptic: There are %d haptic devices available", - SDL_numhaptics); + SDL_NumHaptics()); return NULL; } @@ -293,13 +290,16 @@ SDL_HapticOpenFromJoystick(SDL_Joystick * joystick) return NULL; } + hapticlist = SDL_haptics; /* Check to see if joystick's haptic is already open */ - for (i = 0; SDL_haptics[i]; i++) { - if (SDL_SYS_JoystickSameHaptic(SDL_haptics[i], joystick)) { - haptic = SDL_haptics[i]; + while ( hapticlist ) + { + if (SDL_SYS_JoystickSameHaptic(hapticlist, joystick)) { + haptic = hapticlist; ++haptic->ref_count; return haptic; } + hapticlist = hapticlist->next; } /* Create the haptic device */ @@ -318,15 +318,10 @@ SDL_HapticOpenFromJoystick(SDL_Joystick * joystick) } /* Add haptic to list */ - for (i = 0; SDL_haptics[i]; i++) - /* Skip to next haptic */ ; - if (i >= SDL_numhaptics) { - SDL_free(haptic); - SDL_SetError("Haptic: Trying to add device past the number originally detected"); - return NULL; - } - SDL_haptics[i] = haptic; ++haptic->ref_count; + /* Link the haptic in the list */ + haptic->next = SDL_haptics; + SDL_haptics = haptic; return haptic; } @@ -339,6 +334,8 @@ void SDL_HapticClose(SDL_Haptic * haptic) { int i; + SDL_Haptic *hapticlist; + SDL_Haptic *hapticlistprev; /* Must be valid */ if (!ValidHaptic(haptic)) { @@ -359,13 +356,26 @@ SDL_HapticClose(SDL_Haptic * haptic) SDL_SYS_HapticClose(haptic); /* Remove from the list */ - for (i = 0; SDL_haptics[i]; ++i) { - if (haptic == SDL_haptics[i]) { - SDL_haptics[i] = NULL; - SDL_memcpy(&SDL_haptics[i], &SDL_haptics[i + 1], - (SDL_numhaptics - i) * sizeof(haptic)); + hapticlist = SDL_haptics; + hapticlistprev = NULL; + while ( hapticlist ) + { + if (haptic == hapticlist) + { + if ( hapticlistprev ) + { + /* unlink this entry */ + hapticlistprev->next = hapticlist->next; + } + else + { + SDL_haptics = haptic->next; + } + break; } + hapticlistprev = hapticlist; + hapticlist = hapticlist->next; } /* Free */ @@ -379,9 +389,8 @@ void SDL_HapticQuit(void) { SDL_SYS_HapticQuit(); - SDL_free(SDL_haptics); + SDL_assert(SDL_haptics == NULL); SDL_haptics = NULL; - SDL_numhaptics = 0; } /* diff --git a/jni/SDL2-2.0.1/src/haptic/SDL_haptic_c.h b/jni/SDL2-2.0.3/src/haptic/SDL_haptic_c.h similarity index 94% rename from jni/SDL2-2.0.1/src/haptic/SDL_haptic_c.h rename to jni/SDL2-2.0.3/src/haptic/SDL_haptic_c.h index 678a08f0..b318fff1 100644 --- a/jni/SDL2-2.0.1/src/haptic/SDL_haptic_c.h +++ b/jni/SDL2-2.0.3/src/haptic/SDL_haptic_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/haptic/SDL_syshaptic.h b/jni/SDL2-2.0.3/src/haptic/SDL_syshaptic.h similarity index 95% rename from jni/SDL2-2.0.1/src/haptic/SDL_syshaptic.h rename to jni/SDL2-2.0.3/src/haptic/SDL_syshaptic.h index bb4095dc..b2918beb 100644 --- a/jni/SDL2-2.0.1/src/haptic/SDL_syshaptic.h +++ b/jni/SDL2-2.0.3/src/haptic/SDL_syshaptic.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -54,6 +54,7 @@ struct _SDL_Haptic int rumble_id; /* ID of rumble effect for simple rumble API. */ SDL_HapticEffect rumble_effect; /* Rumble effect. */ + struct _SDL_Haptic *next; /* pointer to next haptic we have allocated */ }; /* @@ -63,6 +64,9 @@ struct _SDL_Haptic */ extern int SDL_SYS_HapticInit(void); +/* Function to return the number of haptic devices plugged in right now */ +extern int SDL_SYS_NumHaptics(); + /* * Gets the device dependent name of the haptic device */ @@ -201,3 +205,6 @@ extern int SDL_SYS_HapticUnpause(SDL_Haptic * haptic); * Returns 0 on success, -1 on error. */ extern int SDL_SYS_HapticStopAll(SDL_Haptic * haptic); + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/jni/SDL2-2.0.1/src/haptic/darwin/SDL_syshaptic.c b/jni/SDL2-2.0.3/src/haptic/darwin/SDL_syshaptic.c similarity index 86% rename from jni/SDL2-2.0.1/src/haptic/darwin/SDL_syshaptic.c rename to jni/SDL2-2.0.3/src/haptic/darwin/SDL_syshaptic.c index 12dceee4..14beb6c8 100644 --- a/jni/SDL2-2.0.1/src/haptic/darwin/SDL_syshaptic.c +++ b/jni/SDL2-2.0.3/src/haptic/darwin/SDL_syshaptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -22,11 +22,13 @@ #ifdef SDL_HAPTIC_IOKIT +#include "SDL_assert.h" #include "SDL_haptic.h" #include "../SDL_syshaptic.h" #include "SDL_joystick.h" #include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */ #include "../../joystick/darwin/SDL_sysjoystick_c.h" /* For joystick hwdata */ +#include "SDL_syshaptic_c.h" #include #include @@ -38,13 +40,10 @@ #define IO_OBJECT_NULL ((io_service_t)0) #endif -#define MAX_HAPTICS 32 - - /* * List of available haptic devices. */ -static struct +typedef struct SDL_hapticlist_item { char name[256]; /* Name of the device. */ @@ -54,7 +53,9 @@ static struct /* Usage pages for determining if it's a mouse or not. */ long usage; long usagePage; -} SDL_hapticlist[MAX_HAPTICS]; + + struct SDL_hapticlist_item *next; +} SDL_hapticlist_item; /* @@ -82,6 +83,9 @@ struct haptic_hweffect static void SDL_SYS_HapticFreeFFEFFECT(FFEFFECT * effect, int type); static int HIDGetDeviceProduct(io_service_t dev, char *name); +static SDL_hapticlist_item *SDL_hapticlist = NULL; +static SDL_hapticlist_item *SDL_hapticlist_tail = NULL; +static int numhaptics = -1; /* * Like strerror but for force feedback errors. @@ -146,16 +150,15 @@ FFStrError(HRESULT err) int SDL_SYS_HapticInit(void) { - int numhaptics; IOReturn result; io_iterator_t iter; CFDictionaryRef match; io_service_t device; - CFMutableDictionaryRef hidProperties; - CFTypeRef refCF; - /* Clear all the memory. */ - SDL_memset(SDL_hapticlist, 0, sizeof(SDL_hapticlist)); + if (numhaptics != -1) { + return SDL_SetError("Haptic subsystem already initialized!"); + } + numhaptics = 0; /* Get HID devices. */ match = IOServiceMatching(kIOHIDDeviceKey); @@ -174,62 +177,157 @@ SDL_SYS_HapticInit(void) return 0; } - numhaptics = 0; while ((device = IOIteratorNext(iter)) != IO_OBJECT_NULL) { - - /* Check for force feedback. */ - if (FFIsForceFeedback(device) == FF_OK) { - - /* Set basic device data. */ - HIDGetDeviceProduct(device, SDL_hapticlist[numhaptics].name); - SDL_hapticlist[numhaptics].dev = device; - SDL_hapticlist[numhaptics].haptic = NULL; - - /* Set usage pages. */ - hidProperties = 0; - refCF = 0; - result = IORegistryEntryCreateCFProperties(device, - &hidProperties, - kCFAllocatorDefault, - kNilOptions); - if ((result == KERN_SUCCESS) && hidProperties) { - refCF = - CFDictionaryGetValue(hidProperties, - CFSTR(kIOHIDPrimaryUsagePageKey)); - if (refCF) { - if (!CFNumberGetValue(refCF, kCFNumberLongType, - &SDL_hapticlist[numhaptics]. - usagePage)) - SDL_SetError - ("Haptic: Recieving device's usage page."); - refCF = - CFDictionaryGetValue(hidProperties, - CFSTR(kIOHIDPrimaryUsageKey)); - if (refCF) { - if (!CFNumberGetValue(refCF, kCFNumberLongType, - &SDL_hapticlist[numhaptics]. - usage)) - SDL_SetError("Haptic: Recieving device's usage."); - } - } - CFRelease(hidProperties); - } - - /* Device has been added. */ - numhaptics++; - } else { /* Free the unused device. */ - IOObjectRelease(device); - } - - /* Reached haptic limit. */ - if (numhaptics >= MAX_HAPTICS) - break; + MacHaptic_MaybeAddDevice(device); + /* always release as the AddDevice will retain IF it's a forcefeedback device */ + IOObjectRelease(device); } IOObjectRelease(iter); return numhaptics; } +int +SDL_SYS_NumHaptics() +{ + return numhaptics; +} + +static SDL_hapticlist_item * +HapticByDevIndex(int device_index) +{ + SDL_hapticlist_item *item = SDL_hapticlist; + + if ((device_index < 0) || (device_index >= numhaptics)) { + return NULL; + } + + while (device_index > 0) { + SDL_assert(item != NULL); + --device_index; + item = item->next; + } + + return item; +} + +int +MacHaptic_MaybeAddDevice( io_object_t device ) +{ + IOReturn result; + CFMutableDictionaryRef hidProperties; + CFTypeRef refCF; + SDL_hapticlist_item *item; + + if (numhaptics == -1) { + return -1; /* not initialized. We'll pick these up on enumeration if we init later. */ + } + + /* Check for force feedback. */ + if (FFIsForceFeedback(device) != FF_OK) { + return -1; + } + + /* Make sure we don't already have it */ + for (item = SDL_hapticlist; item ; item = item->next) + { + if (IOObjectIsEqualTo((io_object_t) item->dev, device)) { + /* Already added */ + return -1; + } + } + + item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item)); + if (item == NULL) { + return SDL_SetError("Could not allocate haptic storage"); + } + + /* retain it as we are going to keep it around a while */ + IOObjectRetain(device); + + /* Set basic device data. */ + HIDGetDeviceProduct(device, item->name); + item->dev = device; + + /* Set usage pages. */ + hidProperties = 0; + refCF = 0; + result = IORegistryEntryCreateCFProperties(device, + &hidProperties, + kCFAllocatorDefault, + kNilOptions); + if ((result == KERN_SUCCESS) && hidProperties) { + refCF = + CFDictionaryGetValue(hidProperties, + CFSTR(kIOHIDPrimaryUsagePageKey)); + if (refCF) { + if (!CFNumberGetValue(refCF, kCFNumberLongType, + &item->usagePage)) + SDL_SetError + ("Haptic: Recieving device's usage page."); + refCF = + CFDictionaryGetValue(hidProperties, + CFSTR(kIOHIDPrimaryUsageKey)); + if (refCF) { + if (!CFNumberGetValue(refCF, kCFNumberLongType, + &item->usage)) + SDL_SetError("Haptic: Recieving device's usage."); + } + } + CFRelease(hidProperties); + } + + if (SDL_hapticlist_tail == NULL) { + SDL_hapticlist = SDL_hapticlist_tail = item; + } else { + SDL_hapticlist_tail->next = item; + SDL_hapticlist_tail = item; + } + + /* Device has been added. */ + ++numhaptics; + + return numhaptics; +} + +int +MacHaptic_MaybeRemoveDevice( io_object_t device ) +{ + SDL_hapticlist_item *item; + SDL_hapticlist_item *prev = NULL; + + if (numhaptics == -1) { + return -1; /* not initialized. ignore this. */ + } + + for (item = SDL_hapticlist; item != NULL; item = item->next) { + /* found it, remove it. */ + if (IOObjectIsEqualTo((io_object_t) item->dev, device)) { + const int retval = item->haptic ? item->haptic->index : -1; + + if (prev != NULL) { + prev->next = item->next; + } else { + SDL_assert(SDL_hapticlist == item); + SDL_hapticlist = item->next; + } + if (item == SDL_hapticlist_tail) { + SDL_hapticlist_tail = prev; + } + + /* Need to decrement the haptic count */ + --numhaptics; + /* !!! TODO: Send a haptic remove event? */ + + IOObjectRelease(item->dev); + SDL_free(item); + return retval; + } + prev = item; + } + + return -1; +} /* * Return the name of a haptic device, does not need to be opened. @@ -237,7 +335,9 @@ SDL_SYS_HapticInit(void) const char * SDL_SYS_HapticName(int index) { - return SDL_hapticlist[index].name; + SDL_hapticlist_item *item; + item = HapticByDevIndex(index); + return item->name; } /* @@ -470,8 +570,10 @@ SDL_SYS_HapticOpenFromService(SDL_Haptic * haptic, io_service_t service) int SDL_SYS_HapticOpen(SDL_Haptic * haptic) { - return SDL_SYS_HapticOpenFromService(haptic, - SDL_hapticlist[haptic->index].dev); + SDL_hapticlist_item *item; + item = HapticByDevIndex(haptic->index); + + return SDL_SYS_HapticOpenFromService(haptic, item->dev); } @@ -481,12 +583,15 @@ SDL_SYS_HapticOpen(SDL_Haptic * haptic) int SDL_SYS_HapticMouse(void) { - int i; + int device_index = 0; + SDL_hapticlist_item *item; - for (i = 0; i < SDL_numhaptics; i++) { - if ((SDL_hapticlist[i].usagePage == kHIDPage_GenericDesktop) && - (SDL_hapticlist[i].usage == kHIDUsage_GD_Mouse)) - return i; + for (item = SDL_hapticlist; item; item = item->next) { + if ((item->usagePage == kHIDPage_GenericDesktop) && + (item->usage == kHIDUsage_GD_Mouse)) { + return device_index; + } + ++device_index; } return -1; @@ -524,16 +629,16 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) { - int i; - for (i=0; inext) { + if (IOObjectIsEqualTo((io_object_t) item->dev, joystick->hwdata->ffservice)) { - haptic->index = i; + haptic->index = device_index; break; - } - } - if (i >= SDL_numhaptics) { - return -1; + } + ++device_index; } return SDL_SYS_HapticOpenFromService(haptic, joystick->hwdata->ffservice); @@ -569,15 +674,19 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic) void SDL_SYS_HapticQuit(void) { - int i; + SDL_hapticlist_item *item; + SDL_hapticlist_item *next = NULL; - for (i = 0; i < SDL_numhaptics; i++) { + for (item = SDL_hapticlist; item; item = next) { + next = item->next; /* Opened and not closed haptics are leaked, this is on purpose. * Close your haptic devices after usage. */ /* Free the io_service_t */ - IOObjectRelease(SDL_hapticlist[i].dev); + IOObjectRelease(item->dev); + SDL_free(item); } + numhaptics = -1; } diff --git a/jni/SDL2-2.0.3/src/haptic/darwin/SDL_syshaptic_c.h b/jni/SDL2-2.0.3/src/haptic/darwin/SDL_syshaptic_c.h new file mode 100644 index 00000000..f8072071 --- /dev/null +++ b/jni/SDL2-2.0.3/src/haptic/darwin/SDL_syshaptic_c.h @@ -0,0 +1,26 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +extern int MacHaptic_MaybeAddDevice( io_object_t device ); +extern int MacHaptic_MaybeRemoveDevice( io_object_t device ); + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/jni/SDL2-2.0.1/src/haptic/dummy/SDL_syshaptic.c b/jni/SDL2-2.0.3/src/haptic/dummy/SDL_syshaptic.c similarity index 96% rename from jni/SDL2-2.0.1/src/haptic/dummy/SDL_syshaptic.c rename to jni/SDL2-2.0.3/src/haptic/dummy/SDL_syshaptic.c index 1c9f5af4..09839c6d 100644 --- a/jni/SDL2-2.0.1/src/haptic/dummy/SDL_syshaptic.c +++ b/jni/SDL2-2.0.3/src/haptic/dummy/SDL_syshaptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -39,6 +39,11 @@ SDL_SYS_HapticInit(void) return 0; } +int +SDL_SYS_NumHaptics(void) +{ + return 0; +} const char * SDL_SYS_HapticName(int index) diff --git a/jni/SDL2-2.0.1/src/haptic/linux/SDL_syshaptic.c b/jni/SDL2-2.0.3/src/haptic/linux/SDL_syshaptic.c similarity index 82% rename from jni/SDL2-2.0.1/src/haptic/linux/SDL_syshaptic.c rename to jni/SDL2-2.0.3/src/haptic/linux/SDL_syshaptic.c index aa937ed8..281a9316 100644 --- a/jni/SDL2-2.0.1/src/haptic/linux/SDL_syshaptic.c +++ b/jni/SDL2-2.0.3/src/haptic/linux/SDL_syshaptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -22,11 +22,13 @@ #ifdef SDL_HAPTIC_LINUX +#include "SDL_assert.h" #include "SDL_haptic.h" #include "../SDL_syshaptic.h" #include "SDL_joystick.h" #include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */ #include "../../joystick/linux/SDL_sysjoystick_c.h" /* For joystick hwdata */ +#include "../../core/linux/SDL_udev.h" #include /* close */ #include /* Force feedback linux stuff. */ @@ -44,15 +46,21 @@ #define MAX_HAPTICS 32 /* It's doubtful someone has more then 32 evdev */ +static int MaybeAddDevice(const char *path); +#if SDL_USE_LIBUDEV +static int MaybeRemoveDevice(const char *path); +void haptic_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath); +#endif /* SDL_USE_LIBUDEV */ /* * List of available haptic devices. */ -static struct +typedef struct SDL_hapticlist_item { char *fname; /* Dev path name (like /dev/input/event1) */ - SDL_Haptic *haptic; /* Assosciated haptic. */ -} SDL_hapticlist[MAX_HAPTICS]; + SDL_Haptic *haptic; /* Associated haptic. */ + struct SDL_hapticlist_item *next; +} SDL_hapticlist_item; /* @@ -73,7 +81,9 @@ struct haptic_hweffect struct ff_effect effect; /* The linux kernel effect structure. */ }; - +static SDL_hapticlist_item *SDL_hapticlist = NULL; +static SDL_hapticlist_item *SDL_hapticlist_tail = NULL; +static int numhaptics = 0; #define test_bit(nr, addr) \ (((1UL << ((nr) & 31)) & (((const unsigned int *) addr)[(nr) >> 5])) != 0) @@ -147,15 +157,8 @@ int SDL_SYS_HapticInit(void) { const char joydev_pattern[] = "/dev/input/event%d"; - dev_t dev_nums[MAX_HAPTICS]; char path[PATH_MAX]; - struct stat sb; - int fd; - int i, j, k; - int duplicate; - int numhaptics; - - numhaptics = 0; + int i, j; /* * Limit amount of checks to MAX_HAPTICS since we may or may not have @@ -165,44 +168,189 @@ SDL_SYS_HapticInit(void) for (j = 0; j < MAX_HAPTICS; ++j) { snprintf(path, PATH_MAX, joydev_pattern, i++); - - /* check to see if file exists */ - if (stat(path, &sb) != 0) - break; - - /* check for duplicates */ - duplicate = 0; - for (k = 0; (k < numhaptics) && !duplicate; ++k) { - if (sb.st_rdev == dev_nums[k]) { - duplicate = 1; - } - } - if (duplicate) { - continue; - } - - /* try to open */ - fd = open(path, O_RDWR, 0); - if (fd < 0) - continue; - -#ifdef DEBUG_INPUT_EVENTS - printf("Checking %s\n", path); -#endif - - /* see if it works */ - if (EV_IsHaptic(fd) > 0) { - SDL_hapticlist[numhaptics].fname = SDL_strdup(path); - SDL_hapticlist[numhaptics].haptic = NULL; - dev_nums[numhaptics] = sb.st_rdev; - ++numhaptics; - } - close(fd); + MaybeAddDevice(path); } +#if SDL_USE_LIBUDEV + if (SDL_UDEV_Init() < 0) { + return SDL_SetError("Could not initialize UDEV"); + } + + if ( SDL_UDEV_AddCallback(haptic_udev_callback) < 0) { + SDL_UDEV_Quit(); + return SDL_SetError("Could not setup haptic <-> udev callback"); + } +#endif /* SDL_USE_LIBUDEV */ + return numhaptics; } +int +SDL_SYS_NumHaptics() +{ + return numhaptics; +} + +static SDL_hapticlist_item * +HapticByDevIndex(int device_index) +{ + SDL_hapticlist_item *item = SDL_hapticlist; + + if ((device_index < 0) || (device_index >= numhaptics)) { + return NULL; + } + + while (device_index > 0) { + SDL_assert(item != NULL); + --device_index; + item = item->next; + } + + return item; +} + +#if SDL_USE_LIBUDEV +void haptic_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath) +{ + if (devpath == NULL || !(udev_class & SDL_UDEV_DEVICE_JOYSTICK)) { + return; + } + + switch( udev_type ) + { + case SDL_UDEV_DEVICEADDED: + MaybeAddDevice(devpath); + break; + + case SDL_UDEV_DEVICEREMOVED: + MaybeRemoveDevice(devpath); + break; + + default: + break; + } + +} +#endif /* SDL_USE_LIBUDEV */ + +static int +MaybeAddDevice(const char *path) +{ + dev_t dev_nums[MAX_HAPTICS]; + struct stat sb; + int fd; + int k; + int duplicate; + int success; + SDL_hapticlist_item *item; + + + if (path == NULL) { + return -1; + } + + /* check to see if file exists */ + if (stat(path, &sb) != 0) { + return -1; + } + + /* check for duplicates */ + duplicate = 0; + for (k = 0; (k < numhaptics) && !duplicate; ++k) { + if (sb.st_rdev == dev_nums[k]) { + duplicate = 1; + } + } + if (duplicate) { + return -1; + } + + /* try to open */ + fd = open(path, O_RDWR, 0); + if (fd < 0) { + return -1; + } + +#ifdef DEBUG_INPUT_EVENTS + printf("Checking %s\n", path); +#endif + + /* see if it works */ + success = EV_IsHaptic(fd); + close(fd); + if (success <= 0) { + return -1; + } + + item = (SDL_hapticlist_item *) SDL_calloc(1, sizeof (SDL_hapticlist_item)); + if (item == NULL) { + return -1; + } + + item->fname = SDL_strdup(path); + if ( (item->fname == NULL) ) { + SDL_free(item->fname); + SDL_free(item); + return -1; + } + + /* TODO: should we add instance IDs? */ + if (SDL_hapticlist_tail == NULL) { + SDL_hapticlist = SDL_hapticlist_tail = item; + } else { + SDL_hapticlist_tail->next = item; + SDL_hapticlist_tail = item; + } + + dev_nums[numhaptics] = sb.st_rdev; + + ++numhaptics; + + /* !!! TODO: Send a haptic add event? */ + + return numhaptics; +} + +#if SDL_USE_LIBUDEV +static int +MaybeRemoveDevice(const char* path) +{ + SDL_hapticlist_item *item; + SDL_hapticlist_item *prev = NULL; + + if (path == NULL) { + return -1; + } + + for (item = SDL_hapticlist; item != NULL; item = item->next) { + /* found it, remove it. */ + if (SDL_strcmp(path, item->fname) == 0) { + const int retval = item->haptic ? item->haptic->index : -1; + + if (prev != NULL) { + prev->next = item->next; + } else { + SDL_assert(SDL_hapticlist == item); + SDL_hapticlist = item->next; + } + if (item == SDL_hapticlist_tail) { + SDL_hapticlist_tail = prev; + } + + /* Need to decrement the haptic count */ + --numhaptics; + /* !!! TODO: Send a haptic remove event? */ + + SDL_free(item->fname); + SDL_free(item); + return retval; + } + prev = item; + } + + return -1; +} +#endif /* SDL_USE_LIBUDEV */ /* * Gets the name from a file descriptor. @@ -227,19 +375,21 @@ SDL_SYS_HapticNameFromFD(int fd) const char * SDL_SYS_HapticName(int index) { + SDL_hapticlist_item *item; int fd; const char *name; + item = HapticByDevIndex(index); /* Open the haptic device. */ name = NULL; - fd = open(SDL_hapticlist[index].fname, O_RDONLY, 0); + fd = open(item->fname, O_RDONLY, 0); if (fd >= 0) { name = SDL_SYS_HapticNameFromFD(fd); if (name == NULL) { /* No name found, return device character device */ - name = SDL_hapticlist[index].fname; + name = item->fname; } } close(fd); @@ -306,12 +456,14 @@ SDL_SYS_HapticOpen(SDL_Haptic * haptic) { int fd; int ret; + SDL_hapticlist_item *item; + item = HapticByDevIndex(haptic->index); /* Open the character device */ - fd = open(SDL_hapticlist[haptic->index].fname, O_RDWR, 0); + fd = open(item->fname, O_RDWR, 0); if (fd < 0) { return SDL_SetError("Haptic: Unable to open %s: %s", - SDL_hapticlist[haptic->index], strerror(errno)); + item->fname, strerror(errno)); } /* Try to create the haptic. */ @@ -321,7 +473,7 @@ SDL_SYS_HapticOpen(SDL_Haptic * haptic) } /* Set the fname. */ - haptic->hwdata->fname = SDL_hapticlist[haptic->index].fname; + haptic->hwdata->fname = item->fname; return 0; } @@ -333,24 +485,26 @@ int SDL_SYS_HapticMouse(void) { int fd; - int i; - - for (i = 0; i < SDL_numhaptics; i++) { + int device_index = 0; + SDL_hapticlist_item *item; + for (item = SDL_hapticlist; item; item = item->next) { /* Open the device. */ - fd = open(SDL_hapticlist[i].fname, O_RDWR, 0); + fd = open(item->fname, O_RDWR, 0); if (fd < 0) { return SDL_SetError("Haptic: Unable to open %s: %s", - SDL_hapticlist[i], strerror(errno)); + item->fname, strerror(errno)); } /* Is it a mouse? */ if (EV_IsMouse(fd)) { close(fd); - return i; + return device_index; } close(fd); + + ++device_index; } return -1; @@ -388,22 +542,21 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) { - int i; + int device_index = 0; int fd; int ret; + SDL_hapticlist_item *item; /* Find the joystick in the haptic list. */ - for (i = 0; i < MAX_HAPTICS; i++) { - if (SDL_hapticlist[i].fname != NULL) { - if (SDL_strcmp(SDL_hapticlist[i].fname, joystick->hwdata->fname) - == 0) { - haptic->index = i; - break; - } + for (item = SDL_hapticlist; item; item = item->next) { + if (SDL_strcmp(item->fname, joystick->hwdata->fname) == 0) { + haptic->index = device_index; + break; } + ++device_index; } - if (i >= MAX_HAPTICS) { + if (device_index >= MAX_HAPTICS) { return SDL_SetError("Haptic: Joystick doesn't have Haptic capabilities"); } @@ -417,7 +570,7 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) return -1; } - haptic->hwdata->fname = SDL_hapticlist[haptic->index].fname; + haptic->hwdata->fname = item->fname; return 0; } @@ -454,15 +607,23 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic) void SDL_SYS_HapticQuit(void) { - int i; + SDL_hapticlist_item *item = NULL; + SDL_hapticlist_item *next = NULL; - for (i = 0; SDL_hapticlist[i].fname != NULL; i++) { + for (item = SDL_hapticlist; item; item = next) { + next = item->next; /* Opened and not closed haptics are leaked, this is on purpose. * Close your haptic devices after usage. */ - - SDL_free(SDL_hapticlist[i].fname); + SDL_free(item->fname); + item->fname = NULL; } - SDL_hapticlist[0].fname = NULL; + +#if SDL_USE_LIBUDEV + SDL_UDEV_DelCallback(haptic_udev_callback); + SDL_UDEV_Quit(); +#endif /* SDL_USE_LIBUDEV */ + + numhaptics = 0; } @@ -749,7 +910,7 @@ SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) dest->u.rumble.strong_magnitude = leftright->large_magnitude; dest->u.rumble.weak_magnitude = leftright->small_magnitude; - break; + break; default: diff --git a/jni/SDL2-2.0.1/src/haptic/windows/SDL_syshaptic.c b/jni/SDL2-2.0.3/src/haptic/windows/SDL_syshaptic.c similarity index 83% rename from jni/SDL2-2.0.1/src/haptic/windows/SDL_syshaptic.c rename to jni/SDL2-2.0.3/src/haptic/windows/SDL_syshaptic.c index 3025f9bb..a4b5e426 100644 --- a/jni/SDL2-2.0.1/src/haptic/windows/SDL_syshaptic.c +++ b/jni/SDL2-2.0.3/src/haptic/windows/SDL_syshaptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -33,12 +33,12 @@ #include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */ #include "../../joystick/windows/SDL_dxjoystick_c.h" /* For joystick hwdata */ -#define MAX_HAPTICS 32 +#include "SDL_syshaptic_c.h" /* * List of available haptic devices. */ -static struct +typedef struct SDL_hapticlist_item { DIDEVICEINSTANCE instance; char *name; @@ -46,7 +46,8 @@ static struct DIDEVCAPS capabilities; Uint8 bXInputHaptic; /* Supports force feedback via XInput. */ Uint8 userid; /* XInput userid index for this joystick */ -} SDL_hapticlist[MAX_HAPTICS]; + struct SDL_hapticlist_item *next; +} SDL_hapticlist_item; /* @@ -83,7 +84,9 @@ struct haptic_hweffect static SDL_bool coinitialized = SDL_FALSE; static LPDIRECTINPUT8 dinput = NULL; static SDL_bool loaded_xinput = SDL_FALSE; - +static SDL_hapticlist_item *SDL_hapticlist = NULL; +static SDL_hapticlist_item *SDL_hapticlist_tail = NULL; +static int numhaptics = 0; /* * External stuff. @@ -101,7 +104,7 @@ static int SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, static int SDL_SYS_HapticOpenFromDevice8(SDL_Haptic * haptic, LPDIRECTINPUTDEVICE8 device8, SDL_bool is_joystick); -static int SDL_SYS_HapticOpenFromXInput(SDL_Haptic * haptic, Uint8 userid); +static int SDL_SYS_HapticOpenFromXInput(SDL_Haptic * haptic, const Uint8 userid); static DWORD DIGetTriggerButton(Uint16 button); static int SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir, int naxes); @@ -155,11 +158,6 @@ SDL_SYS_HapticInit(void) return SDL_SetError("Haptic: SubSystem already open."); } - /* Clear all the memory. */ - SDL_memset(SDL_hapticlist, 0, sizeof(SDL_hapticlist)); - - SDL_numhaptics = 0; - ret = WIN_CoInitialize(); if (FAILED(ret)) { return DI_SetError("Coinitialize", ret); @@ -205,81 +203,266 @@ SDL_SYS_HapticInit(void) if (loaded_xinput) { DWORD i; - const SDL_bool bIs14OrLater = (SDL_XInputVersion >= ((1<<16)|4)); - - for (i = 0; (i < SDL_XINPUT_MAX_DEVICES) && (SDL_numhaptics < MAX_HAPTICS); i++) { - XINPUT_CAPABILITIES caps; - if (XINPUTGETCAPABILITIES(i, XINPUT_FLAG_GAMEPAD, &caps) == ERROR_SUCCESS) { - if ((!bIs14OrLater) || (caps.Flags & XINPUT_CAPS_FFB_SUPPORTED)) { - /* !!! FIXME: I'm not bothering to query for a real name right now. */ - char buf[64]; - SDL_snprintf(buf, sizeof (buf), "XInput Controller #%u", i+1); - SDL_hapticlist[SDL_numhaptics].name = SDL_strdup(buf); - SDL_hapticlist[SDL_numhaptics].bXInputHaptic = 1; - SDL_hapticlist[SDL_numhaptics].userid = (Uint8) i; - SDL_numhaptics++; - } - } + for (i = 0; i < SDL_XINPUT_MAX_DEVICES; i++) { + XInputHaptic_MaybeAddDevice(i); } } - return SDL_numhaptics; + return numhaptics; } + +int +DirectInputHaptic_MaybeAddDevice(const DIDEVICEINSTANCE * pdidInstance) +{ + HRESULT ret; + LPDIRECTINPUTDEVICE8 device; + const DWORD needflags = DIDC_ATTACHED | DIDC_FORCEFEEDBACK; + DIDEVCAPS capabilities; + SDL_hapticlist_item *item = NULL; + + if (dinput == NULL) { + return -1; /* not initialized. We'll pick these up on enumeration if we init later. */ + } + + /* Make sure we don't already have it */ + for (item = SDL_hapticlist; item; item = item->next) { + if ( (!item->bXInputHaptic) && (SDL_memcmp(&item->instance, pdidInstance, sizeof (*pdidInstance)) == 0) ) { + return -1; /* Already added */ + } + } + + /* Open the device */ + ret = IDirectInput8_CreateDevice(dinput, &pdidInstance->guidInstance, &device, NULL); + if (FAILED(ret)) { + /* DI_SetError("Creating DirectInput device",ret); */ + return -1; + } + + /* Get capabilities. */ + SDL_zero(capabilities); + capabilities.dwSize = sizeof (DIDEVCAPS); + ret = IDirectInputDevice8_GetCapabilities(device, &capabilities); + IDirectInputDevice8_Release(device); + if (FAILED(ret)) { + /* DI_SetError("Getting device capabilities",ret); */ + return -1; + } + + if ((capabilities.dwFlags & needflags) != needflags) { + return -1; /* not a device we can use. */ + } + + item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item)); + if (item == NULL) { + return SDL_OutOfMemory(); + } + + item->name = WIN_StringToUTF8(pdidInstance->tszProductName); + if (!item->name) { + SDL_free(item); + return -1; + } + + /* Copy the instance over, useful for creating devices. */ + SDL_memcpy(&item->instance, pdidInstance, sizeof (DIDEVICEINSTANCE)); + SDL_memcpy(&item->capabilities, &capabilities, sizeof (capabilities)); + + if (SDL_hapticlist_tail == NULL) { + SDL_hapticlist = SDL_hapticlist_tail = item; + } else { + SDL_hapticlist_tail->next = item; + SDL_hapticlist_tail = item; + } + + /* Device has been added. */ + ++numhaptics; + + return numhaptics; +} + + +int +DirectInputHaptic_MaybeRemoveDevice(const DIDEVICEINSTANCE * pdidInstance) +{ + SDL_hapticlist_item *item; + SDL_hapticlist_item *prev = NULL; + + if (dinput == NULL) { + return -1; /* not initialized, ignore this. */ + } + + for (item = SDL_hapticlist; item != NULL; item = item->next) { + if ( (!item->bXInputHaptic) && (SDL_memcmp(&item->instance, pdidInstance, sizeof (*pdidInstance)) == 0) ) { + /* found it, remove it. */ + const int retval = item->haptic ? item->haptic->index : -1; + if (prev != NULL) { + prev->next = item->next; + } else { + SDL_assert(SDL_hapticlist == item); + SDL_hapticlist = item->next; + } + if (item == SDL_hapticlist_tail) { + SDL_hapticlist_tail = prev; + } + --numhaptics; + /* !!! TODO: Send a haptic remove event? */ + SDL_free(item); + return retval; + } + prev = item; + } + + return -1; +} + + +int +XInputHaptic_MaybeAddDevice(const DWORD dwUserid) +{ + const Uint8 userid = (Uint8) dwUserid; + XINPUT_CAPABILITIES caps; + const SDL_bool bIs14OrLater = (SDL_XInputVersion >= ((1<<16)|4)); + SDL_hapticlist_item *item; + + if ((!loaded_xinput) || (dwUserid >= SDL_XINPUT_MAX_DEVICES)) { + return -1; + } + + /* Make sure we don't already have it */ + for (item = SDL_hapticlist; item; item = item->next) { + if ((item->bXInputHaptic) && (item->userid == userid)) { + return -1; /* Already added */ + } + } + + if (XINPUTGETCAPABILITIES(dwUserid, XINPUT_FLAG_GAMEPAD, &caps) != ERROR_SUCCESS) { + return -1; /* maybe controller isn't plugged in. */ + } + + /* XInput < 1.4 is probably only for original XBox360 controllers, + which don't offer the flag, and always have force feedback */ + if ( (bIs14OrLater) && ((caps.Flags & XINPUT_CAPS_FFB_SUPPORTED) == 0) ) { + return -1; /* no force feedback on this device. */ + } + + item = (SDL_hapticlist_item *)SDL_malloc( sizeof(SDL_hapticlist_item)); + if (item == NULL) { + return SDL_OutOfMemory(); + } + + SDL_zerop(item); + + /* !!! FIXME: I'm not bothering to query for a real name right now (can we even?) */ + { + char buf[64]; + SDL_snprintf(buf, sizeof (buf), "XInput Controller #%u", (unsigned int) (userid+1)); + item->name = SDL_strdup(buf); + } + + if (!item->name) { + SDL_free(item); + return -1; + } + + /* Copy the instance over, useful for creating devices. */ + item->bXInputHaptic = 1; + item->userid = userid; + + if (SDL_hapticlist_tail == NULL) { + SDL_hapticlist = SDL_hapticlist_tail = item; + } else { + SDL_hapticlist_tail->next = item; + SDL_hapticlist_tail = item; + } + + /* Device has been added. */ + ++numhaptics; + + return numhaptics; +} + + +int +XInputHaptic_MaybeRemoveDevice(const DWORD dwUserid) +{ + const Uint8 userid = (Uint8) dwUserid; + SDL_hapticlist_item *item; + SDL_hapticlist_item *prev = NULL; + + if ((!loaded_xinput) || (dwUserid >= SDL_XINPUT_MAX_DEVICES)) { + return -1; + } + + for (item = SDL_hapticlist; item != NULL; item = item->next) { + if ((item->bXInputHaptic) && (item->userid == userid)) { + /* found it, remove it. */ + const int retval = item->haptic ? item->haptic->index : -1; + if (prev != NULL) { + prev->next = item->next; + } else { + SDL_assert(SDL_hapticlist == item); + SDL_hapticlist = item->next; + } + if (item == SDL_hapticlist_tail) { + SDL_hapticlist_tail = prev; + } + --numhaptics; + /* !!! TODO: Send a haptic remove event? */ + SDL_free(item); + return retval; + } + prev = item; + } + + return -1; +} + + /* * Callback to find the haptic devices. */ static BOOL CALLBACK EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) { - HRESULT ret; - LPDIRECTINPUTDEVICE8 device; - - /* Copy the instance over, useful for creating devices. */ - SDL_memcpy(&SDL_hapticlist[SDL_numhaptics].instance, pdidInstance, - sizeof(DIDEVICEINSTANCE)); - - /* Open the device */ - ret = IDirectInput8_CreateDevice(dinput, &pdidInstance->guidInstance, - &device, NULL); - if (FAILED(ret)) { - /* DI_SetError("Creating DirectInput device",ret); */ - return DIENUM_CONTINUE; - } - - /* Get capabilities. */ - SDL_hapticlist[SDL_numhaptics].capabilities.dwSize = sizeof(DIDEVCAPS); - ret = IDirectInputDevice8_GetCapabilities(device, - &SDL_hapticlist[SDL_numhaptics]. - capabilities); - if (FAILED(ret)) { - /* DI_SetError("Getting device capabilities",ret); */ - IDirectInputDevice8_Release(device); - return DIENUM_CONTINUE; - } - - /* Copy the name */ - SDL_hapticlist[SDL_numhaptics].name = WIN_StringToUTF8(SDL_hapticlist[SDL_numhaptics].instance.tszProductName); - - /* Close up device and count it. */ - IDirectInputDevice8_Release(device); - SDL_numhaptics++; - - /* Watch out for hard limit. */ - if (SDL_numhaptics >= MAX_HAPTICS) - return DIENUM_STOP; - - return DIENUM_CONTINUE; + (void) pContext; + DirectInputHaptic_MaybeAddDevice(pdidInstance); + return DIENUM_CONTINUE; /* continue enumerating */ } +int +SDL_SYS_NumHaptics() +{ + return numhaptics; +} + +static SDL_hapticlist_item * +HapticByDevIndex(int device_index) +{ + SDL_hapticlist_item *item = SDL_hapticlist; + + if ((device_index < 0) || (device_index >= numhaptics)) { + return NULL; + } + + while (device_index > 0) { + SDL_assert(item != NULL); + --device_index; + item = item->next; + } + + return item; +} + /* * Return the name of a haptic device, does not need to be opened. */ const char * SDL_SYS_HapticName(int index) { - return SDL_hapticlist[index].name; + SDL_hapticlist_item *item = HapticByDevIndex(index); + return item->name; } @@ -384,7 +567,7 @@ SDL_SYS_HapticOpenFromInstance(SDL_Haptic * haptic, DIDEVICEINSTANCE instance) } static int -SDL_SYS_HapticOpenFromXInput(SDL_Haptic * haptic, Uint8 userid) +SDL_SYS_HapticOpenFromXInput(SDL_Haptic *haptic, const Uint8 userid) { char threadName[32]; XINPUT_VIBRATION vibration = { 0, 0 }; /* stop any current vibration */ @@ -595,11 +778,8 @@ SDL_SYS_HapticOpenFromDevice8(SDL_Haptic * haptic, int SDL_SYS_HapticOpen(SDL_Haptic * haptic) { - if (SDL_hapticlist[haptic->index].bXInputHaptic) { - return SDL_SYS_HapticOpenFromXInput(haptic, SDL_hapticlist[haptic->index].userid); - } - - return SDL_SYS_HapticOpenFromInstance(haptic, SDL_hapticlist[haptic->index].instance); + SDL_hapticlist_item *item = HapticByDevIndex(haptic->index); + return (item->bXInputHaptic) ? SDL_SYS_HapticOpenFromXInput(haptic, item->userid) : SDL_SYS_HapticOpenFromInstance(haptic, item->instance); } @@ -609,13 +789,16 @@ SDL_SYS_HapticOpen(SDL_Haptic * haptic) int SDL_SYS_HapticMouse(void) { - int i; + SDL_hapticlist_item *item; + int index = 0; /* Grab the first mouse haptic device we find. */ - for (i = 0; i < SDL_numhaptics; i++) { - if (SDL_hapticlist[i].capabilities.dwDevType == DI8DEVCLASS_POINTER ) { - return i; + for (item = SDL_hapticlist; item != NULL; item = item->next) { + SDL_assert(index >= 0); + if (item->capabilities.dwDevType == DI8DEVCLASS_POINTER ) { + return index; } + ++index; } return -1; @@ -677,34 +860,39 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) { - int i; - HRESULT idret; - DIDEVICEINSTANCE joy_instance; - joy_instance.dwSize = sizeof(DIDEVICEINSTANCE); + SDL_hapticlist_item *item; + int index = 0; /* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */ if (joystick->hwdata->bXInputDevice) { const Uint8 userid = joystick->hwdata->userid; - for (i=0; inext) { + if ((item->bXInputHaptic) && (item->userid == userid)) { SDL_assert(joystick->hwdata->bXInputHaptic); - haptic->index = i; - return SDL_SYS_HapticOpenFromXInput(haptic, SDL_hapticlist[haptic->index].userid); + haptic->index = index; + return SDL_SYS_HapticOpenFromXInput(haptic, userid); } + ++index; } } else { - for (i=0; ihwdata->InputDevice, &joy_instance); - if (FAILED(idret)) { - return -1; - } - if (DI_GUIDIsSame(&SDL_hapticlist[i].instance.guidInstance, - &joy_instance.guidInstance)) { - haptic->index = i; + HRESULT idret; + DIDEVICEINSTANCE joy_instance; + + joy_instance.dwSize = sizeof(DIDEVICEINSTANCE); + idret = IDirectInputDevice8_GetDeviceInfo(joystick->hwdata->InputDevice, &joy_instance); + if (FAILED(idret)) { + return -1; + } + + for (item = SDL_hapticlist; item != NULL; item = item->next) { + if (DI_GUIDIsSame(&item->instance.guidInstance, &joy_instance.guidInstance)) { + haptic->index = index; return SDL_SYS_HapticOpenFromDevice8(haptic, joystick->hwdata->InputDevice, SDL_TRUE); } + ++index; } } + /* No match to our haptic list */ return -1; } @@ -749,18 +937,34 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic) void SDL_SYS_HapticQuit(void) { - int i; + SDL_hapticlist_item *item; + SDL_hapticlist_item *next = NULL; + SDL_Haptic *hapticitem = NULL; + + extern SDL_Haptic *SDL_haptics; + for (hapticitem = SDL_haptics; hapticitem; hapticitem = hapticitem->next) { + if ((hapticitem->hwdata->bXInputHaptic) && (hapticitem->hwdata->thread)) { + /* we _have_ to stop the thread before we free the XInput DLL! */ + hapticitem->hwdata->stopThread = 1; + SDL_WaitThread(hapticitem->hwdata->thread, NULL); + hapticitem->hwdata->thread = NULL; + } + } + + for (item = SDL_hapticlist; item; item = next) { + /* Opened and not closed haptics are leaked, this is on purpose. + * Close your haptic devices after usage. */ + /* !!! FIXME: (...is leaking on purpose a good idea?) */ + next = item->next; + SDL_free(item->name); + SDL_free(item); + } if (loaded_xinput) { WIN_UnloadXInputDLL(); loaded_xinput = SDL_FALSE; } - for (i = 0; i < SDL_arraysize(SDL_hapticlist); ++i) { - SDL_free(SDL_hapticlist[i].name); - SDL_hapticlist[i].name = NULL; - } - if (dinput != NULL) { IDirectInput8_Release(dinput); dinput = NULL; diff --git a/jni/SDL2-2.0.3/src/haptic/windows/SDL_syshaptic_c.h b/jni/SDL2-2.0.3/src/haptic/windows/SDL_syshaptic_c.h new file mode 100644 index 00000000..1e0fa190 --- /dev/null +++ b/jni/SDL2-2.0.3/src/haptic/windows/SDL_syshaptic_c.h @@ -0,0 +1,28 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +extern int DirectInputHaptic_MaybeAddDevice(const DIDEVICEINSTANCE *pdidInstance); +extern int DirectInputHaptic_MaybeRemoveDevice(const DIDEVICEINSTANCE *pdidInstance); +extern int XInputHaptic_MaybeAddDevice(const DWORD dwUserid); +extern int XInputHaptic_MaybeRemoveDevice(const DWORD dwUserid); + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/jni/SDL2-2.0.1/src/joystick/SDL_gamecontroller.c b/jni/SDL2-2.0.3/src/joystick/SDL_gamecontroller.c similarity index 98% rename from jni/SDL2-2.0.1/src/joystick/SDL_gamecontroller.c rename to jni/SDL2-2.0.3/src/joystick/SDL_gamecontroller.c index 940e2054..8361b29f 100644 --- a/jni/SDL2-2.0.1/src/joystick/SDL_gamecontroller.c +++ b/jni/SDL2-2.0.3/src/joystick/SDL_gamecontroller.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -88,7 +88,7 @@ typedef struct _ControllerMapping_t } ControllerMapping_t; static ControllerMapping_t *s_pSupportedControllers = NULL; -#ifdef SDL_JOYSTICK_DINPUT +#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT) static ControllerMapping_t *s_pXInputMapping = NULL; #endif @@ -279,7 +279,7 @@ ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickGUID *gu */ ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index) { -#ifdef SDL_JOYSTICK_DINPUT +#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT) if ( SDL_SYS_IsXInputDeviceIndex(device_index) && s_pXInputMapping ) { return s_pXInputMapping; @@ -737,7 +737,7 @@ SDL_GameControllerAddMapping( const char *mappingString ) char *pchMapping; SDL_JoystickGUID jGUID; ControllerMapping_t *pControllerMapping; -#ifdef SDL_JOYSTICK_DINPUT +#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT) SDL_bool is_xinput_mapping = SDL_FALSE; #endif @@ -745,7 +745,7 @@ SDL_GameControllerAddMapping( const char *mappingString ) if (!pchGUID) { return SDL_SetError("Couldn't parse GUID from %s", mappingString); } -#ifdef SDL_JOYSTICK_DINPUT +#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT) if ( !SDL_strcasecmp( pchGUID, "xinput" ) ) { is_xinput_mapping = SDL_TRUE; } @@ -782,7 +782,7 @@ SDL_GameControllerAddMapping( const char *mappingString ) SDL_free( pchMapping ); return SDL_OutOfMemory(); } -#ifdef SDL_JOYSTICK_DINPUT +#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT) if ( is_xinput_mapping ) { s_pXInputMapping = pControllerMapping; @@ -835,6 +835,7 @@ SDL_GameControllerLoadHints() char *pUserMappings = SDL_malloc( nchHints + 1 ); char *pTempMappings = pUserMappings; SDL_memcpy( pUserMappings, hint, nchHints ); + pUserMappings[nchHints] = '\0'; while ( pUserMappings ) { char *pchNewLine = NULL; @@ -1223,6 +1224,7 @@ SDL_GameControllerQuit(void) pControllerMap = s_pSupportedControllers; s_pSupportedControllers = s_pSupportedControllers->next; SDL_free( pControllerMap->name ); + SDL_free( pControllerMap->mapping ); SDL_free( pControllerMap ); } diff --git a/jni/SDL2-2.0.1/src/joystick/SDL_gamecontrollerdb.h b/jni/SDL2-2.0.3/src/joystick/SDL_gamecontrollerdb.h similarity index 84% rename from jni/SDL2-2.0.1/src/joystick/SDL_gamecontrollerdb.h rename to jni/SDL2-2.0.3/src/joystick/SDL_gamecontrollerdb.h index 39ae4efe..34630ca6 100644 --- a/jni/SDL2-2.0.1/src/joystick/SDL_gamecontrollerdb.h +++ b/jni/SDL2-2.0.3/src/joystick/SDL_gamecontrollerdb.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -36,9 +36,13 @@ static const char *s_ControllerMappings [] = "ffff0000000000000000504944564944,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "6d0416c2000000000000504944564944,Generic DirectInput Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "6d0419c2000000000000504944564944,Logitech F710 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */ + "4d6963726f736f66742050432d6a6f79,OUYA Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:b12,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:b13,rightx:a5,righty:a4,x:b1,y:b2,", "88880803000000000000504944564944,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b9,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b0,y:b3,", "4c056802000000000000504944564944,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,", "25090500000000000000504944564944,PS3 DualShock,a:b2,b:b1,back:b9,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b0,y:b3,", + "4c05c405000000000000504944564944,PS4 Controller,a:a3,a:b1,b:b2,back:b8,dpdown:h0.0,dpdown:h0.4,dpleft:h0.8,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,guide:b12,leftshoulder:b4,leftshoulder:h0.0,leftstick:b10,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightshoulder:b6,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:a4,x:b0,y:b3,", + "xinput,X360 Controller,a:b10,b:b11,back:b5,dpdown:b1,dpleft:b2,dpright:b3,dpup:b0,guide:b14,leftshoulder:b8,leftstick:b6,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b7,righttrigger:a5,rightx:a2,righty:a3,start:b4,x:b12,y:b13,", +#elif defined(SDL_JOYSTICK_XINPUT) "xinput,X360 Controller,a:b10,b:b11,back:b5,dpdown:b1,dpleft:b2,dpright:b3,dpup:b0,guide:b14,leftshoulder:b8,leftstick:b6,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b7,righttrigger:a5,rightx:a2,righty:a3,start:b4,x:b12,y:b13,", #elif defined(__MACOSX__) "0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", @@ -47,6 +51,7 @@ static const char *s_ControllerMappings [] = "6d040000000000001fc2000000000000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,", "6d0400000000000019c2000000000000,Logitech Wireless Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* This includes F710 in DInput mode and the "Logitech Cordless RumblePad 2", at the very least. */ "4c050000000000006802000000000000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,", + "4c05000000000000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "5e040000000000008e02000000000000,X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,", #elif defined(__LINUX__) "0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", @@ -56,7 +61,9 @@ static const char *s_ControllerMappings [] = "030000006d0400001ec2000020200000,Logitech F510 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000006d04000019c2000011010000,Logitech F710 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */ "030000006d0400001fc2000005030000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", +"050000003620000100000002010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,platform:Linux,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,", "030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,", + "030000004c050000c405000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000de280000ff11000001000000,Valve Streaming Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", diff --git a/jni/SDL2-2.0.1/src/joystick/SDL_joystick.c b/jni/SDL2-2.0.3/src/joystick/SDL_joystick.c similarity index 99% rename from jni/SDL2-2.0.1/src/joystick/SDL_joystick.c rename to jni/SDL2-2.0.3/src/joystick/SDL_joystick.c index 69aa37d5..062ece33 100644 --- a/jni/SDL2-2.0.1/src/joystick/SDL_joystick.c +++ b/jni/SDL2-2.0.3/src/joystick/SDL_joystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/joystick/SDL_joystick_c.h b/jni/SDL2-2.0.3/src/joystick/SDL_joystick_c.h similarity index 97% rename from jni/SDL2-2.0.1/src/joystick/SDL_joystick_c.h rename to jni/SDL2-2.0.3/src/joystick/SDL_joystick_c.h index 32410638..bb0c0205 100644 --- a/jni/SDL2-2.0.1/src/joystick/SDL_joystick_c.h +++ b/jni/SDL2-2.0.3/src/joystick/SDL_joystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/joystick/SDL_sysjoystick.h b/jni/SDL2-2.0.3/src/joystick/SDL_sysjoystick.h similarity index 97% rename from jni/SDL2-2.0.1/src/joystick/SDL_sysjoystick.h rename to jni/SDL2-2.0.3/src/joystick/SDL_sysjoystick.h index b125c1c7..818509d6 100644 --- a/jni/SDL2-2.0.1/src/joystick/SDL_sysjoystick.h +++ b/jni/SDL2-2.0.3/src/joystick/SDL_sysjoystick.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -108,7 +108,7 @@ extern SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID(int device_index); /* Function to return the stable GUID for a opened joystick */ extern SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick); -#ifdef SDL_JOYSTICK_DINPUT +#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT) /* Function to get the current instance id of the joystick located at device_index */ extern SDL_bool SDL_SYS_IsXInputDeviceIndex( int device_index ); extern SDL_bool SDL_SYS_IsXInputJoystick(SDL_Joystick * joystick); diff --git a/jni/SDL2-2.0.1/src/joystick/android/SDL_sysjoystick.c b/jni/SDL2-2.0.3/src/joystick/android/SDL_sysjoystick.c similarity index 94% rename from jni/SDL2-2.0.1/src/joystick/android/SDL_sysjoystick.c rename to jni/SDL2-2.0.3/src/joystick/android/SDL_sysjoystick.c index d6f38898..422c5f5f 100644 --- a/jni/SDL2-2.0.1/src/joystick/android/SDL_sysjoystick.c +++ b/jni/SDL2-2.0.3/src/joystick/android/SDL_sysjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -226,6 +226,26 @@ Android_OnJoy(int device_id, int axis, float value) return 0; } +int +Android_OnHat(int device_id, int hat_id, int x, int y) +{ + const Uint8 position_map[3][3] = { + {SDL_HAT_LEFTUP, SDL_HAT_UP, SDL_HAT_RIGHTUP}, + {SDL_HAT_LEFT, SDL_HAT_CENTERED, SDL_HAT_RIGHT}, + {SDL_HAT_LEFTDOWN, SDL_HAT_DOWN, SDL_HAT_RIGHTDOWN} + }; + + if (x >= -1 && x <=1 && y >= -1 && y <= 1) { + SDL_joylist_item *item = JoystickByDeviceId(device_id); + if (item && item->joystick) { + SDL_PrivateJoystickHat(item->joystick, hat_id, position_map[y+1][x+1] ); + } + return 0; + } + + return -1; +} + int Android_AddJoystick(int device_id, const char *name, SDL_bool is_accelerometer, int nbuttons, int naxes, int nhats, int nballs) @@ -359,11 +379,11 @@ Android_RemoveJoystick(int device_id) int SDL_SYS_JoystickInit(void) { - const char *env; + const char *hint; SDL_SYS_JoystickDetect(); - env = SDL_GetHint(SDL_HINT_ACCEL_AS_JOY); - if (!env || SDL_atoi(env)) { + hint = SDL_GetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK); + if (!hint || SDL_atoi(hint)) { /* Default behavior, accelerometer as joystick */ Android_AddJoystick(ANDROID_ACCELEROMETER_DEVICE_ID, ANDROID_ACCELEROMETER_NAME, SDL_TRUE, 0, 3, 0, 0); } @@ -497,8 +517,7 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) while (item) { if (item->is_accelerometer) { if (item->joystick) { - SDL_bool updated = Android_JNI_GetAccelerometerValues(values); - if (updated) { + if (Android_JNI_GetAccelerometerValues(values)) { for ( i = 0; i < 3; i++ ) { value = (Sint16)(values[i] * 32767.0f); SDL_PrivateJoystickAxis(item->joystick, i, value); diff --git a/jni/SDL2-2.0.1/src/joystick/android/SDL_sysjoystick_c.h b/jni/SDL2-2.0.3/src/joystick/android/SDL_sysjoystick_c.h similarity index 93% rename from jni/SDL2-2.0.1/src/joystick/android/SDL_sysjoystick_c.h rename to jni/SDL2-2.0.3/src/joystick/android/SDL_sysjoystick_c.h index 1c1d975c..3d56b0b9 100644 --- a/jni/SDL2-2.0.1/src/joystick/android/SDL_sysjoystick_c.h +++ b/jni/SDL2-2.0.3/src/joystick/android/SDL_sysjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -27,6 +27,7 @@ extern int Android_OnPadDown(int device_id, int keycode); extern int Android_OnPadUp(int device_id, int keycode); extern int Android_OnJoy(int device_id, int axisnum, float value); +extern int Android_OnHat(int device_id, int hat_id, int x, int y); extern int Android_AddJoystick(int device_id, const char *name, SDL_bool is_accelerometer, int nbuttons, int naxes, int nhats, int nballs); extern int Android_RemoveJoystick(int device_id); diff --git a/jni/SDL2-2.0.1/src/joystick/bsd/SDL_sysjoystick.c b/jni/SDL2-2.0.3/src/joystick/bsd/SDL_sysjoystick.c similarity index 99% rename from jni/SDL2-2.0.1/src/joystick/bsd/SDL_sysjoystick.c rename to jni/SDL2-2.0.3/src/joystick/bsd/SDL_sysjoystick.c index 3b4c6cd6..2a09f923 100644 --- a/jni/SDL2-2.0.1/src/joystick/bsd/SDL_sysjoystick.c +++ b/jni/SDL2-2.0.3/src/joystick/bsd/SDL_sysjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.3/src/joystick/darwin/SDL_sysjoystick.c b/jni/SDL2-2.0.3/src/joystick/darwin/SDL_sysjoystick.c new file mode 100644 index 00000000..bdface77 --- /dev/null +++ b/jni/SDL2-2.0.3/src/joystick/darwin/SDL_sysjoystick.c @@ -0,0 +1,824 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifdef SDL_JOYSTICK_IOKIT + +#include + +/* For force feedback testing. */ +#include +#include + +#include "SDL_joystick.h" +#include "../SDL_sysjoystick.h" +#include "../SDL_joystick_c.h" +#include "SDL_sysjoystick_c.h" +#include "SDL_events.h" +#include "../../haptic/darwin/SDL_syshaptic_c.h" /* For haptic hot plugging */ +#if !SDL_EVENTS_DISABLED +#include "../../events/SDL_events_c.h" +#endif + +/* The base object of the HID Manager API */ +static IOHIDManagerRef hidman = NULL; + +/* Linked list of all available devices */ +static recDevice *gpDeviceList = NULL; + +/* if SDL_TRUE then a device was added since the last update call */ +static SDL_bool s_bDeviceAdded = SDL_FALSE; +static SDL_bool s_bDeviceRemoved = SDL_FALSE; + +/* static incrementing counter for new joystick devices seen on the system. Devices should start with index 0 */ +static int s_joystick_instance_id = -1; + + +static void +FreeElementList(recElement *pElement) +{ + while (pElement) { + recElement *pElementNext = pElement->pNext; + SDL_free(pElement); + pElement = pElementNext; + } +} + +static recDevice * +FreeDevice(recDevice *removeDevice) +{ + recDevice *pDeviceNext = NULL; + if (removeDevice) { + /* save next device prior to disposing of this device */ + pDeviceNext = removeDevice->pNext; + + if ( gpDeviceList == removeDevice ) { + gpDeviceList = pDeviceNext; + } else { + recDevice *device = gpDeviceList; + while (device->pNext != removeDevice) { + device = device->pNext; + } + device->pNext = pDeviceNext; + } + removeDevice->pNext = NULL; + + /* free element lists */ + FreeElementList(removeDevice->firstAxis); + FreeElementList(removeDevice->firstButton); + FreeElementList(removeDevice->firstHat); + + SDL_free(removeDevice); + } + return pDeviceNext; +} + +static SInt32 +GetHIDElementState(recDevice *pDevice, recElement *pElement) +{ + SInt32 value = 0; + + if (pDevice && pElement) { + IOHIDValueRef valueRef; + if (IOHIDDeviceGetValue(pDevice->deviceRef, pElement->elementRef, &valueRef) == kIOReturnSuccess) { + value = (SInt32) IOHIDValueGetIntegerValue(valueRef); + + /* record min and max for auto calibration */ + if (value < pElement->minReport) { + pElement->minReport = value; + } + if (value > pElement->maxReport) { + pElement->maxReport = value; + } + } + } + + return value; +} + +static SInt32 +GetHIDScaledCalibratedState(recDevice * pDevice, recElement * pElement, SInt32 min, SInt32 max) +{ + const float deviceScale = max - min; + const float readScale = pElement->maxReport - pElement->minReport; + const SInt32 value = GetHIDElementState(pDevice, pElement); + if (readScale == 0) { + return value; /* no scaling at all */ + } + return ((value - pElement->minReport) * deviceScale / readScale) + min; +} + + +static void +JoystickDeviceWasRemovedCallback(void *ctx, IOReturn result, void *sender) +{ + recDevice *device = (recDevice *) ctx; + device->removed = 1; +#if SDL_HAPTIC_IOKIT + MacHaptic_MaybeRemoveDevice(device->ffservice); +#endif + s_bDeviceRemoved = SDL_TRUE; +} + + +static void AddHIDElement(const void *value, void *parameter); + +/* Call AddHIDElement() on all elements in an array of IOHIDElementRefs */ +static void +AddHIDElements(CFArrayRef array, recDevice *pDevice) +{ + const CFRange range = { 0, CFArrayGetCount(array) }; + CFArrayApplyFunction(array, range, AddHIDElement, pDevice); +} + +static SDL_bool +ElementAlreadyAdded(const IOHIDElementCookie cookie, const recElement *listitem) { + while (listitem) { + if (listitem->cookie == cookie) { + return SDL_TRUE; + } + listitem = listitem->pNext; + } + return SDL_FALSE; +} + +/* See if we care about this HID element, and if so, note it in our recDevice. */ +static void +AddHIDElement(const void *value, void *parameter) +{ + recDevice *pDevice = (recDevice *) parameter; + IOHIDElementRef refElement = (IOHIDElementRef) value; + const CFTypeID elementTypeID = refElement ? CFGetTypeID(refElement) : 0; + + if (refElement && (elementTypeID == IOHIDElementGetTypeID())) { + const IOHIDElementCookie cookie = IOHIDElementGetCookie(refElement); + const uint32_t usagePage = IOHIDElementGetUsagePage(refElement); + const uint32_t usage = IOHIDElementGetUsage(refElement); + recElement *element = NULL; + recElement **headElement = NULL; + + /* look at types of interest */ + switch (IOHIDElementGetType(refElement)) { + case kIOHIDElementTypeInput_Misc: + case kIOHIDElementTypeInput_Button: + case kIOHIDElementTypeInput_Axis: { + switch (usagePage) { /* only interested in kHIDPage_GenericDesktop and kHIDPage_Button */ + case kHIDPage_GenericDesktop: + switch (usage) { + case kHIDUsage_GD_X: + case kHIDUsage_GD_Y: + case kHIDUsage_GD_Z: + case kHIDUsage_GD_Rx: + case kHIDUsage_GD_Ry: + case kHIDUsage_GD_Rz: + case kHIDUsage_GD_Slider: + case kHIDUsage_GD_Dial: + case kHIDUsage_GD_Wheel: + if (!ElementAlreadyAdded(cookie, pDevice->firstAxis)) { + element = (recElement *) SDL_calloc(1, sizeof (recElement)); + if (element) { + pDevice->axes++; + headElement = &(pDevice->firstAxis); + } + } + break; + + case kHIDUsage_GD_Hatswitch: + if (!ElementAlreadyAdded(cookie, pDevice->firstHat)) { + element = (recElement *) SDL_calloc(1, sizeof (recElement)); + if (element) { + pDevice->hats++; + headElement = &(pDevice->firstHat); + } + } + break; + } + break; + + case kHIDPage_Simulation: + switch (usage) { + case kHIDUsage_Sim_Rudder: + case kHIDUsage_Sim_Throttle: + if (!ElementAlreadyAdded(cookie, pDevice->firstAxis)) { + element = (recElement *) SDL_calloc(1, sizeof (recElement)); + if (element) { + pDevice->axes++; + headElement = &(pDevice->firstAxis); + } + } + break; + + default: + break; + } + break; + + case kHIDPage_Button: + if (!ElementAlreadyAdded(cookie, pDevice->firstButton)) { + element = (recElement *) SDL_calloc(1, sizeof (recElement)); + if (element) { + pDevice->buttons++; + headElement = &(pDevice->firstButton); + } + } + break; + + default: + break; + } + } + break; + + case kIOHIDElementTypeCollection: { + CFArrayRef array = IOHIDElementGetChildren(refElement); + if (array) { + AddHIDElements(array, pDevice); + } + } + break; + + default: + break; + } + + if (element && headElement) { /* add to list */ + recElement *elementPrevious = NULL; + recElement *elementCurrent = *headElement; + while (elementCurrent && usage >= elementCurrent->usage) { + elementPrevious = elementCurrent; + elementCurrent = elementCurrent->pNext; + } + if (elementPrevious) { + elementPrevious->pNext = element; + } else { + *headElement = element; + } + + element->elementRef = refElement; + element->usagePage = usagePage; + element->usage = usage; + element->pNext = elementCurrent; + + element->minReport = element->min = (SInt32) IOHIDElementGetLogicalMin(refElement); + element->maxReport = element->max = (SInt32) IOHIDElementGetLogicalMax(refElement); + element->cookie = IOHIDElementGetCookie(refElement); + + pDevice->elements++; + } + } +} + +static SDL_bool +GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice) +{ + Uint32 *guid32 = NULL; + CFTypeRef refCF = NULL; + CFArrayRef array = NULL; + + /* get usage page and usage */ + refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDPrimaryUsagePageKey)); + if (refCF) { + CFNumberGetValue(refCF, kCFNumberSInt32Type, &pDevice->usagePage); + } + if (pDevice->usagePage != kHIDPage_GenericDesktop) { + return SDL_FALSE; /* Filter device list to non-keyboard/mouse stuff */ + } + + refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDPrimaryUsageKey)); + if (refCF) { + CFNumberGetValue(refCF, kCFNumberSInt32Type, &pDevice->usage); + } + + if ((pDevice->usage != kHIDUsage_GD_Joystick && + pDevice->usage != kHIDUsage_GD_GamePad && + pDevice->usage != kHIDUsage_GD_MultiAxisController)) { + return SDL_FALSE; /* Filter device list to non-keyboard/mouse stuff */ + } + + pDevice->deviceRef = hidDevice; + + /* get device name */ + refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDProductKey)); + if (!refCF) { + /* Maybe we can't get "AwesomeJoystick2000", but we can get "Logitech"? */ + refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDManufacturerKey)); + } + if ((!refCF) || (!CFStringGetCString(refCF, pDevice->product, sizeof (pDevice->product), kCFStringEncodingUTF8))) { + SDL_strlcpy(pDevice->product, "Unidentified joystick", sizeof (pDevice->product)); + } + + refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDVendorIDKey)); + if (refCF) { + CFNumberGetValue(refCF, kCFNumberSInt32Type, &pDevice->guid.data[0]); + } + + refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDProductIDKey)); + if (refCF) { + CFNumberGetValue(refCF, kCFNumberSInt32Type, &pDevice->guid.data[8]); + } + + /* Check to make sure we have a vendor and product ID + If we don't, use the same algorithm as the Linux code for Bluetooth devices */ + guid32 = (Uint32*)pDevice->guid.data; + if (!guid32[0] && !guid32[1]) { + /* If we don't have a vendor and product ID this is probably a Bluetooth device */ + const Uint16 BUS_BLUETOOTH = 0x05; + Uint16 *guid16 = (Uint16 *)guid32; + *guid16++ = BUS_BLUETOOTH; + *guid16++ = 0; + SDL_strlcpy((char*)guid16, pDevice->product, sizeof(pDevice->guid.data) - 4); + } + + array = IOHIDDeviceCopyMatchingElements(hidDevice, NULL, kIOHIDOptionsTypeNone); + if (array) { + AddHIDElements(array, pDevice); + CFRelease(array); + } + + return SDL_TRUE; +} + + +static void +JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDeviceRef ioHIDDeviceObject) +{ + if (res != kIOReturnSuccess) { + return; + } + + recDevice *device = (recDevice *) SDL_calloc(1, sizeof(recDevice)); + + if (!device) { + SDL_OutOfMemory(); + return; + } + + if (!GetDeviceInfo(ioHIDDeviceObject, device)) { + SDL_free(device); + return; /* not a device we care about, probably. */ + } + + /* Get notified when this device is disconnected. */ + IOHIDDeviceRegisterRemovalCallback(ioHIDDeviceObject, JoystickDeviceWasRemovedCallback, device); + IOHIDDeviceScheduleWithRunLoop(ioHIDDeviceObject, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); + + /* Allocate an instance ID for this device */ + device->instance_id = ++s_joystick_instance_id; + + /* We have to do some storage of the io_service_t for SDL_HapticOpenFromJoystick */ + if (IOHIDDeviceGetService != NULL) { /* weak reference: available in 10.6 and later. */ + const io_service_t ioservice = IOHIDDeviceGetService(ioHIDDeviceObject); + if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK)) { + device->ffservice = ioservice; +#if SDL_HAPTIC_IOKIT + MacHaptic_MaybeAddDevice(ioservice); +#endif + } + } + + device->send_open_event = 1; + s_bDeviceAdded = SDL_TRUE; + + /* Add device to the end of the list */ + if ( !gpDeviceList ) + { + gpDeviceList = device; + } + else + { + recDevice *curdevice; + + curdevice = gpDeviceList; + while ( curdevice->pNext ) + { + curdevice = curdevice->pNext; + } + curdevice->pNext = device; + } +} + +static SDL_bool +ConfigHIDManager(CFArrayRef matchingArray) +{ + CFRunLoopRef runloop = CFRunLoopGetCurrent(); + + /* Run in a custom RunLoop mode just while initializing, + so we can detect sticks without messing with everything else. */ + CFStringRef tempRunLoopMode = CFSTR("SDLJoystickInit"); + + if (IOHIDManagerOpen(hidman, kIOHIDOptionsTypeNone) != kIOReturnSuccess) { + return SDL_FALSE; + } + + IOHIDManagerRegisterDeviceMatchingCallback(hidman, JoystickDeviceWasAddedCallback, NULL); + IOHIDManagerScheduleWithRunLoop(hidman, runloop, tempRunLoopMode); + IOHIDManagerSetDeviceMatchingMultiple(hidman, matchingArray); + + while (CFRunLoopRunInMode(tempRunLoopMode,0,TRUE)==kCFRunLoopRunHandledSource) { + /* no-op. Callback fires once per existing device. */ + } + + /* Put this in the normal RunLoop mode now, for future hotplug events. */ + IOHIDManagerUnscheduleFromRunLoop(hidman, runloop, tempRunLoopMode); + IOHIDManagerScheduleWithRunLoop(hidman, runloop, kCFRunLoopDefaultMode); + + return SDL_TRUE; /* good to go. */ +} + + +static CFDictionaryRef +CreateHIDDeviceMatchDictionary(const UInt32 page, const UInt32 usage, int *okay) +{ + CFDictionaryRef retval = NULL; + CFNumberRef pageNumRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page); + CFNumberRef usageNumRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage); + const void *keys[2] = { (void *) CFSTR(kIOHIDDeviceUsagePageKey), (void *) CFSTR(kIOHIDDeviceUsageKey) }; + const void *vals[2] = { (void *) pageNumRef, (void *) usageNumRef }; + + if (pageNumRef && usageNumRef) { + retval = CFDictionaryCreate(kCFAllocatorDefault, keys, vals, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + } + + if (pageNumRef) { + CFRelease(pageNumRef); + } + if (usageNumRef) { + CFRelease(usageNumRef); + } + + if (!retval) { + *okay = 0; + } + + return retval; +} + +static SDL_bool +CreateHIDManager(void) +{ + SDL_bool retval = SDL_FALSE; + int okay = 1; + const void *vals[] = { + (void *) CreateHIDDeviceMatchDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick, &okay), + (void *) CreateHIDDeviceMatchDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad, &okay), + (void *) CreateHIDDeviceMatchDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_MultiAxisController, &okay), + }; + const size_t numElements = SDL_arraysize(vals); + CFArrayRef array = okay ? CFArrayCreate(kCFAllocatorDefault, vals, numElements, &kCFTypeArrayCallBacks) : NULL; + size_t i; + + for (i = 0; i < numElements; i++) { + if (vals[i]) { + CFRelease((CFTypeRef) vals[i]); + } + } + + if (array) { + hidman = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); + if (hidman != NULL) { + retval = ConfigHIDManager(array); + } + CFRelease(array); + } + + return retval; +} + + +/* Function to scan the system for joysticks. + * Joystick 0 should be the system default joystick. + * This function should return the number of available joysticks, or -1 + * on an unrecoverable fatal error. + */ +int +SDL_SYS_JoystickInit(void) +{ + if (gpDeviceList) { + return SDL_SetError("Joystick: Device list already inited."); + } + + if (!CreateHIDManager()) { + return SDL_SetError("Joystick: Couldn't initialize HID Manager"); + } + + return SDL_SYS_NumJoysticks(); +} + +/* Function to return the number of joystick devices plugged in right now */ +int +SDL_SYS_NumJoysticks() +{ + recDevice *device = gpDeviceList; + int nJoySticks = 0; + + while (device) { + if (!device->removed) { + nJoySticks++; + } + device = device->pNext; + } + + return nJoySticks; +} + +/* Function to cause any queued joystick insertions to be processed + */ +void +SDL_SYS_JoystickDetect() +{ + if (s_bDeviceAdded || s_bDeviceRemoved) { + recDevice *device = gpDeviceList; + s_bDeviceAdded = SDL_FALSE; + s_bDeviceRemoved = SDL_FALSE; + int device_index = 0; + /* send notifications */ + while (device) { + if (device->send_open_event) { + device->send_open_event = 0; +/* !!! FIXME: why isn't there an SDL_PrivateJoyDeviceAdded()? */ +#if !SDL_EVENTS_DISABLED + SDL_Event event; + event.type = SDL_JOYDEVICEADDED; + + if (SDL_GetEventState(event.type) == SDL_ENABLE) { + event.jdevice.which = device_index; + if ((SDL_EventOK == NULL) + || (*SDL_EventOK) (SDL_EventOKParam, &event)) { + SDL_PushEvent(&event); + } + } +#endif /* !SDL_EVENTS_DISABLED */ + + } + + if (device->removed) { + const int instance_id = device->instance_id; + device = FreeDevice(device); + +/* !!! FIXME: why isn't there an SDL_PrivateJoyDeviceRemoved()? */ +#if !SDL_EVENTS_DISABLED + SDL_Event event; + event.type = SDL_JOYDEVICEREMOVED; + + if (SDL_GetEventState(event.type) == SDL_ENABLE) { + event.jdevice.which = instance_id; + if ((SDL_EventOK == NULL) + || (*SDL_EventOK) (SDL_EventOKParam, &event)) { + SDL_PushEvent(&event); + } + } +#endif /* !SDL_EVENTS_DISABLED */ + + } else { + device = device->pNext; + device_index++; + } + } + } +} + +SDL_bool +SDL_SYS_JoystickNeedsPolling() +{ + return s_bDeviceAdded || s_bDeviceRemoved; +} + +/* Function to get the device-dependent name of a joystick */ +const char * +SDL_SYS_JoystickNameForDeviceIndex(int device_index) +{ + recDevice *device = gpDeviceList; + + while (device_index-- > 0) { + device = device->pNext; + } + + return device->product; +} + +/* Function to return the instance id of the joystick at device_index + */ +SDL_JoystickID +SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index) +{ + recDevice *device = gpDeviceList; + int index; + + for (index = device_index; index > 0; index--) { + device = device->pNext; + } + + return device->instance_id; +} + +/* Function to open a joystick for use. + * The joystick to open is specified by the index field of the joystick. + * This should fill the nbuttons and naxes fields of the joystick structure. + * It returns 0, or -1 if there is an error. + */ +int +SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) +{ + recDevice *device = gpDeviceList; + int index; + + for (index = device_index; index > 0; index--) { + device = device->pNext; + } + + joystick->instance_id = device->instance_id; + joystick->hwdata = device; + joystick->name = device->product; + + joystick->naxes = device->axes; + joystick->nhats = device->hats; + joystick->nballs = 0; + joystick->nbuttons = device->buttons; + return 0; +} + +/* Function to query if the joystick is currently attached + * It returns 1 if attached, 0 otherwise. + */ +SDL_bool +SDL_SYS_JoystickAttached(SDL_Joystick * joystick) +{ + recDevice *device = gpDeviceList; + + while (device) { + if (joystick->instance_id == device->instance_id) { + return SDL_TRUE; + } + device = device->pNext; + } + + return SDL_FALSE; +} + +/* Function to update the state of a joystick - called as a device poll. + * This function shouldn't update the joystick structure directly, + * but instead should call SDL_PrivateJoystick*() to deliver events + * and update joystick device state. + */ +void +SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) +{ + recDevice *device = joystick->hwdata; + recElement *element; + SInt32 value, range; + int i; + + if (!device) { + return; + } + + if (device->removed) { /* device was unplugged; ignore it. */ + joystick->closed = 1; + joystick->uncentered = 1; + joystick->hwdata = NULL; + return; + } + + element = device->firstAxis; + i = 0; + while (element) { + value = GetHIDScaledCalibratedState(device, element, -32768, 32767); + if (value != joystick->axes[i]) { + SDL_PrivateJoystickAxis(joystick, i, value); + } + element = element->pNext; + ++i; + } + + element = device->firstButton; + i = 0; + while (element) { + value = GetHIDElementState(device, element); + if (value > 1) { /* handle pressure-sensitive buttons */ + value = 1; + } + if (value != joystick->buttons[i]) { + SDL_PrivateJoystickButton(joystick, i, value); + } + element = element->pNext; + ++i; + } + + element = device->firstHat; + i = 0; + while (element) { + Uint8 pos = 0; + + range = (element->max - element->min + 1); + value = GetHIDElementState(device, element) - element->min; + if (range == 4) { /* 4 position hatswitch - scale up value */ + value *= 2; + } else if (range != 8) { /* Neither a 4 nor 8 positions - fall back to default position (centered) */ + value = -1; + } + switch (value) { + case 0: + pos = SDL_HAT_UP; + break; + case 1: + pos = SDL_HAT_RIGHTUP; + break; + case 2: + pos = SDL_HAT_RIGHT; + break; + case 3: + pos = SDL_HAT_RIGHTDOWN; + break; + case 4: + pos = SDL_HAT_DOWN; + break; + case 5: + pos = SDL_HAT_LEFTDOWN; + break; + case 6: + pos = SDL_HAT_LEFT; + break; + case 7: + pos = SDL_HAT_LEFTUP; + break; + default: + /* Every other value is mapped to center. We do that because some + * joysticks use 8 and some 15 for this value, and apparently + * there are even more variants out there - so we try to be generous. + */ + pos = SDL_HAT_CENTERED; + break; + } + + if (pos != joystick->hats[i]) { + SDL_PrivateJoystickHat(joystick, i, pos); + } + + element = element->pNext; + ++i; + } +} + +/* Function to close a joystick after use */ +void +SDL_SYS_JoystickClose(SDL_Joystick * joystick) +{ + joystick->closed = 1; +} + +/* Function to perform any system-specific joystick related cleanup */ +void +SDL_SYS_JoystickQuit(void) +{ + while (FreeDevice(gpDeviceList)) { + /* spin */ + } + + if (hidman) { + IOHIDManagerClose(hidman, kIOHIDOptionsTypeNone); + CFRelease(hidman); + hidman = NULL; + } + + s_bDeviceAdded = s_bDeviceRemoved = SDL_FALSE; +} + + +SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) +{ + recDevice *device = gpDeviceList; + int index; + + for (index = device_index; index > 0; index--) { + device = device->pNext; + } + + return device->guid; +} + +SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick *joystick) +{ + return joystick->hwdata->guid; +} + +#endif /* SDL_JOYSTICK_IOKIT */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/joystick/darwin/SDL_sysjoystick_c.h b/jni/SDL2-2.0.3/src/joystick/darwin/SDL_sysjoystick_c.h new file mode 100644 index 00000000..0a15ba18 --- /dev/null +++ b/jni/SDL2-2.0.3/src/joystick/darwin/SDL_sysjoystick_c.h @@ -0,0 +1,73 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifndef SDL_JOYSTICK_IOKIT_H + +#include + +struct recElement +{ + IOHIDElementRef elementRef; + IOHIDElementCookie cookie; + uint32_t usagePage, usage; /* HID usage */ + SInt32 min; /* reported min value possible */ + SInt32 max; /* reported max value possible */ + + /* runtime variables used for auto-calibration */ + SInt32 minReport; /* min returned value */ + SInt32 maxReport; /* max returned value */ + + struct recElement *pNext; /* next element in list */ +}; +typedef struct recElement recElement; + +struct joystick_hwdata +{ + IOHIDDeviceRef deviceRef; /* HIDManager device handle */ + io_service_t ffservice; /* Interface for force feedback, 0 = no ff */ + + char product[256]; /* name of product */ + uint32_t usage; /* usage page from IOUSBHID Parser.h which defines general usage */ + uint32_t usagePage; /* usage within above page from IOUSBHID Parser.h which defines specific usage */ + + int axes; /* number of axis (calculated, not reported by device) */ + int buttons; /* number of buttons (calculated, not reported by device) */ + int hats; /* number of hat switches (calculated, not reported by device) */ + int elements; /* number of total elements (should be total of above) (calculated, not reported by device) */ + + recElement *firstAxis; + recElement *firstButton; + recElement *firstHat; + + int removed; + int uncentered; + + int instance_id; + SDL_JoystickGUID guid; + Uint8 send_open_event; /* 1 if we need to send an Added event for this device */ + + struct joystick_hwdata *pNext; /* next device */ +}; +typedef struct joystick_hwdata recDevice; + + +#endif /* SDL_JOYSTICK_IOKIT_H */ diff --git a/jni/SDL2-2.0.1/src/joystick/dummy/SDL_sysjoystick.c b/jni/SDL2-2.0.3/src/joystick/dummy/SDL_sysjoystick.c similarity index 96% rename from jni/SDL2-2.0.1/src/joystick/dummy/SDL_sysjoystick.c rename to jni/SDL2-2.0.3/src/joystick/dummy/SDL_sysjoystick.c index 4ec6d1bd..0d45b6ce 100644 --- a/jni/SDL2-2.0.1/src/joystick/dummy/SDL_sysjoystick.c +++ b/jni/SDL2-2.0.3/src/joystick/dummy/SDL_sysjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -22,7 +22,7 @@ #if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED) -/* This is the system specific header for the SDL joystick API */ +/* This is the dummy implementation of the SDL joystick API */ #include "SDL_joystick.h" #include "../SDL_sysjoystick.h" diff --git a/jni/SDL2-2.0.1/src/joystick/haiku/SDL_haikujoystick.cc b/jni/SDL2-2.0.3/src/joystick/haiku/SDL_haikujoystick.cc similarity index 98% rename from jni/SDL2-2.0.1/src/joystick/haiku/SDL_haikujoystick.cc rename to jni/SDL2-2.0.3/src/joystick/haiku/SDL_haikujoystick.cc index e3c98414..95757bc1 100644 --- a/jni/SDL2-2.0.1/src/joystick/haiku/SDL_haikujoystick.cc +++ b/jni/SDL2-2.0.3/src/joystick/haiku/SDL_haikujoystick.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -22,7 +22,7 @@ #ifdef SDL_JOYSTICK_HAIKU -/* This is the system specific header for the SDL joystick API */ +/* This is the Haiku implementation of the SDL joystick API */ #include #include diff --git a/jni/SDL2-2.0.1/src/joystick/iphoneos/SDLUIAccelerationDelegate.h b/jni/SDL2-2.0.3/src/joystick/iphoneos/SDLUIAccelerationDelegate.h similarity index 95% rename from jni/SDL2-2.0.1/src/joystick/iphoneos/SDLUIAccelerationDelegate.h rename to jni/SDL2-2.0.3/src/joystick/iphoneos/SDLUIAccelerationDelegate.h index 733357b4..bb3e0d61 100644 --- a/jni/SDL2-2.0.1/src/joystick/iphoneos/SDLUIAccelerationDelegate.h +++ b/jni/SDL2-2.0.3/src/joystick/iphoneos/SDLUIAccelerationDelegate.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/joystick/iphoneos/SDLUIAccelerationDelegate.m b/jni/SDL2-2.0.3/src/joystick/iphoneos/SDLUIAccelerationDelegate.m similarity index 98% rename from jni/SDL2-2.0.1/src/joystick/iphoneos/SDLUIAccelerationDelegate.m rename to jni/SDL2-2.0.3/src/joystick/iphoneos/SDLUIAccelerationDelegate.m index 0037c585..a099fcf3 100644 --- a/jni/SDL2-2.0.1/src/joystick/iphoneos/SDLUIAccelerationDelegate.m +++ b/jni/SDL2-2.0.3/src/joystick/iphoneos/SDLUIAccelerationDelegate.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/joystick/iphoneos/SDL_sysjoystick.m b/jni/SDL2-2.0.3/src/joystick/iphoneos/SDL_sysjoystick.m similarity index 97% rename from jni/SDL2-2.0.1/src/joystick/iphoneos/SDL_sysjoystick.m rename to jni/SDL2-2.0.3/src/joystick/iphoneos/SDL_sysjoystick.m index 31d40a5f..b89bd78e 100644 --- a/jni/SDL2-2.0.1/src/joystick/iphoneos/SDL_sysjoystick.m +++ b/jni/SDL2-2.0.3/src/joystick/iphoneos/SDL_sysjoystick.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -20,7 +20,7 @@ */ #include "../../SDL_internal.h" -/* This is the system specific header for the SDL joystick API */ +/* This is the iOS implementation of the SDL joystick API */ #include "SDL_joystick.h" #include "../SDL_sysjoystick.h" diff --git a/jni/SDL2-2.0.1/src/joystick/linux/SDL_sysjoystick.c b/jni/SDL2-2.0.3/src/joystick/linux/SDL_sysjoystick.c similarity index 99% rename from jni/SDL2-2.0.1/src/joystick/linux/SDL_sysjoystick.c rename to jni/SDL2-2.0.3/src/joystick/linux/SDL_sysjoystick.c index a8e10bc7..c37a22d5 100644 --- a/jni/SDL2-2.0.1/src/joystick/linux/SDL_sysjoystick.c +++ b/jni/SDL2-2.0.3/src/joystick/linux/SDL_sysjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -26,7 +26,7 @@ #error SDL now requires a Linux 2.4+ kernel with /dev/input/event support. #endif -/* This is the system specific header for the SDL joystick API */ +/* This is the Linux implementation of the SDL joystick API */ #include #include diff --git a/jni/SDL2-2.0.1/src/joystick/linux/SDL_sysjoystick_c.h b/jni/SDL2-2.0.3/src/joystick/linux/SDL_sysjoystick_c.h similarity index 96% rename from jni/SDL2-2.0.1/src/joystick/linux/SDL_sysjoystick_c.h rename to jni/SDL2-2.0.3/src/joystick/linux/SDL_sysjoystick_c.h index 4e942b54..16d16e26 100644 --- a/jni/SDL2-2.0.1/src/joystick/linux/SDL_sysjoystick_c.h +++ b/jni/SDL2-2.0.3/src/joystick/linux/SDL_sysjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/joystick/psp/SDL_sysjoystick.c b/jni/SDL2-2.0.3/src/joystick/psp/SDL_sysjoystick.c similarity index 98% rename from jni/SDL2-2.0.1/src/joystick/psp/SDL_sysjoystick.c rename to jni/SDL2-2.0.3/src/joystick/psp/SDL_sysjoystick.c index b953372d..d01489bb 100644 --- a/jni/SDL2-2.0.1/src/joystick/psp/SDL_sysjoystick.c +++ b/jni/SDL2-2.0.3/src/joystick/psp/SDL_sysjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -19,7 +19,7 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* This is the system specific header for the SDL joystick API */ +/* This is the PSP implementation of the SDL joystick API */ #include #include diff --git a/jni/SDL2-2.0.1/src/joystick/sort_controllers.py b/jni/SDL2-2.0.3/src/joystick/sort_controllers.py similarity index 100% rename from jni/SDL2-2.0.1/src/joystick/sort_controllers.py rename to jni/SDL2-2.0.3/src/joystick/sort_controllers.py diff --git a/jni/SDL2-2.0.1/src/joystick/windows/SDL_dxjoystick.c b/jni/SDL2-2.0.3/src/joystick/windows/SDL_dxjoystick.c similarity index 98% rename from jni/SDL2-2.0.1/src/joystick/windows/SDL_dxjoystick.c rename to jni/SDL2-2.0.3/src/joystick/windows/SDL_dxjoystick.c index c8a0d7ba..3c009746 100644 --- a/jni/SDL2-2.0.1/src/joystick/windows/SDL_dxjoystick.c +++ b/jni/SDL2-2.0.3/src/joystick/windows/SDL_dxjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -49,6 +49,10 @@ #define INITGUID /* Only set here, if set twice will cause mingw32 to break. */ #include "SDL_dxjoystick_c.h" +#if SDL_HAPTIC_DINPUT +#include "../../haptic/windows/SDL_syshaptic_c.h" /* For haptic hot plugging */ +#endif + #ifndef DIDFT_OPTIONAL #define DIDFT_OPTIONAL 0x80000000 #endif @@ -778,7 +782,7 @@ EnumXInputDevices(JoyStick_DeviceData **pContext) XINPUT_CAPABILITIES capabilities; if (XINPUTGETCAPABILITIES(userid, XINPUT_FLAG_GAMEPAD, &capabilities) == ERROR_SUCCESS) { /* Current version of XInput mistakenly returns 0 as the Type. Ignore it and ensure the subtype is a gamepad. */ - /* !!! FIXME: we might want to support steering wheels or guitars or whatever laster. */ + /* !!! FIXME: we might want to support steering wheels or guitars or whatever later. */ if (capabilities.SubType == XINPUT_DEVSUBTYPE_GAMEPAD) { AddXInputDevice(userid, pContext); } @@ -824,7 +828,17 @@ void SDL_SYS_JoystickDetect() while ( pCurList ) { JoyStick_DeviceData *pListNext = NULL; + +#if SDL_HAPTIC_DINPUT + if (pCurList->bXInputDevice) { + XInputHaptic_MaybeRemoveDevice(pCurList->XInputUserId); + } else { + DirectInputHaptic_MaybeRemoveDevice(&pCurList->dxdevice); + } +#endif + #if !SDL_EVENTS_DISABLED + { SDL_Event event; event.type = SDL_JOYDEVICEREMOVED; @@ -835,6 +849,7 @@ void SDL_SYS_JoystickDetect() SDL_PushEvent(&event); } } + } #endif /* !SDL_EVENTS_DISABLED */ pListNext = pCurList->pNext; @@ -855,7 +870,16 @@ void SDL_SYS_JoystickDetect() { if ( pNewJoystick->send_add_event ) { +#if SDL_HAPTIC_DINPUT + if (pNewJoystick->bXInputDevice) { + XInputHaptic_MaybeAddDevice(pNewJoystick->XInputUserId); + } else { + DirectInputHaptic_MaybeAddDevice(&pNewJoystick->dxdevice); + } +#endif + #if !SDL_EVENTS_DISABLED + { SDL_Event event; event.type = SDL_JOYDEVICEADDED; @@ -866,6 +890,7 @@ void SDL_SYS_JoystickDetect() SDL_PushEvent(&event); } } + } #endif /* !SDL_EVENTS_DISABLED */ pNewJoystick->send_add_event = 0; } @@ -1423,6 +1448,7 @@ SDL_SYS_JoystickUpdate_XInput(SDL_Joystick * joystick) XINPUT_STATE_EX *pXInputState = &joystick->hwdata->XInputState[joystick->hwdata->currentXInputSlot]; XINPUT_STATE_EX *pXInputStatePrev = &joystick->hwdata->XInputState[joystick->hwdata->currentXInputSlot ^ 1]; + /* !!! FIXME: why isn't this just using SDL_PrivateJoystickAxis_Int()? */ SDL_PrivateJoystickAxis( joystick, 0, (Sint16)pXInputState->Gamepad.sThumbLX ); SDL_PrivateJoystickAxis( joystick, 1, (Sint16)(-SDL_max(-32767, pXInputState->Gamepad.sThumbLY)) ); SDL_PrivateJoystickAxis( joystick, 2, (Sint16)pXInputState->Gamepad.sThumbRX ); @@ -1430,6 +1456,7 @@ SDL_SYS_JoystickUpdate_XInput(SDL_Joystick * joystick) SDL_PrivateJoystickAxis( joystick, 4, (Sint16)(((int)pXInputState->Gamepad.bLeftTrigger*65535/255) - 32768)); SDL_PrivateJoystickAxis( joystick, 5, (Sint16)(((int)pXInputState->Gamepad.bRightTrigger*65535/255) - 32768)); + /* !!! FIXME: why isn't this just using SDL_PrivateJoystickButton_Int(), instead of keeping these two alternating state buffers? */ if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_UP ) ) SDL_PrivateJoystickButton(joystick, 0, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP ? SDL_PRESSED : SDL_RELEASED ); if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_DOWN ) ) @@ -1497,6 +1524,7 @@ TranslatePOV(DWORD value) /* SDL_PrivateJoystick* doesn't discard duplicate events, so we need to * do it. */ +/* !!! FIXME: SDL_PrivateJoystickAxis _does_ discard duplicate events now. Ditch this code. */ static int SDL_PrivateJoystickAxis_Int(SDL_Joystick * joystick, Uint8 axis, Sint16 value) { diff --git a/jni/SDL2-2.0.1/src/joystick/windows/SDL_dxjoystick_c.h b/jni/SDL2-2.0.3/src/joystick/windows/SDL_dxjoystick_c.h similarity index 98% rename from jni/SDL2-2.0.1/src/joystick/windows/SDL_dxjoystick_c.h rename to jni/SDL2-2.0.3/src/joystick/windows/SDL_dxjoystick_c.h index 9e04881b..2808fed5 100644 --- a/jni/SDL2-2.0.1/src/joystick/windows/SDL_dxjoystick_c.h +++ b/jni/SDL2-2.0.3/src/joystick/windows/SDL_dxjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/joystick/windows/SDL_mmjoystick.c b/jni/SDL2-2.0.3/src/joystick/windows/SDL_mmjoystick.c similarity index 99% rename from jni/SDL2-2.0.1/src/joystick/windows/SDL_mmjoystick.c rename to jni/SDL2-2.0.3/src/joystick/windows/SDL_mmjoystick.c index 824ecc93..c28ed91b 100644 --- a/jni/SDL2-2.0.1/src/joystick/windows/SDL_mmjoystick.c +++ b/jni/SDL2-2.0.3/src/joystick/windows/SDL_mmjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.3/src/joystick/winrt/SDL_xinputjoystick.c b/jni/SDL2-2.0.3/src/joystick/winrt/SDL_xinputjoystick.c new file mode 100644 index 00000000..00005080 --- /dev/null +++ b/jni/SDL2-2.0.3/src/joystick/winrt/SDL_xinputjoystick.c @@ -0,0 +1,537 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_JOYSTICK_XINPUT + +/* SDL_xinputjoystick.c implements an XInput-only joystick and game controller + backend that is suitable for use on WinRT. SDL's DirectInput backend, also + XInput-capable, was not used as DirectInput is not available on WinRT (or, + at least, it isn't a public API). Some portions of this XInput backend + may copy parts of the XInput-using code from the DirectInput backend. + Refactoring the common parts into one location may be good to-do at some + point. + + TODO, WinRT: add hotplug support for XInput based game controllers +*/ + +#include "SDL_joystick.h" +#include "../SDL_sysjoystick.h" +#include "../SDL_joystick_c.h" +#include "SDL_events.h" +#include "../../events/SDL_events_c.h" +#include "SDL_timer.h" + +#include +#include + +struct joystick_hwdata { + //Uint8 bXInputHaptic; // Supports force feedback via XInput. + DWORD userIndex; // The XInput device index, in the range [0, XUSER_MAX_COUNT-1] (probably [0,3]). + XINPUT_STATE XInputState; // the last-read in XInputState, kept around to compare old and new values + SDL_bool isDeviceConnected; // was the device connected (on the last detection-polling, or during backend-initialization)? + SDL_bool isDeviceConnectionEventPending; // was a device added, and is the associated add-event pending? + SDL_bool isDeviceRemovalEventPending; // was the device removed, and is the associated remove-event pending? +}; + +/* Keep track of data on all XInput devices, regardless of whether or not + they've been opened (via SDL_JoystickOpen). + */ +static struct joystick_hwdata g_XInputData[XUSER_MAX_COUNT]; + +/* Device detection can be extremely costly performance-wise, in some cases. + In particular, if no devices are connected, calls to detect a single device, + via either XInputGetState() or XInputGetCapabilities(), can take upwards of + 20 ms on a 1st generation Surface RT, more if devices are detected across + all of of XInput's four device slots. WinRT and XInput do not appear to + have callback-based APIs to notify an app when a device is connected, at + least as of Windows 8.1. The synchronous XInput calls must be used. + + Once a device is connected, calling XInputGetState() is a much less costly + operation, with individual calls costing well under 1 ms, and often under + 0.1 ms [on a 1st gen Surface RT]. + + With XInput's performance limitations in mind, a separate device-detection + thread will be utilized (by SDL) to try to move costly XInput calls off the + main thread. Polling of active devices still, however, occurs on the main + thread. + */ +static SDL_Thread * g_DeviceDetectionThread = NULL; +static SDL_mutex * g_DeviceInfoLock = NULL; +static SDL_bool g_DeviceDetectionQuit = SDL_FALSE; + +/* Main function for the device-detection thread. + */ +static int +DeviceDetectionThreadMain(void * _data) +{ + DWORD result; + XINPUT_CAPABILITIES tempXInputCaps; + int i; + + while (1) { + /* See if the device-detection thread is being asked to shutdown. + */ + SDL_LockMutex(g_DeviceInfoLock); + if (g_DeviceDetectionQuit) { + SDL_UnlockMutex(g_DeviceInfoLock); + break; + } + SDL_UnlockMutex(g_DeviceInfoLock); + + /* Add a short delay to prevent the device-detection thread from eating + up too much CPU time: + */ + SDL_Delay(300); + + /* TODO, WinRT: try making the device-detection thread wakeup sooner from its CPU-preserving SDL_Delay, if the thread was asked to quit. + */ + + /* See if any new devices are connected. */ + SDL_LockMutex(g_DeviceInfoLock); + for (i = 0; i < XUSER_MAX_COUNT; ++i) { + if (!g_XInputData[i].isDeviceConnected && + !g_XInputData[i].isDeviceConnectionEventPending && + !g_XInputData[i].isDeviceRemovalEventPending) + { + SDL_UnlockMutex(g_DeviceInfoLock); + result = XInputGetCapabilities(i, 0, &tempXInputCaps); + SDL_LockMutex(g_DeviceInfoLock); + if (result == ERROR_SUCCESS) { + /* Yes, a device is connected. Mark it as such. + Others will be told about this (via an + SDL_JOYDEVICEADDED event) in the next call to + SDL_SYS_JoystickDetect. + */ + g_XInputData[i].isDeviceConnected = SDL_TRUE; + g_XInputData[i].isDeviceConnectionEventPending = SDL_TRUE; + } + } + } + SDL_UnlockMutex(g_DeviceInfoLock); + } + + return 0; +} + +/* Function to scan the system for joysticks. + * It should return 0, or -1 on an unrecoverable fatal error. + */ +int +SDL_SYS_JoystickInit(void) +{ + HRESULT result = S_OK; + XINPUT_STATE tempXInputState; + int i; + + SDL_zero(g_XInputData); + + /* Make initial notes on whether or not devices are connected (or not). + */ + for (i = 0; i < XUSER_MAX_COUNT; ++i) { + result = XInputGetState(i, &tempXInputState); + if (result == ERROR_SUCCESS) { + g_XInputData[i].isDeviceConnected = SDL_TRUE; + } + } + + /* Start up the device-detection thread. + */ + g_DeviceDetectionQuit = SDL_FALSE; + g_DeviceInfoLock = SDL_CreateMutex(); + g_DeviceDetectionThread = SDL_CreateThread(DeviceDetectionThreadMain, "SDL_joystick", NULL); + + return (0); +} + +int SDL_SYS_NumJoysticks() +{ + int joystickCount = 0; + DWORD i; + + /* Iterate through each possible XInput device and see if something + was connected (at joystick init, or during the last polling). + */ + SDL_LockMutex(g_DeviceInfoLock); + for (i = 0; i < XUSER_MAX_COUNT; ++i) { + if (g_XInputData[i].isDeviceConnected) { + ++joystickCount; + } + } + SDL_UnlockMutex(g_DeviceInfoLock); + + return joystickCount; +} + +void SDL_SYS_JoystickDetect() +{ + DWORD i; + SDL_Event event; + + /* Iterate through each possible XInput device, seeing if any devices + have been connected, or if they were removed. + */ + SDL_LockMutex(g_DeviceInfoLock); + for (i = 0; i < XUSER_MAX_COUNT; ++i) { + /* See if any new devices are connected. */ + if (g_XInputData[i].isDeviceConnectionEventPending) { +#if !SDL_EVENTS_DISABLED + SDL_zero(event); + event.type = SDL_JOYDEVICEADDED; + + if (SDL_GetEventState(event.type) == SDL_ENABLE) { + event.jdevice.which = i; + if ((SDL_EventOK == NULL) + || (*SDL_EventOK) (SDL_EventOKParam, &event)) { + SDL_PushEvent(&event); + } + } +#endif + g_XInputData[i].isDeviceConnectionEventPending = SDL_FALSE; + } else if (g_XInputData[i].isDeviceRemovalEventPending) { + /* A device was previously marked as removed (by + SDL_SYS_JoystickUpdate). Tell others about the device removal. + */ + + g_XInputData[i].isDeviceRemovalEventPending = SDL_FALSE; + +#if !SDL_EVENTS_DISABLED + SDL_zero(event); + event.type = SDL_JOYDEVICEREMOVED; + + if (SDL_GetEventState(event.type) == SDL_ENABLE) { + event.jdevice.which = i; //joystick->hwdata->userIndex; + if ((SDL_EventOK == NULL) + || (*SDL_EventOK) (SDL_EventOKParam, &event)) { + SDL_PushEvent(&event); + } + } +#endif + } + } + SDL_UnlockMutex(g_DeviceInfoLock); +} + +SDL_bool SDL_SYS_JoystickNeedsPolling() +{ + /* Since XInput, or WinRT, provides any events to indicate when a game + controller gets connected, and instead indicates device availability + solely through polling, we'll poll (for new devices). + */ + return SDL_TRUE; +} + +/* Internal function to retreive device capabilities. + This function will return an SDL-standard value of 0 on success + (a device is connected, and data on it was retrieved), or -1 + on failure (no device was connected, or some other error + occurred. SDL_SetError() will be invoked to set an appropriate + error message. + */ +static int +SDL_XInput_GetDeviceCapabilities(int device_index, XINPUT_CAPABILITIES * pDeviceCaps) +{ + HRESULT dwResult; + + /* Make sure that the device index is a valid one. If not, return to the + caller with an error. + */ + if (device_index < 0 || device_index >= XUSER_MAX_COUNT) { + return SDL_SetError("invalid/unavailable device index"); + } + + /* See if a device exists, and if so, what its capabilities are. If a + device is not available, return to the caller with an error. + */ + switch ((dwResult = XInputGetCapabilities(device_index, 0, pDeviceCaps))) { + case ERROR_SUCCESS: + /* A device is available, and its capabilities were retrieved! */ + return 0; + case ERROR_DEVICE_NOT_CONNECTED: + return SDL_SetError("no device is connected at joystick index, %d", device_index); + default: + return SDL_SetError("an unknown error occurred when retrieving info on a device at joystick index, %d", device_index); + } +} + +/* Function to get the device-dependent name of a joystick */ +const char * +SDL_SYS_JoystickNameForDeviceIndex(int device_index) +{ + XINPUT_CAPABILITIES deviceCaps; + + if (SDL_XInput_GetDeviceCapabilities(device_index, &deviceCaps) != 0) { + /* Uh oh. Device capabilities couldn't be retrieved. Return to the + caller. SDL_SetError() has already been invoked (with relevant + information). + */ + return NULL; + } + + switch (deviceCaps.SubType) { + default: + if (deviceCaps.Type == XINPUT_DEVTYPE_GAMEPAD) { + return "Undefined game controller"; + } else { + return "Undefined controller"; + } + case XINPUT_DEVSUBTYPE_UNKNOWN: + if (deviceCaps.Type == XINPUT_DEVTYPE_GAMEPAD) { + return "Unknown game controller"; + } else { + return "Unknown controller"; + } + case XINPUT_DEVSUBTYPE_GAMEPAD: + return "Gamepad controller"; + case XINPUT_DEVSUBTYPE_WHEEL: + return "Racing wheel controller"; + case XINPUT_DEVSUBTYPE_ARCADE_STICK: + return "Arcade stick controller"; + case XINPUT_DEVSUBTYPE_FLIGHT_STICK: + return "Flight stick controller"; + case XINPUT_DEVSUBTYPE_DANCE_PAD: + return "Dance pad controller"; + case XINPUT_DEVSUBTYPE_GUITAR: + return "Guitar controller"; + case XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE: + return "Guitar controller, Alternate"; + case XINPUT_DEVSUBTYPE_GUITAR_BASS: + return "Guitar controller, Bass"; + case XINPUT_DEVSUBTYPE_DRUM_KIT: + return "Drum controller"; + case XINPUT_DEVSUBTYPE_ARCADE_PAD: + return "Arcade pad controller"; + } +} + +/* Function to perform the mapping from device index to the instance id for this index */ +SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index) +{ + return device_index; +} + +/* Function to open a joystick for use. + The joystick to open is specified by the index field of the joystick. + This should fill the nbuttons and naxes fields of the joystick structure. + It returns 0, or -1 if there is an error. + */ +int +SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) +{ + XINPUT_CAPABILITIES deviceCaps; + + if (SDL_XInput_GetDeviceCapabilities(device_index, &deviceCaps) != 0) { + /* Uh oh. Device capabilities couldn't be retrieved. Return to the + caller. SDL_SetError() has already been invoked (with relevant + information). + */ + return -1; + } + + /* For now, only game pads are supported. If the device is something other + than that, return an error to the caller. + */ + if (deviceCaps.Type != XINPUT_DEVTYPE_GAMEPAD) { + return SDL_SetError("a device is connected (at joystick index, %d), but it is of an unknown device type (deviceCaps.Flags=%ul)", + device_index, (unsigned int)deviceCaps.Flags); + } + + /* Create the joystick data structure */ + joystick->instance_id = device_index; + joystick->hwdata = &g_XInputData[device_index]; + + // The XInput API has a hard coded button/axis mapping, so we just match it + joystick->naxes = 6; + joystick->nbuttons = 15; + joystick->nballs = 0; + joystick->nhats = 0; + + /* We're done! */ + return (0); +} + +/* Function to determine is this joystick is attached to the system right now */ +SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick) +{ + SDL_bool isDeviceConnected; + SDL_LockMutex(g_DeviceInfoLock); + isDeviceConnected = joystick->hwdata->isDeviceConnected; + SDL_UnlockMutex(g_DeviceInfoLock); + return isDeviceConnected; +} + +/* Function to return > 0 if a bit array of buttons differs after applying a mask +*/ +static int ButtonChanged( int ButtonsNow, int ButtonsPrev, int ButtonMask ) +{ + return ( ButtonsNow & ButtonMask ) != ( ButtonsPrev & ButtonMask ); +} + +/* Function to update the state of a joystick - called as a device poll. + * This function shouldn't update the joystick structure directly, + * but instead should call SDL_PrivateJoystick*() to deliver events + * and update joystick device state. + */ +void +SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) +{ + HRESULT result; + XINPUT_STATE prevXInputState; + + SDL_LockMutex(g_DeviceInfoLock); + + /* Before polling for new data, make note of the old data */ + prevXInputState = joystick->hwdata->XInputState; + + /* Poll for new data */ + result = XInputGetState(joystick->hwdata->userIndex, &joystick->hwdata->XInputState); + if (result == ERROR_DEVICE_NOT_CONNECTED) { + if (joystick->hwdata->isDeviceConnected) { + joystick->hwdata->isDeviceConnected = SDL_FALSE; + joystick->hwdata->isDeviceRemovalEventPending = SDL_TRUE; + /* TODO, WinRT: make sure isDeviceRemovalEventPending gets cleared as appropriate, and that quick re-plugs don't cause trouble */ + } + SDL_UnlockMutex(g_DeviceInfoLock); + return; + } + + /* Make sure the device is marked as connected */ + joystick->hwdata->isDeviceConnected = SDL_TRUE; + + // only fire events if the data changed from last time + if ( joystick->hwdata->XInputState.dwPacketNumber != 0 + && joystick->hwdata->XInputState.dwPacketNumber != prevXInputState.dwPacketNumber ) + { + XINPUT_STATE *pXInputState = &joystick->hwdata->XInputState; + XINPUT_STATE *pXInputStatePrev = &prevXInputState; + + SDL_PrivateJoystickAxis(joystick, 0, (Sint16)pXInputState->Gamepad.sThumbLX ); + SDL_PrivateJoystickAxis(joystick, 1, (Sint16)(-1*pXInputState->Gamepad.sThumbLY-1) ); + SDL_PrivateJoystickAxis(joystick, 2, (Sint16)pXInputState->Gamepad.sThumbRX ); + SDL_PrivateJoystickAxis(joystick, 3, (Sint16)(-1*pXInputState->Gamepad.sThumbRY-1) ); + SDL_PrivateJoystickAxis(joystick, 4, (Sint16)((int)pXInputState->Gamepad.bLeftTrigger*32767/255) ); + SDL_PrivateJoystickAxis(joystick, 5, (Sint16)((int)pXInputState->Gamepad.bRightTrigger*32767/255) ); + + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_UP ) ) + SDL_PrivateJoystickButton(joystick, 0, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_DOWN ) ) + SDL_PrivateJoystickButton(joystick, 1, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_LEFT ) ) + SDL_PrivateJoystickButton(joystick, 2, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_DPAD_RIGHT ) ) + SDL_PrivateJoystickButton(joystick, 3, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_START ) ) + SDL_PrivateJoystickButton(joystick, 4, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_START ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_BACK ) ) + SDL_PrivateJoystickButton(joystick, 5, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_BACK ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_LEFT_THUMB ) ) + SDL_PrivateJoystickButton(joystick, 6, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_RIGHT_THUMB ) ) + SDL_PrivateJoystickButton(joystick, 7, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_LEFT_SHOULDER ) ) + SDL_PrivateJoystickButton(joystick, 8, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_RIGHT_SHOULDER ) ) + SDL_PrivateJoystickButton(joystick, 9, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_A ) ) + SDL_PrivateJoystickButton(joystick, 10, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_A ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_B ) ) + SDL_PrivateJoystickButton(joystick, 11, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_B ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_X ) ) + SDL_PrivateJoystickButton(joystick, 12, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_X ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, XINPUT_GAMEPAD_Y ) ) + SDL_PrivateJoystickButton(joystick, 13, pXInputState->Gamepad.wButtons & XINPUT_GAMEPAD_Y ? SDL_PRESSED : SDL_RELEASED ); + if ( ButtonChanged( pXInputState->Gamepad.wButtons, pXInputStatePrev->Gamepad.wButtons, 0x400 ) ) + SDL_PrivateJoystickButton(joystick, 14, pXInputState->Gamepad.wButtons & 0x400 ? SDL_PRESSED : SDL_RELEASED ); // 0x400 is the undocumented code for the guide button + } + + SDL_UnlockMutex(g_DeviceInfoLock); +} + +/* Function to close a joystick after use */ +void +SDL_SYS_JoystickClose(SDL_Joystick * joystick) +{ + /* Clear cached button data on the joystick */ + SDL_LockMutex(g_DeviceInfoLock); + SDL_zero(joystick->hwdata->XInputState); + SDL_UnlockMutex(g_DeviceInfoLock); + + /* There's need to free 'hwdata', as it's a pointer to a global array. + The field will be cleared anyways, just to indicate that it's not + currently needed. + */ + joystick->hwdata = NULL; +} + +/* Function to perform any system-specific joystick related cleanup */ +void +SDL_SYS_JoystickQuit(void) +{ + /* Tell the joystick detection thread to stop, then wait for it to finish */ + SDL_LockMutex(g_DeviceInfoLock); + g_DeviceDetectionQuit = SDL_TRUE; + SDL_UnlockMutex(g_DeviceInfoLock); + SDL_WaitThread(g_DeviceDetectionThread, NULL); + + /* Clean up device-detection stuff */ + SDL_DestroyMutex(g_DeviceInfoLock); + g_DeviceInfoLock = NULL; + g_DeviceDetectionThread = NULL; + g_DeviceDetectionQuit = SDL_FALSE; + + return; +} + +SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) +{ + SDL_JoystickGUID guid; + // the GUID is just the first 16 chars of the name for now + const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index ); + SDL_zero( guid ); + SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); + return guid; +} + + +SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick) +{ + SDL_JoystickGUID guid; + // the GUID is just the first 16 chars of the name for now + const char *name = joystick->name; + SDL_zero( guid ); + SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); + return guid; +} + +SDL_bool SDL_SYS_IsXInputDeviceIndex(int device_index) +{ + /* The XInput-capable DirectInput joystick backend implements the same + function (SDL_SYS_IsXInputDeviceIndex), however in that case, not all + joystick devices are XInput devices. In this case, with the + WinRT-enabled XInput-only backend, all "joystick" devices are XInput + devices. + */ + return SDL_TRUE; +} + +#endif /* SDL_JOYSTICK_XINPUT */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.1/src/libm/e_atan2.c b/jni/SDL2-2.0.3/src/libm/e_atan2.c similarity index 100% rename from jni/SDL2-2.0.1/src/libm/e_atan2.c rename to jni/SDL2-2.0.3/src/libm/e_atan2.c diff --git a/jni/SDL2-2.0.1/src/libm/e_log.c b/jni/SDL2-2.0.3/src/libm/e_log.c similarity index 100% rename from jni/SDL2-2.0.1/src/libm/e_log.c rename to jni/SDL2-2.0.3/src/libm/e_log.c diff --git a/jni/SDL2-2.0.1/src/libm/e_pow.c b/jni/SDL2-2.0.3/src/libm/e_pow.c similarity index 100% rename from jni/SDL2-2.0.1/src/libm/e_pow.c rename to jni/SDL2-2.0.3/src/libm/e_pow.c diff --git a/jni/SDL2-2.0.1/src/libm/e_rem_pio2.c b/jni/SDL2-2.0.3/src/libm/e_rem_pio2.c similarity index 100% rename from jni/SDL2-2.0.1/src/libm/e_rem_pio2.c rename to jni/SDL2-2.0.3/src/libm/e_rem_pio2.c diff --git a/jni/SDL2-2.0.1/src/libm/e_sqrt.c b/jni/SDL2-2.0.3/src/libm/e_sqrt.c similarity index 100% rename from jni/SDL2-2.0.1/src/libm/e_sqrt.c rename to jni/SDL2-2.0.3/src/libm/e_sqrt.c diff --git a/jni/SDL2-2.0.1/src/libm/k_cos.c b/jni/SDL2-2.0.3/src/libm/k_cos.c similarity index 100% rename from jni/SDL2-2.0.1/src/libm/k_cos.c rename to jni/SDL2-2.0.3/src/libm/k_cos.c diff --git a/jni/SDL2-2.0.1/src/libm/k_rem_pio2.c b/jni/SDL2-2.0.3/src/libm/k_rem_pio2.c similarity index 100% rename from jni/SDL2-2.0.1/src/libm/k_rem_pio2.c rename to jni/SDL2-2.0.3/src/libm/k_rem_pio2.c diff --git a/jni/SDL2-2.0.1/src/libm/k_sin.c b/jni/SDL2-2.0.3/src/libm/k_sin.c similarity index 100% rename from jni/SDL2-2.0.1/src/libm/k_sin.c rename to jni/SDL2-2.0.3/src/libm/k_sin.c diff --git a/jni/SDL2-2.0.1/src/libm/math_libm.h b/jni/SDL2-2.0.3/src/libm/math_libm.h similarity index 96% rename from jni/SDL2-2.0.1/src/libm/math_libm.h rename to jni/SDL2-2.0.3/src/libm/math_libm.h index 861dece3..20432bd2 100644 --- a/jni/SDL2-2.0.1/src/libm/math_libm.h +++ b/jni/SDL2-2.0.3/src/libm/math_libm.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/libm/math_private.h b/jni/SDL2-2.0.3/src/libm/math_private.h similarity index 100% rename from jni/SDL2-2.0.1/src/libm/math_private.h rename to jni/SDL2-2.0.3/src/libm/math_private.h diff --git a/jni/SDL2-2.0.1/src/libm/s_atan.c b/jni/SDL2-2.0.3/src/libm/s_atan.c similarity index 100% rename from jni/SDL2-2.0.1/src/libm/s_atan.c rename to jni/SDL2-2.0.3/src/libm/s_atan.c diff --git a/jni/SDL2-2.0.1/src/libm/s_copysign.c b/jni/SDL2-2.0.3/src/libm/s_copysign.c similarity index 100% rename from jni/SDL2-2.0.1/src/libm/s_copysign.c rename to jni/SDL2-2.0.3/src/libm/s_copysign.c diff --git a/jni/SDL2-2.0.1/src/libm/s_cos.c b/jni/SDL2-2.0.3/src/libm/s_cos.c similarity index 100% rename from jni/SDL2-2.0.1/src/libm/s_cos.c rename to jni/SDL2-2.0.3/src/libm/s_cos.c diff --git a/jni/SDL2-2.0.1/src/libm/s_fabs.c b/jni/SDL2-2.0.3/src/libm/s_fabs.c similarity index 100% rename from jni/SDL2-2.0.1/src/libm/s_fabs.c rename to jni/SDL2-2.0.3/src/libm/s_fabs.c diff --git a/jni/SDL2-2.0.1/src/libm/s_floor.c b/jni/SDL2-2.0.3/src/libm/s_floor.c similarity index 100% rename from jni/SDL2-2.0.1/src/libm/s_floor.c rename to jni/SDL2-2.0.3/src/libm/s_floor.c diff --git a/jni/SDL2-2.0.1/src/libm/s_scalbn.c b/jni/SDL2-2.0.3/src/libm/s_scalbn.c similarity index 100% rename from jni/SDL2-2.0.1/src/libm/s_scalbn.c rename to jni/SDL2-2.0.3/src/libm/s_scalbn.c diff --git a/jni/SDL2-2.0.1/src/libm/s_sin.c b/jni/SDL2-2.0.3/src/libm/s_sin.c similarity index 100% rename from jni/SDL2-2.0.1/src/libm/s_sin.c rename to jni/SDL2-2.0.3/src/libm/s_sin.c diff --git a/jni/SDL2-2.0.1/src/loadso/dlopen/SDL_sysloadso.c b/jni/SDL2-2.0.3/src/loadso/dlopen/SDL_sysloadso.c similarity index 97% rename from jni/SDL2-2.0.1/src/loadso/dlopen/SDL_sysloadso.c rename to jni/SDL2-2.0.3/src/loadso/dlopen/SDL_sysloadso.c index 337f050d..db842222 100644 --- a/jni/SDL2-2.0.1/src/loadso/dlopen/SDL_sysloadso.c +++ b/jni/SDL2-2.0.3/src/loadso/dlopen/SDL_sysloadso.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/loadso/dummy/SDL_sysloadso.c b/jni/SDL2-2.0.3/src/loadso/dummy/SDL_sysloadso.c similarity index 96% rename from jni/SDL2-2.0.1/src/loadso/dummy/SDL_sysloadso.c rename to jni/SDL2-2.0.3/src/loadso/dummy/SDL_sysloadso.c index 652b6f4e..0dfb90b0 100644 --- a/jni/SDL2-2.0.1/src/loadso/dummy/SDL_sysloadso.c +++ b/jni/SDL2-2.0.3/src/loadso/dummy/SDL_sysloadso.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/loadso/haiku/SDL_sysloadso.c b/jni/SDL2-2.0.3/src/loadso/haiku/SDL_sysloadso.c similarity index 97% rename from jni/SDL2-2.0.1/src/loadso/haiku/SDL_sysloadso.c rename to jni/SDL2-2.0.3/src/loadso/haiku/SDL_sysloadso.c index 95a4ce93..c8bba670 100644 --- a/jni/SDL2-2.0.1/src/loadso/haiku/SDL_sysloadso.c +++ b/jni/SDL2-2.0.3/src/loadso/haiku/SDL_sysloadso.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/loadso/windows/SDL_sysloadso.c b/jni/SDL2-2.0.3/src/loadso/windows/SDL_sysloadso.c similarity index 85% rename from jni/SDL2-2.0.1/src/loadso/windows/SDL_sysloadso.c rename to jni/SDL2-2.0.3/src/loadso/windows/SDL_sysloadso.c index fe6f19fc..4d32b098 100644 --- a/jni/SDL2-2.0.1/src/loadso/windows/SDL_sysloadso.c +++ b/jni/SDL2-2.0.3/src/loadso/windows/SDL_sysloadso.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -33,7 +33,15 @@ void * SDL_LoadObject(const char *sofile) { LPTSTR tstr = WIN_UTF8ToString(sofile); +#ifdef __WINRT__ + /* WinRT only publically supports LoadPackagedLibrary() for loading .dll + files. LoadLibrary() is a private API, and not available for apps + (that can be published to MS' Windows Store.) + */ + void *handle = (void *) LoadPackagedLibrary(tstr, 0); +#else void *handle = (void *) LoadLibrary(tstr); +#endif SDL_free(tstr); /* Generate an error message if all loads failed */ diff --git a/jni/SDL2-2.0.1/src/main/android/SDL_android_main.c b/jni/SDL2-2.0.3/src/main/android/SDL_android_main.c similarity index 89% rename from jni/SDL2-2.0.1/src/main/android/SDL_android_main.c rename to jni/SDL2-2.0.3/src/main/android/SDL_android_main.c index ab41cbb5..f932f317 100644 --- a/jni/SDL2-2.0.1/src/main/android/SDL_android_main.c +++ b/jni/SDL2-2.0.3/src/main/android/SDL_android_main.c @@ -1,4 +1,6 @@ - +/* + SDL_android_main.c, placed in the public domain by Sam Lantinga 3/13/14 +*/ #include "../../SDL_internal.h" #ifdef __ANDROID__ @@ -25,7 +27,7 @@ void Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass cls, jobject /* Run the application code! */ int status; char *argv[2]; - argv[0] = SDL_strdup("app_process"); + argv[0] = SDL_strdup("SDL_app"); argv[1] = NULL; status = SDL_main(1, argv); diff --git a/jni/SDL2-2.0.1/src/main/dummy/SDL_dummy_main.c b/jni/SDL2-2.0.3/src/main/dummy/SDL_dummy_main.c similarity index 81% rename from jni/SDL2-2.0.1/src/main/dummy/SDL_dummy_main.c rename to jni/SDL2-2.0.3/src/main/dummy/SDL_dummy_main.c index 4737d459..0174136b 100644 --- a/jni/SDL2-2.0.1/src/main/dummy/SDL_dummy_main.c +++ b/jni/SDL2-2.0.3/src/main/dummy/SDL_dummy_main.c @@ -1,6 +1,9 @@ +/* + SDL_dummy_main.c, placed in the public domain by Sam Lantinga 3/13/14 +*/ +#include "../../SDL_internal.h" /* Include the SDL main definition header */ -#include "../../SDL_internal.h" #include "SDL_main.h" #ifdef main diff --git a/jni/SDL2-2.0.1/src/main/haiku/SDL_BApp.h b/jni/SDL2-2.0.3/src/main/haiku/SDL_BApp.h similarity index 99% rename from jni/SDL2-2.0.1/src/main/haiku/SDL_BApp.h rename to jni/SDL2-2.0.3/src/main/haiku/SDL_BApp.h index bbdb34c0..1e4a0f55 100644 --- a/jni/SDL2-2.0.1/src/main/haiku/SDL_BApp.h +++ b/jni/SDL2-2.0.3/src/main/haiku/SDL_BApp.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/main/haiku/SDL_BeApp.cc b/jni/SDL2-2.0.3/src/main/haiku/SDL_BeApp.cc similarity index 98% rename from jni/SDL2-2.0.1/src/main/haiku/SDL_BeApp.cc rename to jni/SDL2-2.0.3/src/main/haiku/SDL_BeApp.cc index 959ccbc6..d471887f 100644 --- a/jni/SDL2-2.0.1/src/main/haiku/SDL_BeApp.cc +++ b/jni/SDL2-2.0.3/src/main/haiku/SDL_BeApp.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/main/haiku/SDL_BeApp.h b/jni/SDL2-2.0.3/src/main/haiku/SDL_BeApp.h similarity index 95% rename from jni/SDL2-2.0.1/src/main/haiku/SDL_BeApp.h rename to jni/SDL2-2.0.3/src/main/haiku/SDL_BeApp.h index ccee0b21..f4399c81 100644 --- a/jni/SDL2-2.0.1/src/main/haiku/SDL_BeApp.h +++ b/jni/SDL2-2.0.3/src/main/haiku/SDL_BeApp.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -20,7 +20,6 @@ */ #include "../../SDL_internal.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/jni/SDL2-2.0.1/src/main/psp/SDL_psp_main.c b/jni/SDL2-2.0.3/src/main/psp/SDL_psp_main.c similarity index 61% rename from jni/SDL2-2.0.1/src/main/psp/SDL_psp_main.c rename to jni/SDL2-2.0.3/src/main/psp/SDL_psp_main.c index 77ef39d5..d79135db 100644 --- a/jni/SDL2-2.0.1/src/main/psp/SDL_psp_main.c +++ b/jni/SDL2-2.0.3/src/main/psp/SDL_psp_main.c @@ -1,22 +1,5 @@ /* - Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. + SDL_psp_main.c, placed in the public domain by Sam Lantinga 3/13/14 */ #include "SDL_main.h" diff --git a/jni/SDL2-2.0.1/src/main/windows/SDL_windows_main.c b/jni/SDL2-2.0.3/src/main/windows/SDL_windows_main.c similarity index 98% rename from jni/SDL2-2.0.1/src/main/windows/SDL_windows_main.c rename to jni/SDL2-2.0.3/src/main/windows/SDL_windows_main.c index 4e8e3f2f..8c8ccab6 100644 --- a/jni/SDL2-2.0.1/src/main/windows/SDL_windows_main.c +++ b/jni/SDL2-2.0.3/src/main/windows/SDL_windows_main.c @@ -1,5 +1,5 @@ /* - SDL_main.c, placed in the public domain by Sam Lantinga 4/13/98 + SDL_windows_main.c, placed in the public domain by Sam Lantinga 4/13/98 The WinMain function -- calls your program's main() function */ diff --git a/jni/SDL2-2.0.1/src/main/windows/version.rc b/jni/SDL2-2.0.3/src/main/windows/version.rc similarity index 74% rename from jni/SDL2-2.0.1/src/main/windows/version.rc rename to jni/SDL2-2.0.3/src/main/windows/version.rc index b096a914..2b7e2dde 100644 --- a/jni/SDL2-2.0.1/src/main/windows/version.rc +++ b/jni/SDL2-2.0.3/src/main/windows/version.rc @@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,0,1,0 - PRODUCTVERSION 2,0,1,0 + FILEVERSION 2,0,3,0 + PRODUCTVERSION 2,0,3,0 FILEFLAGSMASK 0x3fL FILEFLAGS 0x0L FILEOS 0x40004L @@ -23,12 +23,12 @@ BEGIN BEGIN VALUE "CompanyName", "\0" VALUE "FileDescription", "SDL\0" - VALUE "FileVersion", "2, 0, 1, 0\0" + VALUE "FileVersion", "2, 0, 3, 0\0" VALUE "InternalName", "SDL\0" - VALUE "LegalCopyright", "Copyright © 2013 Sam Lantinga\0" + VALUE "LegalCopyright", "Copyright © 2014 Sam Lantinga\0" VALUE "OriginalFilename", "SDL2.dll\0" VALUE "ProductName", "Simple DirectMedia Layer\0" - VALUE "ProductVersion", "2, 0, 1, 0\0" + VALUE "ProductVersion", "2, 0, 3, 0\0" END END BLOCK "VarFileInfo" diff --git a/jni/SDL2-2.0.3/src/main/winrt/SDL_winrt_main_NonXAML.cpp b/jni/SDL2-2.0.3/src/main/winrt/SDL_winrt_main_NonXAML.cpp new file mode 100644 index 00000000..ce5e8247 --- /dev/null +++ b/jni/SDL2-2.0.3/src/main/winrt/SDL_winrt_main_NonXAML.cpp @@ -0,0 +1,59 @@ +/* + SDL_winrt_main_NonXAML.cpp, placed in the public domain by David Ludwig 3/13/14 +*/ + +#include "SDL_main.h" +#include + +/* At least one file in any SDL/WinRT app appears to require compilation + with C++/CX, otherwise a Windows Metadata file won't get created, and + an APPX0702 build error can appear shortly after linking. + + The following set of preprocessor code forces this file to be compiled + as C++/CX, which appears to cause Visual C++ 2012's build tools to + create this .winmd file, and will help allow builds of SDL/WinRT apps + to proceed without error. + + If other files in an app's project enable C++/CX compilation, then it might + be possible for SDL_winrt_main_NonXAML.cpp to be compiled without /ZW, + for Visual C++'s build tools to create a winmd file, and for the app to + build without APPX0702 errors. In this case, if + SDL_WINRT_METADATA_FILE_AVAILABLE is defined as a C/C++ macro, then + the #error (to force C++/CX compilation) will be disabled. + + Please note that /ZW can be specified on a file-by-file basis. To do this, + right click on the file in Visual C++, click Properties, then change the + setting through the dialog that comes up. +*/ +#ifndef SDL_WINRT_METADATA_FILE_AVAILABLE +#ifndef __cplusplus_winrt +#error SDL_winrt_main_NonXAML.cpp must be compiled with /ZW, otherwise build errors due to missing .winmd files can occur. +#endif +#endif + +/* Prevent MSVC++ from warning about threading models when defining our + custom WinMain. The threading model will instead be set via a direct + call to Windows::Foundation::Initialize (rather than via an attributed + function). + + To note, this warning (C4447) does not seem to come up unless this file + is compiled with C++/CX enabled (via the /ZW compiler flag). +*/ +#ifdef _MSC_VER +#pragma warning(disable:4447) +#endif + +/* Make sure the function to initialize the Windows Runtime gets linked in. */ +#ifdef _MSC_VER +#pragma comment(lib, "runtimeobject.lib") +#endif + +int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int) +{ + if (FAILED(Windows::Foundation::Initialize(RO_INIT_MULTITHREADED))) { + return 1; + } + + SDL_WinRTRunApp(SDL_main, NULL); + return 0; +} diff --git a/jni/SDL2-2.0.1/src/power/SDL_power.c b/jni/SDL2-2.0.3/src/power/SDL_power.c similarity index 94% rename from jni/SDL2-2.0.1/src/power/SDL_power.c rename to jni/SDL2-2.0.3/src/power/SDL_power.c index 0ce4f686..10f8355f 100644 --- a/jni/SDL2-2.0.1/src/power/SDL_power.c +++ b/jni/SDL2-2.0.3/src/power/SDL_power.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -37,6 +37,7 @@ SDL_bool SDL_GetPowerInfo_Haiku(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_Android(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_PSP(SDL_PowerState *, int *, int *); +SDL_bool SDL_GetPowerInfo_WinRT(SDL_PowerState *, int *, int *); #ifndef SDL_POWER_DISABLED #ifdef SDL_POWER_HARDWIRED @@ -77,6 +78,9 @@ static SDL_GetPowerInfo_Impl implementations[] = { #ifdef SDL_POWER_PSP /* handles PSP. */ SDL_GetPowerInfo_PSP, #endif +#ifdef SDL_POWER_WINRT /* handles WinRT */ + SDL_GetPowerInfo_WinRT, +#endif #ifdef SDL_POWER_HARDWIRED SDL_GetPowerInfo_Hardwired, diff --git a/jni/SDL2-2.0.1/src/power/android/SDL_syspower.c b/jni/SDL2-2.0.3/src/power/android/SDL_syspower.c similarity index 96% rename from jni/SDL2-2.0.1/src/power/android/SDL_syspower.c rename to jni/SDL2-2.0.3/src/power/android/SDL_syspower.c index 9f4c55f5..e363731d 100644 --- a/jni/SDL2-2.0.1/src/power/android/SDL_syspower.c +++ b/jni/SDL2-2.0.3/src/power/android/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/power/haiku/SDL_syspower.c b/jni/SDL2-2.0.3/src/power/haiku/SDL_syspower.c similarity index 98% rename from jni/SDL2-2.0.1/src/power/haiku/SDL_syspower.c rename to jni/SDL2-2.0.3/src/power/haiku/SDL_syspower.c index a627a907..aaf61e8b 100644 --- a/jni/SDL2-2.0.1/src/power/haiku/SDL_syspower.c +++ b/jni/SDL2-2.0.3/src/power/haiku/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/power/linux/SDL_syspower.c b/jni/SDL2-2.0.3/src/power/linux/SDL_syspower.c similarity index 99% rename from jni/SDL2-2.0.1/src/power/linux/SDL_syspower.c rename to jni/SDL2-2.0.3/src/power/linux/SDL_syspower.c index b8169806..05eb200b 100644 --- a/jni/SDL2-2.0.1/src/power/linux/SDL_syspower.c +++ b/jni/SDL2-2.0.3/src/power/linux/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/power/macosx/SDL_syspower.c b/jni/SDL2-2.0.3/src/power/macosx/SDL_syspower.c similarity index 98% rename from jni/SDL2-2.0.1/src/power/macosx/SDL_syspower.c rename to jni/SDL2-2.0.3/src/power/macosx/SDL_syspower.c index d60cdbc1..9bcacafd 100644 --- a/jni/SDL2-2.0.1/src/power/macosx/SDL_syspower.c +++ b/jni/SDL2-2.0.3/src/power/macosx/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/power/psp/SDL_syspower.c b/jni/SDL2-2.0.3/src/power/psp/SDL_syspower.c similarity index 97% rename from jni/SDL2-2.0.1/src/power/psp/SDL_syspower.c rename to jni/SDL2-2.0.3/src/power/psp/SDL_syspower.c index b1096b80..b28a68cf 100644 --- a/jni/SDL2-2.0.1/src/power/psp/SDL_syspower.c +++ b/jni/SDL2-2.0.3/src/power/psp/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/power/uikit/SDL_syspower.h b/jni/SDL2-2.0.3/src/power/uikit/SDL_syspower.h similarity index 95% rename from jni/SDL2-2.0.1/src/power/uikit/SDL_syspower.h rename to jni/SDL2-2.0.3/src/power/uikit/SDL_syspower.h index 187ee590..581c358d 100644 --- a/jni/SDL2-2.0.1/src/power/uikit/SDL_syspower.h +++ b/jni/SDL2-2.0.3/src/power/uikit/SDL_syspower.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/power/uikit/SDL_syspower.m b/jni/SDL2-2.0.3/src/power/uikit/SDL_syspower.m similarity index 95% rename from jni/SDL2-2.0.1/src/power/uikit/SDL_syspower.m rename to jni/SDL2-2.0.3/src/power/uikit/SDL_syspower.m index cf1c207c..60c42745 100644 --- a/jni/SDL2-2.0.1/src/power/uikit/SDL_syspower.m +++ b/jni/SDL2-2.0.3/src/power/uikit/SDL_syspower.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -87,8 +87,8 @@ SDL_GetPowerInfo_UIKit(SDL_PowerState * state, int *seconds, int *percent) } const float level = [uidev batteryLevel]; - *percent = ( (level < 0.0f) ? -1 : (((int) (level + 0.5f)) * 100) ); - return SDL_TRUE; /* always the definitive answer on iPhoneOS. */ + *percent = ( (level < 0.0f) ? -1 : ((int) ((level * 100) + 0.5f)) ); + return SDL_TRUE; /* always the definitive answer on iOS. */ } #endif /* SDL_POWER_UIKIT */ diff --git a/jni/SDL2-2.0.1/src/power/windows/SDL_syspower.c b/jni/SDL2-2.0.3/src/power/windows/SDL_syspower.c similarity index 97% rename from jni/SDL2-2.0.1/src/power/windows/SDL_syspower.c rename to jni/SDL2-2.0.3/src/power/windows/SDL_syspower.c index d2485fb4..0a247ba0 100644 --- a/jni/SDL2-2.0.1/src/power/windows/SDL_syspower.c +++ b/jni/SDL2-2.0.3/src/power/windows/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.3/src/power/winrt/SDL_syspower.cpp b/jni/SDL2-2.0.3/src/power/winrt/SDL_syspower.cpp new file mode 100644 index 00000000..8804aec7 --- /dev/null +++ b/jni/SDL2-2.0.3/src/power/winrt/SDL_syspower.cpp @@ -0,0 +1,44 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifndef SDL_POWER_DISABLED +#if SDL_POWER_WINRT + +#include "SDL_power.h" + +extern "C" +SDL_bool +SDL_GetPowerInfo_WinRT(SDL_PowerState * state, int *seconds, int *percent) +{ + /* TODO, WinRT: Battery info is available on at least one WinRT platform (Windows Phone 8). Implement SDL_GetPowerInfo_WinRT as appropriate. */ + /* Notes: + - the Win32 function, GetSystemPowerStatus, is not available for use on WinRT + - Windows Phone 8 has a 'Battery' class, which is documented as available for C++ + - More info on WP8's Battery class can be found at http://msdn.microsoft.com/library/windowsphone/develop/jj207231 + */ + return SDL_FALSE; +} + +#endif /* SDL_POWER_WINRT */ +#endif /* SDL_POWER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/render/SDL_d3dmath.c b/jni/SDL2-2.0.3/src/render/SDL_d3dmath.c new file mode 100644 index 00000000..df1dc0ba --- /dev/null +++ b/jni/SDL2-2.0.3/src/render/SDL_d3dmath.c @@ -0,0 +1,131 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../SDL_internal.h" +#include "SDL_stdinc.h" + +#include "SDL_d3dmath.h" + +/* Direct3D matrix math functions */ + +Float4X4 MatrixIdentity() +{ + Float4X4 m; + SDL_zero(m); + m._11 = 1.0f; + m._22 = 1.0f; + m._33 = 1.0f; + m._44 = 1.0f; + return m; +} + +Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2) +{ + Float4X4 m; + m._11 = M1._11 * M2._11 + M1._12 * M2._21 + M1._13 * M2._31 + M1._14 * M2._41; + m._12 = M1._11 * M2._12 + M1._12 * M2._22 + M1._13 * M2._32 + M1._14 * M2._42; + m._13 = M1._11 * M2._13 + M1._12 * M2._23 + M1._13 * M2._33 + M1._14 * M2._43; + m._14 = M1._11 * M2._14 + M1._12 * M2._24 + M1._13 * M2._34 + M1._14 * M2._44; + m._21 = M1._21 * M2._11 + M1._22 * M2._21 + M1._23 * M2._31 + M1._24 * M2._41; + m._22 = M1._21 * M2._12 + M1._22 * M2._22 + M1._23 * M2._32 + M1._24 * M2._42; + m._23 = M1._21 * M2._13 + M1._22 * M2._23 + M1._23 * M2._33 + M1._24 * M2._43; + m._24 = M1._21 * M2._14 + M1._22 * M2._24 + M1._23 * M2._34 + M1._24 * M2._44; + m._31 = M1._31 * M2._11 + M1._32 * M2._21 + M1._33 * M2._31 + M1._34 * M2._41; + m._32 = M1._31 * M2._12 + M1._32 * M2._22 + M1._33 * M2._32 + M1._34 * M2._42; + m._33 = M1._31 * M2._13 + M1._32 * M2._23 + M1._33 * M2._33 + M1._34 * M2._43; + m._34 = M1._31 * M2._14 + M1._32 * M2._24 + M1._33 * M2._34 + M1._34 * M2._44; + m._41 = M1._41 * M2._11 + M1._42 * M2._21 + M1._43 * M2._31 + M1._44 * M2._41; + m._42 = M1._41 * M2._12 + M1._42 * M2._22 + M1._43 * M2._32 + M1._44 * M2._42; + m._43 = M1._41 * M2._13 + M1._42 * M2._23 + M1._43 * M2._33 + M1._44 * M2._43; + m._44 = M1._41 * M2._14 + M1._42 * M2._24 + M1._43 * M2._34 + M1._44 * M2._44; + return m; +} + +Float4X4 MatrixScaling(float x, float y, float z) +{ + Float4X4 m; + SDL_zero(m); + m._11 = x; + m._22 = y; + m._33 = z; + m._44 = 1.0f; + return m; +} + +Float4X4 MatrixTranslation(float x, float y, float z) +{ + Float4X4 m; + SDL_zero(m); + m._11 = 1.0f; + m._22 = 1.0f; + m._33 = 1.0f; + m._44 = 1.0f; + m._41 = x; + m._42 = y; + m._43 = z; + return m; +} + +Float4X4 MatrixRotationX(float r) +{ + float sinR = SDL_sinf(r); + float cosR = SDL_cosf(r); + Float4X4 m; + SDL_zero(m); + m._11 = 1.0f; + m._22 = cosR; + m._23 = sinR; + m._32 = -sinR; + m._33 = cosR; + m._44 = 1.0f; + return m; +} + +Float4X4 MatrixRotationY(float r) +{ + float sinR = SDL_sinf(r); + float cosR = SDL_cosf(r); + Float4X4 m; + SDL_zero(m); + m._11 = cosR; + m._13 = -sinR; + m._22 = 1.0f; + m._31 = sinR; + m._33 = cosR; + m._44 = 1.0f; + return m; +} + +Float4X4 MatrixRotationZ(float r) +{ + float sinR = SDL_sinf(r); + float cosR = SDL_cosf(r); + Float4X4 m; + SDL_zero(m); + m._11 = cosR; + m._12 = sinR; + m._21 = -sinR; + m._22 = cosR; + m._33 = 1.0f; + m._44 = 1.0f; + return m; +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/render/SDL_d3dmath.h b/jni/SDL2-2.0.3/src/render/SDL_d3dmath.h new file mode 100644 index 00000000..206c4350 --- /dev/null +++ b/jni/SDL2-2.0.3/src/render/SDL_d3dmath.h @@ -0,0 +1,69 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../SDL_internal.h" + + +/* Direct3D matrix math functions */ + +typedef struct +{ + float x; + float y; +} Float2; + +typedef struct +{ + float x; + float y; + float z; +} Float3; + +typedef struct +{ + float x; + float y; + float z; + float w; +} Float4; + +typedef struct +{ + union { + struct { + float _11, _12, _13, _14; + float _21, _22, _23, _24; + float _31, _32, _33, _34; + float _41, _42, _43, _44; + }; + float m[4][4]; + }; +} Float4X4; + + +Float4X4 MatrixIdentity(); +Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2); +Float4X4 MatrixScaling(float x, float y, float z); +Float4X4 MatrixTranslation(float x, float y, float z); +Float4X4 MatrixRotationX(float r); +Float4X4 MatrixRotationY(float r); +Float4X4 MatrixRotationZ(float r); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.1/src/render/SDL_render.c b/jni/SDL2-2.0.3/src/render/SDL_render.c similarity index 99% rename from jni/SDL2-2.0.1/src/render/SDL_render.c rename to jni/SDL2-2.0.3/src/render/SDL_render.c index aa717149..1547668f 100644 --- a/jni/SDL2-2.0.1/src/render/SDL_render.c +++ b/jni/SDL2-2.0.3/src/render/SDL_render.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -50,6 +50,9 @@ static const SDL_RenderDriver *render_drivers[] = { #if SDL_VIDEO_RENDER_D3D &D3D_RenderDriver, #endif +#if SDL_VIDEO_RENDER_D3D11 + &D3D11_RenderDriver, +#endif #if SDL_VIDEO_RENDER_OGL &GL_RenderDriver, #endif @@ -1876,7 +1879,9 @@ int SDL_GL_UnbindTexture(SDL_Texture *texture) CHECK_TEXTURE_MAGIC(texture, -1); renderer = texture->renderer; - if (renderer && renderer->GL_UnbindTexture) { + if (texture->native) { + return SDL_GL_UnbindTexture(texture->native); + } else if (renderer && renderer->GL_UnbindTexture) { return renderer->GL_UnbindTexture(renderer, texture); } diff --git a/jni/SDL2-2.0.1/src/render/SDL_sysrender.h b/jni/SDL2-2.0.3/src/render/SDL_sysrender.h similarity index 97% rename from jni/SDL2-2.0.1/src/render/SDL_sysrender.h rename to jni/SDL2-2.0.3/src/render/SDL_sysrender.h index c2eaa3f1..5098d34f 100644 --- a/jni/SDL2-2.0.1/src/render/SDL_sysrender.h +++ b/jni/SDL2-2.0.3/src/render/SDL_sysrender.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -171,6 +171,9 @@ struct SDL_RenderDriver #if SDL_VIDEO_RENDER_D3D extern SDL_RenderDriver D3D_RenderDriver; #endif +#if SDL_VIDEO_RENDER_D3D11 +extern SDL_RenderDriver D3D11_RenderDriver; +#endif #if SDL_VIDEO_RENDER_OGL extern SDL_RenderDriver GL_RenderDriver; #endif diff --git a/jni/SDL2-2.0.1/src/render/SDL_yuv_mmx.c b/jni/SDL2-2.0.3/src/render/SDL_yuv_mmx.c similarity index 99% rename from jni/SDL2-2.0.1/src/render/SDL_yuv_mmx.c rename to jni/SDL2-2.0.3/src/render/SDL_yuv_mmx.c index 9e9976f0..e4ae4acb 100644 --- a/jni/SDL2-2.0.1/src/render/SDL_yuv_mmx.c +++ b/jni/SDL2-2.0.3/src/render/SDL_yuv_mmx.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/SDL_yuv_sw.c b/jni/SDL2-2.0.3/src/render/SDL_yuv_sw.c similarity index 99% rename from jni/SDL2-2.0.1/src/render/SDL_yuv_sw.c rename to jni/SDL2-2.0.3/src/render/SDL_yuv_sw.c index 39387a2a..af685b9d 100644 --- a/jni/SDL2-2.0.1/src/render/SDL_yuv_sw.c +++ b/jni/SDL2-2.0.3/src/render/SDL_yuv_sw.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/SDL_yuv_sw_c.h b/jni/SDL2-2.0.3/src/render/SDL_yuv_sw_c.h similarity index 98% rename from jni/SDL2-2.0.1/src/render/SDL_yuv_sw_c.h rename to jni/SDL2-2.0.3/src/render/SDL_yuv_sw_c.h index 75fe9363..6b4044b6 100644 --- a/jni/SDL2-2.0.1/src/render/SDL_yuv_sw_c.h +++ b/jni/SDL2-2.0.3/src/render/SDL_yuv_sw_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/direct3d/SDL_render_d3d.c b/jni/SDL2-2.0.3/src/render/direct3d/SDL_render_d3d.c similarity index 89% rename from jni/SDL2-2.0.1/src/render/direct3d/SDL_render_d3d.c rename to jni/SDL2-2.0.3/src/render/direct3d/SDL_render_d3d.c index 74dbea2f..24482818 100644 --- a/jni/SDL2-2.0.1/src/render/direct3d/SDL_render_d3d.c +++ b/jni/SDL2-2.0.3/src/render/direct3d/SDL_render_d3d.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -20,6 +20,9 @@ */ #include "../../SDL_internal.h" +#include "SDL_render.h" +#include "SDL_system.h" + #if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED #include "../../core/windows/SDL_windows.h" @@ -27,8 +30,8 @@ #include "SDL_hints.h" #include "SDL_loadso.h" #include "SDL_syswm.h" -#include "SDL_system.h" #include "../SDL_sysrender.h" +#include "../SDL_d3dmath.h" #include "../../video/windows/SDL_windowsvideo.h" #if SDL_VIDEO_RENDER_D3D @@ -37,89 +40,6 @@ #endif -typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; -typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX; -typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3; - -DEFINE_GUID(IID_ID3DXMatrixStack, -0xc7885ba7, 0xf990, 0x4fe7, 0x92, 0x2d, 0x85, 0x15, 0xe4, 0x77, 0xdd, 0x85); - -#undef INTERFACE -#define INTERFACE ID3DXMatrixStack - -DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) -{ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - STDMETHOD(Pop)(THIS) PURE; - STDMETHOD(Push)(THIS) PURE; - STDMETHOD(LoadIdentity)(THIS) PURE; - STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE; - STDMETHOD(RotateAxis)(THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - STDMETHOD(RotateAxisLocal)(THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - STDMETHOD(RotateYawPitchRoll)(THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - STDMETHOD(RotateYawPitchRollLocal)(THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE; - STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE; -}; - -#undef INTERFACE - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define ID3DXMatrixStack_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define ID3DXMatrixStack_AddRef(p) (p)->lpVtbl->AddRef(p) -#define ID3DXMatrixStack_Release(p) (p)->lpVtbl->Release(p) -#define ID3DXMatrixStack_Pop(p) (p)->lpVtbl->Pop(p) -#define ID3DXMatrixStack_Push(p) (p)->lpVtbl->Push(p) -#define ID3DXMatrixStack_LoadIdentity(p) (p)->lpVtbl->LoadIdentity(p) -#define ID3DXMatrixStack_LoadMatrix(p,a) (p)->lpVtbl->LoadMatrix(p,a) -#define ID3DXMatrixStack_MultMatrix(p,a) (p)->lpVtbl->MultMatrix(p,a) -#define ID3DXMatrixStack_MultMatrixLocal(p,a) (p)->lpVtbl->MultMatrixLocal(p,a) -#define ID3DXMatrixStack_RotateAxis(p,a,b) (p)->lpVtbl->RotateAxis(p,a,b) -#define ID3DXMatrixStack_RotateAxisLocal(p,a,b) (p)->lpVtbl->RotateAxisLocal(p,a,b) -#define ID3DXMatrixStack_RotateYawPitchRoll(p,a,b,c) (p)->lpVtbl->RotateYawPitchRoll(p,a,b,c) -#define ID3DXMatrixStack_RotateYawPitchRollLocal(p,a,b,c) (p)->lpVtbl->RotateYawPitchRollLocal(p,a,b,c) -#define ID3DXMatrixStack_Scale(p,a,b,c) (p)->lpVtbl->Scale(p,a,b,c) -#define ID3DXMatrixStack_ScaleLocal(p,a,b,c) (p)->lpVtbl->ScaleLocal(p,a,b,c) -#define ID3DXMatrixStack_Translate(p,a,b,c) (p)->lpVtbl->Translate(p,a,b,c) -#define ID3DXMatrixStack_TranslateLocal(p,a,b,c) (p)->lpVtbl->TranslateLocal(p,a,b,c) -#define ID3DXMatrixStack_GetTop(p) (p)->lpVtbl->GetTop(p) -#else -#define ID3DXMatrixStack_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define ID3DXMatrixStack_AddRef(p) (p)->AddRef() -#define ID3DXMatrixStack_Release(p) (p)->Release() -#define ID3DXMatrixStack_Pop(p) (p)->Pop() -#define ID3DXMatrixStack_Push(p) (p)->Push() -#define ID3DXMatrixStack_LoadIdentity(p) (p)->LoadIdentity() -#define ID3DXMatrixStack_LoadMatrix(p,a) (p)->LoadMatrix(a) -#define ID3DXMatrixStack_MultMatrix(p,a) (p)->MultMatrix(a) -#define ID3DXMatrixStack_MultMatrixLocal(p,a) (p)->MultMatrixLocal(a) -#define ID3DXMatrixStack_RotateAxis(p,a,b) (p)->RotateAxis(a,b) -#define ID3DXMatrixStack_RotateAxisLocal(p,a,b) (p)->RotateAxisLocal(a,b) -#define ID3DXMatrixStack_RotateYawPitchRoll(p,a,b,c) (p)->RotateYawPitchRollLocal(a,b,c) -#define ID3DXMatrixStack_Scale(p,a,b,c) (p)->Scale(a,b,c) -#define ID3DXMatrixStack_ScaleLocal(p,a,b,c) (p)->ScaleLocal(a,b,c) -#define ID3DXMatrixStack_Translate(p,a,b,c) (p)->Translate(a,b,c) -#define ID3DXMatrixStack_TranslateLocal(p,a,b,c) (p)->TranslateLocal(a,b,c) -#define ID3DXMatrixStack_GetTop(p) (p)->GetTop() -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -HRESULT WINAPI D3DXCreateMatrixStack(DWORD flags, LPD3DXMATRIXSTACK* ppstack); - -#ifdef __cplusplus -} -#endif - #ifdef ASSEMBLE_SHADER /************************************************************************** * ID3DXBuffer: @@ -215,6 +135,7 @@ static int D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch); static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture); static int D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture); static int D3D_UpdateViewport(SDL_Renderer * renderer); static int D3D_UpdateClipRect(SDL_Renderer * renderer); @@ -263,7 +184,6 @@ typedef struct IDirect3DSurface9 *defaultRenderTarget; IDirect3DSurface9 *currentRenderTarget; void* d3dxDLL; - ID3DXMatrixStack *matrixStack; LPDIRECT3DPIXELSHADER9 ps_yuv; } D3D_RenderData; @@ -472,12 +392,24 @@ D3D_Reset(SDL_Renderer * renderer) { D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; HRESULT result; + SDL_Texture *texture; /* Release the default render target before reset */ if (data->defaultRenderTarget) { IDirect3DSurface9_Release(data->defaultRenderTarget); data->defaultRenderTarget = NULL; } + if (data->currentRenderTarget != NULL) { + IDirect3DSurface9_Release(data->currentRenderTarget); + data->currentRenderTarget = NULL; + } + + /* Release application render targets */ + for (texture = renderer->textures; texture; texture = texture->next) { + if (texture->access == SDL_TEXTUREACCESS_TARGET) { + D3D_DestroyTexture(renderer, texture); + } + } result = IDirect3DDevice9_Reset(data->device, &data->pparams); if (FAILED(result)) { @@ -489,9 +421,25 @@ D3D_Reset(SDL_Renderer * renderer) } } + /* Allocate application render targets */ + for (texture = renderer->textures; texture; texture = texture->next) { + if (texture->access == SDL_TEXTUREACCESS_TARGET) { + D3D_CreateTexture(renderer, texture); + } + } + IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget); D3D_InitRenderState(data); + D3D_SetRenderTargetInternal(renderer, renderer->target); D3D_UpdateViewport(renderer); + + /* Let the application know that render targets were reset */ + { + SDL_Event event; + event.type = SDL_RENDER_TARGETS_RESET; + SDL_PushEvent(&event); + } + return 0; } @@ -551,8 +499,6 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) Uint32 window_flags; int w, h; SDL_DisplayMode fullscreen_mode; - int d3dxVersion; - char d3dxDLLFile[50]; int displayIndex; renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); @@ -568,29 +514,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) return NULL; } - if( D3D_LoadDLL( &data->d3dDLL, &data->d3d ) ) { - for (d3dxVersion=50;d3dxVersion>0;d3dxVersion--) { - LPTSTR dllName; - SDL_snprintf(d3dxDLLFile, sizeof(d3dxDLLFile), "D3DX9_%02d.dll", d3dxVersion); - dllName = WIN_UTF8ToString(d3dxDLLFile); - data->d3dxDLL = (void *)LoadLibrary(dllName); /* not using SDL_LoadObject() as we want silently fail - no error message */ - SDL_free(dllName); - if (data->d3dxDLL) { - HRESULT (WINAPI *D3DXCreateMatrixStack) (DWORD Flags, LPD3DXMATRIXSTACK* ppStack); - D3DXCreateMatrixStack = (HRESULT (WINAPI *) (DWORD, LPD3DXMATRIXSTACK*)) SDL_LoadFunction(data->d3dxDLL, "D3DXCreateMatrixStack"); - if (D3DXCreateMatrixStack) { - D3DXCreateMatrixStack(0, &data->matrixStack); - break; - } - } - } - - if (!data->matrixStack) { - if (data->d3dxDLL) SDL_UnloadObject(data->d3dxDLL); - } - } - - if (!data->d3d || !data->matrixStack) { + if (!D3D_LoadDLL(&data->d3dDLL, &data->d3d)) { SDL_free(renderer); SDL_free(data); SDL_SetError("Unable to create Direct3D interface"); @@ -617,10 +541,9 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->DestroyTexture = D3D_DestroyTexture; renderer->DestroyRenderer = D3D_DestroyRenderer; renderer->info = D3D_RenderDriver.info; + renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); renderer->driverdata = data; - renderer->info.flags = SDL_RENDERER_ACCELERATED; - SDL_VERSION(&windowinfo.version); SDL_GetWindowWMInfo(window, &windowinfo); @@ -642,13 +565,12 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) pparams.SwapEffect = D3DSWAPEFFECT_DISCARD; if (window_flags & SDL_WINDOW_FULLSCREEN) { - if ( ( window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP ) == SDL_WINDOW_FULLSCREEN_DESKTOP ) { + if ((window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) { pparams.Windowed = TRUE; pparams.FullScreen_RefreshRateInHz = 0; } else { - pparams.Windowed = FALSE; - pparams.FullScreen_RefreshRateInHz = - fullscreen_mode.refresh_rate; + pparams.Windowed = FALSE; + pparams.FullScreen_RefreshRateInHz = fullscreen_mode.refresh_rate; } } else { pparams.Windowed = TRUE; @@ -661,8 +583,8 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) } /* Get the adapter for the display that the window is on */ - displayIndex = SDL_GetWindowDisplayIndex( window ); - data->adapter = SDL_Direct3D9GetAdapterIndex( displayIndex ); + displayIndex = SDL_GetWindowDisplayIndex(window); + data->adapter = SDL_Direct3D9GetAdapterIndex(displayIndex); IDirect3D9_GetDeviceCaps(data->d3d, data->adapter, D3DDEVTYPE_HAL, &caps); @@ -979,6 +901,12 @@ D3D_UpdateTextureInternal(IDirect3DTexture9 *texture, Uint32 format, SDL_bool fu if (length == pitch && length == locked.Pitch) { SDL_memcpy(dst, src, length*h); } else { + if (length > pitch) { + length = pitch; + } + if (length > locked.Pitch) { + length = locked.Pitch; + } for (row = 0; row < h; ++row) { SDL_memcpy(dst, src, length); src += pitch; @@ -1005,6 +933,11 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, } #endif + if (!data) { + SDL_SetError("Texture is not currently available"); + return -1; + } + if (D3D_UpdateTextureInternal(data->texture, texture->format, full_texture, rect->x, rect->y, rect->w, rect->h, pixels, pitch) < 0) { return -1; } @@ -1044,6 +977,11 @@ D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, } #endif + if (!data) { + SDL_SetError("Texture is not currently available"); + return -1; + } + if (D3D_UpdateTextureInternal(data->texture, texture->format, full_texture, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) { return -1; } @@ -1065,6 +1003,11 @@ D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, D3DLOCKED_RECT locked; HRESULT result; + if (!data) { + SDL_SetError("Texture is not currently available"); + return -1; + } + if (data->yuv) { /* It's more efficient to upload directly... */ if (!data->pixels) { @@ -1100,6 +1043,10 @@ D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) { D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; + if (!data) { + return; + } + if (data->yuv) { const SDL_Rect *rect = &data->locked_rect; void *pixels = @@ -1112,14 +1059,12 @@ D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) } static int -D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture) { D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; D3D_TextureData *texturedata; HRESULT result; - D3D_ActivateRenderer(renderer); - /* Release the previous render target if it wasn't the default one */ if (data->currentRenderTarget != NULL) { IDirect3DSurface9_Release(data->currentRenderTarget); @@ -1131,7 +1076,12 @@ D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } - texturedata = (D3D_TextureData *) texture->driverdata; + texturedata = (D3D_TextureData *)texture->driverdata; + if (!texturedata) { + SDL_SetError("Texture is not currently available"); + return -1; + } + result = IDirect3DTexture9_GetSurfaceLevel(texturedata->texture, 0, &data->currentRenderTarget); if(FAILED(result)) { return D3D_SetError("GetSurfaceLevel()", result); @@ -1144,6 +1094,14 @@ D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } +static int +D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +{ + D3D_ActivateRenderer(renderer); + + return D3D_SetRenderTargetInternal(renderer, texture); +} + static int D3D_UpdateViewport(SDL_Renderer * renderer) { @@ -1507,7 +1465,7 @@ D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * srcrect, const SDL_FRect * dstrect) { D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; - D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata; + D3D_TextureData *texturedata; LPDIRECT3DPIXELSHADER9 shader = NULL; float minx, miny, maxx, maxy; float minu, maxu, minv, maxv; @@ -1519,6 +1477,12 @@ D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, return -1; } + texturedata = (D3D_TextureData *)texture->driverdata; + if (!texturedata) { + SDL_SetError("Texture is not currently available"); + return -1; + } + minx = dstrect->x - 0.5f; miny = dstrect->y - 0.5f; maxx = dstrect->x + dstrect->w - 0.5f; @@ -1619,19 +1583,26 @@ D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip) { D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; - D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata; + D3D_TextureData *texturedata; LPDIRECT3DPIXELSHADER9 shader = NULL; float minx, miny, maxx, maxy; float minu, maxu, minv, maxv; float centerx, centery; DWORD color; Vertex vertices[4]; + Float4X4 modelMatrix; HRESULT result; if (D3D_ActivateRenderer(renderer) < 0) { return -1; } + texturedata = (D3D_TextureData *)texture->driverdata; + if (!texturedata) { + SDL_SetError("Texture is not currently available"); + return -1; + } + centerx = center->x; centery = center->y; @@ -1691,11 +1662,11 @@ D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, D3D_SetBlendMode(data, texture->blendMode); /* Rotate and translate */ - ID3DXMatrixStack_Push(data->matrixStack); - ID3DXMatrixStack_LoadIdentity(data->matrixStack); - ID3DXMatrixStack_RotateYawPitchRoll(data->matrixStack, 0.0, 0.0, (float)(M_PI * (float) angle / 180.0f)); - ID3DXMatrixStack_Translate(data->matrixStack, (float)dstrect->x + centerx, (float)dstrect->y + centery, (float)0.0); - IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)ID3DXMatrixStack_GetTop(data->matrixStack)); + modelMatrix = MatrixMultiply( + MatrixRotationZ((float)(M_PI * (float) angle / 180.0f)), + MatrixTranslation(dstrect->x + center->x, dstrect->y + center->y, 0) + ); + IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&modelMatrix); D3D_UpdateTextureScaleMode(data, texturedata, 0); @@ -1745,11 +1716,9 @@ D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, return D3D_SetError("SetShader()", result); } } - ID3DXMatrixStack_Pop(data->matrixStack); - ID3DXMatrixStack_Push(data->matrixStack); - ID3DXMatrixStack_LoadIdentity(data->matrixStack); - IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)ID3DXMatrixStack_GetTop(data->matrixStack)); - ID3DXMatrixStack_Pop(data->matrixStack); + + modelMatrix = MatrixIdentity(); + IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&modelMatrix); return 0; } @@ -1883,19 +1852,23 @@ D3D_DestroyRenderer(SDL_Renderer * renderer) } if (data->d3d) { IDirect3D9_Release(data->d3d); - ID3DXMatrixStack_Release(data->matrixStack); SDL_UnloadObject(data->d3dDLL); } SDL_free(data); } SDL_free(renderer); } +#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */ +#ifdef __WIN32__ +/* This function needs to always exist on Windows, for the Dynamic API. */ IDirect3DDevice9 * SDL_RenderGetD3D9Device(SDL_Renderer * renderer) { + IDirect3DDevice9 *device = NULL; + +#if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; - IDirect3DDevice9 *device; // Make sure that this is a D3D renderer if (renderer->DestroyRenderer != D3D_DestroyRenderer) { @@ -1905,11 +1878,12 @@ SDL_RenderGetD3D9Device(SDL_Renderer * renderer) device = data->device; if (device) { - IDirect3DDevice9_AddRef( device ); + IDirect3DDevice9_AddRef(device); } - return device; -} - #endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */ + return device; +} +#endif /* __WIN32__ */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/render/direct3d11/SDL_render_d3d11.c b/jni/SDL2-2.0.3/src/render/direct3d11/SDL_render_d3d11.c new file mode 100644 index 00000000..dbffd505 --- /dev/null +++ b/jni/SDL2-2.0.3/src/render/direct3d11/SDL_render_d3d11.c @@ -0,0 +1,2879 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED + +#define COBJMACROS +#include "../../core/windows/SDL_windows.h" +#include "SDL_hints.h" +#include "SDL_loadso.h" +#include "SDL_syswm.h" +#include "../SDL_sysrender.h" +#include "../SDL_d3dmath.h" + +#include + + +#ifdef __WINRT__ + +#include "SDL_render_winrt.h" + +#if WINAPI_FAMILY == WINAPI_FAMILY_APP +#include +/* TODO, WinRT, XAML: get the ISwapChainBackgroundPanelNative from something other than a global var */ +extern ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNative; +#endif /* WINAPI_FAMILY == WINAPI_FAMILY_APP */ + +#endif /* __WINRT__ */ + + +#define SAFE_RELEASE(X) if ((X)) { IUnknown_Release(SDL_static_cast(IUnknown*, X)); X = NULL; } + + +/* Vertex shader, common values */ +typedef struct +{ + Float4X4 model; + Float4X4 projectionAndView; +} VertexShaderConstants; + +/* Per-vertex data */ +typedef struct +{ + Float3 pos; + Float2 tex; + Float4 color; +} VertexPositionColor; + +/* Per-texture data */ +typedef struct +{ + ID3D11Texture2D *mainTexture; + ID3D11ShaderResourceView *mainTextureResourceView; + ID3D11RenderTargetView *mainTextureRenderTargetView; + ID3D11Texture2D *stagingTexture; + int lockedTexturePositionX; + int lockedTexturePositionY; + D3D11_FILTER scaleMode; + + /* YV12 texture support */ + SDL_bool yuv; + ID3D11Texture2D *mainTextureU; + ID3D11ShaderResourceView *mainTextureResourceViewU; + ID3D11Texture2D *mainTextureV; + ID3D11ShaderResourceView *mainTextureResourceViewV; + Uint8 *pixels; + int pitch; + SDL_Rect locked_rect; +} D3D11_TextureData; + +/* Private renderer data */ +typedef struct +{ + void *hDXGIMod; + void *hD3D11Mod; + IDXGIFactory2 *dxgiFactory; + IDXGIAdapter *dxgiAdapter; + ID3D11Device1 *d3dDevice; + ID3D11DeviceContext1 *d3dContext; + IDXGISwapChain1 *swapChain; + DXGI_SWAP_EFFECT swapEffect; + ID3D11RenderTargetView *mainRenderTargetView; + ID3D11RenderTargetView *currentOffscreenRenderTargetView; + ID3D11InputLayout *inputLayout; + ID3D11Buffer *vertexBuffer; + ID3D11VertexShader *vertexShader; + ID3D11PixelShader *colorPixelShader; + ID3D11PixelShader *texturePixelShader; + ID3D11PixelShader *yuvPixelShader; + ID3D11BlendState *blendModeBlend; + ID3D11BlendState *blendModeAdd; + ID3D11BlendState *blendModeMod; + ID3D11SamplerState *nearestPixelSampler; + ID3D11SamplerState *linearSampler; + D3D_FEATURE_LEVEL featureLevel; + + /* Rasterizers */ + ID3D11RasterizerState *mainRasterizer; + ID3D11RasterizerState *clippedRasterizer; + + /* Vertex buffer constants */ + VertexShaderConstants vertexShaderConstantsData; + ID3D11Buffer *vertexShaderConstants; + + /* Cached renderer properties */ + DXGI_MODE_ROTATION rotation; + ID3D11RenderTargetView *currentRenderTargetView; + ID3D11RasterizerState *currentRasterizerState; + ID3D11BlendState *currentBlendState; + ID3D11PixelShader *currentShader; + ID3D11ShaderResourceView *currentShaderResource; + ID3D11SamplerState *currentSampler; +} D3D11_RenderData; + + +/* Defined here so we don't have to include uuid.lib */ +static const GUID IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } }; +static const GUID IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } }; +static const GUID IID_ID3D11Texture2D = { 0x6f15aaf2, 0xd208, 0x4e89, { 0x9a, 0xb4, 0x48, 0x95, 0x35, 0xd3, 0x4f, 0x9c } }; +static const GUID IID_ID3D11Device1 = { 0xa04bfb29, 0x08ef, 0x43d6, { 0xa4, 0x9c, 0xa9, 0xbd, 0xbd, 0xcb, 0xe6, 0x86 } }; +static const GUID IID_ID3D11DeviceContext1 = { 0xbb2c6faa, 0xb5fb, 0x4082, { 0x8e, 0x6b, 0x38, 0x8b, 0x8c, 0xfa, 0x90, 0xe1 } }; +static const GUID IID_ID3D11Debug = { 0x79cf2233, 0x7536, 0x4948, { 0x9d, 0x36, 0x1e, 0x46, 0x92, 0xdc, 0x57, 0x60 } }; + +/* Direct3D 11.x shaders + + SDL's shaders are compiled into SDL itself, to simplify distribution. + + All Direct3D 11.x shaders were compiled with the following: + + fxc /E"main" /T "" /Fo"" "" + + Variables: + - : the type of shader. A table of utilized shader types is + listed below. + - : where to store compiled output + - : where to read shader source code from + + Shader types: + - ps_4_0_level_9_1: Pixel shader for Windows 8+, including Windows RT + - vs_4_0_level_9_1: Vertex shader for Windows 8+, including Windows RT + - ps_4_0_level_9_3: Pixel shader for Windows Phone 8 + - vs_4_0_level_9_3: Vertex shader for Windows Phone 8 + + + Shader object code was converted to a list of DWORDs via the following + *nix style command (available separately from Windows + MSVC): + + hexdump -v -e '6/4 "0x%08.8x, " "\n"' + */ +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#define D3D11_USE_SHADER_MODEL_4_0_level_9_3 +#else +#define D3D11_USE_SHADER_MODEL_4_0_level_9_1 +#endif + +/* The color-only-rendering pixel shader: + + --- D3D11_PixelShader_Colors.hlsl --- + struct PixelShaderInput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + float4 main(PixelShaderInput input) : SV_TARGET + { + return input.color; + } +*/ +#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1) +static const DWORD D3D11_PixelShader_Colors[] = { + 0x43425844, 0xd74c28fe, 0xa1eb8804, 0x269d512a, 0x7699723d, 0x00000001, + 0x00000240, 0x00000006, 0x00000038, 0x00000084, 0x000000c4, 0x00000140, + 0x00000198, 0x0000020c, 0x396e6f41, 0x00000044, 0x00000044, 0xffff0200, + 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000, + 0x00240000, 0xffff0200, 0x0200001f, 0x80000000, 0xb00f0001, 0x02000001, + 0x800f0800, 0xb0e40001, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040, + 0x0000000e, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, + 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000002, + 0x0100003e, 0x54415453, 0x00000074, 0x00000002, 0x00000000, 0x00000000, + 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x46454452, 0x00000050, 0x00000000, 0x00000000, + 0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d, + 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, + 0x6c69706d, 0x39207265, 0x2e30332e, 0x30303239, 0x3336312e, 0xab003438, + 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, + 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, + 0x00000000, 0x00000003, 0x00000001, 0x00000003, 0x00000065, 0x00000000, + 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, + 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, + 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3) +static const DWORD D3D11_PixelShader_Colors[] = { + 0x43425844, 0x93f6ccfc, 0x5f919270, 0x7a11aa4f, 0x9148e931, 0x00000001, + 0x00000240, 0x00000006, 0x00000038, 0x00000084, 0x000000c4, 0x00000140, + 0x00000198, 0x0000020c, 0x396e6f41, 0x00000044, 0x00000044, 0xffff0200, + 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000, + 0x00240000, 0xffff0201, 0x0200001f, 0x80000000, 0xb00f0001, 0x02000001, + 0x800f0800, 0xb0e40001, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040, + 0x0000000e, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, + 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000002, + 0x0100003e, 0x54415453, 0x00000074, 0x00000002, 0x00000000, 0x00000000, + 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x46454452, 0x00000050, 0x00000000, 0x00000000, + 0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d, + 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, + 0x6c69706d, 0x39207265, 0x2e30332e, 0x30303239, 0x3336312e, 0xab003438, + 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, + 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, + 0x00000000, 0x00000003, 0x00000001, 0x00000003, 0x00000065, 0x00000000, + 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, + 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, + 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#else +#error "An appropriate 'colors' pixel shader is not defined." +#endif + +/* The texture-rendering pixel shader: + + --- D3D11_PixelShader_Textures.hlsl --- + Texture2D theTexture : register(t0); + SamplerState theSampler : register(s0); + + struct PixelShaderInput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + float4 main(PixelShaderInput input) : SV_TARGET + { + return theTexture.Sample(theSampler, input.tex) * input.color; + } +*/ +#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1) +static const DWORD D3D11_PixelShader_Textures[] = { + 0x43425844, 0x6299b59f, 0x155258f2, 0x873ab86a, 0xfcbb6dcd, 0x00000001, + 0x00000330, 0x00000006, 0x00000038, 0x000000c0, 0x0000015c, 0x000001d8, + 0x00000288, 0x000002fc, 0x396e6f41, 0x00000080, 0x00000080, 0xffff0200, + 0x00000058, 0x00000028, 0x00280000, 0x00280000, 0x00280000, 0x00240001, + 0x00280000, 0x00000000, 0xffff0200, 0x0200001f, 0x80000000, 0xb0030000, + 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, 0xa00f0800, + 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000005, 0x800f0000, + 0x80e40000, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, + 0x52444853, 0x00000094, 0x00000040, 0x00000025, 0x0300005a, 0x00106000, + 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x03001062, + 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, + 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x09000045, 0x001000f2, + 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000, + 0x00000000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, + 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x00000003, + 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000, + 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000a8, + 0x00000000, 0x00000000, 0x00000002, 0x0000001c, 0xffff0400, 0x00000100, + 0x00000072, 0x0000005c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000001, 0x00000001, 0x00000067, 0x00000002, 0x00000005, + 0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x53656874, + 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x694d0065, 0x736f7263, + 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43, + 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336, 0xababab00, + 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, + 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, + 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000, + 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, + 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, + 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3) +static const DWORD D3D11_PixelShader_Textures[] = { + 0x43425844, 0x5876569a, 0x01b6c87e, 0x8447454f, 0xc7f3ef10, 0x00000001, + 0x00000330, 0x00000006, 0x00000038, 0x000000c0, 0x0000015c, 0x000001d8, + 0x00000288, 0x000002fc, 0x396e6f41, 0x00000080, 0x00000080, 0xffff0200, + 0x00000058, 0x00000028, 0x00280000, 0x00280000, 0x00280000, 0x00240001, + 0x00280000, 0x00000000, 0xffff0201, 0x0200001f, 0x80000000, 0xb0030000, + 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, 0xa00f0800, + 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000005, 0x800f0000, + 0x80e40000, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, + 0x52444853, 0x00000094, 0x00000040, 0x00000025, 0x0300005a, 0x00106000, + 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x03001062, + 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, + 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x09000045, 0x001000f2, + 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000, + 0x00000000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000, + 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x00000003, + 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000, + 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000a8, + 0x00000000, 0x00000000, 0x00000002, 0x0000001c, 0xffff0400, 0x00000100, + 0x00000072, 0x0000005c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000001, 0x00000001, 0x00000067, 0x00000002, 0x00000005, + 0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x53656874, + 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x694d0065, 0x736f7263, + 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43, + 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336, 0xababab00, + 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, + 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, + 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000, + 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, + 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, + 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#else +#error "An appropriate 'textures' pixel shader is not defined" +#endif + +/* The yuv-rendering pixel shader: + + --- D3D11_PixelShader_YUV.hlsl --- + Texture2D theTextureY : register(t0); + Texture2D theTextureU : register(t1); + Texture2D theTextureV : register(t2); + SamplerState theSampler : register(s0); + + struct PixelShaderInput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + float4 main(PixelShaderInput input) : SV_TARGET + { + const float3 offset = {-0.0625, -0.5, -0.5}; + const float3 Rcoeff = {1.164, 0.000, 1.596}; + const float3 Gcoeff = {1.164, -0.391, -0.813}; + const float3 Bcoeff = {1.164, 2.018, 0.000}; + + float4 Output; + + float3 yuv; + yuv.x = theTextureY.Sample(theSampler, input.tex).r; + yuv.y = theTextureU.Sample(theSampler, input.tex).r; + yuv.z = theTextureV.Sample(theSampler, input.tex).r; + + yuv += offset; + Output.r = dot(yuv, Rcoeff); + Output.g = dot(yuv, Gcoeff); + Output.b = dot(yuv, Bcoeff); + Output.a = 1.0f; + + return Output * input.color; + } + +*/ +#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1) +static const DWORD D3D11_PixelShader_YUV[] = { + 0x43425844, 0x04e69cba, 0x74ce6dd2, 0x7fcf84cb, 0x3003d677, 0x00000001, + 0x000005e8, 0x00000006, 0x00000038, 0x000001dc, 0x000003bc, 0x00000438, + 0x00000540, 0x000005b4, 0x396e6f41, 0x0000019c, 0x0000019c, 0xffff0200, + 0x0000016c, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003, + 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0200, 0x05000051, + 0xa00f0000, 0xbd800000, 0xbf000000, 0xbf000000, 0x3f800000, 0x05000051, + 0xa00f0001, 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x00000000, 0x05000051, + 0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, 0x05000051, + 0xa00f0003, 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000, 0x0200001f, + 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, + 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f, + 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, + 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002, + 0xb0e40000, 0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001, + 0x80040000, 0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, + 0x03000005, 0x80080000, 0x80000000, 0xa0000001, 0x04000004, 0x80010001, + 0x80aa0000, 0xa0550001, 0x80ff0000, 0x03000008, 0x80020001, 0x80e40000, + 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003, + 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001, + 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853, + 0x000001d8, 0x00000040, 0x00000076, 0x0300005a, 0x00106000, 0x00000000, + 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858, 0x00107000, + 0x00000001, 0x00005555, 0x04001858, 0x00107000, 0x00000002, 0x00005555, + 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, + 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, + 0x001000f2, 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, + 0x00106000, 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, + 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, + 0x00100022, 0x00000000, 0x0010000a, 0x00000001, 0x09000045, 0x001000f2, + 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000002, 0x00106000, + 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x0010000a, 0x00000001, + 0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000, 0x00004002, + 0xbd800000, 0xbf000000, 0xbf000000, 0x00000000, 0x0a00000f, 0x00100012, + 0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f94fdf4, 0x3fcc49ba, + 0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001, 0x00100246, + 0x00000000, 0x00004002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, + 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, 0x00000000, 0x00004002, + 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000, 0x05000036, 0x00100082, + 0x00000001, 0x00004001, 0x3f800000, 0x07000038, 0x001020f2, 0x00000000, + 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, + 0x00000074, 0x0000000c, 0x00000002, 0x00000000, 0x00000003, 0x00000005, + 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x46454452, 0x00000100, 0x00000000, 0x00000000, 0x00000004, 0x0000001c, + 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c, 0x00000003, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x000000a7, + 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000000, 0x00000001, + 0x0000000d, 0x000000b3, 0x00000002, 0x00000005, 0x00000004, 0xffffffff, + 0x00000001, 0x00000001, 0x0000000d, 0x000000bf, 0x00000002, 0x00000005, + 0x00000004, 0xffffffff, 0x00000002, 0x00000001, 0x0000000d, 0x53656874, + 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965, 0x65546568, + 0x72757478, 0x74005565, 0x65546568, 0x72757478, 0x4d005665, 0x6f726369, + 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, + 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030, 0x34383336, 0xababab00, + 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, + 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, + 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000, + 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, + 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, + 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, + 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054 +}; +#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3) +static const DWORD D3D11_PixelShader_YUV[] = { + 0x43425844, 0xe6d969fc, 0x63cac33c, 0xa4926502, 0x5d788135, 0x00000001, + 0x000005c0, 0x00000006, 0x00000038, 0x000001b4, 0x00000394, 0x00000410, + 0x00000518, 0x0000058c, 0x396e6f41, 0x00000174, 0x00000174, 0xffff0200, + 0x00000144, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003, + 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0201, 0x05000051, + 0xa00f0000, 0xbd800000, 0xbf000000, 0x3f800000, 0x00000000, 0x05000051, + 0xa00f0001, 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x400126e9, 0x05000051, + 0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, 0x0200001f, + 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, + 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f, + 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40801, + 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800, 0x02000001, 0x80020001, + 0x80000000, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40802, 0x02000001, + 0x80040001, 0x80000000, 0x03000002, 0x80070000, 0x80e40001, 0xa0d40000, + 0x0400005a, 0x80010001, 0x80e80000, 0xa0e40001, 0xa0aa0001, 0x03000008, + 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, + 0xa0ec0001, 0xa0aa0001, 0x02000001, 0x80080001, 0xa0aa0000, 0x03000005, + 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, + 0x0000ffff, 0x52444853, 0x000001d8, 0x00000040, 0x00000076, 0x0300005a, + 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, + 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x04001858, 0x00107000, + 0x00000002, 0x00005555, 0x03001062, 0x00101032, 0x00000001, 0x03001062, + 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, + 0x00000002, 0x09000045, 0x001000f2, 0x00000000, 0x00101046, 0x00000001, + 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045, 0x001000f2, + 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000, + 0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x0010000a, 0x00000001, + 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46, + 0x00000002, 0x00106000, 0x00000000, 0x05000036, 0x00100042, 0x00000000, + 0x0010000a, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246, + 0x00000000, 0x00004002, 0xbd800000, 0xbf000000, 0xbf000000, 0x00000000, + 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002, + 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x00000000, 0x0a000010, 0x00100022, + 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f94fdf4, 0xbec83127, + 0xbf5020c5, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, + 0x00000000, 0x00004002, 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000, + 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000, 0x07000038, + 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, + 0x0100003e, 0x54415453, 0x00000074, 0x0000000c, 0x00000002, 0x00000000, + 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x46454452, 0x00000100, 0x00000000, 0x00000000, + 0x00000004, 0x0000001c, 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c, + 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, + 0x00000001, 0x000000a7, 0x00000002, 0x00000005, 0x00000004, 0xffffffff, + 0x00000000, 0x00000001, 0x0000000d, 0x000000b3, 0x00000002, 0x00000005, + 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, 0x000000bf, + 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000002, 0x00000001, + 0x0000000d, 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, + 0x74005965, 0x65546568, 0x72757478, 0x74005565, 0x65546568, 0x72757478, + 0x4d005665, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, + 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030, + 0x34383336, 0xababab00, 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, + 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, + 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, + 0x00000065, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, + 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, + 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, + 0x45475241, 0xabab0054 +}; +#else +#error "An appropriate 'yuv' pixel shader is not defined." +#endif + +/* The sole vertex shader: + + --- D3D11_VertexShader.hlsl --- + #pragma pack_matrix( row_major ) + + cbuffer VertexShaderConstants : register(b0) + { + matrix model; + matrix projectionAndView; + }; + + struct VertexShaderInput + { + float3 pos : POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + struct VertexShaderOutput + { + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; + float4 color : COLOR0; + }; + + VertexShaderOutput main(VertexShaderInput input) + { + VertexShaderOutput output; + float4 pos = float4(input.pos, 1.0f); + + // Transform the vertex position into projected space. + pos = mul(pos, model); + pos = mul(pos, projectionAndView); + output.pos = pos; + + // Pass through texture coordinates and color values without transformation + output.tex = input.tex; + output.color = input.color; + + return output; + } +*/ +#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1) +static const DWORD D3D11_VertexShader[] = { + 0x43425844, 0x62dfae5f, 0x3e8bd8df, 0x9ec97127, 0x5044eefb, 0x00000001, + 0x00000598, 0x00000006, 0x00000038, 0x0000016c, 0x00000334, 0x000003b0, + 0x000004b4, 0x00000524, 0x396e6f41, 0x0000012c, 0x0000012c, 0xfffe0200, + 0x000000f8, 0x00000034, 0x00240001, 0x00300000, 0x00300000, 0x00240000, + 0x00300001, 0x00000000, 0x00010008, 0x00000000, 0x00000000, 0xfffe0200, + 0x0200001f, 0x80000005, 0x900f0000, 0x0200001f, 0x80010005, 0x900f0001, + 0x0200001f, 0x80020005, 0x900f0002, 0x03000005, 0x800f0000, 0x90550000, + 0xa0e40002, 0x04000004, 0x800f0000, 0x90000000, 0xa0e40001, 0x80e40000, + 0x04000004, 0x800f0000, 0x90aa0000, 0xa0e40003, 0x80e40000, 0x03000002, + 0x800f0000, 0x80e40000, 0xa0e40004, 0x03000005, 0x800f0001, 0x80550000, + 0xa0e40006, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40005, 0x80e40001, + 0x04000004, 0x800f0001, 0x80aa0000, 0xa0e40007, 0x80e40001, 0x04000004, + 0x800f0000, 0x80ff0000, 0xa0e40008, 0x80e40001, 0x04000004, 0xc0030000, + 0x80ff0000, 0xa0e40000, 0x80e40000, 0x02000001, 0xc00c0000, 0x80e40000, + 0x02000001, 0xe0030000, 0x90e40001, 0x02000001, 0xe00f0001, 0x90e40002, + 0x0000ffff, 0x52444853, 0x000001c0, 0x00010040, 0x00000070, 0x04000059, + 0x00208e46, 0x00000000, 0x00000008, 0x0300005f, 0x00101072, 0x00000000, + 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x001010f2, 0x00000002, + 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102032, + 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000002, + 0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000, 0x00208e46, + 0x00000000, 0x00000001, 0x0a000032, 0x001000f2, 0x00000000, 0x00101006, + 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000, + 0x0a000032, 0x001000f2, 0x00000000, 0x00101aa6, 0x00000000, 0x00208e46, + 0x00000000, 0x00000002, 0x00100e46, 0x00000000, 0x08000000, 0x001000f2, + 0x00000000, 0x00100e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000003, + 0x08000038, 0x001000f2, 0x00000001, 0x00100556, 0x00000000, 0x00208e46, + 0x00000000, 0x00000005, 0x0a000032, 0x001000f2, 0x00000001, 0x00100006, + 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x00100e46, 0x00000001, + 0x0a000032, 0x001000f2, 0x00000001, 0x00100aa6, 0x00000000, 0x00208e46, + 0x00000000, 0x00000006, 0x00100e46, 0x00000001, 0x0a000032, 0x001020f2, + 0x00000000, 0x00100ff6, 0x00000000, 0x00208e46, 0x00000000, 0x00000007, + 0x00100e46, 0x00000001, 0x05000036, 0x00102032, 0x00000001, 0x00101046, + 0x00000001, 0x05000036, 0x001020f2, 0x00000002, 0x00101e46, 0x00000002, + 0x0100003e, 0x54415453, 0x00000074, 0x0000000b, 0x00000002, 0x00000000, + 0x00000006, 0x00000003, 0x00000000, 0x00000000, 0x00000001, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x46454452, 0x000000fc, 0x00000001, 0x00000054, + 0x00000001, 0x0000001c, 0xfffe0400, 0x00000100, 0x000000c6, 0x0000003c, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, + 0x00000001, 0x74726556, 0x68537865, 0x72656461, 0x736e6f43, 0x746e6174, + 0xabab0073, 0x0000003c, 0x00000002, 0x0000006c, 0x00000080, 0x00000000, + 0x00000000, 0x0000009c, 0x00000000, 0x00000040, 0x00000002, 0x000000a4, + 0x00000000, 0x000000b4, 0x00000040, 0x00000040, 0x00000002, 0x000000a4, + 0x00000000, 0x65646f6d, 0xabab006c, 0x00030002, 0x00040004, 0x00000000, + 0x00000000, 0x6a6f7270, 0x69746365, 0x6e416e6f, 0x65695664, 0x694d0077, + 0x736f7263, 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, + 0x706d6f43, 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336, + 0xababab00, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000707, 0x00000059, + 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000062, + 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x49534f50, + 0x4e4f4954, 0x58455400, 0x524f4f43, 0x4f430044, 0x00524f4c, 0x4e47534f, + 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, + 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, + 0x00000003, 0x00000001, 0x00000c03, 0x00000065, 0x00000000, 0x00000000, + 0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, + 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f +}; +#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3) +static const DWORD D3D11_VertexShader[] = { + 0x43425844, 0x01a24e41, 0x696af551, 0x4b2a87d1, 0x82ea03f6, 0x00000001, + 0x00000598, 0x00000006, 0x00000038, 0x0000016c, 0x00000334, 0x000003b0, + 0x000004b4, 0x00000524, 0x396e6f41, 0x0000012c, 0x0000012c, 0xfffe0200, + 0x000000f8, 0x00000034, 0x00240001, 0x00300000, 0x00300000, 0x00240000, + 0x00300001, 0x00000000, 0x00010008, 0x00000000, 0x00000000, 0xfffe0201, + 0x0200001f, 0x80000005, 0x900f0000, 0x0200001f, 0x80010005, 0x900f0001, + 0x0200001f, 0x80020005, 0x900f0002, 0x03000005, 0x800f0000, 0x90550000, + 0xa0e40002, 0x04000004, 0x800f0000, 0x90000000, 0xa0e40001, 0x80e40000, + 0x04000004, 0x800f0000, 0x90aa0000, 0xa0e40003, 0x80e40000, 0x03000002, + 0x800f0000, 0x80e40000, 0xa0e40004, 0x03000005, 0x800f0001, 0x80550000, + 0xa0e40006, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40005, 0x80e40001, + 0x04000004, 0x800f0001, 0x80aa0000, 0xa0e40007, 0x80e40001, 0x04000004, + 0x800f0000, 0x80ff0000, 0xa0e40008, 0x80e40001, 0x04000004, 0xc0030000, + 0x80ff0000, 0xa0e40000, 0x80e40000, 0x02000001, 0xc00c0000, 0x80e40000, + 0x02000001, 0xe0030000, 0x90e40001, 0x02000001, 0xe00f0001, 0x90e40002, + 0x0000ffff, 0x52444853, 0x000001c0, 0x00010040, 0x00000070, 0x04000059, + 0x00208e46, 0x00000000, 0x00000008, 0x0300005f, 0x00101072, 0x00000000, + 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x001010f2, 0x00000002, + 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102032, + 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000002, + 0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000, 0x00208e46, + 0x00000000, 0x00000001, 0x0a000032, 0x001000f2, 0x00000000, 0x00101006, + 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000, + 0x0a000032, 0x001000f2, 0x00000000, 0x00101aa6, 0x00000000, 0x00208e46, + 0x00000000, 0x00000002, 0x00100e46, 0x00000000, 0x08000000, 0x001000f2, + 0x00000000, 0x00100e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000003, + 0x08000038, 0x001000f2, 0x00000001, 0x00100556, 0x00000000, 0x00208e46, + 0x00000000, 0x00000005, 0x0a000032, 0x001000f2, 0x00000001, 0x00100006, + 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x00100e46, 0x00000001, + 0x0a000032, 0x001000f2, 0x00000001, 0x00100aa6, 0x00000000, 0x00208e46, + 0x00000000, 0x00000006, 0x00100e46, 0x00000001, 0x0a000032, 0x001020f2, + 0x00000000, 0x00100ff6, 0x00000000, 0x00208e46, 0x00000000, 0x00000007, + 0x00100e46, 0x00000001, 0x05000036, 0x00102032, 0x00000001, 0x00101046, + 0x00000001, 0x05000036, 0x001020f2, 0x00000002, 0x00101e46, 0x00000002, + 0x0100003e, 0x54415453, 0x00000074, 0x0000000b, 0x00000002, 0x00000000, + 0x00000006, 0x00000003, 0x00000000, 0x00000000, 0x00000001, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x46454452, 0x000000fc, 0x00000001, 0x00000054, + 0x00000001, 0x0000001c, 0xfffe0400, 0x00000100, 0x000000c6, 0x0000003c, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, + 0x00000001, 0x74726556, 0x68537865, 0x72656461, 0x736e6f43, 0x746e6174, + 0xabab0073, 0x0000003c, 0x00000002, 0x0000006c, 0x00000080, 0x00000000, + 0x00000000, 0x0000009c, 0x00000000, 0x00000040, 0x00000002, 0x000000a4, + 0x00000000, 0x000000b4, 0x00000040, 0x00000040, 0x00000002, 0x000000a4, + 0x00000000, 0x65646f6d, 0xabab006c, 0x00030002, 0x00040004, 0x00000000, + 0x00000000, 0x6a6f7270, 0x69746365, 0x6e416e6f, 0x65695664, 0x694d0077, + 0x736f7263, 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, + 0x706d6f43, 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336, + 0xababab00, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000707, 0x00000059, + 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000062, + 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x49534f50, + 0x4e4f4954, 0x58455400, 0x524f4f43, 0x4f430044, 0x00524f4c, 0x4e47534f, + 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, + 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, + 0x00000003, 0x00000001, 0x00000c03, 0x00000065, 0x00000000, 0x00000000, + 0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, + 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f +}; +#else +#error "An appropriate vertex shader is not defined." +#endif + + +/* Direct3D 11.1 renderer implementation */ +static SDL_Renderer *D3D11_CreateRenderer(SDL_Window * window, Uint32 flags); +static void D3D11_WindowEvent(SDL_Renderer * renderer, + const SDL_WindowEvent *event); +static int D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *srcPixels, + int srcPitch); +static int D3D11_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); +static int D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch); +static void D3D11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int D3D11_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture); +static int D3D11_UpdateViewport(SDL_Renderer * renderer); +static int D3D11_UpdateClipRect(SDL_Renderer * renderer); +static int D3D11_RenderClear(SDL_Renderer * renderer); +static int D3D11_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_FPoint * points, int count); +static int D3D11_RenderDrawLines(SDL_Renderer * renderer, + const SDL_FPoint * points, int count); +static int D3D11_RenderFillRects(SDL_Renderer * renderer, + const SDL_FRect * rects, int count); +static int D3D11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect); +static int D3D11_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip); +static int D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 format, void * pixels, int pitch); +static void D3D11_RenderPresent(SDL_Renderer * renderer); +static void D3D11_DestroyTexture(SDL_Renderer * renderer, + SDL_Texture * texture); +static void D3D11_DestroyRenderer(SDL_Renderer * renderer); + +/* Direct3D 11.1 Internal Functions */ +static HRESULT D3D11_CreateDeviceResources(SDL_Renderer * renderer); +static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer); +static HRESULT D3D11_UpdateForWindowSizeChange(SDL_Renderer * renderer); +static HRESULT D3D11_HandleDeviceLost(SDL_Renderer * renderer); +static void D3D11_ReleaseMainRenderTargetView(SDL_Renderer * renderer); + +SDL_RenderDriver D3D11_RenderDriver = { + D3D11_CreateRenderer, + { + "direct3d11", + ( + SDL_RENDERER_ACCELERATED | + SDL_RENDERER_PRESENTVSYNC | + SDL_RENDERER_TARGETTEXTURE + ), /* flags. see SDL_RendererFlags */ + 4, /* num_texture_formats */ + { /* texture_formats */ + SDL_PIXELFORMAT_ARGB8888, + SDL_PIXELFORMAT_RGB888, + SDL_PIXELFORMAT_YV12, + SDL_PIXELFORMAT_IYUV + }, + 0, /* max_texture_width: will be filled in later */ + 0 /* max_texture_height: will be filled in later */ + } +}; + + +static Uint32 +DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat) { + switch (dxgiFormat) { + case DXGI_FORMAT_B8G8R8A8_UNORM: + return SDL_PIXELFORMAT_ARGB8888; + case DXGI_FORMAT_B8G8R8X8_UNORM: + return SDL_PIXELFORMAT_RGB888; + default: + return SDL_PIXELFORMAT_UNKNOWN; + } +} + +static DXGI_FORMAT +SDLPixelFormatToDXGIFormat(Uint32 sdlFormat) +{ + switch (sdlFormat) { + case SDL_PIXELFORMAT_ARGB8888: + return DXGI_FORMAT_B8G8R8A8_UNORM; + case SDL_PIXELFORMAT_RGB888: + return DXGI_FORMAT_B8G8R8X8_UNORM; + case SDL_PIXELFORMAT_YV12: + case SDL_PIXELFORMAT_IYUV: + return DXGI_FORMAT_R8_UNORM; + default: + return DXGI_FORMAT_UNKNOWN; + } +} + +SDL_Renderer * +D3D11_CreateRenderer(SDL_Window * window, Uint32 flags) +{ + SDL_Renderer *renderer; + D3D11_RenderData *data; + + renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + if (!renderer) { + SDL_OutOfMemory(); + return NULL; + } + + data = (D3D11_RenderData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + SDL_OutOfMemory(); + return NULL; + } + + renderer->WindowEvent = D3D11_WindowEvent; + renderer->CreateTexture = D3D11_CreateTexture; + renderer->UpdateTexture = D3D11_UpdateTexture; + renderer->UpdateTextureYUV = D3D11_UpdateTextureYUV; + renderer->LockTexture = D3D11_LockTexture; + renderer->UnlockTexture = D3D11_UnlockTexture; + renderer->SetRenderTarget = D3D11_SetRenderTarget; + renderer->UpdateViewport = D3D11_UpdateViewport; + renderer->UpdateClipRect = D3D11_UpdateClipRect; + renderer->RenderClear = D3D11_RenderClear; + renderer->RenderDrawPoints = D3D11_RenderDrawPoints; + renderer->RenderDrawLines = D3D11_RenderDrawLines; + renderer->RenderFillRects = D3D11_RenderFillRects; + renderer->RenderCopy = D3D11_RenderCopy; + renderer->RenderCopyEx = D3D11_RenderCopyEx; + renderer->RenderReadPixels = D3D11_RenderReadPixels; + renderer->RenderPresent = D3D11_RenderPresent; + renderer->DestroyTexture = D3D11_DestroyTexture; + renderer->DestroyRenderer = D3D11_DestroyRenderer; + renderer->info = D3D11_RenderDriver.info; + renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); + renderer->driverdata = data; + + if ((flags & SDL_RENDERER_PRESENTVSYNC)) { + renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; + } + + /* HACK: make sure the SDL_Renderer references the SDL_Window data now, in + * order to give init functions access to the underlying window handle: + */ + renderer->window = window; + + /* Initialize Direct3D resources */ + if (FAILED(D3D11_CreateDeviceResources(renderer))) { + D3D11_DestroyRenderer(renderer); + return NULL; + } + if (FAILED(D3D11_CreateWindowSizeDependentResources(renderer))) { + D3D11_DestroyRenderer(renderer); + return NULL; + } + + return renderer; +} + +static void +D3D11_DestroyRenderer(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + + if (data) { + SAFE_RELEASE(data->dxgiFactory); + SAFE_RELEASE(data->dxgiAdapter); + SAFE_RELEASE(data->d3dDevice); + SAFE_RELEASE(data->d3dContext); + SAFE_RELEASE(data->swapChain); + SAFE_RELEASE(data->mainRenderTargetView); + SAFE_RELEASE(data->currentOffscreenRenderTargetView); + SAFE_RELEASE(data->inputLayout); + SAFE_RELEASE(data->vertexBuffer); + SAFE_RELEASE(data->vertexShader); + SAFE_RELEASE(data->colorPixelShader); + SAFE_RELEASE(data->texturePixelShader); + SAFE_RELEASE(data->yuvPixelShader); + SAFE_RELEASE(data->blendModeBlend); + SAFE_RELEASE(data->blendModeAdd); + SAFE_RELEASE(data->blendModeMod); + SAFE_RELEASE(data->nearestPixelSampler); + SAFE_RELEASE(data->linearSampler); + SAFE_RELEASE(data->mainRasterizer); + SAFE_RELEASE(data->clippedRasterizer); + SAFE_RELEASE(data->vertexShaderConstants); + + if (data->hD3D11Mod) { + SDL_UnloadObject(data->hD3D11Mod); + } + if (data->hDXGIMod) { + SDL_UnloadObject(data->hDXGIMod); + } + SDL_free(data); + } + SDL_free(renderer); +} + +static HRESULT +D3D11_CreateBlendMode(SDL_Renderer * renderer, + BOOL enableBlending, + D3D11_BLEND srcBlend, + D3D11_BLEND destBlend, + D3D11_BLEND srcBlendAlpha, + D3D11_BLEND destBlendAlpha, + ID3D11BlendState ** blendStateOutput) +{ + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + HRESULT result = S_OK; + + D3D11_BLEND_DESC blendDesc; + SDL_zero(blendDesc); + blendDesc.AlphaToCoverageEnable = FALSE; + blendDesc.IndependentBlendEnable = FALSE; + blendDesc.RenderTarget[0].BlendEnable = enableBlending; + blendDesc.RenderTarget[0].SrcBlend = srcBlend; + blendDesc.RenderTarget[0].DestBlend = destBlend; + blendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; + blendDesc.RenderTarget[0].SrcBlendAlpha = srcBlendAlpha; + blendDesc.RenderTarget[0].DestBlendAlpha = destBlendAlpha; + blendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; + blendDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + result = ID3D11Device_CreateBlendState(data->d3dDevice, &blendDesc, blendStateOutput); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateBlendState", result); + return result; + } + + return S_OK; +} + +/* Create resources that depend on the device. */ +static HRESULT +D3D11_CreateDeviceResources(SDL_Renderer * renderer) +{ + typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory); + PFN_CREATE_DXGI_FACTORY CreateDXGIFactoryFunc; + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + PFN_D3D11_CREATE_DEVICE D3D11CreateDeviceFunc; + IDXGIAdapter *d3dAdapter = NULL; + ID3D11Device *d3dDevice = NULL; + ID3D11DeviceContext *d3dContext = NULL; + IDXGIDevice1 *dxgiDevice = NULL; + HRESULT result = S_OK; + UINT creationFlags; + const char *hint; + + /* This array defines the set of DirectX hardware feature levels this app will support. + * Note the ordering should be preserved. + * Don't forget to declare your application's minimum required feature level in its + * description. All applications are assumed to support 9.1 unless otherwise stated. + */ + D3D_FEATURE_LEVEL featureLevels[] = + { + D3D_FEATURE_LEVEL_11_1, + D3D_FEATURE_LEVEL_11_0, + D3D_FEATURE_LEVEL_10_1, + D3D_FEATURE_LEVEL_10_0, + D3D_FEATURE_LEVEL_9_3, + D3D_FEATURE_LEVEL_9_2, + D3D_FEATURE_LEVEL_9_1 + }; + + /* Declare how the input layout for SDL's vertex shader will be setup: */ + const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = + { + { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + }; + + D3D11_BUFFER_DESC constantBufferDesc; + D3D11_SAMPLER_DESC samplerDesc; + D3D11_RASTERIZER_DESC rasterDesc; + +#ifdef __WINRT__ + CreateDXGIFactoryFunc = CreateDXGIFactory1; + D3D11CreateDeviceFunc = D3D11CreateDevice; +#else + data->hDXGIMod = SDL_LoadObject("dxgi.dll"); + if (!data->hDXGIMod) { + result = E_FAIL; + goto done; + } + + CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory"); + if (!CreateDXGIFactoryFunc) { + result = E_FAIL; + goto done; + } + + data->hD3D11Mod = SDL_LoadObject("d3d11.dll"); + if (!data->hD3D11Mod) { + result = E_FAIL; + goto done; + } + + D3D11CreateDeviceFunc = (PFN_D3D11_CREATE_DEVICE)SDL_LoadFunction(data->hD3D11Mod, "D3D11CreateDevice"); + if (!D3D11CreateDeviceFunc) { + result = E_FAIL; + goto done; + } +#endif /* __WINRT__ */ + + result = CreateDXGIFactoryFunc(&IID_IDXGIFactory2, &data->dxgiFactory); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", CreateDXGIFactory", result); + goto done; + } + + /* FIXME: Should we use the default adapter? */ + result = IDXGIFactory2_EnumAdapters(data->dxgiFactory, 0, &data->dxgiAdapter); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", D3D11CreateDevice", result); + goto done; + } + + /* This flag adds support for surfaces with a different color channel ordering + * than the API default. It is required for compatibility with Direct2D. + */ + creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; + + /* Make sure Direct3D's debugging feature gets used, if the app requests it. */ + hint = SDL_GetHint(SDL_HINT_RENDER_DIRECT3D11_DEBUG); + if (hint && SDL_atoi(hint) > 0) { + creationFlags |= D3D11_CREATE_DEVICE_DEBUG; + } + + /* Create the Direct3D 11 API device object and a corresponding context. */ + result = D3D11CreateDeviceFunc( + data->dxgiAdapter, + D3D_DRIVER_TYPE_UNKNOWN, + NULL, + creationFlags, /* Set set debug and Direct2D compatibility flags. */ + featureLevels, /* List of feature levels this app can support. */ + SDL_arraysize(featureLevels), + D3D11_SDK_VERSION, /* Always set this to D3D11_SDK_VERSION for Windows Store apps. */ + &d3dDevice, /* Returns the Direct3D device created. */ + &data->featureLevel, /* Returns feature level of device created. */ + &d3dContext /* Returns the device immediate context. */ + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", D3D11CreateDevice", result); + goto done; + } + + result = ID3D11Device_QueryInterface(d3dDevice, &IID_ID3D11Device1, &data->d3dDevice); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device to ID3D11Device1", result); + goto done; + } + + result = ID3D11DeviceContext_QueryInterface(d3dContext, &IID_ID3D11DeviceContext1, &data->d3dContext); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11DeviceContext to ID3D11DeviceContext1", result); + goto done; + } + + result = ID3D11Device_QueryInterface(d3dDevice, &IID_IDXGIDevice1, &dxgiDevice); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device to IDXGIDevice1", result); + goto done; + } + + /* Ensure that DXGI does not queue more than one frame at a time. This both reduces latency and + * ensures that the application will only render after each VSync, minimizing power consumption. + */ + result = IDXGIDevice1_SetMaximumFrameLatency(dxgiDevice, 1); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIDevice1::SetMaximumFrameLatency", result); + goto done; + } + + /* Make note of the maximum texture size + * Max texture sizes are documented on MSDN, at: + * http://msdn.microsoft.com/en-us/library/windows/apps/ff476876.aspx + */ + switch (data->featureLevel) { + case D3D_FEATURE_LEVEL_11_1: + case D3D_FEATURE_LEVEL_11_0: + renderer->info.max_texture_width = renderer->info.max_texture_height = 16384; + break; + + case D3D_FEATURE_LEVEL_10_1: + case D3D_FEATURE_LEVEL_10_0: + renderer->info.max_texture_width = renderer->info.max_texture_height = 8192; + break; + + case D3D_FEATURE_LEVEL_9_3: + renderer->info.max_texture_width = renderer->info.max_texture_height = 4096; + break; + + case D3D_FEATURE_LEVEL_9_2: + case D3D_FEATURE_LEVEL_9_1: + renderer->info.max_texture_width = renderer->info.max_texture_height = 2048; + break; + + default: + SDL_SetError(__FUNCTION__ ", Unexpected feature level: %d", data->featureLevel); + result = E_FAIL; + goto done; + } + + /* Load in SDL's one and only vertex shader: */ + result = ID3D11Device_CreateVertexShader(data->d3dDevice, + D3D11_VertexShader, + sizeof(D3D11_VertexShader), + NULL, + &data->vertexShader + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateVertexShader", result); + goto done; + } + + /* Create an input layout for SDL's vertex shader: */ + result = ID3D11Device_CreateInputLayout(data->d3dDevice, + vertexDesc, + ARRAYSIZE(vertexDesc), + D3D11_VertexShader, + sizeof(D3D11_VertexShader), + &data->inputLayout + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateInputLayout", result); + goto done; + } + + /* Load in SDL's pixel shaders */ + result = ID3D11Device_CreatePixelShader(data->d3dDevice, + D3D11_PixelShader_Colors, + sizeof(D3D11_PixelShader_Colors), + NULL, + &data->colorPixelShader + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreatePixelShader ['color' shader]", result); + goto done; + } + + result = ID3D11Device_CreatePixelShader(data->d3dDevice, + D3D11_PixelShader_Textures, + sizeof(D3D11_PixelShader_Textures), + NULL, + &data->texturePixelShader + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreatePixelShader ['textures' shader]", result); + goto done; + } + + result = ID3D11Device_CreatePixelShader(data->d3dDevice, + D3D11_PixelShader_YUV, + sizeof(D3D11_PixelShader_YUV), + NULL, + &data->yuvPixelShader + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreatePixelShader ['yuv' shader]", result); + goto done; + } + + /* Setup space to hold vertex shader constants: */ + SDL_zero(constantBufferDesc); + constantBufferDesc.ByteWidth = sizeof(VertexShaderConstants); + constantBufferDesc.Usage = D3D11_USAGE_DEFAULT; + constantBufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; + result = ID3D11Device_CreateBuffer(data->d3dDevice, + &constantBufferDesc, + NULL, + &data->vertexShaderConstants + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateBuffer [vertex shader constants]", result); + goto done; + } + + /* Create samplers to use when drawing textures: */ + SDL_zero(samplerDesc); + samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; + samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP; + samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP; + samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; + samplerDesc.MipLODBias = 0.0f; + samplerDesc.MaxAnisotropy = 1; + samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS; + samplerDesc.MinLOD = 0.0f; + samplerDesc.MaxLOD = D3D11_FLOAT32_MAX; + result = ID3D11Device_CreateSamplerState(data->d3dDevice, + &samplerDesc, + &data->nearestPixelSampler + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateSamplerState [nearest-pixel filter]", result); + goto done; + } + + samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; + result = ID3D11Device_CreateSamplerState(data->d3dDevice, + &samplerDesc, + &data->linearSampler + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateSamplerState [linear filter]", result); + goto done; + } + + /* Setup Direct3D rasterizer states */ + SDL_zero(rasterDesc); + rasterDesc.AntialiasedLineEnable = FALSE; + rasterDesc.CullMode = D3D11_CULL_NONE; + rasterDesc.DepthBias = 0; + rasterDesc.DepthBiasClamp = 0.0f; + rasterDesc.DepthClipEnable = TRUE; + rasterDesc.FillMode = D3D11_FILL_SOLID; + rasterDesc.FrontCounterClockwise = FALSE; + rasterDesc.MultisampleEnable = FALSE; + rasterDesc.ScissorEnable = FALSE; + rasterDesc.SlopeScaledDepthBias = 0.0f; + result = ID3D11Device_CreateRasterizerState(data->d3dDevice, &rasterDesc, &data->mainRasterizer); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateRasterizerState [main rasterizer]", result); + goto done; + } + + rasterDesc.ScissorEnable = TRUE; + result = ID3D11Device_CreateRasterizerState(data->d3dDevice, &rasterDesc, &data->clippedRasterizer); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateRasterizerState [clipped rasterizer]", result); + goto done; + } + + /* Create blending states: */ + result = D3D11_CreateBlendMode( + renderer, + TRUE, + D3D11_BLEND_SRC_ALPHA, /* srcBlend */ + D3D11_BLEND_INV_SRC_ALPHA, /* destBlend */ + D3D11_BLEND_ONE, /* srcBlendAlpha */ + D3D11_BLEND_INV_SRC_ALPHA, /* destBlendAlpha */ + &data->blendModeBlend); + if (FAILED(result)) { + /* D3D11_CreateBlendMode will set the SDL error, if it fails */ + goto done; + } + + result = D3D11_CreateBlendMode( + renderer, + TRUE, + D3D11_BLEND_SRC_ALPHA, /* srcBlend */ + D3D11_BLEND_ONE, /* destBlend */ + D3D11_BLEND_ZERO, /* srcBlendAlpha */ + D3D11_BLEND_ONE, /* destBlendAlpha */ + &data->blendModeAdd); + if (FAILED(result)) { + /* D3D11_CreateBlendMode will set the SDL error, if it fails */ + goto done; + } + + result = D3D11_CreateBlendMode( + renderer, + TRUE, + D3D11_BLEND_ZERO, /* srcBlend */ + D3D11_BLEND_SRC_COLOR, /* destBlend */ + D3D11_BLEND_ZERO, /* srcBlendAlpha */ + D3D11_BLEND_ONE, /* destBlendAlpha */ + &data->blendModeMod); + if (FAILED(result)) { + /* D3D11_CreateBlendMode will set the SDL error, if it fails */ + goto done; + } + + /* Setup render state that doesn't change */ + ID3D11DeviceContext_IASetInputLayout(data->d3dContext, data->inputLayout); + ID3D11DeviceContext_VSSetShader(data->d3dContext, data->vertexShader, NULL, 0); + ID3D11DeviceContext_VSSetConstantBuffers(data->d3dContext, 0, 1, &data->vertexShaderConstants); + +done: + SAFE_RELEASE(d3dDevice); + SAFE_RELEASE(d3dContext); + SAFE_RELEASE(dxgiDevice); + return result; +} + +#ifdef __WIN32__ + +static DXGI_MODE_ROTATION +D3D11_GetCurrentRotation() +{ + /* FIXME */ + return DXGI_MODE_ROTATION_IDENTITY; +} + +#endif /* __WIN32__ */ + +static BOOL +D3D11_IsDisplayRotated90Degrees(DXGI_MODE_ROTATION rotation) +{ + switch (rotation) { + case DXGI_MODE_ROTATION_ROTATE90: + case DXGI_MODE_ROTATION_ROTATE270: + return TRUE; + default: + return FALSE; + } +} + +static int +D3D11_GetViewportAlignedD3DRect(SDL_Renderer * renderer, const SDL_Rect * sdlRect, D3D11_RECT * outRect) +{ + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + switch (data->rotation) { + case DXGI_MODE_ROTATION_IDENTITY: + outRect->left = sdlRect->x; + outRect->right = sdlRect->x + sdlRect->w; + outRect->top = sdlRect->y; + outRect->bottom = sdlRect->y + sdlRect->h; + break; + case DXGI_MODE_ROTATION_ROTATE270: + outRect->left = sdlRect->y; + outRect->right = sdlRect->y + sdlRect->h; + outRect->top = renderer->viewport.w - sdlRect->x - sdlRect->w; + outRect->bottom = renderer->viewport.w - sdlRect->x; + break; + case DXGI_MODE_ROTATION_ROTATE180: + outRect->left = renderer->viewport.w - sdlRect->x - sdlRect->w; + outRect->right = renderer->viewport.w - sdlRect->x; + outRect->top = renderer->viewport.h - sdlRect->y - sdlRect->h; + outRect->bottom = renderer->viewport.h - sdlRect->y; + break; + case DXGI_MODE_ROTATION_ROTATE90: + outRect->left = renderer->viewport.h - sdlRect->y - sdlRect->h; + outRect->right = renderer->viewport.h - sdlRect->y; + outRect->top = sdlRect->x; + outRect->bottom = sdlRect->x + sdlRect->h; + break; + default: + return SDL_SetError("The physical display is in an unknown or unsupported rotation"); + } + return 0; +} + +static HRESULT +D3D11_CreateSwapChain(SDL_Renderer * renderer, int w, int h) +{ + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; +#ifdef __WINRT__ + IUnknown *coreWindow = D3D11_GetCoreWindowFromSDLRenderer(renderer); + const BOOL usingXAML = (coreWindow == NULL); +#else + IUnknown *coreWindow = NULL; + const BOOL usingXAML = FALSE; +#endif + HRESULT result = S_OK; + + /* Create a swap chain using the same adapter as the existing Direct3D device. */ + DXGI_SWAP_CHAIN_DESC1 swapChainDesc; + SDL_zero(swapChainDesc); + swapChainDesc.Width = w; + swapChainDesc.Height = h; + swapChainDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; /* This is the most common swap chain format. */ + swapChainDesc.Stereo = FALSE; + swapChainDesc.SampleDesc.Count = 1; /* Don't use multi-sampling. */ + swapChainDesc.SampleDesc.Quality = 0; + swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + swapChainDesc.BufferCount = 2; /* Use double-buffering to minimize latency. */ +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + swapChainDesc.Scaling = DXGI_SCALING_STRETCH; /* On phone, only stretch and aspect-ratio stretch scaling are allowed. */ + swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; /* On phone, no swap effects are supported. */ +#else + if (usingXAML) { + swapChainDesc.Scaling = DXGI_SCALING_STRETCH; + } else { + swapChainDesc.Scaling = DXGI_SCALING_NONE; + } + swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL; /* All Windows Store apps must use this SwapEffect. */ +#endif + swapChainDesc.Flags = 0; + + if (coreWindow) { + result = IDXGIFactory2_CreateSwapChainForCoreWindow(data->dxgiFactory, + (IUnknown *)data->d3dDevice, + coreWindow, + &swapChainDesc, + NULL, /* Allow on all displays. */ + &data->swapChain + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIFactory2::CreateSwapChainForCoreWindow", result); + goto done; + } + } else if (usingXAML) { + result = IDXGIFactory2_CreateSwapChainForComposition(data->dxgiFactory, + (IUnknown *)data->d3dDevice, + &swapChainDesc, + NULL, + &data->swapChain); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIFactory2::CreateSwapChainForComposition", result); + goto done; + } + +#if WINAPI_FAMILY == WINAPI_FAMILY_APP + result = ISwapChainBackgroundPanelNative_SetSwapChain(WINRT_GlobalSwapChainBackgroundPanelNative, (IDXGISwapChain *) data->swapChain); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ISwapChainBackgroundPanelNative::SetSwapChain", result); + goto done; + } +#else + SDL_SetError(__FUNCTION__ ", XAML support is not yet available for Windows Phone"); + result = E_FAIL; + goto done; +#endif + } else { +#ifdef __WIN32__ + SDL_SysWMinfo windowinfo; + SDL_VERSION(&windowinfo.version); + SDL_GetWindowWMInfo(renderer->window, &windowinfo); + + result = IDXGIFactory2_CreateSwapChainForHwnd(data->dxgiFactory, + (IUnknown *)data->d3dDevice, + windowinfo.info.win.window, + &swapChainDesc, + NULL, + NULL, /* Allow on all displays. */ + &data->swapChain + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIFactory2::CreateSwapChainForHwnd", result); + goto done; + } +#else + SDL_SetError(__FUNCTION__", Unable to find something to attach a swap chain to"); + goto done; +#endif /* ifdef __WIN32__ / else */ + } + data->swapEffect = swapChainDesc.SwapEffect; + +done: + SAFE_RELEASE(coreWindow); + return result; +} + + +/* Initialize all resources that change when the window's size changes. */ +static HRESULT +D3D11_CreateWindowSizeDependentResources(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; + ID3D11Texture2D *backBuffer = NULL; + HRESULT result = S_OK; + int w, h; + + /* Release the previous render target view */ + D3D11_ReleaseMainRenderTargetView(renderer); + + /* The width and height of the swap chain must be based on the display's + * non-rotated size. + */ + SDL_GetWindowSize(renderer->window, &w, &h); + data->rotation = D3D11_GetCurrentRotation(); + if (D3D11_IsDisplayRotated90Degrees(data->rotation)) { + int tmp = w; + w = h; + h = tmp; + } + + if (data->swapChain) { + /* IDXGISwapChain::ResizeBuffers is not available on Windows Phone 8. */ +#if !defined(__WINRT__) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) + /* If the swap chain already exists, resize it. */ + result = IDXGISwapChain_ResizeBuffers(data->swapChain, + 0, + w, h, + DXGI_FORMAT_UNKNOWN, + 0 + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGISwapChain::ResizeBuffers", result); + goto done; + } +#endif + } else { + result = D3D11_CreateSwapChain(renderer, w, h); + if (FAILED(result)) { + goto done; + } + } + +#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP + /* Set the proper rotation for the swap chain, and generate the + * 3D matrix transformation for rendering to the rotated swap chain. + * + * To note, the call for this, IDXGISwapChain1::SetRotation, is not necessary + * on Windows Phone, nor is it supported there. It's only needed in Windows 8/RT. + */ + if (data->swapEffect == DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL) { + result = IDXGISwapChain1_SetRotation(data->swapChain, data->rotation); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGISwapChain1::SetRotation", result); + goto done; + } + } +#endif + + result = IDXGISwapChain_GetBuffer(data->swapChain, + 0, + &IID_ID3D11Texture2D, + &backBuffer + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGISwapChain::GetBuffer [back-buffer]", result); + goto done; + } + + /* Create a render target view of the swap chain back buffer. */ + result = ID3D11Device_CreateRenderTargetView(data->d3dDevice, + (ID3D11Resource *)backBuffer, + NULL, + &data->mainRenderTargetView + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device::CreateRenderTargetView", result); + goto done; + } + + if (D3D11_UpdateViewport(renderer) != 0) { + /* D3D11_UpdateViewport will set the SDL error if it fails. */ + result = E_FAIL; + goto done; + } + +done: + SAFE_RELEASE(backBuffer); + return result; +} + +/* This method is called when the window's size changes. */ +static HRESULT +D3D11_UpdateForWindowSizeChange(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; + return D3D11_CreateWindowSizeDependentResources(renderer); +} + +HRESULT +D3D11_HandleDeviceLost(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + HRESULT result = S_OK; + + /* FIXME: Need to release all resources - all textures are invalid! */ + + result = D3D11_CreateDeviceResources(renderer); + if (FAILED(result)) { + /* D3D11_CreateDeviceResources will set the SDL error */ + return result; + } + + result = D3D11_UpdateForWindowSizeChange(renderer); + if (FAILED(result)) { + /* D3D11_UpdateForWindowSizeChange will set the SDL error */ + return result; + } + + return S_OK; +} + +static void +D3D11_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +{ + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { + D3D11_UpdateForWindowSizeChange(renderer); + } +} + +static D3D11_FILTER +GetScaleQuality(void) +{ + const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY); + if (!hint || *hint == '0' || SDL_strcasecmp(hint, "nearest") == 0) { + return D3D11_FILTER_MIN_MAG_MIP_POINT; + } else /* if (*hint == '1' || SDL_strcasecmp(hint, "linear") == 0) */ { + return D3D11_FILTER_MIN_MAG_MIP_LINEAR; + } +} + +static int +D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_TextureData *textureData; + HRESULT result; + DXGI_FORMAT textureFormat = SDLPixelFormatToDXGIFormat(texture->format); + D3D11_TEXTURE2D_DESC textureDesc; + D3D11_SHADER_RESOURCE_VIEW_DESC resourceViewDesc; + + if (textureFormat == SDL_PIXELFORMAT_UNKNOWN) { + return SDL_SetError("%s, An unsupported SDL pixel format (0x%x) was specified", + __FUNCTION__, texture->format); + } + + textureData = (D3D11_TextureData*) SDL_calloc(1, sizeof(*textureData)); + if (!textureData) { + SDL_OutOfMemory(); + return -1; + } + textureData->scaleMode = GetScaleQuality(); + + texture->driverdata = textureData; + + SDL_zero(textureDesc); + textureDesc.Width = texture->w; + textureDesc.Height = texture->h; + textureDesc.MipLevels = 1; + textureDesc.ArraySize = 1; + textureDesc.Format = textureFormat; + textureDesc.SampleDesc.Count = 1; + textureDesc.SampleDesc.Quality = 0; + textureDesc.MiscFlags = 0; + + if (texture->access == SDL_TEXTUREACCESS_STREAMING) { + textureDesc.Usage = D3D11_USAGE_DYNAMIC; + textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + } else { + textureDesc.Usage = D3D11_USAGE_DEFAULT; + textureDesc.CPUAccessFlags = 0; + } + + if (texture->access == SDL_TEXTUREACCESS_TARGET) { + textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET; + } else { + textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + } + + result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, + &textureDesc, + NULL, + &textureData->mainTexture + ); + if (FAILED(result)) { + D3D11_DestroyTexture(renderer, texture); + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateTexture2D", result); + return -1; + } + + if (texture->format == SDL_PIXELFORMAT_YV12 || + texture->format == SDL_PIXELFORMAT_IYUV) { + textureData->yuv = SDL_TRUE; + + textureDesc.Width /= 2; + textureDesc.Height /= 2; + + result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, + &textureDesc, + NULL, + &textureData->mainTextureU + ); + if (FAILED(result)) { + D3D11_DestroyTexture(renderer, texture); + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateTexture2D", result); + return -1; + } + + result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, + &textureDesc, + NULL, + &textureData->mainTextureV + ); + if (FAILED(result)) { + D3D11_DestroyTexture(renderer, texture); + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateTexture2D", result); + return -1; + } + } + + resourceViewDesc.Format = textureDesc.Format; + resourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; + resourceViewDesc.Texture2D.MostDetailedMip = 0; + resourceViewDesc.Texture2D.MipLevels = textureDesc.MipLevels; + result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice, + (ID3D11Resource *)textureData->mainTexture, + &resourceViewDesc, + &textureData->mainTextureResourceView + ); + if (FAILED(result)) { + D3D11_DestroyTexture(renderer, texture); + WIN_SetErrorFromHRESULT(__FUNCTION__ "ID3D11Device1::CreateShaderResourceView", result); + return -1; + } + + if (textureData->yuv) { + result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice, + (ID3D11Resource *)textureData->mainTextureU, + &resourceViewDesc, + &textureData->mainTextureResourceViewU + ); + if (FAILED(result)) { + D3D11_DestroyTexture(renderer, texture); + WIN_SetErrorFromHRESULT(__FUNCTION__ "ID3D11Device1::CreateShaderResourceView", result); + return -1; + } + result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice, + (ID3D11Resource *)textureData->mainTextureV, + &resourceViewDesc, + &textureData->mainTextureResourceViewV + ); + if (FAILED(result)) { + D3D11_DestroyTexture(renderer, texture); + WIN_SetErrorFromHRESULT(__FUNCTION__ "ID3D11Device1::CreateShaderResourceView", result); + return -1; + } + } + + if (texture->access & SDL_TEXTUREACCESS_TARGET) { + D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc; + renderTargetViewDesc.Format = textureDesc.Format; + renderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; + renderTargetViewDesc.Texture2D.MipSlice = 0; + + result = ID3D11Device_CreateRenderTargetView(rendererData->d3dDevice, + (ID3D11Resource *)textureData->mainTexture, + &renderTargetViewDesc, + &textureData->mainTextureRenderTargetView); + if (FAILED(result)) { + D3D11_DestroyTexture(renderer, texture); + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateRenderTargetView", result); + return -1; + } + } + + return 0; +} + +static void +D3D11_DestroyTexture(SDL_Renderer * renderer, + SDL_Texture * texture) +{ + D3D11_TextureData *data = (D3D11_TextureData *)texture->driverdata; + + if (!data) { + return; + } + + SAFE_RELEASE(data->mainTexture); + SAFE_RELEASE(data->mainTextureResourceView); + SAFE_RELEASE(data->mainTextureRenderTargetView); + SAFE_RELEASE(data->stagingTexture); + SAFE_RELEASE(data->mainTextureU); + SAFE_RELEASE(data->mainTextureResourceViewU); + SAFE_RELEASE(data->mainTextureV); + SAFE_RELEASE(data->mainTextureResourceViewV); + SDL_free(data->pixels); + SDL_free(data); + texture->driverdata = NULL; +} + +static int +D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *texture, Uint32 format, int x, int y, int w, int h, const void *pixels, int pitch) +{ + ID3D11Texture2D *stagingTexture; + const Uint8 *src; + Uint8 *dst; + int row; + UINT length; + HRESULT result; + D3D11_TEXTURE2D_DESC stagingTextureDesc; + D3D11_MAPPED_SUBRESOURCE textureMemory; + + /* Create a 'staging' texture, which will be used to write to a portion of the main texture. */ + ID3D11Texture2D_GetDesc(texture, &stagingTextureDesc); + stagingTextureDesc.Width = w; + stagingTextureDesc.Height = h; + stagingTextureDesc.BindFlags = 0; + stagingTextureDesc.MiscFlags = 0; + stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + stagingTextureDesc.Usage = D3D11_USAGE_STAGING; + result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, + &stagingTextureDesc, + NULL, + &stagingTexture); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateTexture2D [create staging texture]", result); + return -1; + } + + /* Get a write-only pointer to data in the staging texture: */ + result = ID3D11DeviceContext_Map(rendererData->d3dContext, + (ID3D11Resource *)stagingTexture, + 0, + D3D11_MAP_WRITE, + 0, + &textureMemory + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11DeviceContext1::Map [map staging texture]", result); + SAFE_RELEASE(stagingTexture); + return -1; + } + + src = (const Uint8 *)pixels; + dst = textureMemory.pData; + length = w * SDL_BYTESPERPIXEL(format); + if (length == pitch && length == textureMemory.RowPitch) { + SDL_memcpy(dst, src, length*h); + } else { + if (length > (UINT)pitch) { + length = pitch; + } + if (length > textureMemory.RowPitch) { + length = textureMemory.RowPitch; + } + for (row = 0; row < h; ++row) { + SDL_memcpy(dst, src, length); + src += pitch; + dst += textureMemory.RowPitch; + } + } + + /* Commit the pixel buffer's changes back to the staging texture: */ + ID3D11DeviceContext_Unmap(rendererData->d3dContext, + (ID3D11Resource *)stagingTexture, + 0); + + /* Copy the staging texture's contents back to the texture: */ + ID3D11DeviceContext_CopySubresourceRegion(rendererData->d3dContext, + (ID3D11Resource *)texture, + 0, + x, + y, + 0, + (ID3D11Resource *)stagingTexture, + 0, + NULL); + + SAFE_RELEASE(stagingTexture); + + return 0; +} + +static int +D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void * srcPixels, + int srcPitch) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; + D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; + + if (!textureData) { + SDL_SetError("Texture is not currently available"); + return -1; + } + + if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, texture->format, rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch) < 0) { + return -1; + } + + if (textureData->yuv) { + /* Skip to the correct offset into the next texture */ + srcPixels = (const void*)((const Uint8*)srcPixels + rect->h * srcPitch); + + if (D3D11_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureV : textureData->mainTextureU, texture->format, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, srcPixels, srcPitch / 2) < 0) { + return -1; + } + + /* Skip to the correct offset into the next texture */ + srcPixels = (const void*)((const Uint8*)srcPixels + (rect->h * srcPitch) / 4); + if (D3D11_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureU : textureData->mainTextureV, texture->format, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, srcPixels, srcPitch / 2) < 0) { + return -1; + } + } + return 0; +} + +static int +D3D11_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; + D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; + + if (!textureData) { + SDL_SetError("Texture is not currently available"); + return -1; + } + + if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, texture->format, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) { + return -1; + } + if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureU, texture->format, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Uplane, Upitch) < 0) { + return -1; + } + if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureV, texture->format, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Vplane, Vpitch) < 0) { + return -1; + } + return 0; +} + +static int +D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata; + HRESULT result = S_OK; + D3D11_TEXTURE2D_DESC stagingTextureDesc; + D3D11_MAPPED_SUBRESOURCE textureMemory; + + if (!textureData) { + SDL_SetError("Texture is not currently available"); + return -1; + } + + if (textureData->yuv) { + /* It's more efficient to upload directly... */ + if (!textureData->pixels) { + textureData->pitch = texture->w; + textureData->pixels = (Uint8 *)SDL_malloc((texture->h * textureData->pitch * 3) / 2); + if (!textureData->pixels) { + return SDL_OutOfMemory(); + } + } + textureData->locked_rect = *rect; + *pixels = + (void *)((Uint8 *)textureData->pixels + rect->y * textureData->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); + *pitch = textureData->pitch; + return 0; + } + + if (textureData->stagingTexture) { + return SDL_SetError("texture is already locked"); + } + + /* Create a 'staging' texture, which will be used to write to a portion + * of the main texture. This is necessary, as Direct3D 11.1 does not + * have the ability to write a CPU-bound pixel buffer to a rectangular + * subrect of a texture. Direct3D 11.1 can, however, write a pixel + * buffer to an entire texture, hence the use of a staging texture. + * + * TODO, WinRT: consider avoiding the use of a staging texture in D3D11_LockTexture if/when the entire texture is being updated + */ + ID3D11Texture2D_GetDesc(textureData->mainTexture, &stagingTextureDesc); + stagingTextureDesc.Width = rect->w; + stagingTextureDesc.Height = rect->h; + stagingTextureDesc.BindFlags = 0; + stagingTextureDesc.MiscFlags = 0; + stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + stagingTextureDesc.Usage = D3D11_USAGE_STAGING; + result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice, + &stagingTextureDesc, + NULL, + &textureData->stagingTexture); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateTexture2D [create staging texture]", result); + return -1; + } + + /* Get a write-only pointer to data in the staging texture: */ + result = ID3D11DeviceContext_Map(rendererData->d3dContext, + (ID3D11Resource *)textureData->stagingTexture, + 0, + D3D11_MAP_WRITE, + 0, + &textureMemory + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11DeviceContext1::Map [map staging texture]", result); + SAFE_RELEASE(textureData->stagingTexture); + return -1; + } + + /* Make note of where the staging texture will be written to + * (on a call to SDL_UnlockTexture): + */ + textureData->lockedTexturePositionX = rect->x; + textureData->lockedTexturePositionY = rect->y; + + /* Make sure the caller has information on the texture's pixel buffer, + * then return: + */ + *pixels = textureMemory.pData; + *pitch = textureMemory.RowPitch; + return 0; +} + +static void +D3D11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata; + + if (!textureData) { + return; + } + + if (textureData->yuv) { + const SDL_Rect *rect = &textureData->locked_rect; + void *pixels = + (void *) ((Uint8 *) textureData->pixels + rect->y * textureData->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); + D3D11_UpdateTexture(renderer, texture, rect, pixels, textureData->pitch); + return; + } + + /* Commit the pixel buffer's changes back to the staging texture: */ + ID3D11DeviceContext_Unmap(rendererData->d3dContext, + (ID3D11Resource *)textureData->stagingTexture, + 0); + + /* Copy the staging texture's contents back to the main texture: */ + ID3D11DeviceContext_CopySubresourceRegion(rendererData->d3dContext, + (ID3D11Resource *)textureData->mainTexture, + 0, + textureData->lockedTexturePositionX, + textureData->lockedTexturePositionY, + 0, + (ID3D11Resource *)textureData->stagingTexture, + 0, + NULL); + + SAFE_RELEASE(textureData->stagingTexture); +} + +static int +D3D11_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_TextureData *textureData = NULL; + + if (texture == NULL) { + rendererData->currentOffscreenRenderTargetView = NULL; + return 0; + } + + textureData = (D3D11_TextureData *) texture->driverdata; + + if (!textureData->mainTextureRenderTargetView) { + return SDL_SetError("specified texture is not a render target"); + } + + rendererData->currentOffscreenRenderTargetView = textureData->mainTextureRenderTargetView; + + return 0; +} + +static void +D3D11_SetModelMatrix(SDL_Renderer *renderer, const Float4X4 *matrix) +{ + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; + + if (matrix) { + data->vertexShaderConstantsData.model = *matrix; + } else { + data->vertexShaderConstantsData.model = MatrixIdentity(); + } + + ID3D11DeviceContext_UpdateSubresource(data->d3dContext, + (ID3D11Resource *)data->vertexShaderConstants, + 0, + NULL, + &data->vertexShaderConstantsData, + 0, + 0 + ); +} + +static int +D3D11_UpdateViewport(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + Float4X4 projection; + Float4X4 view; + SDL_FRect orientationAlignedViewport; + BOOL swapDimensions; + D3D11_VIEWPORT viewport; + + if (renderer->viewport.w == 0 || renderer->viewport.h == 0) { + /* If the viewport is empty, assume that it is because + * SDL_CreateRenderer is calling it, and will call it again later + * with a non-empty viewport. + */ + return 0; + } + + /* Make sure the SDL viewport gets rotated to that of the physical display's rotation. + * Keep in mind here that the Y-axis will be been inverted (from Direct3D's + * default coordinate system) so rotations will be done in the opposite + * direction of the DXGI_MODE_ROTATION enumeration. + */ + switch (data->rotation) { + case DXGI_MODE_ROTATION_IDENTITY: + projection = MatrixIdentity(); + break; + case DXGI_MODE_ROTATION_ROTATE270: + projection = MatrixRotationZ(SDL_static_cast(float, M_PI * 0.5f)); + break; + case DXGI_MODE_ROTATION_ROTATE180: + projection = MatrixRotationZ(SDL_static_cast(float, M_PI)); + break; + case DXGI_MODE_ROTATION_ROTATE90: + projection = MatrixRotationZ(SDL_static_cast(float, -M_PI * 0.5f)); + break; + default: + return SDL_SetError("An unknown DisplayOrientation is being used"); + } + + /* Update the view matrix */ + view.m[0][0] = 2.0f / renderer->viewport.w; + view.m[0][1] = 0.0f; + view.m[0][2] = 0.0f; + view.m[0][3] = 0.0f; + view.m[1][0] = 0.0f; + view.m[1][1] = -2.0f / renderer->viewport.h; + view.m[1][2] = 0.0f; + view.m[1][3] = 0.0f; + view.m[2][0] = 0.0f; + view.m[2][1] = 0.0f; + view.m[2][2] = 1.0f; + view.m[2][3] = 0.0f; + view.m[3][0] = -1.0f; + view.m[3][1] = 1.0f; + view.m[3][2] = 0.0f; + view.m[3][3] = 1.0f; + + /* Combine the projection + view matrix together now, as both only get + * set here (as of this writing, on Dec 26, 2013). When done, store it + * for eventual transfer to the GPU. + */ + data->vertexShaderConstantsData.projectionAndView = MatrixMultiply( + view, + projection); + + /* Reset the model matrix */ + D3D11_SetModelMatrix(renderer, NULL); + + /* Update the Direct3D viewport, which seems to be aligned to the + * swap buffer's coordinate space, which is always in either + * a landscape mode, for all Windows 8/RT devices, or a portrait mode, + * for Windows Phone devices. + */ + swapDimensions = D3D11_IsDisplayRotated90Degrees(data->rotation); + if (swapDimensions) { + orientationAlignedViewport.x = (float) renderer->viewport.y; + orientationAlignedViewport.y = (float) renderer->viewport.x; + orientationAlignedViewport.w = (float) renderer->viewport.h; + orientationAlignedViewport.h = (float) renderer->viewport.w; + } else { + orientationAlignedViewport.x = (float) renderer->viewport.x; + orientationAlignedViewport.y = (float) renderer->viewport.y; + orientationAlignedViewport.w = (float) renderer->viewport.w; + orientationAlignedViewport.h = (float) renderer->viewport.h; + } + /* TODO, WinRT: get custom viewports working with non-Landscape modes (Portrait, PortraitFlipped, and LandscapeFlipped) */ + + viewport.TopLeftX = orientationAlignedViewport.x; + viewport.TopLeftY = orientationAlignedViewport.y; + viewport.Width = orientationAlignedViewport.w; + viewport.Height = orientationAlignedViewport.h; + viewport.MinDepth = 0.0f; + viewport.MaxDepth = 1.0f; + ID3D11DeviceContext_RSSetViewports(data->d3dContext, 1, &viewport); + + return 0; +} + +static int +D3D11_UpdateClipRect(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + const SDL_Rect *rect = &renderer->clip_rect; + + if (SDL_RectEmpty(rect)) { + ID3D11DeviceContext_RSSetScissorRects(data->d3dContext, 0, NULL); + } else { + D3D11_RECT scissorRect; + if (D3D11_GetViewportAlignedD3DRect(renderer, rect, &scissorRect) != 0) { + /* D3D11_GetViewportAlignedD3DRect will have set the SDL error */ + return -1; + } + ID3D11DeviceContext_RSSetScissorRects(data->d3dContext, 1, &scissorRect); + } + + return 0; +} + +static void +D3D11_ReleaseMainRenderTargetView(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; + ID3D11DeviceContext_OMSetRenderTargets(data->d3dContext, 0, NULL, NULL); + SAFE_RELEASE(data->mainRenderTargetView); +} + +static ID3D11RenderTargetView * +D3D11_GetCurrentRenderTargetView(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + if (data->currentOffscreenRenderTargetView) { + return data->currentOffscreenRenderTargetView; + } else { + return data->mainRenderTargetView; + } +} + +static int +D3D11_RenderClear(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + const float colorRGBA[] = { + (renderer->r / 255.0f), + (renderer->g / 255.0f), + (renderer->b / 255.0f), + (renderer->a / 255.0f) + }; + ID3D11DeviceContext_ClearRenderTargetView(data->d3dContext, + D3D11_GetCurrentRenderTargetView(renderer), + colorRGBA + ); + return 0; +} + +static int +D3D11_UpdateVertexBuffer(SDL_Renderer *renderer, + const void * vertexData, size_t dataSizeInBytes) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_BUFFER_DESC vertexBufferDesc; + HRESULT result = S_OK; + D3D11_SUBRESOURCE_DATA vertexBufferData; + const UINT stride = sizeof(VertexPositionColor); + const UINT offset = 0; + + if (rendererData->vertexBuffer) { + ID3D11Buffer_GetDesc(rendererData->vertexBuffer, &vertexBufferDesc); + } else { + SDL_zero(vertexBufferDesc); + } + + if (rendererData->vertexBuffer && vertexBufferDesc.ByteWidth >= dataSizeInBytes) { + D3D11_MAPPED_SUBRESOURCE mappedResource; + result = ID3D11DeviceContext_Map(rendererData->d3dContext, + (ID3D11Resource *)rendererData->vertexBuffer, + 0, + D3D11_MAP_WRITE_DISCARD, + 0, + &mappedResource + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11DeviceContext1::Map [vertex buffer]", result); + return -1; + } + SDL_memcpy(mappedResource.pData, vertexData, dataSizeInBytes); + ID3D11DeviceContext_Unmap(rendererData->d3dContext, (ID3D11Resource *)rendererData->vertexBuffer, 0); + } else { + SAFE_RELEASE(rendererData->vertexBuffer); + + vertexBufferDesc.ByteWidth = dataSizeInBytes; + vertexBufferDesc.Usage = D3D11_USAGE_DYNAMIC; + vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; + vertexBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; + + SDL_zero(vertexBufferData); + vertexBufferData.pSysMem = vertexData; + vertexBufferData.SysMemPitch = 0; + vertexBufferData.SysMemSlicePitch = 0; + + result = ID3D11Device_CreateBuffer(rendererData->d3dDevice, + &vertexBufferDesc, + &vertexBufferData, + &rendererData->vertexBuffer + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateBuffer [vertex buffer]", result); + return -1; + } + + ID3D11DeviceContext_IASetVertexBuffers(rendererData->d3dContext, + 0, + 1, + &rendererData->vertexBuffer, + &stride, + &offset + ); + } + + return 0; +} + +static void +D3D11_RenderStartDrawOp(SDL_Renderer * renderer) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; + ID3D11RasterizerState *rasterizerState; + ID3D11RenderTargetView *renderTargetView = D3D11_GetCurrentRenderTargetView(renderer); + if (renderTargetView != rendererData->currentRenderTargetView) { + ID3D11DeviceContext_OMSetRenderTargets(rendererData->d3dContext, + 1, + &renderTargetView, + NULL + ); + rendererData->currentRenderTargetView = renderTargetView; + } + + if (SDL_RectEmpty(&renderer->clip_rect)) { + rasterizerState = rendererData->mainRasterizer; + } else { + rasterizerState = rendererData->clippedRasterizer; + } + if (rasterizerState != rendererData->currentRasterizerState) { + ID3D11DeviceContext_RSSetState(rendererData->d3dContext, rasterizerState); + rendererData->currentRasterizerState = rasterizerState; + } +} + +static void +D3D11_RenderSetBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; + ID3D11BlendState *blendState = NULL; + switch (blendMode) { + case SDL_BLENDMODE_BLEND: + blendState = rendererData->blendModeBlend; + break; + case SDL_BLENDMODE_ADD: + blendState = rendererData->blendModeAdd; + break; + case SDL_BLENDMODE_MOD: + blendState = rendererData->blendModeMod; + break; + case SDL_BLENDMODE_NONE: + blendState = NULL; + break; + } + if (blendState != rendererData->currentBlendState) { + ID3D11DeviceContext_OMSetBlendState(rendererData->d3dContext, blendState, 0, 0xFFFFFFFF); + rendererData->currentBlendState = blendState; + } +} + +static void +D3D11_SetPixelShader(SDL_Renderer * renderer, + ID3D11PixelShader * shader, + int numShaderResources, + ID3D11ShaderResourceView ** shaderResources, + ID3D11SamplerState * sampler) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + ID3D11ShaderResourceView *shaderResource; + if (shader != rendererData->currentShader) { + ID3D11DeviceContext_PSSetShader(rendererData->d3dContext, shader, NULL, 0); + rendererData->currentShader = shader; + } + if (numShaderResources > 0) { + shaderResource = shaderResources[0]; + } else { + shaderResource = NULL; + } + if (shaderResource != rendererData->currentShaderResource) { + ID3D11DeviceContext_PSSetShaderResources(rendererData->d3dContext, 0, numShaderResources, shaderResources); + rendererData->currentShaderResource = shaderResource; + } + if (sampler != rendererData->currentSampler) { + ID3D11DeviceContext_PSSetSamplers(rendererData->d3dContext, 0, 1, &sampler); + rendererData->currentSampler = sampler; + } +} + +static void +D3D11_RenderFinishDrawOp(SDL_Renderer * renderer, + D3D11_PRIMITIVE_TOPOLOGY primitiveTopology, + UINT vertexCount) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + + ID3D11DeviceContext_IASetPrimitiveTopology(rendererData->d3dContext, primitiveTopology); + ID3D11DeviceContext_Draw(rendererData->d3dContext, vertexCount, 0); +} + +static int +D3D11_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_FPoint * points, int count) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + float r, g, b, a; + VertexPositionColor *vertices; + int i; + + r = (float)(renderer->r / 255.0f); + g = (float)(renderer->g / 255.0f); + b = (float)(renderer->b / 255.0f); + a = (float)(renderer->a / 255.0f); + + vertices = SDL_stack_alloc(VertexPositionColor, count); + for (i = 0; i < min(count, 128); ++i) { + const VertexPositionColor v = { { points[i].x, points[i].y, 0.0f }, { 0.0f, 0.0f }, { r, g, b, a } }; + vertices[i] = v; + } + + D3D11_RenderStartDrawOp(renderer); + D3D11_RenderSetBlendMode(renderer, renderer->blendMode); + if (D3D11_UpdateVertexBuffer(renderer, vertices, (unsigned int)count * sizeof(VertexPositionColor)) != 0) { + SDL_stack_free(vertices); + return -1; + } + + D3D11_SetPixelShader( + renderer, + rendererData->colorPixelShader, + 0, + NULL, + NULL); + + D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_POINTLIST, count); + SDL_stack_free(vertices); + return 0; +} + +static int +D3D11_RenderDrawLines(SDL_Renderer * renderer, + const SDL_FPoint * points, int count) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + float r, g, b, a; + VertexPositionColor *vertices; + int i; + + r = (float)(renderer->r / 255.0f); + g = (float)(renderer->g / 255.0f); + b = (float)(renderer->b / 255.0f); + a = (float)(renderer->a / 255.0f); + + vertices = SDL_stack_alloc(VertexPositionColor, count); + for (i = 0; i < count; ++i) { + const VertexPositionColor v = { { points[i].x, points[i].y, 0.0f }, { 0.0f, 0.0f }, { r, g, b, a } }; + vertices[i] = v; + } + + D3D11_RenderStartDrawOp(renderer); + D3D11_RenderSetBlendMode(renderer, renderer->blendMode); + if (D3D11_UpdateVertexBuffer(renderer, vertices, (unsigned int)count * sizeof(VertexPositionColor)) != 0) { + SDL_stack_free(vertices); + return -1; + } + + D3D11_SetPixelShader( + renderer, + rendererData->colorPixelShader, + 0, + NULL, + NULL); + + D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP, count); + SDL_stack_free(vertices); + return 0; +} + +static int +D3D11_RenderFillRects(SDL_Renderer * renderer, + const SDL_FRect * rects, int count) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + float r, g, b, a; + int i; + + r = (float)(renderer->r / 255.0f); + g = (float)(renderer->g / 255.0f); + b = (float)(renderer->b / 255.0f); + a = (float)(renderer->a / 255.0f); + + for (i = 0; i < count; ++i) { + VertexPositionColor vertices[] = { + { { rects[i].x, rects[i].y, 0.0f }, { 0.0f, 0.0f}, {r, g, b, a} }, + { { rects[i].x, rects[i].y + rects[i].h, 0.0f }, { 0.0f, 0.0f }, { r, g, b, a } }, + { { rects[i].x + rects[i].w, rects[i].y, 0.0f }, { 0.0f, 0.0f }, { r, g, b, a } }, + { { rects[i].x + rects[i].w, rects[i].y + rects[i].h, 0.0f }, { 0.0f, 0.0f }, { r, g, b, a } }, + }; + + D3D11_RenderStartDrawOp(renderer); + D3D11_RenderSetBlendMode(renderer, renderer->blendMode); + if (D3D11_UpdateVertexBuffer(renderer, vertices, sizeof(vertices)) != 0) { + return -1; + } + + D3D11_SetPixelShader( + renderer, + rendererData->colorPixelShader, + 0, + NULL, + NULL); + + D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, SDL_arraysize(vertices)); + } + + return 0; +} + +static ID3D11SamplerState * +D3D11_RenderGetSampler(SDL_Renderer * renderer, SDL_Texture * texture) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata; + + switch (textureData->scaleMode) { + case D3D11_FILTER_MIN_MAG_MIP_POINT: + return rendererData->nearestPixelSampler; + case D3D11_FILTER_MIN_MAG_MIP_LINEAR: + return rendererData->linearSampler; + default: + return NULL; + } +} + +static int +D3D11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata; + float minu, maxu, minv, maxv; + Float4 color; + VertexPositionColor vertices[4]; + ID3D11SamplerState *textureSampler; + + D3D11_RenderStartDrawOp(renderer); + D3D11_RenderSetBlendMode(renderer, texture->blendMode); + + minu = (float) srcrect->x / texture->w; + maxu = (float) (srcrect->x + srcrect->w) / texture->w; + minv = (float) srcrect->y / texture->h; + maxv = (float) (srcrect->y + srcrect->h) / texture->h; + + color.x = 1.0f; /* red */ + color.y = 1.0f; /* green */ + color.z = 1.0f; /* blue */ + color.w = 1.0f; /* alpha */ + if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) { + color.x = (float)(texture->r / 255.0f); /* red */ + color.y = (float)(texture->g / 255.0f); /* green */ + color.z = (float)(texture->b / 255.0f); /* blue */ + } + if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) { + color.w = (float)(texture->a / 255.0f); /* alpha */ + } + + vertices[0].pos.x = dstrect->x; + vertices[0].pos.y = dstrect->y; + vertices[0].pos.z = 0.0f; + vertices[0].tex.x = minu; + vertices[0].tex.y = minv; + vertices[0].color = color; + + vertices[1].pos.x = dstrect->x; + vertices[1].pos.y = dstrect->y + dstrect->h; + vertices[1].pos.z = 0.0f; + vertices[1].tex.x = minu; + vertices[1].tex.y = maxv; + vertices[1].color = color; + + vertices[2].pos.x = dstrect->x + dstrect->w; + vertices[2].pos.y = dstrect->y; + vertices[2].pos.z = 0.0f; + vertices[2].tex.x = maxu; + vertices[2].tex.y = minv; + vertices[2].color = color; + + vertices[3].pos.x = dstrect->x + dstrect->w; + vertices[3].pos.y = dstrect->y + dstrect->h; + vertices[3].pos.z = 0.0f; + vertices[3].tex.x = maxu; + vertices[3].tex.y = maxv; + vertices[3].color = color; + + if (D3D11_UpdateVertexBuffer(renderer, vertices, sizeof(vertices)) != 0) { + return -1; + } + + textureSampler = D3D11_RenderGetSampler(renderer, texture); + if (textureData->yuv) { + ID3D11ShaderResourceView *shaderResources[] = { + textureData->mainTextureResourceView, + textureData->mainTextureResourceViewU, + textureData->mainTextureResourceViewV + }; + D3D11_SetPixelShader( + renderer, + rendererData->yuvPixelShader, + SDL_arraysize(shaderResources), + shaderResources, + textureSampler); + } else { + D3D11_SetPixelShader( + renderer, + rendererData->texturePixelShader, + 1, + &textureData->mainTextureResourceView, + textureSampler); + } + + D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, sizeof(vertices) / sizeof(VertexPositionColor)); + + return 0; +} + +static int +D3D11_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata; + D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata; + float minu, maxu, minv, maxv; + Float4 color; + Float4X4 modelMatrix; + float minx, maxx, miny, maxy; + VertexPositionColor vertices[4]; + ID3D11SamplerState *textureSampler; + + D3D11_RenderStartDrawOp(renderer); + D3D11_RenderSetBlendMode(renderer, texture->blendMode); + + minu = (float) srcrect->x / texture->w; + maxu = (float) (srcrect->x + srcrect->w) / texture->w; + minv = (float) srcrect->y / texture->h; + maxv = (float) (srcrect->y + srcrect->h) / texture->h; + + color.x = 1.0f; /* red */ + color.y = 1.0f; /* green */ + color.z = 1.0f; /* blue */ + color.w = 1.0f; /* alpha */ + if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) { + color.x = (float)(texture->r / 255.0f); /* red */ + color.y = (float)(texture->g / 255.0f); /* green */ + color.z = (float)(texture->b / 255.0f); /* blue */ + } + if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) { + color.w = (float)(texture->a / 255.0f); /* alpha */ + } + + if (flip & SDL_FLIP_HORIZONTAL) { + float tmp = maxu; + maxu = minu; + minu = tmp; + } + if (flip & SDL_FLIP_VERTICAL) { + float tmp = maxv; + maxv = minv; + minv = tmp; + } + + modelMatrix = MatrixMultiply( + MatrixRotationZ((float)(M_PI * (float) angle / 180.0f)), + MatrixTranslation(dstrect->x + center->x, dstrect->y + center->y, 0) + ); + D3D11_SetModelMatrix(renderer, &modelMatrix); + + minx = -center->x; + maxx = dstrect->w - center->x; + miny = -center->y; + maxy = dstrect->h - center->y; + + vertices[0].pos.x = minx; + vertices[0].pos.y = miny; + vertices[0].pos.z = 0.0f; + vertices[0].tex.x = minu; + vertices[0].tex.y = minv; + vertices[0].color = color; + + vertices[1].pos.x = minx; + vertices[1].pos.y = maxy; + vertices[1].pos.z = 0.0f; + vertices[1].tex.x = minu; + vertices[1].tex.y = maxv; + vertices[1].color = color; + + vertices[2].pos.x = maxx; + vertices[2].pos.y = miny; + vertices[2].pos.z = 0.0f; + vertices[2].tex.x = maxu; + vertices[2].tex.y = minv; + vertices[2].color = color; + + vertices[3].pos.x = maxx; + vertices[3].pos.y = maxy; + vertices[3].pos.z = 0.0f; + vertices[3].tex.x = maxu; + vertices[3].tex.y = maxv; + vertices[3].color = color; + + if (D3D11_UpdateVertexBuffer(renderer, vertices, sizeof(vertices)) != 0) { + return -1; + } + + textureSampler = D3D11_RenderGetSampler(renderer, texture); + if (textureData->yuv) { + ID3D11ShaderResourceView *shaderResources[] = { + textureData->mainTextureResourceView, + textureData->mainTextureResourceViewU, + textureData->mainTextureResourceViewV + }; + D3D11_SetPixelShader( + renderer, + rendererData->yuvPixelShader, + SDL_arraysize(shaderResources), + shaderResources, + textureSampler); + } else { + D3D11_SetPixelShader( + renderer, + rendererData->texturePixelShader, + 1, + &textureData->mainTextureResourceView, + textureSampler); + } + + D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, sizeof(vertices) / sizeof(VertexPositionColor)); + + D3D11_SetModelMatrix(renderer, NULL); + + return 0; +} + +static int +D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 format, void * pixels, int pitch) +{ + D3D11_RenderData * data = (D3D11_RenderData *) renderer->driverdata; + ID3D11Texture2D *backBuffer = NULL; + ID3D11Texture2D *stagingTexture = NULL; + HRESULT result; + int status = -1; + D3D11_TEXTURE2D_DESC stagingTextureDesc; + D3D11_RECT srcRect; + D3D11_BOX srcBox; + D3D11_MAPPED_SUBRESOURCE textureMemory; + + /* Retrieve a pointer to the back buffer: */ + result = IDXGISwapChain_GetBuffer(data->swapChain, + 0, + &IID_ID3D11Texture2D, + &backBuffer + ); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGISwapChain1::GetBuffer [get back buffer]", result); + goto done; + } + + /* Create a staging texture to copy the screen's data to: */ + ID3D11Texture2D_GetDesc(backBuffer, &stagingTextureDesc); + stagingTextureDesc.Width = rect->w; + stagingTextureDesc.Height = rect->h; + stagingTextureDesc.BindFlags = 0; + stagingTextureDesc.MiscFlags = 0; + stagingTextureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; + stagingTextureDesc.Usage = D3D11_USAGE_STAGING; + result = ID3D11Device_CreateTexture2D(data->d3dDevice, + &stagingTextureDesc, + NULL, + &stagingTexture); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11Device1::CreateTexture2D [create staging texture]", result); + goto done; + } + + /* Copy the desired portion of the back buffer to the staging texture: */ + if (D3D11_GetViewportAlignedD3DRect(renderer, rect, &srcRect) != 0) { + /* D3D11_GetViewportAlignedD3DRect will have set the SDL error */ + goto done; + } + + srcBox.left = srcRect.left; + srcBox.right = srcRect.right; + srcBox.top = srcRect.top; + srcBox.bottom = srcRect.bottom; + srcBox.front = 0; + srcBox.back = 1; + ID3D11DeviceContext_CopySubresourceRegion(data->d3dContext, + (ID3D11Resource *)stagingTexture, + 0, + 0, 0, 0, + (ID3D11Resource *)backBuffer, + 0, + &srcBox); + + /* Map the staging texture's data to CPU-accessible memory: */ + result = ID3D11DeviceContext_Map(data->d3dContext, + (ID3D11Resource *)stagingTexture, + 0, + D3D11_MAP_READ, + 0, + &textureMemory); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", ID3D11DeviceContext1::Map [map staging texture]", result); + goto done; + } + + /* Copy the data into the desired buffer, converting pixels to the + * desired format at the same time: + */ + if (SDL_ConvertPixels( + rect->w, rect->h, + DXGIFormatToSDLPixelFormat(stagingTextureDesc.Format), + textureMemory.pData, + textureMemory.RowPitch, + format, + pixels, + pitch) != 0) { + /* When SDL_ConvertPixels fails, it'll have already set the format. + * Get the error message, and attach some extra data to it. + */ + char errorMessage[1024]; + SDL_snprintf(errorMessage, sizeof(errorMessage), __FUNCTION__ ", Convert Pixels failed: %s", SDL_GetError()); + SDL_SetError(errorMessage); + goto done; + } + + /* Unmap the texture: */ + ID3D11DeviceContext_Unmap(data->d3dContext, + (ID3D11Resource *)stagingTexture, + 0); + + status = 0; + +done: + SAFE_RELEASE(backBuffer); + SAFE_RELEASE(stagingTexture); + return status; +} + +static void +D3D11_RenderPresent(SDL_Renderer * renderer) +{ + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + UINT syncInterval; + UINT presentFlags; + HRESULT result; + DXGI_PRESENT_PARAMETERS parameters; + +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + syncInterval = 1; + presentFlags = 0; + result = IDXGISwapChain_Present(data->swapChain, syncInterval, presentFlags); +#else + if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) { + syncInterval = 1; + presentFlags = 0; + } else { + syncInterval = 0; + presentFlags = DXGI_PRESENT_DO_NOT_WAIT; + } + + /* The application may optionally specify "dirty" or "scroll" + * rects to improve efficiency in certain scenarios. + * This option is not available on Windows Phone 8, to note. + */ + SDL_zero(parameters); + result = IDXGISwapChain1_Present1(data->swapChain, syncInterval, presentFlags, ¶meters); +#endif + + /* Discard the contents of the render target. + * This is a valid operation only when the existing contents will be entirely + * overwritten. If dirty or scroll rects are used, this call should be removed. + */ + ID3D11DeviceContext1_DiscardView(data->d3dContext, (ID3D11View*)data->mainRenderTargetView); + + /* When the present flips, it unbinds the current view, so bind it again on the next draw call */ + data->currentRenderTargetView = NULL; + + if (FAILED(result) && result != DXGI_ERROR_WAS_STILL_DRAWING) { + /* If the device was removed either by a disconnect or a driver upgrade, we + * must recreate all device resources. + * + * TODO, WinRT: consider throwing an exception if D3D11_RenderPresent fails, especially if there is a way to salvage debug info from users' machines + */ + if ( result == DXGI_ERROR_DEVICE_REMOVED ) { + D3D11_HandleDeviceLost(renderer); + } else if (result == DXGI_ERROR_INVALID_CALL) { + /* We probably went through a fullscreen <-> windowed transition */ + D3D11_CreateWindowSizeDependentResources(renderer); + } else { + WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGISwapChain::Present", result); + } + } +} + +#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/render/direct3d11/SDL_render_winrt.cpp b/jni/SDL2-2.0.3/src/render/direct3d11/SDL_render_winrt.cpp new file mode 100644 index 00000000..9ed67fd2 --- /dev/null +++ b/jni/SDL2-2.0.3/src/render/direct3d11/SDL_render_winrt.cpp @@ -0,0 +1,119 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED + +#include "SDL_syswm.h" +extern "C" { +#include "../SDL_sysrender.h" +} + +#include +#include + +#if WINAPI_FAMILY == WINAPI_FAMILY_APP +#include +#endif + +using namespace Windows::UI::Core; +using namespace Windows::Graphics::Display; + +#include + +#include "SDL_render_winrt.h" + + +extern "C" void * +D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer) +{ + SDL_Window * sdlWindow = renderer->window; + if ( ! renderer->window ) { + return NULL; + } + + SDL_SysWMinfo sdlWindowInfo; + SDL_VERSION(&sdlWindowInfo.version); + if ( ! SDL_GetWindowWMInfo(sdlWindow, &sdlWindowInfo) ) { + return NULL; + } + + if (sdlWindowInfo.subsystem != SDL_SYSWM_WINRT) { + return NULL; + } + + if (!sdlWindowInfo.info.winrt.window) { + return NULL; + } + + ABI::Windows::UI::Core::ICoreWindow *coreWindow = NULL; + if (FAILED(sdlWindowInfo.info.winrt.window->QueryInterface(&coreWindow))) { + return NULL; + } + + IUnknown *coreWindowAsIUnknown = NULL; + coreWindow->QueryInterface(&coreWindowAsIUnknown); + coreWindow->Release(); + + return coreWindowAsIUnknown; +} + +extern "C" DXGI_MODE_ROTATION +D3D11_GetCurrentRotation() +{ +#if NTDDI_VERSION > NTDDI_WIN8 + const DisplayOrientations currentOrientation = DisplayInformation::GetForCurrentView()->CurrentOrientation; +#else + const DisplayOrientations currentOrientation = DisplayProperties::CurrentOrientation; +#endif + + switch (currentOrientation) { + +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + /* Windows Phone rotations */ + case DisplayOrientations::Landscape: + return DXGI_MODE_ROTATION_ROTATE90; + case DisplayOrientations::Portrait: + return DXGI_MODE_ROTATION_IDENTITY; + case DisplayOrientations::LandscapeFlipped: + return DXGI_MODE_ROTATION_ROTATE270; + case DisplayOrientations::PortraitFlipped: + return DXGI_MODE_ROTATION_ROTATE180; +#else + /* Non-Windows-Phone rotations (ex: Windows 8, Windows RT) */ + case DisplayOrientations::Landscape: + return DXGI_MODE_ROTATION_IDENTITY; + case DisplayOrientations::Portrait: + return DXGI_MODE_ROTATION_ROTATE270; + case DisplayOrientations::LandscapeFlipped: + return DXGI_MODE_ROTATION_ROTATE180; + case DisplayOrientations::PortraitFlipped: + return DXGI_MODE_ROTATION_ROTATE90; +#endif /* WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP */ + } + + return DXGI_MODE_ROTATION_IDENTITY; +} + + +#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/render/direct3d11/SDL_render_winrt.h b/jni/SDL2-2.0.3/src/render/direct3d11/SDL_render_winrt.h new file mode 100644 index 00000000..66a3220d --- /dev/null +++ b/jni/SDL2-2.0.3/src/render/direct3d11/SDL_render_winrt.h @@ -0,0 +1,40 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED + +#include "SDL_render.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void * D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer); +DXGI_MODE_ROTATION D3D11_GetCurrentRotation(); + +#ifdef __cplusplus +} +#endif + +#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.1/src/render/mmx.h b/jni/SDL2-2.0.3/src/render/mmx.h similarity index 100% rename from jni/SDL2-2.0.1/src/render/mmx.h rename to jni/SDL2-2.0.3/src/render/mmx.h diff --git a/jni/SDL2-2.0.1/src/render/opengl/SDL_glfuncs.h b/jni/SDL2-2.0.3/src/render/opengl/SDL_glfuncs.h similarity index 96% rename from jni/SDL2-2.0.1/src/render/opengl/SDL_glfuncs.h rename to jni/SDL2-2.0.3/src/render/opengl/SDL_glfuncs.h index c7e577b0..fefbdd26 100644 --- a/jni/SDL2-2.0.1/src/render/opengl/SDL_glfuncs.h +++ b/jni/SDL2-2.0.3/src/render/opengl/SDL_glfuncs.h @@ -1,3 +1,24 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + /* list of OpenGL functions sorted alphabetically If you need to use a GL function from the SDL video subsystem, change its entry from SDL_PROC_UNUSED to SDL_PROC and rebuild. diff --git a/jni/SDL2-2.0.1/src/render/opengl/SDL_render_gl.c b/jni/SDL2-2.0.3/src/render/opengl/SDL_render_gl.c similarity index 97% rename from jni/SDL2-2.0.1/src/render/opengl/SDL_render_gl.c rename to jni/SDL2-2.0.3/src/render/opengl/SDL_render_gl.c index 1cd03d46..8a0e377b 100644 --- a/jni/SDL2-2.0.1/src/render/opengl/SDL_render_gl.c +++ b/jni/SDL2-2.0.3/src/render/opengl/SDL_render_gl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -32,6 +32,12 @@ #include #endif +/* To prevent unnecessary window recreation, + * these should match the defaults selected in SDL_GL_ResetAttributes + */ + +#define RENDERER_CONTEXT_MAJOR 2 +#define RENDERER_CONTEXT_MINOR 1 /* OpenGL renderer implementation */ @@ -381,11 +387,25 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) const char *hint; GLint value; Uint32 window_flags; + int profile_mask, major, minor; + SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask); + SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major); + SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minor); + window_flags = SDL_GetWindowFlags(window); - if (!(window_flags & SDL_WINDOW_OPENGL)) { + if (!(window_flags & SDL_WINDOW_OPENGL) || + profile_mask == SDL_GL_CONTEXT_PROFILE_ES || major != RENDERER_CONTEXT_MAJOR || minor != RENDERER_CONTEXT_MINOR) { + + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, 0); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, RENDERER_CONTEXT_MAJOR); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, RENDERER_CONTEXT_MINOR); + if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) { /* Uh oh, better try to put it back... */ + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profile_mask); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor); SDL_RecreateWindow(window, window_flags); return NULL; } @@ -427,7 +447,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->GL_BindTexture = GL_BindTexture; renderer->GL_UnbindTexture = GL_UnbindTexture; renderer->info = GL_RenderDriver.info; - renderer->info.flags = SDL_RENDERER_ACCELERATED; + renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); renderer->driverdata = data; renderer->window = window; diff --git a/jni/SDL2-2.0.1/src/render/opengl/SDL_shaders_gl.c b/jni/SDL2-2.0.3/src/render/opengl/SDL_shaders_gl.c similarity index 99% rename from jni/SDL2-2.0.1/src/render/opengl/SDL_shaders_gl.c rename to jni/SDL2-2.0.3/src/render/opengl/SDL_shaders_gl.c index 80e173b8..8b15298f 100644 --- a/jni/SDL2-2.0.1/src/render/opengl/SDL_shaders_gl.c +++ b/jni/SDL2-2.0.3/src/render/opengl/SDL_shaders_gl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/opengl/SDL_shaders_gl.h b/jni/SDL2-2.0.3/src/render/opengl/SDL_shaders_gl.h similarity index 95% rename from jni/SDL2-2.0.1/src/render/opengl/SDL_shaders_gl.h rename to jni/SDL2-2.0.3/src/render/opengl/SDL_shaders_gl.h index 4080b1d3..fdd4db7f 100644 --- a/jni/SDL2-2.0.1/src/render/opengl/SDL_shaders_gl.h +++ b/jni/SDL2-2.0.3/src/render/opengl/SDL_shaders_gl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/opengles/SDL_glesfuncs.h b/jni/SDL2-2.0.3/src/render/opengles/SDL_glesfuncs.h similarity index 71% rename from jni/SDL2-2.0.1/src/render/opengles/SDL_glesfuncs.h rename to jni/SDL2-2.0.3/src/render/opengles/SDL_glesfuncs.h index ff5ce76b..6dc197a6 100644 --- a/jni/SDL2-2.0.1/src/render/opengles/SDL_glesfuncs.h +++ b/jni/SDL2-2.0.3/src/render/opengles/SDL_glesfuncs.h @@ -1,3 +1,24 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + SDL_PROC(void, glBindTexture, (GLenum, GLuint)) SDL_PROC(void, glBlendFunc, (GLenum, GLenum)) SDL_PROC_OES(void, glBlendFuncSeparateOES, (GLenum, GLenum, GLenum, GLenum)) diff --git a/jni/SDL2-2.0.1/src/render/opengles/SDL_render_gles.c b/jni/SDL2-2.0.3/src/render/opengles/SDL_render_gles.c similarity index 96% rename from jni/SDL2-2.0.1/src/render/opengles/SDL_render_gles.c rename to jni/SDL2-2.0.3/src/render/opengles/SDL_render_gles.c index 10e42567..43a07a4b 100644 --- a/jni/SDL2-2.0.1/src/render/opengles/SDL_render_gles.c +++ b/jni/SDL2-2.0.3/src/render/opengles/SDL_render_gles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -26,6 +26,13 @@ #include "SDL_opengles.h" #include "../SDL_sysrender.h" +/* To prevent unnecessary window recreation, + * these should match the defaults selected in SDL_GL_ResetAttributes + */ + +#define RENDERER_CONTEXT_MAJOR 1 +#define RENDERER_CONTEXT_MINOR 1 + #if defined(SDL_VIDEO_DRIVER_PANDORA) /* Empty function stub to get OpenGL ES 1.x support without */ @@ -96,7 +103,7 @@ SDL_RenderDriver GLES_RenderDriver = { GLES_CreateRenderer, { "opengles", - (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC ), + (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), 1, {SDL_PIXELFORMAT_ABGR8888}, 0, @@ -279,15 +286,25 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags) GLES_RenderData *data; GLint value; Uint32 windowFlags; + int profile_mask, major, minor; - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); + SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask); + SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major); + SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minor); windowFlags = SDL_GetWindowFlags(window); - if (!(windowFlags & SDL_WINDOW_OPENGL)) { + if (!(windowFlags & SDL_WINDOW_OPENGL) || + profile_mask != SDL_GL_CONTEXT_PROFILE_ES || major != RENDERER_CONTEXT_MAJOR || minor != RENDERER_CONTEXT_MINOR) { + + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, RENDERER_CONTEXT_MAJOR); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, RENDERER_CONTEXT_MINOR); + if (SDL_RecreateWindow(window, windowFlags | SDL_WINDOW_OPENGL) < 0) { /* Uh oh, better try to put it back... */ + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profile_mask); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor); SDL_RecreateWindow(window, windowFlags); return NULL; } diff --git a/jni/SDL2-2.0.1/src/render/opengles2/SDL_gles2funcs.h b/jni/SDL2-2.0.3/src/render/opengles2/SDL_gles2funcs.h similarity index 75% rename from jni/SDL2-2.0.1/src/render/opengles2/SDL_gles2funcs.h rename to jni/SDL2-2.0.3/src/render/opengles2/SDL_gles2funcs.h index 9faad133..c2a20f7d 100644 --- a/jni/SDL2-2.0.1/src/render/opengles2/SDL_gles2funcs.h +++ b/jni/SDL2-2.0.3/src/render/opengles2/SDL_gles2funcs.h @@ -1,3 +1,24 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + SDL_PROC(void, glActiveTexture, (GLenum)) SDL_PROC(void, glAttachShader, (GLuint, GLuint)) SDL_PROC(void, glBindAttribLocation, (GLuint, GLuint, const char *)) @@ -47,4 +68,4 @@ SDL_PROC(void, glFramebufferTexture2D, (GLenum, GLenum, GLenum, GLuint, GLint)) SDL_PROC(GLenum, glCheckFramebufferStatus, (GLenum)) SDL_PROC(void, glDeleteFramebuffers, (GLsizei, const GLuint *)) SDL_PROC(GLint, glGetAttribLocation, (GLuint, const GLchar *)) - \ No newline at end of file + diff --git a/jni/SDL2-2.0.1/src/render/opengles2/SDL_render_gles2.c b/jni/SDL2-2.0.3/src/render/opengles2/SDL_render_gles2.c similarity index 96% rename from jni/SDL2-2.0.1/src/render/opengles2/SDL_render_gles2.c rename to jni/SDL2-2.0.3/src/render/opengles2/SDL_render_gles2.c index f7ac5613..44484783 100644 --- a/jni/SDL2-2.0.1/src/render/opengles2/SDL_render_gles2.c +++ b/jni/SDL2-2.0.3/src/render/opengles2/SDL_render_gles2.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -28,6 +28,12 @@ #include "../../video/SDL_blit.h" #include "SDL_shaders_gles2.h" +/* To prevent unnecessary window recreation, + * these should match the defaults selected in SDL_GL_ResetAttributes + */ +#define RENDERER_CONTEXT_MAJOR 2 +#define RENDERER_CONTEXT_MINOR 0 + /* Used to re-create the window with OpenGL ES capability */ extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags); @@ -1043,16 +1049,33 @@ CompareColors(Uint8 r1, Uint8 g1, Uint8 b1, Uint8 a1, static int GLES2_RenderClear(SDL_Renderer * renderer) { + Uint8 r, g, b, a; + GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata; GLES2_ActivateRenderer(renderer); if (!CompareColors(data->clear_r, data->clear_g, data->clear_b, data->clear_a, renderer->r, renderer->g, renderer->b, renderer->a)) { - data->glClearColor((GLfloat) renderer->r * inv255f, - (GLfloat) renderer->g * inv255f, - (GLfloat) renderer->b * inv255f, - (GLfloat) renderer->a * inv255f); + + /* Select the color to clear with */ + g = renderer->g; + a = renderer->a; + + if (renderer->target && + (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || + renderer->target->format == SDL_PIXELFORMAT_RGB888)) { + r = renderer->b; + b = renderer->r; + } else { + r = renderer->r; + b = renderer->b; + } + + data->glClearColor((GLfloat) r * inv255f, + (GLfloat) g * inv255f, + (GLfloat) b * inv255f, + (GLfloat) a * inv255f); data->clear_r = renderer->r; data->clear_g = renderer->g; data->clear_b = renderer->b; @@ -1723,15 +1746,25 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) Uint32 windowFlags; GLint window_framebuffer; GLint value; + int profile_mask, major, minor; - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); + SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &profile_mask); + SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &major); + SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minor); windowFlags = SDL_GetWindowFlags(window); - if (!(windowFlags & SDL_WINDOW_OPENGL)) { + if (!(windowFlags & SDL_WINDOW_OPENGL) || + profile_mask != SDL_GL_CONTEXT_PROFILE_ES || major != RENDERER_CONTEXT_MAJOR || minor != RENDERER_CONTEXT_MINOR) { + + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, RENDERER_CONTEXT_MAJOR); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, RENDERER_CONTEXT_MINOR); + if (SDL_RecreateWindow(window, windowFlags | SDL_WINDOW_OPENGL) < 0) { /* Uh oh, better try to put it back... */ + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, profile_mask); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, major); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, minor); SDL_RecreateWindow(window, windowFlags); return NULL; } @@ -1751,7 +1784,7 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) return NULL; } renderer->info = GLES2_RenderDriver.info; - renderer->info.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE; + renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); renderer->driverdata = data; renderer->window = window; @@ -1772,6 +1805,14 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) return NULL; } +#if __WINRT__ + /* DLudwig, 2013-11-29: ANGLE for WinRT doesn't seem to work unless VSync + * is turned on. Not doing so will freeze the screen's contents to that + * of the first drawn frame. + */ + flags |= SDL_RENDERER_PRESENTVSYNC; +#endif + if (flags & SDL_RENDERER_PRESENTVSYNC) { SDL_GL_SetSwapInterval(1); } else { diff --git a/jni/SDL2-2.0.1/src/render/opengles2/SDL_shaders_gles2.c b/jni/SDL2-2.0.3/src/render/opengles2/SDL_shaders_gles2.c similarity index 99% rename from jni/SDL2-2.0.1/src/render/opengles2/SDL_shaders_gles2.c rename to jni/SDL2-2.0.3/src/render/opengles2/SDL_shaders_gles2.c index e4bbebb0..3b16cc3d 100644 --- a/jni/SDL2-2.0.1/src/render/opengles2/SDL_shaders_gles2.c +++ b/jni/SDL2-2.0.3/src/render/opengles2/SDL_shaders_gles2.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/opengles2/SDL_shaders_gles2.h b/jni/SDL2-2.0.3/src/render/opengles2/SDL_shaders_gles2.h similarity index 96% rename from jni/SDL2-2.0.1/src/render/opengles2/SDL_shaders_gles2.h rename to jni/SDL2-2.0.3/src/render/opengles2/SDL_shaders_gles2.h index eeee876a..77c75c9f 100644 --- a/jni/SDL2-2.0.1/src/render/opengles2/SDL_shaders_gles2.h +++ b/jni/SDL2-2.0.3/src/render/opengles2/SDL_shaders_gles2.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/psp/SDL_render_psp.c b/jni/SDL2-2.0.3/src/render/psp/SDL_render_psp.c similarity index 99% rename from jni/SDL2-2.0.1/src/render/psp/SDL_render_psp.c rename to jni/SDL2-2.0.3/src/render/psp/SDL_render_psp.c index c867af36..cdd13e82 100644 --- a/jni/SDL2-2.0.1/src/render/psp/SDL_render_psp.c +++ b/jni/SDL2-2.0.3/src/render/psp/SDL_render_psp.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -375,7 +375,7 @@ PSP_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->DestroyTexture = PSP_DestroyTexture; renderer->DestroyRenderer = PSP_DestroyRenderer; renderer->info = PSP_RenderDriver.info; - renderer->info.flags = SDL_RENDERER_ACCELERATED; + renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); renderer->driverdata = data; renderer->window = window; diff --git a/jni/SDL2-2.0.1/src/render/software/SDL_blendfillrect.c b/jni/SDL2-2.0.3/src/render/software/SDL_blendfillrect.c similarity index 99% rename from jni/SDL2-2.0.1/src/render/software/SDL_blendfillrect.c rename to jni/SDL2-2.0.3/src/render/software/SDL_blendfillrect.c index 4ba2fca3..cb184d63 100644 --- a/jni/SDL2-2.0.1/src/render/software/SDL_blendfillrect.c +++ b/jni/SDL2-2.0.3/src/render/software/SDL_blendfillrect.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/software/SDL_blendfillrect.h b/jni/SDL2-2.0.3/src/render/software/SDL_blendfillrect.h similarity index 95% rename from jni/SDL2-2.0.1/src/render/software/SDL_blendfillrect.h rename to jni/SDL2-2.0.3/src/render/software/SDL_blendfillrect.h index cdae7d0e..297c839e 100644 --- a/jni/SDL2-2.0.1/src/render/software/SDL_blendfillrect.h +++ b/jni/SDL2-2.0.3/src/render/software/SDL_blendfillrect.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/software/SDL_blendline.c b/jni/SDL2-2.0.3/src/render/software/SDL_blendline.c similarity index 99% rename from jni/SDL2-2.0.1/src/render/software/SDL_blendline.c rename to jni/SDL2-2.0.3/src/render/software/SDL_blendline.c index c090a50c..02d748d5 100644 --- a/jni/SDL2-2.0.1/src/render/software/SDL_blendline.c +++ b/jni/SDL2-2.0.3/src/render/software/SDL_blendline.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/software/SDL_blendline.h b/jni/SDL2-2.0.3/src/render/software/SDL_blendline.h similarity index 95% rename from jni/SDL2-2.0.1/src/render/software/SDL_blendline.h rename to jni/SDL2-2.0.3/src/render/software/SDL_blendline.h index aa818068..14a7c18a 100644 --- a/jni/SDL2-2.0.1/src/render/software/SDL_blendline.h +++ b/jni/SDL2-2.0.3/src/render/software/SDL_blendline.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/software/SDL_blendpoint.c b/jni/SDL2-2.0.3/src/render/software/SDL_blendpoint.c similarity index 99% rename from jni/SDL2-2.0.1/src/render/software/SDL_blendpoint.c rename to jni/SDL2-2.0.3/src/render/software/SDL_blendpoint.c index eecf203f..dab13560 100644 --- a/jni/SDL2-2.0.1/src/render/software/SDL_blendpoint.c +++ b/jni/SDL2-2.0.3/src/render/software/SDL_blendpoint.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/software/SDL_blendpoint.h b/jni/SDL2-2.0.3/src/render/software/SDL_blendpoint.h similarity index 95% rename from jni/SDL2-2.0.1/src/render/software/SDL_blendpoint.h rename to jni/SDL2-2.0.3/src/render/software/SDL_blendpoint.h index cbfb4be2..72eaf7b8 100644 --- a/jni/SDL2-2.0.1/src/render/software/SDL_blendpoint.h +++ b/jni/SDL2-2.0.3/src/render/software/SDL_blendpoint.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/software/SDL_draw.h b/jni/SDL2-2.0.3/src/render/software/SDL_draw.h similarity index 99% rename from jni/SDL2-2.0.1/src/render/software/SDL_draw.h rename to jni/SDL2-2.0.3/src/render/software/SDL_draw.h index f643abb2..ba2ec311 100644 --- a/jni/SDL2-2.0.1/src/render/software/SDL_draw.h +++ b/jni/SDL2-2.0.3/src/render/software/SDL_draw.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/software/SDL_drawline.c b/jni/SDL2-2.0.3/src/render/software/SDL_drawline.c similarity index 99% rename from jni/SDL2-2.0.1/src/render/software/SDL_drawline.c rename to jni/SDL2-2.0.3/src/render/software/SDL_drawline.c index 71bee9de..1ff84a46 100644 --- a/jni/SDL2-2.0.1/src/render/software/SDL_drawline.c +++ b/jni/SDL2-2.0.3/src/render/software/SDL_drawline.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/software/SDL_drawline.h b/jni/SDL2-2.0.3/src/render/software/SDL_drawline.h similarity index 94% rename from jni/SDL2-2.0.1/src/render/software/SDL_drawline.h rename to jni/SDL2-2.0.3/src/render/software/SDL_drawline.h index 08b975a5..e3378ae8 100644 --- a/jni/SDL2-2.0.1/src/render/software/SDL_drawline.h +++ b/jni/SDL2-2.0.3/src/render/software/SDL_drawline.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/software/SDL_drawpoint.c b/jni/SDL2-2.0.3/src/render/software/SDL_drawpoint.c similarity index 98% rename from jni/SDL2-2.0.1/src/render/software/SDL_drawpoint.c rename to jni/SDL2-2.0.3/src/render/software/SDL_drawpoint.c index c5c74e0e..3f2de86c 100644 --- a/jni/SDL2-2.0.1/src/render/software/SDL_drawpoint.c +++ b/jni/SDL2-2.0.3/src/render/software/SDL_drawpoint.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/software/SDL_drawpoint.h b/jni/SDL2-2.0.3/src/render/software/SDL_drawpoint.h similarity index 94% rename from jni/SDL2-2.0.1/src/render/software/SDL_drawpoint.h rename to jni/SDL2-2.0.3/src/render/software/SDL_drawpoint.h index 2beb453f..96933d61 100644 --- a/jni/SDL2-2.0.1/src/render/software/SDL_drawpoint.h +++ b/jni/SDL2-2.0.3/src/render/software/SDL_drawpoint.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/software/SDL_render_sw.c b/jni/SDL2-2.0.3/src/render/software/SDL_render_sw.c similarity index 99% rename from jni/SDL2-2.0.1/src/render/software/SDL_render_sw.c rename to jni/SDL2-2.0.3/src/render/software/SDL_render_sw.c index cd42d9b6..f0eb768f 100644 --- a/jni/SDL2-2.0.1/src/render/software/SDL_render_sw.c +++ b/jni/SDL2-2.0.3/src/render/software/SDL_render_sw.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/software/SDL_render_sw_c.h b/jni/SDL2-2.0.3/src/render/software/SDL_render_sw_c.h similarity index 94% rename from jni/SDL2-2.0.1/src/render/software/SDL_render_sw_c.h rename to jni/SDL2-2.0.3/src/render/software/SDL_render_sw_c.h index 7ba0a7ee..81cb656c 100644 --- a/jni/SDL2-2.0.1/src/render/software/SDL_render_sw_c.h +++ b/jni/SDL2-2.0.3/src/render/software/SDL_render_sw_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/render/software/SDL_rotate.c b/jni/SDL2-2.0.3/src/render/software/SDL_rotate.c similarity index 100% rename from jni/SDL2-2.0.1/src/render/software/SDL_rotate.c rename to jni/SDL2-2.0.3/src/render/software/SDL_rotate.c diff --git a/jni/SDL2-2.0.3/src/render/software/SDL_rotate.h b/jni/SDL2-2.0.3/src/render/software/SDL_rotate.h new file mode 100644 index 00000000..e92c3b77 --- /dev/null +++ b/jni/SDL2-2.0.3/src/render/software/SDL_rotate.h @@ -0,0 +1,28 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef MIN +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +extern SDL_Surface *SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery, int smooth, int flipx, int flipy, int dstwidth, int dstheight, double cangle, double sangle); +extern void SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, int *dstwidth, int *dstheight, double *cangle, double *sangle); + diff --git a/jni/SDL2-2.0.1/src/stdlib/SDL_getenv.c b/jni/SDL2-2.0.3/src/stdlib/SDL_getenv.c similarity index 99% rename from jni/SDL2-2.0.1/src/stdlib/SDL_getenv.c rename to jni/SDL2-2.0.3/src/stdlib/SDL_getenv.c index 348fe45c..44921106 100644 --- a/jni/SDL2-2.0.1/src/stdlib/SDL_getenv.c +++ b/jni/SDL2-2.0.3/src/stdlib/SDL_getenv.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/stdlib/SDL_iconv.c b/jni/SDL2-2.0.3/src/stdlib/SDL_iconv.c similarity index 99% rename from jni/SDL2-2.0.1/src/stdlib/SDL_iconv.c rename to jni/SDL2-2.0.3/src/stdlib/SDL_iconv.c index 8963177c..c314bf68 100644 --- a/jni/SDL2-2.0.1/src/stdlib/SDL_iconv.c +++ b/jni/SDL2-2.0.3/src/stdlib/SDL_iconv.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/stdlib/SDL_malloc.c b/jni/SDL2-2.0.3/src/stdlib/SDL_malloc.c similarity index 99% rename from jni/SDL2-2.0.1/src/stdlib/SDL_malloc.c rename to jni/SDL2-2.0.3/src/stdlib/SDL_malloc.c index 91d07c56..74105f58 100644 --- a/jni/SDL2-2.0.1/src/stdlib/SDL_malloc.c +++ b/jni/SDL2-2.0.3/src/stdlib/SDL_malloc.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/stdlib/SDL_qsort.c b/jni/SDL2-2.0.3/src/stdlib/SDL_qsort.c similarity index 100% rename from jni/SDL2-2.0.1/src/stdlib/SDL_qsort.c rename to jni/SDL2-2.0.3/src/stdlib/SDL_qsort.c diff --git a/jni/SDL2-2.0.1/src/stdlib/SDL_stdlib.c b/jni/SDL2-2.0.3/src/stdlib/SDL_stdlib.c similarity index 99% rename from jni/SDL2-2.0.1/src/stdlib/SDL_stdlib.c rename to jni/SDL2-2.0.3/src/stdlib/SDL_stdlib.c index 082c9568..11f778a3 100644 --- a/jni/SDL2-2.0.1/src/stdlib/SDL_stdlib.c +++ b/jni/SDL2-2.0.3/src/stdlib/SDL_stdlib.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -102,6 +102,8 @@ SDL_copysign(double x, double y) { #if defined(HAVE_COPYSIGN) return copysign(x, y); +#elif defined(HAVE__COPYSIGN) + return _copysign(x, y); #else return SDL_uclibc_copysign(x, y); #endif /* HAVE_COPYSIGN */ @@ -172,6 +174,8 @@ SDL_scalbn(double x, int n) { #if defined(HAVE_SCALBN) return scalbn(x, n); +#elif defined(HAVE__SCALB) + return _scalb(x, n); #else return SDL_uclibc_scalbn(x, n); #endif /* HAVE_SCALBN */ @@ -278,12 +282,6 @@ void * memcpy ( void * destination, const void * source, size_t num ) #ifdef _M_IX86 -void -__declspec(naked) -_chkstk() -{ -} - /* Float to long */ void __declspec(naked) diff --git a/jni/SDL2-2.0.1/src/stdlib/SDL_string.c b/jni/SDL2-2.0.3/src/stdlib/SDL_string.c similarity index 99% rename from jni/SDL2-2.0.1/src/stdlib/SDL_string.c rename to jni/SDL2-2.0.3/src/stdlib/SDL_string.c index c351e3ac..fb50687c 100644 --- a/jni/SDL2-2.0.1/src/stdlib/SDL_string.c +++ b/jni/SDL2-2.0.3/src/stdlib/SDL_string.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/test/SDL_test_assert.c b/jni/SDL2-2.0.3/src/test/SDL_test_assert.c similarity index 98% rename from jni/SDL2-2.0.1/src/test/SDL_test_assert.c rename to jni/SDL2-2.0.3/src/test/SDL_test_assert.c index 6f08d1f5..0a594932 100644 --- a/jni/SDL2-2.0.1/src/test/SDL_test_assert.c +++ b/jni/SDL2-2.0.3/src/test/SDL_test_assert.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/test/SDL_test_common.c b/jni/SDL2-2.0.3/src/test/SDL_test_common.c similarity index 99% rename from jni/SDL2-2.0.1/src/test/SDL_test_common.c rename to jni/SDL2-2.0.3/src/test/SDL_test_common.c index f07a0c0c..9d41a194 100644 --- a/jni/SDL2-2.0.1/src/test/SDL_test_common.c +++ b/jni/SDL2-2.0.3/src/test/SDL_test_common.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -706,6 +706,7 @@ SDLTest_CommonInit(SDLTest_CommonState * state) Uint32 Rmask, Gmask, Bmask, Amask; #if SDL_VIDEO_DRIVER_WINDOWS int adapterIndex = 0; + int outputIndex = 0; #endif n = SDL_GetNumVideoDisplays(); fprintf(stderr, "Number of displays: %d\n", n); @@ -761,9 +762,13 @@ SDLTest_CommonInit(SDLTest_CommonState * state) } #if SDL_VIDEO_DRIVER_WINDOWS - /* Print the adapter index */ + /* Print the D3D9 adapter index */ adapterIndex = SDL_Direct3D9GetAdapterIndex( i ); - fprintf( stderr, "Adapter Index: %d", adapterIndex ); + fprintf( stderr, "D3D9 Adapter Index: %d", adapterIndex ); + + /* Print the DXGI adapter and output indices */ + SDL_DXGIGetOutputInfo(i, &adapterIndex, &outputIndex); + fprintf( stderr, "DXGI Adapter Index: %d Output Index: %d", adapterIndex, outputIndex ); #endif } } @@ -1537,6 +1542,7 @@ SDLTest_CommonQuit(SDLTest_CommonState * state) SDL_AudioQuit(); } SDL_free(state); + SDL_Quit(); } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.1/src/test/SDL_test_compare.c b/jni/SDL2-2.0.3/src/test/SDL_test_compare.c similarity index 98% rename from jni/SDL2-2.0.1/src/test/SDL_test_compare.c rename to jni/SDL2-2.0.3/src/test/SDL_test_compare.c index 33f23731..de704166 100644 --- a/jni/SDL2-2.0.1/src/test/SDL_test_compare.c +++ b/jni/SDL2-2.0.3/src/test/SDL_test_compare.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/test/SDL_test_crc32.c b/jni/SDL2-2.0.3/src/test/SDL_test_crc32.c similarity index 98% rename from jni/SDL2-2.0.1/src/test/SDL_test_crc32.c rename to jni/SDL2-2.0.3/src/test/SDL_test_crc32.c index d6685c34..dafe7229 100644 --- a/jni/SDL2-2.0.1/src/test/SDL_test_crc32.c +++ b/jni/SDL2-2.0.3/src/test/SDL_test_crc32.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/test/SDL_test_font.c b/jni/SDL2-2.0.3/src/test/SDL_test_font.c similarity index 96% rename from jni/SDL2-2.0.1/src/test/SDL_test_font.c rename to jni/SDL2-2.0.3/src/test/SDL_test_font.c index b7d2caa2..a6bc40ce 100644 --- a/jni/SDL2-2.0.1/src/test/SDL_test_font.c +++ b/jni/SDL2-2.0.3/src/test/SDL_test_font.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -1569,7 +1569,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 128 0x80 '�' + * 128 0x80 '€' */ 0x7c, /* 01111100 */ 0xc6, /* 11000110 */ @@ -1581,7 +1581,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x78, /* 01111000 */ /* - * 129 0x81 '�' + * 129 0x81 '' */ 0xcc, /* 11001100 */ 0x00, /* 00000000 */ @@ -1593,7 +1593,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 130 0x82 '�' + * 130 0x82 '‚' */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ @@ -1605,7 +1605,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 131 0x83 '�' + * 131 0x83 'ƒ' */ 0x7c, /* 01111100 */ 0x82, /* 10000010 */ @@ -1617,7 +1617,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 132 0x84 '�' + * 132 0x84 '„' */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ @@ -1629,7 +1629,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 133 0x85 '�' + * 133 0x85 '…' */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ @@ -1641,7 +1641,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 134 0x86 '�' + * 134 0x86 '†' */ 0x30, /* 00110000 */ 0x30, /* 00110000 */ @@ -1653,7 +1653,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 135 0x87 '�' + * 135 0x87 '‡' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -1665,7 +1665,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x38, /* 00111000 */ /* - * 136 0x88 '�' + * 136 0x88 'ˆ' */ 0x7c, /* 01111100 */ 0x82, /* 10000010 */ @@ -1677,7 +1677,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 137 0x89 '�' + * 137 0x89 '‰' */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ @@ -1689,7 +1689,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 138 0x8a '�' + * 138 0x8a 'Š' */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ @@ -1701,7 +1701,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 139 0x8b '�' + * 139 0x8b '‹' */ 0x66, /* 01100110 */ 0x00, /* 00000000 */ @@ -1713,7 +1713,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 140 0x8c '�' + * 140 0x8c 'Œ' */ 0x7c, /* 01111100 */ 0x82, /* 10000010 */ @@ -1725,7 +1725,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 141 0x8d '�' + * 141 0x8d '' */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ @@ -1737,7 +1737,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 142 0x8e '�' + * 142 0x8e 'Ž' */ 0xc6, /* 11000110 */ 0x38, /* 00111000 */ @@ -1749,7 +1749,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 143 0x8f '�' + * 143 0x8f '' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ @@ -1761,7 +1761,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 144 0x90 '�' + * 144 0x90 '' */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ @@ -1773,7 +1773,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 145 0x91 '�' + * 145 0x91 '‘' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -1785,7 +1785,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 146 0x92 '�' + * 146 0x92 '’' */ 0x3e, /* 00111110 */ 0x6c, /* 01101100 */ @@ -1797,7 +1797,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 147 0x93 '�' + * 147 0x93 '“' */ 0x7c, /* 01111100 */ 0x82, /* 10000010 */ @@ -1809,7 +1809,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 148 0x94 '�' + * 148 0x94 '”' */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ @@ -1821,7 +1821,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 149 0x95 '�' + * 149 0x95 '•' */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ @@ -1833,7 +1833,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 150 0x96 '�' + * 150 0x96 '–' */ 0x78, /* 01111000 */ 0x84, /* 10000100 */ @@ -1845,7 +1845,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 151 0x97 '�' + * 151 0x97 '—' */ 0x60, /* 01100000 */ 0x30, /* 00110000 */ @@ -1857,7 +1857,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 152 0x98 '�' + * 152 0x98 '˜' */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ @@ -1869,7 +1869,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xfc, /* 11111100 */ /* - * 153 0x99 '�' + * 153 0x99 '™' */ 0xc6, /* 11000110 */ 0x38, /* 00111000 */ @@ -1881,7 +1881,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 154 0x9a '�' + * 154 0x9a 'š' */ 0xc6, /* 11000110 */ 0x00, /* 00000000 */ @@ -1893,7 +1893,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 155 0x9b '�' + * 155 0x9b '›' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -1905,7 +1905,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 156 0x9c '�' + * 156 0x9c 'œ' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ @@ -1917,7 +1917,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 157 0x9d '�' + * 157 0x9d '' */ 0x66, /* 01100110 */ 0x66, /* 01100110 */ @@ -1929,7 +1929,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 158 0x9e '�' + * 158 0x9e 'ž' */ 0xf8, /* 11111000 */ 0xcc, /* 11001100 */ @@ -1941,7 +1941,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xc7, /* 11000111 */ /* - * 159 0x9f '�' + * 159 0x9f 'Ÿ' */ 0x0e, /* 00001110 */ 0x1b, /* 00011011 */ @@ -1953,7 +1953,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 160 0xa0 '�' + * 160 0xa0 ' ' */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ @@ -1965,7 +1965,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 161 0xa1 '�' + * 161 0xa1 '¡' */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ @@ -1977,7 +1977,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 162 0xa2 '�' + * 162 0xa2 '¢' */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ @@ -1989,7 +1989,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 163 0xa3 '�' + * 163 0xa3 '£' */ 0x18, /* 00011000 */ 0x30, /* 00110000 */ @@ -2001,7 +2001,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 164 0xa4 '�' + * 164 0xa4 '¤' */ 0x76, /* 01110110 */ 0xdc, /* 11011100 */ @@ -2013,7 +2013,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 165 0xa5 '�' + * 165 0xa5 '¥' */ 0x76, /* 01110110 */ 0xdc, /* 11011100 */ @@ -2025,7 +2025,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 166 0xa6 '�' + * 166 0xa6 '¦' */ 0x3c, /* 00111100 */ 0x6c, /* 01101100 */ @@ -2037,7 +2037,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 167 0xa7 '�' + * 167 0xa7 '§' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ @@ -2049,7 +2049,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 168 0xa8 '�' + * 168 0xa8 '¨' */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ @@ -2061,7 +2061,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 169 0xa9 '�' + * 169 0xa9 '©' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2073,7 +2073,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 170 0xaa '�' + * 170 0xaa 'ª' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2085,7 +2085,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 171 0xab '�' + * 171 0xab '«' */ 0x63, /* 01100011 */ 0xe6, /* 11100110 */ @@ -2097,7 +2097,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x0f, /* 00001111 */ /* - * 172 0xac '�' + * 172 0xac '¬' */ 0x63, /* 01100011 */ 0xe6, /* 11100110 */ @@ -2109,7 +2109,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x06, /* 00000110 */ /* - * 173 0xad '�' + * 173 0xad '­' */ 0x18, /* 00011000 */ 0x00, /* 00000000 */ @@ -2121,7 +2121,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 174 0xae '�' + * 174 0xae '®' */ 0x00, /* 00000000 */ 0x33, /* 00110011 */ @@ -2133,7 +2133,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 175 0xaf '�' + * 175 0xaf '¯' */ 0x00, /* 00000000 */ 0xcc, /* 11001100 */ @@ -2145,7 +2145,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 176 0xb0 '�' + * 176 0xb0 '°' */ 0x22, /* 00100010 */ 0x88, /* 10001000 */ @@ -2157,7 +2157,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x88, /* 10001000 */ /* - * 177 0xb1 '�' + * 177 0xb1 '±' */ 0x55, /* 01010101 */ 0xaa, /* 10101010 */ @@ -2169,7 +2169,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xaa, /* 10101010 */ /* - * 178 0xb2 '�' + * 178 0xb2 '²' */ 0x77, /* 01110111 */ 0xdd, /* 11011101 */ @@ -2181,7 +2181,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xdd, /* 11011101 */ /* - * 179 0xb3 '�' + * 179 0xb3 '³' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2193,7 +2193,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 180 0xb4 '�' + * 180 0xb4 '´' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2205,7 +2205,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 181 0xb5 '�' + * 181 0xb5 'µ' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2217,7 +2217,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 182 0xb6 '�' + * 182 0xb6 '¶' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2229,7 +2229,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 183 0xb7 '�' + * 183 0xb7 '·' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2241,7 +2241,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 184 0xb8 '�' + * 184 0xb8 '¸' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2253,7 +2253,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 185 0xb9 '�' + * 185 0xb9 '¹' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2265,7 +2265,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 186 0xba '�' + * 186 0xba 'º' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2277,7 +2277,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 187 0xbb '�' + * 187 0xbb '»' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2289,7 +2289,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 188 0xbc '�' + * 188 0xbc '¼' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2301,7 +2301,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 189 0xbd '�' + * 189 0xbd '½' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2313,7 +2313,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 190 0xbe '�' + * 190 0xbe '¾' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2325,7 +2325,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 191 0xbf '�' + * 191 0xbf '¿' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2337,7 +2337,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 192 0xc0 '�' + * 192 0xc0 'À' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2349,7 +2349,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 193 0xc1 '�' + * 193 0xc1 'Á' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2361,7 +2361,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 194 0xc2 '�' + * 194 0xc2 'Â' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2373,7 +2373,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 195 0xc3 '�' + * 195 0xc3 'Ã' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2385,7 +2385,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 196 0xc4 '�' + * 196 0xc4 'Ä' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2397,7 +2397,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 197 0xc5 '�' + * 197 0xc5 'Å' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2409,7 +2409,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 198 0xc6 '�' + * 198 0xc6 'Æ' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2421,7 +2421,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 199 0xc7 '�' + * 199 0xc7 'Ç' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2433,7 +2433,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 200 0xc8 '�' + * 200 0xc8 'È' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2445,7 +2445,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 201 0xc9 '�' + * 201 0xc9 'É' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2457,7 +2457,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 202 0xca '�' + * 202 0xca 'Ê' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2469,7 +2469,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 203 0xcb '�' + * 203 0xcb 'Ë' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2481,7 +2481,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 204 0xcc '�' + * 204 0xcc 'Ì' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2493,7 +2493,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 205 0xcd '�' + * 205 0xcd 'Í' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2505,7 +2505,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 206 0xce '�' + * 206 0xce 'Î' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2517,7 +2517,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 207 0xcf '�' + * 207 0xcf 'Ï' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2529,7 +2529,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 208 0xd0 '�' + * 208 0xd0 'Ð' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2541,7 +2541,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 209 0xd1 '�' + * 209 0xd1 'Ñ' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2553,7 +2553,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 210 0xd2 '�' + * 210 0xd2 'Ò' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2565,7 +2565,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 211 0xd3 '�' + * 211 0xd3 'Ó' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2577,7 +2577,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 212 0xd4 '�' + * 212 0xd4 'Ô' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2589,7 +2589,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 213 0xd5 '�' + * 213 0xd5 'Õ' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2601,7 +2601,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 214 0xd6 '�' + * 214 0xd6 'Ö' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2613,7 +2613,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 215 0xd7 '�' + * 215 0xd7 '×' */ 0x36, /* 00110110 */ 0x36, /* 00110110 */ @@ -2625,7 +2625,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x36, /* 00110110 */ /* - * 216 0xd8 '�' + * 216 0xd8 'Ø' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2637,7 +2637,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 217 0xd9 '�' + * 217 0xd9 'Ù' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2649,7 +2649,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 218 0xda '�' + * 218 0xda 'Ú' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2661,7 +2661,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 219 0xdb '�' + * 219 0xdb 'Û' */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ @@ -2673,7 +2673,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xff, /* 11111111 */ /* - * 220 0xdc '�' + * 220 0xdc 'Ü' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2685,7 +2685,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xff, /* 11111111 */ /* - * 221 0xdd '�' + * 221 0xdd 'Ý' */ 0xf0, /* 11110000 */ 0xf0, /* 11110000 */ @@ -2697,7 +2697,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xf0, /* 11110000 */ /* - * 222 0xde '�' + * 222 0xde 'Þ' */ 0x0f, /* 00001111 */ 0x0f, /* 00001111 */ @@ -2709,7 +2709,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x0f, /* 00001111 */ /* - * 223 0xdf '�' + * 223 0xdf 'ß' */ 0xff, /* 11111111 */ 0xff, /* 11111111 */ @@ -2721,7 +2721,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 224 0xe0 '�' + * 224 0xe0 'à' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2733,7 +2733,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 225 0xe1 '�' + * 225 0xe1 'á' */ 0x78, /* 01111000 */ 0xcc, /* 11001100 */ @@ -2745,7 +2745,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 226 0xe2 '�' + * 226 0xe2 'â' */ 0xfe, /* 11111110 */ 0xc6, /* 11000110 */ @@ -2757,7 +2757,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 227 0xe3 '�' + * 227 0xe3 'ã' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2769,7 +2769,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 228 0xe4 '�' + * 228 0xe4 'ä' */ 0xfe, /* 11111110 */ 0xc6, /* 11000110 */ @@ -2781,7 +2781,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 229 0xe5 '�' + * 229 0xe5 'å' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2793,7 +2793,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 230 0xe6 '�' + * 230 0xe6 'æ' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2805,7 +2805,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xc0, /* 11000000 */ /* - * 231 0xe7 '�' + * 231 0xe7 'ç' */ 0x00, /* 00000000 */ 0x76, /* 01110110 */ @@ -2817,7 +2817,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 232 0xe8 '�' + * 232 0xe8 'è' */ 0x7e, /* 01111110 */ 0x18, /* 00011000 */ @@ -2829,7 +2829,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x7e, /* 01111110 */ /* - * 233 0xe9 '�' + * 233 0xe9 'é' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ @@ -2841,7 +2841,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 234 0xea '�' + * 234 0xea 'ê' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ @@ -2853,7 +2853,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 235 0xeb '�' + * 235 0xeb 'ë' */ 0x0e, /* 00001110 */ 0x18, /* 00011000 */ @@ -2865,7 +2865,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 236 0xec '�' + * 236 0xec 'ì' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -2877,7 +2877,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 237 0xed '�' + * 237 0xed 'í' */ 0x06, /* 00000110 */ 0x0c, /* 00001100 */ @@ -2889,7 +2889,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0xc0, /* 11000000 */ /* - * 238 0xee '�' + * 238 0xee 'î' */ 0x1e, /* 00011110 */ 0x30, /* 00110000 */ @@ -2901,7 +2901,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 239 0xef '�' + * 239 0xef 'ï' */ 0x00, /* 00000000 */ 0x7c, /* 01111100 */ @@ -2913,7 +2913,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 240 0xf0 '�' + * 240 0xf0 'ð' */ 0x00, /* 00000000 */ 0xfe, /* 11111110 */ @@ -2925,7 +2925,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 241 0xf1 '�' + * 241 0xf1 'ñ' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2937,7 +2937,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 242 0xf2 '�' + * 242 0xf2 'ò' */ 0x30, /* 00110000 */ 0x18, /* 00011000 */ @@ -2949,7 +2949,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 243 0xf3 '�' + * 243 0xf3 'ó' */ 0x0c, /* 00001100 */ 0x18, /* 00011000 */ @@ -2961,7 +2961,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 244 0xf4 '�' + * 244 0xf4 'ô' */ 0x0e, /* 00001110 */ 0x1b, /* 00011011 */ @@ -2973,7 +2973,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x18, /* 00011000 */ /* - * 245 0xf5 '�' + * 245 0xf5 'õ' */ 0x18, /* 00011000 */ 0x18, /* 00011000 */ @@ -2985,7 +2985,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x70, /* 01110000 */ /* - * 246 0xf6 '�' + * 246 0xf6 'ö' */ 0x00, /* 00000000 */ 0x18, /* 00011000 */ @@ -2997,7 +2997,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 247 0xf7 '�' + * 247 0xf7 '÷' */ 0x00, /* 00000000 */ 0x76, /* 01110110 */ @@ -3009,7 +3009,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 248 0xf8 '�' + * 248 0xf8 'ø' */ 0x38, /* 00111000 */ 0x6c, /* 01101100 */ @@ -3021,7 +3021,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 249 0xf9 '�' + * 249 0xf9 'ù' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -3033,7 +3033,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 250 0xfa '�' + * 250 0xfa 'ú' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -3045,7 +3045,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 251 0xfb '�' + * 251 0xfb 'û' */ 0x0f, /* 00001111 */ 0x0c, /* 00001100 */ @@ -3057,7 +3057,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x1c, /* 00011100 */ /* - * 252 0xfc '�' + * 252 0xfc 'ü' */ 0x6c, /* 01101100 */ 0x36, /* 00110110 */ @@ -3069,7 +3069,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 253 0xfd '�' + * 253 0xfd 'ý' */ 0x78, /* 01111000 */ 0x0c, /* 00001100 */ @@ -3081,7 +3081,7 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { 0x00, /* 00000000 */ /* - * 254 0xfe '�' + * 254 0xfe 'þ' */ 0x00, /* 00000000 */ 0x00, /* 00000000 */ @@ -3109,16 +3109,16 @@ static unsigned char SDLTest_FontData[SDL_TESTFONTDATAMAX] = { /* ---- Character */ -/* ! +/*! \brief Global cache for 8x8 pixel font textures created at runtime. */ static SDL_Texture *SDLTest_CharTextureCache[256]; int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c) { - const Uint32 charWidth = 8; - const Uint32 charHeight = 8; - const Uint32 charSize = 8; + const Uint32 charWidth = FONT_CHARACTER_SIZE; + const Uint32 charHeight = FONT_CHARACTER_SIZE; + const Uint32 charSize = FONT_CHARACTER_SIZE; SDL_Rect srect; SDL_Rect drect; int result; @@ -3221,7 +3221,7 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c) int SDLTest_DrawString(SDL_Renderer * renderer, int x, int y, const char *s) { - const Uint32 charWidth = 8; + const Uint32 charWidth = FONT_CHARACTER_SIZE; int result = 0; int curx = x; int cury = y; diff --git a/jni/SDL2-2.0.1/src/test/SDL_test_fuzzer.c b/jni/SDL2-2.0.3/src/test/SDL_test_fuzzer.c similarity index 99% rename from jni/SDL2-2.0.1/src/test/SDL_test_fuzzer.c rename to jni/SDL2-2.0.3/src/test/SDL_test_fuzzer.c index d090c150..963fc10b 100644 --- a/jni/SDL2-2.0.1/src/test/SDL_test_fuzzer.c +++ b/jni/SDL2-2.0.3/src/test/SDL_test_fuzzer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/test/SDL_test_harness.c b/jni/SDL2-2.0.3/src/test/SDL_test_harness.c similarity index 89% rename from jni/SDL2-2.0.1/src/test/SDL_test_harness.c rename to jni/SDL2-2.0.3/src/test/SDL_test_harness.c index 1bfe9c28..93f8dd70 100644 --- a/jni/SDL2-2.0.1/src/test/SDL_test_harness.c +++ b/jni/SDL2-2.0.3/src/test/SDL_test_harness.c @@ -1,22 +1,22 @@ /* -Simple DirectMedia Layer -Copyright (C) 1997-2013 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: -1. The origin of this software must not be misrepresented; you must not -claim that you wrote the original software. If you use this software -in a product, an acknowledgment in the product documentation would be -appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be -misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -67,12 +67,13 @@ SDLTest_GenerateRunSeed(const int length) seed = (char *)SDL_malloc((length + 1) * sizeof(char)); if (seed == NULL) { SDLTest_LogError("SDL_malloc for run seed output buffer failed."); + SDL_Error(SDL_ENOMEM); return NULL; } /* Generate a random string of alphanumeric characters */ SDLTest_RandomInitTime(&randomContext); - for (counter = 0; counter < length - 1; ++counter) { + for (counter = 0; counter < length; counter++) { unsigned int number = SDLTest_Random(&randomContext); char ch = (char) (number % (91 - 48)) + 48; if (ch >= 58 && ch <= 64) { @@ -80,7 +81,7 @@ SDLTest_GenerateRunSeed(const int length) } seed[counter] = ch; } - seed[counter] = '\0'; + seed[length] = '\0'; return seed; } @@ -141,7 +142,8 @@ SDLTest_GenerateExecKey(char *runSeed, char *suiteName, char *testName, int iter entireStringLength = runSeedLength + suiteNameLength + testNameLength + iterationStringLength + 1; buffer = (char *)SDL_malloc(entireStringLength); if (buffer == NULL) { - SDLTest_LogError("SDL_malloc failed to allocate buffer for execKey generation."); + SDLTest_LogError("Failed to allocate buffer for execKey generation."); + SDL_Error(SDL_ENOMEM); return 0; } SDL_snprintf(buffer, entireStringLength, "%s%s%s%d", runSeed, suiteName, testName, iteration); @@ -347,7 +349,7 @@ float GetClock() } /** -* \brief Execute a test suite using the given run seend and execution key. +* \brief Execute a test suite using the given run seed and execution key. * * The filter string is matched to the suite name (full comparison) to select a single suite, * or if no suite matches, it is matched to the test names (full comparison) to select a single test. @@ -362,6 +364,8 @@ float GetClock() */ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations) { + int totalNumberOfTests = 0; + int failedNumberOfTests = 0; int suiteCounter; int testCounter; int iterationCounter; @@ -392,6 +396,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user Uint32 testSkippedCount = 0; Uint32 countSum = 0; char *logFormat = (char *)SDLTest_LogSummaryFormat; + SDLTest_TestCaseReference **failedTests; /* Sanitize test iterations */ if (testIterations < 1) { @@ -421,6 +426,27 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user /* Log run with fuzzer parameters */ SDLTest_Log("::::: Test Run /w seed '%s' started\n", runSeed); + /* Count the total number of tests */ + suiteCounter = 0; + while (testSuites[suiteCounter]) { + testSuite=(SDLTest_TestSuiteReference *)testSuites[suiteCounter]; + suiteCounter++; + testCounter = 0; + while (testSuite->testCases[testCounter]) + { + testCounter++; + totalNumberOfTests++; + } + } + + /* Pre-allocate an array for tracking failed tests (potentially all test cases) */ + failedTests = (SDLTest_TestCaseReference **)SDL_malloc(totalNumberOfTests * sizeof(SDLTest_TestCaseReference *)); + if (failedTests == NULL) { + SDLTest_LogError("Unable to allocate cache for failed tests"); + SDL_Error(SDL_ENOMEM); + return -1; + } + /* Initialize filtering */ if (filter != NULL && filter[0] != '\0') { /* Loop over all suites to check if we have a filter match */ @@ -580,6 +606,11 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user break; } + /* Collect failed test case references for repro-step display */ + if (testResult == TEST_RESULT_FAILED) { + failedTests[failedNumberOfTests] = testCase; + failedNumberOfTests++; + } } } @@ -630,6 +661,15 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user SDLTest_LogError((char *)SDLTest_FinalResultFormat, "Run /w seed", runSeed, "Failed"); } + /* Print repro steps for failed tests */ + if (failedNumberOfTests > 0) { + SDLTest_Log("Harness input to repro failures:"); + for (testCounter = 0; testCounter < failedNumberOfTests; testCounter++) { + SDLTest_Log(" --seed %s --filter %s", runSeed, failedTests[testCounter]->name); + } + } + SDL_free(failedTests); + SDLTest_Log("Exit code: %d", runResult); return runResult; } diff --git a/jni/SDL2-2.0.1/src/test/SDL_test_imageBlit.c b/jni/SDL2-2.0.3/src/test/SDL_test_imageBlit.c similarity index 99% rename from jni/SDL2-2.0.1/src/test/SDL_test_imageBlit.c rename to jni/SDL2-2.0.3/src/test/SDL_test_imageBlit.c index d1d12952..d4c74fb4 100644 --- a/jni/SDL2-2.0.1/src/test/SDL_test_imageBlit.c +++ b/jni/SDL2-2.0.3/src/test/SDL_test_imageBlit.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/test/SDL_test_imageBlitBlend.c b/jni/SDL2-2.0.3/src/test/SDL_test_imageBlitBlend.c similarity index 99% rename from jni/SDL2-2.0.1/src/test/SDL_test_imageBlitBlend.c rename to jni/SDL2-2.0.3/src/test/SDL_test_imageBlitBlend.c index 06dbfabd..f849d730 100644 --- a/jni/SDL2-2.0.1/src/test/SDL_test_imageBlitBlend.c +++ b/jni/SDL2-2.0.3/src/test/SDL_test_imageBlitBlend.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/test/SDL_test_imageFace.c b/jni/SDL2-2.0.3/src/test/SDL_test_imageFace.c similarity index 99% rename from jni/SDL2-2.0.1/src/test/SDL_test_imageFace.c rename to jni/SDL2-2.0.3/src/test/SDL_test_imageFace.c index 46c117a4..74fa8341 100644 --- a/jni/SDL2-2.0.1/src/test/SDL_test_imageFace.c +++ b/jni/SDL2-2.0.3/src/test/SDL_test_imageFace.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/test/SDL_test_imagePrimitives.c b/jni/SDL2-2.0.3/src/test/SDL_test_imagePrimitives.c similarity index 99% rename from jni/SDL2-2.0.1/src/test/SDL_test_imagePrimitives.c rename to jni/SDL2-2.0.3/src/test/SDL_test_imagePrimitives.c index 93b99d69..d2aafcbe 100644 --- a/jni/SDL2-2.0.1/src/test/SDL_test_imagePrimitives.c +++ b/jni/SDL2-2.0.3/src/test/SDL_test_imagePrimitives.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/test/SDL_test_imagePrimitivesBlend.c b/jni/SDL2-2.0.3/src/test/SDL_test_imagePrimitivesBlend.c similarity index 99% rename from jni/SDL2-2.0.1/src/test/SDL_test_imagePrimitivesBlend.c rename to jni/SDL2-2.0.3/src/test/SDL_test_imagePrimitivesBlend.c index ce9adc51..cfe189a0 100644 --- a/jni/SDL2-2.0.1/src/test/SDL_test_imagePrimitivesBlend.c +++ b/jni/SDL2-2.0.3/src/test/SDL_test_imagePrimitivesBlend.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/test/SDL_test_log.c b/jni/SDL2-2.0.3/src/test/SDL_test_log.c similarity index 98% rename from jni/SDL2-2.0.1/src/test/SDL_test_log.c rename to jni/SDL2-2.0.3/src/test/SDL_test_log.c index caf3ddde..9a083074 100644 --- a/jni/SDL2-2.0.1/src/test/SDL_test_log.c +++ b/jni/SDL2-2.0.3/src/test/SDL_test_log.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/test/SDL_test_md5.c b/jni/SDL2-2.0.3/src/test/SDL_test_md5.c similarity index 99% rename from jni/SDL2-2.0.1/src/test/SDL_test_md5.c rename to jni/SDL2-2.0.3/src/test/SDL_test_md5.c index 3f42ed35..8467ccbc 100644 --- a/jni/SDL2-2.0.1/src/test/SDL_test_md5.c +++ b/jni/SDL2-2.0.3/src/test/SDL_test_md5.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/test/SDL_test_random.c b/jni/SDL2-2.0.3/src/test/SDL_test_random.c similarity index 97% rename from jni/SDL2-2.0.1/src/test/SDL_test_random.c rename to jni/SDL2-2.0.3/src/test/SDL_test_random.c index 2c70dbd4..bc434183 100644 --- a/jni/SDL2-2.0.1/src/test/SDL_test_random.c +++ b/jni/SDL2-2.0.3/src/test/SDL_test_random.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/SDL_systhread.h b/jni/SDL2-2.0.3/src/thread/SDL_systhread.h similarity index 97% rename from jni/SDL2-2.0.1/src/thread/SDL_systhread.h rename to jni/SDL2-2.0.3/src/thread/SDL_systhread.h index 82af6e42..9c9409a5 100644 --- a/jni/SDL2-2.0.1/src/thread/SDL_systhread.h +++ b/jni/SDL2-2.0.3/src/thread/SDL_systhread.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/SDL_thread.c b/jni/SDL2-2.0.3/src/thread/SDL_thread.c similarity index 99% rename from jni/SDL2-2.0.1/src/thread/SDL_thread.c rename to jni/SDL2-2.0.3/src/thread/SDL_thread.c index ce514892..6cd93331 100644 --- a/jni/SDL2-2.0.1/src/thread/SDL_thread.c +++ b/jni/SDL2-2.0.3/src/thread/SDL_thread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/SDL_thread_c.h b/jni/SDL2-2.0.3/src/thread/SDL_thread_c.h similarity index 95% rename from jni/SDL2-2.0.1/src/thread/SDL_thread_c.h rename to jni/SDL2-2.0.3/src/thread/SDL_thread_c.h index b6e0eebf..85ef5cce 100644 --- a/jni/SDL2-2.0.1/src/thread/SDL_thread_c.h +++ b/jni/SDL2-2.0.3/src/thread/SDL_thread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -34,6 +34,8 @@ #include "windows/SDL_systhread_c.h" #elif SDL_THREAD_PSP #include "psp/SDL_systhread_c.h" +#elif SDL_THREAD_STDCPP +#include "stdcpp/SDL_systhread_c.h" #else #error Need thread implementation for this platform #include "generic/SDL_systhread_c.h" diff --git a/jni/SDL2-2.0.1/src/thread/generic/SDL_syscond.c b/jni/SDL2-2.0.3/src/thread/generic/SDL_syscond.c similarity index 99% rename from jni/SDL2-2.0.1/src/thread/generic/SDL_syscond.c rename to jni/SDL2-2.0.3/src/thread/generic/SDL_syscond.c index 90fe4eac..64cc6340 100644 --- a/jni/SDL2-2.0.1/src/thread/generic/SDL_syscond.c +++ b/jni/SDL2-2.0.3/src/thread/generic/SDL_syscond.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/generic/SDL_sysmutex.c b/jni/SDL2-2.0.3/src/thread/generic/SDL_sysmutex.c similarity index 98% rename from jni/SDL2-2.0.1/src/thread/generic/SDL_sysmutex.c rename to jni/SDL2-2.0.3/src/thread/generic/SDL_sysmutex.c index f2a567c6..ddcc8cdf 100644 --- a/jni/SDL2-2.0.1/src/thread/generic/SDL_sysmutex.c +++ b/jni/SDL2-2.0.3/src/thread/generic/SDL_sysmutex.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/generic/SDL_sysmutex_c.h b/jni/SDL2-2.0.3/src/thread/generic/SDL_sysmutex_c.h similarity index 94% rename from jni/SDL2-2.0.1/src/thread/generic/SDL_sysmutex_c.h rename to jni/SDL2-2.0.3/src/thread/generic/SDL_sysmutex_c.h index 6a3a8015..f868fade 100644 --- a/jni/SDL2-2.0.1/src/thread/generic/SDL_sysmutex_c.h +++ b/jni/SDL2-2.0.3/src/thread/generic/SDL_sysmutex_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/generic/SDL_syssem.c b/jni/SDL2-2.0.3/src/thread/generic/SDL_syssem.c similarity index 98% rename from jni/SDL2-2.0.1/src/thread/generic/SDL_syssem.c rename to jni/SDL2-2.0.3/src/thread/generic/SDL_syssem.c index 71b191bb..c7220a2a 100644 --- a/jni/SDL2-2.0.1/src/thread/generic/SDL_syssem.c +++ b/jni/SDL2-2.0.3/src/thread/generic/SDL_syssem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/generic/SDL_systhread.c b/jni/SDL2-2.0.3/src/thread/generic/SDL_systhread.c similarity index 96% rename from jni/SDL2-2.0.1/src/thread/generic/SDL_systhread.c rename to jni/SDL2-2.0.3/src/thread/generic/SDL_systhread.c index 22b04d41..6cd29f76 100644 --- a/jni/SDL2-2.0.1/src/thread/generic/SDL_systhread.c +++ b/jni/SDL2-2.0.3/src/thread/generic/SDL_systhread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/generic/SDL_systhread_c.h b/jni/SDL2-2.0.3/src/thread/generic/SDL_systhread_c.h similarity index 94% rename from jni/SDL2-2.0.1/src/thread/generic/SDL_systhread_c.h rename to jni/SDL2-2.0.3/src/thread/generic/SDL_systhread_c.h index afabbc79..38e8b208 100644 --- a/jni/SDL2-2.0.1/src/thread/generic/SDL_systhread_c.h +++ b/jni/SDL2-2.0.3/src/thread/generic/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/generic/SDL_systls.c b/jni/SDL2-2.0.3/src/thread/generic/SDL_systls.c similarity index 95% rename from jni/SDL2-2.0.1/src/thread/generic/SDL_systls.c rename to jni/SDL2-2.0.3/src/thread/generic/SDL_systls.c index 60161389..b73d901f 100644 --- a/jni/SDL2-2.0.1/src/thread/generic/SDL_systls.c +++ b/jni/SDL2-2.0.3/src/thread/generic/SDL_systls.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/psp/SDL_syscond.c b/jni/SDL2-2.0.3/src/thread/psp/SDL_syscond.c similarity index 99% rename from jni/SDL2-2.0.1/src/thread/psp/SDL_syscond.c rename to jni/SDL2-2.0.3/src/thread/psp/SDL_syscond.c index 3bdcc2fd..1abd9a3d 100644 --- a/jni/SDL2-2.0.1/src/thread/psp/SDL_syscond.c +++ b/jni/SDL2-2.0.3/src/thread/psp/SDL_syscond.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/psp/SDL_sysmutex.c b/jni/SDL2-2.0.3/src/thread/psp/SDL_sysmutex.c similarity index 98% rename from jni/SDL2-2.0.1/src/thread/psp/SDL_sysmutex.c rename to jni/SDL2-2.0.3/src/thread/psp/SDL_sysmutex.c index 731a2de6..478575b3 100644 --- a/jni/SDL2-2.0.1/src/thread/psp/SDL_sysmutex.c +++ b/jni/SDL2-2.0.3/src/thread/psp/SDL_sysmutex.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/psp/SDL_sysmutex_c.h b/jni/SDL2-2.0.3/src/thread/psp/SDL_sysmutex_c.h similarity index 94% rename from jni/SDL2-2.0.1/src/thread/psp/SDL_sysmutex_c.h rename to jni/SDL2-2.0.3/src/thread/psp/SDL_sysmutex_c.h index 6a3a8015..f868fade 100644 --- a/jni/SDL2-2.0.1/src/thread/psp/SDL_sysmutex_c.h +++ b/jni/SDL2-2.0.3/src/thread/psp/SDL_sysmutex_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/psp/SDL_syssem.c b/jni/SDL2-2.0.3/src/thread/psp/SDL_syssem.c similarity index 98% rename from jni/SDL2-2.0.1/src/thread/psp/SDL_syssem.c rename to jni/SDL2-2.0.3/src/thread/psp/SDL_syssem.c index 8eff409e..27d3251a 100644 --- a/jni/SDL2-2.0.1/src/thread/psp/SDL_syssem.c +++ b/jni/SDL2-2.0.3/src/thread/psp/SDL_syssem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/psp/SDL_systhread.c b/jni/SDL2-2.0.3/src/thread/psp/SDL_systhread.c similarity index 97% rename from jni/SDL2-2.0.1/src/thread/psp/SDL_systhread.c rename to jni/SDL2-2.0.3/src/thread/psp/SDL_systhread.c index 269defe4..d2fbeeb2 100644 --- a/jni/SDL2-2.0.1/src/thread/psp/SDL_systhread.c +++ b/jni/SDL2-2.0.3/src/thread/psp/SDL_systhread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/psp/SDL_systhread_c.h b/jni/SDL2-2.0.3/src/thread/psp/SDL_systhread_c.h similarity index 94% rename from jni/SDL2-2.0.1/src/thread/psp/SDL_systhread_c.h rename to jni/SDL2-2.0.3/src/thread/psp/SDL_systhread_c.h index a806edec..4f9dac24 100644 --- a/jni/SDL2-2.0.1/src/thread/psp/SDL_systhread_c.h +++ b/jni/SDL2-2.0.3/src/thread/psp/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/pthread/SDL_syscond.c b/jni/SDL2-2.0.3/src/thread/pthread/SDL_syscond.c similarity index 98% rename from jni/SDL2-2.0.1/src/thread/pthread/SDL_syscond.c rename to jni/SDL2-2.0.3/src/thread/pthread/SDL_syscond.c index 32342bf1..c15df863 100644 --- a/jni/SDL2-2.0.1/src/thread/pthread/SDL_syscond.c +++ b/jni/SDL2-2.0.3/src/thread/pthread/SDL_syscond.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/pthread/SDL_sysmutex.c b/jni/SDL2-2.0.3/src/thread/pthread/SDL_sysmutex.c similarity index 98% rename from jni/SDL2-2.0.1/src/thread/pthread/SDL_sysmutex.c rename to jni/SDL2-2.0.3/src/thread/pthread/SDL_sysmutex.c index b18d8fc0..36bf394c 100644 --- a/jni/SDL2-2.0.1/src/thread/pthread/SDL_sysmutex.c +++ b/jni/SDL2-2.0.3/src/thread/pthread/SDL_sysmutex.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/pthread/SDL_sysmutex_c.h b/jni/SDL2-2.0.3/src/thread/pthread/SDL_sysmutex_c.h similarity index 94% rename from jni/SDL2-2.0.1/src/thread/pthread/SDL_sysmutex_c.h rename to jni/SDL2-2.0.3/src/thread/pthread/SDL_sysmutex_c.h index d99b0940..bf69bcd1 100644 --- a/jni/SDL2-2.0.1/src/thread/pthread/SDL_sysmutex_c.h +++ b/jni/SDL2-2.0.3/src/thread/pthread/SDL_sysmutex_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/pthread/SDL_syssem.c b/jni/SDL2-2.0.3/src/thread/pthread/SDL_syssem.c similarity index 98% rename from jni/SDL2-2.0.1/src/thread/pthread/SDL_syssem.c rename to jni/SDL2-2.0.3/src/thread/pthread/SDL_syssem.c index 4194b966..358baff2 100644 --- a/jni/SDL2-2.0.1/src/thread/pthread/SDL_syssem.c +++ b/jni/SDL2-2.0.3/src/thread/pthread/SDL_syssem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/pthread/SDL_systhread.c b/jni/SDL2-2.0.3/src/thread/pthread/SDL_systhread.c similarity index 99% rename from jni/SDL2-2.0.1/src/thread/pthread/SDL_systhread.c rename to jni/SDL2-2.0.3/src/thread/pthread/SDL_systhread.c index 08bd182d..b570b2ab 100644 --- a/jni/SDL2-2.0.1/src/thread/pthread/SDL_systhread.c +++ b/jni/SDL2-2.0.3/src/thread/pthread/SDL_systhread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/pthread/SDL_systhread_c.h b/jni/SDL2-2.0.3/src/thread/pthread/SDL_systhread_c.h similarity index 94% rename from jni/SDL2-2.0.1/src/thread/pthread/SDL_systhread_c.h rename to jni/SDL2-2.0.3/src/thread/pthread/SDL_systhread_c.h index c5699c46..eedb7d1f 100644 --- a/jni/SDL2-2.0.1/src/thread/pthread/SDL_systhread_c.h +++ b/jni/SDL2-2.0.3/src/thread/pthread/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/pthread/SDL_systls.c b/jni/SDL2-2.0.3/src/thread/pthread/SDL_systls.c similarity index 97% rename from jni/SDL2-2.0.1/src/thread/pthread/SDL_systls.c rename to jni/SDL2-2.0.3/src/thread/pthread/SDL_systls.c index cce8754c..09a27904 100644 --- a/jni/SDL2-2.0.1/src/thread/pthread/SDL_systls.c +++ b/jni/SDL2-2.0.3/src/thread/pthread/SDL_systls.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.3/src/thread/stdcpp/SDL_syscond.cpp b/jni/SDL2-2.0.3/src/thread/stdcpp/SDL_syscond.cpp new file mode 100644 index 00000000..e9da82a3 --- /dev/null +++ b/jni/SDL2-2.0.3/src/thread/stdcpp/SDL_syscond.cpp @@ -0,0 +1,164 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +extern "C" { +#include "SDL_thread.h" +} + +#include +#include +#include +#include + +#include "SDL_sysmutex_c.h" + +struct SDL_cond +{ + std::condition_variable_any cpp_cond; +}; + +/* Create a condition variable */ +extern "C" +SDL_cond * +SDL_CreateCond(void) +{ + /* Allocate and initialize the condition variable */ + try { + SDL_cond * cond = new SDL_cond; + return cond; + } catch (std::system_error & ex) { + SDL_SetError("unable to create a C++ condition variable: code=%d; %s", ex.code(), ex.what()); + return NULL; + } catch (std::bad_alloc &) { + SDL_OutOfMemory(); + return NULL; + } +} + +/* Destroy a condition variable */ +extern "C" +void +SDL_DestroyCond(SDL_cond * cond) +{ + if (cond) { + delete cond; + } +} + +/* Restart one of the threads that are waiting on the condition variable */ +extern "C" +int +SDL_CondSignal(SDL_cond * cond) +{ + if (!cond) { + SDL_SetError("Passed a NULL condition variable"); + return -1; + } + + cond->cpp_cond.notify_one(); + return 0; +} + +/* Restart all threads that are waiting on the condition variable */ +extern "C" +int +SDL_CondBroadcast(SDL_cond * cond) +{ + if (!cond) { + SDL_SetError("Passed a NULL condition variable"); + return -1; + } + + cond->cpp_cond.notify_all(); + return 0; +} + +/* Wait on the condition variable for at most 'ms' milliseconds. + The mutex must be locked before entering this function! + The mutex is unlocked during the wait, and locked again after the wait. + +Typical use: + +Thread A: + SDL_LockMutex(lock); + while ( ! condition ) { + SDL_CondWait(cond, lock); + } + SDL_UnlockMutex(lock); + +Thread B: + SDL_LockMutex(lock); + ... + condition = true; + ... + SDL_CondSignal(cond); + SDL_UnlockMutex(lock); + */ +extern "C" +int +SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) +{ + if (!cond) { + SDL_SetError("Passed a NULL condition variable"); + return -1; + } + + if (!mutex) { + SDL_SetError("Passed a NULL mutex variable"); + return -1; + } + + try { + std::unique_lock cpp_lock(mutex->cpp_mutex, std::defer_lock_t()); + if (ms == SDL_MUTEX_MAXWAIT) { + cond->cpp_cond.wait( + cpp_lock + ); + cpp_lock.release(); + return 0; + } else { + auto wait_result = cond->cpp_cond.wait_for( + cpp_lock, + std::chrono::duration(ms) + ); + cpp_lock.release(); + if (wait_result == std::cv_status::timeout) { + return SDL_MUTEX_TIMEDOUT; + } else { + return 0; + } + } + } catch (std::system_error & ex) { + SDL_SetError("unable to wait on a C++ condition variable: code=%d; %s", ex.code(), ex.what()); + return -1; + } +} + +/* Wait on the condition variable forever */ +extern "C" +int +SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) +{ + return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT); +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/thread/stdcpp/SDL_sysmutex.cpp b/jni/SDL2-2.0.3/src/thread/stdcpp/SDL_sysmutex.cpp new file mode 100644 index 00000000..4b60fb1d --- /dev/null +++ b/jni/SDL2-2.0.3/src/thread/stdcpp/SDL_sysmutex.cpp @@ -0,0 +1,111 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +extern "C" { +#include "SDL_thread.h" +#include "SDL_systhread_c.h" +#include "SDL_log.h" +} + +#include + +#include "SDL_sysmutex_c.h" +#include + + +/* Create a mutex */ +extern "C" +SDL_mutex * +SDL_CreateMutex(void) +{ + /* Allocate and initialize the mutex */ + try { + SDL_mutex * mutex = new SDL_mutex; + return mutex; + } catch (std::system_error & ex) { + SDL_SetError("unable to create a C++ mutex: code=%d; %s", ex.code(), ex.what()); + return NULL; + } catch (std::bad_alloc &) { + SDL_OutOfMemory(); + return NULL; + } +} + +/* Free the mutex */ +extern "C" +void +SDL_DestroyMutex(SDL_mutex * mutex) +{ + if (mutex) { + delete mutex; + } +} + +/* Lock the semaphore */ +extern "C" +int +SDL_mutexP(SDL_mutex * mutex) +{ + if (mutex == NULL) { + SDL_SetError("Passed a NULL mutex"); + return -1; + } + + try { + mutex->cpp_mutex.lock(); + return 0; + } catch (std::system_error & ex) { + SDL_SetError("unable to lock a C++ mutex: code=%d; %s", ex.code(), ex.what()); + return -1; + } +} + +/* TryLock the mutex */ +int +SDL_TryLockMutex(SDL_mutex * mutex) +{ + int retval = 0; + if (mutex == NULL) { + return SDL_SetError("Passed a NULL mutex"); + } + + if (mutex->cpp_mutex.try_lock() == false) { + retval = SDL_MUTEX_TIMEDOUT; + } + return retval; +} + +/* Unlock the mutex */ +extern "C" +int +SDL_mutexV(SDL_mutex * mutex) +{ + if (mutex == NULL) { + SDL_SetError("Passed a NULL mutex"); + return -1; + } + + mutex->cpp_mutex.unlock(); + return 0; +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/thread/stdcpp/SDL_sysmutex_c.h b/jni/SDL2-2.0.3/src/thread/stdcpp/SDL_sysmutex_c.h new file mode 100644 index 00000000..6bbd9dcd --- /dev/null +++ b/jni/SDL2-2.0.3/src/thread/stdcpp/SDL_sysmutex_c.h @@ -0,0 +1,30 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#include + +struct SDL_mutex +{ + std::recursive_mutex cpp_mutex; +}; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/thread/stdcpp/SDL_systhread.cpp b/jni/SDL2-2.0.3/src/thread/stdcpp/SDL_systhread.cpp new file mode 100644 index 00000000..5de700ab --- /dev/null +++ b/jni/SDL2-2.0.3/src/thread/stdcpp/SDL_systhread.cpp @@ -0,0 +1,167 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +/* Thread management routines for SDL */ + +extern "C" { +#include "SDL_thread.h" +#include "../SDL_thread_c.h" +#include "../SDL_systhread.h" +#include "SDL_log.h" +} + +#include +#include +#include + +#ifdef __WINRT__ +#include +#endif + +static void +RunThread(void *args) +{ + SDL_RunThread(args); +} + +extern "C" +int +SDL_SYS_CreateThread(SDL_Thread * thread, void *args) +{ + try { + std::thread cpp_thread(RunThread, args); + thread->handle = (void *) new std::thread(std::move(cpp_thread)); + return 0; + } catch (std::system_error & ex) { + SDL_SetError("unable to start a C++ thread: code=%d; %s", ex.code(), ex.what()); + return -1; + } catch (std::bad_alloc &) { + SDL_OutOfMemory(); + return -1; + } +} + +extern "C" +void +SDL_SYS_SetupThread(const char *name) +{ + // Make sure a thread ID gets assigned ASAP, for debugging purposes: + SDL_ThreadID(); + return; +} + +extern "C" +SDL_threadID +SDL_ThreadID(void) +{ +#ifdef __WINRT__ + return GetCurrentThreadId(); +#else + // HACK: Mimick a thread ID, if one isn't otherwise available. + static thread_local SDL_threadID current_thread_id = 0; + static SDL_threadID next_thread_id = 1; + static std::mutex next_thread_id_mutex; + + if (current_thread_id == 0) { + std::lock_guard lock(next_thread_id_mutex); + current_thread_id = next_thread_id; + ++next_thread_id; + } + + return current_thread_id; +#endif +} + +extern "C" +int +SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) +{ + // Thread priorities do not look to be settable via C++11's thread + // interface, at least as of this writing (Nov 2012). std::thread does + // provide access to the OS' native handle, however, and some form of + // priority-setting could, in theory, be done through this interface. + // + // WinRT: UPDATE (Aug 20, 2013): thread priorities cannot be changed + // on WinRT, at least not for any thread that's already been created. + // WinRT threads appear to be based off of the WinRT class, + // ThreadPool, more info on which can be found at: + // http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.threading.threadpool.aspx + // + // For compatibility sake, 0 will be returned here. + return (0); +} + +extern "C" +void +SDL_SYS_WaitThread(SDL_Thread * thread) +{ + if ( ! thread) { + return; + } + + try { + std::thread * cpp_thread = (std::thread *) thread->handle; + if (cpp_thread->joinable()) { + cpp_thread->join(); + } + } catch (std::system_error &) { + // An error occurred when joining the thread. SDL_WaitThread does not, + // however, seem to provide a means to report errors to its callers + // though! + } +} + +extern "C" +void +SDL_SYS_DetachThread(SDL_Thread * thread) +{ + if ( ! thread) { + return; + } + + try { + std::thread * cpp_thread = (std::thread *) thread->handle; + if (cpp_thread->joinable()) { + cpp_thread->detach(); + } + } catch (std::system_error &) { + // An error occurred when detaching the thread. SDL_DetachThread does not, + // however, seem to provide a means to report errors to its callers + // though! + } +} + +extern "C" +SDL_TLSData * +SDL_SYS_GetTLSData() +{ + return SDL_Generic_GetTLSData(); +} + +extern "C" +int +SDL_SYS_SetTLSData(SDL_TLSData *data) +{ + return SDL_Generic_SetTLSData(data); +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/thread/stdcpp/SDL_systhread_c.h b/jni/SDL2-2.0.3/src/thread/stdcpp/SDL_systhread_c.h new file mode 100644 index 00000000..a0a338f5 --- /dev/null +++ b/jni/SDL2-2.0.3/src/thread/stdcpp/SDL_systhread_c.h @@ -0,0 +1,26 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +/* For a thread handle, use a void pointer to a std::thread */ +typedef void * SYS_ThreadHandle; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.1/src/thread/windows/SDL_sysmutex.c b/jni/SDL2-2.0.3/src/thread/windows/SDL_sysmutex.c similarity index 97% rename from jni/SDL2-2.0.1/src/thread/windows/SDL_sysmutex.c rename to jni/SDL2-2.0.3/src/thread/windows/SDL_sysmutex.c index 17e9257d..8333e11b 100644 --- a/jni/SDL2-2.0.1/src/thread/windows/SDL_sysmutex.c +++ b/jni/SDL2-2.0.3/src/thread/windows/SDL_sysmutex.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/windows/SDL_syssem.c b/jni/SDL2-2.0.3/src/thread/windows/SDL_syssem.c similarity index 98% rename from jni/SDL2-2.0.1/src/thread/windows/SDL_syssem.c rename to jni/SDL2-2.0.3/src/thread/windows/SDL_syssem.c index 7f178b7b..a4f75f5c 100644 --- a/jni/SDL2-2.0.1/src/thread/windows/SDL_syssem.c +++ b/jni/SDL2-2.0.3/src/thread/windows/SDL_syssem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/windows/SDL_systhread.c b/jni/SDL2-2.0.3/src/thread/windows/SDL_systhread.c similarity index 99% rename from jni/SDL2-2.0.1/src/thread/windows/SDL_systhread.c rename to jni/SDL2-2.0.3/src/thread/windows/SDL_systhread.c index 3972ffdf..79c40b16 100644 --- a/jni/SDL2-2.0.1/src/thread/windows/SDL_systhread.c +++ b/jni/SDL2-2.0.3/src/thread/windows/SDL_systhread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/windows/SDL_systhread_c.h b/jni/SDL2-2.0.3/src/thread/windows/SDL_systhread_c.h similarity index 94% rename from jni/SDL2-2.0.1/src/thread/windows/SDL_systhread_c.h rename to jni/SDL2-2.0.3/src/thread/windows/SDL_systhread_c.h index e346f433..f3c78e99 100644 --- a/jni/SDL2-2.0.1/src/thread/windows/SDL_systhread_c.h +++ b/jni/SDL2-2.0.3/src/thread/windows/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/thread/windows/SDL_systls.c b/jni/SDL2-2.0.3/src/thread/windows/SDL_systls.c similarity index 97% rename from jni/SDL2-2.0.1/src/thread/windows/SDL_systls.c rename to jni/SDL2-2.0.3/src/thread/windows/SDL_systls.c index 6a82d2f8..6ceadaa1 100644 --- a/jni/SDL2-2.0.1/src/thread/windows/SDL_systls.c +++ b/jni/SDL2-2.0.3/src/thread/windows/SDL_systls.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/timer/SDL_timer.c b/jni/SDL2-2.0.3/src/timer/SDL_timer.c similarity index 99% rename from jni/SDL2-2.0.1/src/timer/SDL_timer.c rename to jni/SDL2-2.0.3/src/timer/SDL_timer.c index 3996b360..3ec1291b 100644 --- a/jni/SDL2-2.0.1/src/timer/SDL_timer.c +++ b/jni/SDL2-2.0.3/src/timer/SDL_timer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/timer/SDL_timer_c.h b/jni/SDL2-2.0.3/src/timer/SDL_timer_c.h similarity index 90% rename from jni/SDL2-2.0.1/src/timer/SDL_timer_c.h rename to jni/SDL2-2.0.3/src/timer/SDL_timer_c.h index 6fe0679c..8d563cff 100644 --- a/jni/SDL2-2.0.1/src/timer/SDL_timer_c.h +++ b/jni/SDL2-2.0.3/src/timer/SDL_timer_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -26,7 +26,8 @@ #define ROUND_RESOLUTION(X) \ (((X+TIMER_RESOLUTION-1)/TIMER_RESOLUTION)*TIMER_RESOLUTION) -extern void SDL_InitTicks(void); +extern void SDL_TicksInit(void); +extern void SDL_TicksQuit(void); extern int SDL_TimerInit(void); extern void SDL_TimerQuit(void); diff --git a/jni/SDL2-2.0.1/src/timer/dummy/SDL_systimer.c b/jni/SDL2-2.0.3/src/timer/dummy/SDL_systimer.c similarity index 90% rename from jni/SDL2-2.0.1/src/timer/dummy/SDL_systimer.c rename to jni/SDL2-2.0.3/src/timer/dummy/SDL_systimer.c index 828610a6..57899ae9 100644 --- a/jni/SDL2-2.0.1/src/timer/dummy/SDL_systimer.c +++ b/jni/SDL2-2.0.3/src/timer/dummy/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -27,7 +27,7 @@ static SDL_bool ticks_started = SDL_FALSE; void -SDL_InitTicks(void) +SDL_TicksInit(void) { if (ticks_started) { return; @@ -35,11 +35,17 @@ SDL_InitTicks(void) ticks_started = SDL_TRUE; } +void +SDL_TicksQuit(void) +{ + ticks_started = SDL_FALSE; +} + Uint32 SDL_GetTicks(void) { if (!ticks_started) { - SDL_InitTicks(); + SDL_TicksInit(); } SDL_Unsupported(); diff --git a/jni/SDL2-2.0.1/src/timer/haiku/SDL_systimer.c b/jni/SDL2-2.0.3/src/timer/haiku/SDL_systimer.c similarity index 90% rename from jni/SDL2-2.0.1/src/timer/haiku/SDL_systimer.c rename to jni/SDL2-2.0.3/src/timer/haiku/SDL_systimer.c index 213682b3..685f72a8 100644 --- a/jni/SDL2-2.0.1/src/timer/haiku/SDL_systimer.c +++ b/jni/SDL2-2.0.3/src/timer/haiku/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -30,7 +30,7 @@ static bigtime_t start; static SDL_bool ticks_started = SDL_FALSE; void -SDL_InitTicks(void) +SDL_TicksInit(void) { if (ticks_started) { return; @@ -41,11 +41,17 @@ SDL_InitTicks(void) start = system_time(); } +void +SDL_TicksQuit(void) +{ + ticks_started = SDL_FALSE; +} + Uint32 SDL_GetTicks(void) { if (!ticks_started) { - SDL_InitTicks(); + SDL_TicksInit(); } return ((system_time() - start) / 1000); diff --git a/jni/SDL2-2.0.1/src/timer/psp/SDL_systimer.c b/jni/SDL2-2.0.3/src/timer/psp/SDL_systimer.c similarity index 91% rename from jni/SDL2-2.0.1/src/timer/psp/SDL_systimer.c rename to jni/SDL2-2.0.3/src/timer/psp/SDL_systimer.c index 61c4690a..b706f449 100644 --- a/jni/SDL2-2.0.1/src/timer/psp/SDL_systimer.c +++ b/jni/SDL2-2.0.3/src/timer/psp/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -31,7 +31,8 @@ static struct timeval start; static SDL_bool ticks_started = SDL_FALSE; -void SDL_InitTicks(void) +void +SDL_TicksInit(void) { if (ticks_started) { return; @@ -41,10 +42,16 @@ void SDL_InitTicks(void) gettimeofday(&start, NULL); } +void +SDL_TicksQuit(void) +{ + ticks_started = SDL_FALSE; +} + Uint32 SDL_GetTicks(void) { if (!ticks_started) { - SDL_InitTicks(); + SDL_TicksInit(); } struct timeval now; diff --git a/jni/SDL2-2.0.1/src/timer/unix/SDL_systimer.c b/jni/SDL2-2.0.3/src/timer/unix/SDL_systimer.c similarity index 96% rename from jni/SDL2-2.0.1/src/timer/unix/SDL_systimer.c rename to jni/SDL2-2.0.3/src/timer/unix/SDL_systimer.c index 1d9636a6..0f4c7571 100644 --- a/jni/SDL2-2.0.1/src/timer/unix/SDL_systimer.c +++ b/jni/SDL2-2.0.3/src/timer/unix/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -59,7 +59,7 @@ static struct timeval start_tv; static SDL_bool ticks_started = SDL_FALSE; void -SDL_InitTicks(void) +SDL_TicksInit(void) { if (ticks_started) { return; @@ -83,12 +83,18 @@ SDL_InitTicks(void) } } +void +SDL_TicksQuit(void) +{ + ticks_started = SDL_FALSE; +} + Uint32 SDL_GetTicks(void) { Uint32 ticks; if (!ticks_started) { - SDL_InitTicks(); + SDL_TicksInit(); } if (has_monotonic_time) { @@ -117,7 +123,7 @@ SDL_GetPerformanceCounter(void) { Uint64 ticks; if (!ticks_started) { - SDL_InitTicks(); + SDL_TicksInit(); } if (has_monotonic_time) { @@ -146,7 +152,7 @@ Uint64 SDL_GetPerformanceFrequency(void) { if (!ticks_started) { - SDL_InitTicks(); + SDL_TicksInit(); } if (has_monotonic_time) { diff --git a/jni/SDL2-2.0.1/src/timer/windows/SDL_systimer.c b/jni/SDL2-2.0.3/src/timer/windows/SDL_systimer.c similarity index 77% rename from jni/SDL2-2.0.1/src/timer/windows/SDL_systimer.c rename to jni/SDL2-2.0.3/src/timer/windows/SDL_systimer.c index ebe4272e..07561636 100644 --- a/jni/SDL2-2.0.1/src/timer/windows/SDL_systimer.c +++ b/jni/SDL2-2.0.3/src/timer/windows/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -40,8 +40,8 @@ static BOOL hires_timer_available; static LARGE_INTEGER hires_start_ticks; /* The number of ticks per second of the high-resolution performance counter */ static LARGE_INTEGER hires_ticks_per_second; -#endif +#ifndef __WINRT__ static void timeSetPeriod(UINT uPeriod) { @@ -75,14 +75,17 @@ SDL_TimerResolutionChanged(void *userdata, const char *name, const char *oldValu timeSetPeriod(uPeriod); } } +#endif /* ifndef __WINRT__ */ + +#endif /* !USE_GETTICKCOUNT */ void -SDL_InitTicks(void) +SDL_TicksInit(void) { if (ticks_started) { return; } - ticks_started = TRUE; + ticks_started = SDL_TRUE; /* Set first ticks value */ #ifdef USE_GETTICKCOUNT @@ -96,13 +99,34 @@ SDL_InitTicks(void) QueryPerformanceCounter(&hires_start_ticks); } else { hires_timer_available = FALSE; +#ifdef __WINRT__ + start = 0; /* the timer failed to start! */ +#else timeSetPeriod(1); /* use 1 ms timer precision */ start = timeGetTime(); - } -#endif - SDL_AddHintCallback(SDL_HINT_TIMER_RESOLUTION, - SDL_TimerResolutionChanged, NULL); + SDL_AddHintCallback(SDL_HINT_TIMER_RESOLUTION, + SDL_TimerResolutionChanged, NULL); +#endif /* __WINRT__ */ + } +#endif /* USE_GETTICKCOUNT */ +} + +void +SDL_TicksQuit(void) +{ +#ifndef USE_GETTICKCOUNT + if (!hires_timer_available) { +#ifndef __WINRT__ + SDL_DelHintCallback(SDL_HINT_TIMER_RESOLUTION, + SDL_TimerResolutionChanged, NULL); + + timeSetPeriod(0); +#endif /* __WINRT__ */ + } +#endif /* USE_GETTICKCOUNT */ + + ticks_started = SDL_FALSE; } Uint32 @@ -114,7 +138,7 @@ SDL_GetTicks(void) #endif if (!ticks_started) { - SDL_InitTicks(); + SDL_TicksInit(); } #ifdef USE_GETTICKCOUNT @@ -129,7 +153,11 @@ SDL_GetTicks(void) return (DWORD) hires_now.QuadPart; } else { +#ifdef __WINRT__ + now = 0; +#else now = timeGetTime(); +#endif /* __WINRT__ */ } #endif @@ -158,6 +186,19 @@ SDL_GetPerformanceFrequency(void) return frequency.QuadPart; } +#ifdef __WINRT__ +static void +Sleep(DWORD timeout) +{ + static HANDLE mutex = 0; + if ( ! mutex ) + { + mutex = CreateEventEx(0, 0, 0, EVENT_ALL_ACCESS); + } + WaitForSingleObjectEx(mutex, timeout, FALSE); +} +#endif + void SDL_Delay(Uint32 ms) { diff --git a/jni/SDL2-2.0.1/src/video/SDL_RLEaccel.c b/jni/SDL2-2.0.3/src/video/SDL_RLEaccel.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/SDL_RLEaccel.c rename to jni/SDL2-2.0.3/src/video/SDL_RLEaccel.c index e8bfca71..a464dec3 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_RLEaccel.c +++ b/jni/SDL2-2.0.3/src/video/SDL_RLEaccel.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_RLEaccel_c.h b/jni/SDL2-2.0.3/src/video/SDL_RLEaccel_c.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/SDL_RLEaccel_c.h rename to jni/SDL2-2.0.3/src/video/SDL_RLEaccel_c.h index 69bfa0d8..271faa0b 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_RLEaccel_c.h +++ b/jni/SDL2-2.0.3/src/video/SDL_RLEaccel_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_blit.c b/jni/SDL2-2.0.3/src/video/SDL_blit.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/SDL_blit.c rename to jni/SDL2-2.0.3/src/video/SDL_blit.c index 00bb2e1a..fe30923b 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_blit.c +++ b/jni/SDL2-2.0.3/src/video/SDL_blit.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_blit.h b/jni/SDL2-2.0.3/src/video/SDL_blit.h similarity index 99% rename from jni/SDL2-2.0.1/src/video/SDL_blit.h rename to jni/SDL2-2.0.3/src/video/SDL_blit.h index 8eb47e17..caf6c00f 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_blit.h +++ b/jni/SDL2-2.0.3/src/video/SDL_blit.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_blit_0.c b/jni/SDL2-2.0.3/src/video/SDL_blit_0.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/SDL_blit_0.c rename to jni/SDL2-2.0.3/src/video/SDL_blit_0.c index 3f413446..a820fb37 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_blit_0.c +++ b/jni/SDL2-2.0.3/src/video/SDL_blit_0.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_blit_1.c b/jni/SDL2-2.0.3/src/video/SDL_blit_1.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/SDL_blit_1.c rename to jni/SDL2-2.0.3/src/video/SDL_blit_1.c index a129ca94..4dfcabda 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_blit_1.c +++ b/jni/SDL2-2.0.3/src/video/SDL_blit_1.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_blit_A.c b/jni/SDL2-2.0.3/src/video/SDL_blit_A.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/SDL_blit_A.c rename to jni/SDL2-2.0.3/src/video/SDL_blit_A.c index bb1f3d55..31bd0401 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_blit_A.c +++ b/jni/SDL2-2.0.3/src/video/SDL_blit_A.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_blit_N.c b/jni/SDL2-2.0.3/src/video/SDL_blit_N.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/SDL_blit_N.c rename to jni/SDL2-2.0.3/src/video/SDL_blit_N.c index 25610120..41615be5 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_blit_N.c +++ b/jni/SDL2-2.0.3/src/video/SDL_blit_N.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_blit_auto.c b/jni/SDL2-2.0.3/src/video/SDL_blit_auto.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/SDL_blit_auto.c rename to jni/SDL2-2.0.3/src/video/SDL_blit_auto.c index 1e6ff3cb..310839ca 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_blit_auto.c +++ b/jni/SDL2-2.0.3/src/video/SDL_blit_auto.c @@ -1,7 +1,7 @@ /* DO NOT EDIT! This file is generated by sdlgenblit.pl */ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_blit_auto.h b/jni/SDL2-2.0.3/src/video/SDL_blit_auto.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/SDL_blit_auto.h rename to jni/SDL2-2.0.3/src/video/SDL_blit_auto.h index 750c0a19..369e12fc 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_blit_auto.h +++ b/jni/SDL2-2.0.3/src/video/SDL_blit_auto.h @@ -1,7 +1,7 @@ /* DO NOT EDIT! This file is generated by sdlgenblit.pl */ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_blit_copy.c b/jni/SDL2-2.0.3/src/video/SDL_blit_copy.c similarity index 98% rename from jni/SDL2-2.0.1/src/video/SDL_blit_copy.c rename to jni/SDL2-2.0.3/src/video/SDL_blit_copy.c index 556f9985..5c62d633 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_blit_copy.c +++ b/jni/SDL2-2.0.3/src/video/SDL_blit_copy.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_blit_copy.h b/jni/SDL2-2.0.3/src/video/SDL_blit_copy.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/SDL_blit_copy.h rename to jni/SDL2-2.0.3/src/video/SDL_blit_copy.h index 8d02a83b..8b6950ce 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_blit_copy.h +++ b/jni/SDL2-2.0.3/src/video/SDL_blit_copy.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_blit_slow.c b/jni/SDL2-2.0.3/src/video/SDL_blit_slow.c similarity index 98% rename from jni/SDL2-2.0.1/src/video/SDL_blit_slow.c rename to jni/SDL2-2.0.3/src/video/SDL_blit_slow.c index 85de417a..ca644adc 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_blit_slow.c +++ b/jni/SDL2-2.0.3/src/video/SDL_blit_slow.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_blit_slow.h b/jni/SDL2-2.0.3/src/video/SDL_blit_slow.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/SDL_blit_slow.h rename to jni/SDL2-2.0.3/src/video/SDL_blit_slow.h index 1c1a4dd1..c1786e0b 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_blit_slow.h +++ b/jni/SDL2-2.0.3/src/video/SDL_blit_slow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_bmp.c b/jni/SDL2-2.0.3/src/video/SDL_bmp.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/SDL_bmp.c rename to jni/SDL2-2.0.3/src/video/SDL_bmp.c index 65345d28..6d24aa25 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_bmp.c +++ b/jni/SDL2-2.0.3/src/video/SDL_bmp.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_clipboard.c b/jni/SDL2-2.0.3/src/video/SDL_clipboard.c similarity index 97% rename from jni/SDL2-2.0.1/src/video/SDL_clipboard.c rename to jni/SDL2-2.0.3/src/video/SDL_clipboard.c index 99ab20fa..a3b38e04 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_clipboard.c +++ b/jni/SDL2-2.0.3/src/video/SDL_clipboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_egl.c b/jni/SDL2-2.0.3/src/video/SDL_egl.c similarity index 98% rename from jni/SDL2-2.0.1/src/video/SDL_egl.c rename to jni/SDL2-2.0.3/src/video/SDL_egl.c index 36fcac6e..cfba2007 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_egl.c +++ b/jni/SDL2-2.0.3/src/video/SDL_egl.c @@ -1,6 +1,6 @@ /* * Simple DirectMedia Layer - * Copyright (C) 1997-2013 Sam Lantinga + * Copyright (C) 1997-2014 Sam Lantinga * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages @@ -41,7 +41,7 @@ #define DEFAULT_OGL_ES_PVR "libGLES_CM.so" #define DEFAULT_OGL_ES "libGLESv1_CM.so" -#elif SDL_VIDEO_DRIVER_WINDOWS +#elif SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT /* EGL AND OpenGL ES support via ANGLE */ #define DEFAULT_EGL "libEGL.dll" #define DEFAULT_OGL_ES2 "libGLESv2.dll" @@ -119,7 +119,7 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa { void *dll_handle = NULL, *egl_dll_handle = NULL; /* The naming is counter intuitive, but hey, I just work here -- Gabriel */ char *path = NULL; -#if SDL_VIDEO_DRIVER_WINDOWS +#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT const char *d3dcompiler; #endif @@ -132,7 +132,7 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa return SDL_OutOfMemory(); } -#if SDL_VIDEO_DRIVER_WINDOWS +#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT d3dcompiler = SDL_GetHint(SDL_HINT_VIDEO_WIN_D3DCOMPILER); if (!d3dcompiler) { /* By default we load the Vista+ compatible compiler */ diff --git a/jni/SDL2-2.0.1/src/video/SDL_egl_c.h b/jni/SDL2-2.0.3/src/video/SDL_egl_c.h similarity index 98% rename from jni/SDL2-2.0.1/src/video/SDL_egl_c.h rename to jni/SDL2-2.0.3/src/video/SDL_egl_c.h index 75e9fbd6..ef58b18e 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_egl_c.h +++ b/jni/SDL2-2.0.3/src/video/SDL_egl_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_fillrect.c b/jni/SDL2-2.0.3/src/video/SDL_fillrect.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/SDL_fillrect.c rename to jni/SDL2-2.0.3/src/video/SDL_fillrect.c index d1ddc885..2bf8a291 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_fillrect.c +++ b/jni/SDL2-2.0.3/src/video/SDL_fillrect.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_pixels.c b/jni/SDL2-2.0.3/src/video/SDL_pixels.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/SDL_pixels.c rename to jni/SDL2-2.0.3/src/video/SDL_pixels.c index 3daa85f0..9eb507e1 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_pixels.c +++ b/jni/SDL2-2.0.3/src/video/SDL_pixels.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_pixels_c.h b/jni/SDL2-2.0.3/src/video/SDL_pixels_c.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/SDL_pixels_c.h rename to jni/SDL2-2.0.3/src/video/SDL_pixels_c.h index 94fe38c1..de2916ff 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_pixels_c.h +++ b/jni/SDL2-2.0.3/src/video/SDL_pixels_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_rect.c b/jni/SDL2-2.0.3/src/video/SDL_rect.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/SDL_rect.c rename to jni/SDL2-2.0.3/src/video/SDL_rect.c index 5c9997a4..a0456bd6 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_rect.c +++ b/jni/SDL2-2.0.3/src/video/SDL_rect.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_rect_c.h b/jni/SDL2-2.0.3/src/video/SDL_rect_c.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/SDL_rect_c.h rename to jni/SDL2-2.0.3/src/video/SDL_rect_c.h index 1a76bac7..e6be3292 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_rect_c.h +++ b/jni/SDL2-2.0.3/src/video/SDL_rect_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_shape.c b/jni/SDL2-2.0.3/src/video/SDL_shape.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/SDL_shape.c rename to jni/SDL2-2.0.3/src/video/SDL_shape.c index 4f9f1c1a..97248bbc 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_shape.c +++ b/jni/SDL2-2.0.3/src/video/SDL_shape.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_shape_internals.h b/jni/SDL2-2.0.3/src/video/SDL_shape_internals.h similarity index 97% rename from jni/SDL2-2.0.1/src/video/SDL_shape_internals.h rename to jni/SDL2-2.0.3/src/video/SDL_shape_internals.h index a74bd385..b5413e1e 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_shape_internals.h +++ b/jni/SDL2-2.0.3/src/video/SDL_shape_internals.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_stretch.c b/jni/SDL2-2.0.3/src/video/SDL_stretch.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/SDL_stretch.c rename to jni/SDL2-2.0.3/src/video/SDL_stretch.c index 8f5517d0..a4faacaf 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_stretch.c +++ b/jni/SDL2-2.0.3/src/video/SDL_stretch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_surface.c b/jni/SDL2-2.0.3/src/video/SDL_surface.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/SDL_surface.c rename to jni/SDL2-2.0.3/src/video/SDL_surface.c index 8ccb6443..7caf0fc5 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_surface.c +++ b/jni/SDL2-2.0.3/src/video/SDL_surface.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/SDL_sysvideo.h b/jni/SDL2-2.0.3/src/video/SDL_sysvideo.h similarity index 98% rename from jni/SDL2-2.0.1/src/video/SDL_sysvideo.h rename to jni/SDL2-2.0.3/src/video/SDL_sysvideo.h index aabdffe9..32b5d77a 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_sysvideo.h +++ b/jni/SDL2-2.0.3/src/video/SDL_sysvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -345,12 +345,18 @@ extern VideoBootStrap COCOA_bootstrap; #if SDL_VIDEO_DRIVER_X11 extern VideoBootStrap X11_bootstrap; #endif +#if SDL_VIDEO_DRIVER_MIR +extern VideoBootStrap MIR_bootstrap; +#endif #if SDL_VIDEO_DRIVER_DIRECTFB extern VideoBootStrap DirectFB_bootstrap; #endif #if SDL_VIDEO_DRIVER_WINDOWS extern VideoBootStrap WINDOWS_bootstrap; #endif +#if SDL_VIDEO_DRIVER_WINRT +extern VideoBootStrap WINRT_bootstrap; +#endif #if SDL_VIDEO_DRIVER_HAIKU extern VideoBootStrap HAIKU_bootstrap; #endif diff --git a/jni/SDL2-2.0.1/src/video/SDL_video.c b/jni/SDL2-2.0.3/src/video/SDL_video.c similarity index 98% rename from jni/SDL2-2.0.1/src/video/SDL_video.c rename to jni/SDL2-2.0.3/src/video/SDL_video.c index 157cfa9e..a97051a8 100644 --- a/jni/SDL2-2.0.1/src/video/SDL_video.c +++ b/jni/SDL2-2.0.3/src/video/SDL_video.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -31,6 +31,8 @@ #include "../events/SDL_events_c.h" #include "../timer/SDL_timer_c.h" +#include "SDL_syswm.h" + #if SDL_VIDEO_OPENGL #include "SDL_opengl.h" #endif /* SDL_VIDEO_OPENGL */ @@ -44,8 +46,6 @@ #include "SDL_opengles2.h" #endif /* SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL */ -#include "SDL_syswm.h" - /* On Windows, windows.h defines CreateWindow */ #ifdef CreateWindow #undef CreateWindow @@ -59,12 +59,18 @@ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_X11 &X11_bootstrap, #endif +#if SDL_VIDEO_DRIVER_MIR + &MIR_bootstrap, +#endif #if SDL_VIDEO_DRIVER_DIRECTFB &DirectFB_bootstrap, #endif #if SDL_VIDEO_DRIVER_WINDOWS &WINDOWS_bootstrap, #endif +#if SDL_VIDEO_DRIVER_WINRT + &WINRT_bootstrap, +#endif #if SDL_VIDEO_DRIVER_HAIKU &HAIKU_bootstrap, #endif @@ -418,8 +424,10 @@ int SDL_VideoInit(const char *driver_name) { SDL_VideoDevice *video; + const char *hint; int index; int i; + SDL_bool allow_screensaver; /* Check to make sure we don't overwrite '_this' */ if (_this != NULL) { @@ -427,7 +435,7 @@ SDL_VideoInit(const char *driver_name) } #if !SDL_TIMERS_DISABLED - SDL_InitTicks(); + SDL_TicksInit(); #endif /* Start the event loop */ @@ -477,39 +485,7 @@ SDL_VideoInit(const char *driver_name) /* Set some very sane GL defaults */ _this->gl_config.driver_loaded = 0; _this->gl_config.dll_handle = NULL; - _this->gl_config.red_size = 3; - _this->gl_config.green_size = 3; - _this->gl_config.blue_size = 2; - _this->gl_config.alpha_size = 0; - _this->gl_config.buffer_size = 0; - _this->gl_config.depth_size = 16; - _this->gl_config.stencil_size = 0; - _this->gl_config.double_buffer = 1; - _this->gl_config.accum_red_size = 0; - _this->gl_config.accum_green_size = 0; - _this->gl_config.accum_blue_size = 0; - _this->gl_config.accum_alpha_size = 0; - _this->gl_config.stereo = 0; - _this->gl_config.multisamplebuffers = 0; - _this->gl_config.multisamplesamples = 0; - _this->gl_config.retained_backing = 1; - _this->gl_config.accelerated = -1; /* accelerated or not, both are fine */ - _this->gl_config.profile_mask = 0; -#if SDL_VIDEO_OPENGL - _this->gl_config.major_version = 2; - _this->gl_config.minor_version = 1; -#elif SDL_VIDEO_OPENGL_ES2 - _this->gl_config.major_version = 2; - _this->gl_config.minor_version = 0; - _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; -#elif SDL_VIDEO_OPENGL_ES - _this->gl_config.major_version = 1; - _this->gl_config.minor_version = 1; - _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; -#endif - _this->gl_config.flags = 0; - - _this->gl_config.share_with_current_context = 0; + SDL_GL_ResetAttributes(); _this->current_glwin_tls = SDL_TLSCreate(); _this->current_glctx_tls = SDL_TLSCreate(); @@ -533,6 +509,22 @@ SDL_VideoInit(const char *driver_name) _this->DestroyWindowFramebuffer = SDL_DestroyWindowTexture; } + /* Disable the screen saver by default. This is a change from <= 2.0.1, + but most things using SDL are games or media players; you wouldn't + want a screensaver to trigger if you're playing exclusively with a + joystick, or passively watching a movie. Things that use SDL but + function more like a normal desktop app should explicitly reenable the + screensaver. */ + hint = SDL_GetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER); + if (hint) { + allow_screensaver = SDL_atoi(hint) ? SDL_TRUE : SDL_FALSE; + } else { + allow_screensaver = SDL_FALSE; + } + if (!allow_screensaver) { + SDL_DisableScreenSaver(); + } + /* If we don't use a screen keyboard, turn on text input by default, otherwise programs that expect to get text events without enabling UNICODE input won't get any events. @@ -2547,6 +2539,49 @@ SDL_GL_ExtensionSupported(const char *extension) #endif } +void +SDL_GL_ResetAttributes() +{ + if (!_this) { + return; + } + + _this->gl_config.red_size = 3; + _this->gl_config.green_size = 3; + _this->gl_config.blue_size = 2; + _this->gl_config.alpha_size = 0; + _this->gl_config.buffer_size = 0; + _this->gl_config.depth_size = 16; + _this->gl_config.stencil_size = 0; + _this->gl_config.double_buffer = 1; + _this->gl_config.accum_red_size = 0; + _this->gl_config.accum_green_size = 0; + _this->gl_config.accum_blue_size = 0; + _this->gl_config.accum_alpha_size = 0; + _this->gl_config.stereo = 0; + _this->gl_config.multisamplebuffers = 0; + _this->gl_config.multisamplesamples = 0; + _this->gl_config.retained_backing = 1; + _this->gl_config.accelerated = -1; /* accelerated or not, both are fine */ + _this->gl_config.profile_mask = 0; +#if SDL_VIDEO_OPENGL + _this->gl_config.major_version = 2; + _this->gl_config.minor_version = 1; +#elif SDL_VIDEO_OPENGL_ES2 + _this->gl_config.major_version = 2; + _this->gl_config.minor_version = 0; + _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; +#elif SDL_VIDEO_OPENGL_ES + _this->gl_config.major_version = 1; + _this->gl_config.minor_version = 1; + _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; +#endif + _this->gl_config.flags = 0; + _this->gl_config.framebuffer_srgb_capable = 0; + + _this->gl_config.share_with_current_context = 0; +} + int SDL_GL_SetAttribute(SDL_GLattr attr, int value) { diff --git a/jni/SDL2-2.0.1/src/video/android/SDL_androidclipboard.c b/jni/SDL2-2.0.3/src/video/android/SDL_androidclipboard.c similarity index 95% rename from jni/SDL2-2.0.1/src/video/android/SDL_androidclipboard.c rename to jni/SDL2-2.0.3/src/video/android/SDL_androidclipboard.c index 17420338..dcac2e70 100644 --- a/jni/SDL2-2.0.1/src/video/android/SDL_androidclipboard.c +++ b/jni/SDL2-2.0.3/src/video/android/SDL_androidclipboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/android/SDL_androidclipboard.h b/jni/SDL2-2.0.3/src/video/android/SDL_androidclipboard.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/android/SDL_androidclipboard.h rename to jni/SDL2-2.0.3/src/video/android/SDL_androidclipboard.h index 9c599350..c1ab140c 100644 --- a/jni/SDL2-2.0.1/src/video/android/SDL_androidclipboard.h +++ b/jni/SDL2-2.0.3/src/video/android/SDL_androidclipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/android/SDL_androidevents.c b/jni/SDL2-2.0.3/src/video/android/SDL_androidevents.c similarity index 98% rename from jni/SDL2-2.0.1/src/video/android/SDL_androidevents.c rename to jni/SDL2-2.0.3/src/video/android/SDL_androidevents.c index da102ccf..164126cf 100644 --- a/jni/SDL2-2.0.1/src/video/android/SDL_androidevents.c +++ b/jni/SDL2-2.0.3/src/video/android/SDL_androidevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/android/SDL_androidevents.h b/jni/SDL2-2.0.3/src/video/android/SDL_androidevents.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/android/SDL_androidevents.h rename to jni/SDL2-2.0.3/src/video/android/SDL_androidevents.h index bfab5055..547338d7 100644 --- a/jni/SDL2-2.0.1/src/video/android/SDL_androidevents.h +++ b/jni/SDL2-2.0.3/src/video/android/SDL_androidevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/android/SDL_androidgl.c b/jni/SDL2-2.0.3/src/video/android/SDL_androidgl.c similarity index 96% rename from jni/SDL2-2.0.1/src/video/android/SDL_androidgl.c rename to jni/SDL2-2.0.3/src/video/android/SDL_androidgl.c index 8f0d1aed..1f933ce3 100644 --- a/jni/SDL2-2.0.1/src/video/android/SDL_androidgl.c +++ b/jni/SDL2-2.0.3/src/video/android/SDL_androidgl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/android/SDL_androidkeyboard.c b/jni/SDL2-2.0.3/src/video/android/SDL_androidkeyboard.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/android/SDL_androidkeyboard.c rename to jni/SDL2-2.0.3/src/video/android/SDL_androidkeyboard.c index 034c3023..5008cfde 100644 --- a/jni/SDL2-2.0.1/src/video/android/SDL_androidkeyboard.c +++ b/jni/SDL2-2.0.3/src/video/android/SDL_androidkeyboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/android/SDL_androidkeyboard.h b/jni/SDL2-2.0.3/src/video/android/SDL_androidkeyboard.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/android/SDL_androidkeyboard.h rename to jni/SDL2-2.0.3/src/video/android/SDL_androidkeyboard.h index 4c1cef1a..041987ac 100644 --- a/jni/SDL2-2.0.1/src/video/android/SDL_androidkeyboard.h +++ b/jni/SDL2-2.0.3/src/video/android/SDL_androidkeyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/android/SDL_androidtouch.c b/jni/SDL2-2.0.3/src/video/android/SDL_androidtouch.c similarity index 98% rename from jni/SDL2-2.0.1/src/video/android/SDL_androidtouch.c rename to jni/SDL2-2.0.3/src/video/android/SDL_androidtouch.c index f6cc0d0d..7f11f437 100644 --- a/jni/SDL2-2.0.1/src/video/android/SDL_androidtouch.c +++ b/jni/SDL2-2.0.3/src/video/android/SDL_androidtouch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/android/SDL_androidtouch.h b/jni/SDL2-2.0.3/src/video/android/SDL_androidtouch.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/android/SDL_androidtouch.h rename to jni/SDL2-2.0.3/src/video/android/SDL_androidtouch.h index 0601bea6..81a0cb50 100644 --- a/jni/SDL2-2.0.1/src/video/android/SDL_androidtouch.h +++ b/jni/SDL2-2.0.3/src/video/android/SDL_androidtouch.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/android/SDL_androidvideo.c b/jni/SDL2-2.0.3/src/video/android/SDL_androidvideo.c similarity index 98% rename from jni/SDL2-2.0.1/src/video/android/SDL_androidvideo.c rename to jni/SDL2-2.0.3/src/video/android/SDL_androidvideo.c index 91247dea..f1cf1855 100644 --- a/jni/SDL2-2.0.1/src/video/android/SDL_androidvideo.c +++ b/jni/SDL2-2.0.3/src/video/android/SDL_androidvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/android/SDL_androidvideo.h b/jni/SDL2-2.0.3/src/video/android/SDL_androidvideo.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/android/SDL_androidvideo.h rename to jni/SDL2-2.0.3/src/video/android/SDL_androidvideo.h index 3762f3dd..ccd5d7a1 100644 --- a/jni/SDL2-2.0.1/src/video/android/SDL_androidvideo.h +++ b/jni/SDL2-2.0.3/src/video/android/SDL_androidvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/android/SDL_androidwindow.c b/jni/SDL2-2.0.3/src/video/android/SDL_androidwindow.c similarity index 98% rename from jni/SDL2-2.0.1/src/video/android/SDL_androidwindow.c rename to jni/SDL2-2.0.3/src/video/android/SDL_androidwindow.c index 673b9d98..acbb5820 100644 --- a/jni/SDL2-2.0.1/src/video/android/SDL_androidwindow.c +++ b/jni/SDL2-2.0.3/src/video/android/SDL_androidwindow.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/android/SDL_androidwindow.h b/jni/SDL2-2.0.3/src/video/android/SDL_androidwindow.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/android/SDL_androidwindow.h rename to jni/SDL2-2.0.3/src/video/android/SDL_androidwindow.h index 88c1bc32..8de223aa 100644 --- a/jni/SDL2-2.0.1/src/video/android/SDL_androidwindow.h +++ b/jni/SDL2-2.0.3/src/video/android/SDL_androidwindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoaclipboard.h b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoaclipboard.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoaclipboard.h rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoaclipboard.h index 03ac3cb3..0a5e0dc0 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoaclipboard.h +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoaclipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoaclipboard.m b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoaclipboard.m similarity index 98% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoaclipboard.m rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoaclipboard.m index 0b7d39f7..495c934c 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoaclipboard.m +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoaclipboard.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoaevents.h b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoaevents.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoaevents.h rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoaevents.h index f9ca15dc..687cf647 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoaevents.h +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoaevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoaevents.m b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoaevents.m similarity index 92% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoaevents.m rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoaevents.m index c0231e0a..438385c3 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoaevents.m +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoaevents.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -36,6 +36,22 @@ #define UsrActivity 1 #endif +@interface SDLApplication : NSApplication + +- (void)terminate:(id)sender; + +@end + +@implementation SDLApplication + +// Override terminate to handle Quit and System Shutdown smoothly. +- (void)terminate:(id)sender +{ + SDL_SendQuit(); +} + +@end // SDLApplication + /* setAppleMenu disappeared from the headers in 10.4 */ @interface NSApplication(NSAppleMenu) - (void)setAppleMenu:(NSMenu *)menu; @@ -71,12 +87,6 @@ [super dealloc]; } -- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender -{ - SDL_SendQuit(); - return NSTerminateCancel; -} - - (void)focusSomeWindow:(NSNotification *)aNotification { /* HACK: Ignore the first call. The application gets a @@ -125,13 +135,12 @@ static SDLAppDelegate *appDelegate = nil; static NSString * GetApplicationName(void) { - NSDictionary *dict; - NSString *appName = 0; + NSString *appName; /* Determine the application name */ - dict = (NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle()); - if (dict) - appName = [dict objectForKey: @"CFBundleName"]; + appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]; + if (!appName) + appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]; if (![appName length]) appName = [[NSProcessInfo processInfo] processName]; @@ -256,13 +265,16 @@ Cocoa_RegisterApp(void) pool = [[NSAutoreleasePool alloc] init]; if (NSApp == nil) { - [NSApplication sharedApplication]; + [SDLApplication sharedApplication]; if ([NSApp mainMenu] == nil) { CreateApplicationMenus(); } [NSApp finishLaunching]; - NSDictionary *appDefaults = [NSDictionary dictionaryWithObject:@"NO" forKey:@"AppleMomentumScrollSupported"]; + NSDictionary *appDefaults = [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithBool:NO], @"AppleMomentumScrollSupported", + [NSNumber numberWithBool:NO], @"ApplePressAndHoldEnabled", + nil]; [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults]; } diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoakeyboard.h b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoakeyboard.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoakeyboard.h rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoakeyboard.h index 2bef1607..a85f9b7b 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoakeyboard.h +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoakeyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoakeyboard.m b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoakeyboard.m similarity index 98% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoakeyboard.m rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoakeyboard.m index 406de234..85bf9a06 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoakeyboard.m +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoakeyboard.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -506,7 +506,12 @@ Cocoa_StartTextInput(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSView *parentView = [[NSApp keyWindow] contentView]; + SDL_Window *window = SDL_GetKeyboardFocus(); + NSWindow *nswindow = nil; + if (window) + nswindow = ((SDL_WindowData*)window->driverdata)->nswindow; + + NSView *parentView = [nswindow contentView]; /* We only keep one field editor per process, since only the front most * window can receive text input events, so it make no sense to keep more @@ -523,7 +528,7 @@ Cocoa_StartTextInput(_THIS) /* DEBUG_IME(@"add fieldEdit to window contentView"); */ [data->fieldEdit removeFromSuperview]; [parentView addSubview: data->fieldEdit]; - [[NSApp keyWindow] makeFirstResponder: data->fieldEdit]; + [nswindow makeFirstResponder: data->fieldEdit]; } [pool release]; diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamessagebox.h b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamessagebox.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamessagebox.h rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamessagebox.h index 0d329a46..ff468a88 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamessagebox.h +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamessagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamessagebox.m b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamessagebox.m similarity index 98% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamessagebox.m rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamessagebox.m index f371096f..730d952e 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamessagebox.m +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamessagebox.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamodes.h b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamodes.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamodes.h rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamodes.h index 2eb79e12..4f8e8632 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamodes.h +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamodes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamodes.m b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamodes.m similarity index 99% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamodes.m rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamodes.m index 3eb6f05a..f41c3493 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamodes.m +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamodes.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamouse.h b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamouse.h similarity index 77% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamouse.h rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamouse.h index a49e5cb8..336b8404 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamouse.h +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -28,11 +28,18 @@ extern void Cocoa_InitMouse(_THIS); extern void Cocoa_HandleMouseEvent(_THIS, NSEvent * event); extern void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent * event); +extern void Cocoa_HandleMouseWarp(CGFloat x, CGFloat y); extern void Cocoa_QuitMouse(_THIS); typedef struct { - int deltaXOffset; - int deltaYOffset; + /* Wether we've seen a cursor warp since the last move event. */ + SDL_bool seenWarp; + /* What location our last cursor warp was to. */ + CGFloat lastWarpX; + CGFloat lastWarpY; + /* What location we last saw the cursor move to. */ + CGFloat lastMoveX; + CGFloat lastMoveY; void *tapdata; } SDL_MouseData; diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamouse.m b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamouse.m similarity index 72% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamouse.m rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamouse.m index e38a4f44..f5b54ed3 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamouse.m +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamouse.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -29,6 +29,14 @@ #include "../../events/SDL_mouse_c.h" +/* #define DEBUG_COCOAMOUSE */ + +#ifdef DEBUG_COCOAMOUSE +#define DLog(fmt, ...) printf("%s: " fmt "\n", __func__, ##__VA_ARGS__) +#else +#define DLog(...) do { } while (0) +#endif + @implementation NSCursor (InvisibleCursor) + (NSCursor *)invisibleCursor { @@ -203,18 +211,19 @@ Cocoa_ShowCursor(SDL_Cursor * cursor) static void Cocoa_WarpMouse(SDL_Window * window, int x, int y) { + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + if ([data->listener isMoving]) + { + DLog("Postponing warp, window being moved."); + [data->listener setPendingMoveX:x + Y:y]; + return; + } + SDL_Mouse *mouse = SDL_GetMouse(); CGPoint point = CGPointMake(x + (float)window->x, y + (float)window->y); - { - /* This makes Cocoa_HandleMouseEvent ignore this delta in the next - * movement event. - */ - SDL_MouseData *driverdata = (SDL_MouseData*)mouse->driverdata; - NSPoint location = [NSEvent mouseLocation]; - driverdata->deltaXOffset = location.x - point.x; - driverdata->deltaYOffset = point.y - location.y; - } + Cocoa_HandleMouseWarp(point.x, point.y); /* According to the docs, this was deprecated in 10.6, but it's still * around. The substitute requires a CGEventSource, but I'm not entirely @@ -235,11 +244,28 @@ Cocoa_WarpMouse(SDL_Window * window, int x, int y) static int Cocoa_SetRelativeMouseMode(SDL_bool enabled) { - CGError result; + /* We will re-apply the relative mode when the window gets focus, if it + * doesn't have focus right now. + */ + SDL_Window *window = SDL_GetMouseFocus(); + if (!window) { + return 0; + } + /* We will re-apply the relative mode when the window finishes being moved, + * if it is being moved right now. + */ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + if ([data->listener isMoving]) { + return 0; + } + + CGError result; if (enabled) { + DLog("Turning on."); result = CGAssociateMouseAndMouseCursorPosition(NO); } else { + DLog("Turning off."); result = CGAssociateMouseAndMouseCursorPosition(YES); } if (result != kCGErrorSuccess) { @@ -265,25 +291,67 @@ Cocoa_InitMouse(_THIS) SDL_SetDefaultCursor(Cocoa_CreateDefaultCursor()); Cocoa_InitMouseEventTap(mouse->driverdata); + + SDL_MouseData *driverdata = (SDL_MouseData*)mouse->driverdata; + const NSPoint location = [NSEvent mouseLocation]; + driverdata->lastMoveX = location.x; + driverdata->lastMoveY = location.y; } void Cocoa_HandleMouseEvent(_THIS, NSEvent *event) { + switch ([event type]) + { + case NSMouseMoved: + case NSLeftMouseDragged: + case NSRightMouseDragged: + case NSOtherMouseDragged: + break; + + default: + /* Ignore any other events. */ + return; + } + SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse->relative_mode && - ([event type] == NSMouseMoved || - [event type] == NSLeftMouseDragged || - [event type] == NSRightMouseDragged || - [event type] == NSOtherMouseDragged)) { - SDL_MouseData *driverdata = (SDL_MouseData*)mouse->driverdata; - float x = [event deltaX] + driverdata->deltaXOffset; - float y = [event deltaY] + driverdata->deltaYOffset; - driverdata->deltaXOffset = driverdata->deltaYOffset = 0; + SDL_MouseData *driverdata = (SDL_MouseData*)mouse->driverdata; + const SDL_bool seenWarp = driverdata->seenWarp; + driverdata->seenWarp = NO; - SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 1, (int)x, (int)y); + const NSPoint location = [NSEvent mouseLocation]; + const CGFloat lastMoveX = driverdata->lastMoveX; + const CGFloat lastMoveY = driverdata->lastMoveY; + driverdata->lastMoveX = location.x; + driverdata->lastMoveY = location.y; + DLog("Last seen mouse: (%g, %g)", location.x, location.y); + + /* Non-relative movement is handled in -[Cocoa_WindowListener mouseMoved:] */ + if (!mouse->relative_mode) { + return; } + + /* Ignore events that aren't inside the client area (i.e. title bar.) */ + if ([event window]) { + NSRect windowRect = [[[event window] contentView] frame]; + if (!NSPointInRect([event locationInWindow], windowRect)) { + return; + } + } + + float deltaX = [event deltaX]; + float deltaY = [event deltaY]; + + if (seenWarp) + { + deltaX += (lastMoveX - driverdata->lastWarpX); + deltaY += ((CGDisplayPixelsHigh(kCGDirectMainDisplay) - lastMoveY) - driverdata->lastWarpY); + + DLog("Motion was (%g, %g), offset to (%g, %g)", [event deltaX], [event deltaY], deltaX, deltaY); + } + + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 1, (int)deltaX, (int)deltaY); } void @@ -291,7 +359,7 @@ Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event) { SDL_Mouse *mouse = SDL_GetMouse(); - float x = [event deltaX]; + float x = -[event deltaX]; float y = [event deltaY]; if (x > 0) { @@ -307,6 +375,20 @@ Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event) SDL_SendMouseWheel(window, mouse->mouseID, (int)x, (int)y); } +void +Cocoa_HandleMouseWarp(CGFloat x, CGFloat y) +{ + /* This makes Cocoa_HandleMouseEvent ignore the delta caused by the warp, + * since it gets included in the next movement event. + */ + SDL_MouseData *driverdata = (SDL_MouseData*)SDL_GetMouse()->driverdata; + driverdata->lastWarpX = x; + driverdata->lastWarpY = y; + driverdata->seenWarp = SDL_TRUE; + + DLog("(%g, %g)", x, y); +} + void Cocoa_QuitMouse(_THIS) { diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamousetap.h b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamousetap.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamousetap.h rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamousetap.h index a656020c..bf3e7383 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamousetap.h +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamousetap.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamousetap.m b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamousetap.m similarity index 99% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamousetap.m rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamousetap.m index f0f617df..9cf531cb 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoamousetap.m +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoamousetap.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoaopengl.h b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoaopengl.h similarity index 97% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoaopengl.h rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoaopengl.h index ab635e8a..14fd3ab4 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoaopengl.h +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoaopengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoaopengl.m b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoaopengl.m similarity index 77% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoaopengl.m rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoaopengl.m index 54aae973..d9fb2440 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoaopengl.m +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoaopengl.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -35,17 +35,14 @@ #define DEFAULT_OPENGL "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib" -#ifndef kCGLPFAOpenGLProfile -#define kCGLPFAOpenGLProfile 99 +#ifndef NSOpenGLPFAOpenGLProfile +#define NSOpenGLPFAOpenGLProfile 99 #endif -#ifndef kCGLOGLPVersion_Legacy -#define kCGLOGLPVersion_Legacy 0x1000 +#ifndef NSOpenGLProfileVersionLegacy +#define NSOpenGLProfileVersionLegacy 0x1000 #endif -#ifndef kCGLOGLPVersion_GL3_Core -#define kCGLOGLPVersion_GL3_Core 0x3200 -#endif -#ifndef kCGLOGLPVersion_GL4_Core -#define kCGLOGLPVersion_GL4_Core 0x4100 +#ifndef NSOpenGLProfileVersion3_2Core +#define NSOpenGLProfileVersion3_2Core 0x3200 #endif @implementation SDLOpenGLContext : NSOpenGLContext @@ -110,11 +107,19 @@ if ([self view] != [windowdata->nswindow contentView]) { [self setView:[windowdata->nswindow contentView]]; - [self scheduleUpdate]; + if (self == [NSOpenGLContext currentContext]) { + [self update]; + } else { + [self scheduleUpdate]; + } } } else { [self clearDrawable]; - [self scheduleUpdate]; + if (self == [NSOpenGLContext currentContext]) { + [self update]; + } else { + [self scheduleUpdate]; + } } } @@ -156,8 +161,6 @@ Cocoa_GL_UnloadLibrary(_THIS) SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window * window) { - const int wantver = (_this->gl_config.major_version << 8) | - (_this->gl_config.minor_version); SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; NSAutoreleasePool *pool; SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); @@ -167,16 +170,16 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window) SDLOpenGLContext *context; NSOpenGLContext *share_context = nil; int i = 0; + const char *glversion; + int glversion_major; + int glversion_minor; if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { SDL_SetError ("OpenGL ES is not supported on this platform"); return NULL; } - - /* Sadly, we'll have to update this as life progresses, since we need to - set an enum for context profiles, not a context version number */ - if (wantver > 0x0401) { - SDL_SetError ("OpenGL > 4.1 is not supported on this platform"); + if ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) && (data->osversion < 0x1070)) { + SDL_SetError ("OpenGL Core Profile is not supported on this platform version"); return NULL; } @@ -184,19 +187,11 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window) /* specify a profile if we're on Lion (10.7) or later. */ if (data->osversion >= 0x1070) { - NSOpenGLPixelFormatAttribute profile = kCGLOGLPVersion_Legacy; + NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersionLegacy; if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) { - if (wantver == 0x0302) { - profile = kCGLOGLPVersion_GL3_Core; - } else if ((wantver == 0x0401) && (data->osversion >= 0x1090)) { - profile = kCGLOGLPVersion_GL4_Core; - } else { - SDL_SetError("Requested GL version is not supported on this platform"); - [pool release]; - return NULL; - } + profile = NSOpenGLProfileVersion3_2Core; } - attr[i++] = kCGLPFAOpenGLProfile; + attr[i++] = NSOpenGLPFAOpenGLProfile; attr[i++] = profile; } @@ -253,7 +248,7 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window) fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr]; if (fmt == nil) { - SDL_SetError ("Failed creating OpenGL pixel format"); + SDL_SetError("Failed creating OpenGL pixel format"); [pool release]; return NULL; } @@ -267,7 +262,7 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window) [fmt release]; if (context == nil) { - SDL_SetError ("Failed creating OpenGL context"); + SDL_SetError("Failed creating OpenGL context"); [pool release]; return NULL; } @@ -276,9 +271,50 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window) if ( Cocoa_GL_MakeCurrent(_this, window, context) < 0 ) { Cocoa_GL_DeleteContext(_this, context); + SDL_SetError("Failed making OpenGL context current"); return NULL; } + if (_this->gl_config.major_version < 3 && + _this->gl_config.profile_mask == 0 && + _this->gl_config.flags == 0) { + /* This is a legacy profile, so to match other backends, we're done. */ + } else { + const GLubyte *(APIENTRY * glGetStringFunc)(GLenum); + + glGetStringFunc = (const GLubyte *(APIENTRY *)(GLenum)) SDL_GL_GetProcAddress("glGetString"); + if (!glGetStringFunc) { + Cocoa_GL_DeleteContext(_this, context); + SDL_SetError ("Failed getting OpenGL glGetString entry point"); + return NULL; + } + + glversion = (const char *)glGetStringFunc(GL_VERSION); + if (glversion == NULL) { + Cocoa_GL_DeleteContext(_this, context); + SDL_SetError ("Failed getting OpenGL context version"); + return NULL; + } + + if (SDL_sscanf(glversion, "%d.%d", &glversion_major, &glversion_minor) != 2) { + Cocoa_GL_DeleteContext(_this, context); + SDL_SetError ("Failed parsing OpenGL context version"); + return NULL; + } + + if ((glversion_major < _this->gl_config.major_version) || + ((glversion_major == _this->gl_config.major_version) && (glversion_minor < _this->gl_config.minor_version))) { + Cocoa_GL_DeleteContext(_this, context); + SDL_SetError ("Failed creating OpenGL context at version requested"); + return NULL; + } + + /* In the future we'll want to do this, but to match other platforms + we'll leave the OpenGL version the way it is for now + */ + /*_this->gl_config.major_version = glversion_major;*/ + /*_this->gl_config.minor_version = glversion_minor;*/ + } return context; } diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoashape.h b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoashape.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoashape.h rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoashape.h index f415444f..0ab9980e 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoashape.h +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoashape.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoashape.m b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoashape.m similarity index 98% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoashape.m rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoashape.m index a6ea8795..b3843ccb 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoashape.m +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoashape.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoavideo.h b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoavideo.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoavideo.h rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoavideo.h index 00ea4955..f194e1f7 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoavideo.h +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoavideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -46,6 +46,7 @@ typedef struct SDL_VideoData { SInt32 osversion; + int allow_spaces; unsigned int modifierFlags; void *key_layout; SDLTranslatorResponder *fieldEdit; diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoavideo.m b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoavideo.m similarity index 96% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoavideo.m rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoavideo.m index 18408e94..6766b71b 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoavideo.m +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoavideo.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -148,9 +148,15 @@ VideoBootStrap COCOA_bootstrap = { int Cocoa_VideoInit(_THIS) { + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + Cocoa_InitModes(_this); Cocoa_InitKeyboard(_this); Cocoa_InitMouse(_this); + + const char *hint = SDL_GetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES); + data->allow_spaces = ( (data->osversion >= 0x1070) && (!hint || (*hint != '0')) ); + return 0; } diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoawindow.h b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoawindow.h similarity index 93% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoawindow.h rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoawindow.h index 1a7178c5..a4ec07d7 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoawindow.h +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoawindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -43,6 +43,8 @@ typedef enum BOOL isFullscreenSpace; BOOL inFullscreenTransition; PendingWindowOperation pendingWindowOperation; + BOOL isMoving; + int pendingWindowWarpX, pendingWindowWarpY; } -(void) listen:(SDL_WindowData *) data; @@ -54,6 +56,10 @@ typedef enum -(void) addPendingWindowOperation:(PendingWindowOperation) operation; -(void) close; +-(BOOL) isMoving; +-(void) setPendingMoveX:(int)x Y:(int)y; +-(void) windowDidFinishMoving; + /* Window delegate functionality */ -(BOOL) windowShouldClose:(id) sender; -(void) windowDidExpose:(NSNotification *) aNotification; @@ -67,6 +73,7 @@ typedef enum -(void) windowDidEnterFullScreen:(NSNotification *) aNotification; -(void) windowWillExitFullScreen:(NSNotification *) aNotification; -(void) windowDidExitFullScreen:(NSNotification *) aNotification; +-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions; /* Window event handling */ -(void) mouseDown:(NSEvent *) theEvent; @@ -105,6 +112,7 @@ struct SDL_WindowData NSWindow *nswindow; NSMutableArray *nscontexts; SDL_bool created; + SDL_bool inWindowMove; Cocoa_WindowListener *listener; struct SDL_VideoData *videodata; }; diff --git a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoawindow.m b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoawindow.m similarity index 89% rename from jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoawindow.m rename to jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoawindow.m index f7a03915..a55ab496 100644 --- a/jni/SDL2-2.0.1/src/video/cocoa/SDL_cocoawindow.m +++ b/jni/SDL2-2.0.3/src/video/cocoa/SDL_cocoawindow.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -38,6 +38,54 @@ #include "SDL_cocoashape.h" #include "SDL_cocoamouse.h" #include "SDL_cocoaopengl.h" +#include "SDL_assert.h" + +/* #define DEBUG_COCOAWINDOW */ + +#ifdef DEBUG_COCOAWINDOW +#define DLog(fmt, ...) printf("%s: " fmt "\n", __func__, ##__VA_ARGS__) +#else +#define DLog(...) do { } while (0) +#endif + + +@interface SDLWindow : NSWindow +/* These are needed for borderless/fullscreen windows */ +- (BOOL)canBecomeKeyWindow; +- (BOOL)canBecomeMainWindow; +- (void)sendEvent:(NSEvent *)event; +@end + +@implementation SDLWindow +- (BOOL)canBecomeKeyWindow +{ + return YES; +} + +- (BOOL)canBecomeMainWindow +{ + return YES; +} + +- (void)sendEvent:(NSEvent *)event +{ + [super sendEvent:event]; + + if ([event type] != NSLeftMouseUp) { + return; + } + + id delegate = [self delegate]; + if (![delegate isKindOfClass:[Cocoa_WindowListener class]]) { + return; + } + + if ([delegate isMoving]) { + [delegate windowDidFinishMoving]; + } +} +@end + static Uint32 s_moveHack; @@ -49,10 +97,15 @@ static void ConvertNSRect(NSRect *r) static void ScheduleContextUpdates(SDL_WindowData *data) { + NSOpenGLContext *currentContext = [NSOpenGLContext currentContext]; NSMutableArray *contexts = data->nscontexts; @synchronized (contexts) { for (SDLOpenGLContext *context in contexts) { - [context scheduleUpdate]; + if (context == currentContext) { + [context update]; + } else { + [context scheduleUpdate]; + } } } } @@ -125,6 +178,7 @@ SetWindowStyle(SDL_Window * window, unsigned int style) isFullscreenSpace = NO; inFullscreenTransition = NO; pendingWindowOperation = PENDING_OPERATION_NONE; + isMoving = NO; center = [NSNotificationCenter defaultCenter]; @@ -203,20 +257,18 @@ SetWindowStyle(SDL_Window * window, unsigned int style) } } --(BOOL) setFullscreenSpace:(BOOL) state; +-(BOOL) setFullscreenSpace:(BOOL) state { SDL_Window *window = _data->window; NSWindow *nswindow = _data->nswindow; + SDL_VideoData *videodata = ((SDL_WindowData *) window->driverdata)->videodata; - if (![nswindow respondsToSelector: @selector(collectionBehavior)]) { - return NO; - } - if ([nswindow collectionBehavior] != NSWindowCollectionBehaviorFullScreenPrimary) { - return NO; - } - - if (state == isFullscreenSpace) { - return YES; + if (!videodata->allow_spaces) { + return NO; /* Spaces are forcibly disabled. */ + } else if (state && ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP)) { + return NO; /* we only allow you to make a Space on FULLSCREEN_DESKTOP windows. */ + } else if (state == isFullscreenSpace) { + return YES; /* already there. */ } if (inFullscreenTransition) { @@ -229,13 +281,8 @@ SetWindowStyle(SDL_Window * window, unsigned int style) } inFullscreenTransition = YES; - /* Update the flags here so the state change is available immediately */ - if (state) { - window->flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; - } else { - window->flags &= ~SDL_WINDOW_FULLSCREEN_DESKTOP; - } - + /* you need to be FullScreenPrimary, or toggleFullScreen doesn't work. Unset it again in windowDidExitFullScreen. */ + [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; [nswindow performSelectorOnMainThread: @selector(toggleFullScreen:) withObject:nswindow waitUntilDone:NO]; return YES; } @@ -310,6 +357,34 @@ SetWindowStyle(SDL_Window * window, unsigned int style) } } +- (BOOL)isMoving +{ + return isMoving; +} + +-(void) setPendingMoveX:(int)x Y:(int)y +{ + pendingWindowWarpX = x; + pendingWindowWarpY = y; +} + +- (void)windowDidFinishMoving +{ + if ([self isMoving]) + { + isMoving = NO; + + SDL_Mouse *mouse = SDL_GetMouse(); + if (pendingWindowWarpX >= 0 && pendingWindowWarpY >= 0) { + mouse->WarpMouse(_data->window, pendingWindowWarpX, pendingWindowWarpY); + pendingWindowWarpX = pendingWindowWarpY = -1; + } + if (mouse->relative_mode && SDL_GetMouseFocus() == _data->window) { + mouse->SetRelativeMouseMode(SDL_TRUE); + } + } +} + - (BOOL)windowShouldClose:(id)sender { SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_CLOSE, 0, 0); @@ -321,6 +396,14 @@ SetWindowStyle(SDL_Window * window, unsigned int style) SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_EXPOSED, 0, 0); } +- (void)windowWillMove:(NSNotification *)aNotification +{ + if ([_data->nswindow isKindOfClass:[SDLWindow class]]) { + pendingWindowWarpX = pendingWindowWarpY = -1; + isMoving = YES; + } +} + - (void)windowDidMove:(NSNotification *)aNotification { int x, y; @@ -354,6 +437,11 @@ SetWindowStyle(SDL_Window * window, unsigned int style) - (void)windowDidResize:(NSNotification *)aNotification { + if (inFullscreenTransition) { + /* We'll take care of this at the end of the transition */ + return; + } + SDL_Window *window = _data->window; NSWindow *nswindow = _data->nswindow; int x, y, w, h; @@ -364,11 +452,6 @@ SetWindowStyle(SDL_Window * window, unsigned int style) w = (int)rect.size.width; h = (int)rect.size.height; - if (inFullscreenTransition) { - /* We'll take care of this at the end of the transition */ - return; - } - if (SDL_IsShapedWindow(window)) { Cocoa_ResizeWindowShape(window); } @@ -402,6 +485,9 @@ SetWindowStyle(SDL_Window * window, unsigned int style) { SDL_Window *window = _data->window; SDL_Mouse *mouse = SDL_GetMouse(); + if (mouse->relative_mode && ![self isMoving]) { + mouse->SetRelativeMouseMode(SDL_TRUE); + } /* We're going to get keyboard events, since we're key. */ SDL_SetKeyboardFocus(window); @@ -422,10 +508,19 @@ SetWindowStyle(SDL_Window * window, unsigned int style) /* Check to see if someone updated the clipboard */ Cocoa_CheckClipboardUpdate(_data->videodata); + + if ((isFullscreenSpace) && ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP)) { + [NSMenu setMenuBarVisible:NO]; + } } - (void)windowDidResignKey:(NSNotification *)aNotification { + SDL_Mouse *mouse = SDL_GetMouse(); + if (mouse->relative_mode) { + mouse->SetRelativeMouseMode(SDL_FALSE); + } + /* Some other window will get mouse events, since we're not key. */ if (SDL_GetMouseFocus() == _data->window) { SDL_SetMouseFocus(NULL); @@ -435,13 +530,16 @@ SetWindowStyle(SDL_Window * window, unsigned int style) if (SDL_GetKeyboardFocus() == _data->window) { SDL_SetKeyboardFocus(NULL); } + + if (isFullscreenSpace) { + [NSMenu setMenuBarVisible:YES]; + } } - (void)windowWillEnterFullScreen:(NSNotification *)aNotification { SDL_Window *window = _data->window; - window->flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; SetWindowStyle(window, (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask)); isFullscreenSpace = YES; @@ -458,6 +556,10 @@ SetWindowStyle(SDL_Window * window, unsigned int style) pendingWindowOperation = PENDING_OPERATION_NONE; [self setFullscreenSpace:NO]; } else { + if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) { + [NSMenu setMenuBarVisible:NO]; + } + pendingWindowOperation = PENDING_OPERATION_NONE; /* Force the size change event in case it was delivered earlier while the window was still animating into place. @@ -472,7 +574,6 @@ SetWindowStyle(SDL_Window * window, unsigned int style) { SDL_Window *window = _data->window; - window->flags &= ~SDL_WINDOW_FULLSCREEN_DESKTOP; SetWindowStyle(window, GetWindowStyle(window)); isFullscreenSpace = NO; @@ -486,6 +587,8 @@ SetWindowStyle(SDL_Window * window, unsigned int style) inFullscreenTransition = NO; + [nswindow setLevel:kCGNormalWindowLevel]; + if (pendingWindowOperation == PENDING_OPERATION_ENTER_FULLSCREEN) { pendingWindowOperation = PENDING_OPERATION_NONE; [self setFullscreenSpace:YES]; @@ -493,6 +596,15 @@ SetWindowStyle(SDL_Window * window, unsigned int style) pendingWindowOperation = PENDING_OPERATION_NONE; [nswindow miniaturize:nil]; } else { + /* Adjust the fullscreen toggle button and readd menu now that we're here. */ + if (window->flags & SDL_WINDOW_RESIZABLE) { + /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */ + [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; + } else { + [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged]; + } + [NSMenu setMenuBarVisible:YES]; + pendingWindowOperation = PENDING_OPERATION_NONE; /* Force the size change event in case it was delivered earlier while the window was still animating into place. @@ -500,9 +612,24 @@ SetWindowStyle(SDL_Window * window, unsigned int style) window->w = 0; window->h = 0; [self windowDidResize:aNotification]; + + /* FIXME: Why does the window get hidden? */ + if (window->flags & SDL_WINDOW_SHOWN) { + Cocoa_ShowWindow(SDL_GetVideoDevice(), window); + } } } +-(NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions +{ + if ((_data->window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) { + return NSApplicationPresentationFullScreen | NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar; + } else { + return proposedOptions; + } +} + + /* We'll respond to key events by doing nothing so we don't beep. * We could handle key messages here, but we lose some in the NSApp dispatch, * where they get converted to action messages, etc. @@ -619,8 +746,6 @@ SetWindowStyle(SDL_Window * window, unsigned int style) if (x < 0 || x >= window->w || y < 0 || y >= window->h) { if (window->flags & SDL_WINDOW_INPUT_GRABBED) { - CGPoint cgpoint; - if (x < 0) { x = 0; } else if (x >= window->w) { @@ -633,6 +758,8 @@ SetWindowStyle(SDL_Window * window, unsigned int style) } #if !SDL_MAC_NO_SANDBOX + CGPoint cgpoint; + /* When SDL_MAC_NO_SANDBOX is set, this is handled by * SDL_cocoamousetap.m. */ @@ -647,6 +774,8 @@ SetWindowStyle(SDL_Window * window, unsigned int style) CGSetLocalEventsSuppressionInterval(0.0); CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint); CGSetLocalEventsSuppressionInterval(0.25); + + Cocoa_HandleMouseWarp(cgpoint.x, cgpoint.y); #endif } } @@ -749,24 +878,6 @@ SetWindowStyle(SDL_Window * window, unsigned int style) @end -@interface SDLWindow : NSWindow -/* These are needed for borderless/fullscreen windows */ -- (BOOL)canBecomeKeyWindow; -- (BOOL)canBecomeMainWindow; -@end - -@implementation SDLWindow -- (BOOL)canBecomeKeyWindow -{ - return YES; -} - -- (BOOL)canBecomeMainWindow -{ - return YES; -} -@end - @interface SDLView : NSView /* The default implementation doesn't pass rightMouseDown to responder chain */ @@ -883,6 +994,7 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created int Cocoa_CreateWindow(_THIS, SDL_Window * window) { + SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSWindow *nswindow; SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); @@ -926,9 +1038,13 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window) return -1; } [nswindow setBackgroundColor:[NSColor blackColor]]; - if ([nswindow respondsToSelector:@selector(setCollectionBehavior:)]) { - const char *hint = SDL_GetHint(SDL_HINT_VIDEO_FULLSCREEN_SPACES); - if (hint && SDL_atoi(hint) > 0) { + + if (videodata->allow_spaces) { + SDL_assert(videodata->osversion >= 0x1070); + SDL_assert([nswindow respondsToSelector:@selector(toggleFullScreen:)]); + /* we put FULLSCREEN_DESKTOP windows in their own Space, without a toggle button or menubar, later */ + if (window->flags & SDL_WINDOW_RESIZABLE) { + /* resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. */ [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; } } @@ -1333,13 +1449,18 @@ void Cocoa_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) { /* Move the cursor to the nearest point in the window */ - if (grabbed) { + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + if (grabbed && data && ![data->listener isMoving]) { int x, y; CGPoint cgpoint; SDL_GetMouseState(&x, &y); cgpoint.x = window->x + x; cgpoint.y = window->y + y; + + Cocoa_HandleMouseWarp(cgpoint.x, cgpoint.y); + + DLog("Returning cursor to (%g, %g)", cgpoint.x, cgpoint.y); CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint); } diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_WM.c b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_WM.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_WM.c rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_WM.c index 202e7b02..b48a1069 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_WM.c +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_WM.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_WM.h b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_WM.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_WM.h rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_WM.h index 4c5d539d..0bfe07e0 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_WM.h +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_WM.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_dyn.c b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_dyn.c similarity index 98% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_dyn.c rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_dyn.c index 8b7fa808..49c737b0 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_dyn.c +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_dyn.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_dyn.h b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_dyn.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_dyn.h rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_dyn.h index 52658b01..ba57f453 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_dyn.h +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_dyn.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_events.c b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_events.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_events.c rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_events.c index f5cd6ef3..9c6c7940 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_events.c +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_events.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_events.h b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_events.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_events.h rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_events.h index a69e6bf7..db5c7f0f 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_events.h +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_events.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_modes.c b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_modes.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_modes.c rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_modes.c index 0b54acd1..73de1fc0 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_modes.c +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_modes.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_modes.h b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_modes.h similarity index 97% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_modes.h rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_modes.h index 6e439cdc..7999f606 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_modes.h +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_modes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_mouse.c b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_mouse.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_mouse.c rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_mouse.c index 7c630456..93798f8e 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_mouse.c +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_mouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_mouse.h b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_mouse.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_mouse.h rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_mouse.h index 906f1fb5..7ac48682 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_mouse.h +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_mouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_opengl.c b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_opengl.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_opengl.c rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_opengl.c index 16b3bb14..1a378792 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_opengl.c +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_opengl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_opengl.h b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_opengl.h similarity index 97% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_opengl.h rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_opengl.h index efb11f76..ecd5bbaf 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_opengl.h +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_opengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_render.c b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_render.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_render.c rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_render.c index c719e487..61f9b00c 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_render.c +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_render.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_render.h b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_render.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_render.h rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_render.h index fe888af1..5405a5e5 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_render.h +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_render.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_shape.c b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_shape.c similarity index 98% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_shape.c rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_shape.c index 75ca63b6..64e91f61 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_shape.c +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_shape.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_shape.h b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_shape.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_shape.h rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_shape.h index a9977853..99bff800 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_shape.h +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_shape.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_video.c b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_video.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_video.c rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_video.c index f701d7f1..55e9ece3 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_video.c +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_video.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -35,8 +35,6 @@ #include "SDL_DirectFB_WM.h" -#include "../../SDL_internal.h" - /* DirectFB video driver implementation. */ diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_video.h b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_video.h similarity index 98% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_video.h rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_video.h index 77f6d72d..82250b63 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_video.h +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_video.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_window.c b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_window.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_window.c rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_window.c index 4913f7cf..be496961 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_window.c +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_window.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_window.h b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_window.h similarity index 98% rename from jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_window.h rename to jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_window.h index 96afc59e..a16d1609 100644 --- a/jni/SDL2-2.0.1/src/video/directfb/SDL_DirectFB_window.h +++ b/jni/SDL2-2.0.3/src/video/directfb/SDL_DirectFB_window.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/dummy/SDL_nullevents.c b/jni/SDL2-2.0.3/src/video/dummy/SDL_nullevents.c similarity index 95% rename from jni/SDL2-2.0.1/src/video/dummy/SDL_nullevents.c rename to jni/SDL2-2.0.3/src/video/dummy/SDL_nullevents.c index 2271a48c..22a34bba 100644 --- a/jni/SDL2-2.0.1/src/video/dummy/SDL_nullevents.c +++ b/jni/SDL2-2.0.3/src/video/dummy/SDL_nullevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/dummy/SDL_nullevents_c.h b/jni/SDL2-2.0.3/src/video/dummy/SDL_nullevents_c.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/dummy/SDL_nullevents_c.h rename to jni/SDL2-2.0.3/src/video/dummy/SDL_nullevents_c.h index e18bab9a..41e28caa 100644 --- a/jni/SDL2-2.0.1/src/video/dummy/SDL_nullevents_c.h +++ b/jni/SDL2-2.0.3/src/video/dummy/SDL_nullevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/dummy/SDL_nullframebuffer.c b/jni/SDL2-2.0.3/src/video/dummy/SDL_nullframebuffer.c similarity index 97% rename from jni/SDL2-2.0.1/src/video/dummy/SDL_nullframebuffer.c rename to jni/SDL2-2.0.3/src/video/dummy/SDL_nullframebuffer.c index 93fafe48..2f1bcab7 100644 --- a/jni/SDL2-2.0.1/src/video/dummy/SDL_nullframebuffer.c +++ b/jni/SDL2-2.0.3/src/video/dummy/SDL_nullframebuffer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/dummy/SDL_nullframebuffer_c.h b/jni/SDL2-2.0.3/src/video/dummy/SDL_nullframebuffer_c.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/dummy/SDL_nullframebuffer_c.h rename to jni/SDL2-2.0.3/src/video/dummy/SDL_nullframebuffer_c.h index ddd331d7..4c582d7d 100644 --- a/jni/SDL2-2.0.1/src/video/dummy/SDL_nullframebuffer_c.h +++ b/jni/SDL2-2.0.3/src/video/dummy/SDL_nullframebuffer_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/dummy/SDL_nullvideo.c b/jni/SDL2-2.0.3/src/video/dummy/SDL_nullvideo.c similarity index 98% rename from jni/SDL2-2.0.1/src/video/dummy/SDL_nullvideo.c rename to jni/SDL2-2.0.3/src/video/dummy/SDL_nullvideo.c index 48cbd2d1..28147bd1 100644 --- a/jni/SDL2-2.0.1/src/video/dummy/SDL_nullvideo.c +++ b/jni/SDL2-2.0.3/src/video/dummy/SDL_nullvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/dummy/SDL_nullvideo.h b/jni/SDL2-2.0.3/src/video/dummy/SDL_nullvideo.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/dummy/SDL_nullvideo.h rename to jni/SDL2-2.0.3/src/video/dummy/SDL_nullvideo.h index 94497c38..b0a76c06 100644 --- a/jni/SDL2-2.0.1/src/video/dummy/SDL_nullvideo.h +++ b/jni/SDL2-2.0.3/src/video/dummy/SDL_nullvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/haiku/SDL_BWin.h b/jni/SDL2-2.0.3/src/video/haiku/SDL_BWin.h similarity index 99% rename from jni/SDL2-2.0.1/src/video/haiku/SDL_BWin.h rename to jni/SDL2-2.0.3/src/video/haiku/SDL_BWin.h index 5aca508c..e6de5b0d 100644 --- a/jni/SDL2-2.0.1/src/video/haiku/SDL_BWin.h +++ b/jni/SDL2-2.0.3/src/video/haiku/SDL_BWin.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/haiku/SDL_bclipboard.cc b/jni/SDL2-2.0.3/src/video/haiku/SDL_bclipboard.cc similarity index 97% rename from jni/SDL2-2.0.1/src/video/haiku/SDL_bclipboard.cc rename to jni/SDL2-2.0.3/src/video/haiku/SDL_bclipboard.cc index b75655f3..9760d0fb 100644 --- a/jni/SDL2-2.0.1/src/video/haiku/SDL_bclipboard.cc +++ b/jni/SDL2-2.0.3/src/video/haiku/SDL_bclipboard.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/haiku/SDL_bclipboard.h b/jni/SDL2-2.0.3/src/video/haiku/SDL_bclipboard.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/haiku/SDL_bclipboard.h rename to jni/SDL2-2.0.3/src/video/haiku/SDL_bclipboard.h index 2a572ffe..418ba90b 100644 --- a/jni/SDL2-2.0.1/src/video/haiku/SDL_bclipboard.h +++ b/jni/SDL2-2.0.3/src/video/haiku/SDL_bclipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/haiku/SDL_bevents.cc b/jni/SDL2-2.0.3/src/video/haiku/SDL_bevents.cc similarity index 95% rename from jni/SDL2-2.0.1/src/video/haiku/SDL_bevents.cc rename to jni/SDL2-2.0.3/src/video/haiku/SDL_bevents.cc index 0fe93057..2ffc4713 100644 --- a/jni/SDL2-2.0.1/src/video/haiku/SDL_bevents.cc +++ b/jni/SDL2-2.0.3/src/video/haiku/SDL_bevents.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/haiku/SDL_bevents.h b/jni/SDL2-2.0.3/src/video/haiku/SDL_bevents.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/haiku/SDL_bevents.h rename to jni/SDL2-2.0.3/src/video/haiku/SDL_bevents.h index a83d03b5..9b53f39a 100644 --- a/jni/SDL2-2.0.1/src/video/haiku/SDL_bevents.h +++ b/jni/SDL2-2.0.3/src/video/haiku/SDL_bevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/haiku/SDL_bframebuffer.cc b/jni/SDL2-2.0.3/src/video/haiku/SDL_bframebuffer.cc similarity index 99% rename from jni/SDL2-2.0.1/src/video/haiku/SDL_bframebuffer.cc rename to jni/SDL2-2.0.3/src/video/haiku/SDL_bframebuffer.cc index 4ca28ab6..0c563960 100644 --- a/jni/SDL2-2.0.1/src/video/haiku/SDL_bframebuffer.cc +++ b/jni/SDL2-2.0.3/src/video/haiku/SDL_bframebuffer.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/haiku/SDL_bframebuffer.h b/jni/SDL2-2.0.3/src/video/haiku/SDL_bframebuffer.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/haiku/SDL_bframebuffer.h rename to jni/SDL2-2.0.3/src/video/haiku/SDL_bframebuffer.h index 935f0e95..b0b73d3c 100644 --- a/jni/SDL2-2.0.1/src/video/haiku/SDL_bframebuffer.h +++ b/jni/SDL2-2.0.3/src/video/haiku/SDL_bframebuffer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/haiku/SDL_bkeyboard.cc b/jni/SDL2-2.0.3/src/video/haiku/SDL_bkeyboard.cc similarity index 99% rename from jni/SDL2-2.0.1/src/video/haiku/SDL_bkeyboard.cc rename to jni/SDL2-2.0.3/src/video/haiku/SDL_bkeyboard.cc index c6ba1614..97f34b23 100644 --- a/jni/SDL2-2.0.1/src/video/haiku/SDL_bkeyboard.cc +++ b/jni/SDL2-2.0.3/src/video/haiku/SDL_bkeyboard.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/haiku/SDL_bkeyboard.h b/jni/SDL2-2.0.3/src/video/haiku/SDL_bkeyboard.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/haiku/SDL_bkeyboard.h rename to jni/SDL2-2.0.3/src/video/haiku/SDL_bkeyboard.h index b170228a..0acb42c9 100644 --- a/jni/SDL2-2.0.1/src/video/haiku/SDL_bkeyboard.h +++ b/jni/SDL2-2.0.3/src/video/haiku/SDL_bkeyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/haiku/SDL_bmodes.cc b/jni/SDL2-2.0.3/src/video/haiku/SDL_bmodes.cc similarity index 99% rename from jni/SDL2-2.0.1/src/video/haiku/SDL_bmodes.cc rename to jni/SDL2-2.0.3/src/video/haiku/SDL_bmodes.cc index cf358d7f..b56442b0 100644 --- a/jni/SDL2-2.0.1/src/video/haiku/SDL_bmodes.cc +++ b/jni/SDL2-2.0.3/src/video/haiku/SDL_bmodes.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/haiku/SDL_bmodes.h b/jni/SDL2-2.0.3/src/video/haiku/SDL_bmodes.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/haiku/SDL_bmodes.h rename to jni/SDL2-2.0.3/src/video/haiku/SDL_bmodes.h index 9ca04d08..3df862d3 100644 --- a/jni/SDL2-2.0.1/src/video/haiku/SDL_bmodes.h +++ b/jni/SDL2-2.0.3/src/video/haiku/SDL_bmodes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/haiku/SDL_bopengl.cc b/jni/SDL2-2.0.3/src/video/haiku/SDL_bopengl.cc similarity index 99% rename from jni/SDL2-2.0.1/src/video/haiku/SDL_bopengl.cc rename to jni/SDL2-2.0.3/src/video/haiku/SDL_bopengl.cc index 22bc087d..245cec12 100644 --- a/jni/SDL2-2.0.1/src/video/haiku/SDL_bopengl.cc +++ b/jni/SDL2-2.0.3/src/video/haiku/SDL_bopengl.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/haiku/SDL_bopengl.h b/jni/SDL2-2.0.3/src/video/haiku/SDL_bopengl.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/haiku/SDL_bopengl.h rename to jni/SDL2-2.0.3/src/video/haiku/SDL_bopengl.h index 9ec972ee..b046de4e 100644 --- a/jni/SDL2-2.0.1/src/video/haiku/SDL_bopengl.h +++ b/jni/SDL2-2.0.3/src/video/haiku/SDL_bopengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/haiku/SDL_bvideo.cc b/jni/SDL2-2.0.3/src/video/haiku/SDL_bvideo.cc similarity index 98% rename from jni/SDL2-2.0.1/src/video/haiku/SDL_bvideo.cc rename to jni/SDL2-2.0.3/src/video/haiku/SDL_bvideo.cc index 812291a4..a526893f 100644 --- a/jni/SDL2-2.0.1/src/video/haiku/SDL_bvideo.cc +++ b/jni/SDL2-2.0.3/src/video/haiku/SDL_bvideo.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/haiku/SDL_bvideo.h b/jni/SDL2-2.0.3/src/video/haiku/SDL_bvideo.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/haiku/SDL_bvideo.h rename to jni/SDL2-2.0.3/src/video/haiku/SDL_bvideo.h index 7f0266a7..925c8b5b 100644 --- a/jni/SDL2-2.0.1/src/video/haiku/SDL_bvideo.h +++ b/jni/SDL2-2.0.3/src/video/haiku/SDL_bvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/haiku/SDL_bwindow.cc b/jni/SDL2-2.0.3/src/video/haiku/SDL_bwindow.cc similarity index 99% rename from jni/SDL2-2.0.1/src/video/haiku/SDL_bwindow.cc rename to jni/SDL2-2.0.3/src/video/haiku/SDL_bwindow.cc index b3c309d1..c0a3cee0 100644 --- a/jni/SDL2-2.0.1/src/video/haiku/SDL_bwindow.cc +++ b/jni/SDL2-2.0.3/src/video/haiku/SDL_bwindow.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/haiku/SDL_bwindow.h b/jni/SDL2-2.0.3/src/video/haiku/SDL_bwindow.h similarity index 97% rename from jni/SDL2-2.0.1/src/video/haiku/SDL_bwindow.h rename to jni/SDL2-2.0.3/src/video/haiku/SDL_bwindow.h index e3c0b6a3..5a393497 100644 --- a/jni/SDL2-2.0.1/src/video/haiku/SDL_bwindow.h +++ b/jni/SDL2-2.0.3/src/video/haiku/SDL_bwindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.3/src/video/mir/SDL_mirdyn.c b/jni/SDL2-2.0.3/src/video/mir/SDL_mirdyn.c new file mode 100644 index 00000000..f544d06e --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/mir/SDL_mirdyn.c @@ -0,0 +1,177 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_MIR + +#define DEBUG_DYNAMIC_MIR 0 + +#include "SDL_mirdyn.h" + +#if DEBUG_DYNAMIC_MIR +#include "SDL_log.h" +#endif + +#ifdef SDL_VIDEO_DRIVER_MIR_DYNAMIC + +#include "SDL_name.h" +#include "SDL_loadso.h" + +typedef struct +{ + void *lib; + const char *libname; +} mirdynlib; + +#ifndef SDL_VIDEO_DRIVER_MIR_DYNAMIC +#define SDL_VIDEO_DRIVER_MIR_DYNAMIC NULL +#endif +#ifndef SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON +#define SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON NULL +#endif + +static mirdynlib mirlibs[] = { + {NULL, SDL_VIDEO_DRIVER_MIR_DYNAMIC}, + {NULL, SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON} +}; + +static void * +MIR_GetSym(const char *fnname, int *pHasModule) +{ + int i; + void *fn = NULL; + for (i = 0; i < SDL_TABLESIZE(mirlibs); i++) { + if (mirlibs[i].lib != NULL) { + fn = SDL_LoadFunction(mirlibs[i].lib, fnname); + if (fn != NULL) + break; + } + } + +#if DEBUG_DYNAMIC_MIR + if (fn != NULL) + SDL_Log("MIR: Found '%s' in %s (%p)\n", fnname, mirlibs[i].libname, fn); + else + SDL_Log("MIR: Symbol '%s' NOT FOUND!\n", fnname); +#endif + + if (fn == NULL) + *pHasModule = 0; /* kill this module. */ + + return fn; +} + +#endif /* SDL_VIDEO_DRIVER_MIR_DYNAMIC */ + +/* Define all the function pointers and wrappers... */ +#define SDL_MIR_MODULE(modname) int SDL_MIR_HAVE_##modname = 0; +#define SDL_MIR_SYM(rc,fn,params) SDL_DYNMIRFN_##fn MIR_##fn = NULL; +#include "SDL_mirsym.h" +#undef SDL_MIR_MODULE +#undef SDL_MIR_SYM + +static int mir_load_refcount = 0; + +void +SDL_MIR_UnloadSymbols(void) +{ + /* Don't actually unload if more than one module is using the libs... */ + if (mir_load_refcount > 0) { + if (--mir_load_refcount == 0) { +#ifdef SDL_VIDEO_DRIVER_MIR_DYNAMIC + int i; +#endif + + /* set all the function pointers to NULL. */ +#define SDL_MIR_MODULE(modname) SDL_MIR_HAVE_##modname = 0; +#define SDL_MIR_SYM(rc,fn,params) MIR_##fn = NULL; +#include "SDL_mirsym.h" +#undef SDL_MIR_MODULE +#undef SDL_MIR_SYM + + +#ifdef SDL_VIDEO_DRIVER_MIR_DYNAMIC + for (i = 0; i < SDL_TABLESIZE(mirlibs); i++) { + if (mirlibs[i].lib != NULL) { + SDL_UnloadObject(mirlibs[i].lib); + mirlibs[i].lib = NULL; + } + } +#endif + } + } +} + +/* returns non-zero if all needed symbols were loaded. */ +int +SDL_MIR_LoadSymbols(void) +{ + int rc = 1; /* always succeed if not using Dynamic MIR stuff. */ + + /* deal with multiple modules (dga, wayland, mir, etc) needing these symbols... */ + if (mir_load_refcount++ == 0) { +#ifdef SDL_VIDEO_DRIVER_MIR_DYNAMIC + int i; + int *thismod = NULL; + for (i = 0; i < SDL_TABLESIZE(mirlibs); i++) { + if (mirlibs[i].libname != NULL) { + mirlibs[i].lib = SDL_LoadObject(mirlibs[i].libname); + } + } + +#define SDL_MIR_MODULE(modname) SDL_MIR_HAVE_##modname = 1; /* default yes */ +#define SDL_MIR_SYM(rc,fn,params) +#include "SDL_mirsym.h" +#undef SDL_MIR_MODULE +#undef SDL_MIR_SYM + +#define SDL_MIR_MODULE(modname) thismod = &SDL_MIR_HAVE_##modname; +#define SDL_MIR_SYM(rc,fn,params) MIR_##fn = (SDL_DYNMIRFN_##fn) MIR_GetSym(#fn,thismod); +#include "SDL_mirsym.h" +#undef SDL_MIR_MODULE +#undef SDL_MIR_SYM + + if ((SDL_MIR_HAVE_MIR_CLIENT) && (SDL_MIR_HAVE_XKBCOMMON)) { + /* all required symbols loaded. */ + SDL_ClearError(); + } else { + /* in case something got loaded... */ + SDL_MIR_UnloadSymbols(); + rc = 0; + } + +#else /* no dynamic MIR */ + +#define SDL_MIR_MODULE(modname) SDL_MIR_HAVE_##modname = 1; /* default yes */ +#define SDL_MIR_SYM(rc,fn,params) MIR_##fn = fn; +#include "SDL_mirsym.h" +#undef SDL_MIR_MODULE +#undef SDL_MIR_SYM + +#endif + } + + return rc; +} + +#endif /* SDL_VIDEO_DRIVER_MIR */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/video/mir/SDL_mirdyn.h b/jni/SDL2-2.0.3/src/video/mir/SDL_mirdyn.h new file mode 100644 index 00000000..3bd62e14 --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/mir/SDL_mirdyn.h @@ -0,0 +1,53 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_mirdyn_h +#define _SDL_mirdyn_h + +#include "../../SDL_internal.h" + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int SDL_MIR_LoadSymbols(void); +void SDL_MIR_UnloadSymbols(void); + +/* Declare all the function pointers and wrappers... */ +#define SDL_MIR_MODULE(modname) +#define SDL_MIR_SYM(rc,fn,params) \ + typedef rc (*SDL_DYNMIRFN_##fn) params; \ + extern SDL_DYNMIRFN_##fn MIR_##fn; +#include "SDL_mirsym.h" +#undef SDL_MIR_MODULE +#undef SDL_MIR_SYM + +#ifdef __cplusplus +} +#endif + +#endif /* !defined _SDL_mirdyn_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/video/mir/SDL_mirevents.c b/jni/SDL2-2.0.3/src/video/mir/SDL_mirevents.c new file mode 100644 index 00000000..f2d3ef38 --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/mir/SDL_mirevents.c @@ -0,0 +1,260 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + Contributed by Brandon Schaefer, +*/ + +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_MIR + +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_touch_c.h" +#include "../../events/scancodes_xfree86.h" + +#include "SDL_mirevents.h" +#include "SDL_mirwindow.h" + +#include + +#include "SDL_mirdyn.h" + +static void +HandleKeyText(int32_t key_code) +{ + char text[8]; + int size = 0; + + size = MIR_xkb_keysym_to_utf8(key_code, text, sizeof text); + + if (size > 0) { + text[size] = '\0'; + SDL_SendKeyboardText(text); + } +} + +static void +CheckKeyboardFocus(SDL_Window* sdl_window) +{ + SDL_Window* keyboard_window = SDL_GetKeyboardFocus(); + + if (keyboard_window != sdl_window) + SDL_SetKeyboardFocus(sdl_window); +} + + +/* FIXME + Mir still needs to implement its IM API, for now we assume + a single key press produces a character. +*/ +static void +HandleKeyEvent(MirKeyEvent const ev, SDL_Window* window) +{ + uint32_t scancode = SDL_SCANCODE_UNKNOWN; + Uint8 key_state = ev.action == mir_key_action_up ? SDL_RELEASED : SDL_PRESSED; + + CheckKeyboardFocus(window); + + if (ev.scan_code < SDL_arraysize(xfree86_scancode_table2)) + scancode = xfree86_scancode_table2[ev.scan_code]; + + if (scancode != SDL_SCANCODE_UNKNOWN) + SDL_SendKeyboardKey(key_state, scancode); + + if (key_state == SDL_PRESSED) + HandleKeyText(ev.key_code); +} + +static void +HandleMouseButton(SDL_Window* sdl_window, Uint8 state, MirMotionButton button_state) +{ + static uint32_t last_sdl_button; + uint32_t sdl_button; + + switch (button_state) { + case mir_motion_button_primary: + sdl_button = SDL_BUTTON_LEFT; + break; + case mir_motion_button_secondary: + sdl_button = SDL_BUTTON_RIGHT; + break; + case mir_motion_button_tertiary: + sdl_button = SDL_BUTTON_MIDDLE; + break; + case mir_motion_button_forward: + sdl_button = SDL_BUTTON_X1; + break; + case mir_motion_button_back: + sdl_button = SDL_BUTTON_X2; + break; + default: + sdl_button = last_sdl_button; + break; + } + + last_sdl_button = sdl_button; + SDL_SendMouseButton(sdl_window, 0, state, sdl_button); +} + +static void +HandleTouchPress(int device_id, int source_id, SDL_bool down, float x, float y, float pressure) +{ + SDL_SendTouch(device_id, source_id, down, x, y, pressure); +} + +static void +HandleTouchMotion(int device_id, int source_id, float x, float y, float pressure) +{ + SDL_SendTouchMotion(device_id, source_id, x, y, pressure); +} + +static void +HandleMouseMotion(SDL_Window* sdl_window, int x, int y) +{ + SDL_SendMouseMotion(sdl_window, 0, 0, x, y); +} + +static void +HandleMouseScroll(SDL_Window* sdl_window, int hscroll, int vscroll) +{ + SDL_SendMouseWheel(sdl_window, 0, hscroll, vscroll); +} + +static void +AddTouchDevice(int device_id) +{ + if (SDL_AddTouch(device_id, "") < 0) + SDL_SetError("Error: can't add touch %s, %d", __FILE__, __LINE__); +} + +static void +HandleTouchEvent(MirMotionEvent const motion, int cord_index, SDL_Window* sdl_window) +{ + int device_id = motion.device_id; + int id = motion.pointer_coordinates[cord_index].id; + + int width = sdl_window->w; + int height = sdl_window->h; + float x = motion.pointer_coordinates[cord_index].x; + float y = motion.pointer_coordinates[cord_index].y; + + float n_x = x / width; + float n_y = y / height; + float pressure = motion.pointer_coordinates[cord_index].pressure; + + AddTouchDevice(motion.device_id); + + switch (motion.action) { + case mir_motion_action_down: + case mir_motion_action_pointer_down: + HandleTouchPress(device_id, id, SDL_TRUE, n_x, n_y, pressure); + break; + case mir_motion_action_up: + case mir_motion_action_pointer_up: + HandleTouchPress(device_id, id, SDL_FALSE, n_x, n_y, pressure); + break; + case mir_motion_action_hover_move: + case mir_motion_action_move: + HandleTouchMotion(device_id, id, n_x, n_y, pressure); + break; + default: + break; + } +} + +static void +HandleMouseEvent(MirMotionEvent const motion, int cord_index, SDL_Window* sdl_window) +{ + SDL_SetMouseFocus(sdl_window); + + switch (motion.action) { + case mir_motion_action_down: + case mir_motion_action_pointer_down: + HandleMouseButton(sdl_window, SDL_PRESSED, motion.button_state); + break; + case mir_motion_action_up: + case mir_motion_action_pointer_up: + HandleMouseButton(sdl_window, SDL_RELEASED, motion.button_state); + break; + case mir_motion_action_hover_move: + case mir_motion_action_move: + HandleMouseMotion(sdl_window, + motion.pointer_coordinates[cord_index].x, + motion.pointer_coordinates[cord_index].y); + break; + case mir_motion_action_outside: + SDL_SetMouseFocus(NULL); + break; +#if 0 /* !!! FIXME: needs a newer set of dev headers than Ubuntu 13.10 is shipping atm. */ + case mir_motion_action_scroll: + HandleMouseScroll(sdl_window, + motion.pointer_coordinates[cord_index].hscroll, + motion.pointer_coordinates[cord_index].vscroll); + break; +#endif + case mir_motion_action_cancel: + case mir_motion_action_hover_enter: + case mir_motion_action_hover_exit: + break; + default: + break; + } +} + +static void +HandleMotionEvent(MirMotionEvent const motion, SDL_Window* sdl_window) +{ + int cord_index; + for (cord_index = 0; cord_index < motion.pointer_count; cord_index++) { +#if 0 /* !!! FIXME: needs a newer set of dev headers than Ubuntu 13.10 is shipping atm. */ + if (motion.pointer_coordinates[cord_index].tool_type == mir_motion_tool_type_mouse) { + HandleMouseEvent(motion, cord_index, sdl_window); + } + else if (motion.pointer_coordinates[cord_index].tool_type == mir_motion_tool_type_finger) { + HandleTouchEvent(motion, cord_index, sdl_window); + } +#else + HandleMouseEvent(motion, cord_index, sdl_window); +#endif + } +} + +void +MIR_HandleInput(MirSurface* surface, MirEvent const* ev, void* context) +{ + SDL_Window* window = (SDL_Window*)context; + switch (ev->type) { + case (mir_event_type_key): + HandleKeyEvent(ev->key, window); + break; + case (mir_event_type_motion): + HandleMotionEvent(ev->motion, window); + break; + default: + break; + } +} + +#endif /* SDL_VIDEO_DRIVER_MIR */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/video/mir/SDL_mirevents.h b/jni/SDL2-2.0.3/src/video/mir/SDL_mirevents.h new file mode 100644 index 00000000..9219eed1 --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/mir/SDL_mirevents.h @@ -0,0 +1,37 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + Contributed by Brandon Schaefer, +*/ + +#ifndef _SDL_mirevents_h +#define _SDL_mirevents_h + +#include + +extern void +MIR_HandleInput(MirSurface* surface, MirEvent const* ev, void* context); + +#endif /* _SDL_mirevents_h */ + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/jni/SDL2-2.0.3/src/video/mir/SDL_mirframebuffer.c b/jni/SDL2-2.0.3/src/video/mir/SDL_mirframebuffer.c new file mode 100644 index 00000000..f8b46649 --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/mir/SDL_mirframebuffer.c @@ -0,0 +1,157 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + Contributed by Brandon Schaefer, +*/ + +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_MIR + +#include "SDL_mirevents.h" +#include "SDL_mirframebuffer.h" +#include "SDL_mirwindow.h" + +#include "SDL_mirdyn.h" + +static const Uint32 mir_pixel_format_to_sdl_format[] = { + SDL_PIXELFORMAT_UNKNOWN, /* mir_pixel_format_invalid */ + SDL_PIXELFORMAT_ABGR8888, /* mir_pixel_format_abgr_8888 */ + SDL_PIXELFORMAT_BGR888, /* mir_pixel_format_xbgr_8888 */ + SDL_PIXELFORMAT_ARGB8888, /* mir_pixel_format_argb_8888 */ + SDL_PIXELFORMAT_RGB888, /* mir_pixel_format_xrgb_8888 */ + SDL_PIXELFORMAT_BGR24 /* mir_pixel_format_bgr_888 */ +}; + +Uint32 +MIR_GetSDLPixelFormat(MirPixelFormat format) +{ + return mir_pixel_format_to_sdl_format[format]; +} + +int +MIR_CreateWindowFramebuffer(_THIS, SDL_Window* window, Uint32* format, + void** pixels, int* pitch) +{ + MIR_Data* mir_data = _this->driverdata; + MIR_Window* mir_window; + MirSurfaceParameters surfaceparm; + + if (MIR_CreateWindow(_this, window) < 0) + return SDL_SetError("Failed to created a mir window."); + + mir_window = window->driverdata; + + MIR_mir_surface_get_parameters(mir_window->surface, &surfaceparm); + + *format = MIR_GetSDLPixelFormat(surfaceparm.pixel_format); + if (*format == SDL_PIXELFORMAT_UNKNOWN) + return SDL_SetError("Unknown pixel format"); + + *pitch = (((window->w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3); + + *pixels = SDL_malloc(window->h*(*pitch)); + if (*pixels == NULL) + return SDL_OutOfMemory(); + + mir_window->surface = MIR_mir_connection_create_surface_sync(mir_data->connection, &surfaceparm); + if (!MIR_mir_surface_is_valid(mir_window->surface)) { + const char* error = MIR_mir_surface_get_error_message(mir_window->surface); + return SDL_SetError("Failed to created a mir surface: %s", error); + } + + return 0; +} + +int +MIR_UpdateWindowFramebuffer(_THIS, SDL_Window* window, + const SDL_Rect* rects, int numrects) +{ + MIR_Window* mir_window = window->driverdata; + + MirGraphicsRegion region; + int i, j, x, y, w, h, start; + int bytes_per_pixel, bytes_per_row, s_stride, d_stride; + char* s_dest; + char* pixels; + + MIR_mir_surface_get_graphics_region(mir_window->surface, ®ion); + + s_dest = region.vaddr; + pixels = (char*)window->surface->pixels; + + s_stride = window->surface->pitch; + d_stride = region.stride; + bytes_per_pixel = window->surface->format->BytesPerPixel; + + for (i = 0; i < numrects; i++) { + s_dest = region.vaddr; + pixels = (char*)window->surface->pixels; + + x = rects[i].x; + y = rects[i].y; + w = rects[i].w; + h = rects[i].h; + + if (w <= 0 || h <= 0 || (x + w) <= 0 || (y + h) <= 0) + continue; + + if (x < 0) { + x += w; + w += rects[i].x; + } + + if (y < 0) { + y += h; + h += rects[i].y; + } + + if (x + w > window->w) + w = window->w - x; + if (y + h > window->h) + h = window->h - y; + + start = y * s_stride + x; + pixels += start; + s_dest += start; + + bytes_per_row = bytes_per_pixel * w; + for (j = 0; j < h; j++) { + memcpy(s_dest, pixels, bytes_per_row); + pixels += s_stride; + s_dest += d_stride; + } + } + + MIR_mir_surface_swap_buffers_sync(mir_window->surface); + + return 0; +} + +void +MIR_DestroyWindowFramebuffer(_THIS, SDL_Window* window) +{ +} + +#endif /* SDL_VIDEO_DRIVER_MIR */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/video/mir/SDL_mirframebuffer.h b/jni/SDL2-2.0.3/src/video/mir/SDL_mirframebuffer.h new file mode 100644 index 00000000..b4860fe1 --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/mir/SDL_mirframebuffer.h @@ -0,0 +1,47 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + Contributed by Brandon Schaefer, +*/ + +#ifndef _SDL_mirframebuffer_h +#define _SDL_mirframebuffer_h + +#include "../SDL_sysvideo.h" + +#include "SDL_mirvideo.h" + +extern int +MIR_CreateWindowFramebuffer(_THIS, SDL_Window* sdl_window, Uint32* format, + void** pixels, int* pitch); + +extern int +MIR_UpdateWindowFramebuffer(_THIS, SDL_Window* sdl_window, + const SDL_Rect* rects, int numrects); + +extern void +MIR_DestroyWindowFramebuffer(_THIS, SDL_Window* sdl_window); + +#endif /* _SDL_mirframebuffer_h */ + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/jni/SDL2-2.0.3/src/video/mir/SDL_mirmouse.c b/jni/SDL2-2.0.3/src/video/mir/SDL_mirmouse.c new file mode 100644 index 00000000..def9dbd0 --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/mir/SDL_mirmouse.c @@ -0,0 +1,154 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + Contributed by Brandon Schaefer, +*/ + +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_MIR + +#include "SDL_mirmouse.h" + +#include "../../events/SDL_mouse_c.h" +#include "SDL_assert.h" + +#include "SDL_mirdyn.h" + +static SDL_Cursor* +MIR_CreateDefaultCursor() +{ + SDL_Cursor* cursor; + + cursor = SDL_calloc(1, sizeof(SDL_Cursor)); + if (cursor) { + } + else { + SDL_OutOfMemory(); + } + + return cursor; +} + +static SDL_Cursor* +MIR_CreateCursor(SDL_Surface* sruface, int hot_x, int hot_y) +{ + return MIR_CreateDefaultCursor(); +} + +static SDL_Cursor* +MIR_CreateSystemCursor(SDL_SystemCursor id) +{ + switch(id) { + case SDL_SYSTEM_CURSOR_ARROW: + break; + case SDL_SYSTEM_CURSOR_IBEAM: + break; + case SDL_SYSTEM_CURSOR_WAIT: + break; + case SDL_SYSTEM_CURSOR_CROSSHAIR: + break; + case SDL_SYSTEM_CURSOR_WAITARROW: + break; + case SDL_SYSTEM_CURSOR_SIZENWSE: + break; + case SDL_SYSTEM_CURSOR_SIZENESW: + break; + case SDL_SYSTEM_CURSOR_SIZEWE: + break; + case SDL_SYSTEM_CURSOR_SIZENS: + break; + case SDL_SYSTEM_CURSOR_SIZEALL: + break; + case SDL_SYSTEM_CURSOR_NO: + break; + case SDL_SYSTEM_CURSOR_HAND: + break; + default: + SDL_assert(0); + return NULL; + } + + return MIR_CreateDefaultCursor(); +} + +static void +MIR_FreeCursor(SDL_Cursor* cursor) +{ + if (cursor) + SDL_free(cursor); +} + +static int +MIR_ShowCursor(SDL_Cursor* cursor) +{ + return 0; +} + +static void +MIR_WarpMouse(SDL_Window* window, int x, int y) +{ + SDL_Unsupported(); +} + +static int +MIR_SetRelativeMouseMode(SDL_bool enabled) +{ + return SDL_Unsupported(); +} + +/* TODO Actually implement the cursor, need to wait for mir support */ +void +MIR_InitMouse() +{ + SDL_Mouse* mouse = SDL_GetMouse(); + + mouse->CreateCursor = MIR_CreateCursor; + mouse->ShowCursor = MIR_ShowCursor; + mouse->FreeCursor = MIR_FreeCursor; + mouse->WarpMouse = MIR_WarpMouse; + mouse->CreateSystemCursor = MIR_CreateSystemCursor; + mouse->SetRelativeMouseMode = MIR_SetRelativeMouseMode; + + SDL_SetDefaultCursor(MIR_CreateDefaultCursor()); +} + +void +MIR_FiniMouse() +{ + SDL_Mouse* mouse = SDL_GetMouse(); + + MIR_FreeCursor(mouse->def_cursor); + mouse->def_cursor = NULL; + + mouse->CreateCursor = NULL; + mouse->ShowCursor = NULL; + mouse->FreeCursor = NULL; + mouse->WarpMouse = NULL; + mouse->CreateSystemCursor = NULL; + mouse->SetRelativeMouseMode = NULL; +} + +#endif /* SDL_VIDEO_DRIVER_MIR */ + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/jni/SDL2-2.0.3/src/video/mir/SDL_mirmouse.h b/jni/SDL2-2.0.3/src/video/mir/SDL_mirmouse.h new file mode 100644 index 00000000..fd4e4762 --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/mir/SDL_mirmouse.h @@ -0,0 +1,37 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + Contributed by Brandon Schaefer, +*/ + +#ifndef _SDL_mirmouse_h +#define _SDL_mirmouse_h + +extern void +MIR_InitMouse(); + +extern void +MIR_FiniMouse(); + +#endif /* _SDL_mirmouse_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/video/mir/SDL_miropengl.c b/jni/SDL2-2.0.3/src/video/mir/SDL_miropengl.c new file mode 100644 index 00000000..976b7727 --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/mir/SDL_miropengl.c @@ -0,0 +1,96 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + Contributed by Brandon Schaefer, +*/ + +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_MIR + +#include "SDL_miropengl.h" + +#include "SDL_mirdyn.h" + +void +MIR_GL_SwapWindow(_THIS, SDL_Window* window) +{ + MIR_Window* mir_wind = window->driverdata; + + SDL_EGL_SwapBuffers(_this, mir_wind->egl_surface); +} + +int +MIR_GL_MakeCurrent(_THIS, SDL_Window* window, SDL_GLContext context) +{ + if (window) { + EGLSurface egl_surface = ((MIR_Window*)window->driverdata)->egl_surface; + return SDL_EGL_MakeCurrent(_this, egl_surface, context); + } + + return SDL_EGL_MakeCurrent(_this, NULL, NULL); +} + +SDL_GLContext +MIR_GL_CreateContext(_THIS, SDL_Window* window) +{ + MIR_Window* mir_window = window->driverdata; + + SDL_GLContext context; + context = SDL_EGL_CreateContext(_this, mir_window->egl_surface); + + return context; +} + +int +MIR_GL_LoadLibrary(_THIS, const char* path) +{ + MIR_Data* mir_data = _this->driverdata; + + SDL_EGL_LoadLibrary(_this, path, MIR_mir_connection_get_egl_native_display(mir_data->connection)); + + SDL_EGL_ChooseConfig(_this); + + return 0; +} + +void +MIR_GL_UnloadLibrary(_THIS) +{ + SDL_EGL_UnloadLibrary(_this); +} + +void* +MIR_GL_GetProcAddress(_THIS, const char* proc) +{ + void* proc_addr = SDL_EGL_GetProcAddress(_this, proc); + + if (!proc_addr) { + SDL_SetError("Failed to find proc address!"); + } + + return proc_addr; +} + +#endif /* SDL_VIDEO_DRIVER_MIR */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/video/mir/SDL_miropengl.h b/jni/SDL2-2.0.3/src/video/mir/SDL_miropengl.h new file mode 100644 index 00000000..0f4c9731 --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/mir/SDL_miropengl.h @@ -0,0 +1,58 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + Contributed by Brandon Schaefer, +*/ + +#ifndef _SDL_miropengl_h +#define _SDL_miropengl_h + +#include "SDL_mirwindow.h" + +#include "../SDL_egl_c.h" + +#define MIR_GL_DeleteContext SDL_EGL_DeleteContext +#define MIR_GL_GetSwapInterval SDL_EGL_GetSwapInterval +#define MIR_GL_SetSwapInterval SDL_EGL_SetSwapInterval + +extern void +MIR_GL_SwapWindow(_THIS, SDL_Window* window); + +extern int +MIR_GL_MakeCurrent(_THIS, SDL_Window* window, SDL_GLContext context); + +extern SDL_GLContext +MIR_GL_CreateContext(_THIS, SDL_Window* window); + +extern int +MIR_GL_LoadLibrary(_THIS, const char* path); + +extern void +MIR_GL_UnloadLibrary(_THIS); + +extern void* +MIR_GL_GetProcAddress(_THIS, const char* proc); + +#endif /* _SDL_miropengl_h */ + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/jni/SDL2-2.0.3/src/video/mir/SDL_mirsym.h b/jni/SDL2-2.0.3/src/video/mir/SDL_mirsym.h new file mode 100644 index 00000000..fe495e3e --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/mir/SDL_mirsym.h @@ -0,0 +1,48 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* *INDENT-OFF* */ + +SDL_MIR_MODULE(MIR_CLIENT) +SDL_MIR_SYM(MirDisplayConfiguration*,mir_connection_create_display_config,(MirConnection *connection)) +SDL_MIR_SYM(MirSurface *,mir_connection_create_surface_sync,(MirConnection *connection, MirSurfaceParameters const *params)) +SDL_MIR_SYM(void,mir_connection_get_available_surface_formats,(MirConnection* connection, MirPixelFormat* formats, unsigned const int format_size, unsigned int *num_valid_formats)) +SDL_MIR_SYM(MirEGLNativeDisplayType,mir_connection_get_egl_native_display,(MirConnection *connection)) +SDL_MIR_SYM(int,mir_connection_is_valid,(MirConnection *connection)) +SDL_MIR_SYM(void,mir_connection_release,(MirConnection *connection)) +SDL_MIR_SYM(MirConnection *,mir_connect_sync,(char const *server, char const *app_name)) +SDL_MIR_SYM(void,mir_display_config_destroy,(MirDisplayConfiguration* display_configuration)) +SDL_MIR_SYM(MirEGLNativeWindowType,mir_surface_get_egl_native_window,(MirSurface *surface)) +SDL_MIR_SYM(char const *,mir_surface_get_error_message,(MirSurface *surface)) +SDL_MIR_SYM(void,mir_surface_get_graphics_region,(MirSurface *surface, MirGraphicsRegion *graphics_region)) +SDL_MIR_SYM(void,mir_surface_get_parameters,(MirSurface *surface, MirSurfaceParameters *parameters)) +SDL_MIR_SYM(int,mir_surface_is_valid,(MirSurface *surface)) +SDL_MIR_SYM(void,mir_surface_release_sync,(MirSurface *surface)) +SDL_MIR_SYM(void,mir_surface_set_event_handler,(MirSurface *surface, MirEventDelegate const *event_handler)) +SDL_MIR_SYM(MirWaitHandle*,mir_surface_set_type,(MirSurface *surface, MirSurfaceType type)) +SDL_MIR_SYM(void,mir_surface_swap_buffers_sync,(MirSurface *surface)) + +SDL_MIR_MODULE(XKBCOMMON) +SDL_MIR_SYM(int,xkb_keysym_to_utf8,(xkb_keysym_t keysym, char *buffer, size_t size)) + +/* *INDENT-ON* */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/video/mir/SDL_mirvideo.c b/jni/SDL2-2.0.3/src/video/mir/SDL_mirvideo.c new file mode 100644 index 00000000..ad6de151 --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/mir/SDL_mirvideo.c @@ -0,0 +1,345 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + Contributed by Brandon Schaefer, +*/ + +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_MIR + +#include "SDL_video.h" + +#include "SDL_mirframebuffer.h" +#include "SDL_mirmouse.h" +#include "SDL_miropengl.h" +#include "SDL_mirvideo.h" +#include "SDL_mirwindow.h" + +#include "SDL_mirdyn.h" + +#define MIR_DRIVER_NAME "mir" + +static int +MIR_VideoInit(_THIS); + +static void +MIR_VideoQuit(_THIS); + +static int +MIR_GetDisplayBounds(_THIS, SDL_VideoDisplay* display, SDL_Rect* rect); + +static void +MIR_GetDisplayModes(_THIS, SDL_VideoDisplay* sdl_display); + +static int +MIR_SetDisplayMode(_THIS, SDL_VideoDisplay* sdl_display, SDL_DisplayMode* mode); + +static SDL_WindowShaper* +MIR_CreateShaper(SDL_Window* window) +{ + /* FIXME Im not sure if mir support this atm, will have to come back to this */ + return NULL; +} + +static int +MIR_SetWindowShape(SDL_WindowShaper* shaper, SDL_Surface* shape, SDL_WindowShapeMode* shape_mode) +{ + return SDL_Unsupported(); +} + +static int +MIR_ResizeWindowShape(SDL_Window* window) +{ + return SDL_Unsupported(); +} + +static int +MIR_Available() +{ + int available = 0; + + if (SDL_MIR_LoadSymbols()) { + /* !!! FIXME: try to make a MirConnection here. */ + available = 1; + SDL_MIR_UnloadSymbols(); + + } + + return available; +} + +static void +MIR_DeleteDevice(SDL_VideoDevice* device) +{ + SDL_free(device); + SDL_MIR_UnloadSymbols(); +} + +void +MIR_PumpEvents(_THIS) +{ +} + +static SDL_VideoDevice* +MIR_CreateDevice(int device_index) +{ + MIR_Data* mir_data; + SDL_VideoDevice* device = NULL; + + if (!SDL_MIR_LoadSymbols()) { + return NULL; + } + + device = SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + SDL_MIR_UnloadSymbols(); + SDL_OutOfMemory(); + return NULL; + } + + mir_data = SDL_calloc(1, sizeof(MIR_Data)); + if (!mir_data) { + SDL_free(device); + SDL_MIR_UnloadSymbols(); + SDL_OutOfMemory(); + return NULL; + } + + device->driverdata = mir_data; + + /* mirvideo */ + device->VideoInit = MIR_VideoInit; + device->VideoQuit = MIR_VideoQuit; + device->GetDisplayBounds = MIR_GetDisplayBounds; + device->GetDisplayModes = MIR_GetDisplayModes; + device->SetDisplayMode = MIR_SetDisplayMode; + device->free = MIR_DeleteDevice; + + /* miropengles */ + device->GL_SwapWindow = MIR_GL_SwapWindow; + device->GL_MakeCurrent = MIR_GL_MakeCurrent; + device->GL_CreateContext = MIR_GL_CreateContext; + device->GL_DeleteContext = MIR_GL_DeleteContext; + device->GL_LoadLibrary = MIR_GL_LoadLibrary; + device->GL_UnloadLibrary = MIR_GL_UnloadLibrary; + device->GL_GetSwapInterval = MIR_GL_GetSwapInterval; + device->GL_SetSwapInterval = MIR_GL_SetSwapInterval; + device->GL_GetProcAddress = MIR_GL_GetProcAddress; + + /* mirwindow */ + device->CreateWindow = MIR_CreateWindow; + device->DestroyWindow = MIR_DestroyWindow; + device->GetWindowWMInfo = MIR_GetWindowWMInfo; + device->SetWindowFullscreen = MIR_SetWindowFullscreen; + device->MaximizeWindow = MIR_MaximizeWindow; + device->MinimizeWindow = MIR_MinimizeWindow; + device->RestoreWindow = MIR_RestoreWindow; + + device->CreateWindowFrom = NULL; + device->SetWindowTitle = NULL; + device->SetWindowIcon = NULL; + device->SetWindowPosition = NULL; + device->SetWindowSize = NULL; + device->SetWindowMinimumSize = NULL; + device->SetWindowMaximumSize = NULL; + device->ShowWindow = NULL; + device->HideWindow = NULL; + device->RaiseWindow = NULL; + device->SetWindowBordered = NULL; + device->SetWindowGammaRamp = NULL; + device->GetWindowGammaRamp = NULL; + device->SetWindowGrab = NULL; + device->OnWindowEnter = NULL; + + /* mirframebuffer */ + device->CreateWindowFramebuffer = MIR_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = MIR_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = MIR_DestroyWindowFramebuffer; + + device->shape_driver.CreateShaper = MIR_CreateShaper; + device->shape_driver.SetWindowShape = MIR_SetWindowShape; + device->shape_driver.ResizeWindowShape = MIR_ResizeWindowShape; + + device->PumpEvents = MIR_PumpEvents; + + device->SuspendScreenSaver = NULL; + + device->StartTextInput = NULL; + device->StopTextInput = NULL; + device->SetTextInputRect = NULL; + + device->HasScreenKeyboardSupport = NULL; + device->ShowScreenKeyboard = NULL; + device->HideScreenKeyboard = NULL; + device->IsScreenKeyboardShown = NULL; + + device->SetClipboardText = NULL; + device->GetClipboardText = NULL; + device->HasClipboardText = NULL; + + device->ShowMessageBox = NULL; + + return device; +} + +VideoBootStrap MIR_bootstrap = { + MIR_DRIVER_NAME, "SDL Mir video driver", + MIR_Available, MIR_CreateDevice +}; + +static void +MIR_SetCurrentDisplayMode(MirDisplayOutput const* out, SDL_VideoDisplay* display) +{ + SDL_DisplayMode mode = { + .format = SDL_PIXELFORMAT_RGB888, + .w = out->modes[out->current_mode].horizontal_resolution, + .h = out->modes[out->current_mode].vertical_resolution, + .refresh_rate = out->modes[out->current_mode].refresh_rate, + .driverdata = NULL + }; + + display->desktop_mode = mode; + display->current_mode = mode; +} + +static void +MIR_AddAllModesFromDisplay(MirDisplayOutput const* out, SDL_VideoDisplay* display) +{ + int n_mode; + for (n_mode = 0; n_mode < out->num_modes; ++n_mode) { + SDL_DisplayMode mode = { + .format = SDL_PIXELFORMAT_RGB888, + .w = out->modes[n_mode].horizontal_resolution, + .h = out->modes[n_mode].vertical_resolution, + .refresh_rate = out->modes[n_mode].refresh_rate, + .driverdata = NULL + }; + + SDL_AddDisplayMode(display, &mode); + } +} + +static void +MIR_InitDisplays(_THIS) +{ + MIR_Data* mir_data = _this->driverdata; + int d; + + MirDisplayConfiguration* display_config = MIR_mir_connection_create_display_config(mir_data->connection); + + for (d = 0; d < display_config->num_outputs; d++) { + MirDisplayOutput const* out = display_config->outputs + d; + + SDL_VideoDisplay display; + SDL_zero(display); + + if (out->used && + out->connected && + out->num_modes && + out->current_mode < out->num_modes) { + + MIR_SetCurrentDisplayMode(out, &display); + MIR_AddAllModesFromDisplay(out, &display); + + SDL_AddVideoDisplay(&display); + } + } + + MIR_mir_display_config_destroy(display_config); +} + +int +MIR_VideoInit(_THIS) +{ + MIR_Data* mir_data = _this->driverdata; + + mir_data->connection = MIR_mir_connect_sync(NULL, __PRETTY_FUNCTION__); + + if (!MIR_mir_connection_is_valid(mir_data->connection)) + return SDL_SetError("Failed to connect to the Mir Server"); + + MIR_InitDisplays(_this); + MIR_InitMouse(); + + return 0; +} + +void +MIR_VideoQuit(_THIS) +{ + MIR_Data* mir_data = _this->driverdata; + + MIR_FiniMouse(); + + MIR_GL_DeleteContext(_this, NULL); + MIR_GL_UnloadLibrary(_this); + + MIR_mir_connection_release(mir_data->connection); + + SDL_free(mir_data); + _this->driverdata = NULL; +} + +static int +MIR_GetDisplayBounds(_THIS, SDL_VideoDisplay* display, SDL_Rect* rect) +{ + MIR_Data* mir_data = _this->driverdata; + int d; + + MirDisplayConfiguration* display_config = MIR_mir_connection_create_display_config(mir_data->connection); + + for (d = 0; d < display_config->num_outputs; d++) { + MirDisplayOutput const* out = display_config->outputs + d; + + if (out->used && + out->connected && + out->num_modes && + out->current_mode < out->num_modes) { + + rect->x = out->position_x; + rect->y = out->position_y; + rect->w = out->modes->horizontal_resolution; + rect->h = out->modes->vertical_resolution; + } + } + + MIR_mir_display_config_destroy(display_config); + + return 0; +} + +static void +MIR_GetDisplayModes(_THIS, SDL_VideoDisplay* sdl_display) +{ +} + +static int +MIR_SetDisplayMode(_THIS, SDL_VideoDisplay* sdl_display, SDL_DisplayMode* mode) +{ + return 0; +} + +#endif /* SDL_VIDEO_DRIVER_MIR */ + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/jni/SDL2-2.0.3/src/video/mir/SDL_mirvideo.h b/jni/SDL2-2.0.3/src/video/mir/SDL_mirvideo.h new file mode 100644 index 00000000..edeca01a --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/mir/SDL_mirvideo.h @@ -0,0 +1,39 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + Contributed by Brandon Schaefer, +*/ + +#ifndef _SDL_mirvideo_h_ +#define _SDL_mirvideo_h_ + +#include +#include + +typedef struct +{ + MirConnection* connection; +} MIR_Data; + +#endif /* _SDL_mirvideo_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/video/mir/SDL_mirwindow.c b/jni/SDL2-2.0.3/src/video/mir/SDL_mirwindow.c new file mode 100644 index 00000000..d233db47 --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/mir/SDL_mirwindow.c @@ -0,0 +1,227 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + Contributed by Brandon Schaefer, +*/ + +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_MIR + +#include "../SDL_egl_c.h" +#include "../SDL_sysvideo.h" + +#include "SDL_mirevents.h" +#include "SDL_mirwindow.h" + +#include "SDL_mirdyn.h" + +int +IsSurfaceValid(MIR_Window* mir_window) +{ + if (!MIR_mir_surface_is_valid(mir_window->surface)) { + const char* error = MIR_mir_surface_get_error_message(mir_window->surface); + return SDL_SetError("Failed to created a mir surface: %s", error); + } + + return 0; +} + +MirPixelFormat +FindValidPixelFormat(MIR_Data* mir_data) +{ + unsigned int pf_size = 32; + unsigned int valid_formats; + unsigned int f; + + MirPixelFormat formats[pf_size]; + MIR_mir_connection_get_available_surface_formats(mir_data->connection, formats, + pf_size, &valid_formats); + + for (f = 0; f < valid_formats; f++) { + MirPixelFormat cur_pf = formats[f]; + + if (cur_pf == mir_pixel_format_abgr_8888 || + cur_pf == mir_pixel_format_xbgr_8888 || + cur_pf == mir_pixel_format_argb_8888 || + cur_pf == mir_pixel_format_xrgb_8888) { + + return cur_pf; + } + } + + return mir_pixel_format_invalid; +} + +int +MIR_CreateWindow(_THIS, SDL_Window* window) +{ + MIR_Window* mir_window; + MIR_Data* mir_data; + + MirSurfaceParameters surfaceparm = + { + .name = "MirSurface", + .width = window->w, + .height = window->h, + .pixel_format = mir_pixel_format_invalid, + .buffer_usage = mir_buffer_usage_hardware + }; + + MirEventDelegate delegate = { + MIR_HandleInput, + window + }; + + mir_window = SDL_calloc(1, sizeof(MIR_Window)); + if (!mir_window) + return SDL_OutOfMemory(); + + mir_data = _this->driverdata; + window->driverdata = mir_window; + + if (window->x == SDL_WINDOWPOS_UNDEFINED) + window->x = 0; + + if (window->y == SDL_WINDOWPOS_UNDEFINED) + window->y = 0; + + mir_window->mir_data = mir_data; + mir_window->sdl_window = window; + + surfaceparm.pixel_format = FindValidPixelFormat(mir_data); + if (surfaceparm.pixel_format == mir_pixel_format_invalid) { + return SDL_SetError("Failed to find a valid pixel format."); + } + + mir_window->surface = MIR_mir_connection_create_surface_sync(mir_data->connection, &surfaceparm); + if (!MIR_mir_surface_is_valid(mir_window->surface)) { + const char* error = MIR_mir_surface_get_error_message(mir_window->surface); + return SDL_SetError("Failed to created a mir surface: %s", error); + } + + if (window->flags & SDL_WINDOW_OPENGL) { + EGLNativeWindowType egl_native_window = + (EGLNativeWindowType)MIR_mir_surface_get_egl_native_window(mir_window->surface); + + mir_window->egl_surface = SDL_EGL_CreateSurface(_this, egl_native_window); + + if (mir_window->egl_surface == EGL_NO_SURFACE) { + return SDL_SetError("Failed to created a window surface %p", + _this->egl_data->egl_display); + } + } + else { + mir_window->egl_surface = EGL_NO_SURFACE; + } + + MIR_mir_surface_set_event_handler(mir_window->surface, &delegate); + + return 0; +} + +void +MIR_DestroyWindow(_THIS, SDL_Window* window) +{ + MIR_Data* mir_data = _this->driverdata; + MIR_Window* mir_window = window->driverdata; + + window->driverdata = NULL; + + if (mir_data) { + SDL_EGL_DestroySurface(_this, mir_window->egl_surface); + MIR_mir_surface_release_sync(mir_window->surface); + + SDL_free(mir_window); + } +} + +SDL_bool +MIR_GetWindowWMInfo(_THIS, SDL_Window* window, SDL_SysWMinfo* info) +{ + if (info->version.major == SDL_MAJOR_VERSION && + info->version.minor == SDL_MINOR_VERSION) { + MIR_Window* mir_window = window->driverdata; + + info->subsystem = SDL_SYSWM_MIR; + info->info.mir.connection = mir_window->mir_data->connection; + info->info.mir.surface = mir_window->surface; + + return SDL_TRUE; + } + + return SDL_FALSE; +} + +void +MIR_SetWindowFullscreen(_THIS, SDL_Window* window, + SDL_VideoDisplay* display, + SDL_bool fullscreen) +{ + MIR_Window* mir_window = window->driverdata; + + if (IsSurfaceValid(mir_window) < 0) + return; + + if (fullscreen) { + MIR_mir_surface_set_type(mir_window->surface, mir_surface_state_fullscreen); + } else { + MIR_mir_surface_set_type(mir_window->surface, mir_surface_state_restored); + } +} + +void +MIR_MaximizeWindow(_THIS, SDL_Window* window) +{ + MIR_Window* mir_window = window->driverdata; + + if (IsSurfaceValid(mir_window) < 0) + return; + + MIR_mir_surface_set_type(mir_window->surface, mir_surface_state_maximized); +} + +void +MIR_MinimizeWindow(_THIS, SDL_Window* window) +{ + MIR_Window* mir_window = window->driverdata; + + if (IsSurfaceValid(mir_window) < 0) + return; + + MIR_mir_surface_set_type(mir_window->surface, mir_surface_state_minimized); +} + +void +MIR_RestoreWindow(_THIS, SDL_Window * window) +{ + MIR_Window* mir_window = window->driverdata; + + if (IsSurfaceValid(mir_window) < 0) + return; + + MIR_mir_surface_set_type(mir_window->surface, mir_surface_state_restored); +} + +#endif /* SDL_VIDEO_DRIVER_MIR */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/video/mir/SDL_mirwindow.h b/jni/SDL2-2.0.3/src/video/mir/SDL_mirwindow.h new file mode 100644 index 00000000..411c1485 --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/mir/SDL_mirwindow.h @@ -0,0 +1,69 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + Contributed by Brandon Schaefer, +*/ + +#ifndef _SDL_mirwindow_h +#define _SDL_mirwindow_h + +#include "../SDL_sysvideo.h" +#include "SDL_syswm.h" + +#include "SDL_mirvideo.h" + +typedef struct { + SDL_Window* sdl_window; + MIR_Data* mir_data; + + MirSurface* surface; + EGLSurface egl_surface; +} MIR_Window; + + +extern int +MIR_CreateWindow(_THIS, SDL_Window* window); + +extern void +MIR_DestroyWindow(_THIS, SDL_Window* window); + +extern void +MIR_SetWindowFullscreen(_THIS, SDL_Window* window, + SDL_VideoDisplay* display, + SDL_bool fullscreen); + +extern void +MIR_MaximizeWindow(_THIS, SDL_Window* window); + +extern void +MIR_MinimizeWindow(_THIS, SDL_Window* window); + +extern void +MIR_RestoreWindow(_THIS, SDL_Window* window); + +extern SDL_bool +MIR_GetWindowWMInfo(_THIS, SDL_Window* window, SDL_SysWMinfo* info); + +#endif /* _SDL_mirwindow */ + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/jni/SDL2-2.0.1/src/video/pandora/SDL_pandora.c b/jni/SDL2-2.0.3/src/video/pandora/SDL_pandora.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/pandora/SDL_pandora.c rename to jni/SDL2-2.0.3/src/video/pandora/SDL_pandora.c index 2e182bb1..10ca3824 100644 --- a/jni/SDL2-2.0.1/src/video/pandora/SDL_pandora.c +++ b/jni/SDL2-2.0.3/src/video/pandora/SDL_pandora.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/pandora/SDL_pandora.h b/jni/SDL2-2.0.3/src/video/pandora/SDL_pandora.h similarity index 98% rename from jni/SDL2-2.0.1/src/video/pandora/SDL_pandora.h rename to jni/SDL2-2.0.3/src/video/pandora/SDL_pandora.h index a5edcd41..802365ee 100644 --- a/jni/SDL2-2.0.1/src/video/pandora/SDL_pandora.h +++ b/jni/SDL2-2.0.3/src/video/pandora/SDL_pandora.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/pandora/SDL_pandora_events.c b/jni/SDL2-2.0.3/src/video/pandora/SDL_pandora_events.c similarity index 95% rename from jni/SDL2-2.0.1/src/video/pandora/SDL_pandora_events.c rename to jni/SDL2-2.0.3/src/video/pandora/SDL_pandora_events.c index 32592821..eedbc293 100644 --- a/jni/SDL2-2.0.1/src/video/pandora/SDL_pandora_events.c +++ b/jni/SDL2-2.0.3/src/video/pandora/SDL_pandora_events.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/pandora/SDL_pandora_events.h b/jni/SDL2-2.0.3/src/video/pandora/SDL_pandora_events.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/pandora/SDL_pandora_events.h rename to jni/SDL2-2.0.3/src/video/pandora/SDL_pandora_events.h index aefe6f74..e628d14a 100644 --- a/jni/SDL2-2.0.1/src/video/pandora/SDL_pandora_events.h +++ b/jni/SDL2-2.0.3/src/video/pandora/SDL_pandora_events.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/psp/SDL_pspevents.c b/jni/SDL2-2.0.3/src/video/psp/SDL_pspevents.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/psp/SDL_pspevents.c rename to jni/SDL2-2.0.3/src/video/psp/SDL_pspevents.c index 87bc5299..d096c061 100644 --- a/jni/SDL2-2.0.1/src/video/psp/SDL_pspevents.c +++ b/jni/SDL2-2.0.3/src/video/psp/SDL_pspevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/psp/SDL_pspevents_c.h b/jni/SDL2-2.0.3/src/video/psp/SDL_pspevents_c.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/psp/SDL_pspevents_c.h rename to jni/SDL2-2.0.3/src/video/psp/SDL_pspevents_c.h index e02c11db..af45c4d1 100644 --- a/jni/SDL2-2.0.1/src/video/psp/SDL_pspevents_c.h +++ b/jni/SDL2-2.0.3/src/video/psp/SDL_pspevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/psp/SDL_pspgl.c b/jni/SDL2-2.0.3/src/video/psp/SDL_pspgl.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/psp/SDL_pspgl.c rename to jni/SDL2-2.0.3/src/video/psp/SDL_pspgl.c index fbbc20cc..d24e7229 100644 --- a/jni/SDL2-2.0.1/src/video/psp/SDL_pspgl.c +++ b/jni/SDL2-2.0.3/src/video/psp/SDL_pspgl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/psp/SDL_pspgl_c.h b/jni/SDL2-2.0.3/src/video/psp/SDL_pspgl_c.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/psp/SDL_pspgl_c.h rename to jni/SDL2-2.0.3/src/video/psp/SDL_pspgl_c.h index 8b20d154..c0c15d95 100644 --- a/jni/SDL2-2.0.1/src/video/psp/SDL_pspgl_c.h +++ b/jni/SDL2-2.0.3/src/video/psp/SDL_pspgl_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/psp/SDL_pspmouse.c b/jni/SDL2-2.0.3/src/video/psp/SDL_pspmouse.c similarity index 94% rename from jni/SDL2-2.0.1/src/video/psp/SDL_pspmouse.c rename to jni/SDL2-2.0.3/src/video/psp/SDL_pspmouse.c index 002a518b..8df3d614 100644 --- a/jni/SDL2-2.0.1/src/video/psp/SDL_pspmouse.c +++ b/jni/SDL2-2.0.3/src/video/psp/SDL_pspmouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/psp/SDL_pspmouse_c.h b/jni/SDL2-2.0.3/src/video/psp/SDL_pspmouse_c.h similarity index 93% rename from jni/SDL2-2.0.1/src/video/psp/SDL_pspmouse_c.h rename to jni/SDL2-2.0.3/src/video/psp/SDL_pspmouse_c.h index a0836a30..d14b84b9 100644 --- a/jni/SDL2-2.0.1/src/video/psp/SDL_pspmouse_c.h +++ b/jni/SDL2-2.0.3/src/video/psp/SDL_pspmouse_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/psp/SDL_pspvideo.c b/jni/SDL2-2.0.3/src/video/psp/SDL_pspvideo.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/psp/SDL_pspvideo.c rename to jni/SDL2-2.0.3/src/video/psp/SDL_pspvideo.c index bc68a660..b3787239 100644 --- a/jni/SDL2-2.0.1/src/video/psp/SDL_pspvideo.c +++ b/jni/SDL2-2.0.3/src/video/psp/SDL_pspvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/psp/SDL_pspvideo.h b/jni/SDL2-2.0.3/src/video/psp/SDL_pspvideo.h similarity index 98% rename from jni/SDL2-2.0.1/src/video/psp/SDL_pspvideo.h rename to jni/SDL2-2.0.3/src/video/psp/SDL_pspvideo.h index 0ade001a..2e1bb241 100644 --- a/jni/SDL2-2.0.1/src/video/psp/SDL_pspvideo.h +++ b/jni/SDL2-2.0.3/src/video/psp/SDL_pspvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/raspberry/SDL_rpievents.c b/jni/SDL2-2.0.3/src/video/raspberry/SDL_rpievents.c similarity index 95% rename from jni/SDL2-2.0.1/src/video/raspberry/SDL_rpievents.c rename to jni/SDL2-2.0.3/src/video/raspberry/SDL_rpievents.c index 7e8559c7..cdfc746a 100644 --- a/jni/SDL2-2.0.1/src/video/raspberry/SDL_rpievents.c +++ b/jni/SDL2-2.0.3/src/video/raspberry/SDL_rpievents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/raspberry/SDL_rpievents_c.h b/jni/SDL2-2.0.3/src/video/raspberry/SDL_rpievents_c.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/raspberry/SDL_rpievents_c.h rename to jni/SDL2-2.0.3/src/video/raspberry/SDL_rpievents_c.h index 54d3119d..e69c5917 100644 --- a/jni/SDL2-2.0.1/src/video/raspberry/SDL_rpievents_c.h +++ b/jni/SDL2-2.0.3/src/video/raspberry/SDL_rpievents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/raspberry/SDL_rpimouse.c b/jni/SDL2-2.0.3/src/video/raspberry/SDL_rpimouse.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/raspberry/SDL_rpimouse.c rename to jni/SDL2-2.0.3/src/video/raspberry/SDL_rpimouse.c index 6d222d3d..718fef81 100644 --- a/jni/SDL2-2.0.1/src/video/raspberry/SDL_rpimouse.c +++ b/jni/SDL2-2.0.3/src/video/raspberry/SDL_rpimouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/raspberry/SDL_rpimouse.h b/jni/SDL2-2.0.3/src/video/raspberry/SDL_rpimouse.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/raspberry/SDL_rpimouse.h rename to jni/SDL2-2.0.3/src/video/raspberry/SDL_rpimouse.h index aa8eec9b..a39e6549 100644 --- a/jni/SDL2-2.0.1/src/video/raspberry/SDL_rpimouse.h +++ b/jni/SDL2-2.0.3/src/video/raspberry/SDL_rpimouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/raspberry/SDL_rpiopengles.c b/jni/SDL2-2.0.3/src/video/raspberry/SDL_rpiopengles.c similarity index 95% rename from jni/SDL2-2.0.1/src/video/raspberry/SDL_rpiopengles.c rename to jni/SDL2-2.0.3/src/video/raspberry/SDL_rpiopengles.c index 46d7e029..c6f462b2 100644 --- a/jni/SDL2-2.0.1/src/video/raspberry/SDL_rpiopengles.c +++ b/jni/SDL2-2.0.3/src/video/raspberry/SDL_rpiopengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/raspberry/SDL_rpiopengles.h b/jni/SDL2-2.0.3/src/video/raspberry/SDL_rpiopengles.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/raspberry/SDL_rpiopengles.h rename to jni/SDL2-2.0.3/src/video/raspberry/SDL_rpiopengles.h index e1afa701..5ef8f8ff 100644 --- a/jni/SDL2-2.0.1/src/video/raspberry/SDL_rpiopengles.h +++ b/jni/SDL2-2.0.3/src/video/raspberry/SDL_rpiopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/raspberry/SDL_rpivideo.c b/jni/SDL2-2.0.3/src/video/raspberry/SDL_rpivideo.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/raspberry/SDL_rpivideo.c rename to jni/SDL2-2.0.3/src/video/raspberry/SDL_rpivideo.c index f9922b5f..8391c762 100644 --- a/jni/SDL2-2.0.1/src/video/raspberry/SDL_rpivideo.c +++ b/jni/SDL2-2.0.3/src/video/raspberry/SDL_rpivideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/raspberry/SDL_rpivideo.h b/jni/SDL2-2.0.3/src/video/raspberry/SDL_rpivideo.h similarity index 98% rename from jni/SDL2-2.0.1/src/video/raspberry/SDL_rpivideo.h rename to jni/SDL2-2.0.3/src/video/raspberry/SDL_rpivideo.h index 14be2e42..4de8983c 100644 --- a/jni/SDL2-2.0.1/src/video/raspberry/SDL_rpivideo.h +++ b/jni/SDL2-2.0.3/src/video/raspberry/SDL_rpivideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/sdlgenblit.pl b/jni/SDL2-2.0.3/src/video/sdlgenblit.pl similarity index 99% rename from jni/SDL2-2.0.1/src/video/sdlgenblit.pl rename to jni/SDL2-2.0.3/src/video/sdlgenblit.pl index fb87f750..091d5663 100755 --- a/jni/SDL2-2.0.1/src/video/sdlgenblit.pl +++ b/jni/SDL2-2.0.3/src/video/sdlgenblit.pl @@ -82,7 +82,7 @@ sub open_file { /* DO NOT EDIT! This file is generated by sdlgenblit.pl */ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitappdelegate.h b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitappdelegate.h rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.h index b375f2e3..d5430beb 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitappdelegate.h +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitappdelegate.m b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.m similarity index 99% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitappdelegate.m rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.m index 7078ac5d..a9924fbc 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitappdelegate.m +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitappdelegate.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitevents.h b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitevents.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitevents.h rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitevents.h index 39ee4ca3..d9fb4ab3 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitevents.h +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitevents.m b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitevents.m similarity index 97% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitevents.m rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitevents.m index c94bff4b..94fba878 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitevents.m +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitevents.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitmessagebox.h b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitmessagebox.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitmessagebox.h rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitmessagebox.h index f5817579..86af87b5 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitmessagebox.h +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitmessagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitmessagebox.m b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitmessagebox.m similarity index 98% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitmessagebox.m rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitmessagebox.m index c01f9bc8..8fa8bc97 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitmessagebox.m +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitmessagebox.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitmodes.h b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitmodes.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitmodes.h rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitmodes.h index edc4ca2e..ae9ced65 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitmodes.h +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitmodes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitmodes.m b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitmodes.m similarity index 99% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitmodes.m rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitmodes.m index 54c27736..dddb2f14 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitmodes.m +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitmodes.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitopengles.h b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitopengles.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitopengles.h rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitopengles.h index cb816484..947678ca 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitopengles.h +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitopengles.m b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitopengles.m similarity index 99% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitopengles.m rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitopengles.m index f782ffd1..42303e3c 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitopengles.m +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitopengles.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitopenglview.h b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitopenglview.h similarity index 97% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitopenglview.h rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitopenglview.h index 344ad6a5..f04b5b0b 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitopenglview.h +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitopenglview.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitopenglview.m b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitopenglview.m similarity index 95% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitopenglview.m rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitopenglview.m index 4a9a69e8..5c163c9a 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitopenglview.m +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitopenglview.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -56,6 +56,11 @@ const BOOL useDepthBuffer = (depthBits != 0); NSString *colorFormat = nil; + /* The EAGLRenderingAPI enum values currently map 1:1 to major GLES + versions, and this allows us to handle future OpenGL ES versions. + */ + EAGLRenderingAPI api = majorVersion; + if (rBits == 8 && gBits == 8 && bBits == 8) { /* if user specifically requests rbg888 or some color format higher than 16bpp */ colorFormat = kEAGLColorFormatRGBA8; @@ -71,11 +76,7 @@ eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool: retained], kEAGLDrawablePropertyRetainedBacking, colorFormat, kEAGLDrawablePropertyColorFormat, nil]; - if (majorVersion > 1) { - context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup:shareGroup]; - } else { - context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1 sharegroup:shareGroup]; - } + context = [[EAGLContext alloc] initWithAPI:api sharegroup:shareGroup]; if (!context || ![EAGLContext setCurrentContext:context]) { [self release]; SDL_SetError("OpenGL ES %d not supported", majorVersion); diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitvideo.h b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitvideo.h similarity index 97% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitvideo.h rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitvideo.h index 8969e91e..ef629825 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitvideo.h +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitvideo.m b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitvideo.m similarity index 98% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitvideo.m rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitvideo.m index c19c637f..4893bc16 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitvideo.m +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitvideo.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitview.h b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitview.h similarity index 97% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitview.h rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitview.h index 3921be13..ce616c07 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitview.h +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitview.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitview.m b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitview.m similarity index 99% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitview.m rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitview.m index 841ebbb3..f890b7a8 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitview.m +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitview.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitviewcontroller.h b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitviewcontroller.h rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.h index a69c1e11..e8d595d9 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitviewcontroller.h +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitviewcontroller.m b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m similarity index 98% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitviewcontroller.m rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m index df7b90e6..447b80b8 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitviewcontroller.m +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitviewcontroller.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitwindow.h b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitwindow.h rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.h index effad90c..494b028f 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitwindow.h +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitwindow.m b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m similarity index 99% rename from jni/SDL2-2.0.1/src/video/uikit/SDL_uikitwindow.m rename to jni/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m index 08b91949..a1dd1a9e 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/SDL_uikitwindow.m +++ b/jni/SDL2-2.0.3/src/video/uikit/SDL_uikitwindow.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/uikit/keyinfotable.h b/jni/SDL2-2.0.3/src/video/uikit/keyinfotable.h similarity index 99% rename from jni/SDL2-2.0.1/src/video/uikit/keyinfotable.h rename to jni/SDL2-2.0.3/src/video/uikit/keyinfotable.h index d588f915..1d16868c 100644 --- a/jni/SDL2-2.0.1/src/video/uikit/keyinfotable.h +++ b/jni/SDL2-2.0.3/src/video/uikit/keyinfotable.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylanddyn.c b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylanddyn.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/wayland/SDL_waylanddyn.c rename to jni/SDL2-2.0.3/src/video/wayland/SDL_waylanddyn.c index c2ee8d84..1ed29db5 100644 --- a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylanddyn.c +++ b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylanddyn.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylanddyn.h b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylanddyn.h similarity index 98% rename from jni/SDL2-2.0.1/src/video/wayland/SDL_waylanddyn.h rename to jni/SDL2-2.0.3/src/video/wayland/SDL_waylanddyn.h index a1ff5571..8d9313a2 100644 --- a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylanddyn.h +++ b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylanddyn.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandevents.c b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandevents.c similarity index 82% rename from jni/SDL2-2.0.1/src/video/wayland/SDL_waylandevents.c rename to jni/SDL2-2.0.3/src/video/wayland/SDL_waylandevents.c index 61785742..cb729001 100644 --- a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandevents.c +++ b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -86,10 +86,19 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer, /* enter event for a window we've just destroyed */ return; } + + /* This handler will be called twice in Wayland 1.4 + * Once for the window surface which has valid user data + * and again for the mouse cursor surface which does not have valid user data + * We ignore the later + */ - input->pointer_focus = wl_surface_get_user_data(surface); - window = input->pointer_focus; - SDL_SetMouseFocus(window->sdlwindow); + window = (SDL_WindowData *)wl_surface_get_user_data(surface); + + if (window) { + input->pointer_focus = window; + SDL_SetMouseFocus(window->sdlwindow); + } } static void @@ -98,8 +107,10 @@ pointer_handle_leave(void *data, struct wl_pointer *pointer, { struct SDL_WaylandInput *input = data; - SDL_SetMouseFocus(NULL); - input->pointer_focus = NULL; + if (input->pointer_focus) { + SDL_SetMouseFocus(NULL); + input->pointer_focus = NULL; + } } static void @@ -110,8 +121,9 @@ pointer_handle_motion(void *data, struct wl_pointer *pointer, SDL_WindowData *window = input->pointer_focus; int sx = wl_fixed_to_int(sx_w); int sy = wl_fixed_to_int(sy_w); - - SDL_SendMouseMotion(window->sdlwindow, 0, 0, sx, sy); + if (input->pointer_focus) { + SDL_SendMouseMotion(window->sdlwindow, 0, 0, sx, sy); + } } static void @@ -122,29 +134,31 @@ pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial, SDL_WindowData *window = input->pointer_focus; enum wl_pointer_button_state state = state_w; uint32_t sdl_button; + + if (input->pointer_focus) { + switch (button) { + case BTN_LEFT: + sdl_button = SDL_BUTTON_LEFT; + break; + case BTN_MIDDLE: + sdl_button = SDL_BUTTON_MIDDLE; + break; + case BTN_RIGHT: + sdl_button = SDL_BUTTON_RIGHT; + break; + case BTN_SIDE: + sdl_button = SDL_BUTTON_X1; + break; + case BTN_EXTRA: + sdl_button = SDL_BUTTON_X2; + break; + default: + return; + } - switch (button) { - case BTN_LEFT: - sdl_button = SDL_BUTTON_LEFT; - break; - case BTN_MIDDLE: - sdl_button = SDL_BUTTON_MIDDLE; - break; - case BTN_RIGHT: - sdl_button = SDL_BUTTON_RIGHT; - break; - case BTN_SIDE: - sdl_button = SDL_BUTTON_X1; - break; - case BTN_EXTRA: - sdl_button = SDL_BUTTON_X2; - break; - default: - return; + SDL_SendMouseButton(window->sdlwindow, 0, + state ? SDL_PRESSED : SDL_RELEASED, sdl_button); } - - SDL_SendMouseButton(window->sdlwindow, 0, - state ? SDL_PRESSED : SDL_RELEASED, sdl_button); } static void @@ -156,20 +170,22 @@ pointer_handle_axis(void *data, struct wl_pointer *pointer, enum wl_pointer_axis a = axis; int x, y; - switch (a) { - case WL_POINTER_AXIS_VERTICAL_SCROLL: - x = 0; - y = wl_fixed_to_int(value); - break; - case WL_POINTER_AXIS_HORIZONTAL_SCROLL: - x = wl_fixed_to_int(value); - y = 0; - break; - default: - return; - } + if (input->pointer_focus) { + switch (a) { + case WL_POINTER_AXIS_VERTICAL_SCROLL: + x = 0; + y = wl_fixed_to_int(value); + break; + case WL_POINTER_AXIS_HORIZONTAL_SCROLL: + x = wl_fixed_to_int(value); + y = 0; + break; + default: + return; + } - SDL_SendMouseWheel(window->sdlwindow, 0, x, y); + SDL_SendMouseWheel(window->sdlwindow, 0, x, y); + } } static const struct wl_pointer_listener pointer_listener = { @@ -234,7 +250,9 @@ keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, input->keyboard_focus = window; window->keyboard_device = input; - SDL_SetKeyboardFocus(window->sdlwindow); + if (window) { + SDL_SetKeyboardFocus(window->sdlwindow); + } } static void @@ -340,11 +358,10 @@ Wayland_display_add_input(SDL_VideoData *d, uint32_t id) { struct SDL_WaylandInput *input; - input = malloc(sizeof *input); + input = SDL_calloc(1, sizeof *input); if (input == NULL) return; - memset(input, 0, sizeof *input); input->display = d; input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, 1); @@ -378,7 +395,7 @@ void Wayland_display_destroy_input(SDL_VideoData *d) if (input->xkb.keymap) WAYLAND_xkb_keymap_unref(input->xkb.keymap); - free(input); + SDL_free(input); d->input = NULL; } diff --git a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandevents_c.h b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandevents_c.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/wayland/SDL_waylandevents_c.h rename to jni/SDL2-2.0.3/src/video/wayland/SDL_waylandevents_c.h index cc88cde9..8a6c3fcd 100644 --- a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandevents_c.h +++ b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandmouse.c b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandmouse.c similarity index 98% rename from jni/SDL2-2.0.1/src/video/wayland/SDL_waylandmouse.c rename to jni/SDL2-2.0.3/src/video/wayland/SDL_waylandmouse.c index ae634b62..07526957 100644 --- a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandmouse.c +++ b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandmouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -181,6 +181,7 @@ Wayland_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) surface->h * surface->pitch); data->surface = wl_compositor_create_surface(wd->compositor); + wl_surface_set_user_data(data->surface, NULL); wl_surface_attach(data->surface, data->buffer, 0, @@ -214,6 +215,7 @@ CreateCursorFromWlCursor(SDL_VideoData *d, struct wl_cursor *wlcursor) * reference to it here */ data->buffer = NULL; data->surface = wl_compositor_create_surface(d->compositor); + wl_surface_set_user_data(data->surface, NULL); wl_surface_attach(data->surface, WAYLAND_wl_cursor_image_get_buffer(wlcursor->images[0]), 0, diff --git a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandmouse.h b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandmouse.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/wayland/SDL_waylandmouse.h rename to jni/SDL2-2.0.3/src/video/wayland/SDL_waylandmouse.h index 3ccd7f1c..efd29d6c 100644 --- a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandmouse.h +++ b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandmouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandopengles.c b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandopengles.c similarity index 96% rename from jni/SDL2-2.0.1/src/video/wayland/SDL_waylandopengles.c rename to jni/SDL2-2.0.3/src/video/wayland/SDL_waylandopengles.c index 47f0161c..45078043 100644 --- a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandopengles.c +++ b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandopengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -88,4 +88,4 @@ Wayland_GLES_DeleteContext(_THIS, SDL_GLContext context) #endif /* SDL_VIDEO_DRIVER_WAYLAND && SDL_VIDEO_OPENGL_EGL */ -/* vi: set ts=4 sw=4 expandtab: */ \ No newline at end of file +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandopengles.h b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandopengles.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/wayland/SDL_waylandopengles.h rename to jni/SDL2-2.0.3/src/video/wayland/SDL_waylandopengles.h index 084a4bdd..77081f81 100644 --- a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandopengles.h +++ b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandsym.h b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandsym.h similarity index 98% rename from jni/SDL2-2.0.1/src/video/wayland/SDL_waylandsym.h rename to jni/SDL2-2.0.3/src/video/wayland/SDL_waylandsym.h index c810fab4..c3b4fa50 100644 --- a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandsym.h +++ b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandsym.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -103,4 +103,4 @@ SDL_WAYLAND_SYM(enum xkb_state_component, xkb_state_update_mask, (struct xkb_sta /* *INDENT-ON* */ /* vi: set ts=4 sw=4 expandtab: */ -//SDL_WAYLAND_SYM(ret, fn, params) \ No newline at end of file +//SDL_WAYLAND_SYM(ret, fn, params) diff --git a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandtouch.c b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandtouch.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/wayland/SDL_waylandtouch.c rename to jni/SDL2-2.0.3/src/video/wayland/SDL_waylandtouch.c index 2c55d6d9..683c7029 100644 --- a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandtouch.c +++ b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandtouch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandtouch.h b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandtouch.h similarity index 99% rename from jni/SDL2-2.0.1/src/video/wayland/SDL_waylandtouch.h rename to jni/SDL2-2.0.3/src/video/wayland/SDL_waylandtouch.h index fe514992..435fd562 100644 --- a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandtouch.h +++ b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandtouch.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandvideo.c b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandvideo.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/wayland/SDL_waylandvideo.c rename to jni/SDL2-2.0.3/src/video/wayland/SDL_waylandvideo.c index 0d4ff196..43826b83 100644 --- a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandvideo.c +++ b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -95,6 +95,7 @@ Wayland_CreateDevice(int devindex) /* Initialize all variables that we clean on shutdown */ device = SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { + SDL_WAYLAND_UnloadSymbols(); SDL_OutOfMemory(); return NULL; } diff --git a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandvideo.h b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandvideo.h similarity index 97% rename from jni/SDL2-2.0.1/src/video/wayland/SDL_waylandvideo.h rename to jni/SDL2-2.0.3/src/video/wayland/SDL_waylandvideo.h index 71f93044..06bcdc48 100644 --- a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandvideo.h +++ b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandwindow.c b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandwindow.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/wayland/SDL_waylandwindow.c rename to jni/SDL2-2.0.3/src/video/wayland/SDL_waylandwindow.c index 3b3fc1a6..f7b339cf 100644 --- a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandwindow.c +++ b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandwindow.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandwindow.h b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandwindow.h similarity index 97% rename from jni/SDL2-2.0.1/src/video/wayland/SDL_waylandwindow.h rename to jni/SDL2-2.0.3/src/video/wayland/SDL_waylandwindow.h index 789c43d3..c1190d52 100644 --- a/jni/SDL2-2.0.1/src/video/wayland/SDL_waylandwindow.h +++ b/jni/SDL2-2.0.3/src/video/wayland/SDL_waylandwindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_msctf.h b/jni/SDL2-2.0.3/src/video/windows/SDL_msctf.h similarity index 91% rename from jni/SDL2-2.0.1/src/video/windows/SDL_msctf.h rename to jni/SDL2-2.0.3/src/video/windows/SDL_msctf.h index 9ff43c05..01e732cf 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_msctf.h +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_msctf.h @@ -1,3 +1,24 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + #ifndef _SDL_msctf_h #define _SDL_msctf_h diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_vkeys.h b/jni/SDL2-2.0.3/src/video/windows/SDL_vkeys.h similarity index 97% rename from jni/SDL2-2.0.1/src/video/windows/SDL_vkeys.h rename to jni/SDL2-2.0.3/src/video/windows/SDL_vkeys.h index ca24e8ff..1ed155a1 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_vkeys.h +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_vkeys.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsclipboard.c b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsclipboard.c similarity index 98% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsclipboard.c rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsclipboard.c index 2af05706..ae3a104a 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsclipboard.c +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsclipboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsclipboard.h b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsclipboard.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsclipboard.h rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsclipboard.h index 53f5d729..49c36c4e 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsclipboard.h +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsclipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsevents.c b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsevents.c similarity index 92% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsevents.c rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsevents.c index 49ea4c75..ec3c0526 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsevents.c +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -25,6 +25,7 @@ #include "SDL_windowsvideo.h" #include "SDL_windowsshape.h" #include "SDL_syswm.h" +#include "SDL_timer.h" #include "SDL_vkeys.h" #include "../../events/SDL_events_c.h" #include "../../events/SDL_touch_c.h" @@ -70,6 +71,9 @@ #ifndef WM_MOUSEHWHEEL #define WM_MOUSEHWHEEL 0x020E #endif +#ifndef WM_UNICHAR +#define WM_UNICHAR 0x0109 +#endif static SDL_Scancode WindowsScanCodeToSDLScanCode( LPARAM lParam, WPARAM wParam ) @@ -259,6 +263,30 @@ WIN_CheckRawMouseButtons( ULONG rawButtons, SDL_WindowData *data ) } } +void +WIN_CheckAsyncMouseRelease( SDL_WindowData *data ) +{ + Uint32 mouseFlags; + SHORT keyState; + + /* mouse buttons may have changed state here, we need to resync them, + but we will get a WM_MOUSEMOVE right away which will fix things up if in non raw mode also + */ + mouseFlags = SDL_GetMouseState( NULL, NULL ); + + keyState = GetAsyncKeyState( VK_LBUTTON ); + WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_LMASK ), data, SDL_BUTTON_LEFT ); + keyState = GetAsyncKeyState( VK_RBUTTON ); + WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_RMASK ), data, SDL_BUTTON_RIGHT ); + keyState = GetAsyncKeyState( VK_MBUTTON ); + WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_MMASK ), data, SDL_BUTTON_MIDDLE ); + keyState = GetAsyncKeyState( VK_XBUTTON1 ); + WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_X1MASK ), data, SDL_BUTTON_X1 ); + keyState = GetAsyncKeyState( VK_XBUTTON2 ); + WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), ( mouseFlags & SDL_BUTTON_X2MASK ), data, SDL_BUTTON_X2 ); + data->mouse_button_flags = 0; +} + SDL_FORCE_INLINE BOOL WIN_ConvertUTF32toUTF8(UINT32 codepoint, char * text) { @@ -344,32 +372,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) minimized = HIWORD(wParam); if (!minimized && (LOWORD(wParam) != WA_INACTIVE)) { - Uint32 mouseFlags; - SHORT keyState; - SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0); if (SDL_GetKeyboardFocus() != data->window) { SDL_SetKeyboardFocus(data->window); } - /* mouse buttons may have changed state here, we need - to resync them, but we will get a WM_MOUSEMOVE right away which will fix - things up if in non raw mode also - */ - mouseFlags = SDL_GetMouseState( NULL, NULL ); - - keyState = GetAsyncKeyState( VK_LBUTTON ); - WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_LMASK), data, SDL_BUTTON_LEFT ); - keyState = GetAsyncKeyState( VK_RBUTTON ); - WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_RMASK), data, SDL_BUTTON_RIGHT ); - keyState = GetAsyncKeyState( VK_MBUTTON ); - WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_MMASK), data, SDL_BUTTON_MIDDLE ); - keyState = GetAsyncKeyState( VK_XBUTTON1 ); - WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_X1MASK), data, SDL_BUTTON_X1 ); - keyState = GetAsyncKeyState( VK_XBUTTON2 ); - WIN_CheckWParamMouseButton( ( keyState & 0x8000 ), (mouseFlags & SDL_BUTTON_X2MASK), data, SDL_BUTTON_X2 ); - data->mouse_button_flags = 0; - WIN_UpdateClipCursor(data->window); + WIN_CheckAsyncMouseRelease(data); /* * FIXME: Update keyboard state @@ -533,10 +541,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) /* Detect relevant keyboard shortcuts */ if (keyboardState[SDL_SCANCODE_LALT] == SDL_PRESSED || keyboardState[SDL_SCANCODE_RALT] == SDL_PRESSED ) { - /* ALT+F4: Close window */ - if (code == SDL_SCANCODE_F4) { - SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0); - } + /* ALT+F4: Close window */ + if (code == SDL_SCANCODE_F4) { + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0); + } } if ( code != SDL_SCANCODE_UNKNOWN ) { @@ -551,20 +559,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) break; case WM_UNICHAR: - { - if (wParam == UNICODE_NOCHAR) { - returnCode = 1; - break; - } - } - /* no break */ case WM_CHAR: - { - char text[5]; - - WIN_ConvertUTF32toUTF8(wParam, text); - SDL_SendKeyboardText(text); - } + /* Ignore WM_CHAR messages that come from TranslateMessage(), since we handle WM_KEY* messages directly */ returnCode = 0; break; @@ -577,6 +573,20 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) break; #endif /* WM_INPUTLANGCHANGE */ + case WM_NCLBUTTONDOWN: + { + data->in_title_click = SDL_TRUE; + WIN_UpdateClipCursor(data->window); + } + break; + + case WM_NCMOUSELEAVE: + { + data->in_title_click = SDL_FALSE; + WIN_UpdateClipCursor(data->window); + } + break; + case WM_ENTERSIZEMOVE: case WM_ENTERMENULOOP: { @@ -590,6 +600,9 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { data->in_modal_loop = SDL_FALSE; WIN_UpdateClipCursor(data->window); + + /* The mouse may have been released during the modal loop */ + WIN_CheckAsyncMouseRelease(data); } break; @@ -865,8 +878,17 @@ WIN_PumpEvents(_THIS) { const Uint8 *keystate; MSG msg; + DWORD start_ticks = GetTickCount(); + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - DispatchMessage(&msg); + /* Always translate the message in case it's a non-SDL window (e.g. with Qt integration) */ + TranslateMessage(&msg); + DispatchMessage( &msg ); + + /* Make sure we don't busy loop here forever if there are lots of events coming in */ + if (SDL_TICKS_PASSED(msg.time, start_ticks)) { + break; + } } /* Windows loses a shift KEYUP event when you have both pressed at once and let go of one. diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsevents.h b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsevents.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsevents.h rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsevents.h index ccf7aa00..b9944ee7 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsevents.h +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsframebuffer.c b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsframebuffer.c similarity index 98% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsframebuffer.c rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsframebuffer.c index 29923bef..4292db5a 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsframebuffer.c +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsframebuffer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsframebuffer.h b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsframebuffer.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsframebuffer.h rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsframebuffer.h index c59d28e0..daa42b83 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsframebuffer.h +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsframebuffer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowskeyboard.c b/jni/SDL2-2.0.3/src/video/windows/SDL_windowskeyboard.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowskeyboard.c rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowskeyboard.c index 86c0074e..0f3c9fcb 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowskeyboard.c +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowskeyboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowskeyboard.h b/jni/SDL2-2.0.3/src/video/windows/SDL_windowskeyboard.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowskeyboard.h rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowskeyboard.h index cd5ee70e..3eb0cbf6 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowskeyboard.h +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowskeyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsmessagebox.c b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsmessagebox.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsmessagebox.c rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsmessagebox.c index a9fcfda6..6cffc8ad 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsmessagebox.c +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsmessagebox.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsmessagebox.h b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsmessagebox.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsmessagebox.h rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsmessagebox.h index 1f79b161..ea709a4a 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsmessagebox.h +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsmessagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsmodes.c b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsmodes.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsmodes.c rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsmodes.c index 43d0c977..1687e277 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsmodes.c +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsmodes.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsmodes.h b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsmodes.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsmodes.h rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsmodes.h index e1926b15..d16a5e7a 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsmodes.h +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsmodes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsmouse.c b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsmouse.c similarity index 89% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsmouse.c rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsmouse.c index 967e400d..b49249db 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsmouse.c +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsmouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -183,9 +183,15 @@ WIN_ShowCursor(SDL_Cursor * cursor) static void WIN_WarpMouse(SDL_Window * window, int x, int y) { - HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; + HWND hwnd = data->hwnd; POINT pt; + /* Don't warp the mouse while we're doing a modal interaction */ + if (data->in_title_click || data->in_modal_loop) { + return; + } + pt.x = x; pt.y = y; ClientToScreen(hwnd, &pt); @@ -196,44 +202,20 @@ static int WIN_SetRelativeMouseMode(SDL_bool enabled) { RAWINPUTDEVICE rawMouse = { 0x01, 0x02, 0, NULL }; /* Mouse: UsagePage = 1, Usage = 2 */ - HWND hWnd; - hWnd = GetActiveWindow(); - rawMouse.hwndTarget = hWnd; - if(!enabled) { + if (!enabled) { rawMouse.dwFlags |= RIDEV_REMOVE; - rawMouse.hwndTarget = NULL; } - /* (Un)register raw input for mice */ if (RegisterRawInputDevices(&rawMouse, 1, sizeof(RAWINPUTDEVICE)) == FALSE) { - /* Only return an error when registering. If we unregister and fail, then - it's probably that we unregistered twice. That's OK. */ - if(enabled) { + /* Only return an error when registering. If we unregister and fail, + then it's probably that we unregistered twice. That's OK. */ + if (enabled) { return SDL_Unsupported(); } } - - if (enabled) { - LONG cx, cy; - RECT rect; - GetWindowRect(hWnd, &rect); - - cx = (rect.left + rect.right) / 2; - cy = (rect.top + rect.bottom) / 2; - - /* Make an absurdly small clip rect */ - rect.left = cx-1; - rect.right = cx+1; - rect.top = cy-1; - rect.bottom = cy+1; - - ClipCursor(&rect); - } else { - ClipCursor(NULL); - } return 0; } diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsmouse.h b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsmouse.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsmouse.h rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsmouse.h index 5e88184e..665cdc57 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsmouse.h +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsmouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsopengl.c b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsopengl.c similarity index 96% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsopengl.c rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsopengl.c index 247976b8..80ba3b45 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsopengl.c +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsopengl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -616,13 +616,13 @@ WIN_GL_CreateContext(_THIS, SDL_Window * window) } if (_this->gl_config.major_version < 3 && - _this->gl_config.profile_mask == 0 && - _this->gl_config.flags == 0) { + _this->gl_config.profile_mask == 0 && + _this->gl_config.flags == 0) { /* Create legacy context */ context = _this->gl_data->wglCreateContext(hdc); - if( share_context != 0 ) { + if( share_context != 0 ) { _this->gl_data->wglShareLists(share_context, context); - } + } } else { PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; HGLRC temp_context = _this->gl_data->wglCreateContext(hdc); @@ -759,6 +759,26 @@ WIN_GL_DeleteContext(_THIS, SDL_GLContext context) _this->gl_data->wglDeleteContext((HGLRC) context); } + +SDL_bool +WIN_GL_SetPixelFormatFrom(_THIS, SDL_Window * fromWindow, SDL_Window * toWindow) +{ + HDC hfromdc = ((SDL_WindowData *) fromWindow->driverdata)->hdc; + HDC htodc = ((SDL_WindowData *) toWindow->driverdata)->hdc; + BOOL result; + + /* get the pixel format of the fromWindow */ + int pixel_format = GetPixelFormat(hfromdc); + PIXELFORMATDESCRIPTOR pfd; + SDL_memset(&pfd, 0, sizeof(pfd)); + DescribePixelFormat(hfromdc, pixel_format, sizeof(pfd), &pfd); + + /* set the pixel format of the toWindow */ + result = SetPixelFormat(htodc, pixel_format, &pfd); + + return result ? SDL_TRUE : SDL_FALSE; +} + #endif /* SDL_VIDEO_OPENGL_WGL */ #endif /* SDL_VIDEO_DRIVER_WINDOWS */ diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsopengl.h b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsopengl.h similarity index 97% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsopengl.h rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsopengl.h index f8934b06..b96e0ac1 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsopengl.h +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsopengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -64,6 +64,7 @@ extern int WIN_GL_GetSwapInterval(_THIS); extern void WIN_GL_SwapWindow(_THIS, SDL_Window * window); extern void WIN_GL_DeleteContext(_THIS, SDL_GLContext context); extern void WIN_GL_InitExtensions(_THIS); +extern SDL_bool WIN_GL_SetPixelFormatFrom(_THIS, SDL_Window * fromWindow, SDL_Window * toWindow); #ifndef WGL_ARB_pixel_format #define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsopengles.c b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsopengles.c similarity index 97% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsopengles.c rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsopengles.c index 79d3cc6a..a921ba8a 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsopengles.c +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsopengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -32,8 +32,6 @@ int WIN_GLES_LoadLibrary(_THIS, const char *path) { - SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; - /* If the profile requested is not GL ES, switch over to WIN_GL functions */ if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) { #if SDL_VIDEO_OPENGL_WGL diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsopengles.h b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsopengles.h similarity index 97% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsopengles.h rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsopengles.h index c94fe52e..8e232177 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsopengles.h +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsshape.c b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsshape.c similarity index 98% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsshape.c rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsshape.c index 07b50560..9409e2b4 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsshape.c +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsshape.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsshape.h b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsshape.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsshape.h rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsshape.h index 4be4b51b..9405a501 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsshape.h +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsshape.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsvideo.c b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsvideo.c similarity index 76% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsvideo.c rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsvideo.c index b2cfcbe8..503653bd 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsvideo.c +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -245,6 +245,91 @@ SDL_Direct3D9GetAdapterIndex( int displayIndex ) } } +#define CINTERFACE +#define COBJMACROS +#include + +SDL_bool +DXGI_LoadDLL( void **pDXGIDLL , IDXGIFactory **pDXGIFactory ) +{ + *pDXGIDLL = SDL_LoadObject("DXGI.DLL"); + if (*pDXGIDLL ) { + HRESULT (WINAPI *CreateDXGI)( REFIID riid, void **ppFactory ); + + CreateDXGI = + (HRESULT (WINAPI *) (REFIID, void**)) SDL_LoadFunction(*pDXGIDLL, + "CreateDXGIFactory"); + if (CreateDXGI) { + GUID dxgiGUID = {0x7b7166ec,0x21c7,0x44ae,{0xb2,0x1a,0xc9,0xae,0x32,0x1a,0xe3,0x69}}; + if( !SUCCEEDED( CreateDXGI( &dxgiGUID, (void**)pDXGIFactory ))) { + *pDXGIFactory = NULL; + } + } + if (!*pDXGIFactory) { + SDL_UnloadObject(*pDXGIDLL); + *pDXGIDLL = NULL; + return SDL_FALSE; + } + + return SDL_TRUE; + } else { + *pDXGIFactory = NULL; + return SDL_FALSE; + } +} + + +void +SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex ) +{ + void *pDXGIDLL; + IDXGIFactory *pDXGIFactory; + + *adapterIndex = -1; + *outputIndex = -1; + + if (!DXGI_LoadDLL(&pDXGIDLL, &pDXGIFactory)) { + SDL_SetError("Unable to create DXGI interface"); + } else { + SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData(displayIndex); + + if (!pData) { + SDL_SetError("Invalid display index"); + } else { + char *displayName = WIN_StringToUTF8(pData->DeviceName); + int nAdapter = 0, nOutput = 0; + IDXGIAdapter* pDXGIAdapter; + while ( *adapterIndex == -1 && IDXGIFactory_EnumAdapters(pDXGIFactory, nAdapter, &pDXGIAdapter) != DXGI_ERROR_NOT_FOUND ) { + IDXGIOutput* pDXGIOutput; + while ( *adapterIndex == -1 && IDXGIAdapter_EnumOutputs(pDXGIAdapter, nOutput, &pDXGIOutput) != DXGI_ERROR_NOT_FOUND ) { + DXGI_OUTPUT_DESC outputDesc; + if (SUCCEEDED(IDXGIOutput_GetDesc(pDXGIOutput, &outputDesc))) { + char *outputName = WIN_StringToUTF8(outputDesc.DeviceName); + + if(!SDL_strcmp(outputName, displayName)) { + *adapterIndex = nAdapter; + *outputIndex = nOutput; + } + + SDL_free( outputName ); + } + + IDXGIOutput_Release( pDXGIOutput ); + nOutput++; + } + + IDXGIAdapter_Release( pDXGIAdapter ); + nAdapter++; + } + SDL_free(displayName); + } + + /* free up the D3D stuff we inited */ + IDXGIFactory_AddRef( pDXGIFactory ); + SDL_UnloadObject(pDXGIDLL); + } +} + #endif /* SDL_VIDEO_DRIVER_WINDOWS */ /* vim: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsvideo.h b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsvideo.h similarity index 98% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowsvideo.h rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowsvideo.h index bf6613de..b64cbddf 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowsvideo.h +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowsvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowswindow.c b/jni/SDL2-2.0.3/src/video/windows/SDL_windowswindow.c similarity index 94% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowswindow.c rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowswindow.c index 5cba9ff2..425b4da2 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowswindow.c +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowswindow.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -32,6 +32,7 @@ #include "SDL_windowsvideo.h" #include "SDL_windowswindow.h" +#include "SDL_hints.h" /* Dropfile support */ #include @@ -337,6 +338,31 @@ WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) if (SetupWindowData(_this, window, hwnd, SDL_FALSE) < 0) { return -1; } + +#if SDL_VIDEO_OPENGL_WGL + { + const char *hint = SDL_GetHint(SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT); + if (hint) { + // This hint is a pointer (in string form) of the address of + // the window to share a pixel format with + SDL_Window *otherWindow = NULL; + SDL_sscanf(hint, "%p", (void**)&otherWindow); + + // Do some error checking on the pointer + if (otherWindow != NULL && otherWindow->magic == &_this->window_magic) + { + // If the otherWindow has SDL_WINDOW_OPENGL set, set it for the new window as well + if (otherWindow->flags & SDL_WINDOW_OPENGL) + { + window->flags |= SDL_WINDOW_OPENGL; + if(!WIN_GL_SetPixelFormatFrom(_this, otherWindow, window)) { + return -1; + } + } + } + } + } +#endif return 0; } @@ -527,7 +553,7 @@ WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, } SetWindowLong(hwnd, GWL_STYLE, style); data->expected_resize = TRUE; - SetWindowPos(hwnd, top, x, y, w, h, SWP_NOCOPYBITS); + SetWindowPos(hwnd, top, x, y, w, h, SWP_NOCOPYBITS | SWP_NOACTIVATE); data->expected_resize = FALSE; } @@ -647,7 +673,7 @@ SDL_HelperWindowCreate(void) /* Register the class. */ SDL_HelperWindowClass = RegisterClass(&wce); - if (SDL_HelperWindowClass == 0) { + if (SDL_HelperWindowClass == 0 && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) { return WIN_SetError("Unable to create Helper Window Class"); } @@ -720,7 +746,7 @@ WIN_UpdateClipCursor(SDL_Window *window) SDL_Mouse *mouse = SDL_GetMouse(); /* Don't clip the cursor while we're in the modal resize or move loop */ - if (data->in_modal_loop) { + if (data->in_title_click || data->in_modal_loop) { ClipCursor(NULL); return; } diff --git a/jni/SDL2-2.0.1/src/video/windows/SDL_windowswindow.h b/jni/SDL2-2.0.3/src/video/windows/SDL_windowswindow.h similarity index 97% rename from jni/SDL2-2.0.1/src/video/windows/SDL_windowswindow.h rename to jni/SDL2-2.0.3/src/video/windows/SDL_windowswindow.h index 743c322f..c4288874 100644 --- a/jni/SDL2-2.0.1/src/video/windows/SDL_windowswindow.h +++ b/jni/SDL2-2.0.3/src/video/windows/SDL_windowswindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -38,6 +38,7 @@ typedef struct SDL_bool created; WPARAM mouse_button_flags; BOOL expected_resize; + SDL_bool in_title_click; SDL_bool in_modal_loop; struct SDL_VideoData *videodata; #if SDL_VIDEO_OPENGL_EGL diff --git a/jni/SDL2-2.0.1/src/video/windows/wmmsg.h b/jni/SDL2-2.0.3/src/video/windows/wmmsg.h similarity index 91% rename from jni/SDL2-2.0.1/src/video/windows/wmmsg.h rename to jni/SDL2-2.0.3/src/video/windows/wmmsg.h index 2cc7a843..ea463963 100644 --- a/jni/SDL2-2.0.1/src/video/windows/wmmsg.h +++ b/jni/SDL2-2.0.3/src/video/windows/wmmsg.h @@ -1,3 +1,23 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ #define MAX_WMMSG (sizeof(wmtab)/sizeof(wmtab[0])) @@ -257,7 +277,7 @@ char *wmtab[] = { "UNKNOWN (252)", "UNKNOWN (253)", "UNKNOWN (254)", - "UNKNOWN (255)", + "WM_INPUT", "WM_KEYDOWN", "WM_KEYUP", "WM_CHAR", @@ -570,30 +590,30 @@ char *wmtab[] = { "UNKNOWN (565)", "UNKNOWN (566)", "UNKNOWN (567)", - "UNKNOWN (568)", - "UNKNOWN (569)", - "UNKNOWN (570)", + "WM_POINTERDEVICECHANGE", + "WM_POINTERDEVICEINRANGE", + "WM_POINTERDEVICEOUTOFRANGE", "UNKNOWN (571)", "UNKNOWN (572)", "UNKNOWN (573)", "UNKNOWN (574)", "UNKNOWN (575)", "WM_TOUCH", - "UNKNOWN (577)", - "UNKNOWN (578)", - "UNKNOWN (579)", + "WM_NCPOINTERUPDATE", + "WM_NCPOINTERDOWN", + "WM_NCPOINTERUP", "UNKNOWN (580)", - "UNKNOWN (581)", - "UNKNOWN (582)", - "UNKNOWN (583)", - "UNKNOWN (584)", - "UNKNOWN (585)", - "UNKNOWN (586)", - "UNKNOWN (587)", - "UNKNOWN (588)", - "UNKNOWN (589)", - "UNKNOWN (590)", - "UNKNOWN (591)", + "WM_POINTERUPDATE", + "WM_POINTERDOWN", + "WM_POINTERUP", + "WM_POINTERENTER", + "WM_POINTERLEAVE", + "WM_POINTERACTIVATE", + "WM_POINTERCAPTURECHANGED", + "WM_TOUCHHITTESTING", + "WM_POINTERWHEEL", + "WM_POINTERHWHEEL", + "DM_POINTERHITTEST", "UNKNOWN (592)", "UNKNOWN (593)", "UNKNOWN (594)", @@ -643,14 +663,14 @@ char *wmtab[] = { "UNKNOWN (638)", "UNKNOWN (639)", "UNKNOWN (640)", - "UNKNOWN (641)", - "UNKNOWN (642)", - "UNKNOWN (643)", - "UNKNOWN (644)", - "UNKNOWN (645)", - "UNKNOWN (646)", + "WM_IME_SETCONTEXT", + "WM_IME_NOTIFY", + "WM_IME_CONTROL", + "WM_IME_COMPOSITIONFULL", + "WM_IME_SELECT", + "WM_IME_CHAR", "UNKNOWN (647)", - "UNKNOWN (648)", + "WM_IME_REQUEST", "UNKNOWN (649)", "UNKNOWN (650)", "UNKNOWN (651)", @@ -658,8 +678,8 @@ char *wmtab[] = { "UNKNOWN (653)", "UNKNOWN (654)", "UNKNOWN (655)", - "UNKNOWN (656)", - "UNKNOWN (657)", + "WM_IME_KEYDOWN", + "WM_IME_KEYUP", "UNKNOWN (658)", "UNKNOWN (659)", "UNKNOWN (660)", @@ -674,9 +694,9 @@ char *wmtab[] = { "UNKNOWN (669)", "UNKNOWN (670)", "UNKNOWN (671)", - "UNKNOWN (672)", + "WM_NCMOUSEHOVER", "WM_MOUSEHOVER", - "UNKNOWN (674)", + "WM_NCMOUSELEAVE", "WM_MOUSELEAVE", "UNKNOWN (676)", "UNKNOWN (677)", @@ -691,7 +711,7 @@ char *wmtab[] = { "UNKNOWN (686)", "UNKNOWN (687)", "UNKNOWN (688)", - "UNKNOWN (689)", + "WM_WTSSESSION_CHANGE", "UNKNOWN (690)", "UNKNOWN (691)", "UNKNOWN (692)", @@ -738,7 +758,7 @@ char *wmtab[] = { "UNKNOWN (733)", "UNKNOWN (734)", "UNKNOWN (735)", - "UNKNOWN (736)", + "WM_DPICHANGED", "UNKNOWN (737)", "UNKNOWN (738)", "UNKNOWN (739)", @@ -795,20 +815,20 @@ char *wmtab[] = { "UNKNOWN (790)", "WM_PRINT", "WM_PRINTCLIENT", - "UNKNOWN (793)", - "UNKNOWN (794)", + "WM_APPCOMMAND", + "WM_THEMECHANGED", "UNKNOWN (795)", "UNKNOWN (796)", - "UNKNOWN (797)", - "UNKNOWN (798)", - "UNKNOWN (799)", - "UNKNOWN (800)", - "UNKNOWN (801)", + "WM_CLIPBOARDUPDATE", + "WM_DWMCOMPOSITIONCHANGED", + "WM_DWMNCRENDERINGCHANGED", + "WM_DWMCOLORIZATIONCOLORCHANGED", + "WM_DWMWINDOWMAXIMIZEDCHANGE", "UNKNOWN (802)", - "UNKNOWN (803)", + "WM_DWMSENDICONICTHUMBNAIL", "UNKNOWN (804)", "UNKNOWN (805)", - "UNKNOWN (806)", + "WM_DWMSENDICONICLIVEPREVIEWBITMAP", "UNKNOWN (807)", "UNKNOWN (808)", "UNKNOWN (809)", @@ -833,7 +853,7 @@ char *wmtab[] = { "UNKNOWN (828)", "UNKNOWN (829)", "UNKNOWN (830)", - "UNKNOWN (831)", + "WM_GETTITLEBARINFOEX", "UNKNOWN (832)", "UNKNOWN (833)", "UNKNOWN (834)", diff --git a/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtevents.cpp b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtevents.cpp new file mode 100644 index 00000000..7c0cf49a --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtevents.cpp @@ -0,0 +1,153 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_WINRT + +/* + * Windows includes: + */ +#include +using namespace Windows::UI::Core; +using Windows::UI::Core::CoreCursor; + +/* + * SDL includes: + */ +#include "SDL_winrtevents_c.h" +#include "../../core/winrt/SDL_winrtapp_common.h" +#include "../../core/winrt/SDL_winrtapp_direct3d.h" +#include "../../core/winrt/SDL_winrtapp_xaml.h" +#include "SDL_assert.h" +#include "SDL_system.h" + +extern "C" { +#include "../SDL_sysvideo.h" +#include "../../events/SDL_events_c.h" +} + + +/* Forward declarations */ +static void WINRT_YieldXAMLThread(); + + +/* Global event management */ + +void +WINRT_PumpEvents(_THIS) +{ + if (SDL_WinRTGlobalApp) { + SDL_WinRTGlobalApp->PumpEvents(); + } else if (WINRT_XAMLWasEnabled) { + WINRT_YieldXAMLThread(); + } +} + + +/* XAML Thread management */ + +enum SDL_XAMLAppThreadState +{ + ThreadState_NotLaunched = 0, + ThreadState_Running, + ThreadState_Yielding +}; + +static SDL_XAMLAppThreadState _threadState = ThreadState_NotLaunched; +static SDL_Thread * _XAMLThread = nullptr; +static SDL_mutex * _mutex = nullptr; +static SDL_cond * _cond = nullptr; + +static void +WINRT_YieldXAMLThread() +{ + SDL_LockMutex(_mutex); + SDL_assert(_threadState == ThreadState_Running); + _threadState = ThreadState_Yielding; + SDL_UnlockMutex(_mutex); + + SDL_CondSignal(_cond); + + SDL_LockMutex(_mutex); + while (_threadState != ThreadState_Running) { + SDL_CondWait(_cond, _mutex); + } + SDL_UnlockMutex(_mutex); +} + +static int +WINRT_XAMLThreadMain(void * userdata) +{ + // TODO, WinRT: pass the C-style main() a reasonably realistic + // representation of command line arguments. + int argc = 0; + char **argv = NULL; + return WINRT_SDLAppEntryPoint(argc, argv); +} + +void +WINRT_CycleXAMLThread() +{ + switch (_threadState) { + case ThreadState_NotLaunched: + { + _cond = SDL_CreateCond(); + + _mutex = SDL_CreateMutex(); + _threadState = ThreadState_Running; + _XAMLThread = SDL_CreateThread(WINRT_XAMLThreadMain, "SDL/XAML App Thread", nullptr); + + SDL_LockMutex(_mutex); + while (_threadState != ThreadState_Yielding) { + SDL_CondWait(_cond, _mutex); + } + SDL_UnlockMutex(_mutex); + + break; + } + + case ThreadState_Running: + { + SDL_assert(false); + break; + } + + case ThreadState_Yielding: + { + SDL_LockMutex(_mutex); + SDL_assert(_threadState == ThreadState_Yielding); + _threadState = ThreadState_Running; + SDL_UnlockMutex(_mutex); + + SDL_CondSignal(_cond); + + SDL_LockMutex(_mutex); + while (_threadState != ThreadState_Yielding) { + SDL_CondWait(_cond, _mutex); + } + SDL_UnlockMutex(_mutex); + } + } +} + +#endif /* SDL_VIDEO_DRIVER_WINRT */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtevents_c.h b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtevents_c.h new file mode 100644 index 00000000..826cad74 --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtevents_c.h @@ -0,0 +1,72 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +extern "C" { +#include "../SDL_sysvideo.h" +} + +/* + * Internal-use, C-style functions: + */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern void WINRT_InitTouch(_THIS); +extern void WINRT_PumpEvents(_THIS); + +#ifdef __cplusplus +} +#endif + + +/* + * Internal-use, C++/CX functions: + */ +#ifdef __cplusplus_winrt + +/* Pointers (Mice, Touch, etc.) */ +typedef enum { + NormalizeZeroToOne, + TransformToSDLWindowSize +} WINRT_CursorNormalizationType; +extern Windows::Foundation::Point WINRT_TransformCursorPosition(SDL_Window * window, + Windows::Foundation::Point rawPosition, + WINRT_CursorNormalizationType normalization); +extern Uint8 WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt); +extern void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint); +extern void WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint); +extern void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint); +extern void WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint); +extern void WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::MouseEventArgs ^args); + +/* Keyboard */ +extern void WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^args); +extern void WINRT_ProcessKeyUpEvent(Windows::UI::Core::KeyEventArgs ^args); + +/* XAML Thread Management */ +extern void WINRT_CycleXAMLThread(); + +#endif // ifdef __cplusplus_winrt + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtkeyboard.cpp b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtkeyboard.cpp new file mode 100644 index 00000000..f2fa59d6 --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtkeyboard.cpp @@ -0,0 +1,301 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_WINRT + +/* Standard C++11 includes */ +#include + + +/* Windows-specific includes */ +#include +#include + + +/* SDL-specific includes */ +#include +#include "SDL_winrtevents_c.h" + +extern "C" { +#include "../../events/scancodes_windows.h" +#include "../../events/SDL_keyboard_c.h" +} + + +static SDL_Scancode WinRT_Official_Keycodes[] = { + SDL_SCANCODE_UNKNOWN, // VirtualKey.None -- 0 + SDL_SCANCODE_UNKNOWN, // VirtualKey.LeftButton -- 1 + SDL_SCANCODE_UNKNOWN, // VirtualKey.RightButton -- 2 + SDL_SCANCODE_CANCEL, // VirtualKey.Cancel -- 3 + SDL_SCANCODE_UNKNOWN, // VirtualKey.MiddleButton -- 4 + SDL_SCANCODE_UNKNOWN, // VirtualKey.XButton1 -- 5 + SDL_SCANCODE_UNKNOWN, // VirtualKey.XButton2 -- 6 + SDL_SCANCODE_UNKNOWN, // -- 7 + SDL_SCANCODE_BACKSPACE, // VirtualKey.Back -- 8 + SDL_SCANCODE_TAB, // VirtualKey.Tab -- 9 + SDL_SCANCODE_UNKNOWN, // -- 10 + SDL_SCANCODE_UNKNOWN, // -- 11 + SDL_SCANCODE_CLEAR, // VirtualKey.Clear -- 12 + SDL_SCANCODE_RETURN, // VirtualKey.Enter -- 13 + SDL_SCANCODE_UNKNOWN, // -- 14 + SDL_SCANCODE_UNKNOWN, // -- 15 + SDL_SCANCODE_LSHIFT, // VirtualKey.Shift -- 16 + SDL_SCANCODE_LCTRL, // VirtualKey.Control -- 17 + SDL_SCANCODE_MENU, // VirtualKey.Menu -- 18 + SDL_SCANCODE_PAUSE, // VirtualKey.Pause -- 19 + SDL_SCANCODE_CAPSLOCK, // VirtualKey.CapitalLock -- 20 + SDL_SCANCODE_UNKNOWN, // VirtualKey.Kana or VirtualKey.Hangul -- 21 + SDL_SCANCODE_UNKNOWN, // -- 22 + SDL_SCANCODE_UNKNOWN, // VirtualKey.Junja -- 23 + SDL_SCANCODE_UNKNOWN, // VirtualKey.Final -- 24 + SDL_SCANCODE_UNKNOWN, // VirtualKey.Hanja or VirtualKey.Kanji -- 25 + SDL_SCANCODE_UNKNOWN, // -- 26 + SDL_SCANCODE_ESCAPE, // VirtualKey.Escape -- 27 + SDL_SCANCODE_UNKNOWN, // VirtualKey.Convert -- 28 + SDL_SCANCODE_UNKNOWN, // VirtualKey.NonConvert -- 29 + SDL_SCANCODE_UNKNOWN, // VirtualKey.Accept -- 30 + SDL_SCANCODE_UNKNOWN, // VirtualKey.ModeChange -- 31 (maybe SDL_SCANCODE_MODE ?) + SDL_SCANCODE_SPACE, // VirtualKey.Space -- 32 + SDL_SCANCODE_PAGEUP, // VirtualKey.PageUp -- 33 + SDL_SCANCODE_PAGEDOWN, // VirtualKey.PageDown -- 34 + SDL_SCANCODE_END, // VirtualKey.End -- 35 + SDL_SCANCODE_HOME, // VirtualKey.Home -- 36 + SDL_SCANCODE_LEFT, // VirtualKey.Left -- 37 + SDL_SCANCODE_UP, // VirtualKey.Up -- 38 + SDL_SCANCODE_RIGHT, // VirtualKey.Right -- 39 + SDL_SCANCODE_DOWN, // VirtualKey.Down -- 40 + SDL_SCANCODE_SELECT, // VirtualKey.Select -- 41 + SDL_SCANCODE_UNKNOWN, // VirtualKey.Print -- 42 (maybe SDL_SCANCODE_PRINTSCREEN ?) + SDL_SCANCODE_EXECUTE, // VirtualKey.Execute -- 43 + SDL_SCANCODE_UNKNOWN, // VirtualKey.Snapshot -- 44 + SDL_SCANCODE_INSERT, // VirtualKey.Insert -- 45 + SDL_SCANCODE_DELETE, // VirtualKey.Delete -- 46 + SDL_SCANCODE_HELP, // VirtualKey.Help -- 47 + SDL_SCANCODE_0, // VirtualKey.Number0 -- 48 + SDL_SCANCODE_1, // VirtualKey.Number1 -- 49 + SDL_SCANCODE_2, // VirtualKey.Number2 -- 50 + SDL_SCANCODE_3, // VirtualKey.Number3 -- 51 + SDL_SCANCODE_4, // VirtualKey.Number4 -- 52 + SDL_SCANCODE_5, // VirtualKey.Number5 -- 53 + SDL_SCANCODE_6, // VirtualKey.Number6 -- 54 + SDL_SCANCODE_7, // VirtualKey.Number7 -- 55 + SDL_SCANCODE_8, // VirtualKey.Number8 -- 56 + SDL_SCANCODE_9, // VirtualKey.Number9 -- 57 + SDL_SCANCODE_UNKNOWN, // -- 58 + SDL_SCANCODE_UNKNOWN, // -- 59 + SDL_SCANCODE_UNKNOWN, // -- 60 + SDL_SCANCODE_UNKNOWN, // -- 61 + SDL_SCANCODE_UNKNOWN, // -- 62 + SDL_SCANCODE_UNKNOWN, // -- 63 + SDL_SCANCODE_UNKNOWN, // -- 64 + SDL_SCANCODE_A, // VirtualKey.A -- 65 + SDL_SCANCODE_B, // VirtualKey.B -- 66 + SDL_SCANCODE_C, // VirtualKey.C -- 67 + SDL_SCANCODE_D, // VirtualKey.D -- 68 + SDL_SCANCODE_E, // VirtualKey.E -- 69 + SDL_SCANCODE_F, // VirtualKey.F -- 70 + SDL_SCANCODE_G, // VirtualKey.G -- 71 + SDL_SCANCODE_H, // VirtualKey.H -- 72 + SDL_SCANCODE_I, // VirtualKey.I -- 73 + SDL_SCANCODE_J, // VirtualKey.J -- 74 + SDL_SCANCODE_K, // VirtualKey.K -- 75 + SDL_SCANCODE_L, // VirtualKey.L -- 76 + SDL_SCANCODE_M, // VirtualKey.M -- 77 + SDL_SCANCODE_N, // VirtualKey.N -- 78 + SDL_SCANCODE_O, // VirtualKey.O -- 79 + SDL_SCANCODE_P, // VirtualKey.P -- 80 + SDL_SCANCODE_Q, // VirtualKey.Q -- 81 + SDL_SCANCODE_R, // VirtualKey.R -- 82 + SDL_SCANCODE_S, // VirtualKey.S -- 83 + SDL_SCANCODE_T, // VirtualKey.T -- 84 + SDL_SCANCODE_U, // VirtualKey.U -- 85 + SDL_SCANCODE_V, // VirtualKey.V -- 86 + SDL_SCANCODE_W, // VirtualKey.W -- 87 + SDL_SCANCODE_X, // VirtualKey.X -- 88 + SDL_SCANCODE_Y, // VirtualKey.Y -- 89 + SDL_SCANCODE_Z, // VirtualKey.Z -- 90 + SDL_SCANCODE_UNKNOWN, // VirtualKey.LeftWindows -- 91 (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_LGUI ?) + SDL_SCANCODE_UNKNOWN, // VirtualKey.RightWindows -- 92 (maybe SDL_SCANCODE_APPLICATION or SDL_SCANCODE_RGUI ?) + SDL_SCANCODE_APPLICATION, // VirtualKey.Application -- 93 + SDL_SCANCODE_UNKNOWN, // -- 94 + SDL_SCANCODE_SLEEP, // VirtualKey.Sleep -- 95 + SDL_SCANCODE_KP_0, // VirtualKey.NumberPad0 -- 96 + SDL_SCANCODE_KP_1, // VirtualKey.NumberPad1 -- 97 + SDL_SCANCODE_KP_2, // VirtualKey.NumberPad2 -- 98 + SDL_SCANCODE_KP_3, // VirtualKey.NumberPad3 -- 99 + SDL_SCANCODE_KP_4, // VirtualKey.NumberPad4 -- 100 + SDL_SCANCODE_KP_5, // VirtualKey.NumberPad5 -- 101 + SDL_SCANCODE_KP_6, // VirtualKey.NumberPad6 -- 102 + SDL_SCANCODE_KP_7, // VirtualKey.NumberPad7 -- 103 + SDL_SCANCODE_KP_8, // VirtualKey.NumberPad8 -- 104 + SDL_SCANCODE_KP_9, // VirtualKey.NumberPad9 -- 105 + SDL_SCANCODE_KP_MULTIPLY, // VirtualKey.Multiply -- 106 + SDL_SCANCODE_KP_PLUS, // VirtualKey.Add -- 107 + SDL_SCANCODE_UNKNOWN, // VirtualKey.Separator -- 108 + SDL_SCANCODE_KP_MINUS, // VirtualKey.Subtract -- 109 + SDL_SCANCODE_UNKNOWN, // VirtualKey.Decimal -- 110 (maybe SDL_SCANCODE_DECIMALSEPARATOR, SDL_SCANCODE_KP_DECIMAL, or SDL_SCANCODE_KP_PERIOD ?) + SDL_SCANCODE_KP_DIVIDE, // VirtualKey.Divide -- 111 + SDL_SCANCODE_F1, // VirtualKey.F1 -- 112 + SDL_SCANCODE_F2, // VirtualKey.F2 -- 113 + SDL_SCANCODE_F3, // VirtualKey.F3 -- 114 + SDL_SCANCODE_F4, // VirtualKey.F4 -- 115 + SDL_SCANCODE_F5, // VirtualKey.F5 -- 116 + SDL_SCANCODE_F6, // VirtualKey.F6 -- 117 + SDL_SCANCODE_F7, // VirtualKey.F7 -- 118 + SDL_SCANCODE_F8, // VirtualKey.F8 -- 119 + SDL_SCANCODE_F9, // VirtualKey.F9 -- 120 + SDL_SCANCODE_F10, // VirtualKey.F10 -- 121 + SDL_SCANCODE_F11, // VirtualKey.F11 -- 122 + SDL_SCANCODE_F12, // VirtualKey.F12 -- 123 + SDL_SCANCODE_F13, // VirtualKey.F13 -- 124 + SDL_SCANCODE_F14, // VirtualKey.F14 -- 125 + SDL_SCANCODE_F15, // VirtualKey.F15 -- 126 + SDL_SCANCODE_F16, // VirtualKey.F16 -- 127 + SDL_SCANCODE_F17, // VirtualKey.F17 -- 128 + SDL_SCANCODE_F18, // VirtualKey.F18 -- 129 + SDL_SCANCODE_F19, // VirtualKey.F19 -- 130 + SDL_SCANCODE_F20, // VirtualKey.F20 -- 131 + SDL_SCANCODE_F21, // VirtualKey.F21 -- 132 + SDL_SCANCODE_F22, // VirtualKey.F22 -- 133 + SDL_SCANCODE_F23, // VirtualKey.F23 -- 134 + SDL_SCANCODE_F24, // VirtualKey.F24 -- 135 + SDL_SCANCODE_UNKNOWN, // -- 136 + SDL_SCANCODE_UNKNOWN, // -- 137 + SDL_SCANCODE_UNKNOWN, // -- 138 + SDL_SCANCODE_UNKNOWN, // -- 139 + SDL_SCANCODE_UNKNOWN, // -- 140 + SDL_SCANCODE_UNKNOWN, // -- 141 + SDL_SCANCODE_UNKNOWN, // -- 142 + SDL_SCANCODE_UNKNOWN, // -- 143 + SDL_SCANCODE_NUMLOCKCLEAR, // VirtualKey.NumberKeyLock -- 144 + SDL_SCANCODE_SCROLLLOCK, // VirtualKey.Scroll -- 145 + SDL_SCANCODE_UNKNOWN, // -- 146 + SDL_SCANCODE_UNKNOWN, // -- 147 + SDL_SCANCODE_UNKNOWN, // -- 148 + SDL_SCANCODE_UNKNOWN, // -- 149 + SDL_SCANCODE_UNKNOWN, // -- 150 + SDL_SCANCODE_UNKNOWN, // -- 151 + SDL_SCANCODE_UNKNOWN, // -- 152 + SDL_SCANCODE_UNKNOWN, // -- 153 + SDL_SCANCODE_UNKNOWN, // -- 154 + SDL_SCANCODE_UNKNOWN, // -- 155 + SDL_SCANCODE_UNKNOWN, // -- 156 + SDL_SCANCODE_UNKNOWN, // -- 157 + SDL_SCANCODE_UNKNOWN, // -- 158 + SDL_SCANCODE_UNKNOWN, // -- 159 + SDL_SCANCODE_LSHIFT, // VirtualKey.LeftShift -- 160 + SDL_SCANCODE_RSHIFT, // VirtualKey.RightShift -- 161 + SDL_SCANCODE_LCTRL, // VirtualKey.LeftControl -- 162 + SDL_SCANCODE_RCTRL, // VirtualKey.RightControl -- 163 + SDL_SCANCODE_MENU, // VirtualKey.LeftMenu -- 164 + SDL_SCANCODE_MENU, // VirtualKey.RightMenu -- 165 +}; + +static std::unordered_map WinRT_Unofficial_Keycodes; + +static SDL_Scancode +TranslateKeycode(int keycode) +{ + if (WinRT_Unofficial_Keycodes.empty()) { + /* Set up a table of undocumented (by Microsoft), WinRT-specific, + key codes: */ + // TODO, WinRT: move content declarations of WinRT_Unofficial_Keycodes into a C++11 initializer list, when possible + WinRT_Unofficial_Keycodes[220] = SDL_SCANCODE_GRAVE; + WinRT_Unofficial_Keycodes[222] = SDL_SCANCODE_BACKSLASH; + } + + /* Try to get a documented, WinRT, 'VirtualKey' first (as documented at + http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.virtualkey.aspx ). + If that fails, fall back to a Win32 virtual key. + */ + // TODO, WinRT: try filling out the WinRT keycode table as much as possible, using the Win32 table for interpretation hints + //SDL_Log("WinRT TranslateKeycode, keycode=%d\n", (int)keycode); + SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN; + if (keycode < SDL_arraysize(WinRT_Official_Keycodes)) { + scancode = WinRT_Official_Keycodes[keycode]; + } + if (scancode == SDL_SCANCODE_UNKNOWN) { + if (WinRT_Unofficial_Keycodes.find(keycode) != WinRT_Unofficial_Keycodes.end()) { + scancode = WinRT_Unofficial_Keycodes[keycode]; + } + } + if (scancode == SDL_SCANCODE_UNKNOWN) { + if (keycode < SDL_arraysize(windows_scancode_table)) { + scancode = windows_scancode_table[keycode]; + } + } + if (scancode == SDL_SCANCODE_UNKNOWN) { + SDL_Log("WinRT TranslateKeycode, unknown keycode=%d\n", (int)keycode); + } + return scancode; +} + +void +WINRT_ProcessKeyDownEvent(Windows::UI::Core::KeyEventArgs ^args) +{ + SDL_Scancode sdlScancode = TranslateKeycode((int)args->VirtualKey); +#if 0 + SDL_Keycode keycode = SDL_GetKeyFromScancode(sdlScancode); + SDL_Log("key down, handled=%s, ext?=%s, released?=%s, menu key down?=%s, repeat count=%d, native scan code=%d, was down?=%s, vkey=%d, sdl scan code=%d (%s), sdl key code=%d (%s)\n", + (args->Handled ? "1" : "0"), + (args->KeyStatus.IsExtendedKey ? "1" : "0"), + (args->KeyStatus.IsKeyReleased ? "1" : "0"), + (args->KeyStatus.IsMenuKeyDown ? "1" : "0"), + args->KeyStatus.RepeatCount, + args->KeyStatus.ScanCode, + (args->KeyStatus.WasKeyDown ? "1" : "0"), + args->VirtualKey, + sdlScancode, + SDL_GetScancodeName(sdlScancode), + keycode, + SDL_GetKeyName(keycode)); + //args->Handled = true; + //VirtualKey vkey = args->VirtualKey; +#endif + SDL_SendKeyboardKey(SDL_PRESSED, sdlScancode); +} + +void +WINRT_ProcessKeyUpEvent(Windows::UI::Core::KeyEventArgs ^args) +{ + SDL_Scancode sdlScancode = TranslateKeycode((int)args->VirtualKey); +#if 0 + SDL_Keycode keycode = SDL_GetKeyFromScancode(sdlScancode); + SDL_Log("key up, handled=%s, ext?=%s, released?=%s, menu key down?=%s, repeat count=%d, native scan code=%d, was down?=%s, vkey=%d, sdl scan code=%d (%s), sdl key code=%d (%s)\n", + (args->Handled ? "1" : "0"), + (args->KeyStatus.IsExtendedKey ? "1" : "0"), + (args->KeyStatus.IsKeyReleased ? "1" : "0"), + (args->KeyStatus.IsMenuKeyDown ? "1" : "0"), + args->KeyStatus.RepeatCount, + args->KeyStatus.ScanCode, + (args->KeyStatus.WasKeyDown ? "1" : "0"), + args->VirtualKey, + sdlScancode, + SDL_GetScancodeName(sdlScancode), + keycode, + SDL_GetKeyName(keycode)); + //args->Handled = true; +#endif + SDL_SendKeyboardKey(SDL_RELEASED, sdlScancode); +} + +#endif // SDL_VIDEO_DRIVER_WINRT diff --git a/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtmouse.cpp b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtmouse.cpp new file mode 100644 index 00000000..4c04a211 --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtmouse.cpp @@ -0,0 +1,165 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_WINRT + +/* + * Windows includes: + */ +#include +using namespace Windows::UI::Core; +using Windows::UI::Core::CoreCursor; + +/* + * SDL includes: + */ +extern "C" { +#include "SDL_assert.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_touch_c.h" +#include "../SDL_sysvideo.h" +#include "SDL_events.h" +#include "SDL_log.h" +} + +#include "../../core/winrt/SDL_winrtapp_direct3d.h" +#include "SDL_winrtvideo_cpp.h" +#include "SDL_winrtmouse_c.h" + + +extern "C" SDL_bool WINRT_UsingRelativeMouseMode = SDL_FALSE; + + +static SDL_Cursor * +WINRT_CreateSystemCursor(SDL_SystemCursor id) +{ + SDL_Cursor *cursor; + CoreCursorType cursorType = CoreCursorType::Arrow; + + switch(id) + { + default: + SDL_assert(0); + return NULL; + case SDL_SYSTEM_CURSOR_ARROW: cursorType = CoreCursorType::Arrow; break; + case SDL_SYSTEM_CURSOR_IBEAM: cursorType = CoreCursorType::IBeam; break; + case SDL_SYSTEM_CURSOR_WAIT: cursorType = CoreCursorType::Wait; break; + case SDL_SYSTEM_CURSOR_CROSSHAIR: cursorType = CoreCursorType::Cross; break; + case SDL_SYSTEM_CURSOR_WAITARROW: cursorType = CoreCursorType::Wait; break; + case SDL_SYSTEM_CURSOR_SIZENWSE: cursorType = CoreCursorType::SizeNorthwestSoutheast; break; + case SDL_SYSTEM_CURSOR_SIZENESW: cursorType = CoreCursorType::SizeNortheastSouthwest; break; + case SDL_SYSTEM_CURSOR_SIZEWE: cursorType = CoreCursorType::SizeWestEast; break; + case SDL_SYSTEM_CURSOR_SIZENS: cursorType = CoreCursorType::SizeNorthSouth; break; + case SDL_SYSTEM_CURSOR_SIZEALL: cursorType = CoreCursorType::SizeAll; break; + case SDL_SYSTEM_CURSOR_NO: cursorType = CoreCursorType::UniversalNo; break; + case SDL_SYSTEM_CURSOR_HAND: cursorType = CoreCursorType::Hand; break; + } + + cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + /* Create a pointer to a COM reference to a cursor. The extra + pointer is used (on top of the COM reference) to allow the cursor + to be referenced by the SDL_cursor's driverdata field, which is + a void pointer. + */ + CoreCursor ^* theCursor = new CoreCursor^(nullptr); + *theCursor = ref new CoreCursor(cursorType, 0); + cursor->driverdata = (void *) theCursor; + } else { + SDL_OutOfMemory(); + } + + return cursor; +} + +static SDL_Cursor * +WINRT_CreateDefaultCursor() +{ + return WINRT_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); +} + +static void +WINRT_FreeCursor(SDL_Cursor * cursor) +{ + if (cursor->driverdata) { + CoreCursor ^* theCursor = (CoreCursor ^*) cursor->driverdata; + *theCursor = nullptr; // Release the COM reference to the CoreCursor + delete theCursor; // Delete the pointer to the COM reference + } + SDL_free(cursor); +} + +static int +WINRT_ShowCursor(SDL_Cursor * cursor) +{ + // TODO, WinRT, XAML: make WINRT_ShowCursor work when XAML support is enabled. + if ( ! CoreWindow::GetForCurrentThread()) { + return 0; + } + + if (cursor) { + CoreCursor ^* theCursor = (CoreCursor ^*) cursor->driverdata; + CoreWindow::GetForCurrentThread()->PointerCursor = *theCursor; + } else { + CoreWindow::GetForCurrentThread()->PointerCursor = nullptr; + } + return 0; +} + +static int +WINRT_SetRelativeMouseMode(SDL_bool enabled) +{ + WINRT_UsingRelativeMouseMode = enabled; + return 0; +} + +void +WINRT_InitMouse(_THIS) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + /* DLudwig, Dec 3, 2012: WinRT does not currently provide APIs for + the following features, AFAIK: + - custom cursors (multiple system cursors are, however, available) + - programmatically moveable cursors + */ + +#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP + //mouse->CreateCursor = WINRT_CreateCursor; + mouse->CreateSystemCursor = WINRT_CreateSystemCursor; + mouse->ShowCursor = WINRT_ShowCursor; + mouse->FreeCursor = WINRT_FreeCursor; + //mouse->WarpMouse = WINRT_WarpMouse; + mouse->SetRelativeMouseMode = WINRT_SetRelativeMouseMode; + + SDL_SetDefaultCursor(WINRT_CreateDefaultCursor()); +#endif +} + +void +WINRT_QuitMouse(_THIS) +{ +} + +#endif /* SDL_VIDEO_DRIVER_WINRT */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtmouse_c.h b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtmouse_c.h new file mode 100644 index 00000000..676669b3 --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtmouse_c.h @@ -0,0 +1,40 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_winrtmouse_h +#define _SDL_winrtmouse_h + +#ifdef __cplusplus +extern "C" { +#endif + +extern void WINRT_InitMouse(_THIS); +extern void WINRT_QuitMouse(_THIS); +extern SDL_bool WINRT_UsingRelativeMouseMode; + +#ifdef __cplusplus +} +#endif + +#endif /* _SDL_windowsmouse_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtopengles.cpp b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtopengles.cpp new file mode 100644 index 00000000..6f3ddced --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtopengles.cpp @@ -0,0 +1,50 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +// TODO: WinRT, make this file compile via C code + +#if SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL + +/* EGL implementation of SDL OpenGL support */ + +#include "SDL_winrtvideo_cpp.h" +extern "C" { +#include "SDL_winrtopengles.h" +} + +#define EGL_D3D11_ONLY_DISPLAY_ANGLE ((NativeDisplayType) -3) + +extern "C" int +WINRT_GLES_LoadLibrary(_THIS, const char *path) { + return SDL_EGL_LoadLibrary(_this, path, EGL_D3D11_ONLY_DISPLAY_ANGLE); +} + +extern "C" { +SDL_EGL_CreateContext_impl(WINRT) +SDL_EGL_SwapWindow_impl(WINRT) +SDL_EGL_MakeCurrent_impl(WINRT) +} + +#endif /* SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL */ + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtopengles.h b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtopengles.h new file mode 100644 index 00000000..f051132e --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtopengles.h @@ -0,0 +1,48 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_winrtopengles_h +#define _SDL_winrtopengles_h + +#if SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL + +#include "../SDL_sysvideo.h" +#include "../SDL_egl_c.h" + +/* OpenGLES functions */ +#define WINRT_GLES_GetAttribute SDL_EGL_GetAttribute +#define WINRT_GLES_GetProcAddress SDL_EGL_GetProcAddress +#define WINRT_GLES_UnloadLibrary SDL_EGL_UnloadLibrary +#define WINRT_GLES_SetSwapInterval SDL_EGL_SetSwapInterval +#define WINRT_GLES_GetSwapInterval SDL_EGL_GetSwapInterval +#define WINRT_GLES_DeleteContext SDL_EGL_DeleteContext + +extern int WINRT_GLES_LoadLibrary(_THIS, const char *path); +extern SDL_GLContext WINRT_GLES_CreateContext(_THIS, SDL_Window * window); +extern void WINRT_GLES_SwapWindow(_THIS, SDL_Window * window); +extern int WINRT_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); + +#endif /* SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL */ + +#endif /* _SDL_winrtopengles_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtpointerinput.cpp b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtpointerinput.cpp new file mode 100644 index 00000000..e3afffba --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtpointerinput.cpp @@ -0,0 +1,394 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_WINRT + +/* SDL includes */ +#include "SDL_winrtevents_c.h" +#include "SDL_winrtmouse_c.h" +#include "SDL_winrtvideo_cpp.h" +#include "SDL_assert.h" +#include "SDL_system.h" + +extern "C" { +#include "../SDL_sysvideo.h" +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_touch_c.h" +} + +/* File-specific globals: */ +static SDL_TouchID WINRT_TouchID = 1; +static unsigned int WINRT_LeftFingerDown = 0; + + +void +WINRT_InitTouch(_THIS) +{ + SDL_AddTouch(WINRT_TouchID, ""); +} + + +// +// Applies necessary geometric transformations to raw cursor positions: +// +Windows::Foundation::Point +WINRT_TransformCursorPosition(SDL_Window * window, + Windows::Foundation::Point rawPosition, + WINRT_CursorNormalizationType normalization) +{ + using namespace Windows::UI::Core; + using namespace Windows::Graphics::Display; + + if (!window) { + return rawPosition; + } + + SDL_WindowData * windowData = (SDL_WindowData *) window->driverdata; + if (windowData->coreWindow == nullptr) { + // For some reason, the window isn't associated with a CoreWindow. + // This might end up being the case as XAML support is extended. + // For now, if there's no CoreWindow attached to the SDL_Window, + // don't do any transforms. + + // TODO, WinRT: make sure touch input coordinate ranges are correct when using XAML support + return rawPosition; + } + + // The CoreWindow can only be accessed on certain thread(s). + SDL_assert(CoreWindow::GetForCurrentThread() != nullptr); + + CoreWindow ^ nativeWindow = windowData->coreWindow.Get(); + Windows::Foundation::Point outputPosition; + + // Compute coordinates normalized from 0..1. + // If the coordinates need to be sized to the SDL window, + // we'll do that after. +#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP + outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width; + outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height; +#else + switch (DisplayProperties::CurrentOrientation) + { + case DisplayOrientations::Portrait: + outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width; + outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height; + break; + case DisplayOrientations::PortraitFlipped: + outputPosition.X = 1.0f - (rawPosition.X / nativeWindow->Bounds.Width); + outputPosition.Y = 1.0f - (rawPosition.Y / nativeWindow->Bounds.Height); + break; + case DisplayOrientations::Landscape: + outputPosition.X = rawPosition.Y / nativeWindow->Bounds.Height; + outputPosition.Y = 1.0f - (rawPosition.X / nativeWindow->Bounds.Width); + break; + case DisplayOrientations::LandscapeFlipped: + outputPosition.X = 1.0f - (rawPosition.Y / nativeWindow->Bounds.Height); + outputPosition.Y = rawPosition.X / nativeWindow->Bounds.Width; + break; + default: + break; + } +#endif + + if (normalization == TransformToSDLWindowSize) { + outputPosition.X *= ((float32) window->w); + outputPosition.Y *= ((float32) window->h); + } + + return outputPosition; +} + +static inline int +_lround(float arg) +{ + if (arg >= 0.0f) { + return (int)floor(arg + 0.5f); + } else { + return (int)ceil(arg - 0.5f); + } +} + +Uint8 +WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt) +{ + using namespace Windows::UI::Input; + +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + return SDL_BUTTON_LEFT; +#else + switch (pt->Properties->PointerUpdateKind) + { + case PointerUpdateKind::LeftButtonPressed: + case PointerUpdateKind::LeftButtonReleased: + return SDL_BUTTON_LEFT; + + case PointerUpdateKind::RightButtonPressed: + case PointerUpdateKind::RightButtonReleased: + return SDL_BUTTON_RIGHT; + + case PointerUpdateKind::MiddleButtonPressed: + case PointerUpdateKind::MiddleButtonReleased: + return SDL_BUTTON_MIDDLE; + + case PointerUpdateKind::XButton1Pressed: + case PointerUpdateKind::XButton1Released: + return SDL_BUTTON_X1; + + case PointerUpdateKind::XButton2Pressed: + case PointerUpdateKind::XButton2Released: + return SDL_BUTTON_X2; + + default: + break; + } +#endif + + return 0; +} + +//const char * +//WINRT_ConvertPointerUpdateKindToString(Windows::UI::Input::PointerUpdateKind kind) +//{ +// using namespace Windows::UI::Input; +// +// switch (kind) +// { +// case PointerUpdateKind::Other: +// return "Other"; +// case PointerUpdateKind::LeftButtonPressed: +// return "LeftButtonPressed"; +// case PointerUpdateKind::LeftButtonReleased: +// return "LeftButtonReleased"; +// case PointerUpdateKind::RightButtonPressed: +// return "RightButtonPressed"; +// case PointerUpdateKind::RightButtonReleased: +// return "RightButtonReleased"; +// case PointerUpdateKind::MiddleButtonPressed: +// return "MiddleButtonPressed"; +// case PointerUpdateKind::MiddleButtonReleased: +// return "MiddleButtonReleased"; +// case PointerUpdateKind::XButton1Pressed: +// return "XButton1Pressed"; +// case PointerUpdateKind::XButton1Released: +// return "XButton1Released"; +// case PointerUpdateKind::XButton2Pressed: +// return "XButton2Pressed"; +// case PointerUpdateKind::XButton2Released: +// return "XButton2Released"; +// } +// +// return ""; +//} + +static bool +WINRT_IsTouchEvent(Windows::UI::Input::PointerPoint ^pointerPoint) +{ +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + return true; +#else + using namespace Windows::Devices::Input; + switch (pointerPoint->PointerDevice->PointerDeviceType) { + case PointerDeviceType::Touch: + case PointerDeviceType::Pen: + return true; + default: + return false; + } +#endif +} + +void WINRT_ProcessPointerPressedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint) +{ + if (!window) { + return; + } + + Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint); + + if ( ! WINRT_IsTouchEvent(pointerPoint)) { + SDL_SendMouseButton(window, 0, SDL_PRESSED, button); + } else { + Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne); + Windows::Foundation::Point windowPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, TransformToSDLWindowSize); + + if (!WINRT_LeftFingerDown) { + if (button) { + SDL_SendMouseMotion(window, 0, 0, (int)windowPoint.X, (int)windowPoint.Y); + SDL_SendMouseButton(window, 0, SDL_PRESSED, button); + } + + WINRT_LeftFingerDown = pointerPoint->PointerId; + } + + SDL_SendTouch( + WINRT_TouchID, + (SDL_FingerID) pointerPoint->PointerId, + SDL_TRUE, + normalizedPoint.X, + normalizedPoint.Y, + pointerPoint->Properties->Pressure); + } +} + +void +WINRT_ProcessPointerMovedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint) +{ + if (!window || WINRT_UsingRelativeMouseMode) { + return; + } + + Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne); + Windows::Foundation::Point windowPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, TransformToSDLWindowSize); + + if ( ! WINRT_IsTouchEvent(pointerPoint)) { + SDL_SendMouseMotion(window, 0, 0, (int)windowPoint.X, (int)windowPoint.Y); + } else if (pointerPoint->PointerId == WINRT_LeftFingerDown) { + if (pointerPoint->PointerId == WINRT_LeftFingerDown) { + SDL_SendMouseMotion(window, 0, 0, (int)windowPoint.X, (int)windowPoint.Y); + } + + SDL_SendTouchMotion( + WINRT_TouchID, + (SDL_FingerID) pointerPoint->PointerId, + normalizedPoint.X, + normalizedPoint.Y, + pointerPoint->Properties->Pressure); + } +} + +void WINRT_ProcessPointerReleasedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint) +{ + if (!window) { + return; + } + + Uint8 button = WINRT_GetSDLButtonForPointerPoint(pointerPoint); + + if (!WINRT_IsTouchEvent(pointerPoint)) { + SDL_SendMouseButton(window, 0, SDL_RELEASED, button); + } else { + Windows::Foundation::Point normalizedPoint = WINRT_TransformCursorPosition(window, pointerPoint->Position, NormalizeZeroToOne); + + if (WINRT_LeftFingerDown == pointerPoint->PointerId) { + if (button) { + SDL_SendMouseButton(window, 0, SDL_RELEASED, button); + } + WINRT_LeftFingerDown = 0; + } + + SDL_SendTouch( + WINRT_TouchID, + (SDL_FingerID) pointerPoint->PointerId, + SDL_FALSE, + normalizedPoint.X, + normalizedPoint.Y, + pointerPoint->Properties->Pressure); + } +} + +void +WINRT_ProcessPointerWheelChangedEvent(SDL_Window *window, Windows::UI::Input::PointerPoint ^pointerPoint) +{ + if (!window) { + return; + } + + // FIXME: This may need to accumulate deltas up to WHEEL_DELTA + short motion = pointerPoint->Properties->MouseWheelDelta / WHEEL_DELTA; + SDL_SendMouseWheel(window, 0, 0, motion); +} + +void +WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::MouseEventArgs ^args) +{ + if (!window || !WINRT_UsingRelativeMouseMode) { + return; + } + + // DLudwig, 2012-12-28: On some systems, namely Visual Studio's Windows + // Simulator, as well as Windows 8 in a Parallels 8 VM, MouseEventArgs' + // MouseDelta field often reports very large values. More information + // on this can be found at the following pages on MSDN: + // - http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/a3c789fa-f1c5-49c4-9c0a-7db88d0f90f8 + // - https://connect.microsoft.com/VisualStudio/Feedback/details/756515 + // + // The values do not appear to be as large when running on some systems, + // most notably a Surface RT. Furthermore, the values returned by + // CoreWindow's PointerMoved event, and sent to this class' OnPointerMoved + // method, do not ever appear to be large, even when MouseEventArgs' + // MouseDelta is reporting to the contrary. + // + // On systems with the large-values behavior, it appears that the values + // get reported as if the screen's size is 65536 units in both the X and Y + // dimensions. This can be viewed by using Windows' now-private, "Raw Input" + // APIs. (GetRawInputData, RegisterRawInputDevices, WM_INPUT, etc.) + // + // MSDN's documentation on MouseEventArgs' MouseDelta field (at + // http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.input.mouseeventargs.mousedelta ), + // does not seem to indicate (to me) that its values should be so large. It + // says that its values should be a "change in screen location". I could + // be misinterpreting this, however a post on MSDN from a Microsoft engineer (see: + // http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/09a9868e-95bb-4858-ba1a-cb4d2c298d62 ), + // indicates that these values are in DIPs, which is the same unit used + // by CoreWindow's PointerMoved events (via the Position field in its CurrentPoint + // property. See http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.input.pointerpoint.position.aspx + // for details.) + // + // To note, PointerMoved events are sent a 'RawPosition' value (via the + // CurrentPoint property in MouseEventArgs), however these do not seem + // to exhibit the same large-value behavior. + // + // The values passed via PointerMoved events can't always be used for relative + // mouse motion, unfortunately. Its values are bound to the cursor's position, + // which stops when it hits one of the screen's edges. This can be a problem in + // first person shooters, whereby it is normal for mouse motion to travel far + // along any one axis for a period of time. MouseMoved events do not have the + // screen-bounding limitation, and can be used regardless of where the system's + // cursor is. + // + // One possible workaround would be to programmatically set the cursor's + // position to the screen's center (when SDL's relative mouse mode is enabled), + // however WinRT does not yet seem to have the ability to set the cursor's + // position via a public API. Win32 did this via an API call, SetCursorPos, + // however WinRT makes this function be private. Apps that use it won't get + // approved for distribution in the Windows Store. I've yet to be able to find + // a suitable, store-friendly counterpart for WinRT. + // + // There may be some room for a workaround whereby OnPointerMoved's values + // are compared to the values from OnMouseMoved in order to detect + // when this bug is active. A suitable transformation could then be made to + // OnMouseMoved's values. For now, however, the system-reported values are sent + // to SDL with minimal transformation: from native screen coordinates (in DIPs) + // to SDL window coordinates. + // + const Windows::Foundation::Point mouseDeltaInDIPs((float)args->MouseDelta.X, (float)args->MouseDelta.Y); + const Windows::Foundation::Point mouseDeltaInSDLWindowCoords = WINRT_TransformCursorPosition(window, mouseDeltaInDIPs, TransformToSDLWindowSize); + SDL_SendMouseMotion( + window, + 0, + 1, + _lround(mouseDeltaInSDLWindowCoords.X), + _lround(mouseDeltaInSDLWindowCoords.Y)); +} + +#endif // SDL_VIDEO_DRIVER_WINRT diff --git a/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtvideo.cpp b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtvideo.cpp new file mode 100644 index 00000000..4a5301f2 --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtvideo.cpp @@ -0,0 +1,409 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#if SDL_VIDEO_DRIVER_WINRT + +/* WinRT SDL video driver implementation + + Initial work on this was done by David Ludwig (dludwig@pobox.com), and + was based off of SDL's "dummy" video driver. + */ + +/* Windows includes */ +#include +using namespace Windows::UI::Core; + + +/* SDL includes */ +extern "C" { +#include "SDL_video.h" +#include "SDL_mouse.h" +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "../../events/SDL_events_c.h" +#include "../../render/SDL_sysrender.h" +#include "SDL_syswm.h" +#include "SDL_winrtopengles.h" +} + +#include "../../core/winrt/SDL_winrtapp_direct3d.h" +#include "../../core/winrt/SDL_winrtapp_xaml.h" +#include "SDL_winrtvideo_cpp.h" +#include "SDL_winrtevents_c.h" +#include "SDL_winrtmouse_c.h" +#include "SDL_main.h" +#include "SDL_system.h" + + +/* Initialization/Query functions */ +static int WINRT_VideoInit(_THIS); +static int WINRT_InitModes(_THIS); +static int WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); +static void WINRT_VideoQuit(_THIS); + + +/* Window functions */ +static int WINRT_CreateWindow(_THIS, SDL_Window * window); +static void WINRT_DestroyWindow(_THIS, SDL_Window * window); +static SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info); + + +/* SDL-internal globals: */ +SDL_Window * WINRT_GlobalSDLWindow = NULL; +SDL_VideoDevice * WINRT_GlobalSDLVideoDevice = NULL; + + +/* WinRT driver bootstrap functions */ + +static int +WINRT_Available(void) +{ + return (1); +} + +static void +WINRT_DeleteDevice(SDL_VideoDevice * device) +{ + if (device == WINRT_GlobalSDLVideoDevice) { + WINRT_GlobalSDLVideoDevice = NULL; + } + SDL_free(device); +} + +static SDL_VideoDevice * +WINRT_CreateDevice(int devindex) +{ + SDL_VideoDevice *device; + + /* Initialize all variables that we clean on shutdown */ + device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + SDL_OutOfMemory(); + if (device) { + SDL_free(device); + } + return (0); + } + + /* Set the function pointers */ + device->VideoInit = WINRT_VideoInit; + device->VideoQuit = WINRT_VideoQuit; + device->CreateWindow = WINRT_CreateWindow; + device->DestroyWindow = WINRT_DestroyWindow; + device->SetDisplayMode = WINRT_SetDisplayMode; + device->PumpEvents = WINRT_PumpEvents; + device->GetWindowWMInfo = WINRT_GetWindowWMInfo; +#ifdef SDL_VIDEO_OPENGL_EGL + device->GL_LoadLibrary = WINRT_GLES_LoadLibrary; + device->GL_GetProcAddress = WINRT_GLES_GetProcAddress; + device->GL_UnloadLibrary = WINRT_GLES_UnloadLibrary; + device->GL_CreateContext = WINRT_GLES_CreateContext; + device->GL_MakeCurrent = WINRT_GLES_MakeCurrent; + device->GL_SetSwapInterval = WINRT_GLES_SetSwapInterval; + device->GL_GetSwapInterval = WINRT_GLES_GetSwapInterval; + device->GL_SwapWindow = WINRT_GLES_SwapWindow; + device->GL_DeleteContext = WINRT_GLES_DeleteContext; +#endif + device->free = WINRT_DeleteDevice; + WINRT_GlobalSDLVideoDevice = device; + + return device; +} + +#define WINRTVID_DRIVER_NAME "winrt" +VideoBootStrap WINRT_bootstrap = { + WINRTVID_DRIVER_NAME, "SDL WinRT video driver", + WINRT_Available, WINRT_CreateDevice +}; + +int +WINRT_VideoInit(_THIS) +{ + if (WINRT_InitModes(_this) < 0) { + return -1; + } + WINRT_InitMouse(_this); + WINRT_InitTouch(_this); + + return 0; +} + +int +WINRT_CalcDisplayModeUsingNativeWindow(SDL_DisplayMode * mode) +{ + SDL_DisplayModeData * driverdata; + + using namespace Windows::Graphics::Display; + + // Go no further if a native window cannot be accessed. This can happen, + // for example, if this function is called from certain threads, such as + // the SDL/XAML thread. + if (!CoreWindow::GetForCurrentThread()) { + return SDL_SetError("SDL/WinRT display modes cannot be calculated outside of the main thread, such as in SDL's XAML thread"); + } + + // Calculate the display size given the window size, taking into account + // the current display's DPI: +#if NTDDI_VERSION > NTDDI_WIN8 + const float currentDPI = DisplayInformation::GetForCurrentView()->LogicalDpi; +#else + const float currentDPI = Windows::Graphics::Display::DisplayProperties::LogicalDpi; +#endif + const float dipsPerInch = 96.0f; + const int w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch); + const int h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch); + if (w == 0 || w == h) { + return SDL_SetError("Unable to calculate the WinRT window/display's size"); + } + + // Create a driverdata field: + driverdata = (SDL_DisplayModeData *) SDL_malloc(sizeof(*driverdata)); + if (!driverdata) { + return SDL_OutOfMemory(); + } + SDL_zerop(driverdata); + + // Fill in most fields: + SDL_zerop(mode); + mode->format = SDL_PIXELFORMAT_RGB888; + mode->refresh_rate = 0; // TODO, WinRT: see if refresh rate data is available, or relevant (for WinRT apps) + mode->w = w; + mode->h = h; + mode->driverdata = driverdata; +#if NTDDI_VERSION > NTDDI_WIN8 + driverdata->currentOrientation = DisplayInformation::GetForCurrentView()->CurrentOrientation; +#else + driverdata->currentOrientation = DisplayProperties::CurrentOrientation; +#endif + +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP + // On Windows Phone, the native window's size is always in portrait, + // regardless of the device's orientation. This is in contrast to + // Windows 8/RT, which will resize the native window as the device's + // orientation changes. In order to compensate for this behavior, + // on Windows Phone, the mode's width and height will be swapped when + // the device is in a landscape (non-portrait) mode. + switch (DisplayProperties::CurrentOrientation) { + case DisplayOrientations::Landscape: + case DisplayOrientations::LandscapeFlipped: + { + const int tmp = mode->h; + mode->h = mode->w; + mode->w = tmp; + break; + } + + default: + break; + } +#endif + + return 0; +} + +int +WINRT_DuplicateDisplayMode(SDL_DisplayMode * dest, const SDL_DisplayMode * src) +{ + SDL_DisplayModeData * driverdata; + driverdata = (SDL_DisplayModeData *) SDL_malloc(sizeof(*driverdata)); + if (!driverdata) { + return SDL_OutOfMemory(); + } + SDL_memcpy(driverdata, src->driverdata, sizeof(SDL_DisplayModeData)); + SDL_memcpy(dest, src, sizeof(SDL_DisplayMode)); + dest->driverdata = driverdata; + return 0; +} + +int +WINRT_InitModes(_THIS) +{ + // Retrieve the display mode: + SDL_DisplayMode mode, desktop_mode; + if (WINRT_CalcDisplayModeUsingNativeWindow(&mode) != 0) { + return -1; // If WINRT_CalcDisplayModeUsingNativeWindow fails, it'll already have set the SDL error + } + + if (WINRT_DuplicateDisplayMode(&desktop_mode, &mode) != 0) { + return -1; + } + if (SDL_AddBasicVideoDisplay(&desktop_mode) < 0) { + return -1; + } + + SDL_AddDisplayMode(&_this->displays[0], &mode); + return 0; +} + +static int +WINRT_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +{ + return 0; +} + +void +WINRT_VideoQuit(_THIS) +{ + WINRT_QuitMouse(_this); +} + +int +WINRT_CreateWindow(_THIS, SDL_Window * window) +{ + // Make sure that only one window gets created, at least until multimonitor + // support is added. + if (WINRT_GlobalSDLWindow != NULL) { + SDL_SetError("WinRT only supports one window"); + return -1; + } + + SDL_WindowData *data = new SDL_WindowData; + if (!data) { + SDL_OutOfMemory(); + return -1; + } + window->driverdata = data; + data->sdlWindow = window; + + /* To note, when XAML support is enabled, access to the CoreWindow will not + be possible, at least not via the SDL/XAML thread. Attempts to access it + from there will throw exceptions. As such, the SDL_WindowData's + 'coreWindow' field will only be set (to a non-null value) if XAML isn't + enabled. + */ + if (!WINRT_XAMLWasEnabled) { + data->coreWindow = CoreWindow::GetForCurrentThread(); + } + +#if SDL_VIDEO_OPENGL_EGL + /* Setup the EGL surface, but only if OpenGL ES 2 was requested. */ + if (!(window->flags & SDL_WINDOW_OPENGL)) { + /* OpenGL ES 2 wasn't requested. Don't set up an EGL surface. */ + data->egl_surface = EGL_NO_SURFACE; + } else { + /* OpenGL ES 2 was reuqested. Set up an EGL surface. */ + + /* HACK: ANGLE/WinRT currently uses non-pointer, C++ objects to represent + native windows. The object only contains a single pointer to a COM + interface pointer, which on x86 appears to be castable to the object + without apparant problems. On other platforms, notable ARM and x64, + doing so will cause a crash. To avoid this crash, we'll bypass + SDL's normal call to eglCreateWindowSurface, which is invoked from C + code, and call it here, where an appropriate C++ object may be + passed in. + */ + typedef EGLSurface (*eglCreateWindowSurfaceFunction)(EGLDisplay dpy, EGLConfig config, + Microsoft::WRL::ComPtr win, + const EGLint *attrib_list); + eglCreateWindowSurfaceFunction WINRT_eglCreateWindowSurface = + (eglCreateWindowSurfaceFunction) _this->egl_data->eglCreateWindowSurface; + + Microsoft::WRL::ComPtr nativeWindow = reinterpret_cast(data->coreWindow.Get()); + data->egl_surface = WINRT_eglCreateWindowSurface( + _this->egl_data->egl_display, + _this->egl_data->egl_config, + nativeWindow, NULL); + if (data->egl_surface == NULL) { + // TODO, WinRT: see if eglCreateWindowSurface, or its callee(s), sets an error message. If so, attach it to the SDL error. + return SDL_SetError("eglCreateWindowSurface failed"); + } + } +#endif + + /* Make sure the window is considered to be positioned at {0,0}, + and is considered fullscreen, shown, and the like. + */ + window->x = 0; + window->y = 0; + window->flags = + SDL_WINDOW_FULLSCREEN | + SDL_WINDOW_SHOWN | + SDL_WINDOW_BORDERLESS | + SDL_WINDOW_MAXIMIZED | + SDL_WINDOW_INPUT_GRABBED; + +#if SDL_VIDEO_OPENGL_EGL + if (data->egl_surface) { + window->flags |= SDL_WINDOW_OPENGL; + } +#endif + + /* WinRT does not, as of this writing, appear to support app-adjustable + window sizes. Set the window size to whatever the native WinRT + CoreWindow is set at. + + TODO, WinRT: if and when non-fullscreen XAML control support is added to SDL, consider making those resizable via SDL_Window's interfaces. + */ + window->w = _this->displays[0].current_mode.w; + window->h = _this->displays[0].current_mode.h; + + /* For now, treat WinRT apps as if they always have focus. + TODO, WinRT: try tracking keyboard and mouse focus state with respect to snapped apps + */ + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); + + /* Make sure the WinRT app's IFramworkView can post events on + behalf of SDL: + */ + WINRT_GlobalSDLWindow = window; + + /* All done! */ + return 0; +} + +void +WINRT_DestroyWindow(_THIS, SDL_Window * window) +{ + SDL_WindowData * data = (SDL_WindowData *) window->driverdata; + + if (WINRT_GlobalSDLWindow == window) { + WINRT_GlobalSDLWindow = NULL; + } + + if (data) { + // Delete the internal window data: + delete data; + data = NULL; + } +} + +SDL_bool +WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) +{ + SDL_WindowData * data = (SDL_WindowData *) window->driverdata; + + if (info->version.major <= SDL_MAJOR_VERSION) { + info->subsystem = SDL_SYSWM_WINRT; + info->info.winrt.window = reinterpret_cast(data->coreWindow.Get()); + return SDL_TRUE; + } else { + SDL_SetError("Application not compiled with SDL %d.%d\n", + SDL_MAJOR_VERSION, SDL_MINOR_VERSION); + return SDL_FALSE; + } + return SDL_FALSE; +} + +#endif /* SDL_VIDEO_DRIVER_WINRT */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtvideo_cpp.h b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtvideo_cpp.h new file mode 100644 index 00000000..b5f44510 --- /dev/null +++ b/jni/SDL2-2.0.3/src/video/winrt/SDL_winrtvideo_cpp.h @@ -0,0 +1,79 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* Windows includes: */ +#include +#ifdef __cplusplus_winrt +#include +#endif + +/* SDL includes: */ +#include "SDL_video.h" +#include "SDL_events.h" + +extern "C" { +#include "../SDL_sysvideo.h" +#include "../SDL_egl_c.h" +} + + +/* The global, WinRT, SDL Window. + For now, SDL/WinRT only supports one window (due to platform limitations of + WinRT. +*/ +extern SDL_Window * WINRT_GlobalSDLWindow; + +/* The global, WinRT, video device. */ +extern SDL_VideoDevice * WINRT_GlobalSDLVideoDevice; + +/* Creates a display mode for Plain Direct3D (non-XAML) apps, using the lone, native window's settings. + + Pass in an allocated SDL_DisplayMode field to store the data in. + + This function will return 0 on success, -1 on failure. + + If this function succeeds, be sure to call SDL_free on the + SDL_DisplayMode's driverdata field. +*/ +extern int WINRT_CalcDisplayModeUsingNativeWindow(SDL_DisplayMode * mode); + +/* Duplicates a display mode, copying over driverdata as necessary */ +extern int WINRT_DuplicateDisplayMode(SDL_DisplayMode * dest, const SDL_DisplayMode * src); + +/* Display mode internals */ +typedef struct +{ + Windows::Graphics::Display::DisplayOrientations currentOrientation; +} SDL_DisplayModeData; + +#ifdef __cplusplus_winrt + +/* Internal window data */ +struct SDL_WindowData +{ + SDL_Window *sdlWindow; + Platform::Agile coreWindow; +#ifdef SDL_VIDEO_OPENGL_EGL + EGLSurface egl_surface; +#endif +}; + +#endif // ifdef __cplusplus_winrt diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11clipboard.c b/jni/SDL2-2.0.3/src/video/x11/SDL_x11clipboard.c similarity index 98% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11clipboard.c rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11clipboard.c index b2adde8d..2999d983 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11clipboard.c +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11clipboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11clipboard.h b/jni/SDL2-2.0.3/src/video/x11/SDL_x11clipboard.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11clipboard.h rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11clipboard.h index 2c6c5516..46291cf6 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11clipboard.h +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11clipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11dyn.c b/jni/SDL2-2.0.3/src/video/x11/SDL_x11dyn.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11dyn.c rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11dyn.c index fa7b3ab3..97760ba3 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11dyn.c +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11dyn.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11dyn.h b/jni/SDL2-2.0.3/src/video/x11/SDL_x11dyn.h similarity index 98% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11dyn.h rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11dyn.h index f06fc60f..7d2e077c 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11dyn.h +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11dyn.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11events.c b/jni/SDL2-2.0.3/src/video/x11/SDL_x11events.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11events.c rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11events.c index 1bf42199..ad3c59d6 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11events.c +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11events.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -28,7 +28,6 @@ #include #include /* For INT_MAX */ -#include "SDL_x11video.h" #include "SDL_x11video.h" #include "SDL_x11touch.h" #include "SDL_x11xinput2.h" @@ -993,11 +992,6 @@ X11_Pending(Display * display) return (0); } - -/* !!! FIXME: this should be exposed in a header, or something. */ -int SDL_GetNumTouch(void); -void SDL_dbus_screensaver_tickle(_THIS); - void X11_PumpEvents(_THIS) { @@ -1035,7 +1029,19 @@ X11_SuspendScreenSaver(_THIS) SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; int dummy; int major_version, minor_version; +#endif /* SDL_VIDEO_DRIVER_X11_XSCRNSAVER */ +#if SDL_USE_LIBDBUS + if (SDL_dbus_screensaver_inhibit(_this)) { + return; + } + + if (_this->suspend_screensaver) { + SDL_dbus_screensaver_tickle(_this); + } +#endif + +#if SDL_VIDEO_DRIVER_X11_XSCRNSAVER if (SDL_X11_HAVE_XSS) { /* X11_XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */ if (!X11_XScreenSaverQueryExtension(data->display, &dummy, &dummy) || @@ -1049,12 +1055,6 @@ X11_SuspendScreenSaver(_THIS) X11_XResetScreenSaver(data->display); } #endif - -#if SDL_USE_LIBDBUS - if (_this->suspend_screensaver) { - SDL_dbus_screensaver_tickle(_this); - } -#endif } #endif /* SDL_VIDEO_DRIVER_X11 */ diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11events.h b/jni/SDL2-2.0.3/src/video/x11/SDL_x11events.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11events.h rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11events.h index 0af685cb..e27d53ac 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11events.h +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11events.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11framebuffer.c b/jni/SDL2-2.0.3/src/video/x11/SDL_x11framebuffer.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11framebuffer.c rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11framebuffer.c index 2bfc0ef4..19d9d0ba 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11framebuffer.c +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11framebuffer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11framebuffer.h b/jni/SDL2-2.0.3/src/video/x11/SDL_x11framebuffer.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11framebuffer.h rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11framebuffer.h index f5fd4f3f..c73c7487 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11framebuffer.h +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11framebuffer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11keyboard.c b/jni/SDL2-2.0.3/src/video/x11/SDL_x11keyboard.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11keyboard.c rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11keyboard.c index 6b8c4df7..36034606 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11keyboard.c +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11keyboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11keyboard.h b/jni/SDL2-2.0.3/src/video/x11/SDL_x11keyboard.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11keyboard.h rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11keyboard.h index 5cab9a59..3d1631fe 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11keyboard.h +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11keyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11messagebox.c b/jni/SDL2-2.0.3/src/video/x11/SDL_x11messagebox.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11messagebox.c rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11messagebox.c index a3dcc654..2a98e3c3 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11messagebox.c +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11messagebox.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -560,7 +560,11 @@ X11_MessageBoxLoop( SDL_MessageBoxDataX11 *data ) case MotionNotify: if ( has_focus ) { /* Mouse moved... */ + int previndex = data->mouse_over_index; data->mouse_over_index = GetHitButtonIndex( data, e.xbutton.x, e.xbutton.y ); + if (data->mouse_over_index == previndex) { + draw = SDL_FALSE; + } } break; diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11messagebox.h b/jni/SDL2-2.0.3/src/video/x11/SDL_x11messagebox.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11messagebox.h rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11messagebox.h index 9b270f82..d2d17128 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11messagebox.h +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11messagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11modes.c b/jni/SDL2-2.0.3/src/video/x11/SDL_x11modes.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11modes.c rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11modes.c index c5a1d799..6336f0ca 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11modes.c +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11modes.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11modes.h b/jni/SDL2-2.0.3/src/video/x11/SDL_x11modes.h similarity index 97% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11modes.h rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11modes.h index 7103d721..82af1d2d 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11modes.h +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11modes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11mouse.c b/jni/SDL2-2.0.3/src/video/x11/SDL_x11mouse.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11mouse.c rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11mouse.c index ea0f32da..38bb8665 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11mouse.c +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11mouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11mouse.h b/jni/SDL2-2.0.3/src/video/x11/SDL_x11mouse.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11mouse.h rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11mouse.h index d50bc324..8a2dac0e 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11mouse.h +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11mouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11opengl.c b/jni/SDL2-2.0.3/src/video/x11/SDL_x11opengl.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11opengl.c rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11opengl.c index 73a65571..1d2603e0 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11opengl.c +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11opengl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11opengl.h b/jni/SDL2-2.0.3/src/video/x11/SDL_x11opengl.h similarity index 97% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11opengl.h rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11opengl.h index fcf7fe24..ed7f292d 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11opengl.h +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11opengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11opengles.c b/jni/SDL2-2.0.3/src/video/x11/SDL_x11opengles.c similarity index 98% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11opengles.c rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11opengles.c index a6cdeebc..bce59b10 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11opengles.c +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11opengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11opengles.h b/jni/SDL2-2.0.3/src/video/x11/SDL_x11opengles.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11opengles.h rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11opengles.h index 16480c39..f6ea71eb 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11opengles.h +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11opengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11shape.c b/jni/SDL2-2.0.3/src/video/x11/SDL_x11shape.c similarity index 98% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11shape.c rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11shape.c index 1d5ae764..51520946 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11shape.c +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11shape.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11shape.h b/jni/SDL2-2.0.3/src/video/x11/SDL_x11shape.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11shape.h rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11shape.h index 3a3663d8..68118cfe 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11shape.h +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11shape.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11sym.h b/jni/SDL2-2.0.3/src/video/x11/SDL_x11sym.h similarity index 99% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11sym.h rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11sym.h index 1ee982b5..9678bac5 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11sym.h +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11sym.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11touch.c b/jni/SDL2-2.0.3/src/video/x11/SDL_x11touch.c similarity index 95% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11touch.c rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11touch.c index 0e83d6c2..a6da0463 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11touch.c +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11touch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11touch.h b/jni/SDL2-2.0.3/src/video/x11/SDL_x11touch.h similarity index 94% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11touch.h rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11touch.h index 71263d15..84de8d63 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11touch.h +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11touch.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11video.c b/jni/SDL2-2.0.3/src/video/x11/SDL_x11video.c similarity index 85% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11video.c rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11video.c index 065211db..ca9faee3 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11video.c +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11video.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -45,6 +45,7 @@ #include "SDL_loadso.h" static const char *dbus_library = "libdbus-1.so.3"; static void *dbus_handle = NULL; +static unsigned int screensaver_cookie = 0; /* !!! FIXME: this is kinda ugly. */ static SDL_bool @@ -63,10 +64,13 @@ load_dbus_sym(const char *fn, void **addr) static DBusConnection *(*DBUS_dbus_bus_get_private)(DBusBusType, DBusError *) = NULL; static void (*DBUS_dbus_connection_set_exit_on_disconnect)(DBusConnection *, dbus_bool_t) = NULL; static dbus_bool_t (*DBUS_dbus_connection_send)(DBusConnection *, DBusMessage *, dbus_uint32_t *) = NULL; +static DBusMessage *(*DBUS_dbus_connection_send_with_reply_and_block)(DBusConnection *, DBusMessage *, int, DBusError *) = NULL; static void (*DBUS_dbus_connection_close)(DBusConnection *) = NULL; static void (*DBUS_dbus_connection_unref)(DBusConnection *) = NULL; static void (*DBUS_dbus_connection_flush)(DBusConnection *) = NULL; static DBusMessage *(*DBUS_dbus_message_new_method_call)(const char *, const char *, const char *, const char *) = NULL; +static dbus_bool_t (*DBUS_dbus_message_append_args)(DBusMessage *, int, ...) = NULL; +static dbus_bool_t (*DBUS_dbus_message_get_args)(DBusMessage *, DBusError *, int, ...) = NULL; static void (*DBUS_dbus_message_unref)(DBusMessage *) = NULL; static void (*DBUS_dbus_error_init)(DBusError *) = NULL; static dbus_bool_t (*DBUS_dbus_error_is_set)(const DBusError *) = NULL; @@ -82,9 +86,12 @@ load_dbus_syms(void) SDL_DBUS_SYM(dbus_bus_get_private); SDL_DBUS_SYM(dbus_connection_set_exit_on_disconnect); SDL_DBUS_SYM(dbus_connection_send); + SDL_DBUS_SYM(dbus_connection_send_with_reply_and_block); SDL_DBUS_SYM(dbus_connection_close); SDL_DBUS_SYM(dbus_connection_unref); SDL_DBUS_SYM(dbus_connection_flush); + SDL_DBUS_SYM(dbus_message_append_args); + SDL_DBUS_SYM(dbus_message_get_args); SDL_DBUS_SYM(dbus_message_new_method_call); SDL_DBUS_SYM(dbus_message_unref); SDL_DBUS_SYM(dbus_error_init); @@ -174,6 +181,76 @@ SDL_dbus_screensaver_tickle(_THIS) } } } + +SDL_bool +SDL_dbus_screensaver_inhibit(_THIS) +{ + const SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + DBusConnection *conn = data->dbus; + + if (conn == NULL) + return SDL_FALSE; + + if (_this->suspend_screensaver && + screensaver_cookie != 0) + return SDL_TRUE; + if (!_this->suspend_screensaver && + screensaver_cookie == 0) + return SDL_TRUE; + + if (_this->suspend_screensaver) { + const char *app = "My SDL application"; + const char *reason = "Playing a game"; + + DBusMessage *msg = DBUS_dbus_message_new_method_call("org.freedesktop.ScreenSaver", + "/org/freedesktop/ScreenSaver", + "org.freedesktop.ScreenSaver", + "Inhibit"); + if (msg != NULL) { + DBUS_dbus_message_append_args (msg, + DBUS_TYPE_STRING, &app, + DBUS_TYPE_STRING, &reason, + DBUS_TYPE_INVALID); + } + + if (msg != NULL) { + DBusMessage *reply; + + reply = DBUS_dbus_connection_send_with_reply_and_block(conn, msg, 300, NULL); + if (reply) { + if (!DBUS_dbus_message_get_args(reply, NULL, + DBUS_TYPE_UINT32, &screensaver_cookie, + DBUS_TYPE_INVALID)) + screensaver_cookie = 0; + DBUS_dbus_message_unref(reply); + } + + DBUS_dbus_message_unref(msg); + } + + if (screensaver_cookie == 0) { + return SDL_FALSE; + } + return SDL_TRUE; + } else { + DBusMessage *msg = DBUS_dbus_message_new_method_call("org.freedesktop.ScreenSaver", + "/org/freedesktop/ScreenSaver", + "org.freedesktop.ScreenSaver", + "UnInhibit"); + DBUS_dbus_message_append_args (msg, + DBUS_TYPE_UINT32, &screensaver_cookie, + DBUS_TYPE_INVALID); + if (msg != NULL) { + if (DBUS_dbus_connection_send(conn, msg, NULL)) { + DBUS_dbus_connection_flush(conn); + } + DBUS_dbus_message_unref(msg); + } + + screensaver_cookie = 0; + return SDL_TRUE; + } +} #endif /* Initialization/Query functions */ diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11video.h b/jni/SDL2-2.0.3/src/video/x11/SDL_x11video.h similarity index 95% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11video.h rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11video.h index 005ca5d6..8ab88f72 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11video.h +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11video.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -121,6 +121,9 @@ typedef struct SDL_VideoData extern SDL_bool X11_UseDirectColorVisuals(void); +SDL_bool SDL_dbus_screensaver_inhibit(_THIS); +void SDL_dbus_screensaver_tickle(_THIS); + #endif /* _SDL_x11video_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11window.c b/jni/SDL2-2.0.3/src/video/x11/SDL_x11window.c similarity index 99% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11window.c rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11window.c index fe2596d5..f5ae655b 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11window.c +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11window.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11window.h b/jni/SDL2-2.0.3/src/video/x11/SDL_x11window.h similarity index 98% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11window.h rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11window.h index b8eda772..cf0d7f79 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11window.h +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11window.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11xinput2.c b/jni/SDL2-2.0.3/src/video/x11/SDL_x11xinput2.c similarity index 89% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11xinput2.c rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11xinput2.c index 967ddeb7..7c149922 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11xinput2.c +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11xinput2.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -60,16 +60,18 @@ static void parse_valuators(const double *input_values,unsigned char *mask,int m } } -static SDL_bool -xinput2_version_okay(Display *display, const int major, const int minor) +static int +query_xinput2_version(Display *display, int major, int minor) { - int outmajor = major; - int outminor = minor; - if (X11_XIQueryVersion(display, &outmajor, &outminor) != Success) { - return SDL_FALSE; - } + /* We don't care if this fails, so long as it sets major/minor on it's way out the door. */ + X11_XIQueryVersion(display, &major, &minor); + return ((major * 1000) + minor); +} - return ( ((outmajor * 1000) + outminor) >= ((major * 1000) + minor) ); +static SDL_bool +xinput2_version_atleast(const int version, const int wantmajor, const int wantminor) +{ + return ( version >= ((wantmajor * 1000) + wantminor) ); } #endif /* SDL_VIDEO_DRIVER_X11_XINPUT2 */ @@ -79,9 +81,11 @@ X11_InitXinput2(_THIS) #if SDL_VIDEO_DRIVER_X11_XINPUT2 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + int version = 0; XIEventMask eventmask; unsigned char mask[3] = { 0,0,0 }; int event, err; + /* * Initialize XInput 2 * According to http://who-t.blogspot.com/2009/05/xi2-recipes-part-1.html its better @@ -96,16 +100,16 @@ X11_InitXinput2(_THIS) return; /* X server does not have XInput at all */ } - if (!xinput2_version_okay(data->display, 2, 0)) { - return; /* X server does not support the version we want */ + /* We need at least 2.2 for Multitouch, 2.0 otherwise. */ + version = query_xinput2_version(data->display, 2, 2); + if (!xinput2_version_atleast(version, 2, 0)) { + return; /* X server does not support the version we want at all. */ } xinput2_initialized = 1; -#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH - if (xinput2_version_okay(data->display, 2, 2)) { /* Multitouch needs XInput 2.2 */ - xinput2_multitouch_supported = 1; - } +#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH /* Multitouch needs XInput 2.2 */ + xinput2_multitouch_supported = xinput2_version_atleast(version, 2, 2); #endif /* Enable Raw motion events for this display */ diff --git a/jni/SDL2-2.0.1/src/video/x11/SDL_x11xinput2.h b/jni/SDL2-2.0.3/src/video/x11/SDL_x11xinput2.h similarity index 96% rename from jni/SDL2-2.0.1/src/video/x11/SDL_x11xinput2.h rename to jni/SDL2-2.0.3/src/video/x11/SDL_x11xinput2.h index ee0e2763..3e7178cb 100644 --- a/jni/SDL2-2.0.1/src/video/x11/SDL_x11xinput2.h +++ b/jni/SDL2-2.0.3/src/video/x11/SDL_x11xinput2.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/src/video/x11/edid-parse.c b/jni/SDL2-2.0.3/src/video/x11/edid-parse.c similarity index 100% rename from jni/SDL2-2.0.1/src/video/x11/edid-parse.c rename to jni/SDL2-2.0.3/src/video/x11/edid-parse.c diff --git a/jni/SDL2-2.0.1/src/video/x11/edid.h b/jni/SDL2-2.0.3/src/video/x11/edid.h similarity index 100% rename from jni/SDL2-2.0.1/src/video/x11/edid.h rename to jni/SDL2-2.0.3/src/video/x11/edid.h diff --git a/jni/SDL2-2.0.1/src/video/x11/imKStoUCS.c b/jni/SDL2-2.0.3/src/video/x11/imKStoUCS.c similarity index 100% rename from jni/SDL2-2.0.1/src/video/x11/imKStoUCS.c rename to jni/SDL2-2.0.3/src/video/x11/imKStoUCS.c diff --git a/jni/SDL2-2.0.1/src/video/x11/imKStoUCS.h b/jni/SDL2-2.0.3/src/video/x11/imKStoUCS.h similarity index 100% rename from jni/SDL2-2.0.1/src/video/x11/imKStoUCS.h rename to jni/SDL2-2.0.3/src/video/x11/imKStoUCS.h diff --git a/jni/SDL2-2.0.1/test/COPYING b/jni/SDL2-2.0.3/test/COPYING similarity index 100% rename from jni/SDL2-2.0.1/test/COPYING rename to jni/SDL2-2.0.3/test/COPYING diff --git a/jni/SDL2-2.0.1/test/Makefile.in b/jni/SDL2-2.0.3/test/Makefile.in similarity index 98% rename from jni/SDL2-2.0.1/test/Makefile.in rename to jni/SDL2-2.0.3/test/Makefile.in index 8a8c2b8f..bf03896f 100644 --- a/jni/SDL2-2.0.1/test/Makefile.in +++ b/jni/SDL2-2.0.3/test/Makefile.in @@ -24,6 +24,7 @@ TARGETS = \ testgles2$(EXE) \ testhaptic$(EXE) \ testrumble$(EXE) \ + testhotplug$(EXE) \ testthread$(EXE) \ testiconv$(EXE) \ testime$(EXE) \ @@ -139,6 +140,9 @@ testgles2$(EXE): $(srcdir)/testgles2.c testhaptic$(EXE): $(srcdir)/testhaptic.c $(CC) -o $@ $^ $(CFLAGS) $(LIBS) +testhotplug$(EXE): $(srcdir)/testhotplug.c + $(CC) -o $@ $^ $(CFLAGS) $(LIBS) + testrumble$(EXE): $(srcdir)/testrumble.c $(CC) -o $@ $^ $(CFLAGS) $(LIBS) diff --git a/jni/SDL2-2.0.1/test/README b/jni/SDL2-2.0.3/test/README similarity index 100% rename from jni/SDL2-2.0.1/test/README rename to jni/SDL2-2.0.3/test/README diff --git a/jni/SDL2-2.0.1/test/acinclude.m4 b/jni/SDL2-2.0.3/test/acinclude.m4 similarity index 100% rename from jni/SDL2-2.0.1/test/acinclude.m4 rename to jni/SDL2-2.0.3/test/acinclude.m4 diff --git a/jni/SDL2-2.0.1/test/aclocal.m4 b/jni/SDL2-2.0.3/test/aclocal.m4 similarity index 100% rename from jni/SDL2-2.0.1/test/aclocal.m4 rename to jni/SDL2-2.0.3/test/aclocal.m4 diff --git a/jni/SDL2-2.0.1/test/autogen.sh b/jni/SDL2-2.0.3/test/autogen.sh similarity index 100% rename from jni/SDL2-2.0.1/test/autogen.sh rename to jni/SDL2-2.0.3/test/autogen.sh diff --git a/jni/SDL2-2.0.1/test/axis.bmp b/jni/SDL2-2.0.3/test/axis.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/axis.bmp rename to jni/SDL2-2.0.3/test/axis.bmp diff --git a/jni/SDL2-2.0.1/test/button.bmp b/jni/SDL2-2.0.3/test/button.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/button.bmp rename to jni/SDL2-2.0.3/test/button.bmp diff --git a/jni/SDL2-2.0.1/test/checkkeys.c b/jni/SDL2-2.0.3/test/checkkeys.c similarity index 98% rename from jni/SDL2-2.0.1/test/checkkeys.c rename to jni/SDL2-2.0.3/test/checkkeys.c index 5f2d1484..e157b289 100644 --- a/jni/SDL2-2.0.1/test/checkkeys.c +++ b/jni/SDL2-2.0.3/test/checkkeys.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/configure b/jni/SDL2-2.0.3/test/configure similarity index 100% rename from jni/SDL2-2.0.1/test/configure rename to jni/SDL2-2.0.3/test/configure diff --git a/jni/SDL2-2.0.1/test/configure.in b/jni/SDL2-2.0.3/test/configure.in similarity index 100% rename from jni/SDL2-2.0.1/test/configure.in rename to jni/SDL2-2.0.3/test/configure.in diff --git a/jni/SDL2-2.0.1/test/controllermap.bmp b/jni/SDL2-2.0.3/test/controllermap.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/controllermap.bmp rename to jni/SDL2-2.0.3/test/controllermap.bmp diff --git a/jni/SDL2-2.0.1/test/controllermap.c b/jni/SDL2-2.0.3/test/controllermap.c similarity index 96% rename from jni/SDL2-2.0.1/test/controllermap.c rename to jni/SDL2-2.0.3/test/controllermap.c index df4c892c..e6e9607c 100644 --- a/jni/SDL2-2.0.1/test/controllermap.c +++ b/jni/SDL2-2.0.3/test/controllermap.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -96,19 +96,12 @@ LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) return texture; } -static void -DrawRect(SDL_Renderer *r, const int x, const int y, const int w, const int h) -{ - const SDL_Rect area = { x, y, w, h }; - SDL_RenderFillRect(r, &area); -} - static SDL_bool WatchJoystick(SDL_Joystick * joystick) { SDL_Window *window = NULL; SDL_Renderer *screen = NULL; - SDL_Texture *target, *background, *button, *axis, *marker; + SDL_Texture *background, *button, *axis, *marker; const char *name = NULL; SDL_bool retval = SDL_FALSE; SDL_bool done = SDL_FALSE, next=SDL_FALSE; @@ -159,12 +152,14 @@ WatchJoystick(SDL_Joystick * joystick) return SDL_FALSE; } - target = SDL_CreateTexture(screen, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_TARGET, MAP_WIDTH, MAP_HEIGHT); background = LoadTexture(screen, "controllermap.bmp", SDL_FALSE); button = LoadTexture(screen, "button.bmp", SDL_TRUE); axis = LoadTexture(screen, "axis.bmp", SDL_TRUE); SDL_RaiseWindow(window); + /* scale for platforms that don't give you the window size you asked for. */ + SDL_RenderSetLogicalSize(screen, SCREEN_WIDTH, SCREEN_HEIGHT); + /* Print info about the joystick we are watching */ name = SDL_JoystickName(joystick); SDL_Log("Watching joystick %d: (%s)\n", SDL_JoystickInstanceID(joystick), @@ -213,7 +208,9 @@ WatchJoystick(SDL_Joystick * joystick) dst.y = step->y; SDL_QueryTexture(marker, NULL, NULL, &dst.w, &dst.h); next=SDL_FALSE; - + + SDL_SetRenderDrawColor(screen, 0xFF, 0xFF, 0xFF, SDL_ALPHA_OPAQUE); + while (!done && !next) { if (SDL_GetTicks() - alpha_ticks > 5) { alpha_ticks = SDL_GetTicks(); @@ -226,13 +223,11 @@ WatchJoystick(SDL_Joystick * joystick) } } - SDL_SetRenderTarget(screen, target); + SDL_RenderClear(screen); SDL_RenderCopy(screen, background, NULL, NULL); SDL_SetTextureAlphaMod(marker, alpha); SDL_SetTextureColorMod(marker, 10, 255, 21); SDL_RenderCopyEx(screen, marker, NULL, &dst, step->angle, NULL, 0); - SDL_SetRenderTarget(screen, NULL); - SDL_RenderCopy(screen, target, NULL, NULL); SDL_RenderPresent(screen); if (SDL_PollEvent(&event)) { diff --git a/jni/SDL2-2.0.1/test/gcc-fat.sh b/jni/SDL2-2.0.3/test/gcc-fat.sh similarity index 100% rename from jni/SDL2-2.0.1/test/gcc-fat.sh rename to jni/SDL2-2.0.3/test/gcc-fat.sh diff --git a/jni/SDL2-2.0.1/test/icon.bmp b/jni/SDL2-2.0.3/test/icon.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/icon.bmp rename to jni/SDL2-2.0.3/test/icon.bmp diff --git a/jni/SDL2-2.0.1/test/loopwave.c b/jni/SDL2-2.0.3/test/loopwave.c similarity index 90% rename from jni/SDL2-2.0.1/test/loopwave.c rename to jni/SDL2-2.0.3/test/loopwave.c index 34d07c2b..ab94da43 100644 --- a/jni/SDL2-2.0.1/test/loopwave.c +++ b/jni/SDL2-2.0.3/test/loopwave.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -79,6 +79,7 @@ int main(int argc, char *argv[]) { int i; + char filename[4096]; /* Enable standard application logging */ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); @@ -89,11 +90,13 @@ main(int argc, char *argv[]) return (1); } - if (argv[1] == NULL) { - argv[1] = "sample.wav"; + if (argc >= 1) { + SDL_strlcpy(filename, argv[1], sizeof(filename)); + } else { + SDL_strlcpy(filename, "sample.wav", sizeof(filename)); } /* Load the wave file into memory */ - if (SDL_LoadWAV(argv[1], &wave.spec, &wave.sound, &wave.soundlen) == NULL) { + if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", argv[1], SDL_GetError()); quit(1); } diff --git a/jni/SDL2-2.0.1/test/moose.dat b/jni/SDL2-2.0.3/test/moose.dat similarity index 100% rename from jni/SDL2-2.0.1/test/moose.dat rename to jni/SDL2-2.0.3/test/moose.dat diff --git a/jni/SDL2-2.0.1/test/picture.xbm b/jni/SDL2-2.0.3/test/picture.xbm similarity index 100% rename from jni/SDL2-2.0.1/test/picture.xbm rename to jni/SDL2-2.0.3/test/picture.xbm diff --git a/jni/SDL2-2.0.1/test/relative_mode.markdown b/jni/SDL2-2.0.3/test/relative_mode.markdown similarity index 100% rename from jni/SDL2-2.0.1/test/relative_mode.markdown rename to jni/SDL2-2.0.3/test/relative_mode.markdown diff --git a/jni/SDL2-2.0.1/test/sample.bmp b/jni/SDL2-2.0.3/test/sample.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/sample.bmp rename to jni/SDL2-2.0.3/test/sample.bmp diff --git a/jni/SDL2-2.0.1/test/sample.wav b/jni/SDL2-2.0.3/test/sample.wav similarity index 100% rename from jni/SDL2-2.0.1/test/sample.wav rename to jni/SDL2-2.0.3/test/sample.wav diff --git a/jni/SDL2-2.0.1/test/shapes/p01_shape24.bmp b/jni/SDL2-2.0.3/test/shapes/p01_shape24.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p01_shape24.bmp rename to jni/SDL2-2.0.3/test/shapes/p01_shape24.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p01_shape32alpha.bmp b/jni/SDL2-2.0.3/test/shapes/p01_shape32alpha.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p01_shape32alpha.bmp rename to jni/SDL2-2.0.3/test/shapes/p01_shape32alpha.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p01_shape8.bmp b/jni/SDL2-2.0.3/test/shapes/p01_shape8.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p01_shape8.bmp rename to jni/SDL2-2.0.3/test/shapes/p01_shape8.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p02_shape24.bmp b/jni/SDL2-2.0.3/test/shapes/p02_shape24.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p02_shape24.bmp rename to jni/SDL2-2.0.3/test/shapes/p02_shape24.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p02_shape32alpha.bmp b/jni/SDL2-2.0.3/test/shapes/p02_shape32alpha.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p02_shape32alpha.bmp rename to jni/SDL2-2.0.3/test/shapes/p02_shape32alpha.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p02_shape8.bmp b/jni/SDL2-2.0.3/test/shapes/p02_shape8.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p02_shape8.bmp rename to jni/SDL2-2.0.3/test/shapes/p02_shape8.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p03_shape24.bmp b/jni/SDL2-2.0.3/test/shapes/p03_shape24.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p03_shape24.bmp rename to jni/SDL2-2.0.3/test/shapes/p03_shape24.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p03_shape8.bmp b/jni/SDL2-2.0.3/test/shapes/p03_shape8.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p03_shape8.bmp rename to jni/SDL2-2.0.3/test/shapes/p03_shape8.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p04_shape1.bmp b/jni/SDL2-2.0.3/test/shapes/p04_shape1.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p04_shape1.bmp rename to jni/SDL2-2.0.3/test/shapes/p04_shape1.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p04_shape24.bmp b/jni/SDL2-2.0.3/test/shapes/p04_shape24.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p04_shape24.bmp rename to jni/SDL2-2.0.3/test/shapes/p04_shape24.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p04_shape32alpha.bmp b/jni/SDL2-2.0.3/test/shapes/p04_shape32alpha.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p04_shape32alpha.bmp rename to jni/SDL2-2.0.3/test/shapes/p04_shape32alpha.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p04_shape8.bmp b/jni/SDL2-2.0.3/test/shapes/p04_shape8.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p04_shape8.bmp rename to jni/SDL2-2.0.3/test/shapes/p04_shape8.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p05_shape8.bmp b/jni/SDL2-2.0.3/test/shapes/p05_shape8.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p05_shape8.bmp rename to jni/SDL2-2.0.3/test/shapes/p05_shape8.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p06_shape1alpha.bmp b/jni/SDL2-2.0.3/test/shapes/p06_shape1alpha.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p06_shape1alpha.bmp rename to jni/SDL2-2.0.3/test/shapes/p06_shape1alpha.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p06_shape24.bmp b/jni/SDL2-2.0.3/test/shapes/p06_shape24.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p06_shape24.bmp rename to jni/SDL2-2.0.3/test/shapes/p06_shape24.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p06_shape32alpha.bmp b/jni/SDL2-2.0.3/test/shapes/p06_shape32alpha.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p06_shape32alpha.bmp rename to jni/SDL2-2.0.3/test/shapes/p06_shape32alpha.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p06_shape8.bmp b/jni/SDL2-2.0.3/test/shapes/p06_shape8.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p06_shape8.bmp rename to jni/SDL2-2.0.3/test/shapes/p06_shape8.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p07_shape24.bmp b/jni/SDL2-2.0.3/test/shapes/p07_shape24.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p07_shape24.bmp rename to jni/SDL2-2.0.3/test/shapes/p07_shape24.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p07_shape32alpha.bmp b/jni/SDL2-2.0.3/test/shapes/p07_shape32alpha.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p07_shape32alpha.bmp rename to jni/SDL2-2.0.3/test/shapes/p07_shape32alpha.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p07_shape8.bmp b/jni/SDL2-2.0.3/test/shapes/p07_shape8.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p07_shape8.bmp rename to jni/SDL2-2.0.3/test/shapes/p07_shape8.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p08_shape24.bmp b/jni/SDL2-2.0.3/test/shapes/p08_shape24.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p08_shape24.bmp rename to jni/SDL2-2.0.3/test/shapes/p08_shape24.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p08_shape32alpha.bmp b/jni/SDL2-2.0.3/test/shapes/p08_shape32alpha.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p08_shape32alpha.bmp rename to jni/SDL2-2.0.3/test/shapes/p08_shape32alpha.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p08_shape8.bmp b/jni/SDL2-2.0.3/test/shapes/p08_shape8.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p08_shape8.bmp rename to jni/SDL2-2.0.3/test/shapes/p08_shape8.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p09_shape24.bmp b/jni/SDL2-2.0.3/test/shapes/p09_shape24.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p09_shape24.bmp rename to jni/SDL2-2.0.3/test/shapes/p09_shape24.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p09_shape32alpha.bmp b/jni/SDL2-2.0.3/test/shapes/p09_shape32alpha.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p09_shape32alpha.bmp rename to jni/SDL2-2.0.3/test/shapes/p09_shape32alpha.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p09_shape8.bmp b/jni/SDL2-2.0.3/test/shapes/p09_shape8.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p09_shape8.bmp rename to jni/SDL2-2.0.3/test/shapes/p09_shape8.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p10_shape1.bmp b/jni/SDL2-2.0.3/test/shapes/p10_shape1.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p10_shape1.bmp rename to jni/SDL2-2.0.3/test/shapes/p10_shape1.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p10_shape24.bmp b/jni/SDL2-2.0.3/test/shapes/p10_shape24.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p10_shape24.bmp rename to jni/SDL2-2.0.3/test/shapes/p10_shape24.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p10_shape32alpha.bmp b/jni/SDL2-2.0.3/test/shapes/p10_shape32alpha.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p10_shape32alpha.bmp rename to jni/SDL2-2.0.3/test/shapes/p10_shape32alpha.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p10_shape8.bmp b/jni/SDL2-2.0.3/test/shapes/p10_shape8.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p10_shape8.bmp rename to jni/SDL2-2.0.3/test/shapes/p10_shape8.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p11_shape24.bmp b/jni/SDL2-2.0.3/test/shapes/p11_shape24.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p11_shape24.bmp rename to jni/SDL2-2.0.3/test/shapes/p11_shape24.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p11_shape32alpha.bmp b/jni/SDL2-2.0.3/test/shapes/p11_shape32alpha.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p11_shape32alpha.bmp rename to jni/SDL2-2.0.3/test/shapes/p11_shape32alpha.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p11_shape8.bmp b/jni/SDL2-2.0.3/test/shapes/p11_shape8.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p11_shape8.bmp rename to jni/SDL2-2.0.3/test/shapes/p11_shape8.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p12_shape24.bmp b/jni/SDL2-2.0.3/test/shapes/p12_shape24.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p12_shape24.bmp rename to jni/SDL2-2.0.3/test/shapes/p12_shape24.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p12_shape8.bmp b/jni/SDL2-2.0.3/test/shapes/p12_shape8.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p12_shape8.bmp rename to jni/SDL2-2.0.3/test/shapes/p12_shape8.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p13_shape24.bmp b/jni/SDL2-2.0.3/test/shapes/p13_shape24.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p13_shape24.bmp rename to jni/SDL2-2.0.3/test/shapes/p13_shape24.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p13_shape32alpha.bmp b/jni/SDL2-2.0.3/test/shapes/p13_shape32alpha.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p13_shape32alpha.bmp rename to jni/SDL2-2.0.3/test/shapes/p13_shape32alpha.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p13_shape8.bmp b/jni/SDL2-2.0.3/test/shapes/p13_shape8.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p13_shape8.bmp rename to jni/SDL2-2.0.3/test/shapes/p13_shape8.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p14_shape24.bmp b/jni/SDL2-2.0.3/test/shapes/p14_shape24.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p14_shape24.bmp rename to jni/SDL2-2.0.3/test/shapes/p14_shape24.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p14_shape8.bmp b/jni/SDL2-2.0.3/test/shapes/p14_shape8.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p14_shape8.bmp rename to jni/SDL2-2.0.3/test/shapes/p14_shape8.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p15_shape24.bmp b/jni/SDL2-2.0.3/test/shapes/p15_shape24.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p15_shape24.bmp rename to jni/SDL2-2.0.3/test/shapes/p15_shape24.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p15_shape32alpha.bmp b/jni/SDL2-2.0.3/test/shapes/p15_shape32alpha.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p15_shape32alpha.bmp rename to jni/SDL2-2.0.3/test/shapes/p15_shape32alpha.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p15_shape8.bmp b/jni/SDL2-2.0.3/test/shapes/p15_shape8.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p15_shape8.bmp rename to jni/SDL2-2.0.3/test/shapes/p15_shape8.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p16_shape1.bmp b/jni/SDL2-2.0.3/test/shapes/p16_shape1.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p16_shape1.bmp rename to jni/SDL2-2.0.3/test/shapes/p16_shape1.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p16_shape24.bmp b/jni/SDL2-2.0.3/test/shapes/p16_shape24.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p16_shape24.bmp rename to jni/SDL2-2.0.3/test/shapes/p16_shape24.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/p16_shape8.bmp b/jni/SDL2-2.0.3/test/shapes/p16_shape8.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/p16_shape8.bmp rename to jni/SDL2-2.0.3/test/shapes/p16_shape8.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/trollface_24.bmp b/jni/SDL2-2.0.3/test/shapes/trollface_24.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/trollface_24.bmp rename to jni/SDL2-2.0.3/test/shapes/trollface_24.bmp diff --git a/jni/SDL2-2.0.1/test/shapes/trollface_32alpha.bmp b/jni/SDL2-2.0.3/test/shapes/trollface_32alpha.bmp similarity index 100% rename from jni/SDL2-2.0.1/test/shapes/trollface_32alpha.bmp rename to jni/SDL2-2.0.3/test/shapes/trollface_32alpha.bmp diff --git a/jni/SDL2-2.0.1/test/testatomic.c b/jni/SDL2-2.0.3/test/testatomic.c similarity index 99% rename from jni/SDL2-2.0.1/test/testatomic.c rename to jni/SDL2-2.0.3/test/testatomic.c index b360616d..006fdedf 100644 --- a/jni/SDL2-2.0.1/test/testatomic.c +++ b/jni/SDL2-2.0.3/test/testatomic.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testaudioinfo.c b/jni/SDL2-2.0.3/test/testaudioinfo.c similarity index 96% rename from jni/SDL2-2.0.1/test/testaudioinfo.c rename to jni/SDL2-2.0.3/test/testaudioinfo.c index a65db5fa..76ac9428 100644 --- a/jni/SDL2-2.0.1/test/testaudioinfo.c +++ b/jni/SDL2-2.0.3/test/testaudioinfo.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testautomation.c b/jni/SDL2-2.0.3/test/testautomation.c similarity index 98% rename from jni/SDL2-2.0.1/test/testautomation.c rename to jni/SDL2-2.0.3/test/testautomation.c index 0a181bd9..8eab76e9 100644 --- a/jni/SDL2-2.0.1/test/testautomation.c +++ b/jni/SDL2-2.0.3/test/testautomation.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testautomation_audio.c b/jni/SDL2-2.0.3/test/testautomation_audio.c similarity index 100% rename from jni/SDL2-2.0.1/test/testautomation_audio.c rename to jni/SDL2-2.0.3/test/testautomation_audio.c diff --git a/jni/SDL2-2.0.1/test/testautomation_clipboard.c b/jni/SDL2-2.0.3/test/testautomation_clipboard.c similarity index 100% rename from jni/SDL2-2.0.1/test/testautomation_clipboard.c rename to jni/SDL2-2.0.3/test/testautomation_clipboard.c diff --git a/jni/SDL2-2.0.1/test/testautomation_events.c b/jni/SDL2-2.0.3/test/testautomation_events.c similarity index 100% rename from jni/SDL2-2.0.1/test/testautomation_events.c rename to jni/SDL2-2.0.3/test/testautomation_events.c diff --git a/jni/SDL2-2.0.1/test/testautomation_keyboard.c b/jni/SDL2-2.0.3/test/testautomation_keyboard.c similarity index 100% rename from jni/SDL2-2.0.1/test/testautomation_keyboard.c rename to jni/SDL2-2.0.3/test/testautomation_keyboard.c diff --git a/jni/SDL2-2.0.1/test/testautomation_main.c b/jni/SDL2-2.0.3/test/testautomation_main.c similarity index 100% rename from jni/SDL2-2.0.1/test/testautomation_main.c rename to jni/SDL2-2.0.3/test/testautomation_main.c diff --git a/jni/SDL2-2.0.1/test/testautomation_mouse.c b/jni/SDL2-2.0.3/test/testautomation_mouse.c similarity index 100% rename from jni/SDL2-2.0.1/test/testautomation_mouse.c rename to jni/SDL2-2.0.3/test/testautomation_mouse.c diff --git a/jni/SDL2-2.0.1/test/testautomation_pixels.c b/jni/SDL2-2.0.3/test/testautomation_pixels.c similarity index 100% rename from jni/SDL2-2.0.1/test/testautomation_pixels.c rename to jni/SDL2-2.0.3/test/testautomation_pixels.c diff --git a/jni/SDL2-2.0.1/test/testautomation_platform.c b/jni/SDL2-2.0.3/test/testautomation_platform.c similarity index 90% rename from jni/SDL2-2.0.1/test/testautomation_platform.c rename to jni/SDL2-2.0.3/test/testautomation_platform.c index 19896b48..849d4e38 100644 --- a/jni/SDL2-2.0.1/test/testautomation_platform.c +++ b/jni/SDL2-2.0.3/test/testautomation_platform.c @@ -163,6 +163,7 @@ int platform_testGetFunctions (void *arg) * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE3 * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE41 * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE42 + * http://wiki.libsdl.org/moin.cgi/SDL_HasAVX */ int platform_testHasFunctions (void *arg) { @@ -197,6 +198,9 @@ int platform_testHasFunctions (void *arg) ret = SDL_HasSSE42(); SDLTest_AssertPass("SDL_HasSSE42()"); + ret = SDL_HasAVX(); + SDLTest_AssertPass("SDL_HasAVX()"); + return TEST_COMPLETED; } @@ -279,6 +283,7 @@ int platform_testDefaultInit(void *arg) */ int platform_testGetSetClearError(void *arg) { + int result; const char *testError = "Testing"; char *lastError; int len; @@ -297,8 +302,9 @@ int platform_testGetSetClearError(void *arg) "SDL_GetError(): no message expected, len: %i", len); } - SDL_SetError("%s", testError); + result = SDL_SetError("%s", testError); SDLTest_AssertPass("SDL_SetError()"); + SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); lastError = (char *)SDL_GetError(); SDLTest_AssertCheck(lastError != NULL, "SDL_GetError() != NULL"); @@ -329,12 +335,14 @@ int platform_testGetSetClearError(void *arg) */ int platform_testSetErrorEmptyInput(void *arg) { + int result; const char *testError = ""; char *lastError; int len; - SDL_SetError("%s", testError); + result = SDL_SetError("%s", testError); SDLTest_AssertPass("SDL_SetError()"); + SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); lastError = (char *)SDL_GetError(); SDLTest_AssertCheck(lastError != NULL, "SDL_GetError() != NULL"); @@ -365,7 +373,8 @@ int platform_testSetErrorEmptyInput(void *arg) */ int platform_testSetErrorInvalidInput(void *arg) { - const char *testError = NULL; + int result; + const char *invalidError = NULL; const char *probeError = "Testing"; char *lastError; int len; @@ -375,8 +384,9 @@ int platform_testSetErrorInvalidInput(void *arg) SDLTest_AssertPass("SDL_ClearError()"); /* Check for no-op */ - SDL_SetError(testError); + result = SDL_SetError(invalidError); SDLTest_AssertPass("SDL_SetError()"); + SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); lastError = (char *)SDL_GetError(); SDLTest_AssertCheck(lastError != NULL, "SDL_GetError() != NULL"); @@ -393,12 +403,14 @@ int platform_testSetErrorInvalidInput(void *arg) } /* Set */ - SDL_SetError(probeError); + result = SDL_SetError(probeError); SDLTest_AssertPass("SDL_SetError()"); + SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); /* Check for no-op */ - SDL_SetError(testError); + result = SDL_SetError(invalidError); SDLTest_AssertPass("SDL_SetError()"); + SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); lastError = (char *)SDL_GetError(); SDLTest_AssertCheck(lastError != NULL, "SDL_GetError() != NULL"); @@ -415,6 +427,30 @@ int platform_testSetErrorInvalidInput(void *arg) lastError); } + /* Reset */ + SDL_ClearError(); + SDLTest_AssertPass("SDL_ClearError()"); + + /* Set and check */ + result = SDL_SetError(probeError); + SDLTest_AssertPass("SDL_SetError()"); + SDLTest_AssertCheck(result == -1, "SDL_SetError: expected -1, got: %i", result); + lastError = (char *)SDL_GetError(); + SDLTest_AssertCheck(lastError != NULL, + "SDL_GetError() != NULL"); + if (lastError != NULL) + { + len = SDL_strlen(lastError); + SDLTest_AssertCheck(len == SDL_strlen(probeError), + "SDL_GetError(): expected message len %i, was len: %i", + SDL_strlen(probeError), + len); + SDLTest_AssertCheck(SDL_strcmp(lastError, probeError) == 0, + "SDL_GetError(): expected message '%s', was message: '%s'", + probeError, + lastError); + } + /* Clean up */ SDL_ClearError(); SDLTest_AssertPass("SDL_ClearError()"); diff --git a/jni/SDL2-2.0.1/test/testautomation_rect.c b/jni/SDL2-2.0.3/test/testautomation_rect.c similarity index 100% rename from jni/SDL2-2.0.1/test/testautomation_rect.c rename to jni/SDL2-2.0.3/test/testautomation_rect.c diff --git a/jni/SDL2-2.0.1/test/testautomation_render.c b/jni/SDL2-2.0.3/test/testautomation_render.c similarity index 100% rename from jni/SDL2-2.0.1/test/testautomation_render.c rename to jni/SDL2-2.0.3/test/testautomation_render.c diff --git a/jni/SDL2-2.0.1/test/testautomation_rwops.c b/jni/SDL2-2.0.3/test/testautomation_rwops.c similarity index 100% rename from jni/SDL2-2.0.1/test/testautomation_rwops.c rename to jni/SDL2-2.0.3/test/testautomation_rwops.c diff --git a/jni/SDL2-2.0.1/test/testautomation_sdltest.c b/jni/SDL2-2.0.3/test/testautomation_sdltest.c similarity index 97% rename from jni/SDL2-2.0.1/test/testautomation_sdltest.c rename to jni/SDL2-2.0.3/test/testautomation_sdltest.c index d9ce7d28..646027a6 100644 --- a/jni/SDL2-2.0.1/test/testautomation_sdltest.c +++ b/jni/SDL2-2.0.3/test/testautomation_sdltest.c @@ -21,6 +21,39 @@ /* Test case functions */ +/* Forward declarations for internal harness functions */ +extern char *SDLTest_GenerateRunSeed(const int length); + +/** + * @brief Calls to SDLTest_GenerateRunSeed() + */ +int +sdltest_generateRunSeed(void *arg) +{ + char* result; + int i, l; + + for (i = 1; i <= 10; i += 3) { + result = SDLTest_GenerateRunSeed((const int)i); + SDLTest_AssertPass("Call to SDLTest_GenerateRunSeed()"); + SDLTest_AssertCheck(result != NULL, "Verify returned value is not NULL"); + if (result != NULL) { + l = SDL_strlen(result); + SDLTest_AssertCheck(l == i, "Verify length of returned value is %d, got: %d", i, l); + SDL_free(result); + } + } + + /* Negative cases */ + for (i = -2; i <= 0; i++) { + result = SDLTest_GenerateRunSeed((const int)i); + SDLTest_AssertPass("Call to SDLTest_GenerateRunSeed()"); + SDLTest_AssertCheck(result == NULL, "Verify returned value is not NULL"); + } + + return TEST_COMPLETED; +} + /** * @brief Calls to SDLTest_GetFuzzerInvocationCount() */ @@ -1263,11 +1296,14 @@ static const SDLTest_TestCaseReference sdltestTest13 = static const SDLTest_TestCaseReference sdltestTest14 = { (SDLTest_TestCaseFp)sdltest_randomAsciiStringOfSize, "sdltest_randomAsciiStringOfSize", "Calls to fixed size ASCII string generator", TEST_ENABLED }; +static const SDLTest_TestCaseReference sdltestTest15 = + { (SDLTest_TestCaseFp)sdltest_generateRunSeed, "sdltest_generateRunSeed", "Checks internal harness function SDLTest_GenerateRunSeed", TEST_ENABLED }; + /* Sequence of SDL_test test cases */ static const SDLTest_TestCaseReference *sdltestTests[] = { &sdltestTest1, &sdltestTest2, &sdltestTest3, &sdltestTest4, &sdltestTest5, &sdltestTest6, &sdltestTest7, &sdltestTest8, &sdltestTest9, &sdltestTest10, &sdltestTest11, &sdltestTest12, - &sdltestTest13, &sdltestTest14, NULL + &sdltestTest13, &sdltestTest14, &sdltestTest15, NULL }; /* SDL_test test suite (global) */ diff --git a/jni/SDL2-2.0.1/test/testautomation_stdlib.c b/jni/SDL2-2.0.3/test/testautomation_stdlib.c similarity index 100% rename from jni/SDL2-2.0.1/test/testautomation_stdlib.c rename to jni/SDL2-2.0.3/test/testautomation_stdlib.c diff --git a/jni/SDL2-2.0.1/test/testautomation_suites.h b/jni/SDL2-2.0.3/test/testautomation_suites.h similarity index 100% rename from jni/SDL2-2.0.1/test/testautomation_suites.h rename to jni/SDL2-2.0.3/test/testautomation_suites.h diff --git a/jni/SDL2-2.0.1/test/testautomation_surface.c b/jni/SDL2-2.0.3/test/testautomation_surface.c similarity index 100% rename from jni/SDL2-2.0.1/test/testautomation_surface.c rename to jni/SDL2-2.0.3/test/testautomation_surface.c diff --git a/jni/SDL2-2.0.1/test/testautomation_syswm.c b/jni/SDL2-2.0.3/test/testautomation_syswm.c similarity index 100% rename from jni/SDL2-2.0.1/test/testautomation_syswm.c rename to jni/SDL2-2.0.3/test/testautomation_syswm.c diff --git a/jni/SDL2-2.0.1/test/testautomation_timer.c b/jni/SDL2-2.0.3/test/testautomation_timer.c similarity index 100% rename from jni/SDL2-2.0.1/test/testautomation_timer.c rename to jni/SDL2-2.0.3/test/testautomation_timer.c diff --git a/jni/SDL2-2.0.1/test/testautomation_video.c b/jni/SDL2-2.0.3/test/testautomation_video.c similarity index 100% rename from jni/SDL2-2.0.1/test/testautomation_video.c rename to jni/SDL2-2.0.3/test/testautomation_video.c diff --git a/jni/SDL2-2.0.1/test/testdraw2.c b/jni/SDL2-2.0.3/test/testdraw2.c similarity index 99% rename from jni/SDL2-2.0.1/test/testdraw2.c rename to jni/SDL2-2.0.3/test/testdraw2.c index 62e2dbf6..8c14185c 100644 --- a/jni/SDL2-2.0.1/test/testdraw2.c +++ b/jni/SDL2-2.0.3/test/testdraw2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testdrawchessboard.c b/jni/SDL2-2.0.3/test/testdrawchessboard.c similarity index 97% rename from jni/SDL2-2.0.1/test/testdrawchessboard.c rename to jni/SDL2-2.0.3/test/testdrawchessboard.c index bb30bd8d..3e6179e1 100644 --- a/jni/SDL2-2.0.1/test/testdrawchessboard.c +++ b/jni/SDL2-2.0.3/test/testdrawchessboard.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testdropfile.c b/jni/SDL2-2.0.3/test/testdropfile.c similarity index 89% rename from jni/SDL2-2.0.1/test/testdropfile.c rename to jni/SDL2-2.0.3/test/testdropfile.c index 9f4fa7b6..d62c7f0e 100644 --- a/jni/SDL2-2.0.1/test/testdropfile.c +++ b/jni/SDL2-2.0.3/test/testdropfile.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -44,6 +44,10 @@ main(int argc, char *argv[]) int consumed; consumed = SDLTest_CommonArg(state, i); + // needed vodoo to allow app to launch via OS X Finder + if (SDL_strncmp(argv[i], "-psn", 4)==0) { + consumed = 1; + } if (consumed == 0) { consumed = -1; } @@ -64,6 +68,8 @@ main(int argc, char *argv[]) SDL_RenderPresent(renderer); } + SDL_EventState(SDL_DROPFILE, SDL_ENABLE); + /* Main render loop */ done = 0; while (!done) { diff --git a/jni/SDL2-2.0.1/test/testerror.c b/jni/SDL2-2.0.3/test/testerror.c similarity index 97% rename from jni/SDL2-2.0.1/test/testerror.c rename to jni/SDL2-2.0.3/test/testerror.c index e9c76ff1..1fa60885 100644 --- a/jni/SDL2-2.0.1/test/testerror.c +++ b/jni/SDL2-2.0.3/test/testerror.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testfile.c b/jni/SDL2-2.0.3/test/testfile.c similarity index 99% rename from jni/SDL2-2.0.1/test/testfile.c rename to jni/SDL2-2.0.3/test/testfile.c index 57ba02f5..172da865 100644 --- a/jni/SDL2-2.0.1/test/testfile.c +++ b/jni/SDL2-2.0.3/test/testfile.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testfilesystem.c b/jni/SDL2-2.0.3/test/testfilesystem.c similarity index 93% rename from jni/SDL2-2.0.1/test/testfilesystem.c rename to jni/SDL2-2.0.3/test/testfilesystem.c index e1f25137..701b98ad 100644 --- a/jni/SDL2-2.0.1/test/testfilesystem.c +++ b/jni/SDL2-2.0.3/test/testfilesystem.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testgamecontroller.c b/jni/SDL2-2.0.3/test/testgamecontroller.c similarity index 66% rename from jni/SDL2-2.0.1/test/testgamecontroller.c rename to jni/SDL2-2.0.3/test/testgamecontroller.c index 77d63f2d..f762ce62 100644 --- a/jni/SDL2-2.0.1/test/testgamecontroller.c +++ b/jni/SDL2-2.0.3/test/testgamecontroller.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -24,20 +24,10 @@ #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 480 #else -#define SCREEN_WIDTH 640 -#define SCREEN_HEIGHT 480 +#define SCREEN_WIDTH 512 +#define SCREEN_HEIGHT 317 #endif -#define MAX_NUM_AXES 6 -#define MAX_NUM_HATS 2 - -static void -DrawRect(SDL_Renderer *r, const int x, const int y, const int w, const int h) -{ - const SDL_Rect area = { x, y, w, h }; - SDL_RenderFillRect(r, &area); -} - static const char * ControllerAxisName(const SDL_GameControllerAxis axis) { @@ -83,13 +73,71 @@ ControllerButtonName(const SDL_GameControllerButton button) } } +static SDL_Texture * +LoadTexture(SDL_Renderer *renderer, char *file, SDL_bool transparent) +{ + SDL_Surface *temp = NULL; + SDL_Texture *texture = NULL; + + temp = SDL_LoadBMP(file); + if (temp == NULL) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); + } else { + /* Set transparent pixel as the pixel at (0,0) */ + if (transparent) { + SDL_assert(!temp->format->palette); + SDL_assert(temp->format->BitsPerPixel == 24); + SDL_SetColorKey(temp, SDL_TRUE, (*(Uint32 *) temp->pixels) & 0x00FFFFFF); + } + + texture = SDL_CreateTextureFromSurface(renderer, temp); + if (!texture) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); + } + } + if (temp) { + SDL_FreeSurface(temp); + } + return texture; +} + SDL_bool WatchGameController(SDL_GameController * gamecontroller) { + /* This is indexed by SDL_GameControllerButton. */ + static const struct { int x; int y; } button_positions[] = { + {387, 167}, /* A */ + {431, 132}, /* B */ + {342, 132}, /* X */ + {389, 101}, /* Y */ + {174, 132}, /* BACK */ + {233, 132}, /* GUIDE */ + {289, 132}, /* START */ + {75, 154}, /* LEFTSTICK */ + {305, 230}, /* RIGHTSTICK */ + {77, 40}, /* LEFTSHOULDER */ + {396, 36}, /* RIGHTSHOULDER */ + {154, 188}, /* DPAD_UP */ + {154, 249}, /* DPAD_DOWN */ + {116, 217}, /* DPAD_LEFT */ + {186, 217}, /* DPAD_RIGHT */ + }; + + /* This is indexed by SDL_GameControllerAxis. */ + static const struct { int x; int y; double angle; } axis_positions[] = { + {75, 154, 0.0}, /* LEFTX */ + {75, 154, 90.0}, /* LEFTY */ + {305, 230, 0.0}, /* RIGHTX */ + {305, 230, 90.0}, /* RIGHTY */ + {91, 0, 90.0}, /* TRIGGERLEFT */ + {375, 0, 90.0}, /* TRIGGERRIGHT */ + }; + const char *name = SDL_GameControllerName(gamecontroller); const char *basetitle = "Game Controller Test: "; const size_t titlelen = SDL_strlen(basetitle) + SDL_strlen(name) + 1; char *title = (char *)SDL_malloc(titlelen); + SDL_Texture *background, *button, *axis; SDL_Window *window = NULL; SDL_Renderer *screen = NULL; SDL_bool retval = SDL_FALSE; @@ -101,7 +149,7 @@ WatchGameController(SDL_GameController * gamecontroller) SDL_snprintf(title, titlelen, "%s%s", basetitle, name); } - /* Create a window to display controller axis position */ + /* Create a window to display controller state */ window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT, 0); @@ -122,34 +170,36 @@ WatchGameController(SDL_GameController * gamecontroller) SDL_RenderPresent(screen); SDL_RaiseWindow(window); + /* scale for platforms that don't give you the window size you asked for. */ + SDL_RenderSetLogicalSize(screen, SCREEN_WIDTH, SCREEN_HEIGHT); + + background = LoadTexture(screen, "controllermap.bmp", SDL_FALSE); + button = LoadTexture(screen, "button.bmp", SDL_TRUE); + axis = LoadTexture(screen, "axis.bmp", SDL_TRUE); + + if (!background || !button || !axis) { + SDL_DestroyRenderer(screen); + SDL_DestroyWindow(window); + return SDL_FALSE; + } + SDL_SetTextureColorMod(button, 10, 255, 21); + SDL_SetTextureColorMod(axis, 10, 255, 21); + + /* !!! FIXME: */ + /*SDL_RenderSetLogicalSize(screen, background->w, background->h);*/ + /* Print info about the controller we are watching */ SDL_Log("Watching controller %s\n", name ? name : "Unknown Controller"); /* Loop, getting controller events! */ while (!done) { /* blank screen, set up for drawing this frame. */ - SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0x00, SDL_ALPHA_OPAQUE); + SDL_SetRenderDrawColor(screen, 0xFF, 0xFF, 0xFF, SDL_ALPHA_OPAQUE); SDL_RenderClear(screen); + SDL_RenderCopy(screen, background, NULL, NULL); while (SDL_PollEvent(&event)) { switch (event.type) { - case SDL_CONTROLLERAXISMOTION: - SDL_Log("Controller %d axis %d ('%s') value: %d\n", - event.caxis.which, - event.caxis.axis, - ControllerAxisName((SDL_GameControllerAxis)event.caxis.axis), - event.caxis.value); - break; - case SDL_CONTROLLERBUTTONDOWN: - SDL_Log("Controller %d button %d ('%s') down\n", - event.cbutton.which, event.cbutton.button, - ControllerButtonName((SDL_GameControllerButton)event.cbutton.button)); - break; - case SDL_CONTROLLERBUTTONUP: - SDL_Log("Controller %d button %d ('%s') up\n", - event.cbutton.which, event.cbutton.button, - ControllerButtonName((SDL_GameControllerButton)event.cbutton.button)); - break; case SDL_KEYDOWN: if (event.key.keysym.sym != SDLK_ESCAPE) { break; @@ -162,40 +212,29 @@ WatchGameController(SDL_GameController * gamecontroller) break; } } + /* Update visual controller state */ - SDL_SetRenderDrawColor(screen, 0x00, 0xFF, 0x00, SDL_ALPHA_OPAQUE); - for (i = 0; i (SCREEN_WIDTH - 16)) { - x = SCREEN_WIDTH - 16; + for (i = 0; i < SDL_CONTROLLER_AXIS_MAX; ++i) { + const Sint16 deadzone = 8000; /* !!! FIXME: real deadzone */ + const Sint16 value = SDL_GameControllerGetAxis(gamecontroller, (SDL_GameControllerAxis)(i)); + if (value < -deadzone) { + const SDL_Rect dst = { axis_positions[i].x, axis_positions[i].y, 50, 50 }; + const double angle = axis_positions[i].angle; + SDL_RenderCopyEx(screen, axis, NULL, &dst, angle, NULL, 0); + } else if (value > deadzone) { + const SDL_Rect dst = { axis_positions[i].x, axis_positions[i].y, 50, 50 }; + const double angle = axis_positions[i].angle + 180.0; + SDL_RenderCopyEx(screen, axis, NULL, &dst, angle, NULL, 0); } - y = (((int) SDL_GameControllerGetAxis(gamecontroller, (SDL_GameControllerAxis)(i * 2 + 1))) + 32768); - y *= SCREEN_HEIGHT; - y /= 65535; - if (y < 0) { - y = 0; - } else if (y > (SCREEN_HEIGHT - 16)) { - y = SCREEN_HEIGHT - 16; - } - - DrawRect(screen, x, y, 16, 16); } - SDL_SetRenderDrawColor(screen, 0x00, 0x00, 0xFF, SDL_ALPHA_OPAQUE); - SDL_RenderPresent(screen); if (!SDL_GameControllerGetAttached(gamecontroller)) { diff --git a/jni/SDL2-2.0.1/test/testgesture.c b/jni/SDL2-2.0.3/test/testgesture.c similarity index 99% rename from jni/SDL2-2.0.1/test/testgesture.c rename to jni/SDL2-2.0.3/test/testgesture.c index 89008fb3..f2cf694f 100644 --- a/jni/SDL2-2.0.1/test/testgesture.c +++ b/jni/SDL2-2.0.3/test/testgesture.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testgl2.c b/jni/SDL2-2.0.3/test/testgl2.c similarity index 99% rename from jni/SDL2-2.0.1/test/testgl2.c rename to jni/SDL2-2.0.3/test/testgl2.c index f51efe90..85148515 100644 --- a/jni/SDL2-2.0.1/test/testgl2.c +++ b/jni/SDL2-2.0.3/test/testgl2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testgles.c b/jni/SDL2-2.0.3/test/testgles.c similarity index 99% rename from jni/SDL2-2.0.1/test/testgles.c rename to jni/SDL2-2.0.3/test/testgles.c index 314ec7cd..588cbfb3 100644 --- a/jni/SDL2-2.0.1/test/testgles.c +++ b/jni/SDL2-2.0.3/test/testgles.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testgles2.c b/jni/SDL2-2.0.3/test/testgles2.c similarity index 97% rename from jni/SDL2-2.0.1/test/testgles2.c rename to jni/SDL2-2.0.3/test/testgles2.c index 32b19df4..ef9f38d6 100644 --- a/jni/SDL2-2.0.1/test/testgles2.c +++ b/jni/SDL2-2.0.3/test/testgles2.c @@ -1,5 +1,5 @@ /* - Copyright (r) 1997-2011 Sam Lantinga + Copyright (r) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -629,7 +629,7 @@ main(int argc, char *argv[]) while (!done) { /* Check for events */ ++frames; - while (SDL_PollEvent(&event)) { + while (SDL_PollEvent(&event) && !done) { switch (event.type) { case SDL_WINDOWEVENT: switch (event.window.event) { @@ -654,16 +654,18 @@ main(int argc, char *argv[]) } SDLTest_CommonEvent(state, &event, &done); } - for (i = 0; i < state->num_windows; ++i) { - status = SDL_GL_MakeCurrent(state->windows[i], context[i]); - if (status) { - SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); + if (!done) { + for (i = 0; i < state->num_windows; ++i) { + status = SDL_GL_MakeCurrent(state->windows[i], context[i]); + if (status) { + SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); - /* Continue for next window */ - continue; - } - Render(state->window_w, state->window_h, &datas[i]); - SDL_GL_SwapWindow(state->windows[i]); + /* Continue for next window */ + continue; + } + Render(state->window_w, state->window_h, &datas[i]); + SDL_GL_SwapWindow(state->windows[i]); + } } } diff --git a/jni/SDL2-2.0.1/test/testhaptic.c b/jni/SDL2-2.0.3/test/testhaptic.c similarity index 99% rename from jni/SDL2-2.0.1/test/testhaptic.c rename to jni/SDL2-2.0.3/test/testhaptic.c index 1e9dd3bd..5e335674 100644 --- a/jni/SDL2-2.0.1/test/testhaptic.c +++ b/jni/SDL2-2.0.3/test/testhaptic.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.3/test/testhotplug.c b/jni/SDL2-2.0.3/test/testhotplug.c new file mode 100644 index 00000000..328a8eef --- /dev/null +++ b/jni/SDL2-2.0.3/test/testhotplug.c @@ -0,0 +1,159 @@ +/* + Copyright (C) 1997-2014 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely. +*/ + +/* Simple program to test the SDL joystick hotplugging */ + +#include +#include +#include + +#include "SDL.h" +#include "SDL_haptic.h" + +#if !defined SDL_JOYSTICK_DISABLED && !defined SDL_HAPTIC_DISABLED + +int +main(int argc, char *argv[]) +{ + SDL_Joystick *joystick = NULL; + SDL_Haptic *haptic = NULL; + SDL_JoystickID instance = -1; + SDL_bool keepGoing = SDL_TRUE; + int i; + SDL_bool enable_haptic = SDL_TRUE; + Uint32 init_subsystems = SDL_INIT_VIDEO | SDL_INIT_JOYSTICK; + + for (i = 1; i < argc; ++i) { + if (SDL_strcasecmp(argv[i], "--nohaptic") == 0) { + enable_haptic = SDL_FALSE; + } + } + + if(enable_haptic) { + init_subsystems |= SDL_INIT_HAPTIC; + } + + /* Enable standard application logging */ + SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + + SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1"); + + /* Initialize SDL (Note: video is required to start event loop) */ + if (SDL_Init(init_subsystems) < 0) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); + exit(1); + } + + //SDL_CreateWindow("Dummy", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 128, 128, 0); + + SDL_Log("There are %d joysticks at startup\n", SDL_NumJoysticks()); + if (enable_haptic) + SDL_Log("There are %d haptic devices at startup\n", SDL_NumHaptics()); + + while(keepGoing) + { + SDL_Event event; + while(SDL_PollEvent(&event)) + { + switch(event.type) + { + case SDL_QUIT: + keepGoing = SDL_FALSE; + break; + case SDL_JOYDEVICEADDED: + if (joystick != NULL) + { + SDL_Log("Only one joystick supported by this test\n"); + } + else + { + joystick = SDL_JoystickOpen(event.jdevice.which); + instance = SDL_JoystickInstanceID(joystick); + SDL_Log("Joy Added : %d : %s\n", event.jdevice.which, SDL_JoystickName(joystick)); + if (enable_haptic) + { + if (SDL_JoystickIsHaptic(joystick)) + { + haptic = SDL_HapticOpenFromJoystick(joystick); + if (haptic) + { + SDL_Log("Joy Haptic Opened\n"); + if (SDL_HapticRumbleInit( haptic ) != 0) + { + SDL_Log("Could not init Rumble!: %s\n", SDL_GetError()); + SDL_HapticClose(haptic); + haptic = NULL; + } + } else { + SDL_Log("Joy haptic open FAILED!: %s\n", SDL_GetError()); + } + } + else + { + SDL_Log("No haptic found\n"); + } + } + } + break; + case SDL_JOYDEVICEREMOVED: + if (instance == event.jdevice.which) + { + SDL_Log("Joy Removed: %d\n", event.jdevice.which); + instance = -1; + if(enable_haptic && haptic) + { + SDL_HapticClose(haptic); + haptic = NULL; + } + SDL_JoystickClose(joystick); + joystick = NULL; + } else { + SDL_Log("Unknown joystick diconnected\n"); + } + break; + case SDL_JOYAXISMOTION: +// SDL_Log("Axis Move: %d\n", event.jaxis.axis); + if (enable_haptic) + SDL_HapticRumblePlay(haptic, 0.25, 250); + break; + case SDL_JOYBUTTONDOWN: + SDL_Log("Button Press: %d\n", event.jbutton.button); + if(enable_haptic && haptic) + { + SDL_HapticRumblePlay(haptic, 0.25, 250); + } + if (event.jbutton.button == 0) { + SDL_Log("Exiting due to button press of button 0\n"); + keepGoing = SDL_FALSE; + } + break; + case SDL_JOYBUTTONUP: + SDL_Log("Button Release: %d\n", event.jbutton.button); + break; + } + } + } + + SDL_Quit(); + + return 0; +} +#else + +int +main(int argc, char *argv[]) +{ + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL compiled without Joystick and haptic support.\n"); + return 1; +} + +#endif diff --git a/jni/SDL2-2.0.1/test/testiconv.c b/jni/SDL2-2.0.3/test/testiconv.c similarity index 97% rename from jni/SDL2-2.0.1/test/testiconv.c rename to jni/SDL2-2.0.3/test/testiconv.c index 3165b342..1ab4c036 100644 --- a/jni/SDL2-2.0.1/test/testiconv.c +++ b/jni/SDL2-2.0.3/test/testiconv.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testime.c b/jni/SDL2-2.0.3/test/testime.c similarity index 99% rename from jni/SDL2-2.0.1/test/testime.c rename to jni/SDL2-2.0.3/test/testime.c index 3d9789ad..6f7b6a54 100644 --- a/jni/SDL2-2.0.1/test/testime.c +++ b/jni/SDL2-2.0.3/test/testime.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testintersections.c b/jni/SDL2-2.0.3/test/testintersections.c similarity index 99% rename from jni/SDL2-2.0.1/test/testintersections.c rename to jni/SDL2-2.0.3/test/testintersections.c index b4deeecd..7ea3b555 100644 --- a/jni/SDL2-2.0.1/test/testintersections.c +++ b/jni/SDL2-2.0.3/test/testintersections.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testjoystick.c b/jni/SDL2-2.0.3/test/testjoystick.c similarity index 99% rename from jni/SDL2-2.0.1/test/testjoystick.c rename to jni/SDL2-2.0.3/test/testjoystick.c index 2984145d..3e90e98d 100644 --- a/jni/SDL2-2.0.1/test/testjoystick.c +++ b/jni/SDL2-2.0.3/test/testjoystick.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testkeys.c b/jni/SDL2-2.0.3/test/testkeys.c similarity index 94% rename from jni/SDL2-2.0.1/test/testkeys.c rename to jni/SDL2-2.0.3/test/testkeys.c index f4a35aba..97f52a44 100644 --- a/jni/SDL2-2.0.1/test/testkeys.c +++ b/jni/SDL2-2.0.3/test/testkeys.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testloadso.c b/jni/SDL2-2.0.3/test/testloadso.c similarity index 97% rename from jni/SDL2-2.0.1/test/testloadso.c rename to jni/SDL2-2.0.3/test/testloadso.c index 946aafd2..da7bab98 100644 --- a/jni/SDL2-2.0.1/test/testloadso.c +++ b/jni/SDL2-2.0.3/test/testloadso.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testlock.c b/jni/SDL2-2.0.3/test/testlock.c similarity index 98% rename from jni/SDL2-2.0.1/test/testlock.c rename to jni/SDL2-2.0.3/test/testlock.c index 0414fe31..9ca3ca19 100644 --- a/jni/SDL2-2.0.1/test/testlock.c +++ b/jni/SDL2-2.0.3/test/testlock.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testmessage.c b/jni/SDL2-2.0.3/test/testmessage.c similarity index 98% rename from jni/SDL2-2.0.1/test/testmessage.c rename to jni/SDL2-2.0.3/test/testmessage.c index 254bd9b3..005c4799 100644 --- a/jni/SDL2-2.0.1/test/testmessage.c +++ b/jni/SDL2-2.0.3/test/testmessage.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testmultiaudio.c b/jni/SDL2-2.0.3/test/testmultiaudio.c similarity index 98% rename from jni/SDL2-2.0.1/test/testmultiaudio.c rename to jni/SDL2-2.0.3/test/testmultiaudio.c index 48d628ae..f0f1ce1c 100644 --- a/jni/SDL2-2.0.1/test/testmultiaudio.c +++ b/jni/SDL2-2.0.3/test/testmultiaudio.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testnative.c b/jni/SDL2-2.0.3/test/testnative.c similarity index 99% rename from jni/SDL2-2.0.1/test/testnative.c rename to jni/SDL2-2.0.3/test/testnative.c index 0ac99b2a..c010445f 100644 --- a/jni/SDL2-2.0.1/test/testnative.c +++ b/jni/SDL2-2.0.3/test/testnative.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testnative.h b/jni/SDL2-2.0.3/test/testnative.h similarity index 95% rename from jni/SDL2-2.0.1/test/testnative.h rename to jni/SDL2-2.0.3/test/testnative.h index 275c0d61..fa0bffc3 100644 --- a/jni/SDL2-2.0.1/test/testnative.h +++ b/jni/SDL2-2.0.3/test/testnative.h @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2011 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testnativecocoa.m b/jni/SDL2-2.0.3/test/testnativecocoa.m similarity index 100% rename from jni/SDL2-2.0.1/test/testnativecocoa.m rename to jni/SDL2-2.0.3/test/testnativecocoa.m diff --git a/jni/SDL2-2.0.1/test/testnativew32.c b/jni/SDL2-2.0.3/test/testnativew32.c similarity index 97% rename from jni/SDL2-2.0.1/test/testnativew32.c rename to jni/SDL2-2.0.3/test/testnativew32.c index 2cb57dde..f43c2209 100644 --- a/jni/SDL2-2.0.1/test/testnativew32.c +++ b/jni/SDL2-2.0.3/test/testnativew32.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testnativex11.c b/jni/SDL2-2.0.3/test/testnativex11.c similarity index 94% rename from jni/SDL2-2.0.1/test/testnativex11.c rename to jni/SDL2-2.0.3/test/testnativex11.c index 9f4150c4..b60c999e 100644 --- a/jni/SDL2-2.0.1/test/testnativex11.c +++ b/jni/SDL2-2.0.3/test/testnativex11.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testoverlay2.c b/jni/SDL2-2.0.3/test/testoverlay2.c similarity index 99% rename from jni/SDL2-2.0.1/test/testoverlay2.c rename to jni/SDL2-2.0.3/test/testoverlay2.c index 4561f984..441e1f33 100644 --- a/jni/SDL2-2.0.1/test/testoverlay2.c +++ b/jni/SDL2-2.0.3/test/testoverlay2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testplatform.c b/jni/SDL2-2.0.3/test/testplatform.c similarity index 97% rename from jni/SDL2-2.0.1/test/testplatform.c rename to jni/SDL2-2.0.3/test/testplatform.c index a8ed39dd..ae367ff4 100644 --- a/jni/SDL2-2.0.1/test/testplatform.c +++ b/jni/SDL2-2.0.3/test/testplatform.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -153,6 +153,7 @@ TestCPUInfo(SDL_bool verbose) SDL_Log("SSE3 %s\n", SDL_HasSSE3()? "detected" : "not detected"); SDL_Log("SSE4.1 %s\n", SDL_HasSSE41()? "detected" : "not detected"); SDL_Log("SSE4.2 %s\n", SDL_HasSSE42()? "detected" : "not detected"); + SDL_Log("AVX %s\n", SDL_HasAVX()? "detected" : "not detected"); SDL_Log("System RAM %d MB\n", SDL_GetSystemRAM()); } return (0); diff --git a/jni/SDL2-2.0.1/test/testpower.c b/jni/SDL2-2.0.3/test/testpower.c similarity index 96% rename from jni/SDL2-2.0.1/test/testpower.c rename to jni/SDL2-2.0.3/test/testpower.c index 1b321439..058a53fc 100644 --- a/jni/SDL2-2.0.1/test/testpower.c +++ b/jni/SDL2-2.0.3/test/testpower.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testrelative.c b/jni/SDL2-2.0.3/test/testrelative.c similarity index 97% rename from jni/SDL2-2.0.1/test/testrelative.c rename to jni/SDL2-2.0.3/test/testrelative.c index 9e8e1e2d..955a4304 100644 --- a/jni/SDL2-2.0.1/test/testrelative.c +++ b/jni/SDL2-2.0.3/test/testrelative.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testrendercopyex.c b/jni/SDL2-2.0.3/test/testrendercopyex.c similarity index 99% rename from jni/SDL2-2.0.1/test/testrendercopyex.c rename to jni/SDL2-2.0.3/test/testrendercopyex.c index 0c8ad7de..95a77a17 100644 --- a/jni/SDL2-2.0.1/test/testrendercopyex.c +++ b/jni/SDL2-2.0.3/test/testrendercopyex.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testrendertarget.c b/jni/SDL2-2.0.3/test/testrendertarget.c similarity index 99% rename from jni/SDL2-2.0.1/test/testrendertarget.c rename to jni/SDL2-2.0.3/test/testrendertarget.c index ac4aa500..61a3a5fd 100644 --- a/jni/SDL2-2.0.1/test/testrendertarget.c +++ b/jni/SDL2-2.0.3/test/testrendertarget.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testresample.c b/jni/SDL2-2.0.3/test/testresample.c similarity index 98% rename from jni/SDL2-2.0.1/test/testresample.c rename to jni/SDL2-2.0.3/test/testresample.c index a6e859d3..78335052 100644 --- a/jni/SDL2-2.0.1/test/testresample.c +++ b/jni/SDL2-2.0.3/test/testresample.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testrumble.c b/jni/SDL2-2.0.3/test/testrumble.c similarity index 98% rename from jni/SDL2-2.0.1/test/testrumble.c rename to jni/SDL2-2.0.3/test/testrumble.c index ffcaae4a..74a7e98f 100644 --- a/jni/SDL2-2.0.1/test/testrumble.c +++ b/jni/SDL2-2.0.3/test/testrumble.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testscale.c b/jni/SDL2-2.0.3/test/testscale.c similarity index 98% rename from jni/SDL2-2.0.1/test/testscale.c rename to jni/SDL2-2.0.3/test/testscale.c index 8449f233..edd2c2fd 100644 --- a/jni/SDL2-2.0.1/test/testscale.c +++ b/jni/SDL2-2.0.3/test/testscale.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testsem.c b/jni/SDL2-2.0.3/test/testsem.c similarity index 98% rename from jni/SDL2-2.0.1/test/testsem.c rename to jni/SDL2-2.0.3/test/testsem.c index 6a2a59e6..ca71ec2e 100644 --- a/jni/SDL2-2.0.1/test/testsem.c +++ b/jni/SDL2-2.0.3/test/testsem.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testshader.c b/jni/SDL2-2.0.3/test/testshader.c similarity index 99% rename from jni/SDL2-2.0.1/test/testshader.c rename to jni/SDL2-2.0.3/test/testshader.c index ced43fd9..91ce3313 100644 --- a/jni/SDL2-2.0.1/test/testshader.c +++ b/jni/SDL2-2.0.3/test/testshader.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testshape.c b/jni/SDL2-2.0.3/test/testshape.c similarity index 99% rename from jni/SDL2-2.0.1/test/testshape.c rename to jni/SDL2-2.0.3/test/testshape.c index bffa540e..38465df7 100644 --- a/jni/SDL2-2.0.1/test/testshape.c +++ b/jni/SDL2-2.0.3/test/testshape.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testsprite2.c b/jni/SDL2-2.0.3/test/testsprite2.c similarity index 99% rename from jni/SDL2-2.0.1/test/testsprite2.c rename to jni/SDL2-2.0.3/test/testsprite2.c index e6108103..945280f9 100644 --- a/jni/SDL2-2.0.1/test/testsprite2.c +++ b/jni/SDL2-2.0.3/test/testsprite2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testspriteminimal.c b/jni/SDL2-2.0.3/test/testspriteminimal.c similarity index 98% rename from jni/SDL2-2.0.1/test/testspriteminimal.c rename to jni/SDL2-2.0.3/test/testspriteminimal.c index 157293f3..bdcb8b38 100644 --- a/jni/SDL2-2.0.1/test/testspriteminimal.c +++ b/jni/SDL2-2.0.3/test/testspriteminimal.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/teststreaming.c b/jni/SDL2-2.0.3/test/teststreaming.c similarity index 98% rename from jni/SDL2-2.0.1/test/teststreaming.c rename to jni/SDL2-2.0.3/test/teststreaming.c index 1d3f6825..3b6bbda9 100644 --- a/jni/SDL2-2.0.1/test/teststreaming.c +++ b/jni/SDL2-2.0.3/test/teststreaming.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testthread.c b/jni/SDL2-2.0.3/test/testthread.c similarity index 97% rename from jni/SDL2-2.0.1/test/testthread.c rename to jni/SDL2-2.0.3/test/testthread.c index ed9f1f18..d732320a 100644 --- a/jni/SDL2-2.0.1/test/testthread.c +++ b/jni/SDL2-2.0.3/test/testthread.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testtimer.c b/jni/SDL2-2.0.3/test/testtimer.c similarity index 98% rename from jni/SDL2-2.0.1/test/testtimer.c rename to jni/SDL2-2.0.3/test/testtimer.c index ea985e26..ef6bcb6a 100644 --- a/jni/SDL2-2.0.1/test/testtimer.c +++ b/jni/SDL2-2.0.3/test/testtimer.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testver.c b/jni/SDL2-2.0.3/test/testver.c similarity index 95% rename from jni/SDL2-2.0.1/test/testver.c rename to jni/SDL2-2.0.3/test/testver.c index cf3a5459..e59381f4 100644 --- a/jni/SDL2-2.0.1/test/testver.c +++ b/jni/SDL2-2.0.3/test/testver.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testviewport.c b/jni/SDL2-2.0.3/test/testviewport.c similarity index 98% rename from jni/SDL2-2.0.1/test/testviewport.c rename to jni/SDL2-2.0.3/test/testviewport.c index 022d9880..c9d32340 100644 --- a/jni/SDL2-2.0.1/test/testviewport.c +++ b/jni/SDL2-2.0.3/test/testviewport.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/testwm2.c b/jni/SDL2-2.0.3/test/testwm2.c similarity index 98% rename from jni/SDL2-2.0.1/test/testwm2.c rename to jni/SDL2-2.0.3/test/testwm2.c index 127a4d87..186e0827 100644 --- a/jni/SDL2-2.0.1/test/testwm2.c +++ b/jni/SDL2-2.0.3/test/testwm2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/torturethread.c b/jni/SDL2-2.0.3/test/torturethread.c similarity index 97% rename from jni/SDL2-2.0.1/test/torturethread.c rename to jni/SDL2-2.0.3/test/torturethread.c index b22ee2af..bc4e1132 100644 --- a/jni/SDL2-2.0.1/test/torturethread.c +++ b/jni/SDL2-2.0.3/test/torturethread.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2013 Sam Lantinga + Copyright (C) 1997-2014 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/jni/SDL2-2.0.1/test/utf8.txt b/jni/SDL2-2.0.3/test/utf8.txt similarity index 100% rename from jni/SDL2-2.0.1/test/utf8.txt rename to jni/SDL2-2.0.3/test/utf8.txt diff --git a/jni/love/Android.mk b/jni/love/Android.mk index 9f06ad58..ef926774 100644 --- a/jni/love/Android.mk +++ b/jni/love/Android.mk @@ -15,7 +15,7 @@ LOCAL_C_INCLUDES := \ ${LOCAL_PATH}/src/modules \ ${LOCAL_PATH}/src/libraries/ \ ${LOCAL_PATH}/src/libraries/enet/libenet/include \ - ${LOCAL_PATH}/../SDL2-2.0.1/include \ + ${LOCAL_PATH}/../SDL2-2.0.3/include \ ${LOCAL_PATH}/../devil-1.7.8/include \ ${LOCAL_PATH}/../devil-1.7.8/src-IL/include \ ${LOCAL_PATH}/../jasper-1.900.1/src/libjasper/include \ @@ -104,7 +104,7 @@ LOCAL_STATIC_LIBRARIES := libluajit SDL2_static # $(info liblove: include dirs $(LOCAL_C_INCLUDES)) # $(info liblove: src files $(LOCAL_SRC_FILES)) -SDL_PATH := ../SDL2-2.0.1 +SDL_PATH := ../SDL2-2.0.3 LOCAL_SRC_FILES += $(SDL_PATH)/src/main/android/SDL_android_main.c LOCAL_LDLIBS := -lz -lGLESv1_CM -lGLESv2 -ldl -landroid diff --git a/jni/love/src/modules/filesystem/physfs/dire b/jni/love/src/modules/filesystem/physfs/dire new file mode 100644 index 00000000..ce2ac50e --- /dev/null +++ b/jni/love/src/modules/filesystem/physfs/dire @@ -0,0 +1,342 @@ +/** + * Copyright (c) 2006-2014 LOVE Development Team + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + **/ + +#include "File.h" + +// STD +#include + +// LOVE +#include "Filesystem.h" +#include "filesystem/FileData.h" + +namespace love +{ +namespace filesystem +{ +namespace physfs +{ + +extern bool hack_setupWriteDirectory(); + +File::File(const std::string &filename) + : filename(filename) + , file(0) + , mode(CLOSED) + , bufferMode(BUFFER_NONE) + , bufferSize(0) +{ +} + +File::~File() +{ + if (mode != CLOSED) + close(); +} + +bool File::open(Mode mode) +{ + if (mode == CLOSED) + return true; + + // File must exist if read mode. + if ((mode == READ) && !PHYSFS_exists(filename.c_str())) + throw love::Exception("Could not open file %s. Does not exist.", filename.c_str()); + + // Check whether the write directory is set. + if ((mode == APPEND || mode == WRITE) && (PHYSFS_getWriteDir() == 0) && !hack_setupWriteDirectory()) + throw love::Exception("Could not set write directory."); + + // File already open? + if (file != 0) + return false; + + this->mode = mode; + + switch (mode) + { + case READ: + file = PHYSFS_openRead(filename.c_str()); + break; + case APPEND: + file = PHYSFS_openAppend(filename.c_str()); + break; + case WRITE: + file = PHYSFS_openWrite(filename.c_str()); + break; + default: + break; + } + + if (file != 0 && !setBuffer(bufferMode, bufferSize)) + { + // Revert to buffer defaults if we don't successfully set the buffer. + bufferMode = BUFFER_NONE; + bufferSize = 0; + } + + return (file != 0); +} + +bool File::close() +{ + if (!PHYSFS_close(file)) + return false; + mode = CLOSED; + file = 0; + return true; +} + +bool File::isOpen() const +{ + return mode != CLOSED && file != 0; +} + +int64 File::getSize() +{ + // If the file is closed, open it to + // check the size. + if (file == 0) + { + open(READ); + int64 size = (int64)PHYSFS_fileLength(file); + close(); + return size; + } + + return (int64)PHYSFS_fileLength(file); +} + + +FileData *File::read(int64 size) +{ + bool isOpen = (file != 0); + + if (!isOpen && !open(READ)) + throw love::Exception("Could not read file %s.", filename.c_str()); + + int64 max = getSize(); + int64 cur = tell(); + size = (size == ALL) ? max : size; + + if (size < 0) + throw love::Exception("Invalid read size."); + + // Clamping because the file offset may be in a weird position. + if (cur < 0) + cur = 0; + else if (cur > max) + cur = max; + + if (cur + size > max) + size = max - cur; + + FileData *fileData = new FileData(size, getFilename()); + int64 bytesRead = read(fileData->getData(), size); + + if (bytesRead < 0 || (bytesRead == 0 && bytesRead != size)) + { + delete fileData; + throw love::Exception("Could not read from file."); + } + if (bytesRead < size) + { + FileData *tmpFileData = new FileData(bytesRead, getFilename()); + memcpy(tmpFileData->getData(), fileData->getData(), (size_t) bytesRead); + delete fileData; + fileData = tmpFileData; + } + + if (!isOpen) + close(); + + return fileData; +} + +int64 File::read(void *dst, int64 size) +{ + if (!file || mode != READ) + throw love::Exception("File is not opened for reading."); + + int64 max = (int64)PHYSFS_fileLength(file); + size = (size == ALL) ? max : size; + size = (size > max) ? max : size; + // Sadly, we'll have to clamp to 32 bits here + size = (size > LOVE_UINT32_MAX) ? LOVE_UINT32_MAX : size; + + if (size < 0) + throw love::Exception("Invalid read size."); + + int64 read = (int64)PHYSFS_read(file, dst, 1, (PHYSFS_uint32) size); + + return read; +} + +bool File::write(const void *data, int64 size) +{ + if (!file || (mode != WRITE && mode != APPEND)) + throw love::Exception("File is not opened for writing."); + + // Another clamp, for the time being. + size = (size > LOVE_UINT32_MAX) ? LOVE_UINT32_MAX : size; + + if (size < 0) + throw love::Exception("Invalid write size."); + + // Try to write. + int64 written = static_cast(PHYSFS_write(file, data, 1, (PHYSFS_uint32) size)); + + // Check that correct amount of data was written. + if (written != size) + return false; + + // Manually flush the buffer in BUFFER_LINE mode if we find a newline. + if (bufferMode == BUFFER_LINE && bufferSize > size) + { + if (memchr(data, '\n', (size_t) size) != NULL) + flush(); + } + + return true; +} + +bool File::write(const Data *data, int64 size) +{ + return write(data->getData(), (size == ALL) ? data->getSize() : size); +} + +bool File::flush() +{ + if (!file || (mode != WRITE && mode != APPEND)) + throw love::Exception("File is not opened for writing."); + + return PHYSFS_flush(file) != 0; +} + +#ifdef LOVE_WINDOWS +// MSVC doesn't like the 'this' keyword +// well, we'll use 'that'. +// It zigs, we zag. +inline bool test_eof(File *that, PHYSFS_File *) +{ + int64 pos = that->tell(); + int64 size = that->getSize(); + return pos == -1 || size == -1 || pos >= size; +} +#else +inline bool test_eof(File *, PHYSFS_File *file) +{ + return PHYSFS_eof(file); +} +#endif + +bool File::eof() +{ + if (file == 0 || test_eof(this, file)) + return true; + return false; +} + +int64 File::tell() +{ + if (file == 0) + return -1; + + return (int64) PHYSFS_tell(file); +} + +bool File::seek(uint64 pos) +{ + if (file == 0) + return false; + + if (!PHYSFS_seek(file, (PHYSFS_uint64) pos)) + return false; + return true; +} + +bool File::setBuffer(BufferMode bufmode, int64 size) +{ + // No negativity allowed! + if (size < 0) + return false; + + // If the file isn't open, we'll make sure the buffer values are set in + // File::open. + if (file == 0 || mode == CLOSED) + { + bufferMode = bufmode; + bufferSize = size; + return true; + } + + int ret = 1; + + switch (bufmode) + { + case BUFFER_NONE: + default: + ret = PHYSFS_setBuffer(file, 0); + size = 0; + break; + case BUFFER_LINE: + case BUFFER_FULL: + ret = PHYSFS_setBuffer(file, size); + break; + } + + if (ret == 0) + return false; + + bufferMode = bufmode; + bufferSize = size; + + return true; +} + +File::BufferMode File::getBuffer(int64 &size) const +{ + size = bufferSize; + return bufferMode; +} + +std::string File::getFilename() const +{ + return filename; +} + +std::string File::getExtension() const +{ + std::string::size_type idx = filename.rfind('.'); + + if (idx != std::string::npos) + return filename.substr(idx+1); + else + return std::string(); +} + +filesystem::File::Mode File::getMode() const +{ + return mode; +} + +} // physfs +} // filesystem +} // love