News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Read two keys pressed at the same time from port 0x60

Started by popcalent, June 09, 2022, 11:03:15 AM

Previous topic - Next topic

popcalent

Hello,

Does anyone know how to read two keys at the same time from port 0x60? For instance, how do I know if I'm pressing the right arrow and the up arrow at the same time? How do I know if I'm releasing them at the same time? Do I AND or OR the scan codes? Thanks!

_japheth

Quote from: popcalent on June 09, 2022, 11:03:15 AM
Does anyone know how to read two keys at the same time from port 0x60? For instance, how do I know if I'm pressing the right arrow and the up arrow at the same time? How do I know if I'm releasing them at the same time? Do I AND or OR the scan codes? Thanks!

Hmm, your question reveals a certain ignorance about how the (PS/2?) keyboard works. Are you sure you are fit for such low-level things?

From port 0x60 you will never get the status of multiple keys in one byte, "usually" you get at least one "message" when a key is pressed and another one when it is released ( ignoring the "repetition" msgs for now )

Here's a starting point: https://wiki.osdev.org/PS/2_Keyboard
Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

avcaballero

Maybe this may help you

http://abreojosensamblador.epizy.com/?Tarea=1&SubTarea=9#Scan


popcalent

Thanks for your response.

Here's what I'm trying to do. I have a program that scans port 0x60 and when a key is pressed it pushes a code into a stack, and when that key is released it pops the code.

For instance, if I press right, then left, then release right, and then release left, the stack would go:
[][]-->[][R]-->[L][R]-->[][L]-->[][]

It works fine most of the time, but the problem is that if I release both keys at the same time, looks like it won't scan the correct release code, and it doesn't clear the stack. That's what I thought I need a way to tell two keys have been pressed or released at the same time.

Thanks for your help.

avcaballero

As I understand you, you will need one buffer for each one key, not one buffer for all the keys.