33#![ no_std]
44#![ feature( abi_x86_interrupt) ]
55
6- use log:: { error, warn, debug } ;
6+ use log:: { error, warn} ;
77use spin:: Once ;
88use mpmc:: Queue ;
99use event_types:: Event ;
1010use x86_64:: structures:: idt:: InterruptStackFrame ;
1111use mouse_data:: { MouseButtons , MouseEvent , MouseMovementRelative } ;
12- use ps2:: { PS2Mouse , MouseId , MousePacket } ;
12+ use ps2:: { PS2Mouse , MousePacket } ;
1313
1414/// The first PS/2 port for the mouse is connected directly to IRQ 0xC.
1515/// Because we perform the typical PIC remapping, the remapped IRQ vector number is 0x2C.
@@ -29,26 +29,10 @@ struct MouseInterruptParams {
2929/// * `mouse_queue_producer`: the queue onto which the mouse interrupt handler
3030/// will push new mouse events when a mouse action occurs.
3131pub fn init ( mut mouse : PS2Mouse < ' static > , mouse_queue_producer : Queue < Event > ) -> Result < ( ) , & ' static str > {
32- //TODO: set to 3, failed? id = 0, otherwise set to 4, failed? id = 3, otherwise id = 4
33- //the current code beneath just tries to set id = 4, so is not final
34- // Set Mouse ID to 4.
35- if let Err ( e) = mouse. set_mouse_id ( MouseId :: Four ) {
36- error ! ( "Failed to set the mouse id to four: {e}" ) ;
37- return Err ( "Failed to set the mouse id to four" ) ;
38- }
39- // Read it back to check that it worked.
40- match mouse. mouse_id ( ) {
41- Ok ( id) => {
42- debug ! ( "The PS/2 mouse ID is: {id:?}" ) ;
43- if !matches ! ( id, MouseId :: Four ) {
44- error ! ( "Failed to set the mouse id to four" ) ;
45- return Err ( "Failed to set the mouse id to four" ) ;
46- }
47- }
48- Err ( e) => {
49- error ! ( "Failed to read the PS/2 mouse ID: {e}" ) ;
50- return Err ( "Failed to read the PS/2 mouse ID" ) ;
51- }
32+ // Set MouseId to the highest possible one
33+ if let Err ( e) = mouse. set_mouse_id ( ) {
34+ error ! ( "Failed to set the mouse id: {e}" ) ;
35+ return Err ( "Failed to set the mouse id" ) ;
5236 }
5337
5438 // Register the interrupt handler
@@ -78,13 +62,12 @@ extern "x86-interrupt" fn ps2_mouse_handler(_stack_frame: InterruptStackFrame) {
7862 // try to redesign this to only get one byte per interrupt instead of the 3-4 bytes we
7963 // currently get in read_mouse_packet and merge them afterwards
8064 let mouse_packet = mouse. read_mouse_packet ( ) ;
81- // warn!("read_mouse_packet: {mouse_packet:?}");
8265
8366 if mouse_packet. always_one ( ) != 1 {
8467 // this could signal a hardware error or a mouse which doesn't conform to the rule
85- warn ! ( "Discarding mouse data packet since its third bit should always be 1." ) ;
68+ warn ! ( "ps2_mouse_handler(): Discarding mouse data packet since its third bit should always be 1." ) ;
8669 } else if let Err ( e) = handle_mouse_input ( mouse_packet, queue) {
87- error ! ( "ps2_mouse_handler: {e:?}" ) ;
70+ error ! ( "ps2_mouse_handler() : {e:?}" ) ;
8871 }
8972 }
9073 } else {
0 commit comments