diff --git a/stella/src/ui/cyberstella/DirectInput.cxx b/stella/src/ui/cyberstella/DirectInput.cxx index 431503424..9575446b9 100644 --- a/stella/src/ui/cyberstella/DirectInput.cxx +++ b/stella/src/ui/cyberstella/DirectInput.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DirectInput.cxx,v 1.4 2003-11-14 00:47:35 stephena Exp $ +// $Id: DirectInput.cxx,v 1.5 2003-11-16 19:32:50 stephena Exp $ //============================================================================ #include "pch.hxx" @@ -26,9 +26,10 @@ DirectInput::DirectInput() mylpdi(NULL), myKeyboard(NULL), myMouse(NULL), - myLeftJoystick(NULL), - myRightJoystick(NULL) + myJoystickCount(0) { + for(uInt32 i = 0; i < 8; i++) + myJoystick[i] = NULL; } DirectInput::~DirectInput() @@ -87,6 +88,70 @@ bool DirectInput::initialize(HWND hwnd) if(FAILED(myMouse->Acquire())) return false; + // Initialize all joysticks + // Since a joystick isn't absolutely required, we won't return + // false if there are none found + if(FAILED(mylpdi->EnumDevices(DI8DEVCLASS_GAMECTRL, + EnumJoysticksCallback, + this, DIEDFL_ATTACHEDONLY))) + return true; + + for(uInt32 i = 0; i < myJoystickCount; i++) + { + LPDIRECTINPUTDEVICE8 joystick = myJoystick[i]; + + if(FAILED(joystick->SetDataFormat(&c_dfDIJoystick2 ))) + return true; + if(FAILED(joystick->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND))) + return true; + + // Set the size of the buffer for buffered data + DIPROPDWORD j_dipdw; + j_dipdw.diph.dwSize = sizeof(DIPROPDWORD); + j_dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); + j_dipdw.diph.dwObj = 0; + j_dipdw.diph.dwHow = DIPH_DEVICE; + j_dipdw.dwData = 64; + joystick->SetProperty(DIPROP_BUFFERSIZE, &j_dipdw.diph); + + // Set X-axis range to (-1000 ... +1000) + DIPROPRANGE dipr; + dipr.diph.dwSize = sizeof(dipr); + dipr.diph.dwHeaderSize = sizeof(dipr.diph); + dipr.diph.dwHow = DIPH_BYOFFSET; + dipr.lMin = -1000; + dipr.lMax = +1000; + dipr.diph.dwObj = DIJOFS_X; + joystick->SetProperty(DIPROP_RANGE, &dipr.diph); + + // And again for Y-axis range + dipr.diph.dwSize = sizeof(dipr); + dipr.diph.dwHeaderSize = sizeof(dipr.diph); + dipr.diph.dwHow = DIPH_BYOFFSET; + dipr.lMin = -1000; + dipr.lMax = +1000; + dipr.diph.dwObj = DIJOFS_Y; + joystick->SetProperty(DIPROP_RANGE, &dipr.diph); + + // Set dead zone to 50% + DIPROPDWORD dipdw; + dipdw.diph.dwSize = sizeof(dipdw); + dipdw.diph.dwHeaderSize = sizeof(dipdw.diph); + dipdw.diph.dwHow = DIPH_BYOFFSET; + dipdw.dwData = 5000; + dipdw.diph.dwObj = DIJOFS_X; + joystick->SetProperty(DIPROP_DEADZONE, &dipdw.diph); + + dipdw.diph.dwSize = sizeof(dipdw); + dipdw.diph.dwHeaderSize = sizeof(dipdw.diph); + dipdw.diph.dwHow = DIPH_BYOFFSET; + dipdw.dwData = 5000; + dipdw.diph.dwObj = DIJOFS_Y; + joystick->SetProperty(DIPROP_DEADZONE, &dipdw.diph); + + joystick->Acquire(); + } + return true; } @@ -142,8 +207,52 @@ bool DirectInput::getMouseEvents(DIDEVICEOBJECTDATA* mouseEvents, return true; } +bool DirectInput::getJoystickEvents(uInt32 stick, DIDEVICEOBJECTDATA* joyEvents, + DWORD* numJoyEvents) +{ + LPDIRECTINPUTDEVICE8 joystick; + + // Make sure the joystick exists and has been initialized + if(stick >= 0 && stick <= 8) + { + joystick = myJoystick[stick]; + if(joystick == NULL) + return false; + } + else + return false; + + // Check for joystick events + joystick->Poll(); + HRESULT hr = joystick->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), + joyEvents, numJoyEvents, 0 ); + + if(hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) + { + hr = joystick->Acquire(); + if(hr == DIERR_OTHERAPPHASPRIO) + return false; + + joystick->Poll(); + hr = joystick->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), + joyEvents, numJoyEvents, 0 ); + } + + return true; +} + void DirectInput::cleanup() { + for(uInt32 i = 0; i < myJoystickCount; i++) + { + if(myJoystick[i]) + { + myJoystick[i]->Unacquire(); + myJoystick[i]->Release(); + myJoystick[i] = NULL; + } + } + if(myMouse) { myMouse->Unacquire(); @@ -165,396 +274,28 @@ void DirectInput::cleanup() } } -/* -BOOL CALLBACK DirectInput::EnumDevicesProc -( - const DIDEVICEINSTANCE* lpddi, - LPVOID pvRef -) +BOOL CALLBACK DirectInput::EnumJoysticksCallback( + const DIDEVICEINSTANCE* inst, + LPVOID pvRef) { - DirectInput* pThis = (DirectInput*)pvRef; - ASSERT(pThis); + DirectInput* pThis = (DirectInput*) pvRef; + if(!pThis) + return DIENUM_STOP; - const DIDATAFORMAT* pdidf = NULL; + // If we can't store any more joysticks, then stop enumeration. + // The limit is set to 8, since the Stella eventhandler core + // can use up to 8 joysticks. + if(pThis->myJoystickCount > 8) + return DIENUM_STOP; - switch(pThis->m_dwDevType) - { - case DIDEVTYPE_MOUSE: - TRACE("EnumDevicesProc (mouse)"); - pdidf = &c_dfDIMouse; - break; + // Obtain an interface to the enumerated joystick. + HRESULT hr = pThis->mylpdi->CreateDevice(inst->guidInstance, + (LPDIRECTINPUTDEVICE8*) &pThis->myJoystick[pThis->myJoystickCount], NULL ); - case DIDEVTYPE_KEYBOARD: - TRACE("EnumDevicesProc (keyboard)"); - pdidf = &c_dfDIKeyboard; - break; + // Indicate that we've found one more joystick + if(!FAILED(hr)) + pThis->myJoystickCount++; - case DIDEVTYPE_JOYSTICK: - TRACE("EnumDevicesProc (joystick)"); - pdidf = &c_dfDIJoystick; - break; - - default: - ASSERT(FALSE); - return DIENUM_STOP; - }; - - HRESULT hr; - - IDirectInputDevice* piDID; - hr = pThis->m_piDI->CreateDevice(lpddi->guidInstance, &piDID, - NULL); - ASSERT(hr == DI_OK && "IDI::CreateDevice failed"); - if (hr != DI_OK) - { - return DIENUM_CONTINUE; - } - - hr = piDID->SetDataFormat(pdidf); - ASSERT(hr == DI_OK && "IDID::SetDataFormat failed"); - if (hr != DI_OK) - { - piDID->Release(); - return DIENUM_CONTINUE; - } - - hr = piDID->QueryInterface(IID_IDirectInputDevice2, - (void**)&(pThis->m_piDID)); - if (hr != S_OK) - { - piDID->Release(); - return DIENUM_CONTINUE; - } - - // undo the addref that QI did (CreateDevice did an addref) - - pThis->m_piDID->Release(); - -#ifdef _DEBUG - DIDEVICEINSTANCE didi; - didi.dwSize = sizeof(didi); - piDID->GetDeviceInfo(&didi); - TRACE("Using device: %s", didi.tszProductName); -#endif - - return DIENUM_STOP; + // And continue enumeration for more joysticks + return DIENUM_CONTINUE; } - -BOOL DirectInput::IsButtonPressed -( - int nButton -) const -{ - if ( nButton > GetButtonCount() ) - { - return FALSE; - } - - return ( m_pButtons[nButton] ) ? 1 : 0; -} - - -// --------------------------------------------------------------------------- - - -// --------------------------------------------------------------------------- - -DirectJoystick::DirectJoystick( - HWND hwnd - ) : \ - DirectInput( hwnd, DIDEVTYPE_JOYSTICK, 32 ) -{ - TRACE( "DirectJoystick::DirectJoystick" ); -} - -HRESULT DirectJoystick::Initialize( - void - ) -{ - TRACE( "DirectJoystick::Initialize" ); - - HRESULT hr; - - hr = DirectInput::Initialize(); - if ( FAILED(hr) ) - { - return hr; - } - - if ( GetDevice() == NULL ) - { - TRACE("No joystick was found"); - return S_FALSE; - } - - // set X-axis range to (-1000 ... +1000) - // This lets us test against 0 to see which way the stick is pointed. - - DIPROPRANGE dipr; - - dipr.diph.dwSize = sizeof(dipr); - dipr.diph.dwHeaderSize = sizeof(dipr.diph); - dipr.diph.dwHow = DIPH_BYOFFSET; - dipr.lMin = -1000; - dipr.lMax = +1000; - dipr.diph.dwObj = DIJOFS_X; - hr = GetDevice()->SetProperty( DIPROP_RANGE, &dipr.diph ); - if ( FAILED(hr) ) - { - TRACE( "SetProperty(DIPROP_RANGE,x) failed, hr=%X", hr ); - return hr; - } - - // And again for Y-axis range - - dipr.diph.dwSize = sizeof(dipr); - dipr.diph.dwHeaderSize = sizeof(dipr.diph); - dipr.diph.dwHow = DIPH_BYOFFSET; - dipr.lMin = -1000; - dipr.lMax = +1000; - dipr.diph.dwObj = DIJOFS_Y; - hr = GetDevice()->SetProperty( DIPROP_RANGE, &dipr.diph ); - if ( FAILED(hr) ) - { - TRACE( "SetProperty(DIPROP_RANGE,y) failed, hr=%X", hr ); - return hr; - } - - - // set dead zone to 50% - - DIPROPDWORD dipdw; - - dipdw.diph.dwSize = sizeof(dipdw); - dipdw.diph.dwHeaderSize = sizeof(dipdw.diph); - dipdw.diph.dwHow = DIPH_BYOFFSET; - dipdw.dwData = 5000; - dipdw.diph.dwObj = DIJOFS_X; - hr = GetDevice()->SetProperty( DIPROP_DEADZONE, &dipdw.diph ); - if ( FAILED(hr) ) - { - TRACE( "SetProperty(DIPROP_DEADZONE,x) failed, hr=%X", hr ); - return hr; - } - - dipdw.diph.dwSize = sizeof(dipdw); - dipdw.diph.dwHeaderSize = sizeof(dipdw.diph); - dipdw.diph.dwHow = DIPH_BYOFFSET; - dipdw.dwData = 5000; - dipdw.diph.dwObj = DIJOFS_Y; - hr = GetDevice()->SetProperty( DIPROP_DEADZONE, &dipdw.diph ); - if ( FAILED(hr) ) - { - TRACE( "SetProperty(DIPROP_DEADZONE,y) failed, hr=%X", hr ); - return hr; - } - - return S_OK; -} - -HRESULT DirectJoystick::Update( - void - ) -{ - if ( GetDevice() == NULL ) - { - return E_FAIL; - } - - HRESULT hr; - - DIJOYSTATE dijs; - - GetDevice()->Poll(); - - hr = GetDevice()->GetDeviceState( sizeof(dijs), &dijs ); - if ( hr == DIERR_INPUTLOST || - hr == DIERR_NOTACQUIRED ) - { - hr = GetDevice()->Acquire(); - if ( hr == DIERR_OTHERAPPHASPRIO ) - { - return S_FALSE; - } - - GetDevice()->Poll(); - hr = GetDevice()->GetDeviceState( sizeof(dijs), &dijs ); - } - - ASSERT(hr == DI_OK && "Joystick GetDeviceState failed"); - - if ( hr == DI_OK ) - { - m_lX = dijs.lX; - m_lY = dijs.lY; - - memcpy( m_pButtons, - dijs.rgbButtons, - sizeof(dijs.rgbButtons) ); - } - - return hr; -} - - -// --------------------------------------------------------------------------- - -CDisabledJoystick::CDisabledJoystick( - HWND hwnd - ) : \ - DirectInput( NULL, 0, 0 ) -{ - UNUSED_ALWAYS( hwnd ); - - TRACE( "CDisabledJoystick::CDisabledJoystick" ); -} - -HRESULT CDisabledJoystick::Update( - void - ) -{ - return S_FALSE; -} - -// --------------------------------------------------------------------------- - -DirectMouse::DirectMouse( - HWND hwnd - ) : \ - DirectInput( hwnd, DIDEVTYPE_MOUSE, 4 ) -{ - TRACE( "DirectMouse::DirectMouse" ); -} - -HRESULT DirectMouse::Update( - void - ) -{ - if (GetDevice() == NULL) - { - return E_FAIL; - } - - HRESULT hr; - - DIMOUSESTATE dims; - - GetDevice()->Poll(); - - hr = GetDevice()->GetDeviceState( sizeof(dims), &dims ); - if ( hr == DIERR_INPUTLOST || - hr == DIERR_NOTACQUIRED ) - { - hr = GetDevice()->Acquire(); - if ( hr == DIERR_OTHERAPPHASPRIO ) - { - return S_FALSE; - } - - GetDevice()->Poll(); - hr = GetDevice()->GetDeviceState( sizeof(dims), &dims ); - } - - ASSERT( hr == DI_OK && "Mouse GetDeviceState failed" ); - - if ( hr == DI_OK ) - { - // Because the mouse is returning relative positions, - // force X and Y to go between 0 ... 999 - - m_lX += dims.lX; - - if (m_lX < 0) - { - m_lX = 0; - } - else if (m_lX > 999) - { - m_lX = 999; - } - - m_lY += dims.lY; - - if (m_lY < 0) - { - m_lY = 0; - } - else if (m_lY > 999) - { - m_lY = 999; - } - - memcpy( m_pButtons, - dims.rgbButtons, - sizeof(dims.rgbButtons) ); - } - - return hr; -} -*/ - -/////////////////////////////////////// -// The following was part of initialize -/////////////////////////////////////// -/* - // initialize the mouse - if (FAILED(lpdi->CreateDevice(GUID_SysMouse, &m_mouse, NULL))) - return false; - if (FAILED(m_mouse->SetCooperativeLevel(hWnd, DISCL_BACKGROUND | - DISCL_NONEXCLUSIVE))) - return false; - if (FAILED(m_mouse->SetDataFormat(&c_dfDIMouse))) - return false; - if (FAILED(m_mouse->Acquire())) - return false; -*/ -/* - // - // enumerate to find proper device - // The callback will set m_piDID - // - - TRACE("\tCalling EnumDevices"); - - hr = m_piDI->EnumDevices( m_dwDevType, - EnumDevicesProc, - this, - DIEDFL_ATTACHEDONLY ); - if ( m_piDID ) - { - TRACE("\tGot a device!"); - - (void)m_piDID->SetCooperativeLevel( m_hwnd, - DISCL_NONEXCLUSIVE - | DISCL_FOREGROUND); - - hr = GetDevice()->Acquire(); - if ( hr == DIERR_OTHERAPPHASPRIO ) - { - return S_FALSE; - } - } - - m_pButtons = new BYTE[GetButtonCount()]; - if ( m_pButtons == NULL ) - { - hr = E_OUTOFMEMORY; - goto cleanup; - } - - m_fInitialized = TRUE; - -cleanup: - - if ( FAILED(hr) ) - { - Cleanup(); - - if ( uMsg != 0 ) - { - MessageBox( hInstance, m_hwnd, uMsg ); - } - } - - return hr; -*/ diff --git a/stella/src/ui/cyberstella/DirectInput.hxx b/stella/src/ui/cyberstella/DirectInput.hxx index 48ad3be39..f2f419897 100644 --- a/stella/src/ui/cyberstella/DirectInput.hxx +++ b/stella/src/ui/cyberstella/DirectInput.hxx @@ -13,12 +13,14 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DirectInput.hxx,v 1.5 2003-11-14 00:47:35 stephena Exp $ +// $Id: DirectInput.hxx,v 1.6 2003-11-16 19:32:51 stephena Exp $ //============================================================================ #ifndef DIRECT_INPUT_HXX #define DIRECT_INPUT_HXX +#define DIRECTINPUT_VERSION 0x0800 + #include "bspf.hxx" #include "dinput.h" @@ -30,23 +32,28 @@ class DirectInput bool getKeyEvents(DIDEVICEOBJECTDATA* keyEvents, DWORD* numKeyEvents); bool getMouseEvents(DIDEVICEOBJECTDATA* mouseEvents, DWORD* numMouseEvents); + bool getJoystickEvents(uInt32 stick, DIDEVICEOBJECTDATA* joyEvents, + DWORD* numJoyEvents); bool initialize(HWND hwnd); void update(); + uInt32 numJoysticks() { return myJoystickCount; } + private: void cleanup(); - static BOOL CALLBACK EnumDevicesProc(const DIDEVICEINSTANCE* lpddi, LPVOID pvRef ); + static BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE* inst, + LPVOID pvRef); HWND myHWND; LPDIRECTINPUT8 mylpdi; LPDIRECTINPUTDEVICE8 myKeyboard; LPDIRECTINPUTDEVICE8 myMouse; - LPDIRECTINPUTDEVICE8 myLeftJoystick; - LPDIRECTINPUTDEVICE8 myRightJoystick; + LPDIRECTINPUTDEVICE8 myJoystick[8]; + uInt32 myJoystickCount; }; #endif diff --git a/stella/src/ui/cyberstella/FrameBufferWin32.cxx b/stella/src/ui/cyberstella/FrameBufferWin32.cxx index becf04d20..400fb2c5f 100644 --- a/stella/src/ui/cyberstella/FrameBufferWin32.cxx +++ b/stella/src/ui/cyberstella/FrameBufferWin32.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: FrameBufferWin32.cxx,v 1.3 2003-11-14 00:47:35 stephena Exp $ +// $Id: FrameBufferWin32.cxx,v 1.4 2003-11-16 19:32:52 stephena Exp $ //============================================================================ #include @@ -48,14 +48,12 @@ FrameBufferWin32::FrameBufferWin32() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FrameBufferWin32::~FrameBufferWin32() { -OutputDebugString("got here FrameBufferWin32::~FrameBufferWin32()"); cleanup(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBufferWin32::cleanup() { -OutputDebugString("got here FrameBufferWin32::cleanup()"); if(m_piDDPalette) { m_piDDPalette->Release(); @@ -83,7 +81,7 @@ OutputDebugString("got here FrameBufferWin32::cleanup()"); if(myHWND) { ::DestroyWindow( myHWND ); -OutputDebugString("got here destroyed window"); + // // Remove the WM_QUIT which will be in the message queue // so that the main window doesn't exit diff --git a/stella/src/ui/cyberstella/MainWin32.cxx b/stella/src/ui/cyberstella/MainWin32.cxx index e0f38f796..cf5302ba5 100644 --- a/stella/src/ui/cyberstella/MainWin32.cxx +++ b/stella/src/ui/cyberstella/MainWin32.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: MainWin32.cxx,v 1.2 2003-11-14 00:47:35 stephena Exp $ +// $Id: MainWin32.cxx,v 1.3 2003-11-16 19:32:52 stephena Exp $ //============================================================================ #define STRICT @@ -89,11 +89,13 @@ MainWin32::MainWin32(const uInt8* image, uInt32 size, const char* filename, myIsInitialized = true; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MainWin32::~MainWin32() { cleanup(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void MainWin32::cleanup() { ShowCursor(TRUE); @@ -113,6 +115,7 @@ void MainWin32::cleanup() myIsInitialized = false; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DWORD MainWin32::run() { if(!myIsInitialized) @@ -200,6 +203,7 @@ DWORD MainWin32::run() return msg.wParam; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void MainWin32::UpdateEvents() { DIDEVICEOBJECTDATA eventArray[64]; @@ -281,66 +285,55 @@ void MainWin32::UpdateEvents() } } } -/* - // - // Update joystick - // - FIXME - add multiple joysticks - if (m_pDirectJoystick->Update() == S_OK) - { - rgEventState[Event::JoystickZeroFire] |= - m_pDirectJoystick->IsButtonPressed(0); - - LONG x; - LONG y; - m_pDirectJoystick->GetPos( &x, &y ); - - if (x < 0) - { - rgEventState[Event::JoystickZeroLeft] = 1; - } - else if (x > 0) - { - rgEventState[Event::JoystickZeroRight] = 1; - } - if (y < 0) - { - rgEventState[Event::JoystickZeroUp] = 1; - } - else if (y > 0) - { - rgEventState[Event::JoystickZeroDown] = 1; - } - } - - // - // Update mouse - // - - if (m_pDirectMouse->Update() == S_OK) - { - // NOTE: Mouse::GetPos returns a value from 0..999 - - LONG x; - m_pDirectMouse->GetPos( &x, NULL ); - - // Mouse resistance is measured between 0...1000000 - -// rgEventState[ m_rGlobalData->PaddleResistanceEvent() ] = (999-x)*1000; - -// rgEventState[ m_rGlobalData->PaddleFireEvent() ] |= m_pDirectMouse->IsButtonPressed(0); - } - - // - // Write new event state - // - -// for (i = 0; i < nEventCount; ++i) -// { -// m_rEvent.set( (Event::Type)i, rgEventState[i] ); -// } -*/ + // Check for joystick events + for(uInt32 joystick = 0; joystick < theInput->numJoysticks(); joystick++) + { + numEvents = 64; + if(theInput->getJoystickEvents(joystick, eventArray, &numEvents)) + { + StellaEvent::JoyStick stick = joyList[joystick]; + StellaEvent::JoyCode code; + + for(uInt32 i = 0; i < numEvents; i++ ) + { + Event::Type type = Event::LastType; + Int32 state, value; + + if(eventArray[i].dwOfs == DIJOFS_X) // left-right motion + { + value = (Int32) eventArray[i].dwData; + + theConsole->eventHandler().sendJoyEvent(stick, StellaEvent::JAXIS_LEFT, + (value < 0) ? 1 : 0); + theConsole->eventHandler().sendJoyEvent(stick, StellaEvent::JAXIS_RIGHT, + (value > 0) ? 1 : 0); + } + else if(eventArray[i].dwOfs == DIJOFS_Y) // up-down motion + { + value = (Int32) eventArray[i].dwData; + + theConsole->eventHandler().sendJoyEvent(stick, StellaEvent::JAXIS_UP, + (value < 0) ? 1 : 0); + theConsole->eventHandler().sendJoyEvent(stick, StellaEvent::JAXIS_DOWN, + (value > 0) ? 1 : 0); + } + else // Check for button press and release + { + for(uInt32 j = 0; j < StellaEvent::LastJCODE-4; j++) + { + if(eventArray[i].dwOfs == DIJOFS_BUTTON(j)) + { + code = joyButtonList[j]; + state = (Int32) eventArray[i].dwData & 0x80 ? 1 : 0; + + theConsole->eventHandler().sendJoyEvent(stick, code, state); + } + } + } + } + } + } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -457,3 +450,22 @@ MainWin32::Switches MainWin32::keyList[StellaEvent::LastKCODE] = { { DIK_END, StellaEvent::KCODE_END }, { DIK_NEXT, StellaEvent::KCODE_PAGEDOWN } }; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +StellaEvent::JoyStick MainWin32::joyList[StellaEvent::LastJSTICK] = { + StellaEvent::JSTICK_0, StellaEvent::JSTICK_1, + StellaEvent::JSTICK_2, StellaEvent::JSTICK_3, + StellaEvent::JSTICK_4, StellaEvent::JSTICK_5, + StellaEvent::JSTICK_6, StellaEvent::JSTICK_7 +}; + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +StellaEvent::JoyCode MainWin32::joyButtonList[StellaEvent::LastJCODE-4] = { + StellaEvent::JBUTTON_0, StellaEvent::JBUTTON_1, StellaEvent::JBUTTON_2, + StellaEvent::JBUTTON_3, StellaEvent::JBUTTON_4, StellaEvent::JBUTTON_5, + StellaEvent::JBUTTON_6, StellaEvent::JBUTTON_7, StellaEvent::JBUTTON_8, + StellaEvent::JBUTTON_9, StellaEvent::JBUTTON_10, StellaEvent::JBUTTON_11, + StellaEvent::JBUTTON_12, StellaEvent::JBUTTON_13, StellaEvent::JBUTTON_14, + StellaEvent::JBUTTON_15, StellaEvent::JBUTTON_16, StellaEvent::JBUTTON_17, + StellaEvent::JBUTTON_18, StellaEvent::JBUTTON_19 +}; diff --git a/stella/src/ui/cyberstella/MainWin32.hxx b/stella/src/ui/cyberstella/MainWin32.hxx index 641cdb01c..8b106a3cb 100644 --- a/stella/src/ui/cyberstella/MainWin32.hxx +++ b/stella/src/ui/cyberstella/MainWin32.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: MainWin32.hxx,v 1.2 2003-11-14 00:47:35 stephena Exp $ +// $Id: MainWin32.hxx,v 1.3 2003-11-16 19:32:52 stephena Exp $ //============================================================================ #ifndef MAIN_WIN32_HXX @@ -41,7 +41,7 @@ class DirectInput; in the Porting.txt document @author Stephen Anthony - @version $Id: MainWin32.hxx,v 1.2 2003-11-14 00:47:35 stephena Exp $ + @version $Id: MainWin32.hxx,v 1.3 2003-11-16 19:32:52 stephena Exp $ */ class MainWin32 { @@ -96,6 +96,10 @@ class MainWin32 }; static Switches keyList[StellaEvent::LastKCODE]; + // Lookup tables for joystick numbers and events + static StellaEvent::JoyStick joyList[StellaEvent::LastJSTICK]; + static StellaEvent::JoyCode joyButtonList[StellaEvent::LastJCODE-4]; + const CGlobalData* m_rGlobalData; // Indicates the current mouse position in the X direction