Direkt zum Inhalt springen und Lesemodus aktivieren
Article image

Artikel anhören


Lesezeit: ca 3 Min Druckversion

Building a keyboard filter part 1

In this series, I will describe the full approach from idea to "product" for a keyboard filter.

What is the product about

The idea comes from a simple issue and/or need. You play a game and accidentally hit one of the windows keys and get thrown out of the game.
Almost always at the most inconvenient situation. Or pressing a button at the "wrong" time could result in a death of your character.
And I wanted to learn how keyboards work for my 8 bit computer, as well as build a macro-keyboard like a Stream Deck. So lets combine those.

Phase 1: Design

After some quick research (and ´previous knowledge) I concluded that USB is a bit hefty for a prototype, there is a way easier method for the "old style" PS/2 keyboards. For USB you need a lot of processing power and speed or dedicated chips for computer - box and box - keyboard. For PS/2 a simple Arduino (clone) is suited enough (famous last words?). So the box will interrupt the connection between computer and keyboard,
will filter out "unwanted" key presses and send the others to the computer.

Which keys a are "unwanted" and when?

I could hard code the buttons and enable or disable them via switches on the Arduino inputs, but where is the fun in that?
So I will make it programmable by defining multiple sets of filter actions that can be enabled or disabled via keyboards shortcuts, also programming them will be with shortcuts. Probably something like this: programming by holding left shift and scroll lock for 5 seconds,
the scroll lock LED will blink slowly, then you need to press the F1...F12 keys for selecting the set, the LED will blink faster, you press the "forbidden" keys, each time the LED will confirm it and if you don't press any key for 10 seconds, programming will be finished.
Now if you want to lock keys, you press right shift and scroll lock for min. 1 second, press F1...F12 for the right list and those keys will be filtered.

The computer will only see the first shift/scroll lock and will get an unpressed message when programming or filtering mode selection starts.

Hardware setup

Since I will use a PS/2 keyboard, I need to tap/interrupt 4 wires, +5V, GND are tapped and drive the Arduino, DATA (Pin 4/5) and CLK (Pin 2/3) will go "through" the Arduino on multiple pins, 2 to computer, 2 to keyboard. Since only pins 2 and 3 are interrupt capable, I need to interleave the input/output pins. You could use PS/2 connectors or cut a cable, I will be hooking into my keyboard directly by creating a JST connector/socket for the factory cable. No extra wiring needed, unless you want to beef it up.

PS/2 protocol

No need to write it once more, just look at the Wikipedia article.

Software setup

This will be described in the next article in this series, but for a quick test if the hardware from box to keyboard works, power you Arduino via USB, install and the PS2KeyAdvanced library from the library manager and open the included simple test.
Change the IRQPIN on line 135 to 2 and upload.
Open the serial console and  press keys and look for messages. If this works, you are ready for next step.

Later versions

The next version will replace the box to computer connection with USB using an Arduino Leonardo, Pro Mini or one of the clones based on the Atmel 32u4. If that works, maybe I try to attach a USB keyboard with software USB or a controller. But one step after the other.

Continue to part 2

0 Kommentare
Artikel melden

Unser Algorithmus glaubt, diese Artikel sind relevant: