2 inputs given, both ON

I am giving 2 inputs and both will be ON at some point of time (considering) , so what I want is if the order is 1st ON and 2nd ON I want the motor to rotate to direction 1... wait 3 sec and then rotate to direction 2.

If we have 2nd ON and then 1st ON, the reverse should happen.

How can I do that ?

One way is to have a variable called (say) firstON and read both your input to decide what value to put into it

inputAstate = digitalRead(inputApin);
inputBstate = digitalRead(inputBpin);
if (inputAstate == LOW) { // assumes LOW when button pressed
   firstOn = 'A';
}
else if {inputBstate == LOW) {
   firstOn = 'B';
}

...R