2005-05-04 21:32:25 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
|
|
|
// SSSS tt ee ee ll ll aa
|
|
|
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
|
|
|
// SS SS tt ee ll ll aa aa
|
|
|
|
// SSSS ttt eeeee llll llll aaaaa
|
|
|
|
//
|
2014-01-12 17:23:42 +00:00
|
|
|
// Copyright (c) 1995-2014 by Bradford W. Mott, Stephen Anthony
|
2010-04-10 21:37:23 +00:00
|
|
|
// and the Stella Team
|
2005-05-04 21:32:25 +00:00
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
2005-05-04 21:32:25 +00:00
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
2009-05-13 13:55:40 +00:00
|
|
|
// $Id$
|
2005-05-04 21:32:25 +00:00
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#include "OSystem.hxx"
|
|
|
|
#include "Dialog.hxx"
|
|
|
|
#include "Stack.hxx"
|
2005-05-26 15:43:44 +00:00
|
|
|
#include "EventHandler.hxx"
|
2008-05-11 21:18:35 +00:00
|
|
|
#include "Joystick.hxx"
|
2005-05-04 21:32:25 +00:00
|
|
|
#include "bspf.hxx"
|
|
|
|
#include "DialogContainer.hxx"
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
DialogContainer::DialogContainer(OSystem* osystem)
|
2005-08-11 19:12:39 +00:00
|
|
|
: myOSystem(osystem),
|
|
|
|
myBaseDialog(NULL),
|
2008-12-28 21:01:55 +00:00
|
|
|
myTime(0)
|
2005-05-04 21:32:25 +00:00
|
|
|
{
|
2005-12-24 22:09:36 +00:00
|
|
|
reset();
|
2005-05-04 21:32:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
DialogContainer::~DialogContainer()
|
|
|
|
{
|
|
|
|
if(myBaseDialog)
|
|
|
|
delete myBaseDialog;
|
|
|
|
}
|
|
|
|
|
2005-05-26 15:43:44 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2009-07-01 14:39:01 +00:00
|
|
|
void DialogContainer::updateTime(uInt64 time)
|
2005-05-26 15:43:44 +00:00
|
|
|
{
|
|
|
|
// We only need millisecond precision
|
|
|
|
myTime = time / 1000;
|
|
|
|
|
|
|
|
if(myDialogStack.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Check for pending continuous events and send them to the active dialog box
|
|
|
|
Dialog* activeDialog = myDialogStack.top();
|
|
|
|
|
2006-05-25 22:23:39 +00:00
|
|
|
// Key still pressed
|
2005-05-26 15:43:44 +00:00
|
|
|
if(myCurrentKeyDown.keycode != 0 && myKeyRepeatTime < myTime)
|
|
|
|
{
|
2014-06-10 16:43:35 +00:00
|
|
|
activeDialog->handleKeyDown(myCurrentKeyDown.keycode, myCurrentKeyDown.flags);
|
2006-05-25 22:23:39 +00:00
|
|
|
myKeyRepeatTime = myTime + kRepeatSustainDelay;
|
2005-05-26 15:43:44 +00:00
|
|
|
}
|
|
|
|
|
2006-05-25 22:23:39 +00:00
|
|
|
// Mouse button still pressed
|
2005-05-26 15:43:44 +00:00
|
|
|
if(myCurrentMouseDown.button != -1 && myClickRepeatTime < myTime)
|
|
|
|
{
|
|
|
|
activeDialog->handleMouseDown(myCurrentMouseDown.x - activeDialog->_x,
|
|
|
|
myCurrentMouseDown.y - activeDialog->_y,
|
|
|
|
myCurrentMouseDown.button, 1);
|
2006-05-25 22:23:39 +00:00
|
|
|
myClickRepeatTime = myTime + kRepeatSustainDelay;
|
2005-05-26 15:43:44 +00:00
|
|
|
}
|
2005-12-24 22:09:36 +00:00
|
|
|
|
2006-05-25 22:23:39 +00:00
|
|
|
// Joystick button still pressed
|
|
|
|
if(myCurrentButtonDown.stick != -1 && myButtonRepeatTime < myTime)
|
2006-01-04 01:24:17 +00:00
|
|
|
{
|
2006-05-25 22:23:39 +00:00
|
|
|
activeDialog->handleJoyDown(myCurrentButtonDown.stick, myCurrentButtonDown.button);
|
|
|
|
myButtonRepeatTime = myTime + kRepeatSustainDelay;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Joystick axis still pressed
|
|
|
|
if(myCurrentAxisDown.stick != -1 && myAxisRepeatTime < myTime)
|
|
|
|
{
|
|
|
|
activeDialog->handleJoyAxis(myCurrentAxisDown.stick, myCurrentAxisDown.axis,
|
|
|
|
myCurrentAxisDown.value);
|
|
|
|
myAxisRepeatTime = myTime + kRepeatSustainDelay;
|
2006-01-04 01:24:17 +00:00
|
|
|
}
|
Modified joystick axis event handling, so that digital output is always used
when sending axis events to the DialogContainer (ie, all UI-related stuff).
The UI code was originally written with this in mind, and wasn't designed for
analog input. For normal digital sticks, nothing changes. For analog sticks,
values are clamped to 3 points (max, min, off), and repeated consecutive
events are ignored. This (partially) fixes bugs in the UI, where pressing
an analog stick would cause the current selector to move very fast.
Added repeat mode for joystick hats, similar to joystick axes (so holding
down a hat will cause continuous events to occur. More testing is
required for this, as I don't actually have access to hats right now.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2058 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2010-07-02 19:17:57 +00:00
|
|
|
|
|
|
|
// Joystick hat still pressed
|
|
|
|
if(myCurrentHatDown.stick != -1 && myHatRepeatTime < myTime)
|
|
|
|
{
|
|
|
|
activeDialog->handleJoyHat(myCurrentHatDown.stick, myCurrentHatDown.hat,
|
|
|
|
myCurrentHatDown.value);
|
|
|
|
myHatRepeatTime = myTime + kRepeatSustainDelay;
|
|
|
|
}
|
2005-05-26 15:43:44 +00:00
|
|
|
}
|
|
|
|
|
2005-05-04 21:32:25 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2008-12-27 23:27:32 +00:00
|
|
|
void DialogContainer::draw(bool full)
|
2005-05-04 21:32:25 +00:00
|
|
|
{
|
2005-08-01 22:33:16 +00:00
|
|
|
// Draw all the dialogs on the stack when we want a full refresh
|
2008-12-27 23:27:32 +00:00
|
|
|
if(full)
|
2005-05-04 21:32:25 +00:00
|
|
|
{
|
2005-08-01 22:33:16 +00:00
|
|
|
for(int i = 0; i < myDialogStack.size(); i++)
|
|
|
|
{
|
2008-12-21 19:51:35 +00:00
|
|
|
myDialogStack[i]->center();
|
2005-08-11 19:12:39 +00:00
|
|
|
myDialogStack[i]->setDirty();
|
2005-08-01 22:33:16 +00:00
|
|
|
myDialogStack[i]->drawDialog();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(!myDialogStack.empty())
|
|
|
|
myDialogStack.top()->drawDialog();
|
2005-05-04 21:32:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2013-05-01 16:56:43 +00:00
|
|
|
void DialogContainer::addDialog(Dialog* d)
|
2005-05-04 21:32:25 +00:00
|
|
|
{
|
|
|
|
myDialogStack.push(d);
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2013-05-01 16:56:43 +00:00
|
|
|
void DialogContainer::removeDialog()
|
2005-05-04 21:32:25 +00:00
|
|
|
{
|
|
|
|
if(!myDialogStack.empty())
|
|
|
|
myDialogStack.pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void DialogContainer::reStack()
|
|
|
|
{
|
|
|
|
// Pop all items from the stack, and then add the base menu
|
|
|
|
while(!myDialogStack.empty())
|
2013-04-24 20:30:16 +00:00
|
|
|
myDialogStack.top()->close(false); // don't force a refresh
|
|
|
|
|
|
|
|
myBaseDialog->open(false); // don't force a refresh
|
|
|
|
|
|
|
|
myOSystem->frameBuffer().refresh();
|
2005-05-16 15:37:30 +00:00
|
|
|
|
2005-05-26 15:43:44 +00:00
|
|
|
// Reset all continuous events
|
2005-12-24 22:09:36 +00:00
|
|
|
reset();
|
2005-05-04 21:32:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2014-06-10 16:43:35 +00:00
|
|
|
void DialogContainer::handleTextEvent(char text)
|
|
|
|
{
|
|
|
|
if(myDialogStack.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Send the event to the dialog box on the top of the stack
|
|
|
|
Dialog* activeDialog = myDialogStack.top();
|
|
|
|
activeDialog->handleText(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void DialogContainer::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
|
2005-05-04 21:32:25 +00:00
|
|
|
{
|
|
|
|
if(myDialogStack.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Send the event to the dialog box on the top of the stack
|
|
|
|
Dialog* activeDialog = myDialogStack.top();
|
2012-01-14 22:00:54 +00:00
|
|
|
if(state)
|
2005-05-26 15:43:44 +00:00
|
|
|
{
|
|
|
|
myCurrentKeyDown.keycode = key;
|
|
|
|
myCurrentKeyDown.flags = mod;
|
2006-05-25 22:23:39 +00:00
|
|
|
myKeyRepeatTime = myTime + kRepeatInitialDelay;
|
2005-05-26 15:43:44 +00:00
|
|
|
|
2014-06-10 16:43:35 +00:00
|
|
|
activeDialog->handleKeyDown(key, mod);
|
2005-05-26 15:43:44 +00:00
|
|
|
}
|
2005-05-04 21:32:25 +00:00
|
|
|
else
|
2005-05-26 15:43:44 +00:00
|
|
|
{
|
2014-06-10 16:43:35 +00:00
|
|
|
activeDialog->handleKeyUp(key, mod);
|
2005-05-26 15:43:44 +00:00
|
|
|
|
|
|
|
// Only stop firing events if it's the current key
|
|
|
|
if (key == myCurrentKeyDown.keycode)
|
2012-01-14 22:00:54 +00:00
|
|
|
myCurrentKeyDown.keycode = KBDK_UNKNOWN;
|
2005-05-26 15:43:44 +00:00
|
|
|
}
|
2005-05-04 21:32:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-05-13 18:28:06 +00:00
|
|
|
void DialogContainer::handleMouseMotionEvent(int x, int y, int button)
|
2005-05-04 21:32:25 +00:00
|
|
|
{
|
|
|
|
if(myDialogStack.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Send the event to the dialog box on the top of the stack
|
|
|
|
Dialog* activeDialog = myDialogStack.top();
|
2008-06-13 13:14:52 +00:00
|
|
|
activeDialog->surface().translateCoords(x, y);
|
2005-05-04 21:32:25 +00:00
|
|
|
activeDialog->handleMouseMoved(x - activeDialog->_x,
|
|
|
|
y - activeDialog->_y,
|
|
|
|
button);
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2014-02-15 21:37:29 +00:00
|
|
|
void DialogContainer::handleMouseButtonEvent(MouseButton b, int x, int y)
|
2005-05-04 21:32:25 +00:00
|
|
|
{
|
|
|
|
if(myDialogStack.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Send the event to the dialog box on the top of the stack
|
|
|
|
Dialog* activeDialog = myDialogStack.top();
|
2008-06-13 13:14:52 +00:00
|
|
|
activeDialog->surface().translateCoords(x, y);
|
2005-05-04 21:32:25 +00:00
|
|
|
|
2005-08-31 19:15:10 +00:00
|
|
|
int button = (b == EVENT_LBUTTONDOWN || b == EVENT_LBUTTONUP) ? 1 : 2;
|
2005-05-04 21:32:25 +00:00
|
|
|
switch(b)
|
|
|
|
{
|
|
|
|
case EVENT_LBUTTONDOWN:
|
|
|
|
case EVENT_RBUTTONDOWN:
|
|
|
|
// If more than two clicks have been recorded, we start over
|
|
|
|
if(myLastClick.count == 2)
|
|
|
|
{
|
|
|
|
myLastClick.x = myLastClick.y = 0;
|
|
|
|
myLastClick.time = 0;
|
|
|
|
myLastClick.count = 0;
|
|
|
|
}
|
|
|
|
|
2005-05-26 15:43:44 +00:00
|
|
|
if(myLastClick.count && (myTime < myLastClick.time + kDoubleClickDelay)
|
2007-07-31 15:46:21 +00:00
|
|
|
&& BSPF_abs(myLastClick.x - x) < 3
|
|
|
|
&& BSPF_abs(myLastClick.y - y) < 3)
|
2005-05-04 21:32:25 +00:00
|
|
|
{
|
|
|
|
myLastClick.count++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
myLastClick.x = x;
|
|
|
|
myLastClick.y = y;
|
|
|
|
myLastClick.count = 1;
|
|
|
|
}
|
2005-05-26 15:43:44 +00:00
|
|
|
myLastClick.time = myTime;
|
|
|
|
|
More cleanups to the UI.
Context menus, both as right-mouse button popups and those part of
PopupWidgets now have arrows that support scrolling, without having to
continuously click the mouse button. The scroll arrow color also
changes to disabled when they reach the upper or lower range.
Also, the maximum number of items shown in a ContextMenu is now 16,
which looks quite a bit nicer than showing 30 or so all at once.
ScrollBarWidget now looks a little nicer, as the scroll bar is a little
wider, and the arrows are larger (same ones from ContextMenu). As well,
click and hold works on the scroll buttons, even during mouse movement.
This means you no longer have to hold the mouse completely still to
get continuous mouse click events.
Dialogs can now register whether they want to receive continuous mouse
click events (aka, click and hold of a mouse button). Most dialogs
don't need it, and some even work incorrectly when it's activated.
This fixes a bug in ContextMenu, where click and hold on a PopupWidget
would continuously open and close the list of items.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2080 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2010-07-30 17:25:28 +00:00
|
|
|
// Now account for repeated mouse events (click and hold), but only
|
|
|
|
// if the dialog wants them
|
|
|
|
if(activeDialog->handleMouseClicks(x - activeDialog->_x, y - activeDialog->_y,
|
|
|
|
button))
|
|
|
|
{
|
|
|
|
myCurrentMouseDown.x = x;
|
|
|
|
myCurrentMouseDown.y = y;
|
|
|
|
myCurrentMouseDown.button = button;
|
|
|
|
myClickRepeatTime = myTime + kRepeatInitialDelay;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
myCurrentMouseDown.button = -1;
|
2005-05-26 15:43:44 +00:00
|
|
|
|
2005-05-04 21:32:25 +00:00
|
|
|
activeDialog->handleMouseDown(x - activeDialog->_x, y - activeDialog->_y,
|
2005-08-31 19:15:10 +00:00
|
|
|
button, myLastClick.count);
|
2005-05-04 21:32:25 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EVENT_LBUTTONUP:
|
|
|
|
case EVENT_RBUTTONUP:
|
|
|
|
activeDialog->handleMouseUp(x - activeDialog->_x, y - activeDialog->_y,
|
2005-08-31 19:15:10 +00:00
|
|
|
button, myLastClick.count);
|
|
|
|
|
|
|
|
if(button == myCurrentMouseDown.button)
|
|
|
|
myCurrentMouseDown.button = -1;
|
2005-05-04 21:32:25 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EVENT_WHEELUP:
|
|
|
|
activeDialog->handleMouseWheel(x - activeDialog->_x, y - activeDialog->_y, -1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EVENT_WHEELDOWN:
|
|
|
|
activeDialog->handleMouseWheel(x - activeDialog->_x, y - activeDialog->_y, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-05-25 23:22:11 +00:00
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2005-05-26 15:43:44 +00:00
|
|
|
void DialogContainer::handleJoyEvent(int stick, int button, uInt8 state)
|
2005-05-25 23:22:11 +00:00
|
|
|
{
|
|
|
|
if(myDialogStack.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Send the event to the dialog box on the top of the stack
|
|
|
|
Dialog* activeDialog = myDialogStack.top();
|
2005-12-24 22:09:36 +00:00
|
|
|
|
Huge GUI-related changes. The GUI in launcher/options/command modes
is now fully navigable via the keyboard be means of 'tab-like'
functionality. This means that eventually systems without a keyboard
will also be able to navigate the interface without resorting to the
buggy joymouse code (which is soon to be removed).
Laid the infrastructure for remapping GUI events, whereby (for example)
a widget checks for Event::UISelect for 'doing its thing', vs. looking
at the Enter/Return key. So widgets now respond to events, and events
can (eventually) be remapped to *any* device.
Currently, these UI events are as follows:
UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect
At present, they're hardcoded to key events only, so pressing 'Return'
will send a UISelect, cursor up a UIUp, etc. When the remapping code
is complete, *any* input will be able to send these events, and that
remapping will be distinct from emulation mode. So, for example,
cursor up in GUI mode might generate a UIUp event, but in emulation
mode might generate a left joystick up event.
Modified 'tab' key while in emulation mode to only enter the options
menu. Once inside the menu, the tab key acts as navigation between
elements, and exiting the options menu requires navigating to the
'Exit menu' button.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1100 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-05-04 17:45:25 +00:00
|
|
|
if(state == 1)
|
2006-05-25 22:23:39 +00:00
|
|
|
{
|
|
|
|
myCurrentButtonDown.stick = stick;
|
|
|
|
myCurrentButtonDown.button = button;
|
|
|
|
myButtonRepeatTime = myTime + kRepeatInitialDelay;
|
|
|
|
|
Huge GUI-related changes. The GUI in launcher/options/command modes
is now fully navigable via the keyboard be means of 'tab-like'
functionality. This means that eventually systems without a keyboard
will also be able to navigate the interface without resorting to the
buggy joymouse code (which is soon to be removed).
Laid the infrastructure for remapping GUI events, whereby (for example)
a widget checks for Event::UISelect for 'doing its thing', vs. looking
at the Enter/Return key. So widgets now respond to events, and events
can (eventually) be remapped to *any* device.
Currently, these UI events are as follows:
UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect
At present, they're hardcoded to key events only, so pressing 'Return'
will send a UISelect, cursor up a UIUp, etc. When the remapping code
is complete, *any* input will be able to send these events, and that
remapping will be distinct from emulation mode. So, for example,
cursor up in GUI mode might generate a UIUp event, but in emulation
mode might generate a left joystick up event.
Modified 'tab' key while in emulation mode to only enter the options
menu. Once inside the menu, the tab key acts as navigation between
elements, and exiting the options menu requires navigating to the
'Exit menu' button.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1100 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-05-04 17:45:25 +00:00
|
|
|
activeDialog->handleJoyDown(stick, button);
|
2006-05-25 22:23:39 +00:00
|
|
|
}
|
Huge GUI-related changes. The GUI in launcher/options/command modes
is now fully navigable via the keyboard be means of 'tab-like'
functionality. This means that eventually systems without a keyboard
will also be able to navigate the interface without resorting to the
buggy joymouse code (which is soon to be removed).
Laid the infrastructure for remapping GUI events, whereby (for example)
a widget checks for Event::UISelect for 'doing its thing', vs. looking
at the Enter/Return key. So widgets now respond to events, and events
can (eventually) be remapped to *any* device.
Currently, these UI events are as follows:
UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect
At present, they're hardcoded to key events only, so pressing 'Return'
will send a UISelect, cursor up a UIUp, etc. When the remapping code
is complete, *any* input will be able to send these events, and that
remapping will be distinct from emulation mode. So, for example,
cursor up in GUI mode might generate a UIUp event, but in emulation
mode might generate a left joystick up event.
Modified 'tab' key while in emulation mode to only enter the options
menu. Once inside the menu, the tab key acts as navigation between
elements, and exiting the options menu requires navigating to the
'Exit menu' button.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1100 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-05-04 17:45:25 +00:00
|
|
|
else
|
2006-05-25 22:23:39 +00:00
|
|
|
{
|
|
|
|
// Only stop firing events if it's the current button
|
|
|
|
if(stick == myCurrentButtonDown.stick)
|
|
|
|
myCurrentButtonDown.stick = myCurrentButtonDown.button = -1;
|
|
|
|
|
Huge GUI-related changes. The GUI in launcher/options/command modes
is now fully navigable via the keyboard be means of 'tab-like'
functionality. This means that eventually systems without a keyboard
will also be able to navigate the interface without resorting to the
buggy joymouse code (which is soon to be removed).
Laid the infrastructure for remapping GUI events, whereby (for example)
a widget checks for Event::UISelect for 'doing its thing', vs. looking
at the Enter/Return key. So widgets now respond to events, and events
can (eventually) be remapped to *any* device.
Currently, these UI events are as follows:
UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect
At present, they're hardcoded to key events only, so pressing 'Return'
will send a UISelect, cursor up a UIUp, etc. When the remapping code
is complete, *any* input will be able to send these events, and that
remapping will be distinct from emulation mode. So, for example,
cursor up in GUI mode might generate a UIUp event, but in emulation
mode might generate a left joystick up event.
Modified 'tab' key while in emulation mode to only enter the options
menu. Once inside the menu, the tab key acts as navigation between
elements, and exiting the options menu requires navigating to the
'Exit menu' button.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1100 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-05-04 17:45:25 +00:00
|
|
|
activeDialog->handleJoyUp(stick, button);
|
2006-05-25 22:23:39 +00:00
|
|
|
}
|
2005-05-25 23:22:11 +00:00
|
|
|
}
|
2005-12-07 02:33:56 +00:00
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void DialogContainer::handleJoyAxisEvent(int stick, int axis, int value)
|
|
|
|
{
|
2005-12-07 20:46:49 +00:00
|
|
|
if(myDialogStack.empty())
|
|
|
|
return;
|
|
|
|
|
Huge GUI-related changes. The GUI in launcher/options/command modes
is now fully navigable via the keyboard be means of 'tab-like'
functionality. This means that eventually systems without a keyboard
will also be able to navigate the interface without resorting to the
buggy joymouse code (which is soon to be removed).
Laid the infrastructure for remapping GUI events, whereby (for example)
a widget checks for Event::UISelect for 'doing its thing', vs. looking
at the Enter/Return key. So widgets now respond to events, and events
can (eventually) be remapped to *any* device.
Currently, these UI events are as follows:
UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect
At present, they're hardcoded to key events only, so pressing 'Return'
will send a UISelect, cursor up a UIUp, etc. When the remapping code
is complete, *any* input will be able to send these events, and that
remapping will be distinct from emulation mode. So, for example,
cursor up in GUI mode might generate a UIUp event, but in emulation
mode might generate a left joystick up event.
Modified 'tab' key while in emulation mode to only enter the options
menu. Once inside the menu, the tab key acts as navigation between
elements, and exiting the options menu requires navigating to the
'Exit menu' button.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1100 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-05-04 17:45:25 +00:00
|
|
|
// Only stop firing events if it's the current stick
|
|
|
|
if(myCurrentAxisDown.stick == stick && value == 0)
|
2006-01-04 01:24:17 +00:00
|
|
|
{
|
Huge GUI-related changes. The GUI in launcher/options/command modes
is now fully navigable via the keyboard be means of 'tab-like'
functionality. This means that eventually systems without a keyboard
will also be able to navigate the interface without resorting to the
buggy joymouse code (which is soon to be removed).
Laid the infrastructure for remapping GUI events, whereby (for example)
a widget checks for Event::UISelect for 'doing its thing', vs. looking
at the Enter/Return key. So widgets now respond to events, and events
can (eventually) be remapped to *any* device.
Currently, these UI events are as follows:
UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect
At present, they're hardcoded to key events only, so pressing 'Return'
will send a UISelect, cursor up a UIUp, etc. When the remapping code
is complete, *any* input will be able to send these events, and that
remapping will be distinct from emulation mode. So, for example,
cursor up in GUI mode might generate a UIUp event, but in emulation
mode might generate a left joystick up event.
Modified 'tab' key while in emulation mode to only enter the options
menu. Once inside the menu, the tab key acts as navigation between
elements, and exiting the options menu requires navigating to the
'Exit menu' button.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1100 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-05-04 17:45:25 +00:00
|
|
|
myCurrentAxisDown.stick = myCurrentAxisDown.axis = -1;
|
2006-01-04 01:24:17 +00:00
|
|
|
}
|
2010-07-08 16:32:32 +00:00
|
|
|
else if(value != 0) // never repeat the 'off' event
|
2005-12-24 22:09:36 +00:00
|
|
|
{
|
Huge GUI-related changes. The GUI in launcher/options/command modes
is now fully navigable via the keyboard be means of 'tab-like'
functionality. This means that eventually systems without a keyboard
will also be able to navigate the interface without resorting to the
buggy joymouse code (which is soon to be removed).
Laid the infrastructure for remapping GUI events, whereby (for example)
a widget checks for Event::UISelect for 'doing its thing', vs. looking
at the Enter/Return key. So widgets now respond to events, and events
can (eventually) be remapped to *any* device.
Currently, these UI events are as follows:
UIUp, UIDown, UILeft, UIRight, UIHome, UIEnd, UIPgUp, UIPgDown,
UIPrevDir, UINavNext, UINavPrev, UITabNext, UITabPrev, UISelect
At present, they're hardcoded to key events only, so pressing 'Return'
will send a UISelect, cursor up a UIUp, etc. When the remapping code
is complete, *any* input will be able to send these events, and that
remapping will be distinct from emulation mode. So, for example,
cursor up in GUI mode might generate a UIUp event, but in emulation
mode might generate a left joystick up event.
Modified 'tab' key while in emulation mode to only enter the options
menu. Once inside the menu, the tab key acts as navigation between
elements, and exiting the options menu requires navigating to the
'Exit menu' button.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1100 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2006-05-04 17:45:25 +00:00
|
|
|
// Now account for repeated axis events (press and hold)
|
|
|
|
myCurrentAxisDown.stick = stick;
|
|
|
|
myCurrentAxisDown.axis = axis;
|
|
|
|
myCurrentAxisDown.value = value;
|
2006-05-25 22:23:39 +00:00
|
|
|
myAxisRepeatTime = myTime + kRepeatInitialDelay;
|
2005-12-24 22:09:36 +00:00
|
|
|
}
|
Modified joystick axis event handling, so that digital output is always used
when sending axis events to the DialogContainer (ie, all UI-related stuff).
The UI code was originally written with this in mind, and wasn't designed for
analog input. For normal digital sticks, nothing changes. For analog sticks,
values are clamped to 3 points (max, min, off), and repeated consecutive
events are ignored. This (partially) fixes bugs in the UI, where pressing
an analog stick would cause the current selector to move very fast.
Added repeat mode for joystick hats, similar to joystick axes (so holding
down a hat will cause continuous events to occur. More testing is
required for this, as I don't actually have access to hats right now.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2058 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2010-07-02 19:17:57 +00:00
|
|
|
myDialogStack.top()->handleJoyAxis(stick, axis, value);
|
2005-12-24 22:09:36 +00:00
|
|
|
}
|
|
|
|
|
2006-01-09 16:50:01 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2010-07-07 14:19:45 +00:00
|
|
|
void DialogContainer::handleJoyHatEvent(int stick, int hat, JoyHat value)
|
2006-01-09 16:50:01 +00:00
|
|
|
{
|
2006-01-09 19:30:04 +00:00
|
|
|
if(myDialogStack.empty())
|
|
|
|
return;
|
|
|
|
|
Modified joystick axis event handling, so that digital output is always used
when sending axis events to the DialogContainer (ie, all UI-related stuff).
The UI code was originally written with this in mind, and wasn't designed for
analog input. For normal digital sticks, nothing changes. For analog sticks,
values are clamped to 3 points (max, min, off), and repeated consecutive
events are ignored. This (partially) fixes bugs in the UI, where pressing
an analog stick would cause the current selector to move very fast.
Added repeat mode for joystick hats, similar to joystick axes (so holding
down a hat will cause continuous events to occur. More testing is
required for this, as I don't actually have access to hats right now.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2058 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2010-07-02 19:17:57 +00:00
|
|
|
// Only stop firing events if it's the current stick
|
2010-07-07 14:19:45 +00:00
|
|
|
if(myCurrentHatDown.stick == stick && value == EVENT_HATCENTER)
|
Modified joystick axis event handling, so that digital output is always used
when sending axis events to the DialogContainer (ie, all UI-related stuff).
The UI code was originally written with this in mind, and wasn't designed for
analog input. For normal digital sticks, nothing changes. For analog sticks,
values are clamped to 3 points (max, min, off), and repeated consecutive
events are ignored. This (partially) fixes bugs in the UI, where pressing
an analog stick would cause the current selector to move very fast.
Added repeat mode for joystick hats, similar to joystick axes (so holding
down a hat will cause continuous events to occur. More testing is
required for this, as I don't actually have access to hats right now.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2058 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2010-07-02 19:17:57 +00:00
|
|
|
{
|
|
|
|
myCurrentHatDown.stick = myCurrentHatDown.hat = -1;
|
|
|
|
}
|
2010-07-08 16:32:32 +00:00
|
|
|
else if(value != EVENT_HATCENTER) // never repeat the 'center' direction
|
Modified joystick axis event handling, so that digital output is always used
when sending axis events to the DialogContainer (ie, all UI-related stuff).
The UI code was originally written with this in mind, and wasn't designed for
analog input. For normal digital sticks, nothing changes. For analog sticks,
values are clamped to 3 points (max, min, off), and repeated consecutive
events are ignored. This (partially) fixes bugs in the UI, where pressing
an analog stick would cause the current selector to move very fast.
Added repeat mode for joystick hats, similar to joystick axes (so holding
down a hat will cause continuous events to occur. More testing is
required for this, as I don't actually have access to hats right now.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2058 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2010-07-02 19:17:57 +00:00
|
|
|
{
|
|
|
|
// Now account for repeated hat events (press and hold)
|
|
|
|
myCurrentHatDown.stick = stick;
|
|
|
|
myCurrentHatDown.hat = hat;
|
|
|
|
myCurrentHatDown.value = value;
|
|
|
|
myHatRepeatTime = myTime + kRepeatInitialDelay;
|
|
|
|
}
|
|
|
|
myDialogStack.top()->handleJoyHat(stick, hat, value);
|
2005-12-24 22:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void DialogContainer::reset()
|
|
|
|
{
|
2012-01-14 22:00:54 +00:00
|
|
|
myCurrentKeyDown.keycode = KBDK_UNKNOWN;
|
2005-12-24 22:09:36 +00:00
|
|
|
myCurrentMouseDown.button = -1;
|
|
|
|
myLastClick.x = myLastClick.y = 0;
|
|
|
|
myLastClick.time = 0;
|
|
|
|
myLastClick.count = 0;
|
|
|
|
|
2006-05-25 22:23:39 +00:00
|
|
|
myCurrentButtonDown.stick = myCurrentButtonDown.button = -1;
|
2006-01-04 01:24:17 +00:00
|
|
|
myCurrentAxisDown.stick = myCurrentAxisDown.axis = -1;
|
2006-05-25 22:23:39 +00:00
|
|
|
myCurrentHatDown.stick = myCurrentHatDown.hat = -1;
|
2005-12-07 02:33:56 +00:00
|
|
|
}
|