Finished adding remappings to the user interface. All remappable

events can now be remapped from the GUI.

Added joystick support for remapping.

Updated EventHandler with defaults for every remappable event
in Stella.

Updated the manual with changes to the key mappings.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@195 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2003-09-30 01:22:45 +00:00
parent bbd7a69179
commit 87ba3c0b1e
5 changed files with 405 additions and 212 deletions

View File

@ -839,84 +839,92 @@
<hr>
<p>The Atari 2600 console controls and controllers are mapped to the computer's
keyboard as shown in the following tables:</p>
keyboard as shown in the following tables.</p>
<p>As of Stella 1.4, most of these events can be remapped to other keys on your keyboard
or buttons on your joystick. The tables below are the default settings.</p>
<p><b>Console Controls</b></p>
<table BORDER=2>
<tr>
<th>Key</th>
<th>Function</th>
<th>Key</th>
</tr>
<tr>
<td>Exit emulator/submenu</td>
<td>Escape</td>
<td>Exit game/emulator</td>
</tr>
<tr>
<td>F1</td>
<td>Enter/exit menu mode</td>
<td>Tab</td>
</tr>
<tr>
<td>Select Game</td>
<td>F1</td>
</tr>
<tr>
<td>F2</td>
<td>Reset Game</td>
<td>F2</td>
</tr>
<tr>
<td>F3</td>
<td>Color TV</td>
<td>F3</td>
</tr>
<tr>
<td>F4</td>
<td>Black/White TV</td>
<td>F4</td>
</tr>
<tr>
<td>F5</td>
<td>Left Player Difficulty B</td>
<td>F5</td>
</tr>
<tr>
<td>F6</td>
<td>Left Player Difficulty A</td>
<td>F6</td>
</tr>
<tr>
<td>F7</td>
<td>Right Player Difficulty B</td>
<td>F7</td>
</tr>
<tr>
<td>F8</td>
<td>Right Player Difficulty A</td>
<td>F8</td>
</tr>
<tr>
<td>Save state to current slot</td>
<td>F9</td>
<td>Save state to current slot (if supported)</td>
</tr>
<tr>
<td>F10, Shift + F10</td>
<td>Increase/decrease current state slot (if supported)</td>
<td>Change current state slot</td>
<td>F10</td>
</tr>
<tr>
<td>Load state from current slot</td>
<td>F11</td>
<td>Load state from current slot (if supported)</td>
</tr>
<tr>
<td>F12</td>
<td>Save snapshot (if supported)</td>
<td>F12</td>
</tr>
<tr>
<td>Pause/resume emulation</td>
<td>Pause</td>
<td>Pause/resume emulation (if supported)</td>
</tr>
</table>
@ -933,33 +941,33 @@
<td>
<table BORDER=1>
<tr>
<th>Key</th>
<th>Function</th>
<th>Key</th>
</tr>
<tr>
<td>W, Up arrow</td>
<td>Joystick Up</td>
<td>Up arrow</td>
</tr>
<tr>
<td>S, Down arrow</td>
<td>Joystick Down</td>
<td>Down arrow</td>
</tr>
<tr>
<td>A, Left arrow</td>
<td>Joystick Left</td>
<td>Left arrow</td>
</tr>
<tr>
<td>D, Right arrow</td>
<td>Joystick Right</td>
<td>Right arrow</td>
</tr>
<tr>
<td>Tab, Space</td>
<td>Fire Button</td>
<td>Space</td>
</tr>
</table>
</td>
@ -967,33 +975,33 @@
<td>
<table BORDER=1>
<tr>
<th>Key</th>
<th>Function</th>
<th>Key</th>
</tr>
<tr>
<td>O</td>
<td>Joystick Up</td>
<td>Y</td>
</tr>
<tr>
<td>L</td>
<td>Joystick Down</td>
<td>H</td>
</tr>
<tr>
<td>K</td>
<td>Joystick Left</td>
<td>G</td>
</tr>
<tr>
<td>;</td>
<td>Joystick Right</td>
<td>J</td>
</tr>
<tr>
<td>J</td>
<td>Fire Button</td>
<td>F</td>
</tr>
</table>
</td>
@ -1012,43 +1020,43 @@
<td>
<table BORDER=1>
<tr>
<th>Key</th>
<th>Function</th>
<th>Key</th>
</tr>
<tr>
<td>W, Up arrow</td>
<td>Booster-Grip Up</td>
<td>Same as left joystick</td>
</tr>
<tr>
<td>S, Down arrow</td>
<td>Booster-Grip Down</td>
<td>Same as left joystick</td>
</tr>
<tr>
<td>A, Left arrow</td>
<td>Booster-Grip Left</td>
<td>Same as left joystick</td>
</tr>
<tr>
<td>D, Right arrow</td>
<td>Booster-Grip Right</td>
<td>Same as left joystick</td>
</tr>
<tr>
<td>Tab, Space</td>
<td>Fire Button</td>
<td>Same as left joystick</td>
</tr>
<tr>
<td>1, Z</td>
<td>Trigger Button</td>
<td>4</td>
</tr>
<tr>
<td>2, X</td>
<td>Booster Button</td>
<td>5</td>
</tr>
</table>
</td>
@ -1056,43 +1064,43 @@
<td>
<table BORDER=1>
<tr>
<th>Key</th>
<th>Function</th>
<th>Key</th>
</tr>
<tr>
<td>O</td>
<td>Booster-Grip Up</td>
<td>Same as right joystick</td>
</tr>
<tr>
<td>L</td>
<td>Booster-Grip Down</td>
<td>Same as right joystick</td>
</tr>
<tr>
<td>K</td>
<td>Booster-Grip Left</td>
<td>Same as right joystick</td>
</tr>
<tr>
<td>;</td>
<td>Booster-Grip Right</td>
<td>Same as right joystick</td>
</tr>
<tr>
<td>J</td>
<td>Fire Button</td>
<td>Same as right joystick</td>
</tr>
<tr>
<td>N</td>
<td>Trigger Button</td>
<td>6</td>
</tr>
<tr>
<td>M</td>
<td>Booster Button</td>
<td>7</td>
</tr>
</table>
</td>
@ -1111,23 +1119,23 @@
<td>
<table BORDER=1>
<tr>
<th>Key</th>
<th>Function</th>
<th>Key</th>
</tr>
<tr>
<td>A, Left Arrow</td>
<td>Left</td>
<td>Left Direction</td>
<td>Insert</td>
</tr>
<tr>
<td>D, Right Arrow</td>
<td>Right</td>
<td>Right Direction</td>
<td>Page Up</td>
</tr>
<tr>
<td>Tab, Space</td>
<td>Button</td>
<td>Fire Button</td>
<td>Home</td>
</tr>
</table>
</td>
@ -1135,23 +1143,23 @@
<td>
<table BORDER=1>
<tr>
<th>Key</th>
<th>Function</th>
<th>Key</th>
</tr>
<tr>
<td>K</td>
<td>Left</td>
<td>Left Direction</td>
<td>Delete</td>
</tr>
<tr>
<td>;</td>
<td>Right</td>
<td>Right Direction</td>
<td>Page Down</td>
</tr>
<tr>
<td>J</td>
<td>Button</td>
<td>Fire Button</td>
<td>End</td>
</tr>
</table>
</td>
@ -1170,8 +1178,8 @@
<td>
<table BORDER=1>
<tr>
<th>Pad Button</th>
<th>Key</th>
<th>Keypad Button</th>
</tr>
<tr>
@ -1190,48 +1198,48 @@
</tr>
<tr>
<td>Q</td>
<td>4</td>
<td>Q</td>
</tr>
<tr>
<td>W</td>
<td>5</td>
<td>W</td>
</tr>
<tr>
<td>E</td>
<td>6</td>
<td>E</td>
</tr>
<tr>
<td>A</td>
<td>7</td>
<td>A</td>
</tr>
<tr>
<td>S</td>
<td>8</td>
<td>S</td>
</tr>
<tr>
<td>D</td>
<td>9</td>
<td>D</td>
</tr>
<tr>
<td>Z</td>
<td>.</td>
<td>Z</td>
</tr>
<tr>
<td>X</td>
<td>0</td>
<td>X</td>
</tr>
<tr>
<td>C</td>
<td>#</td>
<td>C</td>
</tr>
</table>
</td>
@ -1239,176 +1247,176 @@
<td>
<table BORDER=1>
<tr>
<th>Pad Button</th>
<th>Key</th>
<th>Keypad Button</th>
</tr>
<tr>
<td>8</td>
<td>1</td>
</tr>
<tr>
<td>9</td>
<td>2</td>
</tr>
<tr>
<td>0</td>
<td>3</td>
</tr>
<tr>
<td>I</td>
<td>4</td>
</tr>
<tr>
<td>O</td>
<td>5</td>
</tr>
<tr>
<td>P</td>
<td>6</td>
</tr>
<tr>
<td>K</td>
<td>7</td>
</tr>
<tr>
<td>L</td>
<td>8</td>
</tr>
<tr>
<td>;</td>
<td>2</td>
<td>9</td>
</tr>
<tr>
<td>,</td>
<td>.</td>
</tr>
<tr>
<td>.</td>
<td>3</td>
<td>0</td>
</tr>
<tr>
<td>/</td>
<td>4</td>
<td>I</td>
</tr>
<tr>
<td>5</td>
<td>O</td>
</tr>
<tr>
<td>6</td>
<td>P</td>
</tr>
<tr>
<td>7</td>
<td>K</td>
</tr>
<tr>
<td>8</td>
<td>L</td>
</tr>
<tr>
<td>9</td>
<td>;</td>
</tr>
<tr>
<td>.</td>
<td>,</td>
</tr>
<tr>
<td>0</td>
<td>.</td>
</tr>
<tr>
<td>#</td>
<td>/</td>
</tr>
</table>
</td>
</tr>
</table>
<p><b>Developer Keys</b></p>
<p><b>Developer Keys (cannot be remapped)</b></p>
<p>The following keys are activated only if <b>developer</b> support has
been included:</p>
<table BORDER=2>
<tr>
<th>Key</th>
<th>Function</th>
<th>Key</th>
</tr>
<tr>
<td>PageUp</td>
<td>Set "Display.YStart" to next <i>larger</i> value</td>
</tr>
<tr>
<td>PageDown</td>
<td>Set "Display.YStart" to next <i>smaller</i> value</td>
</tr>
<tr>
<td>Alt + PageUp</td>
<td>Set "Display.Height" to next <i>larger</i> value</td>
</tr>
<tr>
<td>Set "Display.YStart" to next <i>smaller</i> value</td>
<td>Alt + PageDown</td>
</tr>
<tr>
<td>Set "Display.Height" to next <i>larger</i> value</td>
<td>Control + PageUp</td>
</tr>
<tr>
<td>Set "Display.Height" to next <i>smaller</i> value</td>
<td>Control + PageDown</td>
</tr>
<tr>
<td>Home</td>
<td>Set "Display.XStart" to next <i>larger</i> value</td>
</tr>
<tr>
<td>End</td>
<td>Set "Display.XStart" to next <i>smaller</i> value</td>
</tr>
<tr>
<td>Alt + Home</td>
<td>Set "Display.Width" to next <i>larger</i> value</td>
</tr>
<tr>
<td>Alt + End</td>
</tr>
<tr>
<td>Set "Display.XStart" to next <i>smaller</i> value</td>
<td>Alt + Home</td>
</tr>
<tr>
<td>Set "Display.Width" to next <i>larger</i> value</td>
<td>Control + End</td>
</tr>
<tr>
<td>Set "Display.Width" to next <i>smaller</i> value</td>
<td>Control + Home</td>
</tr>
<tr>
<td>Alt + f</td>
<td>Toggle "Display.Format" between <i>NTSC</i> and <i>PAL</i></td>
<td>Control + f</td>
</tr>
<tr>
<td>Alt + s</td>
<td>Save (or merge) the current properties</td>
<td>Control + s</td>
</tr>
</table>
<p><b>Other Keys</b></p>
<p><b>Other Keys (cannot be remapped)</b></p>
<p>The following keys are not present in all versions, so they are listed by
version here:</p>
<table BORDER=2>
<tr>
<th>Key</th>
<th>Function</th>
<th>Key</th>
<th>Version</th>
</tr>
<tr>
<td>=</td>
<td>Resize window to next <i>larger</i> size</td>
<td>X11, SDL</td>
<td>Alt + =</td>
<td>SDL</td>
</tr>
<tr>
<td>-</td>
<td>Resize window to next <i>smaller</i> size</td>
<td>X11, SDL</td>
<td>Alt + -</td>
<td>SDL</td>
</tr>
<tr>
<td>g</td>
<td>Grab mouse (keep mouse in game window)</td>
<td>X11, SDL</td>
<td>Control + g</td>
<td>SDL</td>
</tr>
<tr>
<td>h</td>
<td>Hide cursor (hide cursor in game window)</td>
<td>X11, SDL</td>
<td>Control + h</td>
<td>SDL</td>
</tr>
<tr>
<td>Alt + Enter</td>
<td>Toggle fullscreen/windowed mode</td>
<td>Alt + Enter</td>
<td>SDL</td>
</tr>
</table>

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.14 2003-09-28 21:59:24 stephena Exp $
// $Id: EventHandler.cxx,v 1.15 2003-09-30 01:22:45 stephena Exp $
//============================================================================
#include <algorithm>
@ -66,9 +66,6 @@ EventHandler::EventHandler(Console* console)
setKeymap();
setJoymap();
// Now send the filled event arrays to the GUI for display and remapping
// myConsole->gui().
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -239,18 +236,17 @@ string EventHandler::getJoymap()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::getKeymapArray(Event::Type** array, uInt32* sizex)
void EventHandler::getKeymapArray(Event::Type** array, uInt32* size)
{
*array = myKeyTable;
*sizex = StellaEvent::LastKCODE;
*size = StellaEvent::LastKCODE;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::getJoymapArray(Event::Type** array, uInt32* sizex, uInt32* sizey)
void EventHandler::getJoymapArray(Event::Type** array, uInt32* size)
{
*array = myJoyTable;
*sizex = StellaEvent::LastJSTICK;
*sizey = StellaEvent::LastJCODE;
*size = StellaEvent::LastJSTICK * StellaEvent::LastJCODE;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -287,16 +283,24 @@ void EventHandler::setDefaultKeymap()
myKeyTable[StellaEvent::KCODE_LEFT] = Event::JoystickZeroLeft;
myKeyTable[StellaEvent::KCODE_RIGHT] = Event::JoystickZeroRight;
myKeyTable[StellaEvent::KCODE_SPACE] = Event::JoystickZeroFire;
// myKeyTable[StellaEvent::KCODE_] = Event::BoosterGripZeroTrigger;
// myKeyTable[StellaEvent::KCODE_] = Event::BoosterGripZeroBooster;
myKeyTable[StellaEvent::KCODE_4] = Event::BoosterGripZeroTrigger;
myKeyTable[StellaEvent::KCODE_5] = Event::BoosterGripZeroBooster;
myKeyTable[StellaEvent::KCODE_y] = Event::JoystickOneUp;
myKeyTable[StellaEvent::KCODE_h] = Event::JoystickOneDown;
myKeyTable[StellaEvent::KCODE_g] = Event::JoystickOneLeft;
myKeyTable[StellaEvent::KCODE_j] = Event::JoystickOneRight;
myKeyTable[StellaEvent::KCODE_f] = Event::JoystickOneFire;
// myKeyTable[StellaEvent::KCODE_] = Event::BoosterGripOneTrigger;
// myKeyTable[StellaEvent::KCODE_] = Event::BoosterGripOneBooster;
myKeyTable[StellaEvent::KCODE_6] = Event::BoosterGripOneTrigger;
myKeyTable[StellaEvent::KCODE_7] = Event::BoosterGripOneBooster;
myKeyTable[StellaEvent::KCODE_INSERT] = Event::DrivingZeroCounterClockwise;
myKeyTable[StellaEvent::KCODE_PAGEUP] = Event::DrivingZeroClockwise;
myKeyTable[StellaEvent::KCODE_HOME] = Event::DrivingZeroFire;
myKeyTable[StellaEvent::KCODE_DELETE] = Event::DrivingOneCounterClockwise;
myKeyTable[StellaEvent::KCODE_PAGEDOWN] = Event::DrivingOneClockwise;
myKeyTable[StellaEvent::KCODE_END] = Event::DrivingOneFire;
myKeyTable[StellaEvent::KCODE_F1] = Event::ConsoleSelect;
myKeyTable[StellaEvent::KCODE_F2] = Event::ConsoleReset;
@ -313,11 +317,6 @@ void EventHandler::setDefaultKeymap()
myKeyTable[StellaEvent::KCODE_PAUSE] = Event::Pause;
myKeyTable[StellaEvent::KCODE_ESCAPE] = Event::Quit;
#if 0
DrivingZeroClockwise, DrivingZeroCounterClockwise, DrivingZeroFire,
DrivingOneClockwise, DrivingOneCounterClockwise, DrivingOneFire,
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -418,7 +417,7 @@ void EventHandler::takeSnapshot()
// Now save the snapshot file
string filename = myConsole->settings().snapshotFilename();
myConsole->snapshot().savePNG(filename, myConsole->mediaSource(),
myConsole->settings().getInt("zoom"));
myConsole->settings().getInt("zoom")); // FIXME - update zoom in resizewindow
myConsole->gui().showMessage("Snapshot saved");
#else

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.hxx,v 1.9 2003-09-28 21:59:24 stephena Exp $
// $Id: EventHandler.hxx,v 1.10 2003-09-30 01:22:45 stephena Exp $
//============================================================================
#ifndef EVENTHANDLER_HXX
@ -41,7 +41,7 @@ class MediaSource;
mapping can take place.
@author Stephen Anthony
@version $Id: EventHandler.hxx,v 1.9 2003-09-28 21:59:24 stephena Exp $
@version $Id: EventHandler.hxx,v 1.10 2003-09-30 01:22:45 stephena Exp $
*/
class EventHandler
{
@ -111,8 +111,8 @@ class EventHandler
*/
string getJoymap();
void getKeymapArray(Event::Type** array, uInt32* sizex);
void getJoymapArray(Event::Type** array, uInt32* sizex, uInt32* sizey);
void getKeymapArray(Event::Type** array, uInt32* size);
void getJoymapArray(Event::Type** array, uInt32* size);
private:
void setKeymap();

View File

@ -13,9 +13,11 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: UserInterface.cxx,v 1.6 2003-09-29 18:10:56 stephena Exp $
// $Id: UserInterface.cxx,v 1.7 2003-09-30 01:22:45 stephena Exp $
//============================================================================
#include <sstream>
#include "bspf.hxx"
#include "Console.hxx"
#include "Event.hxx"
@ -97,7 +99,7 @@ UserInterface::UserInterface(Console* console, MediaSource* mediasrc)
// Get the arrays containing key and joystick mappings
myConsole->eventHandler().getKeymapArray(&myKeyTable, &myKeyTableSize);
// myConsole->eventHandler().getJoymapArray(&myJoyTable, &jsize);
myConsole->eventHandler().getJoymapArray(&myJoyTable, &myJoyTableSize);
loadRemapMenu();
}
@ -154,6 +156,10 @@ cerr << "'" << ourRemapMenu[myRemapMenuIndex].action << "' selected for remappin
moveCursorUp();
else if(key == StellaEvent::KCODE_DOWN)
moveCursorDown();
else if(key == StellaEvent::KCODE_PAGEUP)
movePageUp();
else if(key == StellaEvent::KCODE_PAGEDOWN)
movePageDown();
else if(key == StellaEvent::KCODE_ESCAPE)
myCurrentWidget = MAIN_MENU;
@ -174,6 +180,46 @@ cerr << "'" << ourRemapMenu[myRemapMenuIndex].action << "' selected for remappin
void UserInterface::sendJoyEvent(StellaEvent::JoyStick stick,
StellaEvent::JoyCode code, Int32 state)
{
if(myCurrentWidget == W_NONE || state != 1)
return;
cerr << "stick = " << stick << ", button = " << code << endl;
// Check which type of widget is pending
switch(myCurrentWidget)
{
case MAIN_MENU:
// if(key == StellaEvent::KCODE_RETURN)
// myCurrentWidget = currentSelectedWidget();
if(stick == StellaEvent::JSTICK_0 && code == StellaEvent::JAXIS_UP)
moveCursorUp();
else if(stick == StellaEvent::JSTICK_0 && code == StellaEvent::JAXIS_DOWN)
moveCursorDown();
break; // MAIN_MENU
case REMAP_MENU:
if(myRemapEventSelectedFlag)
{
addJoyBinding(mySelectedEvent, stick, code);
myRemapEventSelectedFlag = false;
}
else if(stick == StellaEvent::JSTICK_0 && code == StellaEvent::JAXIS_UP)
moveCursorUp();
else if(stick == StellaEvent::JSTICK_0 && code == StellaEvent::JAXIS_DOWN)
moveCursorDown();
// else if(key == StellaEvent::KCODE_PAGEUP)
// movePageUp();
// else if(key == StellaEvent::KCODE_PAGEDOWN)
// movePageDown();
// else if(key == StellaEvent::KCODE_ESCAPE)
// myCurrentWidget = MAIN_MENU;
break; // REMAP_MENU
default:
break;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -297,7 +343,6 @@ void UserInterface::moveCursorUp()
if(myRemapMenuIndex > myRemapMenuLowIndex)
{
myRemapMenuIndex--;
cerr << "'" << ourRemapMenu[myRemapMenuIndex].action << "'\n";
}
else if(myRemapMenuIndex == myRemapMenuLowIndex)
{
@ -306,7 +351,6 @@ cerr << "'" << ourRemapMenu[myRemapMenuIndex].action << "'\n";
myRemapMenuLowIndex--;
myRemapMenuHighIndex--;
myRemapMenuIndex--;
cerr << "'" << ourRemapMenu[myRemapMenuIndex].action << "'\n";
}
}
@ -334,7 +378,6 @@ void UserInterface::moveCursorDown()
if(myRemapMenuIndex < myRemapMenuHighIndex - 1)
{
myRemapMenuIndex++;
cerr << "'" << ourRemapMenu[myRemapMenuIndex].action << "'\n";
}
else if(myRemapMenuIndex == myRemapMenuHighIndex - 1)
{
@ -343,7 +386,6 @@ cerr << "'" << ourRemapMenu[myRemapMenuIndex].action << "'\n";
myRemapMenuLowIndex++;
myRemapMenuHighIndex++;
myRemapMenuIndex++;
cerr << "'" << ourRemapMenu[myRemapMenuIndex].action << "'\n";
}
}
@ -354,6 +396,70 @@ cerr << "'" << ourRemapMenu[myRemapMenuIndex].action << "'\n";
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::movePageUp()
{
switch(myCurrentWidget)
{
case MAIN_MENU:
break;
case REMAP_MENU:
if(myRemapMenuLowIndex < myMaxLines)
{
myRemapMenuLowIndex = 0;
myRemapMenuHighIndex = myMaxLines;
}
else
{
myRemapMenuLowIndex -= myMaxLines;
myRemapMenuHighIndex -= myMaxLines;
}
// Don't scroll the cursor if it falls within the screen
if(myRemapMenuIndex < myRemapMenuLowIndex ||
myRemapMenuIndex > myRemapMenuHighIndex-1)
myRemapMenuIndex = myRemapMenuHighIndex - 1;
break;
default: // This should never happen
break;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::movePageDown()
{
switch(myCurrentWidget)
{
case MAIN_MENU:
break;
case REMAP_MENU:
if(myRemapMenuHighIndex + myMaxLines >= myRemapMenuItems)
{
myRemapMenuHighIndex = myRemapMenuItems;
myRemapMenuLowIndex = myRemapMenuHighIndex - myMaxLines;
}
else
{
myRemapMenuLowIndex += myMaxLines;
myRemapMenuHighIndex += myMaxLines;
}
// Don't scroll the cursor if it falls within the screen
if(myRemapMenuIndex < myRemapMenuLowIndex ||
myRemapMenuIndex > myRemapMenuHighIndex-1)
myRemapMenuIndex = myRemapMenuLowIndex;
break;
default: // This should never happen
break;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::showMessage(const string& message)
{
@ -403,7 +509,7 @@ void UserInterface::drawText(uInt32 xorig, uInt32 yorig, const string& message)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::loadRemapMenu()
{
// Fill the remap menu with the current key mappings
// Fill the remap menu with the current key and joystick mappings
for(uInt32 i = 0; i < myRemapMenuItems; ++i)
{
Event::Type event = ourRemapMenu[i].event;
@ -417,10 +523,26 @@ void UserInterface::loadRemapMenu()
key = key + ourEventName[j];
else
key = key + ", " + ourEventName[j];
ourRemapMenu[i].key = key;
}
}
for(uInt32 j = 0; j < myJoyTableSize; ++j)
{
if(myJoyTable[j] == event)
{
ostringstream joyevent;
uInt32 stick = j / StellaEvent::LastJCODE;
uInt32 button = j % StellaEvent::LastJCODE;
joyevent << "Joy " << stick << " B" << button;
if(key == "")
key = key + joyevent.str();
else
key = key + ", " + joyevent.str();
}
}
if(key != "")
ourRemapMenu[i].key = key;
}
}
@ -432,6 +554,15 @@ void UserInterface::addKeyBinding(Event::Type event, StellaEvent::KeyCode key)
loadRemapMenu();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::addJoyBinding(Event::Type event,
StellaEvent::JoyStick stick, StellaEvent::JoyCode code)
{
myJoyTable[stick * StellaEvent::LastJCODE + code] = event;
loadRemapMenu();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void UserInterface::deleteBinding(Event::Type event)
{
@ -439,6 +570,10 @@ void UserInterface::deleteBinding(Event::Type event)
if(myKeyTable[i] == event)
myKeyTable[i] = Event::NoType;
for(uInt32 j = 0; j < myJoyTableSize; ++j)
if(myJoyTable[j] == event)
myJoyTable[j] = Event::NoType;
loadRemapMenu();
}
@ -461,34 +596,72 @@ UserInterface::MainMenuItem UserInterface::ourMainMenu[2] = {
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
UserInterface::RemapMenuItem UserInterface::ourRemapMenu[23] = {
{ Event::ConsoleSelect, "Select", "" },
{ Event::ConsoleReset, "Reset", "" },
{ Event::ConsoleColor, "Color TV", "" },
{ Event::ConsoleBlackWhite, "B/W TV", "" },
{ Event::ConsoleLeftDifficultyB, "P1 Diff. B", "" },
{ Event::ConsoleLeftDifficultyA, "P1 Diff. A", "" },
{ Event::ConsoleRightDifficultyB, "P2 Diff. B", "" },
{ Event::ConsoleRightDifficultyA, "P2 Diff. A", "" },
{ Event::SaveState, "Save State", "" },
{ Event::ChangeState, "Change State", "" },
{ Event::LoadState, "Load State", "" },
{ Event::TakeSnapshot, "Snapshot", "" },
{ Event::Pause, "Pause", "" },
UserInterface::RemapMenuItem UserInterface::ourRemapMenu[57] = {
{ Event::ConsoleSelect, "Select", "" },
{ Event::ConsoleReset, "Reset", "" },
{ Event::ConsoleColor, "Color TV", "" },
{ Event::ConsoleBlackWhite, "B/W TV", "" },
{ Event::ConsoleLeftDifficultyB, "Left Diff. B", "" },
{ Event::ConsoleLeftDifficultyA, "Left Diff. A", "" },
{ Event::ConsoleRightDifficultyB, "Right Diff. B", "" },
{ Event::ConsoleRightDifficultyA, "Right Diff. A", "" },
{ Event::SaveState, "Save State", "" },
{ Event::ChangeState, "Change State", "" },
{ Event::LoadState, "Load State", "" },
{ Event::TakeSnapshot, "Snapshot", "" },
{ Event::Pause, "Pause", "" },
{ Event::JoystickZeroUp, "P1 Up", "" },
{ Event::JoystickZeroDown, "P1 Down", "" },
{ Event::JoystickZeroLeft, "P1 Left", "" },
{ Event::JoystickZeroRight, "P1 Right", "" },
{ Event::JoystickZeroFire, "P1 Fire", "" },
{ Event::JoystickZeroUp, "Left-Joy Up", "" },
{ Event::JoystickZeroDown, "Left-Joy Down", "" },
{ Event::JoystickZeroLeft, "Left-Joy Left", "" },
{ Event::JoystickZeroRight, "Left-Joy Right", "" },
{ Event::JoystickZeroFire, "Left-Joy Fire", "" },
{ Event::JoystickOneUp, "P2 Up", "" },
{ Event::JoystickOneDown, "P2 Down", "" },
{ Event::JoystickOneLeft, "P2 Left", "" },
{ Event::JoystickOneRight, "P2 Right", "" },
{ Event::JoystickOneFire, "P2 Fire", "" }
{ Event::JoystickOneUp, "Right-Joy Up", "" },
{ Event::JoystickOneDown, "Right-Joy Down", "" },
{ Event::JoystickOneLeft, "Right-Joy Left", "" },
{ Event::JoystickOneRight, "Right-Joy Right", "" },
{ Event::JoystickOneFire, "Right-Joy Fire", "" },
// { Event::, "" },
{ Event::BoosterGripZeroTrigger, "Left-BGrip Trigger", "" },
{ Event::BoosterGripZeroBooster, "Left-BGrip Booster", "" },
{ Event::BoosterGripOneTrigger, "Right-BGrip Trigger", "" },
{ Event::BoosterGripOneBooster, "Right-BGrip Booster", "" },
{ Event::DrivingZeroCounterClockwise, "Left-Driving Left", "" },
{ Event::DrivingZeroClockwise, "Left-Driving Right", "" },
{ Event::DrivingZeroFire, "Left-Driving Fire", "" },
{ Event::DrivingOneCounterClockwise, "Right-Driving Left", "" },
{ Event::DrivingOneClockwise, "Right-Driving Right", "" },
{ Event::DrivingOneFire, "Right-Driving Fire", "" },
{ Event::KeyboardZero1, "Left-Pad 1", "" },
{ Event::KeyboardZero2, "Left-Pad 2", "" },
{ Event::KeyboardZero3, "Left-Pad 3", "" },
{ Event::KeyboardZero4, "Left-Pad 4", "" },
{ Event::KeyboardZero5, "Left-Pad 5", "" },
{ Event::KeyboardZero6, "Left-Pad 6", "" },
{ Event::KeyboardZero7, "Left-Pad 7", "" },
{ Event::KeyboardZero8, "Left-Pad 8", "" },
{ Event::KeyboardZero9, "Left-Pad 9", "" },
{ Event::KeyboardZeroStar, "Left-Pad *", "" },
{ Event::KeyboardZero0, "Left-Pad 0", "" },
{ Event::KeyboardZeroPound, "Left-Pad #", "" },
{ Event::KeyboardOne1, "Right-Pad 1", "" },
{ Event::KeyboardOne2, "Right-Pad 2", "" },
{ Event::KeyboardOne3, "Right-Pad 3", "" },
{ Event::KeyboardOne4, "Right-Pad 4", "" },
{ Event::KeyboardOne5, "Right-Pad 5", "" },
{ Event::KeyboardOne6, "Right-Pad 6", "" },
{ Event::KeyboardOne7, "Right-Pad 7", "" },
{ Event::KeyboardOne8, "Right-Pad 8", "" },
{ Event::KeyboardOne9, "Right-Pad 9", "" },
{ Event::KeyboardOneStar, "Right-Pad *", "" },
{ Event::KeyboardOne0, "Right-Pad 0", "" },
{ Event::KeyboardOnePound, "Right-Pad #", "" }
};
/**

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: UserInterface.hxx,v 1.5 2003-09-28 21:59:24 stephena Exp $
// $Id: UserInterface.hxx,v 1.6 2003-09-30 01:22:45 stephena Exp $
//============================================================================
#ifndef USERINTERFACE_HXX
@ -31,7 +31,7 @@ class MediaSource;
can be changed.
@author Stephen Anthony
@version $Id: UserInterface.hxx,v 1.5 2003-09-28 21:59:24 stephena Exp $
@version $Id: UserInterface.hxx,v 1.6 2003-09-30 01:22:45 stephena Exp $
*/
class UserInterface
{
@ -79,9 +79,18 @@ class UserInterface
Widget currentSelectedWidget();
Event::Type currentSelectedEvent();
// Move the cursor up 1 line, possibly scrolling the list of items
void moveCursorUp();
// Move the cursor down 1 line, possibly scrolling the list of items
void moveCursorDown();
// Move the list up 1 page and put the cursor at the top
void movePageUp();
// Move the list down 1 page and put the cursor at the top
void movePageDown();
// Draw a bounded box at the specified coordinates
void drawBoundedBox(uInt32 x, uInt32 y, uInt32 width, uInt32 height);
@ -94,6 +103,10 @@ class UserInterface
// Add binding between a StellaEvent key and a core event
void addKeyBinding(Event::Type event, StellaEvent::KeyCode key);
// Add binding between a StellaEvent joystick and a core event
void addJoyBinding(Event::Type event, StellaEvent::JoyStick stick,
StellaEvent::JoyCode code);
// Remove all bindings for this core event
void deleteBinding(Event::Type event);
@ -164,7 +177,7 @@ class UserInterface
static MainMenuItem ourMainMenu[2];
// Holds static strings for the remap menu
static RemapMenuItem ourRemapMenu[23];
static RemapMenuItem ourRemapMenu[57];
// Holds the current key mappings
Event::Type* myKeyTable;