Skip to content

Commit

Permalink
Fixed cut/copy/paste
Browse files Browse the repository at this point in the history
  • Loading branch information
tommitytom committed May 18, 2019
1 parent 0a8ecef commit a620cda
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/LsdjKeyMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ class LsdjKeyMap {
VirtualKey vk = (VirtualKey)key.VK;
ButtonType b = _gbKeyMap->getControllerButton(vk);

if (down && key.C) {
switch (vk) {
case VirtualKeys::X: cut(); return true;
case VirtualKeys::C: copy(); return true;
case VirtualKeys::V: paste(); return true;
}
}

switch (b) {
case ButtonTypes::Left:
case ButtonTypes::Right:
Expand All @@ -96,13 +104,7 @@ class LsdjKeyMap {
return true;
case ButtonTypes::MAX:
// Key press does not relate to a button but may still be used
if (down && key.C) {
switch (vk) {
case VirtualKeys::X: cut(); return true;
case VirtualKeys::C: copy(); return true;
case VirtualKeys::V: paste(); return true;
}
} else if (down) {
if (down) {
auto found = _actionMap.find(vk);
if (found != _actionMap.end()) {
if (_state == State::None) {
Expand All @@ -126,17 +128,15 @@ class LsdjKeyMap {

return false;
default:
// In selection mode, all button presses are ignored unless
// they are directional
if (_state == State::None) {
if (down) {
_presses.hold(b);
} else {
_presses.release(b);
}

return true;
}

return true;
}

return false;
Expand All @@ -159,22 +159,26 @@ class LsdjKeyMap {

ButtonQueue& copy() {
consoleLogLine("copy");
int delay = 0;
if (_state != State::Selecting) {
beginSelect();
delay = 150;
}

_state = State::None;
return _presses.press(ButtonTypes::B);
return _presses.press(ButtonTypes::B, delay);
}

ButtonQueue& cut() {
consoleLogLine("cut");
int delay = 0;
if (_state != State::Selecting) {
beginSelect();
delay = 150;
}

_state = State::None;
return _presses.pressModified(ButtonTypes::A, ButtonTypes::Select);
return _presses.pressModified(ButtonTypes::A, ButtonTypes::Select, delay);
}

ButtonQueue& paste() {
Expand Down

0 comments on commit a620cda

Please sign in to comment.