mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-22 17:29:18 +01:00
c443be85a7
Profile system; Megred options/mapping; Button mode and Standard Mode; removed other touchpad modes; allow 360 controls on touchpad points; Minor Changes: Color picker for light bar is more accurate, added keyboard popup for mapping, PS+Touching pad toggles sliding, added more mouse buttons + media keys Signed-off-by: jays2kings <jays2kings@gmail.com>
94 lines
3.1 KiB
C#
94 lines
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using DS4Library;
|
|
namespace DS4Control
|
|
{
|
|
class TPadModeSwitcher
|
|
{
|
|
List<ITouchpadBehaviour> modes = new List<ITouchpadBehaviour>();
|
|
public event EventHandler<DebugEventArgs> Debug = null;
|
|
private DS4Device device;
|
|
Int32 currentTypeInd = 0;
|
|
public TPadModeSwitcher(DS4Device device, int deviceID)
|
|
{
|
|
this.device = device;
|
|
//modes.Add(TouchpadDisabled.singleton);
|
|
modes.Add(new Mouse(deviceID, device));
|
|
//modes.Add(new ButtonMouse(deviceID, device));
|
|
//modes.Add(new MouseCursorOnly(deviceID));
|
|
//modes.Add(new DragMouse(deviceID));
|
|
}
|
|
|
|
public void switchMode(int ind)
|
|
{
|
|
ITouchpadBehaviour currentMode = modes.ElementAt(currentTypeInd);
|
|
device.Touchpad.TouchButtonDown -= currentMode.touchButtonDown;
|
|
device.Touchpad.TouchButtonUp -= currentMode.touchButtonUp;
|
|
device.Touchpad.TouchesBegan -= currentMode.touchesBegan;
|
|
device.Touchpad.TouchesMoved -= currentMode.touchesMoved;
|
|
device.Touchpad.TouchesEnded -= currentMode.touchesEnded;
|
|
device.Touchpad.TouchUnchanged -= currentMode.touchUnchanged;
|
|
setMode(ind);
|
|
}
|
|
|
|
public void setMode(int ind)
|
|
{
|
|
ITouchpadBehaviour tmode = modes.ElementAt(ind % modes.Count);
|
|
device.Touchpad.TouchButtonDown += tmode.touchButtonDown;
|
|
device.Touchpad.TouchButtonUp += tmode.touchButtonUp;
|
|
device.Touchpad.TouchesBegan += tmode.touchesBegan;
|
|
device.Touchpad.TouchesMoved += tmode.touchesMoved;
|
|
device.Touchpad.TouchesEnded += tmode.touchesEnded;
|
|
device.Touchpad.TouchUnchanged += tmode.touchUnchanged;
|
|
currentTypeInd = ind;
|
|
LogDebug("Touchpad mode for " + device.MacAddress + " is now " + tmode.ToString());
|
|
Log.LogToTray("Touchpad mode for " + device.MacAddress + " is now " + tmode.ToString());
|
|
Global.ControllerStatusChanged(this);
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return modes.ElementAt(currentTypeInd).ToString();
|
|
}
|
|
|
|
public void previousMode()
|
|
{
|
|
int i = currentTypeInd - 1;
|
|
if (i == -1)
|
|
i = modes.Count - 1;
|
|
switchMode(i);
|
|
}
|
|
|
|
public void nextMode()
|
|
{
|
|
int i = currentTypeInd + 1;
|
|
if (i == modes.Count)
|
|
i = 0;
|
|
switchMode(i);
|
|
}
|
|
|
|
private void LogDebug(string data)
|
|
{
|
|
if (Debug != null)
|
|
Debug(this, new DebugEventArgs(data));
|
|
}
|
|
|
|
/*public ITouchpadBehaviour getCurrentMode()
|
|
{
|
|
return modes.ElementAt(currentTypeInd);
|
|
}*/
|
|
|
|
public ITouchpadBehaviour[] getAvailableModes()
|
|
{
|
|
return modes.ToArray();
|
|
}
|
|
|
|
public int getCurrentModeInt()
|
|
{
|
|
return currentTypeInd;
|
|
}
|
|
}
|
|
}
|