bool CheckForJoystick(HWND hWnd) { //Creamos variables temporales JOYINFO joyinfo; UINT wNumDevs; BOOL bDev1Attached, bDev2Attached; //Obtenemos el número de joysticks configurados if((wNumDevs = joyGetNumDevs()) == 0) { return false; } //Revisamos si hay uno o dos joysticks conectados bDev1Attached = joyGetPos(JOYSTICKID1, &joyinfo) != JOYERR_UNPLUGGED; bDev2Attached = joyGetPos(JOYSTICKID2, &joyinfo) != JOYERR_UNPLUGGED; //Si hay un primer dispositivo conectado if( bDev1Attached ) {//Establecemos la velocidad de captura de datos para este joystick joySetCapture(hWnd, JOYSTICKID1, 1000/30, true); } //Si hay un segundo dispositivo conectado if( bDev2Attached ) {//Establecemos la velocidad de captura de datos para este joystick joySetCapture(hWnd, JOYSTICKID2, 1000/30, true); } return true; //Indicamos que si hay joysticks conectados }
/* CENTRY */ void APIENTRY glutJoystickFunc(GLUTjoystickCB joystickFunc, int pollInterval) { #ifdef _WIN32 if (joystickFunc && (pollInterval > 0)) { if (__glutCurrentWindow->entryState == WM_SETFOCUS) { MMRESULT result; /* Capture joystick focus if current window has focus now. */ result = joySetCapture(__glutCurrentWindow->win, JOYSTICKID1, 0, TRUE); if (result == JOYERR_NOERROR) { (void) joySetThreshold(JOYSTICKID1, pollInterval); } } __glutCurrentWindow->joyPollInterval = pollInterval; } else { /* Release joystick focus if current window has focus now. */ if (__glutCurrentWindow->joystick && (__glutCurrentWindow->joyPollInterval > 0) && (__glutCurrentWindow->entryState == WM_SETFOCUS)) { (void) joyReleaseCapture(JOYSTICKID1); } __glutCurrentWindow->joyPollInterval = 0; } __glutCurrentWindow->joystick = joystickFunc; #else /* XXX No support currently for X11 joysticks. */ #endif }
////////////////////////////////////// // Handle WM_CREATE ////////////////////////////////////// BOOL Main_Create(HWND hwnd, CREATESTRUCT FAR* lpCreateStruct) { fight = TRUE; joySetCapture(hwnd, JOYSTICKID1, TimeRate, FALSE); Reset((HWNDdll)hwnd); ButtonUpdate((HWNDdll)hwnd, (HINST)hInst); return TRUE; }
bool wxJoystick::SetCapture(wxWindow* win, int pollingFreq) { #ifdef __WXMSW__ BOOL changed = (pollingFreq == 0); MMRESULT res = joySetCapture((HWND) win->GetHWND(), m_joystick, pollingFreq, changed); return (res == JOYERR_NOERROR); #else wxUnusedVar(win); wxUnusedVar(pollingFreq); return false; #endif }
bool joystick_load(int id) { JOYINFO joyinfo; UINT wNumDevs; if((wNumDevs = joyGetNumDevs()) == 0) return false; if (joySetCapture(enigma::hWnd, JOYSTICKID1 + id, 0, FALSE)) { MessageBeep(MB_ICONEXCLAMATION); MessageBox(enigma::hWnd, "Couldn't capture the joystick.", NULL, MB_OK | MB_ICONEXCLAMATION); return false; } return (joyGetPos(JOYSTICKID1 + id, &joyinfo) == JOYERR_NOERROR); }
int CJoystick::Init() { m_Cant=joyGetNumDevs(); joySetCapture(m_hWnd,JOYSTICKID1,0,FALSE); if (m_Cant==0) return false; for (m_ID=JOYSTICKID1; m_ID<m_Cant; m_ID++) { if (joyGetPos(m_ID, &m_JI)==JOYERR_NOERROR) { break; } if (m_ID == m_Cant-1) return false; } return true; }
bool joystick_load(int id) { JOYINFO joyinfo; UINT wNumDevs; BOOL bDevAttached; if((wNumDevs = joyGetNumDevs()) == 0) return false; if (joySetCapture(enigma::hWnd, JOYSTICKID1 + id, NULL, FALSE)) { MessageBeep(MB_ICONEXCLAMATION); MessageBox(enigma::hWnd, "Couldn't capture the joystick.", NULL, MB_OK | MB_ICONEXCLAMATION); return false; } bDevAttached = joyGetPos(JOYSTICKID1 + id, &joyinfo) != JOYERR_UNPLUGGED; if (!bDevAttached) return false; return true; }
LRESULT CALLBACK WndProc(HWND hWnd, // handle for this window UINT uMsg, // message for this window WPARAM wParam, // additional message information LPARAM lParam) // additional message information { TRect rect; switch (uMsg) // check for windows messages { case WM_PASTE: //[Ctrl]+[V] potrzebujemy do innych celów return 0; case WM_COPYDATA: // obs³uga danych przes³anych przez program steruj¹cy pDane = (PCOPYDATASTRUCT)lParam; if (pDane->dwData == 'EU07') // sygnatura danych World.OnCommandGet((DaneRozkaz *)(pDane->lpData)); break; case WM_ACTIVATE: // watch for window activate message // case WM_ACTIVATEAPP: { // Ra: uzale¿nienie aktywnoœci od bycia na wierzchu Global::bActive = (LOWORD(wParam) != WA_INACTIVE); if (Global::bInactivePause) // jeœli ma byæ pauzowanie okna w tle if (Global::bActive) Global::iPause &= ~4; // odpauzowanie, gdy jest na pierwszym planie else Global::iPause |= 4; // w³¹czenie pauzy, gdy nieaktywy if (Global::bActive) SetCursorPos(mx, my); ShowCursor(!Global::bActive); /* if (!HIWORD(wParam)) //check minimization state active=TRUE; //program is active else active=FALSE; //program is no longer active */ return 0; // return to the message loop } case WM_SYSCOMMAND: // intercept system commands { switch (wParam) // check system calls { case 61696: // F10 World.OnKeyDown(VK_F10); return 0; case SC_SCREENSAVE: // screensaver trying to start? case SC_MONITORPOWER: // monitor trying to enter powersave? return 0; // prevent from happening } break; // exit } case WM_CLOSE: // did we receive a close message? { PostQuitMessage(0); // send a quit message [Alt]+[F4] return 0; // jump back } case WM_MOUSEMOVE: { // mx= 100;//Global::iWindowWidth/2; // my= 100;//Global::iWindowHeight/2; // SetCursorPos(Global::iWindowWidth/2,Global::iWindowHeight/2); // m_x= LOWORD(lParam); // m_y= HIWORD(lParam); GetCursorPos(&mouse); if (Global::bActive && ((mouse.x != mx) || (mouse.y != my))) { World.OnMouseMove(double(mouse.x - mx) * 0.005, double(mouse.y - my) * 0.01); SetCursorPos(mx, my); } return 0; // jump back } case WM_KEYUP: if (Global::bActive) { World.OnKeyUp(wParam); return 0; } case WM_KEYDOWN: if (Global::bActive) { if (wParam != 17) // bo naciœniêcia [Ctrl] nie ma po co przekazywaæ if (wParam != 145) //[Scroll Lock] te¿ nie World.OnKeyDown(wParam); switch (wParam) { case VK_ESCAPE: //[Esc] pauzuje tylko bez Debugmode if (DebugModeFlag) break; case 19: //[Pause] if (Global::iPause & 1) // jeœli pauza startowa Global::iPause &= ~1; // odpauzowanie, gdy po wczytaniu mia³o nie startowaæ else if (!(Global::iMultiplayer & 2)) // w multiplayerze pauza nie ma sensu if (!Console::Pressed(VK_CONTROL)) // z [Ctrl] to radiostop jest // Ra: poni¿sze nie ma sensu, bo brak komunikacji natychmiast zapauzuje // ponownie // if (Global::iPause&8) //jeœli pauza zwi¹zana z brakiem komunikacji z // PoKeys // Global::iPause&=~10; //odpauzowanie pauzy PoKeys (chyba nic nie da) i // ewentualnie klawiszowej równie¿ // else Global::iPause ^= 2; // zmiana stanu zapauzowania if (Global::iPause) // jak pauza Global::iTextMode = VK_F1; // to wyœwietliæ zegar i informacjê break; case VK_F7: if (DebugModeFlag) { // siatki wyœwietlane tyko w trybie testowym Global::bWireFrame = !Global::bWireFrame; ++Global::iReCompile; // odœwie¿yæ siatki // Ra: jeszcze usun¹æ siatki ze skompilowanych obiektów! } break; } } return 0; // jump back case WM_CHAR: { /* switch ((TCHAR) wParam) { // case 'q': // done= true; // KillGLWindow(); // PostQuitMessage(0); // DestroyWindow( hWnd ); // break; }; */ return 0; } case WM_SIZE: // resize the OpenGL window { ReSizeGLScene(LOWORD(lParam), HIWORD(lParam)); // LoWord=Width, HiWord=Height if (GetWindowRect(hWnd, &rect)) { // Ra: zmiana rozmiaru okna bez przesuwania myszy // mx=WindowWidth/2+rect.left; // horizontal position // my=WindowHeight/2+rect.top; // vertical position // SetCursorPos(mx,my); } return 0; // jump back } case WM_MOVE: // przesuwanie okna? { mx = WindowWidth / 2 + LOWORD(lParam); // horizontal position my = WindowHeight / 2 + HIWORD(lParam); // vertical position // SetCursorPos(mx,my); break; } case WM_PAINT: { // odrysowanie okna break; } // case WM_ERASEBKGND: //Process this message to keep Windows from erasing background. case MM_JOY1BUTTONDOWN: { // WriteLog("Joystick button "+AnsiString(wParam)); break; } case WM_CREATE: /* Capture the joystick. If this fails, beep and display * error, then quit. */ if (joySetCapture(hWnd, JOYSTICKID1, 0, FALSE)) { // MessageBeep(MB_ICONEXCLAMATION); // MessageBox(hWnd,"Couldn't capture the joystick",NULL,MB_OK|MB_ICONEXCLAMATION); // return -1; } break; } // pass all unhandled messages to DefWindowProc return DefWindowProc(hWnd, uMsg, wParam, lParam); };
LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { MMouse * mouse = MMouse::getInstance(); MWindow * window = MWindow::getInstance(); MWinEvent events; if(window->isActive()) { switch(uMsg) { case WM_CREATE: { joySetCapture(hwnd, JOYSTICKID1, 0, FALSE); joySetCapture(hwnd, JOYSTICKID2, 0, FALSE); } break; case WM_KILLFOCUS: window->setFocus(false); break; case WM_SETFOCUS: window->setFocus(true); break; case WM_CLOSE: events.type = MWIN_EVENT_WINDOW_CLOSE; window->sendEvents(&events); return 0; case WM_DESTROY: { joyReleaseCapture(JOYSTICKID1); joyReleaseCapture(JOYSTICKID2); } break; case WM_SYSKEYDOWN: case WM_KEYDOWN: events.type = MWIN_EVENT_KEY_DOWN; events.data[0] = (int)wParam; window->sendEvents(&events); break; case WM_SYSKEYUP: case WM_KEYUP: events.type = MWIN_EVENT_KEY_UP; events.data[0] = (int)wParam; window->sendEvents(&events); break; case WM_SIZE: events.type = MWIN_EVENT_WINDOW_RESIZE; events.data[0] = (int)LOWORD(lParam); events.data[1] = (int)HIWORD(lParam); window->sendEvents(&events); break; case WM_MOVE: events.type = MWIN_EVENT_WINDOW_MOVE; events.data[0] = (int)(short)LOWORD(lParam); events.data[1] = (int)(short)HIWORD(lParam); window->sendEvents(&events); break; case WM_LBUTTONDOWN: SetCapture(hwnd); events.type = MWIN_EVENT_MOUSE_BUTTON_DOWN; events.data[0] = (int)MMOUSE_BUTTON_LEFT; window->sendEvents(&events); break; case WM_LBUTTONUP: ReleaseCapture(); events.type = MWIN_EVENT_MOUSE_BUTTON_UP; events.data[0] = (int)MMOUSE_BUTTON_LEFT; window->sendEvents(&events); break; case WM_CHAR: if(wParam == 8 || wParam == 32 || wParam == 13 || wParam == 9) // not return, space, delete etc.. break; events.type = MWIN_EVENT_CHAR; events.data[0] = (int)(char)wParam; window->sendEvents(&events); break; case WM_MBUTTONDOWN: SetCapture(hwnd); events.type = MWIN_EVENT_MOUSE_BUTTON_DOWN; events.data[0] = (int)MMOUSE_BUTTON_MIDDLE; window->sendEvents(&events); break; case WM_MBUTTONUP: ReleaseCapture(); events.type = MWIN_EVENT_MOUSE_BUTTON_UP; events.data[0] = (int)MMOUSE_BUTTON_MIDDLE; window->sendEvents(&events); break; case WM_RBUTTONDOWN: SetCapture(hwnd); events.type = MWIN_EVENT_MOUSE_BUTTON_DOWN; events.data[0] = (int)MMOUSE_BUTTON_RIGHT; window->sendEvents(&events); break; case WM_RBUTTONUP: ReleaseCapture(); events.type = MWIN_EVENT_MOUSE_BUTTON_UP; events.data[0] = (int)MMOUSE_BUTTON_RIGHT; window->sendEvents(&events); break; case WM_MOUSEWHEEL: events.type = MWIN_EVENT_MOUSE_WHEEL_MOVE; events.data[0] = CLAMP((int)((short)HIWORD(wParam) / (int)WHEEL_DELTA), -1, 1); window->sendEvents(&events); break; } } else { switch(uMsg) { case WM_NCPAINT: window->swapBuffer(); break; } } // Pass All unhandled Messages To DefWindowProc return DefWindowProc(hwnd, uMsg, wParam, lParam); }
int joy95_init_stick(int joy, int spjoy) { UINT joyid; MMRESULT mmresult; char joyname[256]; if (!joy_installed) return 0; switch (SpecialDevice) { case TACTILE_CYBERNET: //@@ joystick.present_mask = JOY_1_X_AXIS | JOY_1_Y_AXIS | JOY_1_Z_AXIS | JOY_1_POV; //@@ joystick.has_pov = 1; break; case TACTILE_IMMERSION: mprintf((0, "Joystick name= I-Force compatible device.\n")); break; } // if (spjoy) return 1; joystick.joyid = 0; if (joy == 1) joystick.joyid = joyid = JOYSTICKID1; else return 0; mmresult = joyGetDevCaps(joyid, &WinJoyCaps, sizeof(WinJoyCaps)); if (mmresult != JOYERR_NOERROR) { mprintf((1, "Attempt to get Joystick %d caps failed.\n", joy)); return 0; } mprintf ((0,"Joystick name=%s\n",WinJoyCaps.szPname)); // Tell our Window App. about this joystick. joySetThreshold(joyid, WinJoyCaps.wXmax/256); mmresult = joySetCapture(GetLibraryWindow(), joyid, JOY_POLL_RATE, FALSE); if (mmresult != JOYERR_NOERROR) { mprintf((1, "Unable to capture joystick %d. Error=%d\n", joy,mmresult)); return 0; } // Get raw axis' min and max. joystick.threshold = WinJoyCaps.wXmax/256; joystick.max_timer = WinJoyCaps.wPeriodMax; joystick.threshold = WinJoyCaps.wXmax/256; joystick.max_timer = WinJoyCaps.wPeriodMax; joystick.axis_min[0] = WinJoyCaps.wXmin; joystick.axis_min[1] = WinJoyCaps.wYmin; joystick.axis_min[2] = WinJoyCaps.wZmin; joystick.axis_min[4] = WinJoyCaps.wRmin; joystick.axis_min[5] = WinJoyCaps.wUmin; joystick.axis_min[6] = WinJoyCaps.wVmin; joystick.axis_max[0] = WinJoyCaps.wXmax; joystick.axis_max[1] = WinJoyCaps.wYmax; joystick.axis_max[2] = WinJoyCaps.wZmax; joystick.axis_max[4] = WinJoyCaps.wRmax; joystick.axis_max[5] = WinJoyCaps.wUmax; joystick.axis_max[6] = WinJoyCaps.wVmax; joystick.axis_center[0] = (WinJoyCaps.wXmax-WinJoyCaps.wXmin)/2; joystick.axis_center[1] = (WinJoyCaps.wYmax-WinJoyCaps.wYmin)/2; joystick.axis_center[2] = (WinJoyCaps.wZmax-WinJoyCaps.wZmin)/2; joystick.axis_center[4] = (WinJoyCaps.wRmax-WinJoyCaps.wRmin)/2; joystick.axis_center[5] = (WinJoyCaps.wUmax-WinJoyCaps.wUmin)/2; joystick.axis_center[6] = (WinJoyCaps.wVmax-WinJoyCaps.wVmin)/2; joystick.present_mask = JOY_1_X_AXIS | JOY_1_Y_AXIS; if (WinJoyCaps.wCaps & JOYCAPS_HASPOV) { joystick.has_pov = 1; joystick.present_mask |= JOY_1_POV; } else joystick.has_pov = 0; if (WinJoyCaps.wCaps & JOYCAPS_HASZ) joystick.present_mask |= JOY_1_Z_AXIS; if (WinJoyCaps.wCaps & JOYCAPS_HASR) joystick.present_mask |= JOY_1_R_AXIS; if (WinJoyCaps.wCaps & JOYCAPS_HASU) joystick.present_mask |= JOY_1_U_AXIS; if (WinJoyCaps.wCaps & JOYCAPS_HASV) joystick.present_mask |= JOY_1_V_AXIS; joy95_get_name(JOYSTICKID1, joyname, 255); if (!strcmpi(joyname, "CH Flightstick Pro") || FindArg("-ordinaljoy")) { CHStickHack = 1; } else CHStickHack = 0; return 1; }
bool PXL_Joystick::activate() { return joySetCapture(0, device_id, 0, false) == 0; }
static LRESULT WINAPI fuse_window_proc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { switch( msg ) { #if defined USE_JOYSTICK && !defined HAVE_JSW_H case WM_CREATE: if( joysticks_supported > 0 ) if( joySetCapture( hWnd, JOYSTICKID1, 0, FALSE ) ) ui_error( UI_ERROR_ERROR, "Couldn't start capture for joystick 1" ); if( joysticks_supported > 1 ) if( joySetCapture( hWnd, JOYSTICKID2, 0, FALSE ) ) ui_error( UI_ERROR_ERROR, "Couldn't start capture for joystick 2" ); break; #endif /* if defined USE_JOYSTICK && !defined HAVE_JSW_H */ case WM_COMMAND: if( ! handle_menu( LOWORD( wParam ), hWnd ) ) return 0; break; case WM_DROPFILES: handle_drop( ( HDROP )wParam ); return 0; case WM_CLOSE: menu_file_exit( 0 ); return 0; case WM_KEYDOWN: win32keyboard_keypress( wParam, lParam ); return 0; case WM_KEYUP: win32keyboard_keyrelease( wParam, lParam ); return 0; case WM_PAINT: if( ! win32ui_window_paint( hWnd, wParam, lParam ) ) return 0; break; case WM_SIZING: if( win32ui_window_resizing( hWnd, wParam, lParam ) ) return TRUE; break; case WM_SIZE: if( ! win32ui_window_resize( hWnd, wParam, lParam ) ) return 0; break; case WM_DRAWITEM: if( wParam == ID_STATUSBAR ) { win32statusbar_redraw( hWnd, lParam ); return TRUE; } break; case WM_DESTROY: fuse_exiting = 1; PostQuitMessage( 0 ); /* Stop the paused state to allow us to exit (occurs from main emulation loop) */ if( paused ) menu_machine_pause( 0 ); return 0; case WM_ENTERMENULOOP: case WM_ENTERSIZEMOVE: { fuse_emulation_pause(); return 0; } case WM_EXITMENULOOP: case WM_EXITSIZEMOVE: { fuse_emulation_unpause(); return 0; } case WM_LBUTTONUP: win32mouse_button( 1, 0 ); return 0; case WM_LBUTTONDOWN: win32mouse_button( 1, 1 ); return 0; case WM_MBUTTONUP: win32mouse_button( 2, 0 ); return 0; case WM_MBUTTONDOWN: win32mouse_button( 2, 1 ); return 0; case WM_RBUTTONUP: win32mouse_button( 3, 0 ); return 0; case WM_RBUTTONDOWN: win32mouse_button( 3, 1 ); return 0; case WM_MOUSEMOVE: win32mouse_position( lParam ); return 0; case WM_SETCURSOR: /* prevent the cursor from being redrawn if fuse has grabbed the mouse */ if( ui_mouse_grabbed ) return TRUE; else return( DefWindowProc( hWnd, msg, wParam, lParam ) ); case WM_ACTIVATE: if( ( LOWORD( wParam ) == WA_ACTIVE ) || ( LOWORD( wParam ) == WA_CLICKACTIVE ) ) win32ui_gain_focus( hWnd, wParam, lParam ); else if( LOWORD( wParam ) == WA_INACTIVE ) win32ui_lose_focus( hWnd, wParam, lParam ); /* We'll call DefWindowProc to get keyboard focus when debugger window is open and inactive */ break; case WM_USER_EXIT_PROCESS_MESSAGES: /* Odd case when message loop is overridden by a modal dialog. This should not be caught here, so we delay this notification */ exit_process_messages++; return 0; case WM_ERASEBKGND: /* Improves speed and avoid flickering when main window is invalidated by another window */ return TRUE; #if defined USE_JOYSTICK && !defined HAVE_JSW_H case MM_JOY1BUTTONDOWN: win32joystick_buttonevent( 0, 1, wParam ); break; case MM_JOY1BUTTONUP: win32joystick_buttonevent( 0, 0, wParam ); break; case MM_JOY2BUTTONDOWN: win32joystick_buttonevent( 1, 1, wParam ); break; case MM_JOY2BUTTONUP: win32joystick_buttonevent( 1, 0, wParam ); break; case MM_JOY1MOVE: win32joystick_move( 0, LOWORD( lParam ), HIWORD( lParam ) ); break; case MM_JOY2MOVE: win32joystick_move( 1, LOWORD( lParam ), HIWORD( lParam ) ); break; #endif /* if defined USE_JOYSTICK && !defined HAVE_JSW_H */ } return( DefWindowProc( hWnd, msg, wParam, lParam ) ); }
bool XBOXController::isConnected() { if (!m_connected) { UINT numDevs = joyGetNumDevs(); UINT selected = numDevs; m_connected = true; for (UINT i = 0; i < numDevs; ++i) { JOYCAPS caps; if (JOYERR_NOERROR == joyGetDevCaps(i, &caps, sizeof(caps))) { //yam2d::esLogMessage("Joystick(%d): %s", i, caps.szPname); if (i == m_joyID) { selected = i; m_caps = caps; } } } if (selected == numDevs) { m_connected = false; } yam2d::ESContext* ctx = yam2d::esGetCurrentContext(); if (joySetCapture(ctx->hWnd, m_joyID, 0, FALSE)) { m_connected = false; } } if (m_connected) { joyInfoEx.dwSize = sizeof(joyInfoEx); joyInfoEx.dwFlags = JOY_RETURNALL; m_prevJoyInfoEx = joyInfoEx; MMRESULT res = joyGetPosEx(m_joyID, &joyInfoEx); m_connected = false; if (JOYERR_NOERROR == res) { m_connected = true; } else if (MMSYSERR_NODRIVER == res) { yam2d::esLogMessage("Joystick(%d) The joystick driver is not present.", m_joyID); } else if (MMSYSERR_INVALPARAM == res) { yam2d::esLogMessage("Joystick(%d) An invalid parameter was passed.", m_joyID); } else if (MMSYSERR_BADDEVICEID == res) { yam2d::esLogMessage("Joystick(%d) The specified joystick identifier is invalid.", m_joyID); } else if (JOYERR_UNPLUGGED == res) { yam2d::esLogMessage("Joystick(%d) The specified joystick is not connected to the system.", m_joyID); } else if (JOYERR_PARMS == res) { yam2d::esLogMessage("Joystick(%d) The specified joystick identifier is invalid.", m_joyID); } else { yam2d::esLogMessage("Joystick(%d) unknown error", m_joyID); } } return m_connected; }
bool wxJoystick::SetCapture(wxWindow *win, int pollingFreq) { BOOL changed = (pollingFreq == 0); MMRESULT res = joySetCapture((HWND) win->GetHWND(), m_joystick, pollingFreq, changed); return (res == JOYERR_NOERROR); }
bool ScreenCamView::OnCreate( wxDocument* doc, /* TYPENOTE: Correct */ long flags ) { // Construct the (C++) child windows. PORTNOTE("other","ScreenCamView::OnCreate - Removed scroller / ruler usage") #ifndef EXCLUDE_FROM_XARALX RenderWindow = new CRenderWnd; HScrollBar = new CWinScroller(TRUE); VScrollBar = new CWinScroller(FALSE); Corner = new CScrollerCorner; // WEBSTER - markn 15/1/97 // No rulers in Webster #ifndef WEBSTER HRuler = new OILHorizontalRuler; VRuler = new OILVerticalRuler; OGadget = new OriginGadget; #endif //webster if (!RenderWindow || !HScrollBar || !VScrollBar || !Corner #ifndef WEBSTER ||!HRuler ||!VRuler ||!OGadget #endif //webster ) { Error::SetError(_R(IDE_CREATE_VIEW_FAILED), 0); InformError(); return -1; } #endif // Get base class to call CView functions, and get a document for this view. if( !CCamView::OnCreate( doc, flags ) ) // Something went wrong - pass error back. return false; PORTNOTE("other","ScreenCamView::OnCreate - Removed scroller usage") // Now get Windows to do its side of the construction. The stated sizes and // positions of the windows here will be changed very soon. #ifndef EXCLUDE_FROM_XARALX const CRect rcARect(-100,-100,-90,-90); if (!RenderWindow->Create("", "", 0, rcARect, this, 1) || !HScrollBar->Create(0, rcARect, this, 2) || !VScrollBar->Create(0, rcARect, this, 3) || !Corner->Create("", "", 0, rcARect, this, 4) // WEBSTER - markn 15/1/97 // No rulers in Webster #ifndef WEBSTER || !OGadget->Create(this) || !HRuler->Create(this) || !VRuler->Create(this) #endif //webster ) { Error::SetError(_R(IDE_CREATE_VIEW_FAILED), 0); InformError(); return -1; } #endif CreateNewDocView(); // WEBSTER - markn 15/1/97 // No rulers in Webster #ifndef WEBSTER // init the kernel rulers and establish pointer links to them PORTNOTE("other","ScreenCamView::OnCreate - Removed ruler usage") #ifndef EXCLUDE_FROM_XARALX RulerPair* pRulers=pDocView->GetpRulerPair(); pRulers->Init(pDocView,HRuler,VRuler,OGadget); HRuler->LinkToKernel(pRulers->GetpHorizontalRuler()); VRuler->LinkToKernel(pRulers->GetpVerticalRuler()); #endif #endif //webster ENSURE(pDocView != 0, "ScreenView::ScreenView can't get a new DocView!"); pDocView->ConnectToOilView(this); // find the last view so we can use some of it's settings to create the new // DocView * LastView = DocView::GetSelected(); // Link this and the DocView to the ViewState object. pDocView->SetViewState(Status); //////////////////////////////////////////////////////////////////////////////// wxScreenDC dc; wxSize pixsize=OSRenderRegion::GetFixedDCPPI(dc); PORTNOTE("other","ScreenCamView::OnCreate - Removed scroller usage") #ifndef EXCLUDE_FROM_XARALX // Set the logical pixel size accordingly (measured in millipoints). Take the // opportunity to pass the values into the scrollers and the OIL -> Windows coordinate // transform system. HScrollBar->SetGranularity(72000L / pixwidth); VScrollBar->SetGranularity(72000L / pixheight); #endif // Tell DocView how big the pixel size is. FIXED16 PixelWidth = FIXED16(72000.0/pixsize.x); FIXED16 PixelHeight = FIXED16(72000.0/pixsize.y); ERROR3IF(PixelWidth != PixelHeight, "Luke says non-square pixels are not supported"); pDocView->SetPixelSize(PixelWidth, PixelHeight); // Make our DocView the current DocView pDocView->SetCurrent(); GetCanvas()->SetScrollRate(1,1); if (GetFrame()) GetFrame()->GetClientSize(&CurrentSize.width,&CurrentSize.height); // Now the scrollers have all their information, we can set their appearance. // Make sure that they are invisible until the rest of the frame is ready /* XLONG x1 = CurrentSize.GetWidth () * PixelWidth; XLONG x2 = CurrentSize.GetHeight() * PixelHeight; GetFrame()->SetScrollbar(wxHORIZONTAL,0,x1,Status->WorkAreaExtent.hi.x-Status->WorkAreaExtent.lo.x,false); GetFrame()->SetScrollbar( wxVERTICAL,0,x2,Status->WorkAreaExtent.hi.y-Status->WorkAreaExtent.lo.y,false); */ SetScrollerStyle(ScrollerStyle = PropScrollersOn); ShowScrollers(DefaultScrollersState); ShowRulers(DefaultRulersState); /////////////////////////////////////////////////////////////////////////////// // Register for WM_DROPFILES messages // DragAcceptFiles(TRUE); // WEBSTER - markn 12/2/97 #if (_OLE_VER >= 0x200) // Register with OLE as a drop target. m_DropTarget.Register(this); #endif /////////////////////////////////////////////////////////////////////////////// // now that the ScreenView (and hence DocView) is stable, broadcast a message to let everyone know BROADCAST_TO_ALL(DocViewMsg(pDocView,DocViewMsg::NEWANDSTABLE)); // ****************** BODGE ************************** // This code will tell windows to send us messages when // the joystick gets waggled about. // We should really release the joystick at some point later, // but it gets released automatically when this ScreenView is // destroyed, so it will do for now. // The messages get passed to 'OnJoystickMove' member of this // class. #ifdef WIN32 PORTNOTE("other","ScreenCamView::OnCreate - Removed joystick usage") #ifndef EXCLUDE_FROM_XARALX JOYINFO joyinfo; UINT32 wNumDevs, wDeviceID; BOOL bDev1Attached, bDev2Attached; // Are there any Joysticks available ? if((wNumDevs = joyGetNumDevs()) == 0) return 0; // Nope. // Are there One or Two of them ? bDev1Attached = joyGetPos(JOYSTICKID1,&joyinfo) != JOYERR_UNPLUGGED; bDev2Attached = wNumDevs == 2 && joyGetPos(JOYSTICKID2,&joyinfo) != JOYERR_UNPLUGGED; if(bDev1Attached || bDev2Attached) // Decide which joystick to use wDeviceID = bDev1Attached ? JOYSTICKID1 : JOYSTICKID2; else return 0; // Grab those Messages !! MMRESULT JoyResult = joySetCapture(m_hWnd, wDeviceID, NULL, TRUE); #endif #endif // ****************** BODGE ************************** // Return success! return true; }