Key bindings now available via scripts
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
void added_script()
|
||||
{
|
||||
displayMessage("This trigger was added by another script");
|
||||
displayMessage(getKeyBinding("DRIFT") + getKeyBinding("ACCEL") + "This trigger was added by another script");
|
||||
jumpKartTo( 0, 67.90, 99.49 );
|
||||
Vec3 a;
|
||||
Vec3 b;
|
||||
|
||||
@@ -87,9 +87,15 @@ namespace Scripting
|
||||
std::string *str = (std::string*)gen->GetArgAddress(0);
|
||||
InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
|
||||
DeviceConfig* config = device->getConfiguration();
|
||||
irr::core::stringw skid = config->getBindingAsString(PA_DRIFT);
|
||||
std::string key = std::string(irr::core::stringc(skid).c_str());
|
||||
gen->SetReturnObject(&key);
|
||||
irr::core::stringw control;
|
||||
//TODO : bind Enumerables?
|
||||
if (*str == "DRIFT")control = config->getBindingAsString(PA_DRIFT);
|
||||
if (*str == "FIRE")control = config->getBindingAsString(PA_FIRE);
|
||||
if (*str == "ACCEL")control = config->getBindingAsString(PA_ACCEL);
|
||||
|
||||
std::string key = std::string(irr::core::stringc(control).c_str());
|
||||
void *key_pointer = &key;
|
||||
gen->SetReturnObject(key_pointer);
|
||||
}
|
||||
void getTrackObject(asIScriptGeneric *gen)
|
||||
{
|
||||
@@ -111,7 +117,6 @@ namespace Scripting
|
||||
void registerScriptFunctions(asIScriptEngine *engine)
|
||||
{
|
||||
int r;
|
||||
void getKeyBinding(asIScriptGeneric *gen)
|
||||
|
||||
r = engine->RegisterGlobalFunction("void displayMessage(string &in)", asFUNCTION(displayMessage), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void disableAnimation(string &in)", asFUNCTION(disableAnimation), asCALL_GENERIC); assert(r >= 0);
|
||||
@@ -120,7 +125,7 @@ namespace Scripting
|
||||
r = engine->RegisterGlobalFunction("void disableTrigger(string &in)", asFUNCTION(disableTrigger), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void createTrigger(string &in,float x,float y,float z, float distance)",
|
||||
asFUNCTION(createTrigger), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("void getKeyBinding(string &in)", asFUNCTION(displayMessage), asCALL_GENERIC); assert(r >= 0);
|
||||
r = engine->RegisterGlobalFunction("string getKeyBinding(string &in)", asFUNCTION(getKeyBinding), asCALL_GENERIC); assert(r >= 0);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user