Changeset 2763 for trunk/synergy/lib/platform/CPMScreen.cpp
- Timestamp:
- Aug 13, 2006, 12:50:25 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/synergy/lib/platform/CPMScreen.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/synergy/lib/platform/CPMScreen.cpp
r2762 r2763 71 71 assert(s_screen == NULL); 72 72 s_screen = this; 73 73 74 74 75 // create the event queue buffer first so we know there is a message queue. … … 93 94 94 95 try { 95 if (m_isPrimary) 96 m_hmodHook = openHookLibrary("synrgyhk"); 96 m_hmodHook = openHookLibrary("synrgyhk"); 97 97 m_screensaver = new CPMScreenSaver(); 98 98 m_keyState = new CPMKeyState(getEventTarget()); … … 528 528 } 529 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 530 569 void 531 570 CPMScreen::fakeMouseButton(ButtonID id, bool press) const 532 571 { 533 //m_desks->fakeMouseButton(id, press); 572 // determin the message. 573 ULONG msg; 574 switch (id) { 575 case kButtonLeft: 576 msg = press ? WM_BUTTON1DOWN : WM_BUTTON1UP; 577 break; 578 case kButtonRight: 579 msg = press ? WM_BUTTON2DOWN : WM_BUTTON2UP; 580 break; 581 case kButtonMiddle: 582 msg = press ? WM_BUTTON3DOWN : WM_BUTTON3UP; 583 break; 584 default: 585 return; 586 } 587 588 // mp1 589 POINTL ptl; 590 if (!WinQueryPointerPos(HWND_DESKTOP, &ptl)) { 591 LOG((CLOG_CRIT "fakeMouseButton: failed %#lx", WinGetLastError(CPMUtil::getHAB()))); 592 ptl.x = m_xCenter; 593 ptl.y = m_yCenter; 594 } 595 596 // forge the message. 597 fakeMouseMessage(msg, MPFROM2SHORT(ptl.x, ptl.y)); 534 598 } 535 599 … … 539 603 LOG((CLOG_DEBUG "fakeMouseMove: %d,%d (y=%d)", x, m_cy - y, y)); 540 604 if (WinSetPointerPos(HWND_DESKTOP, x, m_cy - y)) { 605 606 607 608 609 610 611 612 613 614 615 541 616 return; 542 617 } … … 550 625 if (WinQueryPointerPos(HWND_DESKTOP, &ptl)) { 551 626 LOG((CLOG_DEBUG "fakeMouseRelativeMove: %d,%d (%d,%d +/- %d,%d)", ptl.x + dx, ptl.y - dy, ptl.y, ptl.x, dx, dy)); 552 if (WinSetPointerPos(HWND_DESKTOP, ptl.x + dx, ptl.y - dy)) { 553 return; 627 fakeMouseMove(ptl.x + dx, ptl.y - dy - m_cy); 628 return; 629 } 630 LOG((CLOG_CRIT "fakeMouseRelativeMove: failed %#lx", WinGetLastError(CPMUtil::getHAB()))); 631 } 632 633 void 634 CPMScreen::fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const 635 { 636 #if 0 /** @todo send scroll messages the the window beneath the cursor. */ 637 POINTL ptl; 638 if (WinQueryPointerPos(HWND_DESKTOP, &ptl)) { 639 } 640 #else 641 /* dead simple arrow movement. */ 642 yDelta /= 30; 643 while (yDelta != 0) { 644 if (yDelta < 0) { 645 yDelta++; 646 fakeMessage(WM_CHAR, MPFROMSH2CH(KC_VIRTUALKEY | KC_SCANCODE, 1, 0x66), MPFROM2SHORT(0x50e0, VK_DOWN)); 647 fakeMessage(WM_CHAR, MPFROMSH2CH(KC_VIRTUALKEY | KC_SCANCODE | KC_KEYUP | KC_LONEKEY | KC_TOGGLE, 1, 0x66), MPFROM2SHORT(0x50e0, VK_DOWN)); 648 } else { 649 yDelta--; 650 fakeMessage(WM_CHAR, MPFROMSH2CH(KC_VIRTUALKEY | KC_SCANCODE, 1, 0x61), MPFROM2SHORT(0x48e0, VK_UP)); 651 fakeMessage(WM_CHAR, MPFROMSH2CH(KC_VIRTUALKEY | KC_SCANCODE | KC_KEYUP | KC_LONEKEY | KC_TOGGLE, 1, 0x61), MPFROM2SHORT(0x48e0, VK_UP)); 554 652 } 555 653 } 556 LOG((CLOG_CRIT "fakeMouseRelativeMove: failed %#lx", WinGetLastError(CPMUtil::getHAB()))); 557 } 558 559 void 560 CPMScreen::fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const 561 { 562 //m_desks->fakeMouseWheel(xDelta, yDelta); 654 #endif 563 655 } 564 656 … … 602 694 CPMScreen::openHookLibrary(const char* name) 603 695 { 604 // load the hook library 605 HMODULE hmod; 606 APIRET rc = DosLoadModule(NULL, 0, (PCSZ)name, &hmod); 696 // load the hook library - try with qualified name first. 697 HMODULE hmod = NULLHANDLE; 698 APIRET rc = ERROR_FILE_NOT_FOUND; 699 char szFullName[CCHMAXPATH + 10]; 700 if (!_execname(szFullName, CCHMAXPATH)) { 701 char *psz = strrchr(szFullName, '\\'); 702 if (!psz || strrchr(psz, '/')) { 703 psz = strrchr(psz, '/'); 704 } 705 if (psz) { 706 strcat(strcpy(psz + 1, name), ".DLL"); 707 } 708 rc = DosLoadModule(NULL, 0, (PCSZ)szFullName, &hmod); 709 } 710 711 // if that failed, try with the bare name. 712 if (rc != NO_ERROR) { 713 rc = DosLoadModule(NULL, 0, (PCSZ)name, &hmod); 714 } else { 715 name = szFullName; 716 } 607 717 if (rc != NO_ERROR) { 608 718 LOG((CLOG_ERR "Failed to load hook library (%s), rc=%d ", name, rc)); … … 611 721 612 722 // look up functions 613 if ( (rc = DosQueryProcAddr(hmod, 0, (PCSZ)"_setSides", (PPFN)&m_setSides)) != NO_ERROR 723 if ( (rc = DosQueryProcAddr(hmod, 0, (PCSZ)"_fakeMsg", (PPFN)&m_fakeMsg )) != NO_ERROR 724 || (rc = DosQueryProcAddr(hmod, 0, (PCSZ)"_setSides", (PPFN)&m_setSides)) != NO_ERROR 614 725 || (rc = DosQueryProcAddr(hmod, 0, (PCSZ)"_setZone", (PPFN)&m_setZone )) != NO_ERROR 615 726 || (rc = DosQueryProcAddr(hmod, 0, (PCSZ)"_setMode", (PPFN)&m_setMode )) != NO_ERROR … … 627 738 throw XScreenOpenFailure(); 628 739 } 740 629 741 return hmod; 630 742 } … … 633 745 CPMScreen::closeHookLibrary(HMODULE hmod) const 634 746 { 747 635 748 if (hmod != NULL) { 636 749 m_cleanup(m_hab);
Note:
See TracChangeset
for help on using the changeset viewer.
