The input system of the engine is completed. this system is composed of a main static input class which contains all input data including keyboard keys, mouse buttons, two analog data, and one cursor. these data are separated into four players and the engine’s parts can access these data from the main input class by specifying the player ID.
cursorX = sx::io::Input::GetCursor_ABS(playerID)->x;
each hardware input device – Keyboard, Mouse, Joystick, etc – can easily defined and attached to the main input class. for example, to define a new joystick for the engine we can write down a unique class for that joystick which is inherited from the standard input device interface of the engine, and attach that to the engine by a unique player ID.
{
// ...
// .. define joystick
// .. change main input class data
// ...
};
// add joystick connectivity. specify player ID in the creation time
sx::io::PInputDeviceBase newDevice = SEGAN_NEW( MyJoystick(new_playerID) );
sx::io::Input::Attach( newDevice );
Also, we can easily send signals to the player devices to change a value or use some new features of current joysticks. something like this:
Input_Signal_Vibration isVibrate;
isVibrate.wLeftMotorSpeed = SX_INPUT_DEFAULT_VIBRATE;
isVibrate.wRightMotorSpeed = SX_INPUT_DEFAULT_VIBRATE;
sx::io::Input::SendSignal(playerID, IST_SHOCK, isVibrate);
And finally, all keys and buttons in this system will have one state from listed below:
SX_INPUT_STATE_NORMAL 0 //This is the normal state of the key
SX_INPUT_STATE_DOWN_FIRST 1 //The key is pressed in first time.
SX_INPUT_STATE_DOWN_HOLD 2 //After the first down, the state will go to hold down
SX_INPUT_STATE_UP -1 // pressing finished.
//This state will go back to normal in the next update
So when we make our game just use one standard input class and don’t worry about devices anymore. easily find how many players are connected. after that according to the gameplay use the keys and data in the input system. For each player change input data or vibrate joystick sets.
PS: The other part of the engine is currently under development. rendering parts, mesh, materials, HUD, AI, script contexts, particles, physics, logic objects, etc will come to gather in the core and will set on scene system and node structures.
that’s amazing …