better alternative OSes handling + tiny C++ fix

This commit is contained in:
David Carlier 2015-12-19 07:05:45 +00:00
parent 94151dda60
commit 2841c0e165
6 changed files with 14 additions and 7 deletions

View File

@ -99,8 +99,10 @@
#if !defined(_IRR_WINDOWS_API_) && !defined(_IRR_OSX_PLATFORM_) #if !defined(_IRR_WINDOWS_API_) && !defined(_IRR_OSX_PLATFORM_)
#ifndef _IRR_SOLARIS_PLATFORM_ #ifndef _IRR_SOLARIS_PLATFORM_
#if !defined(__linux__) && !defined(__FreeBSD__)
#define _IRR_LINUX_PLATFORM_ #define _IRR_LINUX_PLATFORM_
#endif #endif
#endif
#define _IRR_POSIX_API_ #define _IRR_POSIX_API_
#define _IRR_COMPILE_WITH_X11_DEVICE_ #define _IRR_COMPILE_WITH_X11_DEVICE_
#endif #endif

View File

@ -2028,7 +2028,7 @@ public:
{ {
u32 tmp; u32 tmp;
sscanf(text, "0x%x", &tmp); sscanf(text, "0x%x", &tmp);
Value = (void *) tmp; Value = reinterpret_cast<void *>(tmp);
} }
virtual E_ATTRIBUTE_TYPE getType() const virtual E_ATTRIBUTE_TYPE getType() const

View File

@ -39,7 +39,7 @@ extern bool GLContextDebugBit;
#ifdef __FreeBSD__ #ifdef __FreeBSD__
#include <sys/joystick.h> #include <sys/joystick.h>
#else #elif defined(__linux__)
// linux/joystick.h includes linux/input.h, which #defines values for various KEY_FOO keys. // 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. // These override the irr::KEY_FOO equivalents, which stops key handling from working.
@ -2185,7 +2185,7 @@ bool CIrrDeviceLinux::activateJoysticks(core::array<SJoystickInfo> & joystickInf
#ifdef __FreeBSD__ #ifdef __FreeBSD__
info.axes=2; info.axes=2;
info.buttons=2; info.buttons=2;
#else #elif defined(__linux__)
ioctl( info.fd, JSIOCGAXES, &(info.axes) ); ioctl( info.fd, JSIOCGAXES, &(info.axes) );
ioctl( info.fd, JSIOCGBUTTONS, &(info.buttons) ); ioctl( info.fd, JSIOCGBUTTONS, &(info.buttons) );
fcntl( info.fd, F_SETFL, O_NONBLOCK ); fcntl( info.fd, F_SETFL, O_NONBLOCK );
@ -2207,7 +2207,7 @@ bool CIrrDeviceLinux::activateJoysticks(core::array<SJoystickInfo> & joystickInf
returnInfo.Axes = info.axes; returnInfo.Axes = info.axes;
returnInfo.Buttons = info.buttons; returnInfo.Buttons = info.buttons;
#ifndef __FreeBSD__ #if !defined(__FreeBSD__) && !defined(__OpenBSD__)
char name[80]; char name[80];
ioctl( info.fd, JSIOCGNAME(80), name); ioctl( info.fd, JSIOCGNAME(80), name);
returnInfo.Name = name; returnInfo.Name = name;
@ -2252,7 +2252,7 @@ void CIrrDeviceLinux::pollJoysticks()
info.persistentData.JoystickEvent.Axis[0] = js.x; /* X axis */ info.persistentData.JoystickEvent.Axis[0] = js.x; /* X axis */
info.persistentData.JoystickEvent.Axis[1] = js.y; /* Y axis */ info.persistentData.JoystickEvent.Axis[1] = js.y; /* Y axis */
} }
#else #elif defined(__linux__)
struct js_event event; struct js_event event;
while (sizeof(event) == read(info.fd, &event, sizeof(event))) while (sizeof(event) == read(info.fd, &event, sizeof(event)))
{ {

View File

@ -478,7 +478,7 @@ bool CIrrDeviceSDL::run()
joyevent.JoystickEvent.ButtonStates |= (SDL_JoystickGetButton(joystick, j)<<j); joyevent.JoystickEvent.ButtonStates |= (SDL_JoystickGetButton(joystick, j)<<j);
// query all axes, already in correct range // query all axes, already in correct range
const int numAxes = core::min_(SDL_JoystickNumAxes(joystick), SEvent::SJoystickEvent::NUMBER_OF_AXES); const int numAxes = core::min_(SDL_JoystickNumAxes(joystick), static_cast<int>(SEvent::SJoystickEvent::NUMBER_OF_AXES));
joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_X]=0; joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_X]=0;
joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Y]=0; joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Y]=0;
joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Z]=0; joyevent.JoystickEvent.Axis[SEvent::SJoystickEvent::AXIS_Z]=0;

View File

@ -12,6 +12,7 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#if !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__CYGWIN__) #if !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__CYGWIN__)
#include <sys/param.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
#endif #endif

View File

@ -22,10 +22,14 @@
#include <libkern/OSByteOrder.h> #include <libkern/OSByteOrder.h>
#define bswap_16(X) OSReadSwapInt16(&X,0) #define bswap_16(X) OSReadSwapInt16(&X,0)
#define bswap_32(X) OSReadSwapInt32(&X,0) #define bswap_32(X) OSReadSwapInt32(&X,0)
#elif defined(__FreeBSD__) || defined(__OpenBSD__) #elif defined(__FreeBSD__)
#include <sys/endian.h> #include <sys/endian.h>
#define bswap_16(X) bswap16(X) #define bswap_16(X) bswap16(X)
#define bswap_32(X) bswap32(X) #define bswap_32(X) bswap32(X)
#elif defined(__OpenBSD__)
#include <endian.h>
#define bswap_16(X) swap16(X)
#define bswap_32(X) swap32(X)
#elif !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__PPC__) && !defined(_IRR_WINDOWS_API_) #elif !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__PPC__) && !defined(_IRR_WINDOWS_API_)
#include <byteswap.h> #include <byteswap.h>
#else #else