Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 28, 2011, 7:15:14 AM (13 years ago)
Author:
rgrieder
Message:

Merged kicklib2 branch back to trunk (includes former branches ois_update, mac_osx and kicklib).

Notes for updating

Linux:
You don't need an extra package for CEGUILua and Tolua, it's already shipped with CEGUI.
However you do need to make sure that the OgreRenderer is installed too with CEGUI 0.7 (may be a separate package).
Also, Orxonox now recognises if you install the CgProgramManager (a separate package available on newer Ubuntu on Debian systems).

Windows:
Download the new dependency packages versioned 6.0 and use these. If you have problems with that or if you don't like the in game console problem mentioned below, you can download the new 4.3 version of the packages (only available for Visual Studio 2005/2008).

Key new features:

  • *Support for Mac OS X*
  • Visual Studio 2010 support
  • Bullet library update to 2.77
  • OIS library update to 1.3
  • Support for CEGUI 0.7 —> Support for Arch Linux and even SuSE
  • Improved install target
  • Compiles now with GCC 4.6
  • Ogre Cg Shader plugin activated for Linux if available
  • And of course lots of bug fixes

There are also some regressions:

  • No support for CEGUI 0.5, Ogre 1.4 and boost 1.35 - 1.39 any more
  • In game console is not working in main menu for CEGUI 0.7
  • Tolua (just the C lib, not the application) and CEGUILua libraries are no longer in our repository. —> You will need to get these as well when compiling Orxonox
  • And of course lots of new bugs we don't yet know about
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/external/ois/mac/MacHIDManager.cpp

    r5781 r8351  
    2020 
    2121 3. This notice may not be removed or altered from any source distribution.
    22 */
     22 */
    2323#include "mac/MacHIDManager.h"
     24#include "mac/MacJoyStick.h"
    2425#include "OISException.h"
    2526#include "OISObject.h"
     
    4243{
    4344        CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
    44 
     45       
    4546        if(temp && CFGetTypeID(temp) == CFArrayGetTypeID())
    4647                return (CFArrayRef)temp;
     
    5354{
    5455        CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
    55 
     56       
    5657        if(temp && CFGetTypeID(temp) == CFStringGetTypeID())
    5758                return (CFStringRef)temp;
     
    6465{
    6566        CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
    66 
     67       
    6768        if(temp && CFGetTypeID(temp) == CFNumberGetTypeID())
    6869                return (CFNumberRef)temp;
     
    8384{
    8485        CFTypeRef temp = CFArrayGetValueAtIndex(array, idx);
    85 
     86       
    8687        if(temp && CFGetTypeID(temp) == CFDictionaryGetTypeID())
    8788                return (CFDictionaryRef)temp;
     
    9394int getInt32(CFNumberRef ref)
    9495{
    95    int r = 0;
    96    if (r)
    97       CFNumberGetValue(ref, kCFNumberIntType, &r);
    98    return r;
     96        int r = 0;
     97        if (r)
     98                CFNumberGetValue(ref, kCFNumberIntType, &r);
     99        return r;
    99100}
    100101
     
    111112//------------------------------------------------------------------------------------------------------//
    112113void MacHIDManager::initialize()
     114{
     115        //Make the search more specific by adding usage flags
     116        int usage = kHIDUsage_GD_Joystick;
     117        int page = kHIDPage_GenericDesktop;
     118       
     119        io_iterator_t iterator = lookUpDevices(usage, page);
     120       
     121        if(iterator)
     122                iterateAndOpenDevices(iterator);
     123       
     124        //Doesn't support multiple usage flags, iterate twice
     125        usage = kHIDUsage_GD_GamePad;
     126        iterator = lookUpDevices(usage, page);
     127       
     128        if(iterator)
     129                iterateAndOpenDevices(iterator);
     130}
     131
     132//------------------------------------------------------------------------------------------------------//
     133io_iterator_t MacHIDManager::lookUpDevices(int usage, int page)
    113134{
    114135        CFMutableDictionaryRef deviceLookupMap = IOServiceMatching(kIOHIDDeviceKey);
    115136        if(!deviceLookupMap)
    116137                OIS_EXCEPT(E_General, "Could not setup HID device search parameters");
    117 
    118         //Make the search more specific by adding usage flags
    119         int usage = kHIDUsage_GD_GamePad | kHIDUsage_GD_Joystick,
    120             page  = kHIDPage_GenericDesktop;
    121 
    122         CFNumberRef usageRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage),
    123                                 pageRef  = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page);
    124 
     138       
     139        CFNumberRef usageRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage);
     140        CFNumberRef pageRef  = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page);
     141       
    125142        CFDictionarySetValue(deviceLookupMap, CFSTR(kIOHIDPrimaryUsageKey), usageRef);
    126143        CFDictionarySetValue(deviceLookupMap, CFSTR(kIOHIDPrimaryUsagePageKey), pageRef);
    127 
     144       
    128145        //IOServiceGetMatchingServices consumes the map so we do not have to release it ourself
    129146        io_iterator_t iterator = 0;
    130147        IOReturn result = IOServiceGetMatchingServices(kIOMasterPortDefault, deviceLookupMap, &iterator);
    131         if (result == kIOReturnSuccess && iterator)
    132         {
    133                 io_object_t hidDevice = 0;
    134                 while ((hidDevice = IOIteratorNext(iterator)) !=0)
     148       
     149        CFRelease(usageRef);
     150        CFRelease(pageRef);
     151       
     152        if(result == kIOReturnSuccess)
     153        {
     154                return iterator;
     155        }
     156        //TODO: Throw exception instead?
     157        else
     158        {
     159                return 0;
     160        }
     161}
     162
     163//------------------------------------------------------------------------------------------------------//
     164void MacHIDManager::iterateAndOpenDevices(io_iterator_t iterator)
     165{
     166        io_object_t hidDevice = 0;
     167        while ((hidDevice = IOIteratorNext(iterator)) !=0)
     168        {
     169                //Get the current registry items property map
     170                CFMutableDictionaryRef propertyMap = 0;
     171                if (IORegistryEntryCreateCFProperties(hidDevice, &propertyMap, kCFAllocatorDefault, kNilOptions) == KERN_SUCCESS && propertyMap)
    135172                {
    136                         //Get the current registry items property map
    137                         CFMutableDictionaryRef propertyMap = 0;
    138                         if (IORegistryEntryCreateCFProperties(hidDevice, &propertyMap, kCFAllocatorDefault, kNilOptions) == KERN_SUCCESS && propertyMap)
     173                        //Go through device to find all needed info
     174                        HidInfo* hid = enumerateDeviceProperties(propertyMap);
     175                       
     176                        if(hid)
    139177                        {
    140                                 //Go through device to find all needed info
    141                                 HidInfo* hid = enumerateDeviceProperties(propertyMap);
    142                                 if(hid)
    143                                         mDeviceList.push_back(hid);
    144                                        
    145178                                //todo - we need to hold an open interface so we do not have to enumerate again later
    146179                                //should be able to watch for device removals also
    147 
    148                                 /// Testing opening / closing interface
    149                                 //IOCFPlugInInterface **pluginInterface = NULL;
    150                                 //SInt32 score = 0;
    151                                 //if (IOCreatePlugInInterfaceForService(hidDevice, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &pluginInterface, &score) == kIOReturnSuccess)
    152                                 //{
    153                                 //      IOHIDDeviceInterface **interface;
    154                                 //      HRESULT pluginResult = (*pluginInterface)->QueryInterface(pluginInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void **)&(interface));
    155                                 //      if(pluginResult == S_OK)
    156                                 //              cout << "Successfully created plugin interface for device\n";
    157                                 //      else
    158                                 //              cout << "Not able to create plugin interface\n";
    159 
    160                                 //      IODestroyPlugInInterface(pluginInterface);
    161 
    162                                 //      if ((*interface)->open(interface, 0) == KERN_SUCCESS)
    163                                 //              cout << "Opened interface.\n";
    164                                 //      else
    165                                 //              cout << "Failed to open\n";
    166 
    167                                 //      (*interface)->close(interface);
    168                                 //}
    169                                 //
     180                               
     181                                // Testing opening / closing interface
     182                                IOCFPlugInInterface **pluginInterface = NULL;
     183                                SInt32 score = 0;
     184                                if (IOCreatePlugInInterfaceForService(hidDevice, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &pluginInterface, &score) == kIOReturnSuccess)
     185                                {
     186                                        IOHIDDeviceInterface **interface;
     187                                       
     188                                        HRESULT pluginResult = (*pluginInterface)->QueryInterface(pluginInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void **)&(interface));
     189                                       
     190                                        if(pluginResult != S_OK)
     191                                                OIS_EXCEPT(E_General, "Not able to create plugin interface");
     192                                       
     193                                        IODestroyPlugInInterface(pluginInterface);
     194                                       
     195                                        hid->interface = interface;
     196                                       
     197                                        //Check for duplicates - some devices have multiple usage
     198                                        if(std::find(mDeviceList.begin(), mDeviceList.end(), hid) == mDeviceList.end())
     199                                                mDeviceList.push_back(hid);
     200                                }
    170201                        }
    171202                }
    172 
    173                 IOObjectRelease(iterator);
    174         }
    175 
    176         CFRelease(usageRef);
    177         CFRelease(pageRef);
     203        }
     204       
     205        IOObjectRelease(iterator);
    178206}
    179207
     
    188216        if (str)
    189217                info->vendor = CFStringGetCStringPtr(str, CFStringGetSystemEncoding());
    190 
     218       
    191219        str = getDictionaryItemAsRef<CFStringRef>(propertyMap, kIOHIDProductKey);
    192220        if (str)
    193221                info->productKey = CFStringGetCStringPtr(str, CFStringGetSystemEncoding());
    194                
     222       
    195223        info->combinedKey = info->vendor + " " + info->productKey;
    196 
     224       
    197225        //Go through all items in this device (i.e. buttons, hats, sticks, axes, etc)
    198226        CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(propertyMap, kIOHIDElementKey);
     
    200228                for (int i = 0; i < CFArrayGetCount(array); i++)
    201229                        parseDeviceProperties(getArrayItemAsRef<CFDictionaryRef>(array, i));
    202 
     230       
    203231        return info;
    204232}
     
    209237        if(!properties)
    210238                return;
    211 
     239       
    212240        CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(properties, kIOHIDElementKey);
    213241        if (array)
     
    227255                                        switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsagePageKey)))
    228256                                        {
    229                                         case kHIDPage_GenericDesktop:
    230                                                 switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsageKey)))
     257                                                case kHIDPage_GenericDesktop:
     258                                                        switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsageKey)))
    231259                                                {
    232                                                 case kHIDUsage_GD_Pointer:
    233                                                         cout << "\tkHIDUsage_GD_Pointer\n";
    234                                                         parseDevicePropertiesGroup(element);
     260                                                        case kHIDUsage_GD_Pointer:
     261                                                                cout << "\tkHIDUsage_GD_Pointer\n";
     262                                                                parseDevicePropertiesGroup(element);
     263                                                                break;
     264                                                        case kHIDUsage_GD_X:
     265                                                        case kHIDUsage_GD_Y:
     266                                                        case kHIDUsage_GD_Z:
     267                                                        case kHIDUsage_GD_Rx:
     268                                                        case kHIDUsage_GD_Ry:
     269                                                        case kHIDUsage_GD_Rz:
     270                                                                cout << "\tAxis\n";
     271                                                                break;
     272                                                        case kHIDUsage_GD_Slider:
     273                                                        case kHIDUsage_GD_Dial:
     274                                                        case kHIDUsage_GD_Wheel:
     275                                                                cout << "\tUnsupported kHIDUsage_GD_Wheel\n";
     276                                                                break;
     277                                                        case kHIDUsage_GD_Hatswitch:
     278                                                                cout << "\tUnsupported - kHIDUsage_GD_Hatswitch\n";
     279                                                                break;
     280                                                }
    235281                                                        break;
    236                                                 case kHIDUsage_GD_X:
    237                                                 case kHIDUsage_GD_Y:
    238                                                 case kHIDUsage_GD_Z:
    239                                                 case kHIDUsage_GD_Rx:
    240                                                 case kHIDUsage_GD_Ry:
    241                                                 case kHIDUsage_GD_Rz:
    242                                                         cout << "\tAxis\n";
     282                                                case kHIDPage_Button:
     283                                                        cout << "\tkHIDPage_Button\n";
    243284                                                        break;
    244                                                 case kHIDUsage_GD_Slider:
    245                                                 case kHIDUsage_GD_Dial:
    246                                                 case kHIDUsage_GD_Wheel:
    247                                                         cout << "\tUnsupported kHIDUsage_GD_Wheel\n";
    248                                                         break;
    249                                                 case kHIDUsage_GD_Hatswitch:
    250                                                         cout << "\tUnsupported - kHIDUsage_GD_Hatswitch\n";
    251                                                         break;
    252                                                 }
    253                                                 break;
    254                                         case kHIDPage_Button:
    255                                                 cout << "\tkHIDPage_Button\n";
    256                                                 break;
    257285                                        }
    258286                                }
     
    267295        if(!properties)
    268296                return;
    269 
     297       
    270298        CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(properties, kIOHIDElementKey);
    271299        if(array)
     
    278306                                switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsagePageKey)))
    279307                                {
    280                                 case kHIDPage_GenericDesktop:
    281                                         switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsageKey)))
     308                                        case kHIDPage_GenericDesktop:
     309                                                switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsageKey)))
    282310                                        {
    283                                         case kHIDUsage_GD_X:
    284                                         case kHIDUsage_GD_Y:
    285                                         case kHIDUsage_GD_Z:
    286                                         case kHIDUsage_GD_Rx:
    287                                         case kHIDUsage_GD_Ry:
    288                                         case kHIDUsage_GD_Rz:
    289                                                 cout << "\t\tAxis\n";
     311                                                case kHIDUsage_GD_X:
     312                                                case kHIDUsage_GD_Y:
     313                                                case kHIDUsage_GD_Z:
     314                                                case kHIDUsage_GD_Rx:
     315                                                case kHIDUsage_GD_Ry:
     316                                                case kHIDUsage_GD_Rz:
     317                                                        cout << "\t\tAxis\n";
     318                                                        break;
     319                                                case kHIDUsage_GD_Slider:
     320                                                case kHIDUsage_GD_Dial:
     321                                                case kHIDUsage_GD_Wheel:
     322                                                        cout << "\tUnsupported - kHIDUsage_GD_Wheel\n";
     323                                                        break;
     324                                                case kHIDUsage_GD_Hatswitch:
     325                                                        cout << "\tUnsupported - kHIDUsage_GD_Hatswitch\n";
     326                                                        break;
     327                                        }
    290328                                                break;
    291                                         case kHIDUsage_GD_Slider:
    292                                         case kHIDUsage_GD_Dial:
    293                                         case kHIDUsage_GD_Wheel:
    294                                                 cout << "\tUnsupported - kHIDUsage_GD_Wheel\n";
     329                                        case kHIDPage_Button:
    295330                                                break;
    296                                         case kHIDUsage_GD_Hatswitch:
    297                                                 cout << "\tUnsupported - kHIDUsage_GD_Hatswitch\n";
    298                                                 break;
    299                                         }
    300                                         break;
    301                                 case kHIDPage_Button:
    302                                         break;
    303331                                }
    304332                        }
     
    317345                        ret.insert(std::make_pair((*it)->type, (*it)->combinedKey));
    318346        }
    319 
     347       
    320348        return ret;
    321349}
     
    326354        int ret = 0;
    327355        HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
    328 
     356       
    329357        for(; it != end; ++it)
    330358        {
     
    341369        int ret = 0;
    342370        HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
    343 
     371       
    344372        for(; it != end; ++it)
    345373        {
     
    347375                        ret++;
    348376        }
    349 
     377       
    350378        return ret;
    351379}
     
    355383{
    356384        HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
    357 
     385       
    358386        for(; it != end; ++it)
    359387        {
     
    367395//--------------------------------------------------------------------------------//
    368396Object* MacHIDManager::createObject(InputManager* creator, Type iType, bool bufferMode,
    369                                                                           const std::string & vendor)
     397                                                                        const std::string & vendor)
    370398{
    371399        Object *obj = 0;
    372 
     400       
    373401        HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
    374402        for(; it != end; ++it)
     
    376404                if((*it)->inUse == false && (*it)->type == iType && (vendor == "" || (*it)->combinedKey == vendor))
    377405                {
    378                         //create device
     406                        switch(iType)
     407                        {
     408                                case OISJoyStick:
     409                {
     410                                        int totalDevs = totalDevices(iType);
     411                                        int freeDevs = freeDevices(iType);
     412                                        int devID = totalDevs - freeDevs;
     413                                       
     414                                        obj = new MacJoyStick((*it)->combinedKey, bufferMode, *it, creator, devID);
     415                                        (*it)->inUse = true;
     416                                        return obj;
     417                }
     418                                case OISTablet:
     419                                        //Create MacTablet
     420                                        break;
     421                                default:
     422                                        break;
     423                        }
    379424                }
    380425        }
    381 
    382         if( obj == 0 )
    383                 OIS_EXCEPT(E_InputDeviceNonExistant, "No devices match requested type.");
    384 
     426       
    385427        return obj;
    386428}
Note: See TracChangeset for help on using the changeset viewer.