vbox的更動 22810 路徑 trunk/src/VBox/Devices/Input/DevPS2.cpp
- 時間撮記:
- 2009-9-7 下午01:41:45 (15 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/Devices/Input/DevPS2.cpp
r22793 r22810 57 57 #include "../Builtins.h" 58 58 59 #define PCKBD_SAVED_STATE_VERSION 259 #define PCKBD_SAVED_STATE_VERSION 3 60 60 61 61 … … 171 171 #define KBD_QUEUE_SIZE 256 172 172 173 #ifdef VBOX 174 # define MOUSE_REPORT_HORIZONTAL 0x01 175 # define MOUSE_OUTSTANDING_CLICK 0x02 176 #endif 177 173 178 typedef struct { 174 179 #ifndef VBOX … … 221 226 int32_t mouse_dy; 222 227 int32_t mouse_dz; 228 #ifdef VBOX 229 int32_t mouse_dw; 230 int32_t mouse_flags; 231 #endif 223 232 uint8_t mouse_buttons; 224 233 … … 331 340 332 341 #if defined(DEBUG_MOUSE) || defined(DEBUG_KBD) 333 if (aux) 334 Log(("mouse event: 0x%02x\n", b)); 342 if (aux == 1) 343 LogRel3(("%s: mouse command response: 0x%02x\n", __PRETTY_FUNCTION__, b)); 344 else if (aux == 2) 345 LogRel3(("%s: mouse event data: 0x%02x\n", __PRETTY_FUNCTION__, b)); 335 346 #ifdef DEBUG_KBD 336 347 else 337 Log (("kbd event: 0x%02x\n", b));348 LogRel3(("%s: kbd event: 0x%02x\n", __PRETTY_FUNCTION__, b)); 338 349 #endif 339 350 #endif … … 709 720 #endif /* VBOX */ 710 721 unsigned int b; 711 int dx1, dy1, dz1 ;722 int dx1, dy1, dz1, dw1; 712 723 713 724 dx1 = s->mouse_dx; 714 725 dy1 = s->mouse_dy; 715 726 dz1 = s->mouse_dz; 727 dw1 = s->mouse_dw; 728 LogRel3(("%s: dx=%d, dy=%d, dz=%d, dw=%d\n", __PRETTY_FUNCTION__, 729 dx1, dy1, dz1, dw1)); 716 730 /* XXX: increase range to 8 bits ? */ 717 731 if (dx1 > 127) … … 749 763 break; 750 764 case 4: 765 #ifndef VBOX 751 766 if (dz1 > 7) 752 767 dz1 = 7; 753 768 else if (dz1 < -7) 754 769 dz1 = -7; 755 b = (dz1 & 0x0f) | ((s->mouse_buttons & 0x18) << 1); 756 #ifdef VBOX 770 #else 771 if (dz1 > 1) 772 dz1 = 1; 773 else if (dz1 < -1) 774 dz1 = -1; 775 else if (dw1 > 1) 776 dw1 = 1; 777 else if (dw1 < -1) 778 dw1 = -1; 779 if (dz1) 780 dw1 = 0; 781 #endif 782 #ifdef VBOX 783 if ((s->mouse_flags & MOUSE_REPORT_HORIZONTAL) && dw1) 784 b = 0x40 | (dw1 & 0x3f); 785 else 786 { 787 b = (dz1 & 0x0f) | ((dw1 << 1) & 0x0f) 788 | ((s->mouse_buttons & 0x18) << 1); 789 s->mouse_flags &= ~MOUSE_OUTSTANDING_CLICK; 790 } 757 791 kbd_queue(s, b, aux); 758 792 #else /* !VBOX */ 793 b = (dz1 & 0x0f) | ((s->mouse_buttons & 0x18) << 1); 759 794 kbd_queue(s, b, 1); 760 795 #endif /* !VBOX */ … … 766 801 s->mouse_dy -= dy1; 767 802 s->mouse_dz -= dz1; 803 #ifdef VBOX 804 s->mouse_dw -= dw1; 805 #endif 768 806 } 769 807 770 808 #ifdef IN_RING3 809 #ifndef VBOX 771 810 static void pc_kbd_mouse_event(void *opaque, 772 811 int dx, int dy, int dz, int buttons_state) 812 #else 813 static void pc_kbd_mouse_event(void *opaque, 814 int dx, int dy, int dz, int dw, int buttons_state) 815 #endif 773 816 { 774 817 KBDState *s = (KBDState*)opaque; … … 781 824 s->mouse_dy -= dy; 782 825 s->mouse_dz += dz; 826 #ifdef VBOX 827 s->mouse_dw += dw; 828 #endif 783 829 #ifndef VBOX 784 830 /* XXX: SDL sometimes generates nul events: we delete them */ … … 787 833 return; 788 834 #else 789 /* This issue does not affect VBox, and under some circumstances (which?) 790 * we may wish to send null events to make mouse integration work. */ 835 /* The issue described above does not affect VBox, and under some 836 * circumstances (which?) we may even wish to send null events to make 837 * mouse integration work. */ 838 /* In horizontal reporting mode, we may need to send an additional packet 839 * for the forth and fifth buttons, as they can't share a packet with a 840 * horizontal scroll delta. */ 841 if ((s->mouse_buttons & 0x18) != (buttons_state & 0x18)) 842 s->mouse_flags |= MOUSE_OUTSTANDING_CLICK; 791 843 #endif 792 844 s->mouse_buttons = buttons_state; … … 799 851 too big deltas */ 800 852 kbd_mouse_send_packet(s, false); 801 if (s->mouse_dx == 0 && s->mouse_dy == 0 && s->mouse_dz == 0 )853 if (s->mouse_dx == 0 && s->mouse_dy == 0 && s->mouse_dz == 0 && s->mouse_dw == 0 && !(s->mouse_flags & MOUSE_OUTSTANDING_CLICK)) 802 854 break; 803 855 } … … 821 873 { 822 874 #ifdef DEBUG_MOUSE 823 Log (("kbd: write mouse 0x%02x\n", val));875 LogRelFlowFunc(("kbd: write mouse 0x%02x\n", val)); 824 876 #endif 825 877 #ifdef VBOX … … 949 1001 s->mouse_sample_rate = val; 950 1002 /* detect IMPS/2 or IMEX */ 1003 #ifdef VBOX 1004 /* And enable horizontal scrolling reporting when requested */ 1005 #endif 951 1006 switch(s->mouse_detect_state) { 952 1007 default: … … 960 1015 else if (val == 200) 961 1016 s->mouse_detect_state = 3; 1017 #ifdef VBOX 1018 else if ((val == 80) && s->mouse_type == 4 /* IMEX */) 1019 /* enable horizontal scrolling, byte two */ 1020 s->mouse_detect_state = 4; 1021 #endif 962 1022 else 963 1023 s->mouse_detect_state = 0; 964 1024 break; 965 1025 case 2: 1026 #ifdef VBOX 1027 if (val == 80) 1028 { 1029 LogRelFlowFunc(("switching mouse device to IMPS/2 mode\n")); 1030 s->mouse_type = 3; /* IMPS/2 */ 1031 } 1032 #else 966 1033 if (val == 80) 967 1034 s->mouse_type = 3; /* IMPS/2 */ 1035 #endif 968 1036 s->mouse_detect_state = 0; 969 1037 break; 970 1038 case 3: 1039 #ifdef VBOX 1040 if (val == 80) 1041 { 1042 LogRelFlowFunc(("switching mouse device to IMEX mode\n")); 1043 s->mouse_type = 4; /* IMEX */ 1044 } 1045 #else 971 1046 if (val == 80) 972 1047 s->mouse_type = 4; /* IMEX */ 1048 #endif 973 1049 s->mouse_detect_state = 0; 974 1050 break; 1051 #ifdef VBOX 1052 case 4: 1053 if (val == 40) 1054 { 1055 LogFlowFunc(("enabling IMEX horizontal scrolling reporting\n")); 1056 s->mouse_flags |= MOUSE_REPORT_HORIZONTAL; 1057 } 1058 s->mouse_detect_state = 0; 1059 break; 1060 #endif 975 1061 } 976 1062 kbd_queue(s, AUX_ACK, 1); … … 1078 1164 s->mouse_dy = 0; 1079 1165 s->mouse_dz = 0; 1166 s->mouse_dw = 0; 1167 s->mouse_flags = 0; 1080 1168 s->mouse_buttons = 0; 1081 1169 #endif … … 1119 1207 qemu_put_be32s(f, &s->mouse_dy); 1120 1208 qemu_put_be32s(f, &s->mouse_dz); 1209 #ifdef VBOX 1210 qemu_put_be32s(f, &s->mouse_dw); 1211 qemu_put_be32s(f, &s->mouse_flags); 1212 #endif 1121 1213 qemu_put_8s(f, &s->mouse_buttons); 1122 1214 … … 1156 1248 KBDState *s = (KBDState*)opaque; 1157 1249 1158 if (version_id !=PCKBD_SAVED_STATE_VERSION)1250 if (version_id < 2 || version_id > PCKBD_SAVED_STATE_VERSION) 1159 1251 #ifndef VBOX 1160 1252 return -EINVAL; … … 1177 1269 qemu_get_be32s(f, (uint32_t *)&s->mouse_dy); 1178 1270 qemu_get_be32s(f, (uint32_t *)&s->mouse_dz); 1271 #ifdef VBOX 1272 if (version_id > 2) 1273 { 1274 qemu_get_be32s(f, (uint32_t *)&s->mouse_dw); 1275 qemu_get_be32s(f, (uint32_t *)&s->mouse_flags); 1276 } 1277 #endif 1179 1278 qemu_get_8s(f, &s->mouse_buttons); 1180 1279 #ifdef VBOX … … 1537 1636 * @param fButtonStates The button states. 1538 1637 */ 1539 static DECLCALLBACK(int) kbdMousePutEvent(PPDMIMOUSEPORT pInterface, int32_t i32DeltaX, int32_t i32DeltaY, int32_t i32DeltaZ, uint32_t fButtonStates)1638 static DECLCALLBACK(int) kbdMousePutEvent(PPDMIMOUSEPORT pInterface, int32_t i32DeltaX, int32_t i32DeltaY, int32_t i32DeltaZ, int32_t i32DeltaW, uint32_t fButtonStates) 1540 1639 { 1541 1640 KBDState *pThis = IMOUSEPORT_2_KBDSTATE(pInterface); 1542 1641 int rc = PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY); 1543 1642 AssertReleaseRC(rc); 1544 pc_kbd_mouse_event(pThis, i32DeltaX, i32DeltaY, i32DeltaZ, fButtonStates);1643 pc_kbd_mouse_event(pThis, i32DeltaX, i32DeltaY, i32DeltaZ, i32DeltaW, fButtonStates); 1545 1644 PDMCritSectLeave(&pThis->CritSect); 1546 1645 return VINF_SUCCESS;
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器