-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKeyboardSimulation.cpp
65 lines (61 loc) · 2.09 KB
/
KeyboardSimulation.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* File: KeyboardSimulation.cpp
* Author: Saleem Edah-Tally - [email protected]
* Licence : LGPL 2.1
* Copyright Saleem Edah-Tally, M.D. - © 2022
*
* Created on October 8, 2022, 3:43 PM
*/
#include "KeyboardSimulation.h"
KeyboardSimulation::KeyboardSimulation(PedalEVH * evh) {
m_pedalEVH = evh;
if (!m_pedalEVH)
return;
m_pedalEVH->m_owner->Bind(wxEVT_CHAR_HOOK, &KeyboardSimulation::OnKeyDown, this);
}
KeyboardSimulation::~KeyboardSimulation() {
}
void KeyboardSimulation::OnKeyDown(wxKeyEvent& evt) {
const int keycode = evt.GetKeyCode();
if (keycode != WXK_ESCAPE && keycode != WXK_F5
&& keycode != WXK_F6 && keycode != WXK_F7)
return;
// Stop current.
if (m_currentLeftStatus == PedalEvent::PRESSED) {
m_currentLeftStatus = PedalEvent::RELEASED;
m_pedalEVH->Left(m_currentLeftStatus);
}
if (m_currentMiddleStatus == PedalEvent::PRESSED) {
m_currentMiddleStatus = PedalEvent::RELEASED;
m_pedalEVH->Middle(m_currentMiddleStatus);
}
if (m_currentRightStatus == PedalEvent::PRESSED) {
m_currentRightStatus = PedalEvent::RELEASED;
m_pedalEVH->Right(m_currentRightStatus);
}
// Start new or stop all..
switch (keycode) {
case WXK_F5:
m_currentLeftStatus = PedalEvent::PRESSED;
m_pedalEVH->Left(m_currentLeftStatus);
break;
case WXK_F6:
m_currentMiddleStatus = PedalEvent::PRESSED;
m_pedalEVH->Middle(m_currentMiddleStatus);
break;
case WXK_F7:
m_currentRightStatus = PedalEvent::PRESSED;
m_pedalEVH->Right(m_currentRightStatus);
break;
case WXK_ESCAPE:
m_currentLeftStatus = PedalEvent::RELEASED;
m_pedalEVH->Left(m_currentLeftStatus);
m_currentMiddleStatus = PedalEvent::RELEASED;
m_pedalEVH->Middle(m_currentMiddleStatus);
m_currentRightStatus = PedalEvent::RELEASED;
m_pedalEVH->Right(m_currentRightStatus);
break;
default:
break;
}
}