Sorry I haven't replied for so long, I have been busy (and I still am). But I definitely want this to get done eventually, it just might take time.
Ideas:
void Game::defineActions()
{
Scheme* ingame = SchemeManager::getSingleton().createScheme("Ingame");
// defining actions
Action* shoot = ingame->createAction("Shoot", AT_DIGITAL);
Action* nextW = ingame->createAction("Next weapon", AT_DIGITAL);
Action* prevW = ingame->createAction("Previous weapon", AT_DIGITAL);
Action* mouseLookX = ingame->createAction("Mouse Look X", AT_ANALOG_AXIS);
Action* mouseLookY = ingame->createAction("Mouse Look Y", AT_ANALOG_AXIS);
// binding them
Keyboard* keyboard = DeviceManager::getSingleton().getDevice("Keyboard");
shoot->bind(keyboard->getState("CTRL")); // doom 1 style!
nextW->bind("Keyboard/R"); // allow absolute string state names (this eases loading/saving of bindings)
prevW->bind("Keyboard/T");
mouseLookX->bind("Mouse/X Axis");
mouseLookY->bind("Mouse/Y Axis");
// will also allow this to make things extra easy for scripts/loading/saving
ingame->bind("Shoot", "Keyboard/CTRL");
ingame->bind("Shoot", "Keyboard/CTRL + Keyboard/A"); // combination binding
// I want "," to delimit alternative bindings (ie any of those states activated means that action is activated)
// and "+" to delimit combination bindings (all of those states need to be activated for the action to be activated)
// I am not sure yet how I will implement this in the raw API
// maybe this?
Binding b;
b.add("Keyboard/CTRL");
b.add("Keyboard/A");
shoot->bind(b);
// I don't like this yet so I will give it some more thought
Scheme* ingameCar = SchemeManager::getSingleton().createScheme("Ingame (Car)");
AnalogAxisAction* steer = static_cast<AnalogAxisAction*>(ingameCar->createAction("Steer", AT_ANALOG_AXIS));
// change properties of analog axis action
steer->setAllowAnalogEmulation(true);
steer->setMinimum(-1.0);
// also allow properties for easier save/load and scripting
steer->setProperty("Minimum", "-1.0");
steer->setProperty("Maximum", "1.0");
steer->setProperty("Sensitivity", "2.0");
// for analog, you can normally bind analog stuff
steer->bind("Joystick/Axis");
// or you can bind digital stuff and the analog action will emulate analog input state
steer->bindDigital("Keyboard/Left", "Keyboard/Right");
// I might allow some other ways to do this to ease scripting
// perhaps this?:
steer->bind("Keyboard/Left, Keyboard/Right");
Scheme* menu = SchemeManager::getSingleton().createScheme("Menu");
Action* mouseX = menu->createAction("Mouse X", AT_ANALOG_AXIS);
Action* mouseY = menu->createAction("Mouse Y", AT_ANALOG_AXIS);
Action* click = menu->createAction("Mouse Click", AT_DIGITAL);
// ...
// KONAMI SEQUENCE STUFF
SequenceAction* iddqd = static_cast<SequenceAction*>(ingame->createAction("Godmode", AT_SEQUENCE));
// I don't like this, it doesn't really decouple actions and input states
// and it disallows 2 or more possible sequences
iddqd->bind("Keyboard/I, Keyboard/D, Keyboard/D, Keyboard/Q, Keyboard/D");
iddqd->setTimeout(0.5); // allow half a second between sequence keys
// I have no idea yet about gestures, but I guess gestures are pretty much just Action's that
// will need 2 analog axes bound to them and they can recognize something based on that
// I have to do more research in this area
ingame->activate();
menu->deactivate();
// now
}
void Game::setupIngame()
{
SchemeManager::getSingleton().deactivateAll();
ingame->activate();
}
// HOW TO USE THE ACTIONS IN BUFFERED MODE:
if (shoot->isActive())
{
// perform shooting
}
//...
// OR VIA LISTENERS
via shoot->setListener(ActionListener*)
// BUFFERED ANALOG ACTION
if (steer->isActive()) // this means it was activated == changed
{
// steer our ingame car
//steer->getAbsolute();
//steer->getRelative();
}
This is just a mockup, but most of this is already possible with my code with some differences. I want to clean it up a lot (right now I only support buffered actions).
I want to make it easy to create generic ingame controls UI. So I will add ways to listen to all states at once, etc...