Adding missing OK and Cancel events to CheatCodeDialog.

Tied 'OK' and 'Cancel' events to closing the About and Help dialog boxes.

Fixed bug where menu event mappings weren't being reset on default.

Fixed bug where some characters could be mapped to an event, but didn't
actually do anything.  This is related to Unicode issues, and may fix
problems that non-ASCII users have been experiencing.

Fixed issue with joystick buttons/axis events not being processed in
PopUpWidgets.  This fixes the problems experienced by GP2X users, where
selecting a popup menu seemed to lock Stella (in actual fact, it was
still running, waiting for input).


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1163 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2006-11-29 18:22:56 +00:00
parent 018e02d7e6
commit 7ac52b8609
6 changed files with 59 additions and 31 deletions

View File

@ -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: CheatCodeDialog.cxx,v 1.10 2006-05-04 17:45:20 stephena Exp $
// $Id: CheatCodeDialog.cxx,v 1.11 2006-11-29 18:22:55 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -74,15 +74,19 @@ CheatCodeDialog::CheatCodeDialog(OSystem* osystem, DialogContainer* parent,
#ifndef MAC_OSX
b = addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24, "OK", kOKCmd);
wid.push_back(b);
addOKWidget(b);
myCancelButton = addButton(font, _w - (kButtonWidth + 10), _h - 24,
"Cancel", kCloseCmd);
wid.push_back(myCancelButton);
addCancelWidget(myCancelButton);
#else
myCancelButton = addButton(font, _w - 2 * (kButtonWidth + 7), _h - 24,
"Cancel", kCloseCmd);
wid.push_back(myCancelButton);
addCancelWidget(myCancelButton);
b = addButton(font, _w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd);
wid.push_back(b);
addOKWidget(b);
#endif
addToFocusList(wid);

View File

@ -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: EventHandler.cxx,v 1.174 2006-11-28 21:48:56 stephena Exp $
// $Id: EventHandler.cxx,v 1.175 2006-11-29 18:22:55 stephena Exp $
//============================================================================
#include <sstream>
@ -623,9 +623,7 @@ void EventHandler::poll(uInt32 time)
else if(myOverlay != NULL)
{
// Make sure the unicode field is valid
if (key == SDLK_BACKSPACE || key == SDLK_DELETE ||
(key >= SDLK_UP && key <= SDLK_PAGEDOWN))
unicode = key;
if(!unicode) unicode = key;
myOverlay->handleKeyEvent(unicode, key, mod, state);
}
@ -1682,13 +1680,13 @@ void EventHandler::setDefaultMapping(EventMode mode)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setDefaultKeymap(EventMode mode)
{
// Erase all mappings
for(int i = 0; i < SDLK_LAST; ++i)
myKeyTable[i][mode] = Event::NoType;
switch(mode)
{
case kEmulationMode:
// Erase all mappings
for(int i = 0; i < SDLK_LAST; ++i)
myKeyTable[i][mode] = Event::NoType;
myKeyTable[ SDLK_1 ][mode] = Event::KeyboardZero1;
myKeyTable[ SDLK_2 ][mode] = Event::KeyboardZero2;
myKeyTable[ SDLK_3 ][mode] = Event::KeyboardZero3;

View File

@ -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: AboutDialog.cxx,v 1.14 2006-11-28 21:48:56 stephena Exp $
// $Id: AboutDialog.cxx,v 1.15 2006-11-29 18:22:56 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -50,7 +50,7 @@ AboutDialog::AboutDialog(OSystem* osystem, DialogContainer* parent,
ButtonWidget* b = addButton(font, w - (kButtonWidth + 10), h - 24,
"Close", kCloseCmd);
wid.push_back(b);
addCancelWidget(b);
addOKWidget(b); addCancelWidget(b);
myTitle = new StaticTextWidget(this, font, 5, 5, w - 10, font.getFontHeight(),
"", kTextAlignCenter);

View File

@ -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: HelpDialog.cxx,v 1.17 2006-11-28 21:48:56 stephena Exp $
// $Id: HelpDialog.cxx,v 1.18 2006-11-29 18:22:56 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -48,7 +48,7 @@ HelpDialog::HelpDialog(OSystem* osystem, DialogContainer* parent,
ButtonWidget* b = addButton(font, w - (kButtonWidth + 10), h - 24,
"Close", kCloseCmd);
wid.push_back(b);
addCancelWidget(b);
addOKWidget(b); addCancelWidget(b);
myTitle = new StaticTextWidget(this, font, 5, 5, w - 10, font.getFontHeight(),
"", kTextAlignCenter);

View File

@ -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: PopUpWidget.cxx,v 1.27 2006-11-04 19:38:25 stephena Exp $
// $Id: PopUpWidget.cxx,v 1.28 2006-11-29 18:22:56 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -135,17 +135,38 @@ void PopUpDialog::handleKeyDown(int ascii, int keycode, int modifiers)
if(isMouseDown())
return;
switch (ascii)
Event::Type e = instance()->eventHandler().eventForKey(ascii, kMenuMode);
handleEvent(e);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::handleJoyDown(int stick, int button)
{
Event::Type e =
instance()->eventHandler().eventForJoyButton(stick, button, kMenuMode);
handleEvent(e);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::handleJoyAxis(int stick, int axis, int value)
{
if(value != 0) // we don't care about 'axis up' events
{
case 27: // escape
cancelSelection();
break;
default:
handleEvent(instance()->eventHandler().eventForKey(ascii, kMenuMode));
break;
Event::Type e =
instance()->eventHandler().eventForJoyAxis(stick, axis, value, kMenuMode);
handleEvent(e);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PopUpDialog::handleJoyHat(int stick, int hat, int value)
{
Event::Type e =
instance()->eventHandler().eventForJoyHat(stick, hat, value, kMenuMode);
handleEvent(e);
return true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PopUpDialog::handleEvent(Event::Type e)
{
@ -168,6 +189,9 @@ void PopUpDialog::handleEvent(Event::Type e)
case Event::UIEnd:
setSelection(_popUpBoss->_entries.size()-1);
break;
case Event::UICancel:
cancelSelection();
break;
default:
break;
}

View File

@ -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: PopUpWidget.hxx,v 1.13 2006-05-04 17:45:25 stephena Exp $
// $Id: PopUpWidget.hxx,v 1.14 2006-11-29 18:22:56 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -64,9 +64,6 @@ class PopUpWidget : public Widget, public CommandSender
const string& label, int labelWidth = 0, int cmd = 0);
~PopUpWidget();
void handleMouseDown(int x, int y, int button, int clickCount);
bool handleEvent(Event::Type e);
bool wantsFocus() { return true; }
void appendEntry(const string& entry, int tag = (int)-1);
@ -86,6 +83,8 @@ class PopUpWidget : public Widget, public CommandSender
{ return (_selectedItem >= 0) ? _entries[_selectedItem].name : EmptyString; }
protected:
void handleMouseDown(int x, int y, int button, int clickCount);
bool handleEvent(Event::Type e);
void drawWidget(bool hilite);
protected:
@ -109,12 +108,16 @@ class PopUpDialog : public Dialog
void drawDialog();
void handleMouseDown(int x, int y, int button, int clickCount);
void handleMouseWheel(int x, int y, int direction); // Scroll through entries with scroll wheel
void handleMouseMoved(int x, int y, int button); // Redraw selections depending on mouse position
void handleKeyDown(int ascii, int keycode, int modifiers); // Scroll through entries with arrow keys etc
protected:
void handleMouseDown(int x, int y, int button, int clickCount);
void handleMouseWheel(int x, int y, int direction);
void handleMouseMoved(int x, int y, int button);
void handleKeyDown(int ascii, int keycode, int modifiers); // Scroll through entries with arrow keys etc
void handleJoyDown(int stick, int button);
void handleJoyAxis(int stick, int axis, int value);
bool handleJoyHat(int stick, int hat, int value);
void handleEvent(Event::Type e);
void drawMenuEntry(int entry, bool hilite);
void recalc();
@ -128,7 +131,6 @@ class PopUpDialog : public Dialog
private:
void sendSelection();
void cancelSelection();
void handleEvent(Event::Type e);
protected:
PopUpWidget* _popUpBoss;