Commit b56ddb92 authored by hybrid's avatar hybrid

Merged revisions 2778:2832 from 1.6 branch. Add some Linux keycodes, make skin...

Merged revisions 2778:2832 from 1.6 branch. Add some Linux keycodes, make skin name arrays safer, disable dx8. Please note, the last merge was from wrong repository, now everything is up to date again.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2835 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 3d467cb4
...@@ -37,11 +37,14 @@ namespace gui ...@@ -37,11 +37,14 @@ namespace gui
EGST_BURNING_SKIN, EGST_BURNING_SKIN,
//! An unknown skin, not serializable at present //! An unknown skin, not serializable at present
EGST_UNKNOWN EGST_UNKNOWN,
//! this value is not used, it only specifies the number of skin types
EGST_COUNT
}; };
//! Names for gui element types //! Names for gui element types
const c8* const GUISkinTypeNames[] = const c8* const GUISkinTypeNames[EGST_COUNT+1] =
{ {
"windowsClassic", "windowsClassic",
"windowsMetallic", "windowsMetallic",
...@@ -102,7 +105,7 @@ namespace gui ...@@ -102,7 +105,7 @@ namespace gui
}; };
//! Names for default skin colors //! Names for default skin colors
const c8* const GUISkinColorNames[] = const c8* const GUISkinColorNames[EGDC_COUNT+1] =
{ {
"3DDarkShadow", "3DDarkShadow",
"3DShadow", "3DShadow",
...@@ -173,7 +176,7 @@ namespace gui ...@@ -173,7 +176,7 @@ namespace gui
//! Names for default skin sizes //! Names for default skin sizes
const c8* const GUISkinSizeNames[] = const c8* const GUISkinSizeNames[EGDS_COUNT+1] =
{ {
"ScrollBarSize", "ScrollBarSize",
"MenuHeight", "MenuHeight",
...@@ -220,7 +223,7 @@ namespace gui ...@@ -220,7 +223,7 @@ namespace gui
}; };
//! Names for default skin sizes //! Names for default skin sizes
const c8* const GUISkinTextNames[] = const c8* const GUISkinTextNames[EGDT_COUNT+1] =
{ {
"MessageBoxOkay", "MessageBoxOkay",
"MessageBoxCancel", "MessageBoxCancel",
...@@ -287,7 +290,7 @@ namespace gui ...@@ -287,7 +290,7 @@ namespace gui
EGDI_COUNT EGDI_COUNT
}; };
const c8* const GUISkinIconNames[] = const c8* const GUISkinIconNames[EGDI_COUNT+1] =
{ {
"windowMaximize", "windowMaximize",
"windowRestore", "windowRestore",
...@@ -333,7 +336,7 @@ namespace gui ...@@ -333,7 +336,7 @@ namespace gui
EGDF_COUNT EGDF_COUNT
}; };
const c8* const GUISkinFontNames[] = const c8* const GUISkinFontNames[EGDF_COUNT+1] =
{ {
"defaultFont", "defaultFont",
"buttonFont", "buttonFont",
......
...@@ -116,7 +116,7 @@ headers, e.g. Summer 2004. This is a Microsoft issue, not an Irrlicht one. ...@@ -116,7 +116,7 @@ headers, e.g. Summer 2004. This is a Microsoft issue, not an Irrlicht one.
#if defined(_IRR_WINDOWS_API_) && (!defined(__GNUC__) || defined(IRR_COMPILE_WITH_DX9_DEV_PACK)) #if defined(_IRR_WINDOWS_API_) && (!defined(__GNUC__) || defined(IRR_COMPILE_WITH_DX9_DEV_PACK))
//! Only define _IRR_COMPILE_WITH_DIRECT3D_8_ if you have an appropriate DXSDK, e.g. Summer 2004 //! Only define _IRR_COMPILE_WITH_DIRECT3D_8_ if you have an appropriate DXSDK, e.g. Summer 2004
#define _IRR_COMPILE_WITH_DIRECT3D_8_ //#define _IRR_COMPILE_WITH_DIRECT3D_8_
#define _IRR_COMPILE_WITH_DIRECT3D_9_ #define _IRR_COMPILE_WITH_DIRECT3D_9_
#endif #endif
......
...@@ -956,7 +956,7 @@ bool CIrrDeviceLinux::run() ...@@ -956,7 +956,7 @@ bool CIrrDeviceLinux::run()
else else
{ {
irrevent.KeyInput.Key = (EKEY_CODE)0; irrevent.KeyInput.Key = (EKEY_CODE)0;
os::Printer::log("Could not find win32 key for x11 key.", ELL_WARNING); os::Printer::log("Could not find win32 key for x11 key.", core::stringc((int)mp.X11Key).c_str(), ELL_WARNING);
} }
irrevent.EventType = irr::EET_KEY_INPUT_EVENT; irrevent.EventType = irr::EET_KEY_INPUT_EVENT;
irrevent.KeyInput.PressedDown = (event.type == KeyPress); irrevent.KeyInput.PressedDown = (event.type == KeyPress);
...@@ -1349,6 +1349,7 @@ void CIrrDeviceLinux::createKeyMap() ...@@ -1349,6 +1349,7 @@ void CIrrDeviceLinux::createKeyMap()
KeyMap.push_back(SKeyMap(XK_Page_Down, KEY_NEXT)); KeyMap.push_back(SKeyMap(XK_Page_Down, KEY_NEXT));
KeyMap.push_back(SKeyMap(XK_End, KEY_END)); KeyMap.push_back(SKeyMap(XK_End, KEY_END));
KeyMap.push_back(SKeyMap(XK_Begin, KEY_HOME)); KeyMap.push_back(SKeyMap(XK_Begin, KEY_HOME));
KeyMap.push_back(SKeyMap(XK_Num_Lock, KEY_NUMLOCK));
KeyMap.push_back(SKeyMap(XK_KP_Space, KEY_SPACE)); KeyMap.push_back(SKeyMap(XK_KP_Space, KEY_SPACE));
KeyMap.push_back(SKeyMap(XK_KP_Tab, KEY_TAB)); KeyMap.push_back(SKeyMap(XK_KP_Tab, KEY_TAB));
KeyMap.push_back(SKeyMap(XK_KP_Enter, KEY_RETURN)); KeyMap.push_back(SKeyMap(XK_KP_Enter, KEY_RETURN));
...@@ -1356,10 +1357,12 @@ void CIrrDeviceLinux::createKeyMap() ...@@ -1356,10 +1357,12 @@ void CIrrDeviceLinux::createKeyMap()
KeyMap.push_back(SKeyMap(XK_KP_F2, KEY_F2)); KeyMap.push_back(SKeyMap(XK_KP_F2, KEY_F2));
KeyMap.push_back(SKeyMap(XK_KP_F3, KEY_F3)); KeyMap.push_back(SKeyMap(XK_KP_F3, KEY_F3));
KeyMap.push_back(SKeyMap(XK_KP_F4, KEY_F4)); KeyMap.push_back(SKeyMap(XK_KP_F4, KEY_F4));
KeyMap.push_back(SKeyMap(XK_KP_Home, KEY_HOME));
KeyMap.push_back(SKeyMap(XK_KP_Left, KEY_LEFT)); KeyMap.push_back(SKeyMap(XK_KP_Left, KEY_LEFT));
KeyMap.push_back(SKeyMap(XK_KP_Up, KEY_UP)); KeyMap.push_back(SKeyMap(XK_KP_Up, KEY_UP));
KeyMap.push_back(SKeyMap(XK_KP_Right, KEY_RIGHT)); KeyMap.push_back(SKeyMap(XK_KP_Right, KEY_RIGHT));
KeyMap.push_back(SKeyMap(XK_KP_Down, KEY_DOWN)); KeyMap.push_back(SKeyMap(XK_KP_Down, KEY_DOWN));
KeyMap.push_back(SKeyMap(XK_Print, KEY_PRINT));
KeyMap.push_back(SKeyMap(XK_KP_Prior, KEY_PRIOR)); KeyMap.push_back(SKeyMap(XK_KP_Prior, KEY_PRIOR));
KeyMap.push_back(SKeyMap(XK_KP_Page_Up, KEY_PRIOR)); KeyMap.push_back(SKeyMap(XK_KP_Page_Up, KEY_PRIOR));
KeyMap.push_back(SKeyMap(XK_KP_Next, KEY_NEXT)); KeyMap.push_back(SKeyMap(XK_KP_Next, KEY_NEXT));
......
...@@ -60,11 +60,11 @@ struct JoystickInfo ...@@ -60,11 +60,11 @@ struct JoystickInfo
irr::core::array <JoystickComponent> axisComp; irr::core::array <JoystickComponent> axisComp;
irr::core::array <JoystickComponent> buttonComp; irr::core::array <JoystickComponent> buttonComp;
irr::core::array <JoystickComponent> hatComp; irr::core::array <JoystickComponent> hatComp;
int hats; int hats;
int axes; int axes;
int buttons; int buttons;
int numActiveJoysticks; int numActiveJoysticks;
irr::SEvent persistentData; irr::SEvent persistentData;
...@@ -178,7 +178,7 @@ static void addJoystickComponent (CFTypeRef refElement, JoystickInfo* joyInfo) ...@@ -178,7 +178,7 @@ static void addJoystickComponent (CFTypeRef refElement, JoystickInfo* joyInfo)
joyInfo->hatComp.push_back(newComponent); joyInfo->hatComp.push_back(newComponent);
} }
break; break;
} }
} }
break; break;
case kHIDPage_Button: case kHIDPage_Button:
...@@ -235,10 +235,10 @@ static void getJoystickDeviceInfo (io_object_t hidDevice, CFMutableDictionaryRef ...@@ -235,10 +235,10 @@ static void getJoystickDeviceInfo (io_object_t hidDevice, CFMutableDictionaryRef
{ {
CFMutableDictionaryRef usbProperties = 0; CFMutableDictionaryRef usbProperties = 0;
io_registry_entry_t parent1, parent2; 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 /* 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 * get dictionary for usb properties: step up two levels and get CF dictionary for USB properties
*/ */
if ((KERN_SUCCESS == IORegistryEntryGetParentEntry (hidDevice, kIOServicePlane, &parent1)) && if ((KERN_SUCCESS == IORegistryEntryGetParentEntry (hidDevice, kIOServicePlane, &parent1)) &&
(KERN_SUCCESS == IORegistryEntryGetParentEntry (parent1, kIOServicePlane, &parent2)) && (KERN_SUCCESS == IORegistryEntryGetParentEntry (parent1, kIOServicePlane, &parent2)) &&
(KERN_SUCCESS == IORegistryEntryCreateCFProperties (parent2, &usbProperties, kCFAllocatorDefault, kNilOptions))) (KERN_SUCCESS == IORegistryEntryCreateCFProperties (parent2, &usbProperties, kCFAllocatorDefault, kNilOptions)))
...@@ -247,10 +247,9 @@ static void getJoystickDeviceInfo (io_object_t hidDevice, CFMutableDictionaryRef ...@@ -247,10 +247,9 @@ static void getJoystickDeviceInfo (io_object_t hidDevice, CFMutableDictionaryRef
{ {
CFTypeRef refCF = 0; CFTypeRef refCF = 0;
/* get device info /* get device info
* try hid dictionary first, if fail then go to usb dictionary * try hid dictionary first, if fail then go to usb dictionary
*/ */
/* get joystickName name */ /* get joystickName name */
refCF = CFDictionaryGetValue (hidProperties, CFSTR(kIOHIDProductKey)); refCF = CFDictionaryGetValue (hidProperties, CFSTR(kIOHIDProductKey));
if (!refCF) if (!refCF)
...@@ -260,7 +259,7 @@ static void getJoystickDeviceInfo (io_object_t hidDevice, CFMutableDictionaryRef ...@@ -260,7 +259,7 @@ static void getJoystickDeviceInfo (io_object_t hidDevice, CFMutableDictionaryRef
if (!CFStringGetCString ((CFStringRef)refCF, joyInfo->joystickName, 256, CFStringGetSystemEncoding ())) if (!CFStringGetCString ((CFStringRef)refCF, joyInfo->joystickName, 256, CFStringGetSystemEncoding ()))
irr::os::Printer::log("CFStringGetCString error getting joyInfo->joystickName", irr::ELL_ERROR); irr::os::Printer::log("CFStringGetCString error getting joyInfo->joystickName", irr::ELL_ERROR);
} }
/* get usage page and usage */ /* get usage page and usage */
refCF = CFDictionaryGetValue (hidProperties, CFSTR(kIOHIDPrimaryUsagePageKey)); refCF = CFDictionaryGetValue (hidProperties, CFSTR(kIOHIDPrimaryUsagePageKey));
if (refCF) if (refCF)
...@@ -368,17 +367,17 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param) ...@@ -368,17 +367,17 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
initKeycodes(); initKeycodes();
if (CreationParams.DriverType != video::EDT_NULL) if (CreationParams.DriverType != video::EDT_NULL)
createWindow(); createWindow();
setResizable(false); setResizable(false);
CursorControl = new CCursorControl(CreationParams.WindowSize, this); CursorControl = new CCursorControl(CreationParams.WindowSize, this);
createDriver(); createDriver();
if (IsSoftwareRenderer && CreationParams.DriverType != video::EDT_NULL) if (IsSoftwareRenderer && CreationParams.DriverType != video::EDT_NULL)
{ {
// create context for rendering raw bitmap // create context for rendering raw bitmap
} }
createGUIAndScene(); createGUIAndScene();
} }
...@@ -445,7 +444,7 @@ bool CIrrDeviceMacOSX::createWindow() ...@@ -445,7 +444,7 @@ bool CIrrDeviceMacOSX::createWindow()
display = CGMainDisplayID(); display = CGMainDisplayID();
ScreenWidth = (int) CGDisplayPixelsWide(display); ScreenWidth = (int) CGDisplayPixelsWide(display);
ScreenHeight = (int) CGDisplayPixelsHigh(display); ScreenHeight = (int) CGDisplayPixelsHigh(display);
VideoModeList.setDesktop(CreationParams.Bits, core::dimension2d<u32>(ScreenWidth, ScreenHeight)); VideoModeList.setDesktop(CreationParams.Bits, core::dimension2d<u32>(ScreenWidth, ScreenHeight));
if (!CreationParams.Fullscreen) if (!CreationParams.Fullscreen)
...@@ -453,7 +452,7 @@ bool CIrrDeviceMacOSX::createWindow() ...@@ -453,7 +452,7 @@ bool CIrrDeviceMacOSX::createWindow()
Window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,CreationParams.WindowSize.Width,CreationParams.WindowSize.Height) styleMask:NSTitledWindowMask+NSClosableWindowMask+NSResizableWindowMask backing:NSBackingStoreBuffered defer:FALSE]; Window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,CreationParams.WindowSize.Width,CreationParams.WindowSize.Height) styleMask:NSTitledWindowMask+NSClosableWindowMask+NSResizableWindowMask backing:NSBackingStoreBuffered defer:FALSE];
if (Window != NULL) if (Window != NULL)
{ {
NSOpenGLPixelFormatAttribute windowattribs[] = NSOpenGLPixelFormatAttribute windowattribs[] =
{ {
NSOpenGLPFANoRecovery, NSOpenGLPFANoRecovery,
NSOpenGLPFAAccelerated, NSOpenGLPFAAccelerated,
...@@ -503,7 +502,7 @@ bool CIrrDeviceMacOSX::createWindow() ...@@ -503,7 +502,7 @@ bool CIrrDeviceMacOSX::createWindow()
windowattribs[12] = (NSOpenGLPixelFormatAttribute)((int)windowattribs[12]-1); windowattribs[12] = (NSOpenGLPixelFormatAttribute)((int)windowattribs[12]-1);
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs]; format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs];
} }
if (!format) if (!format)
{ {
windowattribs[9] = (NSOpenGLPixelFormatAttribute)0; windowattribs[9] = (NSOpenGLPixelFormatAttribute)0;
...@@ -519,7 +518,7 @@ bool CIrrDeviceMacOSX::createWindow() ...@@ -519,7 +518,7 @@ bool CIrrDeviceMacOSX::createWindow()
{ {
os::Printer::log("No FSAA available.", ELL_WARNING); os::Printer::log("No FSAA available.", ELL_WARNING);
} }
} }
} }
} }
...@@ -633,14 +632,14 @@ bool CIrrDeviceMacOSX::createWindow() ...@@ -633,14 +632,14 @@ bool CIrrDeviceMacOSX::createWindow()
} }
void CIrrDeviceMacOSX::setResize(int width, int height) void CIrrDeviceMacOSX::setResize(int width, int height)
{ {
// set new window size // set new window size
DeviceWidth = width; DeviceWidth = width;
DeviceHeight = height; DeviceHeight = height;
// update the size of the opengl rendering context // update the size of the opengl rendering context
[OGLContext update]; [OGLContext update];
// resize the driver to the inner pane size // resize the driver to the inner pane size
NSRect driverFrame = [Window contentRectForFrameRect:[Window frame]]; NSRect driverFrame = [Window contentRectForFrameRect:[Window frame]];
getVideoDriver()->OnResize(core::dimension2d<u32>( (s32)driverFrame.size.width, (s32)driverFrame.size.height)); getVideoDriver()->OnResize(core::dimension2d<u32>( (s32)driverFrame.size.width, (s32)driverFrame.size.height));
...@@ -689,7 +688,6 @@ void CIrrDeviceMacOSX::createDriver() ...@@ -689,7 +688,6 @@ void CIrrDeviceMacOSX::createDriver()
os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR); os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR);
break; break;
} }
} }
void CIrrDeviceMacOSX::flush() void CIrrDeviceMacOSX::flush()
...@@ -728,32 +726,32 @@ bool CIrrDeviceMacOSX::run() ...@@ -728,32 +726,32 @@ bool CIrrDeviceMacOSX::run()
ievent.EventType = irr::EET_KEY_INPUT_EVENT; ievent.EventType = irr::EET_KEY_INPUT_EVENT;
ievent.KeyInput.Shift = ([(NSEvent *)event modifierFlags] & NSShiftKeyMask ) != 0; ievent.KeyInput.Shift = ([(NSEvent *)event modifierFlags] & NSShiftKeyMask ) != 0;
ievent.KeyInput.Control = ([(NSEvent *)event modifierFlags] & NSControlKeyMask) != 0; ievent.KeyInput.Control = ([(NSEvent *)event modifierFlags] & NSControlKeyMask) != 0;
if (IsShiftDown != ievent.KeyInput.Shift) if (IsShiftDown != ievent.KeyInput.Shift)
{ {
ievent.KeyInput.Char = irr::KEY_SHIFT; ievent.KeyInput.Char = irr::KEY_SHIFT;
ievent.KeyInput.Key = irr::KEY_SHIFT; ievent.KeyInput.Key = irr::KEY_SHIFT;
ievent.KeyInput.PressedDown = ievent.KeyInput.Shift; ievent.KeyInput.PressedDown = ievent.KeyInput.Shift;
IsShiftDown = ievent.KeyInput.Shift; IsShiftDown = ievent.KeyInput.Shift;
postEventFromUser(ievent); postEventFromUser(ievent);
} }
if (IsControlDown != ievent.KeyInput.Control) if (IsControlDown != ievent.KeyInput.Control)
{ {
ievent.KeyInput.Char = irr::KEY_CONTROL; ievent.KeyInput.Char = irr::KEY_CONTROL;
ievent.KeyInput.Key = irr::KEY_CONTROL; ievent.KeyInput.Key = irr::KEY_CONTROL;
ievent.KeyInput.PressedDown = ievent.KeyInput.Control; ievent.KeyInput.PressedDown = ievent.KeyInput.Control;
IsControlDown = ievent.KeyInput.Control; IsControlDown = ievent.KeyInput.Control;
postEventFromUser(ievent); postEventFromUser(ievent);
} }
[NSApp sendEvent:event]; [NSApp sendEvent:event];
break; break;
case NSLeftMouseDown: case NSLeftMouseDown:
ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; ievent.EventType = irr::EET_MOUSE_INPUT_EVENT;
ievent.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN; ievent.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN;
...@@ -769,7 +767,7 @@ bool CIrrDeviceMacOSX::run() ...@@ -769,7 +767,7 @@ bool CIrrDeviceMacOSX::run()
ievent.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP; ievent.MouseInput.Event = irr::EMIE_LMOUSE_LEFT_UP;
postMouseEvent(event,ievent); postMouseEvent(event,ievent);
break; break;
case NSOtherMouseDown: case NSOtherMouseDown:
ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; ievent.EventType = irr::EET_MOUSE_INPUT_EVENT;
ievent.MouseInput.Event = irr::EMIE_MMOUSE_PRESSED_DOWN; ievent.MouseInput.Event = irr::EMIE_MMOUSE_PRESSED_DOWN;
...@@ -777,7 +775,7 @@ bool CIrrDeviceMacOSX::run() ...@@ -777,7 +775,7 @@ bool CIrrDeviceMacOSX::run()
ievent.MouseInput.ButtonStates = MouseButtonStates; ievent.MouseInput.ButtonStates = MouseButtonStates;
postMouseEvent(event,ievent); postMouseEvent(event,ievent);
break; break;
case NSOtherMouseUp: case NSOtherMouseUp:
ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; ievent.EventType = irr::EET_MOUSE_INPUT_EVENT;
MouseButtonStates &= !irr::EMBSM_MIDDLE; MouseButtonStates &= !irr::EMBSM_MIDDLE;
...@@ -816,8 +814,10 @@ bool CIrrDeviceMacOSX::run() ...@@ -816,8 +814,10 @@ bool CIrrDeviceMacOSX::run()
ievent.EventType = irr::EET_MOUSE_INPUT_EVENT; ievent.EventType = irr::EET_MOUSE_INPUT_EVENT;
ievent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL; ievent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL;
ievent.MouseInput.Wheel = [(NSEvent *)event deltaY]; ievent.MouseInput.Wheel = [(NSEvent *)event deltaY];
if (ievent.MouseInput.Wheel < 1.0f) ievent.MouseInput.Wheel *= 10.0f; if (ievent.MouseInput.Wheel < 1.0f)
else ievent.MouseInput.Wheel *= 5.0f; ievent.MouseInput.Wheel *= 10.0f;
else
ievent.MouseInput.Wheel *= 5.0f;
postMouseEvent(event,ievent); postMouseEvent(event,ievent);
break; break;
...@@ -868,7 +868,7 @@ void CIrrDeviceMacOSX::setWindowCaption(const wchar_t* text) ...@@ -868,7 +868,7 @@ void CIrrDeviceMacOSX::setWindowCaption(const wchar_t* text)
if (Window != NULL) if (Window != NULL)
{ {
size = wcstombs(title,text,1024); size = wcstombs(title,text,1024);
if (size == 1024) title[1023] = 0; title[1023] = 0;
[Window setTitle:[NSString stringWithCString:title length:size]]; [Window setTitle:[NSString stringWithCString:title length:size]];
} }
} }
...@@ -912,7 +912,7 @@ void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed ...@@ -912,7 +912,7 @@ void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed
c = [str characterAtIndex:0]; c = [str characterAtIndex:0];
iter = KeyCodes.find(c); iter = KeyCodes.find(c);
if (iter != KeyCodes.end()) if (iter != KeyCodes.end())
mkey = (*iter).second; mkey = (*iter).second;
else else
{ {
...@@ -921,8 +921,8 @@ void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed ...@@ -921,8 +921,8 @@ void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed
{ {
mkey = irr::KEY_PERIOD; mkey = irr::KEY_PERIOD;
mchar = '.'; mchar = '.';
} }
else else
{ {
cStr = (unsigned char *)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding]; cStr = (unsigned char *)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding];
if (cStr != NULL && strlen((char*)cStr) > 0) if (cStr != NULL && strlen((char*)cStr) > 0)
...@@ -965,8 +965,8 @@ void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent) ...@@ -965,8 +965,8 @@ void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent)
{ {
ievent.MouseInput.X = (int)[(NSEvent *)event locationInWindow].x; ievent.MouseInput.X = (int)[(NSEvent *)event locationInWindow].x;
ievent.MouseInput.Y = DeviceHeight - (int)[(NSEvent *)event locationInWindow].y; ievent.MouseInput.Y = DeviceHeight - (int)[(NSEvent *)event locationInWindow].y;
if (ievent.MouseInput.Y < 0) if (ievent.MouseInput.Y < 0)
post = false; post = false;
} }
else else
...@@ -977,7 +977,7 @@ void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent) ...@@ -977,7 +977,7 @@ void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent)
if (post) if (post)
postEventFromUser(ievent); postEventFromUser(ievent);
[NSApp sendEvent:(NSEvent *)event]; [NSApp sendEvent:(NSEvent *)event];
} }
...@@ -1090,7 +1090,7 @@ void CIrrDeviceMacOSX::setResizable(bool resize) ...@@ -1090,7 +1090,7 @@ void CIrrDeviceMacOSX::setResizable(bool resize)
{ {
IsResizable = resize; IsResizable = resize;
} }
bool CIrrDeviceMacOSX::isResizable() const bool CIrrDeviceMacOSX::isResizable() const
{ {
return IsResizable; return IsResizable;
...@@ -1100,13 +1100,13 @@ void CIrrDeviceMacOSX::minimizeWindow() ...@@ -1100,13 +1100,13 @@ void CIrrDeviceMacOSX::minimizeWindow()
{ {
// todo: implement // todo: implement
} }
//! Maximizes the window if possible. //! Maximizes the window if possible.
void CIrrDeviceMacOSX::maximizeWindow() void CIrrDeviceMacOSX::maximizeWindow()
{ {
// todo: implement // todo: implement
} }
//! Restore the window to normal size if possible. //! Restore the window to normal size if possible.
void CIrrDeviceMacOSX::restoreWindow() void CIrrDeviceMacOSX::restoreWindow()
{ {
...@@ -1116,23 +1116,23 @@ void CIrrDeviceMacOSX::restoreWindow() ...@@ -1116,23 +1116,23 @@ void CIrrDeviceMacOSX::restoreWindow()
bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rect<s32>* src ) bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rect<s32>* src )
{ {
// todo: implement window ID and src rectangle // todo: implement window ID and src rectangle
if (!surface) if (!surface)
return false; return false;
if (IsSoftwareRenderer) if (IsSoftwareRenderer)
{ {
// do we need to change the size? // do we need to change the size?
bool updateSize = !SoftwareDriverTarget || bool updateSize = !SoftwareDriverTarget ||
s32([SoftwareDriverTarget size].width) != surface->getDimension().Width || s32([SoftwareDriverTarget size].width) != surface->getDimension().Width ||
s32([SoftwareDriverTarget size].height) != surface->getDimension().Height; s32([SoftwareDriverTarget size].height) != surface->getDimension().Height;
// release if necessary // release if necessary
if (SoftwareDriverTarget && updateSize) if (SoftwareDriverTarget && updateSize)
[SoftwareDriverTarget release]; [SoftwareDriverTarget release];
NSRect areaRect = NSMakeRect(0.0, 0.0, surface->getDimension().Width, surface->getDimension().Height); NSRect areaRect = NSMakeRect(0.0, 0.0, surface->getDimension().Width, surface->getDimension().Height);
// get pointer to image data // get pointer to image data
unsigned char* imgData = (unsigned char*)surface->lock(); unsigned char* imgData = (unsigned char*)surface->lock();
...@@ -1140,25 +1140,25 @@ bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rec ...@@ -1140,25 +1140,25 @@ bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rec
if (updateSize) if (updateSize)
{ {
// allocate target for IImage // allocate target for IImage
SoftwareDriverTarget = [[NSBitmapImageRep alloc] SoftwareDriverTarget = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes: nil initWithBitmapDataPlanes: nil
pixelsWide: areaRect.size.width pixelsWide: areaRect.size.width
pixelsHigh: areaRect.size.height pixelsHigh: areaRect.size.height
bitsPerSample: 8 bitsPerSample: 8
samplesPerPixel: 3 samplesPerPixel: 3
hasAlpha: NO hasAlpha: NO
isPlanar: NO isPlanar: NO
colorSpaceName: NSCalibratedRGBColorSpace colorSpaceName: NSCalibratedRGBColorSpace
bytesPerRow: (3 * areaRect.size.width) bytesPerRow: (3 * areaRect.size.width)
bitsPerPixel: 24]; bitsPerPixel: 24];
} }
const u32 destwidth = areaRect.size.width; const u32 destwidth = areaRect.size.width;
const u32 minWidth = core::min_(surface->getDimension().Width, destwidth); const u32 minWidth = core::min_(surface->getDimension().Width, destwidth);
const u32 destPitch = (3 * areaRect.size.width); const u32 destPitch = (3 * areaRect.size.width);
u8* srcdata = reinterpret_cast<u8*>(imgData); u8* srcdata = reinterpret_cast<u8*>(imgData);
u8* destData = reinterpret_cast<u8*>([SoftwareDriverTarget bitmapData]); u8* destData = reinterpret_cast<u8*>([SoftwareDriverTarget bitmapData]);
const u32 destheight = areaRect.size.height; const u32 destheight = areaRect.size.height;
const u32 srcheight = core::min_(surface->getDimension().Height, destheight); const u32 srcheight = core::min_(surface->getDimension().Height, destheight);
const u32 srcPitch = surface->getPitch(); const u32 srcPitch = surface->getPitch();
...@@ -1168,22 +1168,20 @@ bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rec ...@@ -1168,22 +1168,20 @@ bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rec
srcdata += srcPitch; srcdata += srcPitch;
destData += destPitch; destData += destPitch;
} }
// unlock the data // unlock the data
surface->unlock(); surface->unlock();
// todo: draw properly into a sub-view // todo: draw properly into a sub-view
[SoftwareDriverTarget draw]; [SoftwareDriverTarget draw];
} }
return false; return false;
} }
#if defined (_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) #if defined (_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
static void joystickRemovalCallback(void * target, static void joystickRemovalCallback(void * target,
IOReturn result, IOReturn result, void * refcon, void * sender)
void * refcon,
void * sender)
{ {
JoystickInfo *joy = (JoystickInfo *) refcon; JoystickInfo *joy = (JoystickInfo *) refcon;
joy->removed = 1; joy->removed = 1;
...@@ -1279,27 +1277,27 @@ bool CIrrDeviceMacOSX::activateJoysticks(core::array<SJoystickInfo> & joystickIn ...@@ -1279,27 +1277,27 @@ bool CIrrDeviceMacOSX::activateJoysticks(core::array<SJoystickInfo> & joystickIn
{ {
CFRelease (hidProperties); CFRelease (hidProperties);
os::Printer::log("initialiseJoysticks Open interface failed", ELL_ERROR); os::Printer::log("initialiseJoysticks Open interface failed", ELL_ERROR);
continue; continue;
} }
CFRelease (hidProperties); CFRelease (hidProperties);
result = IOObjectRelease (hidObject); result = IOObjectRelease (hidObject);
if ( (info.usagePage != kHIDPage_GenericDesktop) || if ( (info.usagePage != kHIDPage_GenericDesktop) ||
((info.usage != kHIDUsage_GD_Joystick && ((info.usage != kHIDUsage_GD_Joystick &&
info.usage != kHIDUsage_GD_GamePad && info.usage != kHIDUsage_GD_GamePad &&
info.usage != kHIDUsage_GD_MultiAxisController)) ) info.usage != kHIDUsage_GD_MultiAxisController)) )
{ {
closeJoystickDevice (&info); closeJoystickDevice (&info);
continue; continue;
} }
for (u32 i = 0; i < 6; i++) for (u32 i = 0; i < 6; ++i)
info.persistentData.JoystickEvent.Axis[i] = 0; info.persistentData.JoystickEvent.Axis[i] = 0;
ActiveJoysticks.push_back(info); ActiveJoysticks.push_back(info);
SJoystickInfo returnInfo; SJoystickInfo returnInfo;
returnInfo.Axes = info.axes; returnInfo.Axes = info.axes;
//returnInfo.Hats = info.hats; //returnInfo.Hats = info.hats;
...@@ -1340,7 +1338,7 @@ void CIrrDeviceMacOSX::pollJoysticks() ...@@ -1340,7 +1338,7 @@ void CIrrDeviceMacOSX::pollJoysticks()
{ {
if (ActiveJoysticks[joystick].removed) if (ActiveJoysticks[joystick].removed)
continue; continue;
bool found = false; bool found = false;
ActiveJoysticks[joystick].persistentData.JoystickEvent.Joystick = joystick; ActiveJoysticks[joystick].persistentData.JoystickEvent.Joystick = joystick;
...@@ -1363,7 +1361,7 @@ void CIrrDeviceMacOSX::pollJoysticks() ...@@ -1363,7 +1361,7 @@ void CIrrDeviceMacOSX::pollJoysticks()
ActiveJoysticks[joystick].axisComp[n].minRead = hidEvent.value; ActiveJoysticks[joystick].axisComp[n].minRead = hidEvent.value;
if (hidEvent.value > ActiveJoysticks[joystick].axisComp[n].maxRead) if (hidEvent.value > ActiveJoysticks[joystick].axisComp[n].maxRead)
ActiveJoysticks[joystick].axisComp[n].maxRead = hidEvent.value; ActiveJoysticks[joystick].axisComp[n].maxRead = hidEvent.value;
if (readScale != 0.0f) if (readScale != 0.0f)
hidEvent.value = (int)(((f32)((f32)hidEvent.value - (f32)ActiveJoysticks[joystick].axisComp[n].minRead) * deviceScale / readScale) + min); hidEvent.value = (int)(((f32)((f32)hidEvent.value - (f32)ActiveJoysticks[joystick].axisComp[n].minRead) * deviceScale / readScale) + min);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment