pckeyboard: Fake MIDI events

* on MIDI cable 0, channel 0
* instead of calling key[down|up]()
* derive from class CMIDIDevice
pull/50/head
Rene Stange 3 years ago
parent ff69fdc395
commit 04535c92e7
  1. 2
      src/minidexed.cpp
  2. 21
      src/pckeyboard.cpp
  3. 8
      src/pckeyboard.h

@ -37,7 +37,7 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt,
#endif
m_pConfig (pConfig),
m_UI (this, pGPIOManager, pConfig),
m_PCKeyboard (this),
m_PCKeyboard (this, pConfig),
m_SerialMIDI (this, pInterrupt, pConfig),
m_bUseSerial (false),
m_pSoundDevice (0),

@ -18,8 +18,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#include "pckeyboard.h"
#include "minidexed.h"
#include "config.h"
#include <circle/devicenameservice.h>
#include <circle/util.h>
#include <assert.h>
@ -62,8 +60,8 @@ static TKeyInfo KeyTable[] =
CPCKeyboard *CPCKeyboard::s_pThis = 0;
CPCKeyboard::CPCKeyboard (CMiniDexed *pSynthesizer)
: m_pSynthesizer (pSynthesizer),
CPCKeyboard::CPCKeyboard (CMiniDexed *pSynthesizer, CConfig *pConfig)
: CMIDIDevice (pSynthesizer, pConfig),
m_pKeyboard (0)
{
s_pThis = this;
@ -73,8 +71,6 @@ CPCKeyboard::CPCKeyboard (CMiniDexed *pSynthesizer)
CPCKeyboard::~CPCKeyboard (void)
{
m_pSynthesizer = 0;
s_pThis = 0;
}
@ -101,7 +97,6 @@ void CPCKeyboard::Process (boolean bPlugAndPlayUpdated)
void CPCKeyboard::KeyStatusHandlerRaw (unsigned char ucModifiers, const unsigned char RawKeys[6])
{
assert (s_pThis != 0);
assert (s_pThis->m_pSynthesizer != 0);
// report released keys
for (unsigned i = 0; i < 6; i++)
@ -113,10 +108,8 @@ void CPCKeyboard::KeyStatusHandlerRaw (unsigned char ucModifiers, const unsigned
u8 ucKeyNumber = GetKeyNumber (ucKeyCode);
if (ucKeyNumber != 0)
{
for (unsigned nTG = 0; nTG < CConfig::ToneGenerators; nTG++)
{
s_pThis->m_pSynthesizer->keyup (ucKeyNumber, nTG);
}
u8 NoteOff[] = {0x80, ucKeyNumber, 0};
s_pThis->MIDIMessageHandler (NoteOff, sizeof NoteOff);
}
}
}
@ -131,10 +124,8 @@ void CPCKeyboard::KeyStatusHandlerRaw (unsigned char ucModifiers, const unsigned
u8 ucKeyNumber = GetKeyNumber (ucKeyCode);
if (ucKeyNumber != 0)
{
for (unsigned nTG = 0; nTG < CConfig::ToneGenerators; nTG++)
{
s_pThis->m_pSynthesizer->keydown (ucKeyNumber, 100, nTG);
}
u8 NoteOn[] = {0x90, ucKeyNumber, 100};
s_pThis->MIDIMessageHandler (NoteOn, sizeof NoteOn);
}
}
}

@ -20,16 +20,18 @@
#ifndef _pckeyboard_h
#define _pckeyboard_h
#include "mididevice.h"
#include "config.h"
#include <circle/usb/usbkeyboard.h>
#include <circle/device.h>
#include <circle/types.h>
class CMiniDexed;
class CPCKeyboard
class CPCKeyboard : public CMIDIDevice
{
public:
CPCKeyboard (CMiniDexed *pSynthesizer);
CPCKeyboard (CMiniDexed *pSynthesizer, CConfig *pConfig);
~CPCKeyboard (void);
void Process (boolean bPlugAndPlayUpdated);
@ -44,8 +46,6 @@ private:
static void DeviceRemovedHandler (CDevice *pDevice, void *pContext);
private:
CMiniDexed *m_pSynthesizer;
CUSBKeyboardDevice * volatile m_pKeyboard;
u8 m_LastKeys[6];

Loading…
Cancel
Save