Common Source Code Project for Qt (a.k.a for FM-7).
Revision | 525f70e1a510190c80f87950a95f65c81428f70f (tree) |
---|---|
Time | 2020-12-13 06:37:26 |
Author | K.Ohta <whatisthis.sowhat@gmai...> |
Commiter | K.Ohta |
[UI][Qt][MOUSE][WIP] Fixing mouse clicking on one-board-computers.
@@ -860,7 +860,12 @@ void EmuThreadClassBase::set_romakana(bool flag) | ||
860 | 860 | |
861 | 861 | void EmuThreadClassBase::moved_mouse(double x, double y, double globalx, double globaly) |
862 | 862 | { |
863 | - if(using_flags->is_use_one_board_computer() || using_flags->is_use_mouse() || (using_flags->get_max_button() > 0)) { | |
863 | + if(using_flags->is_use_one_board_computer() || (using_flags->get_max_button() > 0)) { | |
864 | +// bool flag = p_osd->is_mouse_enabled(); | |
865 | +// if(!flag) return; | |
866 | +// printf("Mouse Moved: %g, %g\n", x, y); | |
867 | + p_osd->set_mouse_pointer(floor(x), floor(y)); | |
868 | + } else if(using_flags->is_use_mouse()) { | |
864 | 869 | double factor = (double)(p_config->mouse_sensitivity & ((1 << 16) - 1)); |
865 | 870 | mouse_x = (int)(floor((x * factor) / 8192.0)); |
866 | 871 | mouse_y = (int)(floor((y * factor) / 8192.0)); |
@@ -877,7 +882,7 @@ void EmuThreadClassBase::button_pressed_mouse_sub(Qt::MouseButton button) | ||
877 | 882 | |
878 | 883 | if(using_flags->is_use_one_board_computer() || using_flags->is_use_mouse() || (using_flags->get_max_button() > 0)) { |
879 | 884 | int stat = p_osd->get_mouse_button(); |
880 | - bool flag = p_osd->is_mouse_enabled(); | |
885 | + bool flag = (p_osd->is_mouse_enabled() || using_flags->is_use_one_board_computer() || (using_flags->get_max_button() > 0)); | |
881 | 886 | switch(button) { |
882 | 887 | case Qt::LeftButton: |
883 | 888 | stat |= 0x01; |
@@ -48,15 +48,24 @@ void GLDrawClass::mouseMoveEvent(QMouseEvent *event) | ||
48 | 48 | double yy, gyy; |
49 | 49 | OSD_BASE *p_osd = using_flags->get_osd(); |
50 | 50 | int d_ww, d_hh; |
51 | - if(p_osd != NULL) { | |
52 | - d_ww = p_osd->get_vm_screen_width(); | |
53 | - d_hh = p_osd->get_vm_screen_height(); | |
54 | - } else { | |
51 | + if(using_flags->is_use_one_board_computer() || (using_flags->get_max_button() > 0)) { | |
55 | 52 | d_ww = using_flags->get_screen_width(); |
56 | 53 | d_hh = using_flags->get_screen_height(); |
54 | + } else { | |
55 | + if(p_osd != NULL) { | |
56 | + d_ww = p_osd->get_vm_screen_width(); | |
57 | + d_hh = p_osd->get_vm_screen_height(); | |
58 | + } else { | |
59 | + d_ww = using_flags->get_screen_width(); | |
60 | + d_hh = using_flags->get_screen_height(); | |
61 | + } | |
62 | + } | |
63 | + QPointF pos; | |
64 | + if(using_flags->is_use_one_board_computer() || (using_flags->get_max_button() > 0)) { | |
65 | + pos = event->localPos(); | |
66 | + } else { | |
67 | + pos = event->screenPos(); | |
57 | 68 | } |
58 | -// QPointF pos = event->localPos(); | |
59 | - QPointF pos = event->screenPos(); | |
60 | 69 | double xpos = (double)(pos.x()) / (double)width(); |
61 | 70 | double ypos = (double)(pos.y()) / (double)height(); |
62 | 71 | double gxpos = (double)(event->globalPos().x()) / (double)width(); |
@@ -58,6 +58,7 @@ void OSD_BASE::initialize_input() | ||
58 | 58 | memset(mouse_status, 0, sizeof(mouse_status)); |
59 | 59 | // mouse emulation is disenabled |
60 | 60 | mouse_enabled = false; |
61 | + | |
61 | 62 | mouse_ptrx = mouse_oldx = get_screen_width() / 2; |
62 | 63 | mouse_ptry = mouse_oldy = get_screen_height() / 2; |
63 | 64 | // initialize keycode convert table |
@@ -836,7 +837,7 @@ bool OSD_BASE::is_mouse_enabled() | ||
836 | 837 | |
837 | 838 | void OSD_BASE::set_mouse_pointer(int x, int y) |
838 | 839 | { |
839 | - if(mouse_enabled) { | |
840 | + if(using_flags->is_use_one_board_computer() || (using_flags->get_max_button() > 0) || (mouse_enabled)) { | |
840 | 841 | QMutexLocker n(mouse_mutex); |
841 | 842 | |
842 | 843 | mouse_ptrx = x; |
@@ -844,7 +845,7 @@ void OSD_BASE::set_mouse_pointer(int x, int y) | ||
844 | 845 | |
845 | 846 | // mouse_oldx = mouse_ptrx; |
846 | 847 | // mouse_oldy = mouse_ptry; |
847 | - //printf("Mouse Moved: (%d, %d) -> delta(%d, %d)\n", mouse_ptrx, mouse_ptry, delta_x, delta_y); | |
848 | +// printf("Mouse Moved: (%d, %d)\n", mouse_ptrx, mouse_ptry); | |
848 | 849 | } |
849 | 850 | } |
850 | 851 |
@@ -128,22 +128,37 @@ int OSD::get_vm_buttons_code(int num) | ||
128 | 128 | void OSD::update_buttons(bool press_flag, bool release_flag) |
129 | 129 | { |
130 | 130 | #if defined(MAX_BUTTONS) |
131 | + if((mouse_button & 1) != 0) { | |
132 | + mouse_oldx = mouse_oldy = 0; | |
133 | + return; | |
134 | + } | |
131 | 135 | if(!press_flag && !release_flag) { |
136 | + if((mouse_button & 1) != 0) { | |
137 | + mouse_oldx = mouse_oldy = 0; | |
138 | + return; | |
139 | + } | |
140 | + if((mouse_oldx == mouse_ptrx) || (mouse_oldy == mouse_ptry)) return; | |
132 | 141 | int ii; |
133 | 142 | ii = 0; |
134 | 143 | for(ii = 0; vm_buttons[ii].code != 0x00; ii++) { |
135 | 144 | if((mouse_ptrx >= vm_buttons[ii].x) && (mouse_ptrx < (vm_buttons[ii].x + vm_buttons[ii].width))) { |
145 | + | |
136 | 146 | if((mouse_ptry >= vm_buttons[ii].y) && (mouse_ptry < (vm_buttons[ii].y + vm_buttons[ii].height))) { |
137 | 147 | if((key_status[vm_buttons[ii].code] & 0x7f) == 0) this->press_button(ii); |
148 | + mouse_oldx = mouse_ptrx; | |
149 | + mouse_oldy = mouse_ptry; | |
150 | + return; | |
138 | 151 | } |
139 | 152 | } |
140 | 153 | } |
141 | 154 | if((mouse_ptrx >= vm_buttons[ii].x) && (mouse_ptrx < (vm_buttons[ii].x + vm_buttons[ii].width))) { |
142 | 155 | if((mouse_ptry >= vm_buttons[ii].y) && (mouse_ptry < (vm_buttons[ii].y + vm_buttons[ii].height))) { |
143 | 156 | this->press_button(ii); |
157 | + mouse_oldx = mouse_ptrx; | |
158 | + mouse_oldy = mouse_ptry; | |
144 | 159 | } |
145 | 160 | } |
146 | - mouse_ptrx = mouse_ptry = 0; | |
161 | +// mouse_ptrx = mouse_ptry = 0; | |
147 | 162 | } |
148 | 163 | //return; |
149 | 164 | #endif |