Posted 14 October 2012 - 07:21 PM
In the beta with advanced computers, there's now mouse support. This made me think about why i can't just grab the x,y coordinates of the mouse. Obviously, because there might be multiple people viewing the computer. So i realized that mouses and keyboards could treated like peripherals.
Every time someone opens the computer's GUI, it adds a new mouse peripheral and a new keyboard peripheral. The programmer can take each one individually and do stuff with them. For example, they might make a game where they can keep track of what each person is doing separately. When Jacob clicks here, it turns that character blue. When John clicks there, it turns that one blue. John's keyboard moves John's character and Jacob's moves his.
The mouse peripheral would have a getPos function and the ability to set a callback for clicks. Something like this:
So that's the mouse. Now the keyboard would be pretty similar. There'd be an onKey or onChar property you can set just like the onClick in the mouse.
Ok so the main purpose of this change is for modularization of the keyboard and mouse. I want to be able to see them as separate people and as the peripherals they truly are.
EDIT: Oh and i forgot the Monitor. It should detect clicks as well. These clicks however, (unlike the ones in the screen) WOULD be anonymous, like they are now.
Every time someone opens the computer's GUI, it adds a new mouse peripheral and a new keyboard peripheral. The programmer can take each one individually and do stuff with them. For example, they might make a game where they can keep track of what each person is doing separately. When Jacob clicks here, it turns that character blue. When John clicks there, it turns that one blue. John's keyboard moves John's character and Jacob's moves his.
The mouse peripheral would have a getPos function and the ability to set a callback for clicks. Something like this:
johnsMousePeripheral.onClick = function(mousePeripheral, x, y, button)
if mousePeripheral.getUserName() == "john" and button == 1 then --double checking that it's john's mouse. No actual need to do this besides pointing out the getUserName function
term.setCursorPos(x, y)
term.setBackgroundColor(colors.blue)
term.write(" ")
term.setBackgroundColor(colors.black)
end
end
So that's the mouse. Now the keyboard would be pretty similar. There'd be an onKey or onChar property you can set just like the onClick in the mouse.
Ok so the main purpose of this change is for modularization of the keyboard and mouse. I want to be able to see them as separate people and as the peripherals they truly are.
EDIT: Oh and i forgot the Monitor. It should detect clicks as well. These clicks however, (unlike the ones in the screen) WOULD be anonymous, like they are now.