Fix arrow keys
This commit is contained in:
		@@ -89,23 +89,37 @@ enum InputKey {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "x86-interrupt" fn keyboard_handler(_stack_frame: InterruptStackFrame) {
 | 
					extern "x86-interrupt" fn keyboard_handler(_stack_frame: InterruptStackFrame) {
 | 
				
			||||||
	let scancode = unsafe { inb(0x60) };
 | 
						'key_block: {
 | 
				
			||||||
	println!("{:x?}", scancode);
 | 
							let scancode = unsafe { inb(0x60) };
 | 
				
			||||||
 | 
							let key = match scancode {
 | 
				
			||||||
 | 
								0x11 => Some(InputKey::Up),    // W
 | 
				
			||||||
 | 
								0x1E => Some(InputKey::Left),  // A
 | 
				
			||||||
 | 
								0x1F => Some(InputKey::Down),  // S
 | 
				
			||||||
 | 
								0x20 => Some(InputKey::Right), // D
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	let key = match scancode {
 | 
								// Extended codes
 | 
				
			||||||
		0x11 => Some(InputKey::Up),
 | 
								0xE0 => {
 | 
				
			||||||
		0x1E => Some(InputKey::Left),
 | 
									let scancode = unsafe { inb(0x60) };
 | 
				
			||||||
		0x1F => Some(InputKey::Down),
 | 
									match scancode {
 | 
				
			||||||
		0x20 => Some(InputKey::Right),
 | 
										0x48 => Some(InputKey::Up),    // Up arrow
 | 
				
			||||||
		0xE0 => {
 | 
										0x4B => Some(InputKey::Left),  // Left arrow
 | 
				
			||||||
			let scancode = unsafe { inb(0x60) };
 | 
										0x50 => Some(InputKey::Down),  // Down arrow
 | 
				
			||||||
			println!("e {:x?}", scancode);
 | 
										0x4D => Some(InputKey::Right), // Right arrow
 | 
				
			||||||
			None
 | 
										_ => break 'key_block,         // Ignore unknown codes
 | 
				
			||||||
		}
 | 
									}
 | 
				
			||||||
		_ => None,
 | 
								}
 | 
				
			||||||
	};
 | 
					
 | 
				
			||||||
 | 
								// Ignore unrecognized keycodes.
 | 
				
			||||||
 | 
								//
 | 
				
			||||||
 | 
								// Note that this does NOT return to None!
 | 
				
			||||||
 | 
								// If we do that, "release" keycodes will
 | 
				
			||||||
 | 
								// immediately clear "press" keycodes.
 | 
				
			||||||
 | 
								_ => break 'key_block,
 | 
				
			||||||
 | 
							};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							*LAST_INPUT.lock() = key;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	*LAST_INPUT.lock() = key;
 | 
					 | 
				
			||||||
	PIC.lock().send_eoi(InterruptIndex::Keyboard.as_u8());
 | 
						PIC.lock().send_eoi(InterruptIndex::Keyboard.as_u8());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user