public void ModifyActionInput(InputObj aInputObject, Enum aPositiveInput, Enum aNegativeInput, InputType aInputType) { //Same as create except you change the values of existing object rather than create a new one... aInputObject.InputElement = aPositiveInput; aInputObject.Type = aInputType; if (aNegativeInput != null) { aInputObject.InputElementNegative = aNegativeInput; aInputObject.IsConstructedAxis = true; return; } aInputObject.IsConstructedAxis = false; }
private void AddInput(object sender, EventArgs e) { using (var form = new IdentifierForm <InputObj>("Input", inputs.Keys)) { if (form.ShowDialog(this) == DialogResult.OK) { var obj = new InputObj { UserDefined = true, Type = "any" }; inputs.Add(form.Identifier, obj); cmboInputs.Items.Add(form.Identifier); cmboInputs.SelectedIndex = cmboInputs.FindStringExact(form.Identifier); InputChanged(null, EventArgs.Empty); } } }
//-------------------------------------------------------------------- //public delegate void ButtonInputDelegate(); //protected ButtonInputDelegate m_ButtonInputDel; //public void CheckInput(InputObj aInputObject, Actor aActor, ButtonInputDelegate aInputDel) //aInputDel(); //-------------------------------------------------------------------- public float CheckInput(InputObj aInputObject, Actor aActor) { if (InputManager.Instance.m_InputConfigs[(int)aActor.PlayerNumber].Peripheral != null) { if (aInputObject.IsConstructedAxis) { switch (aInputObject.Type) { case InputType.Disabled: Debug.Log("Key Disabled"); break; case InputType.Tap: //Needs some more work... if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) > 0.01 && aInputObject.ValueLastFrame < 0.01f) //need to handle GOD element { aInputObject.ValueLastFrame = 1.0f; return Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString()); } else if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) < 0.01) { aInputObject.ValueLastFrame = 0.0f; } //NEGATIVE if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElementNegative.ToString())) > 0.01 && aInputObject.ValueLastFrame > -0.01f) //need to handle GOD element { aInputObject.ValueLastFrame = -1.0f; return -Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElementNegative.ToString()); } else if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElementNegative.ToString())) < 0.01) { aInputObject.ValueLastFrame = 0.0f; } break; case InputType.DoubleTap: // Not Implemented break; case InputType.Hold: if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) > 0.01) { return Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString()); } //NEGATIVE if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElementNegative.ToString())) > 0.01) { return -Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElementNegative.ToString()); } break; case InputType.Toggle: // Not Implemented break; default: Debug.Log("Unhandled Input Type " + aInputObject); break; } return 0.0f; } else // !aInputObject.IsConstructedAxis { switch (aInputObject.Type) { case InputType.Disabled: Debug.Log("Key Disabled"); break; case InputType.Tap: //Needs some more work... if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) > 0.01 && aInputObject.ValueLastFrame < 0.01f) //need to handle GOD element { aInputObject.ValueLastFrame = 1.0f; return Mathf.Sign(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())); } else if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) < 0.01) { aInputObject.ValueLastFrame = 0.0f; } break; case InputType.DoubleTap: // Not Implemented break; case InputType.Hold: if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) > 0.01) { return Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString()); } break; case InputType.Toggle: if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) > 0.01 && aInputObject.ValueLastFrame < 0.01f && !aInputObject.IsToggled) //need to handle GOD element { aInputObject.ValueLastFrame = 1.0f; aInputObject.IsToggled = true; return Mathf.Sign(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())); } else if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) > 0.01 && aInputObject.ValueLastFrame < 0.01f && aInputObject.IsToggled) //need to handle GOD element { aInputObject.ValueLastFrame = 1.0f; aInputObject.IsToggled = false; } else if (aInputObject.IsToggled && Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) < 0.01) // if no input and toggled { //currently toggled aInputObject.ValueLastFrame = 0.0f; return Mathf.Sign(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())); } else if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) < 0.01) { aInputObject.ValueLastFrame = 0.0f; } break; default: Debug.Log("Unhandled Input Type " + aInputObject); break; } return 0.0f; } } else { Debug.Log(aActor.name + " Peripheral set to " + InputManager.Instance.m_InputConfigs[(int)aActor.PlayerNumber].Peripheral); return 0.0f; } }
public string EchoInputObject(IFieldContext context, InputObj inpObj) { return(inpObj.ToString()); }
public async Task Test_Input_InputObjects() { string query; GraphQLResponse resp; string result; TDict vars; TestEnv.LogTestMethodStart(); TestEnv.LogTestDescr("literal input object as argument."); query = @" query { res: echoInputObj(inpObj: {id: 1, name: ""abc"", num: 0}) # returns inpObj.ToString() }"; resp = await ExecuteAsync(query); result = (string)resp.Data["res"]; Assert.AreEqual("id:1,name:abc,num:0", result, "Result mismatch"); TestEnv.LogTestDescr("literal input object as argument, with some of its properties set from variables."); query = @" query myQuery($id : int) { res: echoInputObj(inpObj: {id: $id, name: ""abc"", num:456}) }"; vars = new TDict() { { "id", 1 } }; resp = await ExecuteAsync(query, vars); result = (string)resp.Data["res"]; Assert.AreEqual("id:1,name:abc,num:456", result, "Result mismatch"); TestEnv.LogTestDescr("literal input object as argument; variable value ($id) is not provided and is assigned from default."); query = @" query myQuery($num: Int!, $name: String!, $id: Int = 123) { echoInputObj (inpObj: {id: $id, num: $num, name: $name}) }"; vars = new TDict(); vars["num"] = 456; vars["name"] = "SomeName"; resp = await ExecuteAsync(query, vars); var echoInpObj2 = resp.GetValue <string>("echoInputObj"); Assert.AreEqual("id:123,name:SomeName,num:456", echoInpObj2); //this is InputObj.ToString() TestEnv.LogTestDescr("complex input object in a variable."); query = @" query myQuery($inpObj: InputObj!) { echoInputObj (inpObj: $inpObj) }"; vars = new TDict(); // we cannot use InputObj here, serializer will send first-cap prop names and request will fail vars["inpObj"] = new InputObj() { Id = 123, Num = 456, Name = "SomeName" }; resp = await ExecuteAsync(query, vars); var echoInpObj = resp.GetValue <string>("echoInputObj"); Assert.AreEqual("id:123,name:SomeName,num:456", echoInpObj); //this is InputObj.ToString() }
//-------------------------------------------------------------------- //public delegate void ButtonInputDelegate(); //protected ButtonInputDelegate m_ButtonInputDel; //public void CheckInput(InputObj aInputObject, Actor aActor, ButtonInputDelegate aInputDel) //aInputDel(); //-------------------------------------------------------------------- public float CheckInput(InputObj aInputObject, Actor aActor) { if (InputManager.Instance.m_InputConfigs[(int)aActor.PlayerNumber].Peripheral != null) { if (aInputObject.IsConstructedAxis) { switch (aInputObject.Type) { case InputType.Disabled: Debug.Log("Key Disabled"); break; case InputType.Tap: //Needs some more work... if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) > 0.01 && aInputObject.ValueLastFrame < 0.01f) //need to handle GOD element { aInputObject.ValueLastFrame = 1.0f; return(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())); } else if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) < 0.01) { aInputObject.ValueLastFrame = 0.0f; } //NEGATIVE if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElementNegative.ToString())) > 0.01 && aInputObject.ValueLastFrame > -0.01f) //need to handle GOD element { aInputObject.ValueLastFrame = -1.0f; return(-Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElementNegative.ToString())); } else if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElementNegative.ToString())) < 0.01) { aInputObject.ValueLastFrame = 0.0f; } break; case InputType.DoubleTap: // Not Implemented break; case InputType.Hold: if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) > 0.01) { return(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())); } //NEGATIVE if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElementNegative.ToString())) > 0.01) { return(-Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElementNegative.ToString())); } break; case InputType.Toggle: // Not Implemented break; default: Debug.Log("Unhandled Input Type " + aInputObject); break; } return(0.0f); } else // !aInputObject.IsConstructedAxis { switch (aInputObject.Type) { case InputType.Disabled: Debug.Log("Key Disabled"); break; case InputType.Tap: //Needs some more work... if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) > 0.01 && aInputObject.ValueLastFrame < 0.01f) //need to handle GOD element { aInputObject.ValueLastFrame = 1.0f; return(Mathf.Sign(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString()))); } else if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) < 0.01) { aInputObject.ValueLastFrame = 0.0f; } break; case InputType.DoubleTap: // Not Implemented break; case InputType.Hold: if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) > 0.01) { return(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())); } break; case InputType.Toggle: if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) > 0.01 && aInputObject.ValueLastFrame < 0.01f && !aInputObject.IsToggled) //need to handle GOD element { aInputObject.ValueLastFrame = 1.0f; aInputObject.IsToggled = true; return(Mathf.Sign(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString()))); } else if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) > 0.01 && aInputObject.ValueLastFrame < 0.01f && aInputObject.IsToggled) //need to handle GOD element { aInputObject.ValueLastFrame = 1.0f; aInputObject.IsToggled = false; } else if (aInputObject.IsToggled && Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) < 0.01) // if no input and toggled { //currently toggled aInputObject.ValueLastFrame = 0.0f; return(Mathf.Sign(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString()))); } else if (Mathf.Abs(Input.GetAxis(Peripheral.PeripheralString + "_" + aInputObject.InputElement.ToString())) < 0.01) { aInputObject.ValueLastFrame = 0.0f; } break; default: Debug.Log("Unhandled Input Type " + aInputObject); break; } return(0.0f); } } else { Debug.Log(aActor.name + " Peripheral set to " + InputManager.Instance.m_InputConfigs[(int)aActor.PlayerNumber].Peripheral); return(0.0f); } }