From 2841c0e16554ee03aa209ae6fc6a89a21046852d Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 19 Dec 2015 07:05:45 +0000 Subject: [PATCH] better alternative OSes handling + tiny C++ fix --- lib/irrlicht/include/IrrCompileConfig.h | 2 ++ lib/irrlicht/source/Irrlicht/CAttributeImpl.h | 2 +- lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp | 8 ++++---- lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp | 2 +- lib/irrlicht/source/Irrlicht/COSOperator.cpp | 1 + lib/irrlicht/source/Irrlicht/os.cpp | 6 +++++- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/irrlicht/include/IrrCompileConfig.h b/lib/irrlicht/include/IrrCompileConfig.h index 10a1bc279..380ed16a0 100644 --- a/lib/irrlicht/include/IrrCompileConfig.h +++ b/lib/irrlicht/include/IrrCompileConfig.h @@ -99,8 +99,10 @@ #if !defined(_IRR_WINDOWS_API_) && !defined(_IRR_OSX_PLATFORM_) #ifndef _IRR_SOLARIS_PLATFORM_ +#if !defined(__linux__) && !defined(__FreeBSD__) #define _IRR_LINUX_PLATFORM_ #endif +#endif #define _IRR_POSIX_API_ #define _IRR_COMPILE_WITH_X11_DEVICE_ #endif diff --git a/lib/irrlicht/source/Irrlicht/CAttributeImpl.h b/lib/irrlicht/source/Irrlicht/CAttributeImpl.h index 2fbf50ebd..b7c9a455e 100644 --- a/lib/irrlicht/source/Irrlicht/CAttributeImpl.h +++ b/lib/irrlicht/source/Irrlicht/CAttributeImpl.h @@ -2028,7 +2028,7 @@ public: { u32 tmp; sscanf(text, "0x%x", &tmp); - Value = (void *) tmp; + Value = reinterpret_cast(tmp); } virtual E_ATTRIBUTE_TYPE getType() const diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp index 95237d9f0..926b81a70 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.cpp @@ -39,7 +39,7 @@ extern bool GLContextDebugBit; #ifdef __FreeBSD__ #include -#else +#elif defined(__linux__) // linux/joystick.h includes linux/input.h, which #defines values for various KEY_FOO keys. // These override the irr::KEY_FOO equivalents, which stops key handling from working. @@ -2185,7 +2185,7 @@ bool CIrrDeviceLinux::activateJoysticks(core::array & joystickInf #ifdef __FreeBSD__ info.axes=2; info.buttons=2; -#else +#elif defined(__linux__) ioctl( info.fd, JSIOCGAXES, &(info.axes) ); ioctl( info.fd, JSIOCGBUTTONS, &(info.buttons) ); fcntl( info.fd, F_SETFL, O_NONBLOCK ); @@ -2207,7 +2207,7 @@ bool CIrrDeviceLinux::activateJoysticks(core::array & joystickInf returnInfo.Axes = info.axes; returnInfo.Buttons = info.buttons; -#ifndef __FreeBSD__ +#if !defined(__FreeBSD__) && !defined(__OpenBSD__) char name[80]; ioctl( info.fd, JSIOCGNAME(80), name); returnInfo.Name = name; @@ -2252,7 +2252,7 @@ void CIrrDeviceLinux::pollJoysticks() info.persistentData.JoystickEvent.Axis[0] = js.x; /* X axis */ info.persistentData.JoystickEvent.Axis[1] = js.y; /* Y axis */ } -#else +#elif defined(__linux__) struct js_event event; while (sizeof(event) == read(info.fd, &event, sizeof(event))) { diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp index a4c2b5cb5..57540bf7e 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp @@ -478,7 +478,7 @@ bool CIrrDeviceSDL::run() joyevent.JoystickEvent.ButtonStates |= (SDL_JoystickGetButton(joystick, j)<(SEvent::SJoystickEvent::NUMBER_OF_AXES)); joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_X]=0; joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Y]=0; joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Z]=0; diff --git a/lib/irrlicht/source/Irrlicht/COSOperator.cpp b/lib/irrlicht/source/Irrlicht/COSOperator.cpp index ea407fdc4..e2166156f 100644 --- a/lib/irrlicht/source/Irrlicht/COSOperator.cpp +++ b/lib/irrlicht/source/Irrlicht/COSOperator.cpp @@ -12,6 +12,7 @@ #include #include #if !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__CYGWIN__) +#include #include #include #endif diff --git a/lib/irrlicht/source/Irrlicht/os.cpp b/lib/irrlicht/source/Irrlicht/os.cpp index a801667fb..b847ffd5b 100644 --- a/lib/irrlicht/source/Irrlicht/os.cpp +++ b/lib/irrlicht/source/Irrlicht/os.cpp @@ -22,10 +22,14 @@ #include #define bswap_16(X) OSReadSwapInt16(&X,0) #define bswap_32(X) OSReadSwapInt32(&X,0) -#elif defined(__FreeBSD__) || defined(__OpenBSD__) +#elif defined(__FreeBSD__) #include #define bswap_16(X) bswap16(X) #define bswap_32(X) bswap32(X) +#elif defined(__OpenBSD__) + #include + #define bswap_16(X) swap16(X) + #define bswap_32(X) swap32(X) #elif !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__PPC__) && !defined(_IRR_WINDOWS_API_) #include #else