21
21
#include " mouse_config.h"
22
22
#include " mouse_interfaces.h"
23
23
#include " mouse_manymouse.h"
24
- #include " mouse_queue.h"
25
24
26
25
#include < algorithm>
27
26
#include < cctype>
@@ -39,7 +38,6 @@ CHECK_NARROWING();
39
38
40
39
static callback_number_t int74_ret_callback = 0 ;
41
40
42
- static MouseQueue &mouse_queue = MouseQueue::GetInstance();
43
41
static ManyMouseGlue &manymouse = ManyMouseGlue::GetInstance();
44
42
45
43
// ***************************************************************************
@@ -384,65 +382,36 @@ static Bitu int74_exit()
384
382
385
383
static Bitu int74_handler ()
386
384
{
387
- MouseEvent ev;
388
- mouse_queue.FetchEvent (ev);
389
-
390
- // Handle DOS events
391
- if (ev.request_dos ) {
392
- uint8_t mask = 0 ;
393
- if (ev.dos_moved ) {
394
- mask = MOUSEDOS_UpdateMoved ();
395
-
396
- // Taken from DOSBox X: HERE within the IRQ 12 handler
397
- // is the appropriate place to redraw the cursor. OSes
398
- // like Windows 3.1 expect real-mode code to do it in
399
- // response to IRQ 12, not "out of the blue" from the
400
- // SDL event handler like the original DOSBox code did
401
- // it. Doing this allows the INT 33h emulation to draw
402
- // the cursor while not causing Windows 3.1 to crash or
403
- // behave erratically.
404
- if (mask) {
405
- MOUSEDOS_DrawCursor ();
406
- }
407
- }
408
- if (ev.dos_button ) {
409
- const auto new_mask = mask | MOUSEDOS_UpdateButtons (ev.dos_buttons );
410
- mask = static_cast <uint8_t >(new_mask);
411
- }
412
- if (ev.dos_wheel ) {
413
- const auto new_mask = mask | MOUSEDOS_UpdateWheel ();
414
- mask = static_cast <uint8_t >(new_mask);
415
- }
416
-
417
- // If DOS driver's client is not interested in this particular
418
- // type of event - skip it
419
- if (!MOUSEDOS_HasCallback (mask)) {
420
- return int74_exit ();
421
- }
422
-
423
- const auto real_pt = CALLBACK_RealPointer (int74_ret_callback);
424
- CPU_Push16 (RealSeg (real_pt));
425
- CPU_Push16 (RealOff (static_cast <RealPt>(real_pt) + 7 ));
426
-
427
- return MOUSEDOS_DoCallback (mask, ev.dos_buttons );
428
- }
429
-
430
- // Handle PS/2 and BIOS mouse events
431
- if (ev.request_ps2 && mouse_shared.active_bios ) {
385
+ // Try BIOS events (from Intel 8042 controller)
386
+ if (MOUSEBIOS_CheckCallback ()) {
432
387
CPU_Push16 (RealSeg (CALLBACK_RealPointer (int74_ret_callback)));
433
388
CPU_Push16 (RealOff (CALLBACK_RealPointer (int74_ret_callback)));
389
+ MOUSEBIOS_DoCallback ();
390
+ // TODO: Handle both BIOS and DOS callback within
391
+ // in a single interrupt
392
+ return CBRET_NONE;
393
+ }
394
+
395
+ // Try DOS driver events
396
+ if (!mouse_shared.dos_cb_running ) {
397
+ const auto mask = MOUSEDOS_DoInterrupt ();
398
+ if (mask) {
399
+ const auto real_pt = CALLBACK_RealPointer (int74_ret_callback);
400
+ CPU_Push16 (RealSeg (real_pt));
401
+ CPU_Push16 (RealOff (static_cast <RealPt>(real_pt) + 7 ));
434
402
435
- MOUSEPS2_UpdatePacket ();
436
- return MOUSEBIOS_DoCallback ();
403
+ MOUSEDOS_DoCallback (mask);
404
+ return CBRET_NONE;
405
+ }
437
406
}
438
407
439
- // No mouse emulation module is interested in event
408
+ // No mouse emulation module is interested in the event
440
409
return int74_exit ();
441
410
}
442
411
443
412
Bitu int74_ret_handler ()
444
413
{
445
- mouse_queue. StartTimerIfNeeded ();
414
+ MOUSEDOS_FinalizeInterrupt ();
446
415
return CBRET_NONE;
447
416
}
448
417
@@ -507,29 +476,13 @@ void MOUSE_NotifyWindowActive(const bool is_active)
507
476
MOUSE_UpdateGFX ();
508
477
}
509
478
510
- void MOUSE_NotifyResetDOS ()
511
- {
512
- mouse_queue.ClearEventsDOS ();
513
- }
514
-
515
479
void MOUSE_NotifyDisconnect (const MouseInterfaceId interface_id)
516
480
{
517
481
auto interface = MouseInterface::Get (interface_id);
518
482
if (interface)
519
483
interface->NotifyDisconnect ();
520
484
}
521
485
522
- void MOUSE_NotifyFakePS2 ()
523
- {
524
- const auto interface = MouseInterface::GetPS2 ();
525
-
526
- if (interface && interface->IsUsingEvents ()) {
527
- MouseEvent ev;
528
- ev.request_ps2 = true ;
529
- mouse_queue.AddEvent (ev);
530
- }
531
- }
532
-
533
486
void MOUSE_NotifyBooting ()
534
487
{
535
488
for (auto &interface : mouse_interfaces)
@@ -567,14 +520,11 @@ void MOUSE_EventMoved(const float x_rel, const float y_rel,
567
520
// so it needs data in both formats.
568
521
569
522
// Notify mouse interfaces
570
-
571
- MouseEvent ev;
572
523
for (auto &interface : mouse_interfaces)
573
524
if (interface->IsUsingHostPointer ())
574
- interface->NotifyMoved (ev, x_rel, y_rel,
525
+ interface->NotifyMoved (x_rel, y_rel,
575
526
state.cursor_x_abs ,
576
527
state.cursor_y_abs );
577
- mouse_queue.AddEvent (ev);
578
528
}
579
529
580
530
void MOUSE_EventMoved (const float x_rel, const float y_rel,
@@ -587,11 +537,10 @@ void MOUSE_EventMoved(const float x_rel, const float y_rel,
587
537
return ;
588
538
}
589
539
540
+ // Notify mouse interface
590
541
auto interface = MouseInterface::Get (interface_id);
591
542
if (interface && interface->IsUsingEvents ()) {
592
- MouseEvent ev;
593
- interface->NotifyMoved (ev, x_rel, y_rel, 0 , 0 );
594
- mouse_queue.AddEvent (ev);
543
+ interface->NotifyMoved (x_rel, y_rel, 0 , 0 );
595
544
}
596
545
}
597
546
@@ -629,11 +578,10 @@ void MOUSE_EventButton(const uint8_t idx, const bool pressed)
629
578
}
630
579
}
631
580
632
- MouseEvent ev;
581
+ // Notify mouse interfaces
633
582
for (auto &interface : mouse_interfaces)
634
583
if (interface->IsUsingHostPointer ())
635
- interface->NotifyButton (ev, idx, pressed);
636
- mouse_queue.AddEvent (ev);
584
+ interface->NotifyButton (idx, pressed);
637
585
}
638
586
639
587
void MOUSE_EventButton (const uint8_t idx, const bool pressed,
@@ -648,11 +596,10 @@ void MOUSE_EventButton(const uint8_t idx, const bool pressed,
648
596
return ;
649
597
}
650
598
599
+ // Notify mouse interface
651
600
auto interface = MouseInterface::Get (interface_id);
652
601
if (interface && interface->IsUsingEvents ()) {
653
- MouseEvent ev;
654
- interface->NotifyButton (ev, idx, pressed);
655
- mouse_queue.AddEvent (ev);
602
+ interface->NotifyButton (idx, pressed);
656
603
}
657
604
}
658
605
@@ -665,11 +612,10 @@ void MOUSE_EventWheel(const int16_t w_rel)
665
612
return ;
666
613
}
667
614
668
- MouseEvent ev;
615
+ // Notify mouse interfaces
669
616
for (auto &interface : mouse_interfaces)
670
617
if (interface->IsUsingHostPointer ())
671
- interface->NotifyWheel (ev, w_rel);
672
- mouse_queue.AddEvent (ev);
618
+ interface->NotifyWheel (w_rel);
673
619
}
674
620
675
621
void MOUSE_EventWheel (const int16_t w_rel, const MouseInterfaceId interface_id)
@@ -681,11 +627,10 @@ void MOUSE_EventWheel(const int16_t w_rel, const MouseInterfaceId interface_id)
681
627
return ;
682
628
}
683
629
630
+ // Notify mouse interface
684
631
auto interface = MouseInterface::Get (interface_id);
685
632
if (interface && interface->IsUsingEvents ()) {
686
- MouseEvent ev;
687
- interface->NotifyWheel (ev, w_rel);
688
- mouse_queue.AddEvent (ev);
633
+ interface->NotifyWheel (w_rel);
689
634
}
690
635
}
691
636
@@ -1041,7 +986,7 @@ void MOUSE_StartupIfReady()
1041
986
: " be sent to the game/program (clicks not used to capture/release)" );
1042
987
}
1043
988
1044
- // Callback for ps2 irq
989
+ // Callback for PS/2 BIOS or DOS driver IRQ
1045
990
auto call_int74 = CALLBACK_Allocate ();
1046
991
CALLBACK_Setup (call_int74, &int74_handler, CB_IRQ12, " int 74" );
1047
992
// pseudocode for CB_IRQ12:
0 commit comments