mirror of https://github.com/stella-emu/stella.git
fix combined modifier handling (finally :-)
make more hotkeys configurable
This commit is contained in:
parent
bb7c3c429c
commit
ef8fdc8cd9
|
@ -98,12 +98,12 @@ string KeyMap::getDesc(const Mapping& mapping) const
|
||||||
else if (mapping.mod & KBDM_LCTRL) buf << "Left " << modifier;
|
else if (mapping.mod & KBDM_LCTRL) buf << "Left " << modifier;
|
||||||
else if (mapping.mod & KBDM_RCTRL) buf << "Right " << modifier;
|
else if (mapping.mod & KBDM_RCTRL) buf << "Right " << modifier;
|
||||||
|
|
||||||
if ((mapping.mod & KBDM_ALT) && buf.tellp()) buf << "+";
|
if ((mapping.mod & (KBDM_ALT)) && buf.tellp()) buf << "+";
|
||||||
if ((mapping.mod & KBDM_ALT) == KBDM_ALT) buf << "Alt";
|
if ((mapping.mod & KBDM_ALT) == KBDM_ALT) buf << "Alt";
|
||||||
else if (mapping.mod & KBDM_LALT) buf << "Left Alt";
|
else if (mapping.mod & KBDM_LALT) buf << "Left Alt";
|
||||||
else if (mapping.mod & KBDM_RALT) buf << "Right Alt";
|
else if (mapping.mod & KBDM_RALT) buf << "Right Alt";
|
||||||
|
|
||||||
if ((mapping.mod & KBDM_SHIFT) && buf.tellp()) buf << "+";
|
if ((mapping.mod & (KBDM_SHIFT)) && buf.tellp()) buf << "+";
|
||||||
if ((mapping.mod & KBDM_SHIFT) == KBDM_SHIFT) buf << "Shift";
|
if ((mapping.mod & KBDM_SHIFT) == KBDM_SHIFT) buf << "Shift";
|
||||||
else if (mapping.mod & KBDM_LSHIFT) buf << "Left Shift";
|
else if (mapping.mod & KBDM_LSHIFT) buf << "Left Shift";
|
||||||
else if (mapping.mod & KBDM_RSHIFT) buf << "Right Shift";
|
else if (mapping.mod & KBDM_RSHIFT) buf << "Right Shift";
|
||||||
|
@ -151,8 +151,6 @@ std::vector<KeyMap::Mapping> KeyMap::getEventMapping(const Event::Type event, co
|
||||||
if (item.second == event && item.first.mode == mode)
|
if (item.second == event && item.first.mode == mode)
|
||||||
map.push_back(item.first);
|
map.push_back(item.first);
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,8 +219,10 @@ KeyMap::Mapping KeyMap::convertMod(const Mapping& mapping) const
|
||||||
// handle solo modifier keys differently
|
// handle solo modifier keys differently
|
||||||
m.mod = KBDM_NONE;
|
m.mod = KBDM_NONE;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
// limit to modifiers we want to support
|
// limit to modifiers we want to support
|
||||||
m.mod = StellaMod(m.mod & (KBDM_SHIFT | KBDM_ALT | KBDM_CTRL));
|
m.mod = StellaMod(m.mod & (KBDM_SHIFT | KBDM_ALT | KBDM_CTRL));
|
||||||
|
}
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,10 +47,12 @@ class KeyMap
|
||||||
|
|
||||||
bool operator==(const Mapping& other) const
|
bool operator==(const Mapping& other) const
|
||||||
{
|
{
|
||||||
return (//&& mod == other.mod
|
return (key == other.key
|
||||||
(mod | other.mod ? mod & other.mod : true)
|
|
||||||
&& mode == other.mode
|
&& mode == other.mode
|
||||||
&& key == other.key);
|
&& (((mod | other.mod) & KBDM_SHIFT) ? (mod & other.mod & KBDM_SHIFT) : true)
|
||||||
|
&& (((mod | other.mod) & KBDM_ALT ) ? (mod & other.mod & KBDM_ALT ) : true)
|
||||||
|
&& (((mod | other.mod) & KBDM_CTRL ) ? (mod & other.mod & KBDM_CTRL ) : true)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -99,12 +101,11 @@ class KeyMap
|
||||||
|
|
||||||
struct KeyHash {
|
struct KeyHash {
|
||||||
size_t operator()(const Mapping& m)const {
|
size_t operator()(const Mapping& m)const {
|
||||||
return std::hash<uInt64>()((uInt64(m.mode)) // 1 bit
|
return std::hash<uInt64>()((uInt64(m.mode)) // 1 bit
|
||||||
^ ((uInt64(m.key)) << 1) // 8 bits
|
^ ((uInt64(m.key)) << 1) // 8 bits
|
||||||
// no mod in hash to allow mapping left and right modifiers as one
|
^ ((uInt64((m.mod & KBDM_SHIFT) != 0) << 9)) // 1 bit
|
||||||
// also see '==' above
|
^ ((uInt64((m.mod & KBDM_ALT ) != 0) << 10)) // 1 bit
|
||||||
/* ^ ((uInt64(m.mod)) << 9)*/); // 15 bits
|
^ ((uInt64((m.mod & KBDM_CTRL ) != 0) << 11))); // 1 bit
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -174,6 +174,22 @@ void PhysicalKeyboardHandler::setDefaultMapping(Event::Type event, EventMode mod
|
||||||
setDefaultKey(Event::DecreaseAttribute , KBDK_0, KBDM_SHIFT | KBDM_ALT);
|
setDefaultKey(Event::DecreaseAttribute , KBDK_0, KBDM_SHIFT | KBDM_ALT);
|
||||||
setDefaultKey(Event::IncreaseAttribute , KBDK_0, KBDM_ALT);
|
setDefaultKey(Event::IncreaseAttribute , KBDK_0, KBDM_ALT);
|
||||||
|
|
||||||
|
setDefaultKey(Event::ToggleP0Collision , KBDK_Z, KBDM_SHIFT | KBDM_ALT);
|
||||||
|
setDefaultKey(Event::ToggleP0Bit , KBDK_Z, KBDM_ALT);
|
||||||
|
setDefaultKey(Event::ToggleP1Collision , KBDK_X, KBDM_SHIFT | KBDM_ALT);
|
||||||
|
setDefaultKey(Event::ToggleP1Bit , KBDK_X, KBDM_ALT);
|
||||||
|
setDefaultKey(Event::ToggleM0Collision , KBDK_C, KBDM_SHIFT | KBDM_ALT);
|
||||||
|
setDefaultKey(Event::ToggleM0Bit , KBDK_C, KBDM_ALT);
|
||||||
|
setDefaultKey(Event::ToggleM1Collision , KBDK_V, KBDM_SHIFT | KBDM_ALT);
|
||||||
|
setDefaultKey(Event::ToggleM1Bit , KBDK_V, KBDM_ALT);
|
||||||
|
setDefaultKey(Event::ToggleBLCollision , KBDK_B, KBDM_SHIFT | KBDM_ALT);
|
||||||
|
setDefaultKey(Event::ToggleBLBit , KBDK_B, KBDM_ALT);
|
||||||
|
setDefaultKey(Event::TogglePFCollision , KBDK_N, KBDM_SHIFT | KBDM_ALT);
|
||||||
|
setDefaultKey(Event::TogglePFBit , KBDK_N, KBDM_ALT);
|
||||||
|
setDefaultKey(Event::ToggleFixedColors , KBDK_COMMA, KBDM_ALT);
|
||||||
|
setDefaultKey(Event::ToggleCollisions , KBDK_PERIOD, KBDM_SHIFT | KBDM_ALT);
|
||||||
|
setDefaultKey(Event::ToggleBits , KBDK_PERIOD, KBDM_ALT);
|
||||||
|
|
||||||
// FIXME - use the R77 define in the final release
|
// FIXME - use the R77 define in the final release
|
||||||
// use the '1' define for testing
|
// use the '1' define for testing
|
||||||
#if defined(RETRON77)
|
#if defined(RETRON77)
|
||||||
|
@ -386,59 +402,6 @@ bool PhysicalKeyboardHandler::handleAltEvent(StellaKey key, StellaMod mod, bool
|
||||||
myOSystem.console().changeYStart(-1);
|
myOSystem.console().changeYStart(-1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KBDK_Z:
|
|
||||||
if(StellaModTest::isShift(mod))
|
|
||||||
myOSystem.console().toggleP0Collision();
|
|
||||||
else
|
|
||||||
myOSystem.console().toggleP0Bit();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case KBDK_X:
|
|
||||||
if(StellaModTest::isShift(mod))
|
|
||||||
myOSystem.console().toggleP1Collision();
|
|
||||||
else
|
|
||||||
myOSystem.console().toggleP1Bit();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case KBDK_C:
|
|
||||||
if(StellaModTest::isShift(mod))
|
|
||||||
myOSystem.console().toggleM0Collision();
|
|
||||||
else
|
|
||||||
myOSystem.console().toggleM0Bit();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case KBDK_V:
|
|
||||||
if(StellaModTest::isShift(mod))
|
|
||||||
myOSystem.console().toggleM1Collision();
|
|
||||||
else
|
|
||||||
myOSystem.console().toggleM1Bit();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case KBDK_B:
|
|
||||||
if(StellaModTest::isShift(mod))
|
|
||||||
myOSystem.console().toggleBLCollision();
|
|
||||||
else
|
|
||||||
myOSystem.console().toggleBLBit();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case KBDK_N:
|
|
||||||
if(StellaModTest::isShift(mod))
|
|
||||||
myOSystem.console().togglePFCollision();
|
|
||||||
else
|
|
||||||
myOSystem.console().togglePFBit();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case KBDK_COMMA:
|
|
||||||
myOSystem.console().toggleFixedColors();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case KBDK_PERIOD:
|
|
||||||
if(StellaModTest::isShift(mod))
|
|
||||||
myOSystem.console().toggleCollisions();
|
|
||||||
else
|
|
||||||
myOSystem.console().toggleBits();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case KBDK_I: // Alt-i decreases phosphor blend
|
case KBDK_I: // Alt-i decreases phosphor blend
|
||||||
myOSystem.console().changePhosphor(-1);
|
myOSystem.console().changePhosphor(-1);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -87,6 +87,11 @@ class Event
|
||||||
PreviousAttribute, NextAttribute, DecreaseAttribute, IncreaseAttribute,
|
PreviousAttribute, NextAttribute, DecreaseAttribute, IncreaseAttribute,
|
||||||
ScanlinesDecrease, ScanlinesIncrease,
|
ScanlinesDecrease, ScanlinesIncrease,
|
||||||
|
|
||||||
|
ToggleP0Collision, ToggleP0Bit, ToggleP1Collision, ToggleP1Bit,
|
||||||
|
ToggleM0Collision, ToggleM0Bit, ToggleM1Collision, ToggleM1Bit,
|
||||||
|
ToggleBLCollision, ToggleBLBit, TogglePFCollision, TogglePFBit,
|
||||||
|
ToggleCollisions, ToggleBits, ToggleFixedColors,
|
||||||
|
|
||||||
LastType
|
LastType
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -477,6 +477,81 @@ void EventHandler::handleEvent(Event::Type event, bool pressed)
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case Event::ToggleP0Collision:
|
||||||
|
if (pressed)
|
||||||
|
myOSystem.console().toggleP0Collision();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case Event::ToggleP0Bit:
|
||||||
|
if (pressed)
|
||||||
|
myOSystem.console().toggleP0Bit();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case Event::ToggleP1Collision:
|
||||||
|
if (pressed)
|
||||||
|
myOSystem.console().toggleP1Collision();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case Event::ToggleP1Bit:
|
||||||
|
if (pressed)
|
||||||
|
myOSystem.console().toggleP1Bit();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case Event::ToggleM0Collision:
|
||||||
|
if (pressed)
|
||||||
|
myOSystem.console().toggleM0Collision();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case Event::ToggleM0Bit:
|
||||||
|
if (pressed)
|
||||||
|
myOSystem.console().toggleM0Bit();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case Event::ToggleM1Collision:
|
||||||
|
if (pressed)
|
||||||
|
myOSystem.console().toggleM1Collision();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case Event::ToggleM1Bit:
|
||||||
|
if (pressed)
|
||||||
|
myOSystem.console().toggleM1Bit();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case Event::ToggleBLCollision:
|
||||||
|
if (pressed)
|
||||||
|
myOSystem.console().toggleBLCollision();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case Event::ToggleBLBit:
|
||||||
|
if (pressed)
|
||||||
|
myOSystem.console().toggleBLBit();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case Event::TogglePFCollision:
|
||||||
|
if (pressed)
|
||||||
|
myOSystem.console().togglePFCollision();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case Event::TogglePFBit:
|
||||||
|
if (pressed)
|
||||||
|
myOSystem.console().togglePFBit();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case Event::ToggleFixedColors:
|
||||||
|
if (pressed)
|
||||||
|
myOSystem.console().toggleFixedColors();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case Event::ToggleCollisions:
|
||||||
|
if (pressed)
|
||||||
|
myOSystem.console().toggleCollisions();
|
||||||
|
return;
|
||||||
|
|
||||||
|
case Event::ToggleBits:
|
||||||
|
if (pressed)
|
||||||
|
myOSystem.console().toggleBits();
|
||||||
|
return;
|
||||||
|
|
||||||
case Event::SaveState:
|
case Event::SaveState:
|
||||||
if(pressed) myOSystem.state().saveState();
|
if(pressed) myOSystem.state().saveState();
|
||||||
return;
|
return;
|
||||||
|
@ -1469,7 +1544,23 @@ EventHandler::ActionList EventHandler::ourEmulActionList[EMUL_ACTIONLIST_SIZE] =
|
||||||
{ Event::Combo13, "Combo 13", "", false },
|
{ Event::Combo13, "Combo 13", "", false },
|
||||||
{ Event::Combo14, "Combo 14", "", false },
|
{ Event::Combo14, "Combo 14", "", false },
|
||||||
{ Event::Combo15, "Combo 15", "", false },
|
{ Event::Combo15, "Combo 15", "", false },
|
||||||
{ Event::Combo16, "Combo 16", "", false }
|
{ Event::Combo16, "Combo 16", "", false },
|
||||||
|
|
||||||
|
{ Event::ToggleP0Bit, "Toggle TIA Player0 object", "", false },
|
||||||
|
{ Event::ToggleP0Collision, "Toggle TIA Player0 collisions", "", false },
|
||||||
|
{ Event::ToggleP1Bit, "Toggle TIA Player1 object", "", false },
|
||||||
|
{ Event::ToggleP1Collision, "Toggle TIA Player1 collisions", "", false },
|
||||||
|
{ Event::ToggleM0Bit, "Toggle TIA Missile0 object", "", false },
|
||||||
|
{ Event::ToggleM0Collision, "Toggle TIA Missile0 collisions", "", false },
|
||||||
|
{ Event::ToggleM1Bit, "Toggle TIA Missile1 object", "", false },
|
||||||
|
{ Event::ToggleM1Collision, "Toggle TIA Missile1 collisions", "", false },
|
||||||
|
{ Event::ToggleBLBit, "Toggle TIA Ball object", "", false },
|
||||||
|
{ Event::ToggleBLCollision, "Toggle TIA Ball collisions", "", false },
|
||||||
|
{ Event::TogglePFBit, "Toggle TIA Playfield object", "", false },
|
||||||
|
{ Event::TogglePFCollision, "Toggle TIA Playfield collisions","", false },
|
||||||
|
{ Event::ToggleFixedColors, "Toggle TIA 'Fixed Debug Colors' mode","", false },
|
||||||
|
{ Event::ToggleBits, "Toggle all TIA objects", "", false },
|
||||||
|
{ Event::ToggleCollisions, "Toggle all TIA collisions", "", false }
|
||||||
};
|
};
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -367,7 +367,7 @@ class EventHandler
|
||||||
static constexpr Int32
|
static constexpr Int32
|
||||||
COMBO_SIZE = 16,
|
COMBO_SIZE = 16,
|
||||||
EVENTS_PER_COMBO = 8,
|
EVENTS_PER_COMBO = 8,
|
||||||
EMUL_ACTIONLIST_SIZE = 98 + COMBO_SIZE,
|
EMUL_ACTIONLIST_SIZE = 113 + COMBO_SIZE,
|
||||||
MENU_ACTIONLIST_SIZE = 18
|
MENU_ACTIONLIST_SIZE = 18
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue