style fixes

This commit is contained in:
Glenn Maynard
2005-05-25 22:21:35 +00:00
parent 4ccc63fb42
commit 11595d2eff
@@ -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 );
@@ -47,7 +49,8 @@ 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 );
@@ -55,7 +58,8 @@ InputHandler_Win32_MIDI::~InputHandler_Win32_MIDI()
} }
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 );
@@ -73,21 +77,23 @@ void InputHandler_Win32_MIDI::GetDevicesAndDescriptions(vector<InputDevice>& vDe
} }
} }
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 iType = data & 0xff;
int value = ( data & 0x00ff0000) >> 16; 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 // Channel 0 in midi is a special channel that generally will get triggerd when too many channels are pressed
if ( channel == 0 ) return; if( iChannel == 0 )
return;
if ( type == 144 ) if( iType == 144 )
{ {
DeviceInput di = DeviceInput(DEVICE_MIDI,channel); 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 );