From 6b9329adf12f0bb14e5be3497006a99fab2c0c8e Mon Sep 17 00:00:00 2001 From: stephena Date: Mon, 15 May 2006 16:21:27 +0000 Subject: [PATCH] Cleaned up a few FIXME's, and enabled joysticks to use the new UI event mappings (not fully tested yet, since I don't have access to a joystick right now). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1103 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/emucore/FrameBuffer.cxx | 12 +--- stella/src/gui/Dialog.cxx | 112 +++++++++++++++-------------- stella/src/gui/Dialog.hxx | 5 +- 3 files changed, 62 insertions(+), 67 deletions(-) diff --git a/stella/src/emucore/FrameBuffer.cxx b/stella/src/emucore/FrameBuffer.cxx index 52ee70c33..21ae33e00 100644 --- a/stella/src/emucore/FrameBuffer.cxx +++ b/stella/src/emucore/FrameBuffer.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBuffer.cxx,v 1.87 2006-05-15 12:24:09 stephena Exp $ +// $Id: FrameBuffer.cxx,v 1.88 2006-05-15 16:21:27 stephena Exp $ //============================================================================ #include @@ -36,11 +36,6 @@ #include "Debugger.hxx" #endif -#if defined(OS2) // FIXME - make proper OS/2 port - #define INCL_WIN - #include -#endif - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FrameBuffer::FrameBuffer(OSystem* osystem) : myOSystem(osystem), @@ -86,13 +81,8 @@ void FrameBuffer::initialize(const string& title, uInt32 width, uInt32 height, // Query the desktop size // This is really the job of SDL int dwidth = 0, dheight = 0; -#if defined(OS2) // FIXME - make proper OS/2 port - myDesktopDim.w = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN); - myDesktopDim.h = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN); -#else myOSystem->getScreenDimensions(dwidth, dheight); myDesktopDim.w = dwidth; myDesktopDim.h = dheight; -#endif // Set fullscreen flag mySDLFlags = myOSystem->settings().getBool("fullscreen") ? SDL_FULLSCREEN : 0; diff --git a/stella/src/gui/Dialog.cxx b/stella/src/gui/Dialog.cxx index 2262a7b88..93cd76ad0 100644 --- a/stella/src/gui/Dialog.cxx +++ b/stella/src/gui/Dialog.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Dialog.cxx,v 1.45 2006-05-05 18:00:51 stephena Exp $ +// $Id: Dialog.cxx,v 1.46 2006-05-15 16:21:27 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -311,54 +311,12 @@ void Dialog::handleKeyDown(int ascii, int keycode, int modifiers) // Check the keytable now, since we might get one of the above events, // which must always be processed before any widget sees it. - bool handled = false; if(e == Event::NoType) e = instance()->eventHandler().eventForKey(ascii, kMenuMode); - switch(e) - { - case Event::UITabPrev: - if(_ourTab) - { - _ourTab->cycleTab(-1); - handled = true; - } - break; - - case Event::UITabNext: - if(_ourTab) - { - _ourTab->cycleTab(+1); - handled = true; - } - break; - - case Event::UINavPrev: - if(_focusedWidget && !_focusedWidget->wantsTab()) - { - _focusedWidget = Widget::setFocusForChain(this, getFocusList(), - _focusedWidget, -1); - handled = true; - } - break; - - case Event::UINavNext: - if(_focusedWidget && !_focusedWidget->wantsTab()) - { - _focusedWidget = Widget::setFocusForChain(this, getFocusList(), - _focusedWidget, +1); - handled = true; - } - break; - - default: - handled = false; - break; - } - // Unless a widget has claimed all responsibility for data, we assume // that if an event exists for the given data, it should have priority. - if(!handled && _focusedWidget) + if(!handleNavEvent(e) && _focusedWidget) { if(_focusedWidget->wantsRaw() || e == Event::NoType) _focusedWidget->handleKeyDown(ascii, keycode, modifiers); @@ -428,12 +386,12 @@ void Dialog::handleMouseMoved(int x, int y, int button) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Dialog::handleJoyDown(int stick, int button) { - Event::Type e = Event::NoType; // FIXME - do a lookup - bool handled = false; // isNavigation(e); + Event::Type e = + instance()->eventHandler().eventForJoyButton(stick, button, kMenuMode); // Unless a widget has claimed all responsibility for data, we assume // that if an event exists for the given data, it should have priority. - if(!handled && _focusedWidget) + if(!handleNavEvent(e) && _focusedWidget) { if(_focusedWidget->wantsRaw() || e == Event::NoType) _focusedWidget->handleJoyDown(stick, button); @@ -453,12 +411,12 @@ void Dialog::handleJoyUp(int stick, int button) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Dialog::handleJoyAxis(int stick, int axis, int value) { - Event::Type e = Event::NoType; // FIXME - do a lookup - bool handled = false; // isNavigation(e); + Event::Type e = + instance()->eventHandler().eventForJoyAxis(stick, axis, value, kMenuMode); // Unless a widget has claimed all responsibility for data, we assume // that if an event exists for the given data, it should have priority. - if(!handled && _focusedWidget) + if(!handleNavEvent(e) && _focusedWidget) { if(_focusedWidget->wantsRaw() || e == Event::NoType) _focusedWidget->handleJoyAxis(stick, axis, value); @@ -470,19 +428,65 @@ void Dialog::handleJoyAxis(int stick, int axis, int value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool Dialog::handleJoyHat(int stick, int hat, int value) { - Event::Type e = Event::NoType; // FIXME - do a lookup - bool handled = false; // isNavigation(e); + Event::Type e = + instance()->eventHandler().eventForJoyHat(stick, hat, value, kMenuMode); // Unless a widget has claimed all responsibility for data, we assume // that if an event exists for the given data, it should have priority. - if(!handled && _focusedWidget) + if(!handleNavEvent(e) && _focusedWidget) { if(_focusedWidget->wantsRaw() || e == Event::NoType) return _focusedWidget->handleJoyHat(stick, hat, value); else return _focusedWidget->handleEvent(e); } - return handled; + return true; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Dialog::handleNavEvent(Event::Type e) +{ + switch(e) + { + case Event::UITabPrev: + if(_ourTab) + { + _ourTab->cycleTab(-1); + return true; + } + break; + + case Event::UITabNext: + if(_ourTab) + { + _ourTab->cycleTab(+1); + return true; + } + break; + + case Event::UINavPrev: + if(_focusedWidget && !_focusedWidget->wantsTab()) + { + _focusedWidget = Widget::setFocusForChain(this, getFocusList(), + _focusedWidget, -1); + return true; + } + break; + + case Event::UINavNext: + if(_focusedWidget && !_focusedWidget->wantsTab()) + { + _focusedWidget = Widget::setFocusForChain(this, getFocusList(), + _focusedWidget, +1); + return true; + } + break; + + default: + return false; + break; + } + return false; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/gui/Dialog.hxx b/stella/src/gui/Dialog.hxx index 83aed0be8..c33998351 100644 --- a/stella/src/gui/Dialog.hxx +++ b/stella/src/gui/Dialog.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Dialog.hxx,v 1.29 2006-05-04 17:45:25 stephena Exp $ +// $Id: Dialog.hxx,v 1.30 2006-05-15 16:21:27 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -36,7 +36,7 @@ class TabWidget; This is the base class for all dialog boxes. @author Stephen Anthony - @version $Id: Dialog.hxx,v 1.29 2006-05-04 17:45:25 stephena Exp $ + @version $Id: Dialog.hxx,v 1.30 2006-05-15 16:21:27 stephena Exp $ */ class Dialog : public GuiObject { @@ -96,6 +96,7 @@ class Dialog : public GuiObject private: void buildFocusWidgetList(int id); + inline bool handleNavEvent(Event::Type e); protected: Widget* _mouseWidget;