Click here to Skip to main content
15,908,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi..

Im currently using a ps/2 mouse and a keyboard. At first I thought ps/2 ports can only be used to read some input from devices such as mice and keyboards. But in windows, when the computer becoming prepared to the user it automatically on or off some locks as it as been before.

I mean if the user did turn off the capslock with numlock turned on and shut down the computer, next time he start the computer windows would automatically restore the settings user had been configured before. In this case turned off capslock with turned on numlock.

And that's what I wonder about. Does a software can be communicated with ps/2 devices ? I mean send some data to ps/2 devices ? Is that how windows restore the lock key settings back ? Does the windows send a command to the keyboard to turn on the numlock ? or something else ?

Furthermore, If it's possible to send some commands to the keyboard via ps/2 port, will I be able to create a program that can send commands to the mouse ? :)

Thanks in advance !
Posted
Comments
wikus70 5-May-14 2:15am    
As far as I know a mouse and keyboard is read only devices meaning that you can't send info to the devices.
What kind of command would you like to send to these devices? What is your objective?
M­­ar­­­­k 5-May-14 2:57am    
Well, they are input devices as I know either.. But they are just input devices how the platform, the operating system turn on and off those three lights on the key board ?

1 solution

I'm not sure how the OS is able to turn these light on/off. But using Java you can tell the OS to do it. I hope this helps?

Java
import java.awt.Toolkit;
import java.awt.event.KeyEvent;

public class Driver
{
	public static void main(String[] args)
	{
		// turn num lock on
		Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_NUM_LOCK, true);
		// turn num lock off
		Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_NUM_LOCK, false);
		// get num lock state
		boolean isNumLockOn = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_NUM_LOCK);
		
		// turn caps lock on
		Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_CAPS_LOCK, true);
		// turn caps lock off
		Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_CAPS_LOCK, false);
		// get caps lock state
		boolean isCapsLockOn = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
		
		// turn caps lock on
		Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_SCROLL_LOCK, true);
		// turn caps lock off
		Toolkit.getDefaultToolkit().setLockingKeyState(KeyEvent.VK_SCROLL_LOCK, false);
		// get scroll lock state
		boolean isScrollLockOn = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_SCROLL_LOCK);
	}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900