UI: Linux fixes for shortcuts + small tweaks
This commit is contained in:
parent
a4d06f683a
commit
49e74ccba2
8 changed files with 36 additions and 34 deletions
|
@ -763,7 +763,7 @@ public:
|
|||
if(_emulationSpeed == 0) {
|
||||
EmulationSettings::SetEmulationSpeed(_speedValues.back(), true);
|
||||
} else if(_emulationSpeed > _speedValues.front()) {
|
||||
for(size_t i = _speedValues.size() - 1; i >= 0; i--) {
|
||||
for(int i = (int)_speedValues.size() - 1; i >= 0; i--) {
|
||||
if(_speedValues[i] < _emulationSpeed) {
|
||||
EmulationSettings::SetEmulationSpeed(_speedValues[i], true);
|
||||
break;
|
||||
|
|
|
@ -50,9 +50,9 @@ bool ShortcutKeyHandler::IsKeyPressed(EmulatorShortcut shortcut)
|
|||
bool ShortcutKeyHandler::DetectKeyPress(EmulatorShortcut shortcut)
|
||||
{
|
||||
if(IsKeyPressed(shortcut)) {
|
||||
_keysDown[_keySetIndex].emplace(shortcut);
|
||||
_keysDown[_keySetIndex].emplace((uint32_t)shortcut);
|
||||
|
||||
if(_prevKeysDown[_keySetIndex].find(shortcut) == _prevKeysDown[_keySetIndex].end()) {
|
||||
if(_prevKeysDown[_keySetIndex].find((uint32_t)shortcut) == _prevKeysDown[_keySetIndex].end()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ bool ShortcutKeyHandler::DetectKeyPress(EmulatorShortcut shortcut)
|
|||
bool ShortcutKeyHandler::DetectKeyRelease(EmulatorShortcut shortcut)
|
||||
{
|
||||
if(!IsKeyPressed(shortcut)) {
|
||||
if(_prevKeysDown[_keySetIndex].find(shortcut) != _prevKeysDown[_keySetIndex].end()) {
|
||||
if(_prevKeysDown[_keySetIndex].find((uint32_t)shortcut) != _prevKeysDown[_keySetIndex].end()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,6 @@ void ShortcutKeyHandler::CheckMappedKeys()
|
|||
{
|
||||
bool isNetplayClient = GameClient::Connected();
|
||||
bool isMovieActive = MovieManager::Playing() || MovieManager::Recording();
|
||||
bool needConfirm = EmulationSettings::CheckFlag(ConfirmExitResetPower);
|
||||
|
||||
//Let the UI handle these shortcuts
|
||||
for(uint64_t i = (uint64_t)EmulatorShortcut::SwitchDiskSide; i <= (uint64_t)EmulatorShortcut::OpenTraceLogger; i++) {
|
||||
|
|
|
@ -15,8 +15,8 @@ private:
|
|||
int _keySetIndex;
|
||||
vector<uint32_t> _pressedKeys;
|
||||
|
||||
std::unordered_set<EmulatorShortcut> _keysDown[2];
|
||||
std::unordered_set<EmulatorShortcut> _prevKeysDown[2];
|
||||
std::unordered_set<uint32_t> _keysDown[2];
|
||||
std::unordered_set<uint32_t> _prevKeysDown[2];
|
||||
|
||||
void CheckMappedKeys();
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ namespace Mesen.GUI.Config
|
|||
ShortcutKeys1 = new List<ShortcutKeyInfo>();
|
||||
ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.FastForward, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("Tab") }));
|
||||
ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.Rewind, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("Backspace") }));
|
||||
ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.IncreaseSpeed, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("+") }));
|
||||
ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.IncreaseSpeed, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("=") }));
|
||||
ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.DecreaseSpeed, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("-") }));
|
||||
ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.MaxSpeed, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("F9") }));
|
||||
|
||||
|
|
|
@ -64,7 +64,6 @@
|
|||
this.gridShortcuts.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.gridShortcuts.Size = new System.Drawing.Size(448, 216);
|
||||
this.gridShortcuts.TabIndex = 2;
|
||||
this.gridShortcuts.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.gridShortcuts_CellContentClick);
|
||||
this.gridShortcuts.CellMouseDown += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.gridShortcuts_CellMouseDown);
|
||||
//
|
||||
// colAction
|
||||
|
|
|
@ -167,31 +167,25 @@ namespace Mesen.GUI.Forms.Config
|
|||
ConfigManager.Config.PreferenceInfo.ShortcutKeys2 = keySet2;
|
||||
}
|
||||
|
||||
private void gridShortcuts_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if(gridShortcuts.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) {
|
||||
DataGridViewButtonCell button = gridShortcuts.Rows[e.RowIndex].Cells[e.ColumnIndex] as DataGridViewButtonCell;
|
||||
if(button != null) {
|
||||
using(frmGetKey frm = new frmGetKey(false)) {
|
||||
frm.ShowDialog();
|
||||
button.Value = frm.ShortcutKey.ToString();
|
||||
button.Tag = frm.ShortcutKey;
|
||||
|
||||
CheckConflicts();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void gridShortcuts_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
|
||||
{
|
||||
//Right-click on buttons to clear mappings
|
||||
if(e.Button == MouseButtons.Right && gridShortcuts.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) {
|
||||
if(gridShortcuts.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) {
|
||||
DataGridViewButtonCell button = gridShortcuts.Rows[e.RowIndex].Cells[e.ColumnIndex] as DataGridViewButtonCell;
|
||||
if(button != null) {
|
||||
button.Value = "";
|
||||
button.Tag = new KeyCombination();
|
||||
CheckConflicts();
|
||||
if(e.Button == MouseButtons.Right) {
|
||||
button.Value = "";
|
||||
button.Tag = new KeyCombination();
|
||||
CheckConflicts();
|
||||
} else if(e.Button == MouseButtons.Left) {
|
||||
using(frmGetKey frm = new frmGetKey(false)) {
|
||||
frm.ShowDialog();
|
||||
button.Value = frm.ShortcutKey.ToString();
|
||||
button.Tag = frm.ShortcutKey;
|
||||
|
||||
CheckConflicts();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -177,6 +177,15 @@ namespace Mesen.GUI.Forms
|
|||
if(ConfigManager.Config.WindowSize.HasValue) {
|
||||
this.ClientSize = ConfigManager.Config.WindowSize.Value;
|
||||
}
|
||||
|
||||
if(Program.IsMono) {
|
||||
//Mono does not trigger the activate/deactivate events when opening a modal popup, but it does set the form to disabled
|
||||
//Use this to reset key states
|
||||
this.EnabledChanged += (object s, EventArgs evt) => {
|
||||
_removeFocus = !this.Enabled;
|
||||
InteropEmu.ResetKeyState();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDeactivate(EventArgs e)
|
||||
|
@ -472,6 +481,7 @@ namespace Mesen.GUI.Forms
|
|||
|
||||
private void BindShortcuts()
|
||||
{
|
||||
Func<bool> notClient = () => { return !InteropEmu.IsConnected(); };
|
||||
Func<bool> runningNotClient = () => { return _emuThread != null && !InteropEmu.IsConnected(); };
|
||||
Func<bool> runningNotClientNotMovie = () => { return _emuThread != null && !InteropEmu.IsConnected() && !InteropEmu.MoviePlaying() && !InteropEmu.MovieRecording(); };
|
||||
|
||||
|
@ -481,9 +491,9 @@ namespace Mesen.GUI.Forms
|
|||
|
||||
BindShortcut(mnuOpen, EmulatorShortcut.OpenFile);
|
||||
BindShortcut(mnuExit, EmulatorShortcut.Exit);
|
||||
BindShortcut(mnuIncreaseSpeed, EmulatorShortcut.IncreaseSpeed, runningNotClient);
|
||||
BindShortcut(mnuDecreaseSpeed, EmulatorShortcut.DecreaseSpeed, runningNotClient);
|
||||
BindShortcut(mnuEmuSpeedMaximumSpeed, EmulatorShortcut.MaxSpeed, runningNotClient);
|
||||
BindShortcut(mnuIncreaseSpeed, EmulatorShortcut.IncreaseSpeed, notClient);
|
||||
BindShortcut(mnuDecreaseSpeed, EmulatorShortcut.DecreaseSpeed, notClient);
|
||||
BindShortcut(mnuEmuSpeedMaximumSpeed, EmulatorShortcut.MaxSpeed, notClient);
|
||||
|
||||
BindShortcut(mnuPause, EmulatorShortcut.Pause, runningNotClient);
|
||||
BindShortcut(mnuReset, EmulatorShortcut.Reset, runningNotClientNotMovie);
|
||||
|
|
|
@ -111,7 +111,7 @@ static vector<KeyDefinition> _keyDefinitions = {
|
|||
{ "", 115, "End", "" },
|
||||
{ "", 116, "Down Arrow", "" },
|
||||
{ "", 117, "Next", "" },
|
||||
{ "", 118, "Insert", "" },
|
||||
{ "", 118, "Ins", "" },
|
||||
{ "", 119, "Delete", "" },
|
||||
{ "", 121, "XF86AudioMute", "" },
|
||||
{ "", 122, "XF86AudioLowerVolume", "" },
|
||||
|
@ -418,7 +418,7 @@ void LinuxKeyManager::ResetKeyState()
|
|||
memset(_keyState, 0, sizeof(_keyState));
|
||||
}
|
||||
|
||||
void WindowsKeyManager::SetDisabled(bool disabled)
|
||||
void LinuxKeyManager::SetDisabled(bool disabled)
|
||||
{
|
||||
_disableAllKeys = disabled;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue