style fixes
This commit is contained in:
@@ -16,17 +16,18 @@ InputHandler_Win32_MIDI::InputHandler_Win32_MIDI()
|
|||||||
{
|
{
|
||||||
int device_id = 0;
|
int device_id = 0;
|
||||||
|
|
||||||
MMRESULT result;
|
|
||||||
g_device = NULL;
|
g_device = NULL;
|
||||||
|
|
||||||
if (device_id >= midiInGetNumDevs()) {
|
if( device_id >= midiInGetNumDevs() )
|
||||||
|
{
|
||||||
m_bFoundDevice = false;
|
m_bFoundDevice = false;
|
||||||
return;
|
return;
|
||||||
} else
|
}
|
||||||
m_bFoundDevice = true;
|
m_bFoundDevice = true;
|
||||||
|
|
||||||
result = midiInOpen(&g_device, device_id, (DWORD)&(midiCallback), (DWORD)this, CALLBACK_FUNCTION);
|
MMRESULT result = midiInOpen(&g_device, device_id, (DWORD)&(midiCallback), (DWORD)this, CALLBACK_FUNCTION);
|
||||||
if (result != MMSYSERR_NOERROR) {
|
if( result != MMSYSERR_NOERROR )
|
||||||
|
{
|
||||||
char strError[256];
|
char strError[256];
|
||||||
midiOutGetErrorText( result, strError, 256 );
|
midiOutGetErrorText( result, strError, 256 );
|
||||||
LOG->Warn( "Error with MIDI Opening: %s", strError );
|
LOG->Warn( "Error with MIDI Opening: %s", strError );
|
||||||
@@ -34,7 +35,8 @@ InputHandler_Win32_MIDI::InputHandler_Win32_MIDI()
|
|||||||
}
|
}
|
||||||
|
|
||||||
result = midiInStart(g_device);
|
result = midiInStart(g_device);
|
||||||
if (result != MMSYSERR_NOERROR) {
|
if( result != MMSYSERR_NOERROR )
|
||||||
|
{
|
||||||
char strError[256];
|
char strError[256];
|
||||||
midiOutGetErrorText( result, strError, 256 );
|
midiOutGetErrorText( result, strError, 256 );
|
||||||
LOG->Warn( "Error with MIDI Starting: %s", strError );
|
LOG->Warn( "Error with MIDI Starting: %s", strError );
|
||||||
@@ -46,16 +48,18 @@ InputHandler_Win32_MIDI::~InputHandler_Win32_MIDI()
|
|||||||
{
|
{
|
||||||
MMRESULT result;
|
MMRESULT result;
|
||||||
|
|
||||||
result = midiInReset(g_device);
|
result = midiInReset( g_device );
|
||||||
if (result != MMSYSERR_NOERROR) {
|
if( result != MMSYSERR_NOERROR )
|
||||||
|
{
|
||||||
char strError[256];
|
char strError[256];
|
||||||
midiOutGetErrorText( result, strError, 256 );
|
midiOutGetErrorText( result, strError, 256 );
|
||||||
LOG->Warn( "Error with MIDI Reset: %s", strError );
|
LOG->Warn( "Error with MIDI Reset: %s", strError );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = midiInClose(g_device);
|
result = midiInClose( g_device );
|
||||||
if (result != MMSYSERR_NOERROR) {
|
if( result != MMSYSERR_NOERROR )
|
||||||
|
{
|
||||||
char strError[256];
|
char strError[256];
|
||||||
midiOutGetErrorText( result, strError, 256 );
|
midiOutGetErrorText( result, strError, 256 );
|
||||||
LOG->Warn( "Error with MIDI Close: %s", strError );
|
LOG->Warn( "Error with MIDI Close: %s", strError );
|
||||||
@@ -64,30 +68,32 @@ InputHandler_Win32_MIDI::~InputHandler_Win32_MIDI()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputHandler_Win32_MIDI::GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<CString>& vDescriptionsOut)
|
void InputHandler_Win32_MIDI::GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<CString>& vDescriptionsOut )
|
||||||
{
|
{
|
||||||
if ( m_bFoundDevice )
|
if( m_bFoundDevice )
|
||||||
{
|
{
|
||||||
vDevicesOut.push_back( InputDevice(DEVICE_MIDI) );
|
vDevicesOut.push_back( InputDevice(DEVICE_MIDI) );
|
||||||
vDescriptionsOut.push_back( "Win32_MIDI" );
|
vDescriptionsOut.push_back( "Win32_MIDI" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CALLBACK midiCallback(HMIDIIN g_device, UINT status, DWORD instancePtr, DWORD data, DWORD timestamp)
|
static void CALLBACK midiCallback( HMIDIIN device, UINT status, DWORD instancePtr, DWORD data, DWORD timestamp )
|
||||||
{
|
{
|
||||||
if (status == MIM_DATA) {
|
if( status == MIM_DATA )
|
||||||
int type = data & 0x00ff;
|
|
||||||
int channel = (data & 0xff00) >> 8;
|
|
||||||
int value = ( data & 0x00ff0000) >> 16;
|
|
||||||
|
|
||||||
//Channel 0 in midi is a special channel that generally will get triggerd when too many channels are pressed
|
|
||||||
if ( channel == 0 ) return;
|
|
||||||
|
|
||||||
if ( type == 144 )
|
|
||||||
{
|
{
|
||||||
DeviceInput di = DeviceInput(DEVICE_MIDI,channel);
|
int iType = data & 0xff;
|
||||||
|
int iChannel = (data & 0xff00) >> 8;
|
||||||
|
int iValue = (data & 0xff0000) >> 16;
|
||||||
|
|
||||||
|
// Channel 0 in midi is a special channel that generally will get triggerd when too many channels are pressed
|
||||||
|
if( iChannel == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( iType == 144 )
|
||||||
|
{
|
||||||
|
DeviceInput di = DeviceInput( DEVICE_MIDI, iChannel );
|
||||||
di.ts.Touch();
|
di.ts.Touch();
|
||||||
if ( value > 0 )
|
if( iValue > 0 )
|
||||||
((InputHandler_Win32_MIDI *)instancePtr)->SetDev( di, true );
|
((InputHandler_Win32_MIDI *)instancePtr)->SetDev( di, true );
|
||||||
else
|
else
|
||||||
((InputHandler_Win32_MIDI *)instancePtr)->SetDev( di, false );
|
((InputHandler_Win32_MIDI *)instancePtr)->SetDev( di, false );
|
||||||
|
|||||||
Reference in New Issue
Block a user