mirror of https://github.com/stella-emu/stella.git
Fixed ghost key issue with the CompuMate emulation. It seems that mixing
SDL keyboard events and the static GetKeyState() method doesn't always work as you'd expect. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2447 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
e1d31ada6e
commit
f853518540
|
@ -17,7 +17,9 @@
|
||||||
* Updated the CompuMate keyboard handler to recognize more keys on an
|
* Updated the CompuMate keyboard handler to recognize more keys on an
|
||||||
actual keyboard, instead of having to remember the weird combinations
|
actual keyboard, instead of having to remember the weird combinations
|
||||||
used on the original CompuMate keyboard (although those original keys
|
used on the original CompuMate keyboard (although those original keys
|
||||||
will continue to work).
|
will continue to work). Related to this, fixed bug whereby
|
||||||
|
'ghost keys' would be detected by the CompuMate, particularly after
|
||||||
|
pressing 'Enter' to start a game from the ROM launcher.
|
||||||
|
|
||||||
* Added emulation for MindLink controller using the mouse; the 'Bionic
|
* Added emulation for MindLink controller using the mouse; the 'Bionic
|
||||||
Breakthrough' and 'Telepathy' ROMs now work.
|
Breakthrough' and 'Telepathy' ROMs now work.
|
||||||
|
|
|
@ -312,16 +312,4 @@ typedef enum {
|
||||||
// The underlying code doesn't need to know how it's implemented
|
// The underlying code doesn't need to know how it's implemented
|
||||||
typedef int StellaMod;
|
typedef int StellaMod;
|
||||||
|
|
||||||
// Wrapper around the SDL_GetKeyState function
|
|
||||||
// This can be used as-is since KBDK keys and SDL keys are the same
|
|
||||||
class StellaKeys
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// According to the SDL source code, this only needs to be called
|
|
||||||
// once, since it points to an internal static variable in SDL
|
|
||||||
// As such, it's not really a (current) state table, since that
|
|
||||||
// implies it needs to be called each time you want the state updated
|
|
||||||
static inline uInt8* GetKeyTable() { return SDL_GetKeyState(NULL); }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* StellaKeys */
|
#endif /* StellaKeys */
|
||||||
|
|
|
@ -40,7 +40,7 @@ CompuMate::CompuMate(CartridgeCM& cart, const Event& event,
|
||||||
myRightController->myAnalogPinValue[Controller::Nine] = Controller::minimumResistance;
|
myRightController->myAnalogPinValue[Controller::Nine] = Controller::minimumResistance;
|
||||||
myRightController->myAnalogPinValue[Controller::Five] = Controller::maximumResistance;
|
myRightController->myAnalogPinValue[Controller::Five] = Controller::maximumResistance;
|
||||||
|
|
||||||
myKeyTable = StellaKeys::GetKeyTable();
|
myKeyTable = event.getKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -124,7 +124,7 @@ class CompuMate
|
||||||
CMControl *myLeftController, *myRightController;
|
CMControl *myLeftController, *myRightController;
|
||||||
|
|
||||||
// The keyboard state array (tells us the current state of the keyboard)
|
// The keyboard state array (tells us the current state of the keyboard)
|
||||||
uInt8* myKeyTable;
|
const bool* myKeyTable;
|
||||||
|
|
||||||
// System cycle at which the update() method is called
|
// System cycle at which the update() method is called
|
||||||
// Multiple calls at the same cycle should be ignored
|
// Multiple calls at the same cycle should be ignored
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#define EVENT_HXX
|
#define EVENT_HXX
|
||||||
|
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
#include "StellaKeys.hxx"
|
||||||
|
|
||||||
class Event;
|
class Event;
|
||||||
|
|
||||||
|
@ -107,11 +108,27 @@ class Event
|
||||||
{
|
{
|
||||||
for(uInt32 i = 0; i < LastType; ++i)
|
for(uInt32 i = 0; i < LastType; ++i)
|
||||||
myValues[i] = Event::NoType;
|
myValues[i] = Event::NoType;
|
||||||
|
|
||||||
|
for(uInt32 i = 0; i < KBDK_LAST; ++i)
|
||||||
|
myKeyTable[i] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the keytable associated with this event
|
||||||
|
*/
|
||||||
|
const bool* getKeys() const { return myKeyTable; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the value associated with the event of the specified type
|
||||||
|
*/
|
||||||
|
void setKey(StellaKey key, bool state) { myKeyTable[key] = state; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Array of values associated with each event type
|
// Array of values associated with each event type
|
||||||
Int32 myValues[LastType];
|
Int32 myValues[LastType];
|
||||||
|
|
||||||
|
// Array of keyboard key states
|
||||||
|
bool myKeyTable[KBDK_LAST];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -329,6 +329,9 @@ void EventHandler::poll(uInt64 time)
|
||||||
bool state = event.key.type == SDL_KEYDOWN;
|
bool state = event.key.type == SDL_KEYDOWN;
|
||||||
bool handled = true;
|
bool handled = true;
|
||||||
|
|
||||||
|
// Immediately store the key state
|
||||||
|
myEvent.setKey(key, state);
|
||||||
|
|
||||||
// An attempt to speed up event processing
|
// An attempt to speed up event processing
|
||||||
// All SDL-specific event actions are accessed by either
|
// All SDL-specific event actions are accessed by either
|
||||||
// Control or Alt/Cmd keys. So we quickly check for those.
|
// Control or Alt/Cmd keys. So we quickly check for those.
|
||||||
|
|
Loading…
Reference in New Issue