-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMSMOUSE.PAS
More file actions
792 lines (759 loc) · 24.7 KB
/
Copy pathMSMOUSE.PAS
File metadata and controls
792 lines (759 loc) · 24.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
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
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
{ @author: Sylvain Maltais (support@gladir.com)
@created: 2026
@website(https://www.gladir.com/msdos0)
@abstract(Target: Turbo Pascal 7, Free Pascal 3.2)
}
Program MSMOUSE;
{$M 16384,0,65535}
{$A-}
Uses DOS;
Const
{ Version du pilote souris - Compatible Microsoft Mouse Driver }
MOUSE_DRIVER_VERSION = $0806; { Version 8.06 - Format: version majeure.mineure }
{ Codes d'erreur pour les op‚rations souris }
ERR_SUCCESS = 0; { Op‚ration r‚ussie }
ERR_INVALID_FUNCTION = 1; { Fonction non support‚e }
ERR_NO_MOUSE = 2; { Aucune souris d‚tect‚e }
ERR_DRIVER_NOT_INSTALLED = 3; { Pilote non install‚ }
ERR_INVALID_PARAMETER = 4; { ParamŠtre invalide }
{ Interruption logicielle souris - Standard MS-DOS }
MOUSE_INT = $33; { INT 33h - Interface standard souris }
{ Ports s‚rie pour souris série Microsoft/compatibles }
COM1_BASE = $3F8; { Port s‚rie COM1 - Adresse de base }
COM2_BASE = $2F8; { Port s‚rie COM2 - Adresse de base }
COM3_BASE = $3E8; { Port s‚rie COM3 - Adresse de base }
COM4_BASE = $2E8; { Port s‚rie COM4 - Adresse de base }
{ Ports PS/2 pour souris PS/2 (contr“leur clavier 8042) }
PS2_DATA_PORT = $60; { Port de donn‚es PS/2 }
PS2_STATUS_PORT = $64; { Port de statut PS/2 (lecture) }
PS2_COMMAND_PORT = $64; { Port de commande PS/2 (‚criture) }
{ Num‚ros IRQ pour interruptions mat‚rielles souris }
PS2_IRQ = 12; { IRQ 12 - Souris PS/2 (PIC esclave) }
COM1_IRQ = 4; { IRQ 4 - Port s‚rie COM1 }
COM2_IRQ = 3; { IRQ 3 - Port s‚rie COM2 }
{ Types de souris support‚s par le pilote }
MOUSE_TYPE_NONE = 0; { Aucune souris d‚tect‚e }
MOUSE_TYPE_SERIAL = 1; { Souris s‚rie (COM1-COM4) }
MOUSE_TYPE_PS2 = 2; { Souris PS/2 (port auxiliaire) }
MOUSE_TYPE_BUS = 3; { Souris bus (IBM PC/InPort) }
{ Masques de bits pour l'‚tat des boutons souris }
BUTTON_LEFT = 1; { Bit 0 - Bouton gauche }
BUTTON_RIGHT = 2; { Bit 1 - Bouton droit }
BUTTON_MIDDLE = 4; { Bit 2 - Bouton central }
{ Limites par d‚faut de la zone de travail souris }
DEFAULT_MIN_X = 0; { Coordonn‚e X minimale }
DEFAULT_MAX_X = 639; { Coordonn‚e X maximale (mode 640x200) }
DEFAULT_MIN_Y = 0; { Coordonn‚e Y minimale }
DEFAULT_MAX_Y = 199; { Coordonn‚e Y maximale (mode 640x200) }
Type
{ Structure d'‚tat de la souris }
TMouseState = Record
X, Y: Integer; { Position actuelle }
Buttons: Byte; { tat des boutons }
DeltaX, DeltaY: Integer; { D‚placement depuis derniŠre lecture }
Visible: Boolean; { Curseur visible }
MinX, MaxX: Integer; { Limites horizontales }
MinY, MaxY: Integer; { Limites verticales }
MickeyX, MickeyY: Integer; { Sensibilit‚ }
DoubleSpeedThreshold: Integer; { Seuil de vitesse double }
End;
{ Structure de contr“le du pilote TSR }
TMouseDriver = Record
Installed: Boolean; { Pilote install‚ }
MouseType: Byte; { Type de souris d‚tect‚ }
SerialPort: Word; { Port s‚rie (si souris s‚rie) }
SerialIRQ: Byte; { IRQ s‚rie }
State: TMouseState; { tat de la souris }
UserHandler: Pointer; { Gestionnaire utilisateur }
CallMask: Word; { Masque d'appel utilisateur }
OldInt33Handler: Pointer; { Ancien gestionnaire INT 33h }
OldSerialHandler: Pointer; { Ancien gestionnaire IRQ s‚rie }
OldPS2Handler: Pointer; { Ancien gestionnaire IRQ PS/2 }
InitializedHardware: Boolean; { Mat‚riel initialis‚ }
SilentMode: Boolean; { Mode silencieux }
End;
Var
Language:(_French,_English,_Germany,_Italian,_Spain,_Albanian,_Portuguese,_Swedish,_Danish,_Japanese);
TmpLanguage: String;
MouseDriver: TMouseDriver;
I: Byte;
Param: String;
{ Convertir une chaŒne en majuscules }
Function StrToUpper(S: String): String;
Var
I: Byte;
Begin
For I := 1 to Length(S) do Begin
If S[I] in ['a'..'z'] Then S[I] := Chr(Ord(S[I]) - 32);
End;
StrToUpper := S;
End;
{ Lire un byte d'un port }
Function PortReadByte(Port: Word): Byte;
{$IFDEF FPC}
Begin
PortReadByte := 0; { Simulation pour Free Pascal }
End;
{$ELSE}
Begin
Asm
Mov DX, Port
In AL, DX
Mov @Result, AL
End;
End;
{$ENDIF}
{ crire un byte dans un port }
Procedure PortWriteByte(Port: Word; Value: Byte);
{$IFDEF FPC}
Begin
{ Simulation pour Free Pascal - pas d'accŠs direct aux ports }
End;
{$ELSE}
Begin
Asm
Mov DX, Port
Mov AL, Value
Out DX, AL
End;
End;
{$ENDIF}
{ D‚tecter une souris s‚rie sur un port COM }
Function DetectSerialMouse(ComPort: Word): Boolean;
{$IFDEF FPC}
Begin
DetectSerialMouse := False; { Simulation pour Free Pascal }
End;
{$ELSE}
Var
OldValue, TestValue: Byte;
Begin
DetectSerialMouse := False;
{ Test de pr‚sence du port s‚rie }
OldValue := PortReadByte(ComPort + 4); { Registre de contr“le modem }
PortWriteByte(ComPort + 4, $10); { RTS on, DTR off }
TestValue := PortReadByte(ComPort + 6); { Registre d'‚tat modem }
If (TestValue And $10) = 0 Then Begin { CTS devrait ˆtre off }
PortWriteByte(ComPort + 4, $11); { RTS on, DTR on }
TestValue := PortReadByte(ComPort + 6);
If (TestValue And $20) <> 0 Then Begin { DSR devrait ˆtre on }
{ Initialisation basique de la souris s‚rie }
PortWriteByte(ComPort + 3, $80); { DLAB = 1 }
PortWriteByte(ComPort + 0, $60); { 1200 baud }
PortWriteByte(ComPort + 1, $00);
PortWriteByte(ComPort + 3, $02); { 7 bits, no parity, 1 stop }
PortWriteByte(ComPort + 4, $03); { DTR et RTS on }
PortWriteByte(ComPort + 1, $00); { Pas d'interruptions }
DetectSerialMouse := True;
End;
End;
PortWriteByte(ComPort + 4, OldValue); { Restaurer l'ancien ‚tat }
End;
{$ENDIF}
{ D‚tecter une souris PS/2 }
Function DetectPS2Mouse: Boolean;
{$IFDEF FPC}
Begin
DetectPS2Mouse := False; { Simulation pour Free Pascal }
End;
{$ELSE}
Var
Status: Byte;
Begin
DetectPS2Mouse := False;
{ V‚rifier si le contr“leur PS/2 existe }
Status := PortReadByte(PS2_STATUS_PORT);
If (Status And $02) = 0 Then Begin { Tampon d'entr‚e vide }
{ Envoyer commande de test du port souris }
PortWriteByte(PS2_COMMAND_PORT, $A9);
{ Attendre la r‚ponse }
Repeat
Status := PortReadByte(PS2_STATUS_PORT);
Until (Status And $01) <> 0;
{ Lire le r‚sultat }
Status := PortReadByte(PS2_DATA_PORT);
If Status = $00 Then Begin { Test r‚ussi }
DetectPS2Mouse := True;
End;
End;
End;
{$ENDIF}
{ D‚tecter le type de souris pr‚sent }
Function DetectMouseType: Byte;Begin
DetectMouseType := MOUSE_TYPE_NONE;
{ Essayer de d‚tecter une souris PS/2 en premier }
If DetectPS2Mouse Then Begin
DetectMouseType := MOUSE_TYPE_PS2;
Exit;
End;
{ Essayer les ports s‚rie }
If DetectSerialMouse(COM1_BASE) Then Begin
DetectMouseType := MOUSE_TYPE_SERIAL;
MouseDriver.SerialPort := COM1_BASE;
MouseDriver.SerialIRQ := COM1_IRQ;
Exit;
End;
If DetectSerialMouse(COM2_BASE) Then Begin
DetectMouseType := MOUSE_TYPE_SERIAL;
MouseDriver.SerialPort := COM2_BASE;
MouseDriver.SerialIRQ := COM2_IRQ;
Exit;
End;
End;
{ Initialiser l'‚tat de la souris }
Procedure InitMouseState;Begin
With MouseDriver.State Do Begin
X := (DEFAULT_MAX_X + DEFAULT_MIN_X) Div 2;
Y := (DEFAULT_MAX_Y + DEFAULT_MIN_Y) Div 2;
Buttons := 0;
DeltaX := 0;
DeltaY := 0;
Visible := False;
MinX := DEFAULT_MIN_X;
MaxX := DEFAULT_MAX_X;
MinY := DEFAULT_MIN_Y;
MaxY := DEFAULT_MAX_Y;
MickeyX := 8;
MickeyY := 16;
DoubleSpeedThreshold := 64;
End;
End;
{ Gestionnaire d'interruption pour souris s‚rie }
{$F+}
Procedure SerialMouseHandler;
{$F-}
{$IFNDEF FPC}
Begin
Asm
Push AX
Push BX
Push CX
Push DX
Push SI
Push DI
Push DS
Push ES
{ Code de traitement de l'interruption s‚rie }
{ Lecture des données de la souris s‚rie }
Mov DX, MouseDriver.SerialPort
In AL, DX
{ Traitement simplifi‚ des donn‚es souris }
{ (Dans une vraie impl‚mentation, il faudrait d‚coder le protocole) }
{ Envoyer EOI au contr“leur d'interruption }
Mov AL, $20
Out $20, AL
Pop ES
Pop DS
Pop DI
Pop SI
Pop DX
Pop CX
Pop BX
Pop AX
Iret
End;
End;
{$ELSE}
Begin
{ Version simplifi‚e pour Free Pascal }
End;
{$ENDIF}
{ Gestionnaire d'interruption pour souris PS/2 }
{$F+}
Procedure PS2MouseHandler;
{$F-}
{$IFNDEF FPC}
Begin
Asm
Push AX
Push BX
Push CX
Push DX
Push SI
Push DI
Push DS
Push ES
{ Lire les données de la souris PS/2 }
In AL, PS2_DATA_PORT
{ Traitement simplifi‚ des donn‚es souris PS/2 }
{ (Dans une vraie impl‚mentation, il faudrait d‚coder le protocole) }
{ Envoyer EOI au contr“leur d'interruption }
Mov AL, $20
Out $A0, AL { PIC esclave }
Out $20, AL { PIC maŒtre }
Pop ES
Pop DS
Pop DI
Pop SI
Pop DX
Pop CX
Pop BX
Pop AX
Iret
End;
End;
{$ELSE}
Begin
{ Version simplifi‚e pour Free Pascal }
End;
{$ENDIF}
{ Gestionnaire principal d'interruption INT 33h }
{$F+}
Procedure MouseInt33Handler;
{$F-}
{$IFNDEF FPC}
Begin
Asm
Sti { Activer les interruptions }
Push BX
Push CX
Push DX
Push SI
Push DI
Push DS
Push ES
{ V‚rifier la fonction demand‚e dans AX }
Cmp AX, 0
Je @ResetMouse
Cmp AX, 1
Je @ShowCursor
Cmp AX, 2
Je @HideCursor
Cmp AX, 3
Je @GetMouseStatus
Cmp AX, 4
Je @SetMousePosition
Cmp AX, 7
Je @SetHorizontalLimits
Cmp AX, 8
Je @SetVerticalLimits
Cmp AX, 11
Je @ReadMouseMotion
Cmp AX, 15
Je @SetMickeyRatio
Cmp AX, 36
Je @GetDriverVersion
Cmp AX, 109
Je @MicrosoftDetection
Jmp @ExitHandler
@ResetMouse:
Mov AX, $FFFF { Souris pr‚sente }
Mov BX, 2 { 2 boutons }
Jmp @ExitHandler
@ShowCursor:
Mov MouseDriver.State.Visible, 1
Jmp @ExitHandler
@HideCursor:
Mov MouseDriver.State.Visible, 0
Jmp @ExitHandler
@GetMouseStatus:
MOV AL, MouseDriver.State.Buttons
MOV AH, 0
Mov CX, MouseDriver.State.X
Mov DX, MouseDriver.State.Y
Jmp @ExitHandler
@SetMousePosition:
Mov MouseDriver.State.X, CX
Mov MouseDriver.State.Y, DX
Jmp @ExitHandler
@SetHorizontalLimits:
Mov MouseDriver.State.MinX, CX
Mov MouseDriver.State.MaxX, DX
Jmp @ExitHandler
@SetVerticalLimits:
Mov MouseDriver.State.MinY, CX
Mov MouseDriver.State.MaxY, DX
Jmp @ExitHandler
@ReadMouseMotion:
Mov CX, MouseDriver.State.DeltaX
Mov DX, MouseDriver.State.DeltaY
Mov MouseDriver.State.DeltaX, 0
Mov MouseDriver.State.DeltaY, 0
Jmp @ExitHandler
@SetMickeyRatio:
Mov MouseDriver.State.MickeyX, CX
Mov MouseDriver.State.MickeyY, DX
Jmp @ExitHandler
@GetDriverVersion:
Mov AX, MOUSE_DRIVER_VERSION
Mov BX, 0 { Pas de gestionnaire utilisateur }
Jmp @ExitHandler
@MicrosoftDetection:
{ Fonction 6Dh (109) - D‚tection pilote Microsoft }
{ Retourne la signature Microsoft dans les registres }
Mov AX, $006D { Code de fonction confirm‚ }
Mov BX, $4D53 { Signature "MS" }
Mov CX, $002E { Version majeure.mineure }
Mov DX, $0000 { R‚serv‚ }
Jmp @ExitHandler
@ExitHandler:
Pop ES
Pop DS
Pop DI
Pop SI
Pop DX
Pop CX
Pop BX
Iret
End;
End;
{$ELSE}
Begin
{ Version simplifi‚e pour Free Pascal }
End;
{$ENDIF}
{ Installer le pilote souris }
Function InstallMouseDriver:Boolean;Begin
InstallMouseDriver := False;
{ D‚tecter le type de souris }
MouseDriver.MouseType := DetectMouseType;
If MouseDriver.MouseType = MOUSE_TYPE_NONE Then Exit;
{ Initialiser l'‚tat de la souris }
InitMouseState;
{ Sauvegarder l'ancien gestionnaire INT 33h }
GetIntVec(MOUSE_INT, MouseDriver.OldInt33Handler);
{ Installer le nouveau gestionnaire }
SetIntVec(MOUSE_INT, @MouseInt33Handler);
{ Installer les gestionnaires d'interruption mat‚riel }
Case MouseDriver.MouseType Of
MOUSE_TYPE_SERIAL: Begin
GetIntVec($0C + MouseDriver.SerialIRQ, MouseDriver.OldSerialHandler);
SetIntVec($0C + MouseDriver.SerialIRQ, @SerialMouseHandler);
{$IFNDEF FPC}
{ Activer l'IRQ dans le PIC }
Port[$21] := Port[$21] And Not (1 Shl MouseDriver.SerialIRQ);
{$ENDIF}
End;
MOUSE_TYPE_PS2: Begin
GetIntVec($74, MouseDriver.OldPS2Handler); { IRQ 12 = INT 74h }
SetIntVec($74, @PS2MouseHandler);
{$IFNDEF FPC}
{ Activer l'IRQ 12 dans le PIC }
Port[$A1] := Port[$A1] And $EF; { PIC esclave - Bit 4 = IRQ 12 }
Port[$21] := Port[$21] And $FB; { PIC maŒtre - Bit 2 = IRQ cascade }
{$ENDIF}
End;
End;
MouseDriver.Installed := True;
MouseDriver.InitializedHardware := True;
InstallMouseDriver := True;
End;
{ D‚sinstaller le pilote souris }
Procedure UninstallMouseDriver;Begin
If MouseDriver.Installed Then Begin
{ Restaurer les anciens gestionnaires }
SetIntVec(MOUSE_INT, MouseDriver.OldInt33Handler);
Case MouseDriver.MouseType Of
MOUSE_TYPE_SERIAL: Begin
SetIntVec($0C + MouseDriver.SerialIRQ, MouseDriver.OldSerialHandler);
{$IFNDEF FPC}
{ D‚sactiver l'IRQ dans le PIC }
Port[$21] := Port[$21] Or (1 Shl MouseDriver.SerialIRQ);
{$ENDIF}
End;
MOUSE_TYPE_PS2: Begin
SetIntVec($74, MouseDriver.OldPS2Handler);
{$IFNDEF FPC}
{ D‚sactiver l'IRQ 12 dans le PIC }
Port[$A1] := Port[$A1] Or $10;
{$ENDIF}
End;
End;
MouseDriver.Installed := False;
End;
End;
{ R‚initialiser le pilote souris }
Procedure ResetMouseDriver;Begin
If MouseDriver.Installed Then Begin
InitMouseState;
If Not MouseDriver.SilentMode Then Begin
Case Language Of
_English: WriteLn('Mouse driver reset successfully.');
_Germany: WriteLn('Maustreiber erfolgreich zurckgesetzt.');
Else WriteLn('Pilote souris r‚initialis‚ avec succŠs.');
End;
End;
End Else Begin
Case Language Of
_English: WriteLn('Mouse driver not installed.');
_Germany: WriteLn('Maustreiber nicht installiert.');
Else WriteLn('Pilote souris non install‚.');
End;
End;
End;
{ Forcer la d‚tection mat‚rielle }
Procedure ForceHardwareDetection;
Var
DetectedType: Byte;
Begin
DetectedType := DetectMouseType;
Case Language Of
_English: Begin
WriteLn('Hardware detection results:');
Case DetectedType Of
MOUSE_TYPE_NONE: WriteLn(' No mouse detected');
MOUSE_TYPE_SERIAL: WriteLn(' Serial mouse detected on COM',
(MouseDriver.SerialPort - COM1_BASE) Div 8 + 1);
MOUSE_TYPE_PS2: WriteLn(' PS/2 mouse detected');
MOUSE_TYPE_BUS: WriteLn(' Bus mouse detected');
End;
End;
_Germany: Begin
WriteLn('Hardware-Erkennungsergebnisse:');
Case DetectedType Of
MOUSE_TYPE_NONE: WriteLn(' Keine Maus erkannt');
MOUSE_TYPE_SERIAL: WriteLn(' Serielle Maus an COM',
(MouseDriver.SerialPort - COM1_BASE) Div 8 + 1, ' erkannt');
MOUSE_TYPE_PS2: WriteLn(' PS/2-Maus erkannt');
MOUSE_TYPE_BUS: WriteLn(' Bus-Maus erkannt');
End;
End;
Else Begin { Fran‡ais }
WriteLn('R‚sultats de la d‚tection mat‚rielle:');
Case DetectedType Of
MOUSE_TYPE_NONE: WriteLn(' Aucune souris d‚tect‚e');
MOUSE_TYPE_SERIAL: WriteLn(' Souris s‚rie d‚tect‚e sur COM',
(MouseDriver.SerialPort - COM1_BASE) Div 8 + 1);
MOUSE_TYPE_PS2: WriteLn(' Souris PS/2 d‚tect‚e');
MOUSE_TYPE_BUS: WriteLn(' Souris bus d‚tect‚e');
End;
End;
End;
End;
{ Afficher les informations internes }
Procedure ShowInternalInfo;Begin
Case Language Of
_English: Begin
WriteLn('Mouse Driver Internal Information:');
WriteLn(' Version: ', MOUSE_DRIVER_VERSION Shr 8, '.', MOUSE_DRIVER_VERSION And $FF);
WriteLn(' Driver installed: ', MouseDriver.Installed);
If MouseDriver.Installed Then Begin
WriteLn(' Mouse type: ', MouseDriver.MouseType);
WriteLn(' Position: (', MouseDriver.State.X, ',', MouseDriver.State.Y, ')');
WriteLn(' Button state: ', MouseDriver.State.Buttons);
WriteLn(' Cursor visible: ', MouseDriver.State.Visible);
WriteLn(' X limits: ', MouseDriver.State.MinX, '-', MouseDriver.State.MaxX);
WriteLn(' Y limits: ', MouseDriver.State.MinY, '-', MouseDriver.State.MaxY);
End;
End;
_Germany: Begin
WriteLn('Interne Informationen des Maustreibers:');
WriteLn(' Version: ', MOUSE_DRIVER_VERSION Shr 8, '.', MOUSE_DRIVER_VERSION And $FF);
WriteLn(' Treiber installiert: ', MouseDriver.Installed);
If MouseDriver.Installed Then Begin
WriteLn(' Maustyp: ', MouseDriver.MouseType);
WriteLn(' Position: (', MouseDriver.State.X, ',', MouseDriver.State.Y, ')');
WriteLn(' Tastenstatus: ', MouseDriver.State.Buttons);
WriteLn(' Cursor sichtbar: ', MouseDriver.State.Visible);
WriteLn(' X-Grenzen: ', MouseDriver.State.MinX, '-', MouseDriver.State.MaxX);
WriteLn(' Y-Grenzen: ', MouseDriver.State.MinY, '-', MouseDriver.State.MaxY);
End;
End;
Else Begin { Fran‡ais }
WriteLn('Informations internes du pilote souris:');
WriteLn(' Version: ', MOUSE_DRIVER_VERSION Shr 8, '.', MOUSE_DRIVER_VERSION And $FF);
WriteLn(' Pilote install‚: ', MouseDriver.Installed);
If MouseDriver.Installed Then Begin
WriteLn(' Type souris: ', MouseDriver.MouseType);
WriteLn(' Position: (', MouseDriver.State.X, ',', MouseDriver.State.Y, ')');
WriteLn(' tat boutons: ', MouseDriver.State.Buttons);
WriteLn(' Curseur visible: ', MouseDriver.State.Visible);
WriteLn(' Limites X: ', MouseDriver.State.MinX, '-', MouseDriver.State.MaxX);
WriteLn(' Limites Y: ', MouseDriver.State.MinY, '-', MouseDriver.State.MaxY);
End;
End;
End;
End;
{ V‚rifier si le pilote est d‚j… install‚ }
Function IsMouseDriverInstalled: Boolean;
Var
Regs: Registers;
Begin
Regs.AX := 0; { Fonction Reset }
Intr(MOUSE_INT, Regs);
IsMouseDriverInstalled := (Regs.AX = $FFFF);
End;
BEGIN
{ Initialisation de la langue }
Language := _French;
TmpLanguage := GetEnv('LANGUAGE');
If TmpLanguage <> '' Then Begin
If TmpLanguage[1] = '"' Then TmpLanguage := Copy(TmpLanguage, 2, 255);
If StrToUpper(Copy(TmpLanguage, 1, 2)) = 'EN' Then Language := _English Else
If StrToUpper(Copy(TmpLanguage, 1, 2)) = 'GR' Then Language := _Germany Else
If StrToUpper(Copy(TmpLanguage, 1, 2)) = 'IT' Then Language := _Italian Else
If StrToUpper(Copy(TmpLanguage, 1, 2)) = 'SP' Then Language := _Spain Else
If (StrToUpper(Copy(TmpLanguage, 1, 2)) = 'SQ') or
(StrToUpper(Copy(TmpLanguage, 1, 3)) = 'ALB') Then Language := _Albanian Else
If (StrToUpper(Copy(TmpLanguage, 1, 2)) = 'PT') or
(StrToUpper(Copy(TmpLanguage, 1, 3)) = 'PRT') Then Language := _Portuguese Else
If (StrToUpper(Copy(TmpLanguage, 1, 2)) = 'SE') or
(StrToUpper(Copy(TmpLanguage, 1, 3)) = 'SWE') Then Language := _Swedish Else
If (StrToUpper(Copy(TmpLanguage, 1, 2)) = 'DK') or
(StrToUpper(Copy(TmpLanguage, 1, 3)) = 'DNK') Then Language := _Danish Else
If (StrToUpper(Copy(TmpLanguage, 1, 2)) = 'JP') or
(StrToUpper(Copy(TmpLanguage, 1, 3)) = 'JPN') Then Language := _Japanese;
End;
{ Initialisation }
FillChar(MouseDriver, SizeOf(TMouseDriver), 0);
MouseDriver.SilentMode := False;
{ Traitement des paramŠtres de ligne de commande }
For I := 1 to ParamCount do Begin
Param := StrToUpper(ParamStr(I));
If (Param = '/?') Or (Param = '/H') Or (Param = '--HELP') Then Begin
Case Language Of
_English: Begin
WriteLn('MSMOUSE - MS Mouse Driver');
WriteLn;
WriteLn('Loads the mouse driver for MS-DOS applications.');
WriteLn;
WriteLn('MSMOUSE [parameters]');
WriteLn;
WriteLn('Parameters:');
WriteLn(' /Y Load driver without displaying messages (silent mode)');
WriteLn(' /R Reset the mouse driver already loaded in memory');
WriteLn(' /U Unload the driver from memory (if loaded as TSR)');
WriteLn(' /C Force hardware mouse detection');
WriteLn(' /S Force serial mouse usage (COM1/COM2)');
WriteLn(' /B Force bus mouse usage (IBM PC)');
WriteLn(' /I Display internal driver and hardware information');
WriteLn(' /? Display this help');
End;
_Germany: Begin
WriteLn('MSMOUSE - MS Maustreiber');
WriteLn;
WriteLn('L„dt den Maustreiber fr MS-DOS-Anwendungen.');
WriteLn;
WriteLn('MSMOUSE [Parameter]');
WriteLn;
WriteLn('Parameter:');
WriteLn(' /Y Treiber ohne Nachrichten laden (stiller Modus)');
WriteLn(' /R Im Speicher geladenen Maustreiber zurcksetzen');
WriteLn(' /U Treiber aus dem Speicher entfernen (wenn als TSR geladen)');
WriteLn(' /C Hardware-Mauserkennung erzwingen');
WriteLn(' /S Serielle Maus erzwingen (COM1/COM2)');
WriteLn(' /B Bus-Maus erzwingen (IBM PC)');
WriteLn(' /I Interne Treiber- und Hardware-Informationen anzeigen');
WriteLn(' /? Diese Hilfe anzeigen');
End;
Else Begin { Fran‡ais }
WriteLn('MSMOUSE - Pilote de souris MS');
WriteLn;
WriteLn('Cette commande permet de charger le pilote souris pour les applications MS-DOS.');
WriteLn;
WriteLn('MSMOUSE [paramŠtres]');
WriteLn;
WriteLn('ParamŠtres:');
WriteLn(' /Y Charger le pilote sans afficher de messages (mode silencieux)');
WriteLn(' /R R‚initialiser le pilote souris d‚j… charg‚ en m‚moire');
WriteLn(' /U D‚charger le pilote de la m‚moire (si charg‚ comme TSR)');
WriteLn(' /C Forcer la d‚tection du mat‚riel souris');
WriteLn(' /S Forcer l''utilisation d''une souris s‚rie (COM1/COM2)');
WriteLn(' /B Forcer l''utilisation d''une souris bus (IBM PC)');
WriteLn(' /I Afficher les informations internes du pilote et mat‚riel');
WriteLn(' /? Afficher cette aide');
End;
End;
Exit;
End
Else If (Param = '/Y') Then Begin
MouseDriver.SilentMode := True;
End
Else If (Param = '/R') Then Begin
ResetMouseDriver;
Exit;
End
Else If (Param = '/U') Then Begin
UninstallMouseDriver;
If Not MouseDriver.SilentMode Then Begin
Case Language Of
_English: WriteLn('Mouse driver unloaded from memory.');
_Germany: WriteLn('Maustreiber aus dem Speicher entfernt.');
Else WriteLn('Pilote souris d‚charg‚ de la m‚moire.');
End;
End;
Exit;
End
Else If (Param = '/C') Then Begin
ForceHardwareDetection;
Exit;
End
Else If (Param = '/S') Then Begin
{ Forcer souris s‚rie - sera impl‚ment‚ dans DetectMouseType }
MouseDriver.MouseType := MOUSE_TYPE_SERIAL;
End
Else If (Param = '/B') Then Begin
{ Forcer souris bus - pour compatibilit‚ }
MouseDriver.MouseType := MOUSE_TYPE_BUS;
End
Else If (Param = '/I') Then Begin
ShowInternalInfo;
Exit;
End
Else Begin
Case Language Of
_English: WriteLn('Invalid parameter: ', Param);
_Germany: WriteLn('Ungltiger Parameter: ', Param);
Else WriteLn('ParamŠtre invalide: ', Param);
End;
Halt(1);
End;
End;
{ V‚rifier si un pilote souris est d‚j… install‚ }
If IsMouseDriverInstalled Then Begin
If Not MouseDriver.SilentMode Then Begin
Case Language Of
_English: WriteLn('Mouse driver already loaded in memory.');
_Germany: WriteLn('Maustreiber bereits im Speicher geladen.');
Else WriteLn('Pilote souris d‚j… charg‚ en m‚moire.');
End;
End;
Exit;
End;
{ Installer le pilote souris }
If InstallMouseDriver Then Begin
If Not MouseDriver.SilentMode Then Begin
Case Language Of
_English: Begin
WriteLn('MS Mouse Driver v', MOUSE_DRIVER_VERSION Shr 8, '.',
MOUSE_DRIVER_VERSION And $FF, ' loaded successfully.');
Case MouseDriver.MouseType Of
MOUSE_TYPE_SERIAL: WriteLn('Serial mouse detected on COM',
(MouseDriver.SerialPort - COM1_BASE) Div 8 + 1, '.');
MOUSE_TYPE_PS2: WriteLn('PS/2 mouse detected.');
MOUSE_TYPE_BUS: WriteLn('Bus mouse detected.');
End;
End;
_Germany: Begin
WriteLn('MS Maustreiber v', MOUSE_DRIVER_VERSION Shr 8, '.',
MOUSE_DRIVER_VERSION And $FF, ' erfolgreich geladen.');
Case MouseDriver.MouseType Of
MOUSE_TYPE_SERIAL: WriteLn('Serielle Maus an COM',
(MouseDriver.SerialPort - COM1_BASE) Div 8 + 1, ' erkannt.');
MOUSE_TYPE_PS2: WriteLn('PS/2-Maus erkannt.');
MOUSE_TYPE_BUS: WriteLn('Bus-Maus erkannt.');
End;
End;
Else Begin { Fran‡ais }
WriteLn('Pilote souris MS v', MOUSE_DRIVER_VERSION Shr 8, '.',
MOUSE_DRIVER_VERSION And $FF, ' charg‚ avec succŠs.');
Case MouseDriver.MouseType Of
MOUSE_TYPE_SERIAL: WriteLn('Souris s‚rie d‚tect‚e sur COM',
(MouseDriver.SerialPort - COM1_BASE) Div 8 + 1, '.');
MOUSE_TYPE_PS2: WriteLn('Souris PS/2 d‚tect‚e.');
MOUSE_TYPE_BUS: WriteLn('Souris bus d‚tect‚e.');
End;
End;
End;
End;
{ Rester r‚sident en m‚moire }
Keep(0);
End Else Begin
Case Language Of
_English: WriteLn('No mouse hardware detected. Driver not loaded.');
_Germany: WriteLn('Keine Maus-Hardware erkannt. Treiber nicht geladen.');
Else WriteLn('Aucun mat‚riel souris d‚tect‚. Pilote non charg‚.');
End;
Halt(1);
End;
END.