public static void BindKeyToAction(string actionName, InputCode key, int listIndex) { if (!defaultKeys.Dictionary[actionName].Contains(key)) { if (listIndex == -1) { if (defaultKeys.Dictionary[actionName][0] == InputCode.None) { defaultKeys.Dictionary[actionName][0] = key; } else { defaultKeys.Dictionary[actionName].Add(key); } } else { if (defaultKeys.Dictionary[actionName].Count > listIndex) { defaultKeys.Dictionary[actionName][listIndex] = key; } else { defaultKeys.Dictionary[actionName].Add(key); } } } else { Debug.LogWarning(key.ToString() + " is already bound to " + actionName + ". Key not added"); } keys.Dictionary = defaultKeys.Dictionary; }
private void bunifuButton4_Click(object sender, EventArgs e) { // rendre interface d'ajout // effacer les champs // testé et validé ! bunifuTransition1.HideSync(bunifuShadowPanel1, false, BunifuAnimatorNS.Animation.HorizSlide); bunifuButton4.Visible = false; this.bunifuButton1.ButtonText = "Ajouter une secraitaire"; this.bunifuButton1.Location = new System.Drawing.Point(343, 67); this.bunifuButton1.Size = new System.Drawing.Size(150, 32); if (InputCode.Enabled.Equals(false)) { //this.bunifuButton1.Click -= new EventHandler(Modifier_Click); this.bunifuButton1.Click += new EventHandler(bunifuButton1_Click); InputCode.Enabled = true; } InputCode.ResetText(); bunifuMaterialTextbox1.ResetText(); bunifuMaterialTextbox2.ResetText(); bunifuMaterialTextbox3.ResetText(); bunifuMaterialTextbox4.ResetText(); bunifuTransition1.ShowSync(bunifuShadowPanel1, false, BunifuAnimatorNS.Animation.HorizSlide); }
private bool FindInput(out IDevice outDevice, out InputCode outCode) { Func <IDevice, IVirtualAxis, bool> predicate = (device, axis) => { if (IsAssigned(device)) { return(false); } // ReSharper disable once InvertIf if (!axis.Code.IsMouse()) { return(false); } return(axis.IsDown); }; IVirtualAxis outAxis; if (_inputState.FindFirst(out outDevice, out outAxis, predicate, InterestingAxes)) { outCode = outAxis.Code; return(true); } outDevice = null; outCode = InputCode.None; return(false); }
public void Activate(RailPoint point) { if (isSwitch) { StopCoroutine("resetPoint"); nextPoint = null; InputManager mgr = (InputManager)GameObject.Find("InputManager").GetComponent("InputManager"); for (direction = (InputCode)0; direction < InputCode.Button1 && Switches[(int)direction] != point; direction++) { } for (InputCode i = (InputCode)0; i < InputCode.Button1; ++i) { if (i != direction && Switches[(int)i] != null) { mgr.RegisterListener(this, i); } } } else { foreach (RailPoint i in Switches) { if (i != null && i != point) { nextPoint = i; } } } }
private static bool IsUninteresting(InputCode axis) { switch (axis) { case InputCode.MouseX: case InputCode.MouseY: case InputCode.MouseXLeft: case InputCode.MouseXRight: case InputCode.MouseYUp: case InputCode.MouseYDown: case InputCode.PadLeftStickY: case InputCode.PadLeftStickX: case InputCode.PadLeftStickDown: case InputCode.PadLeftStickUp: case InputCode.PadLeftStickLeft: case InputCode.PadLeftStickRight: case InputCode.PadRightStickY: case InputCode.PadRightStickX: case InputCode.PadRightStickDown: case InputCode.PadRightStickUp: case InputCode.PadRightStickLeft: case InputCode.PadRightStickRight: return(true); default: return(false); } }
private static byte ParseInputName(string inputName) { namedInputCode = 0; byte switchRoute = 0; try { namedInputCode = (InputCode)Enum.Parse(typeof(InputCode), inputName); } catch (ArgumentException) { try { Input.GetKey(inputName); } catch (UnityException) { try { Input.GetAxis(inputName); } catch (UnityException) { switchRoute = 4; } finally { if (switchRoute == 0) { switchRoute = 3; } } } finally { if (switchRoute == 0) { switchRoute = 2; } } } finally { if (switchRoute == 0) { switchRoute = 1; } } return(switchRoute); }
public override void RaiseEvent(InputCode ic) { if (ic == InputCode.Up) { Debug.Log("UP!"); } if (ic == InputCode.Down) { Debug.Log("DOWN!"); } if (ic == InputCode.Left) { Debug.Log("LEFT!"); } if (ic == InputCode.Right) { Debug.Log("RIGHT!"); } if (ic == InputCode.Button1) { Debug.Log("BLUE!"); } if (ic == InputCode.Button2) { Debug.Log("RED!"); } }
/// <summary> /// Initializes a new instance of the <see cref="ws.winx.input.InputAction"/> class. /// </summary> /// <param name="code">Code.</param> /// <param name="type">Type.</param> public InputAction(int code, InputActionType type = InputActionType.SINGLE, IDevice device = null) { if (code < InputCode.MAX_KEY_CODE) { code = InputCode.toCode((KeyCode)code); } __defaultCode = _code = code; __defaultType = _type = type; //if(InputCode.toDeviceInx(_code)==(int)Joysticks.Joystick) _fromAny=true; //Debug.Log("From Any:"+_fromAny); setCode(code, device); //if(_codeString.IndexOf("Joy")>-1) throw new Exception("Use JoystickDevice.toCode function for Joystick inputs"); if ((_isMouse = _codeString.IndexOf("Mou") > -1)) { _isKey = true; } }
private static void DrawBindings(InputCombination comb, SerializedProperty combProp, string labelName, string propertyName) { GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(labelName); SerializedProperty defaultCombProp = combProp.FindPropertyRelative(propertyName); GUIContent addButtonContent = new GUIContent("+"); float addButtonWidth = EditorStyles.miniButton.CalcSize(addButtonContent).x; if (GUILayout.Button(addButtonContent, GUILayout.Width(addButtonWidth))) { comb.AddCode(); } GUILayout.EndHorizontal(); EditorGUI.indentLevel++; int indentLevel2 = EditorGUI.indentLevel; List <InputCode> inputs = comb.inputs; SerializedProperty codesProp = defaultCombProp.FindPropertyRelative("inputs"); for (int j = 0; j < codesProp.arraySize && j < inputs.Count; j++) { GUILayout.BeginHorizontal(); InputCode code = inputs[j]; SerializedProperty codeProp = codesProp.GetArrayElementAtIndex(j); EditorGUILayout.PropertyField(codeProp, GUIContent.none); GUIContent removeButtonContent = new GUIContent("-"); float removeButtonWidth = EditorStyles.miniButton.CalcSize(removeButtonContent).x; if (GUILayout.Button(removeButtonContent, GUILayout.Width(removeButtonWidth))) { comb.RemoveAtIndex(j); codesProp = defaultCombProp.FindPropertyRelative("inputs"); } GUILayout.EndHorizontal(); } }
int nonProfiledStringToCode(String codeStringNoType) { _isJoystick = codeStringNoType.IndexOf("Joy") > -1; if ((_isMouse = codeStringNoType.IndexOf("Mou") > -1) && _isJoystick) { _isKey = true; } if (_isJoystick) { return(InputCode.toCode(codeStringNoType)); // if (InputCode.toDeviceInx(_code) == (int)Joysticks.Joystick) _fromAny = true; } else { // if (_isKey) code = code.ToUpper(); return((int)Enum.Parse(typeof(KeyCode), codeStringNoType, true)); } }
public void changeInputMaps(InputCode action, KeyCode oldKey, KeyCode newKey, int axis) { List <KeyCode> listKey; if (inputMaps.ContainsKey(action)) { listKey = inputMaps [action]; inputMaps.Remove(action); } else { addInputMaps(action, newKey, axis); return; } if (listKey.Contains(oldKey)) { listKey.Remove(oldKey); inputAxis.Remove(oldKey); listKey.Add(newKey); inputAxis.Add(newKey, axis); } else { return; } inputMaps.Add(action, listKey); }
public void removeInputMaps(InputCode action, KeyCode key) { if (inputMaps.ContainsKey(action)) { inputMaps.Remove(action); } }
public override void ProcessInput(InputCode code, object data) { if (code == InputCode.AttackMode && data != null && data is Entity) { Context.SetState(new EntityAttackInputState(Context, data as Entity)); } }
public void Deactivate() { InputManager mgr = (InputManager)GameObject.Find("InputManager").GetComponent("InputManager"); for (InputCode i = (InputCode)0; i < InputCode.Button1; ++i) { mgr.DeregisterListener(this, i); } }
private bool FindInput(out IDevice outDevice, out InputCode outCode) { // this returns first unassigned device with non-zero // input on one of the axes that we're interested in // // this is how you can implement key/button mapping, too: // simply run through supported axes and see which // one reports input (see InputStateExt.FindFirst documentation // for details) // // we also grab the InputCode so we can tell whether the device // is (likely) a keyboard, a mouse or a gamepad var player = _players[_currentPlayer]; Func <IDevice, IVirtualAxis, bool> predicate = (device, axis) => { if (IsAssigned(device)) { return(false); } // ReSharper disable once InvertIf if (player.KeyboardMouse) { // if player wants to use keyboard/mouse then we check which one of the // two has already been assigned and only check the other one if (player.HasKeyboard && !axis.Code.IsMouse()) { return(false); } if (!player.HasKeyboard && !axis.Code.IsKeyboard()) { return(false); } if (axis.Code.IsGamepad()) { return(false); } } return(axis.IsUp); }; // see IsUninteresting above IVirtualAxis outAxis; if (_inputState.FindFirst(out outDevice, out outAxis, predicate, InterestingAxes)) { outCode = outAxis.Code; return(true); } outDevice = null; outCode = InputCode.None; return(false); }
private void ChangeControls() { EventNavRegisterRequest.Enabled = true; //enables the Register Request button EventSendCode.Hide(); //Hides the send code button //shows these controls LabelCode.Show(); InputCode.Show(); EventResend.Show(); }
/// <summary> /// Reconstructs this command from a serialized command and returns the size of the command. /// </summary> public int Reconstruct(byte[] Source, int StartIndex) { Used = false; reader.Initialize(Source, StartIndex); ControllerID = reader.ReadByte(); LeInput = (InputCode)reader.ReadByte(); ValuesMask = reader.ReadUInt(); HasPosition = GetMaskBool(ValuesMask, DataType.Position); HasTarget = GetMaskBool(ValuesMask, DataType.Target); HasFlag = GetMaskBool(ValuesMask, DataType.Flag); HasCoord = GetMaskBool(ValuesMask, DataType.Coord); HasCount = GetMaskBool(ValuesMask, DataType.Count); HasSelect = GetMaskBool(ValuesMask, DataType.Select); HasGroupID = GetMaskBool(ValuesMask, DataType.GroupID); if (HasPosition) { _position.x = reader.ReadShort() << CompressionShift; _position.y = reader.ReadShort() << CompressionShift; } if (HasTarget) { _target = reader.ReadUShort(); } if (HasFlag) { _flag = reader.ReadBool(); } if (HasCoord) { _coord.x = reader.ReadInt(); _coord.y = reader.ReadInt(); } if (HasCount) { _count = reader.ReadInt(); } if (HasSelect) { Select = new Selection(); reader.count += Select.Reconstruct(reader.source, reader.count); } if (HasGroupID) { _groupID = reader.ReadByte(); } return(reader.count - StartIndex); }
public void ResetKeyToDefault(string actionName, InputCode keyToReset) { for (int i = 0; i < Dictionary[actionName].Count; i++) { if (Dictionary[actionName][i] == keyToReset) { Dictionary[actionName][i] = Rebind.defaultKeys.Dictionary[actionName][i]; } } }
public static InputCode[] CopyArray(InputCode[] array) { InputCode[] newArray = new InputCode[array.Length]; for (int i = 0; i < array.Length; i++) { newArray[i] = array[i]; } return(newArray); }
public bool GetKey(InputCode inputCode) { //if (!buttonKeys.ContainsKey(inputCode)) //{ // Debug.Log("InputManager::GetButtonDown -- No button Named: " + inputCode); // return false; //} return(Input.GetKey(buttonKeys[inputCode])); }
private static bool IsUninteresting(InputCode axis) { switch (axis) { case InputCode.MouseLeft: return(false); default: return(true); } }
/// <summary> /// Parse the specified code. /// That could be some KeyCode or additional like /// Joystick3AxisYNegative | Joystick2PovAxisXForward /// /// </summary> /// <param name="code">Code.</param> protected void parse(String code, IDevice device) { //parse TYPE _type = InputActionType.SINGLE; if (code.Contains(InputAction.DOUBLE_DESIGNATOR)) { _type = InputActionType.DOUBLE; code = code.Replace(InputAction.DOUBLE_DESIGNATOR, ""); } else if (code.Contains(InputAction.LONG_DESIGNATOR)) { _type = InputActionType.LONG; code = code.Replace(InputAction.LONG_DESIGNATOR, ""); } if (device != null && device.profile != null)//parsing by profile { _code = InputCode.toCode(code, device.profile); } else//default parsing { _isJoystick = code.IndexOf("Joy") > -1; if ((_isMouse = code.IndexOf("Mou") > -1) && _isJoystick) { _isKey = true; } if (_isJoystick) { _code = InputCode.toCode(code); // if (InputCode.toDeviceInx(_code) == (int)Joysticks.Joystick) _fromAny = true; } else { if (_isKey) { code = code.ToUpper(); } _code = (int)Enum.Parse(typeof(KeyCode), code); } } __defaultType = _type; __defaultCode = _code; }
public MainWindowViewModel() { PhotoboothStatusFilePath = Settings.Default.PhotoboothStatusFilePath; CodeColor = ValidCodeColor; AddDigit = new RelayCommand(_ => InputCode += _, _ => string.IsNullOrEmpty(InputCode) || InputCode.Length < CodeLength); Cancel = new RelayCommand(_ => { InputCode = string.Empty; }, _ => !string.IsNullOrEmpty(InputCode)); Correct = new RelayCommand(_ => InputCode = InputCode.Substring(0, InputCode.Length - 1), _ => !string.IsNullOrEmpty(InputCode)); Validate = new RelayCommand(_ => ValidateCode(), _ => !string.IsNullOrEmpty(InputCode) && InputCode.Length == CodeLength); }
///////////////////////// UPDATE ///////////////////////// /// <summary> /// Update this instance. /// </summary> void Update() { InputState state; if (!Application.isPlaying && !__wereDevicesEnumerated) { __wereDevicesEnumerated = true; InputManager.hidInterface.SetProfiles(AssetDatabase.LoadAssetAtPath("Assets/Resources/DeviceProfiles.asset", typeof(DeviceProfiles)) as DeviceProfiles); InputManager.hidInterface.Enumerate(); } if (!Application.isPlaying && _selectedStateHash != 0) { _action = InputManager.GetAction(_deviceByProfile); if (_action != null && (_action.getCode(_deviceByProfile) ^ (int)KeyCode.Escape) != 0 && (_action.getCode(_deviceByProfile) ^ (int)KeyCode.Return) != 0) { if ((_action.getCode(_deviceByProfile) ^ (int)KeyCode.Backspace) == 0) { state = _stateInputCombinations [_selectedStateHash]; state.combinations [_isPrimary].Clear(); state.combinations [_isPrimary].Add(new InputAction(KeyCode.None)); } else { if (!_isComplexActionTypesAllowed) { _action.type = InputActionType.SINGLE; } _action.setCode(InputCode.toCodeAnyDevice(_action.getCode(_deviceByProfile)), _deviceByProfile); if (_isDeviceAxisPositionFull) { _action.setCode(InputCode.toCodeAxisFull(_action.getCode(_deviceByProfile)), _deviceByProfile); } toInputCombination(_stateInputCombinations [_selectedStateHash].combinations [_isPrimary], _action); } //Debug.Log ("Action:" + _action + " " + _action.getCode(_deviceByProfile)+" type:"+_action.type); } //Debug.Log ("Action:"+action); } }
public void setCode(int newCode, IDevice device) { _code = newCode; if (device == null) { _codeString = InputCode.toEnumString(newCode) + _type.ToDesignatorString(); } else { _codeString = InputCode.toProfiled(newCode, device) + _type.ToDesignatorString(); } }
//-------------------------------------------------------------------------------------------------------------------- // Keydown method // dipanggil ketika key telah ditekan public bool getKeyDown(InputCode action) { List <KeyCode> listKey = inputMaps [action]; for (int i = 0; i < listKey.Count; i++) { if (Input.GetKeyDown(listKey[i])) { return(true); } } return(false); }
/// <summary> /// Update this instance. /// </summary> void Update() { if (_selectedStateHash != 0) { // UnityEngine.Debug.Log("Edit mode true"); //Use is mapping states so no quering keys during gameplay InputManager.EditMode = true; _action = InputManager.GetAction(_playerSelected.Device); if (_action != null && (_action.getCode(_playerSelected.Device) ^ (int)KeyCode.Escape) != 0 && (_action.getCode(_playerSelected.Device) ^ (int)KeyCode.Return) != 0) { if ((_action.getCode(_playerSelected.Device) ^ (int)KeyCode.Backspace) == 0) { _stateInputCombinations [_selectedStateHash].combinations [_isPrimary].Clear(); _stateInputCombinations [_selectedStateHash].combinations [_isPrimary].Add(new InputAction(KeyCode.None)); } else { if (!isComplexActionTypesAllowed) { _action.type = InputActionType.SINGLE; } //remove ord _action.setCode(InputCode.toCodeAnyDevice(_action.getCode(_playerSelected.Device)), _playerSelected.Device); toInputCombination(_stateInputCombinations [_selectedStateHash].combinations [_isPrimary], _action); } // Debug.Log("Action:" + _action + " " + _action.getCode(_playerSelected.Device)); } //Debug.Log ("Action:"+action); } else { // UnityEngine.Debug.Log("Edit mode false"); //Continue gameplay InputManager.EditMode = false; } }
private bool pollForInput() { InputCode poll = checkInput(); if (poll != InputCode.None) { Rebind.BindKeyToAction(keyEditInfo.actionName, poll, keyEditInfo.listIndex); Rebind.defaultBindsSerializer.Save(Rebind.defaultKeys.Dictionary); Rebind.keyBindsSerializer.Save(Rebind.defaultKeys.Dictionary); EditorUtility.SetDirty(target); return(false); } return(true); }
/// <summary> /// Reconstructs this command from a serialized command and returns the size of the command. /// </summary> public int Reconstruct(byte[] Source, int StartIndex) { reader.Initialize(Source, StartIndex); ControllerID = reader.ReadByte(); LeInput = (InputCode)reader.ReadByte(); ValuesMask = reader.ReadUInt(); HasPosition = GetMaskBool(ValuesMask, DataType.Position); HasTarget = GetMaskBool(ValuesMask, DataType.Target); HasFlag = GetMaskBool(ValuesMask, DataType.Flag); HasCoord = GetMaskBool(ValuesMask, DataType.Coord); HasCount = GetMaskBool(ValuesMask, DataType.Count); HasSelect = GetMaskBool(ValuesMask, DataType.Select); if (HasPosition) { _position.x = reader.ReadInt(); _position.y = reader.ReadInt(); } if (HasTarget) { _target = reader.ReadUShort(); } if (HasFlag) { _flag = reader.ReadBool(); } if (HasCoord) { _coord.x = reader.ReadInt(); _coord.y = reader.ReadInt(); } if (HasCount) { _count = reader.ReadInt(); } if (HasSelect) { Select = new Selection(); reader.count += Select.Reconstruct( AgentController.InstanceManagers[ControllerID], reader.source, reader.count); } return(reader.count - StartIndex); }
// Use this for initialization void Start() { buttonToLabel = new Dictionary <InputCode, Text>(); InputCode[] buttonNames = InputManager.Instance.GetButtonNames(); int buttonIndex = 0; foreach (GameObject key in keyButtons) { InputCode inputCodeToRebind = buttonNames[buttonIndex]; key.name = buttonNames[buttonIndex].ToString(); buttonToLabel[buttonNames[buttonIndex]] = key.GetComponentInChildren <Text>(); key.GetComponent <Button>().onClick.AddListener(() => { StartRebindFor(inputCodeToRebind); }); buttonIndex++; } }
static uint[] SEQ_DEF_1(InputCode a) { return SEQ_DEF_2(a, (uint)InputCodes.CODE_NONE); }
public ipd(uint type, string name, InputCode[] seq) { this.type = type; this.name = name; this.seq = seq; }
string code_name(InputCode code) { if (code < code_mac) return internal_code_name(code); switch (code) { case (InputCode)InputCodes.CODE_NONE: return "None"; case (InputCode)InputCodes.CODE_NOT: return "not"; case (InputCode)InputCodes.CODE_OR: return "or"; } return "n/a"; }
protected override sealed void TemplateSetup() { ListenInput = Interfacer.ListenInput; }
static void seq_write(object f, InputCode[] seq) { int j, len; for (len = 0; len < SEQ_MAX; ++len) if (seq[len] == (InputCode)InputCodes.CODE_NONE) break; writeword(f, (ushort)len); for (j = 0; j < len; ++j) { writeint(f, code_to_savecode(seq[j])); } }
static uint[] SEQ_DEF_6(InputCode a, InputCode b, InputCode c, InputCode d, InputCode e, InputCode f) { return new uint[] { a, b, c, d, e, f, (uint)InputCodes.CODE_NONE, (uint)InputCodes.CODE_NONE, (uint)InputCodes.CODE_NONE, (uint)InputCodes.CODE_NONE, (uint)InputCodes.CODE_NONE, (uint)InputCodes.CODE_NONE, (uint)InputCodes.CODE_NONE, (uint)InputCodes.CODE_NONE, (uint)InputCodes.CODE_NONE, (uint)InputCodes.CODE_NONE }; }
static uint[] SEQ_DEF_4(InputCode a, InputCode b, InputCode c, InputCode d) { return SEQ_DEF_5(a, b, c, d, (int)InputCodes.CODE_NONE); }
public InputPair(InputCode input, KeyCode key) { inputCode = input; keyCode = key; }
InputCode seq_get_1(InputCode[] a) { return a[0]; }
static void seq_set_3(InputSeq a, InputCode code1, InputCode code2, InputCode code3) { int j; a[0] = code1; a[1] = code2; a[2] = code3; for (j = 3; j < SEQ_MAX; ++j) a[j] = (uint)InputCodes.CODE_NONE; }
static void seq_set_2(InputSeq a, InputCode code1, InputCode code2) { int j; a[0] = code1; a[1] = code2; for (j = 2; j < SEQ_MAX; ++j) a[j] = (uint)InputCodes.CODE_NONE; }
static void seq_set_1(InputSeq a, InputCode code) { int j; a[0] = code; for (j = 1; j < SEQ_MAX; ++j) a[j] = (uint)InputCodes.CODE_NONE; }
/* Convert one code to one saved code */ static uint code_to_savecode(InputCode code) { if (code < (InputCode)InputCodes.__code_max || code >= code_mac) /* if greather than code_mac is a special CODE like CODE_OR */ return code | SAVECODE_FLAGS_TYPE_STANDARD; switch (code_map[code].type) { case CODE_TYPE_KEYBOARD_OS: return code_map[code].oscode | SAVECODE_FLAGS_TYPE_KEYBOARD_OS; case CODE_TYPE_JOYSTICK_OS: return code_map[code].oscode | SAVECODE_FLAGS_TYPE_JOYSTICK_OS; } /* never happen */ return 0; }
static uint[] SEQ_DEF_2(InputCode a, InputCode b) { return SEQ_DEF_3(a, b, (uint)InputCodes.CODE_NONE); }
static uint[] SEQ_DEF_3(InputCode a, InputCode b, InputCode c) { return SEQ_DEF_4(a, b, c, (uint)InputCodes.CODE_NONE); }
public static void AddInput(InputCode inputCode, KeyCode keyCode) { inputPairs.Add (new InputPair (inputCode, keyCode)); InputCount++; }
static uint[] SEQ_DEF_5(InputCode a, InputCode b, InputCode c, InputCode d, InputCode e) { return SEQ_DEF_6(a, b, c, d, e, (uint)InputCodes.CODE_NONE); }
static void seq_set_0(InputCode[] a) { for (int j = 0; j < SEQ_MAX; ++j) a[j] = CODE_TYPE_NONE; }
bool seq_pressed(InputCode[] code) { int j; bool res = true; bool invert = false; int count = 0; for (j = 0; j < SEQ_MAX; ++j) { switch (code[j]) { case (int)InputCodes.CODE_NONE: return res && count != 0; case (int)InputCodes.CODE_OR: if (res && count != 0) return true; res = true; count = 0; break; case (int)InputCodes.CODE_NOT: invert = !invert; break; default: if (res && (code_pressed(code[j])) == invert) res = false; invert = false; ++count; break; } } return res && count != 0; }
public Command(byte controllerID, InputCode inputCode) { ControllerID = controllerID; LeInput = inputCode; }
public Command(InputCode inputCode, byte controllerID) { this.LeInput = inputCode; this.ControllerID = controllerID; }
public Command(InputCode inputCode) { LeInput = inputCode; }
public static bool GetInputUp(InputCode inputcode) { castedInputCode = (ulong)1 << (int)inputcode; return ((PressedUpInputs & castedInputCode) == castedInputCode); }
/// <summary> /// Reconstructs this command from a serialized command and returns the size of the command. /// </summary> public int Reconstruct(byte[] Source, int StartIndex) { Used = false; reader.Initialize(Source, StartIndex); ControllerID = reader.ReadByte(); LeInput = (InputCode)reader.ReadByte(); ValuesMask = reader.ReadUInt(); HasPosition = GetMaskBool(ValuesMask, DataType.Position); HasTarget = GetMaskBool(ValuesMask, DataType.Target); HasFlag = GetMaskBool(ValuesMask, DataType.Flag); HasCoord = GetMaskBool(ValuesMask, DataType.Coord); HasCount = GetMaskBool(ValuesMask, DataType.Count); HasSelect = GetMaskBool(ValuesMask, DataType.Select); HasGroupID = GetMaskBool(ValuesMask, DataType.GroupID); if (HasPosition) { _position.x = reader.ReadShort() << CompressionShift; _position.y = reader.ReadShort() << CompressionShift; } if (HasTarget) { _target = reader.ReadUShort(); } if (HasFlag) { _flag = reader.ReadBool(); } if (HasCoord) { _coord.x = reader.ReadInt(); _coord.y = reader.ReadInt(); } if (HasCount) { _count = reader.ReadInt(); } if (HasSelect) { Select = new Selection(); reader.count += Select.Reconstruct(reader.source, reader.count); } if (HasGroupID) { _groupID = reader.ReadByte(); } return reader.count - StartIndex; }
public static void PressInputDown(InputCode inputCode) { castedInputCode = (ulong)1 << (int)inputCode; PressedDownInputs |= castedInputCode; PressedInputs |= castedInputCode; }
public static void PressInputUp(InputCode inputCode) { castedInputCode = (ulong)1 << (int)inputCode; PressedUpInputs |= castedInputCode; PressedInputs ^= castedInputCode; }
bool code_pressed_memory_repeat(InputCode code, int speed) { bool pressed; pressed = internal_code_pressed(code); if (pressed) { if (!code_map[code].memory) { code_map[code].memory = true; keydelay = 3; counter2 = 0; } else if (++counter2 > keydelay * speed * Machine.drv.frames_per_second / 60) { keydelay = 1; counter = 0; } else pressed = false; } else code_map[code].memory = false; return pressed; }
/// <summary> /// Reconstructs this command from a serialized command and returns the size of the command. /// </summary> public int Reconstruct(byte[] Source, int StartIndex) { reader.Initialize (Source, StartIndex); ControllerID = reader.ReadByte (); LeInput = (InputCode)reader.ReadByte (); ValuesMask = reader.ReadUInt (); HasPosition = GetMaskBool (ValuesMask, DataType.Position); HasTarget = GetMaskBool (ValuesMask, DataType.Target); HasFlag = GetMaskBool (ValuesMask, DataType.Flag); HasCoord = GetMaskBool (ValuesMask, DataType.Coord); HasCount = GetMaskBool (ValuesMask, DataType.Count); HasSelect = GetMaskBool (ValuesMask, DataType.Select); if (HasPosition) { _position.x = reader.ReadInt (); _position.y = reader.ReadInt (); } if (HasTarget) { _target = reader.ReadUShort (); } if (HasFlag) { _flag = reader.ReadBool (); } if (HasCoord) { _coord.x = reader.ReadInt (); _coord.y = reader.ReadInt (); } if (HasCount) { _count = reader.ReadInt (); } if (HasSelect) { Select = new Selection(); reader.count += Select.Reconstruct ( AgentController.InstanceManagers[ControllerID], reader.source, reader.count); } return reader.count - StartIndex; }