Giter Site home page Giter Site logo

techpaul / ps2keyadvanced Goto Github PK

View Code? Open in Web Editor NEW
134.0 15.0 27.0 432 KB

Arduino PS2 Keyboard FULL keyboard protocol support and full keys to integer coding

License: GNU Lesser General Public License v2.1

C++ 71.87% C 28.13%
arduino-library arduino-ps2-keyboard arduino ps2-keyboard-libraries keyboard-protocol ps2-keyboard-interface hardware

ps2keyadvanced's People

Contributors

hiabuto-de avatar per1234 avatar techpaul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ps2keyadvanced's Issues

Missing release `V1.0.10`?

I see release notes for V1.0.10, but I'm unable to find it. I'm currently facing issues with pause and would like to see if this release resolved it (based upon the release notes, it looks like there's a good chance). Is this release available?

Strange output from serial

Not sure if this is an issue with your driver or not. I've run the sample program on an Uno, and keep getting strange output, like so:
™DÄ�hŠ+ÿl3�
This output is created as I type keys, but not in a predicable manner. For example, I could tap a key and nothing will happen. However, if I tap 3 keys in succession, output will occur. This seems like an encoding issue with my keyboard (pretty standard US Dell keyboard from 2000s-ish).

Arduino Nano Every ( MegaAVR board) Serial

I am developing a MIDI controller in which I have hundreds of SysEx strings to be triggered to control a Korg synthesizer, and when I saw the possibility of using a PS / 2 keyboard it became a reality, to be able to use all the keys plus the CTRL , SHIFT and ALT combinations, made my world bigger.

I am using a Genius kb 125 Ps/2 keyboard and an Arduino Nano Every, I have tried with other arduinos but I need more Ram memory and the Nano Every meets my needs for memory and for the physical space that I have inside the qwerty keyboard.

Your library is fantastic for the task I am developing, the problem I have is that when I want to activate the NUM LOCK, CAPS LOCK or SCRL LOCK keys the Serial port is frozen, I have to close and open the Arduino IDE serial monitor so that the serial release and continue using the keys.

With the Arduino PRO MICRO it works well, I press the NUM LOCK key (101, FA, FA), the respective led lights up and the numeric keys are enabled, everything working normally.

With the Arduino Nano Every on the serial monitor I can see this: (101, FA) and the serial is frozen, I have to close and open the serial monitor to be able to use the keys, and the numeral keys are not enabled.
Also try to use: keyboard.setLock (PS2_LOCK_NUM);
and the serial monitor shows: PS2 Advanced Key - Advanced Test:
Invalid Code received of FA.

From now on I appreciate your attention and your library.

Richard

weird mapping in some cases and no shift

hi, I have an Logitech Y-SAE71 SK-2930 PS/2 keyboard, and it has an F-mode (that is basically help, word, excel, powerpoint and some other 2000s stuff) and additional buttons (that work as expected), but I have a problem; ~ is nothing, NumPad enter is +, [+] is [,], [,] is [;], [;] is ([), (]) is [^], [^] is [6], etc. etc. It's like { Polish, but not [Programmers] (normal layout with diacritical under right Alt), but just like s*** of type: [-] is A with a tail, and [=] is C with a small slash [/] on top }. Not forgetting the "CAPS LOCK syndrome", I mean all the letters are uppercase and can't type [!] to [)] etc. I tested this keyboard on a computer (without drivers) and it works as normal PS/2 keyboard. Without drivers means when I press additional buttons on top and left, it's typing just some letters. Why doesn't this map good?
By the way I'm using u8g2 library for 128x64 SH1106 OLED to display the characters instead of an LCD, code page ASCII.

My board does not work with this library

When your board does not work with Library

  1. Check Wiring
  2. Check assignment of pins in software and board match
  3. Are you using a USB keyboard through PS2 adapter ?
  • IF so get a native PS2 keyboard as USB keyboards draw too much current often with external power on your board causing MCU and/or keyboard resets
  1. Has your board been tested to work with keyboard check the Readme file see Readme.md
  2. Have you turned on ALL compiler warnings as shown in the Readme file see Readme.md
  3. If when sending data to the Keyboard (e.g. LEDs) the application locks up, you have an interrupt issue try using PS2_CLEAR_PENDING_IRQ in PS2KeyAdvanced.h for your board/architecture

If you are sure your board has been tested ask questions here.

If your board has NOT been tested you may want to check how to add your own support and need to do various interrupt tests by sending commands to the keyboard like LEDs, see Porting.md

CODE AA error

Hi, I am getting a repeating of the "VALUE AA - Status Bits 0 Code AA" error message, which is supposed to correspond to an error where the keyboard is attached after the program began running, however this keyboard was attached while I uploaded the code. Help is much appreciated thanks!

2 keyboards in 1 board

Hello Paul, I would like to know if it can be connected and how, 2 (two) Ps2 keyboards to the same board, I was trying but I can't make them both work at the same time. Thanks

Host-to-Device: Initial Clock low too short

Function send_now():504 waits for 60 microseconds:
delayMicroseconds( 60 );

This freezes my trusty old Multitech KB084 as soon as an LED is set (CAPS, SCROLL, NUM).
In the PDF from the extras folder, a different time is specified:

"Inhibit communication by pulling Clock low for at least 100 microseconds."

By changing the above line to

delayMicroseconds( 120 );

everything is working perfectly.

Issue with ResetKey

I have found another small bug ;-)

After execute the "resetKey" the "PS2_led_lock" need to set zero or the LEDs will recover on the next call of "setLock"...

FF Issue

Hello, while using this library I was only able to receive FF events from the keyboard. All keys worked correctly, but every keyPress and keyRelease only told me that they were key FF, and not their respective key. Any ideas?

increase buffer ??

is there a way to increase the buffered characters amount? When I use this on one of my Retro computers and if I type something before the program is completely up or before any process is finished; say, "12345" when the program comes up or the process is finished I will only get the first 2-3 characters first typed.

Digispark Attiny85

Any help for using your lib in Digispark ?

Arduino IDE give this error ....
Thanks a lot.

/home/usuario/Arduino/libraries/PS2KeyAdvanced/src/PS2KeyAdvanced.cpp: In member function 'void PS2KeyAdvanced::begin(uint8_t, uint8_t)':
/home/usuario/Arduino/libraries/PS2KeyAdvanced/src/PS2KeyAdvanced.cpp:997:49: error: 'digitalPinToInterrupt' was not declared in this scope
attachInterrupt( digitalPinToInterrupt( irq_pin ), ps2interrupt, FALLING );
^
exit status 1
Error compilando para la tarjeta Digispark (Default - 16.5mhz).

Keyboard almost working

Hi,
Firstly, thank you for your library.

I'm trying to get an IBM keyboard (kb-8926 AZERTY) working. Same as picture
Capture d’écran 2024-01-03 à 22 33 15

Almost all functionality works except:

  • When pressing "Verr num" key, "Défil" LED lit instead of "Num".
  • When pressing "Maj Lock" key, "Num" LED lit instead of the up arrow, but input is correct (Maj character)
  • When pressing "Arrêt défil", the keyboard stop working.
  • Only the "5" key of the numeric pad doesn't input a code.

I'm working on a Xiao RP2040 MCU and use this level-shifter circuit:
Capture d’écran 2024-01-03 à 22 29 45

I tried all the combination of #define IRQs, but it seems to better work without.
Furthermore, I tried to get the scan code set, and it returns 2.

Send own bytes to keyboard

Hello.
I have on my hands Creative ProdikeysDM. It's PS/2 keyboard, but i need using this on USB (because drivers available only on WinXP or Win7x32). Thankfuly, i found page (https://linuxmusicians.com/viewtopic.php?t=15947), where one guy decided, how to work with that. He even create project on Git, where he using Arduino Uno R3. I think using Arduino Micro instead to place inside case.
I try write my onw code to work with PS/2 protocol, but fail (i can only receving data, but cannot send, idk why). Also i found this library and i notice function "send_byte", but not available from class.
It is possible make this function public?

Acknowledging additional startup PS/2->Host messages

I suspect this is not a wide-spread startup handshake for all PS/2 keyboards, but it appears to be happening to at least three keyboards in the wild (mine, a YouTube user's, and a fellow from an Arduino forum). I'm curious it if is feasible to add support for this in the begin() method.

The library reports that a constant sequence of 0xAA messages are sent by the keyboard, which appears to happen during or after the self-test completes (LED lights on keyboard go off). According to this post from 2011, the sequence has an incorrect parity bit set (presumably to distinguish from the standard BAT 0xAA message), and needs to be acknowledged by the 0xFE message, also with an incorrect parity bit set.

This is my first Arduino project, and I'm slowly understanding the platform. I could probably submit a pull request for this once I figure out how to implement the acknowledgement; you might not have a keyboard to test this with. For what its worth, my keyboard has a dual USB-HID and PS/2 controller.

Hold CAPS

Great library! I found it particularly useful in my project.
I noticed that CAPS cannot be held. The library sends 3 events in a row once it's pressed, and 0 when it is released.
I would like to find a way to catch it when it is released. (or I need to remap it to LCTRL but with the ability to catch the "release" event too).
How can I achieve this?

Split the function into a "Raw" and "Advanced" class

Are you entertaining outside pull requests to this code? I ended up doing some serious hacking on the PS2 library (alas, I started with an out of date version), but still, there are some improvements that I could bring from my code up to the libraries here. (My changes could either go here, in the Advanced library, with a lot of work on my part, or they could go into the Raw library, with less work on my part but it'd probably completely replace that code.) I'd like to share my work, but I think it'd be dumb to create a competing PS2 library.

Parity in argument bytes sent from host

First of all, thank you for this nice piece of software.

I have been analysing the behaviour of this library using an oscilloscope, and I noticed that no odd parity bits are added to the argument bytes of a host command.
For example: using getScanCodeSet( ) the command is sent OK, but the following argument byte (0x00) does not get the additional 1 for odd parity bits.
I tried searching if this is the normal behaviour in the PS/2 protocol, but I found no such info.
So, I wonder if this is the correct behaviour or not.

I have a feeling that this might be the problem for the case of issue #23, but I might be mistaken.

Anyway, thank you in advance for any response.

PS: For what it's worth, I also cannot update this library to V1.0.10 through the Arduino IDE. It only gives me up to V1.0.9.

Regards,
Theodore

Pause key gives wrong code. setLock(.) doesn't work in setup()

I'm using V1.0.9 and when I press the Pause key it gives me 6 (PS2_KEY_L_SHIFT) instead of 5 (PS2_KEY_PAUSE).
In PS2KeyAdvanced.cpp line 674 I see
return PS2_KEY_PAUSE + _FUNCTION;

Is there a reason for the + _FUNCTION that results in 5 + 1 = 6?

Also, if I put in setup() the following:

keyboard.begin( . );
keyboard.setLock(PS2_LOCK_NUM);

When the Arduino is initially powered up, the Num Lock doesn't turn on until I press a key on the keyboard.
I also tried setLock(PS2_LOCK_NUM) and resetKey() inside loop() but they don't work either until a key has been pressed on the keyboard.
resetKey() can also cause a hang unless a key has been pressed beforehand.
I can replicate the issue by turning the Arduino off then on.

ESP32 garbage values

I am using ESP32 with this library to read my PS2 keyboard. I am using a bi-directional logic level shifter based on MOSFET to convert 3.3v to 5v logic shift.
The GPIO pin that I was using for the clock is 23 and for data 22.
I uploaded the example code Simple_test. And when I type something with the keyboard it detects like when I press key 'a' then it prints 'a' on the serial monitor but many times when I do this little quickly by pressing different keys on the keyboard now ESP prints random garbage values on the serial monitor. For example, pressing 'g' on a keyboard and will show '2' on the serial monitor, and pressing the same key a second time shows 'g' properly.

Initially, I thought the logic converter I build had some issues so I tried the same code with Arduino UNO connected to it and it worked perfectly as expected so it's not a hardware issue.

Then I looked in the library code and get to know that it is using an interrupt on the clock pin and as I have been in a similar situation with ESP32 before while using interrupt I finally got to know why this thing is happening.

In Arduino ESP32 support there is some bug for an ESP32 interrupt routine.
When we declare interrupt on falling edge in ESP32 with Arduino IDE with our ISR function. Then ideally the ISR function should get only triggered on the falling edge but when I checked with my logic analyzer it sometimes gets triggers on the rising edge also don't know the reason for that and also after such updates this thing is still not resolved.
Have a look at this issue

So the simple solution for this problem can be implemented by adding one more if condition inside our ISR function like this.

void ps2interrupt(void)
 {
  if(digitalRead(irq_num_pin) == LOW)
  {

This will verify that the pin is in the LOW state or not by just adding this condition in .cpp file the ESP32 garbage problem was fixed and now I am getting perfect readings with my ESP32.

I defined a new variable as irq_num_pin which is equal to the clock pin called in begin function.

So I suggest updating this little logic so that it works better with an ESP32. Also, I have not tested it with Arduino UNO after making this change but I am sure it will not make any difference for other boards.

After pressing the NUMLOCK key, there is no response when any key is pressed.

I am using version 1.0.9 on esp32.
My keyboard is logitech g100s and it supports usb and ps2.
After pressing any LOCK key, nothing happens when I press any key until I reconnect the keyboard.

Serial output:

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:184
load:0x40078000,len:12600
load:0x40080400,len:2724
entry 0x40080594
PS2 Advanced Key Simple Test:
Value AA - Status Bits 0  Code AA
Value 41 - Status Bits 0  Code 41
Value 8041 - Status Bits 80  Code 41
Value 41 - Status Bits 0  Code 41
Value 8041 - Status Bits 80  Code 41
Value 41 - Status Bits 0  Code 41
Value 8041 - Status Bits 80  Code 41
Value 1103 - Status Bits 11  Code 3
Value FA - Status Bits 0  Code FA

Analog Input, is it possible?

Hey! Thanks for this project, I've been having a lot of fun tweaking this code and reusing an old keyboard that was lying around.

Do you think it's possible to tweak this to use two of the analog inputs instead of the digital inputs? Because I couldn't manage to do so, the code only works using one of the digital ports of the arduino (nano in my case).

It would be awesome so I could free up the 2 ports for other functionalities! If you could point me to any direction, I would appreciate it a lot.

Cheers and thanks in advance.

` and ~ keys and Keyboard . does not work

The "." on the keyboard only works as a 'DELETE' key whether Numlock is on or off.

Also what is the keywords for use for the ` and the ~ key ?

I can get the "." to work on the Keyboard if I add:

translationTable[PS2_KEY_KP_DOT]=0x34;

But that is not the keycode for the Keyboard "." key. I believe it is 0x53, but that does not work either.

Toggle typematic on/off entirely?

Hi there,
I'm new to using GitHub; hopefully I'm in the right spot.

I've been attempting to use your library as part of a MIDI controller, but the typematic repeat is problematic when it comes to controlling an instrument, so I set about trying to send a 0xF8 command to set it to make/break only. I'm just not sure how to get the keyboard to receive the command, as everywhere I've tried to edge the command in causes it to glitch out or does nothing.

I've added this at line 106 of PS2KeyCode.h:
#define PS2_KC_MKBRK 0xF8

this at line 294 of PS2KeyAdvanced.h:
void mkBrk( void );

and this at 967 of PS2KeyAdvanced.cpp:
void PS2KeyAdvanced::mkBrk( )
{
send_byte( PS2_KC_MKBRK ); // send command
if ( ( send_byte( PS2_KEY_IGNORE ) ) ) // wait data PS2_KC_BAT or PS2_KC_ERROR
send_next( ); // if idle start transmission
}

When I try to pull that class either in setup or in the loop it still doesn't work. I also tried to inject a command into the resetKey command with no success.

If you take feature requests, I'd sure love to see it in there. You've done great work here; it's great for breathing new life in to old equipment.

Thanks for any info you might have.

PS2KeyCode.h

Please check your PS2KeyCode.h, i think your keycode is wrong...

#define PS2_KC_STOP 0X38 -> 0X3B

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.