c-o
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controlling.UsrActivity
|
||||
{
|
||||
public interface ITrigger
|
||||
{
|
||||
public int TargetKeyOrButtonID { get; }
|
||||
public KeyStatus TriggeredStatus { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controlling.UsrActivity
|
||||
{
|
||||
public struct JoystickTrigger : ITrigger, IEquatable<JoystickTrigger>
|
||||
{
|
||||
public Joystick Stick;
|
||||
|
||||
private KeyStatus _triggeredStat;
|
||||
|
||||
public int TargetKeyOrButtonID => (int)Stick;
|
||||
|
||||
public KeyStatus TriggeredStatus => _triggeredStat;
|
||||
|
||||
public JoystickTrigger(Joystick targetKey)
|
||||
{
|
||||
this.Stick = targetKey;
|
||||
}
|
||||
|
||||
public static bool operator ==(JoystickTrigger left, JoystickTrigger right)
|
||||
{
|
||||
return left._triggeredStat == right._triggeredStat && left.Stick == right.Stick;
|
||||
}
|
||||
|
||||
public static bool operator !=(JoystickTrigger left, JoystickTrigger right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (int)Stick + 17 * (int)_triggeredStat;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Key {Stick} triggered when {_triggeredStat}";
|
||||
}
|
||||
|
||||
bool IEquatable<JoystickTrigger>.Equals(JoystickTrigger other)
|
||||
{
|
||||
return other == this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Controlling.UsrActivity
|
||||
{
|
||||
|
||||
public struct KeyTrigger: ITrigger,IEquatable<KeyTrigger>
|
||||
{
|
||||
public KeyboardKey TargetKey;
|
||||
private KeyStatus _triggerStat;
|
||||
|
||||
int ITrigger.TargetKeyOrButtonID => (int)TargetKey;
|
||||
|
||||
KeyStatus ITrigger.TriggeredStatus => _triggerStat;
|
||||
|
||||
public KeyTrigger(KeyboardKey targetKey)
|
||||
{
|
||||
this.TargetKey = targetKey;
|
||||
}
|
||||
|
||||
public static bool operator ==(KeyTrigger left, KeyTrigger right)
|
||||
{
|
||||
return left._triggerStat == right._triggerStat && left.TargetKey == right.TargetKey;
|
||||
}
|
||||
|
||||
public static bool operator !=(KeyTrigger left, KeyTrigger right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (int)TargetKey + 17 * (int)_triggerStat;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Key {TargetKey} triggered when {_triggerStat}";
|
||||
}
|
||||
|
||||
bool IEquatable<KeyTrigger>.Equals(KeyTrigger other)
|
||||
{
|
||||
return other == this;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user