Compare commits
26 Commits
14877f4711
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
83f2e08bb5 | ||
|
4c07938a0d | ||
|
df80ce37ed | ||
|
50c6c9a1de | ||
|
0b3822b8da | ||
a63133a7a5 | |||
600a08dd51 | |||
|
9d33f9a223 | ||
|
ed334a7cf9 | ||
7fb6b4c89c | |||
|
1666be73b3 | ||
6ab18fdf70 | |||
|
987ccad5b9 | ||
|
027ec1f0d9 | ||
7699f5c6b9 | |||
ac92fcb041 | |||
849307d2cc | |||
b0bc2fead2 | |||
|
59673ec211 | ||
|
ee39a91229 | ||
|
2251de8ce9 | ||
|
f3b56cade2 | ||
|
b0427e611b | ||
|
f31a05dcf4 | ||
|
603a171f1b | ||
|
c83c60d2b3 |
@@ -1,4 +1,4 @@
|
|||||||
using FakeeDeck.Class;
|
using FakeDeck.Class;
|
||||||
using Microsoft.VisualBasic.Logging;
|
using Microsoft.VisualBasic.Logging;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
@@ -3,17 +3,21 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrayNotify;
|
||||||
|
|
||||||
namespace FakeeDeck.ButtonType
|
namespace FakeDeck.ButtonType
|
||||||
{
|
{
|
||||||
internal class Button
|
internal class Button
|
||||||
{
|
{
|
||||||
public static string getButtonHTML(string icon, string image, string name, string action, Dictionary<string, string> parameters = null)
|
public static string getButtonHTML(string icon, string image, string name, string action = null, string jsAction = null, Dictionary<string, string> parameters = null, string color = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
string body = "";
|
string body = "";
|
||||||
|
string styles = "style=\"background-size: cover; " + (!string.IsNullOrEmpty(image) ? "background-image: url('" + image + "');" : "") + " width: 150px; height: 150px; " + (!string.IsNullOrEmpty(image) ? "background-image: url('" + image + "');" : "") + (!string.IsNullOrEmpty(color) ? " background-color: " + color + "; " : "") + "\"";
|
||||||
|
|
||||||
body += "<div class=\"m-2\">";
|
body += "<div>";
|
||||||
|
if (action != null)
|
||||||
|
{
|
||||||
body += "<form style=\"margin-bottom: 0px;\" method=\"post\" action=\"" + action + "\">";
|
body += "<form style=\"margin-bottom: 0px;\" method=\"post\" action=\"" + action + "\">";
|
||||||
|
|
||||||
if (parameters is not null)
|
if (parameters is not null)
|
||||||
@@ -24,11 +28,21 @@ namespace FakeeDeck.ButtonType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
body += "<button type=\"submit\" value=\"submit\" style=\"background-size: cover; " + (!string.IsNullOrEmpty(image) ? "background-image: url('" + image + "');" : "") + " width: 150px;height: 150px; background-color: aquamarine;\" >";
|
body += "<button class=\"button\" type=\"submit\" value=\"submit\" " + styles + ">";
|
||||||
body += (!string.IsNullOrEmpty(icon) ? "<i class=\"fa-solid " + icon + "\"></i>" : name);
|
body += (!string.IsNullOrEmpty(icon) ? "<i class=\"fa-solid " + icon + "\"></i>" : name);
|
||||||
body += "</button>";
|
body += "</button>";
|
||||||
|
|
||||||
body += "</form>";
|
body += "</form>";
|
||||||
|
}
|
||||||
|
else if (jsAction != null)
|
||||||
|
{
|
||||||
|
body += "<button class=\"button\" onclick=\"" + jsAction + "\" " + styles + " >";
|
||||||
|
body += (!string.IsNullOrEmpty(icon) ? "<i class=\"fa-solid " + icon + "\"></i>" : name);
|
||||||
|
body += "</button>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
body += "<div class=\"button\" " + styles + "></div>";
|
||||||
|
}
|
||||||
body += "</div>";
|
body += "</div>";
|
||||||
|
|
||||||
return body;
|
return body;
|
||||||
|
38
FakeDeckUI/FakeDeck/ButtonType/FakeDeckMacro.cs
Normal file
38
FakeDeckUI/FakeDeck/ButtonType/FakeDeckMacro.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using FakeDeck.ButtonType;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace FakeDeck.ButtonType
|
||||||
|
{
|
||||||
|
internal class FakeDeckMacro : Button
|
||||||
|
{
|
||||||
|
public static Dictionary<string, string> actionIcons = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "full-screen", "fa-maximize"},
|
||||||
|
{ "set-page", "fa-page"},
|
||||||
|
};
|
||||||
|
|
||||||
|
public static string getButton(string Key, string Image = null, string PageId = null, string Color = null)
|
||||||
|
{
|
||||||
|
if (Key == "full-screen")
|
||||||
|
{
|
||||||
|
return getButtonHTML(actionIcons[Key], Image, Key, null, "!document.fullscreenElement?document.documentElement.requestFullscreen():document.exitFullscreen();", null, Color);
|
||||||
|
}
|
||||||
|
if (Key == "set-page")
|
||||||
|
{
|
||||||
|
return getButtonHTML(actionIcons[Key], Image, Key, null, "loadPage('"+ PageId + "')", null, Color);
|
||||||
|
}
|
||||||
|
if (Key == "spacer")
|
||||||
|
{
|
||||||
|
return getButtonHTML(null, null, null, null, null, null, Color);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "NIC";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
using FakeeDeck.Class;
|
using FakeDeck.Class;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@@ -7,7 +7,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using static System.Net.WebRequestMethods;
|
using static System.Net.WebRequestMethods;
|
||||||
|
|
||||||
namespace FakeeDeck.ButtonType
|
namespace FakeDeck.ButtonType
|
||||||
{
|
{
|
||||||
class HelldiversTwoMacro : Button
|
class HelldiversTwoMacro : Button
|
||||||
{
|
{
|
||||||
@@ -33,9 +33,11 @@ namespace FakeeDeck.ButtonType
|
|||||||
|
|
||||||
//Offensive: Orbital Strikes
|
//Offensive: Orbital Strikes
|
||||||
{ "orbital-precision-strike", new uint[] { 0x65, Key_Right, Key_Right, Key_Up}},
|
{ "orbital-precision-strike", new uint[] { 0x65, Key_Right, Key_Right, Key_Up}},
|
||||||
|
{ "orbital-380-barrage", new uint[] { 0x65, Key_Right, Key_Down, Key_Up, Key_Up, Key_Left, Key_Down, Key_Down}},
|
||||||
|
|
||||||
|
|
||||||
//Defensive
|
//Defensive
|
||||||
{ "mortar-sentry", new uint[] { 0x65, Key_Down, Key_Up, Key_Right, Key_Down}},
|
{ "mortar-sentry", new uint[] { 0x65, Key_Down, Key_Up, Key_Right, Key_Right, Key_Down }},
|
||||||
{ "gatling-sentry", new uint[] { 0x65, Key_Down, Key_Up, Key_Right, Key_Left}},
|
{ "gatling-sentry", new uint[] { 0x65, Key_Down, Key_Up, Key_Right, Key_Left}},
|
||||||
|
|
||||||
|
|
||||||
@@ -61,6 +63,7 @@ namespace FakeeDeck.ButtonType
|
|||||||
{ "autocannon", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/c/c6/AC-8_Autocannon_Icon.png"},
|
{ "autocannon", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/c/c6/AC-8_Autocannon_Icon.png"},
|
||||||
{ "grenade-launcher","https://static.wikia.nocookie.net/helldivers_gamepedia/images/6/66/GL-21_Grenade_Launcher_Icon.png"},
|
{ "grenade-launcher","https://static.wikia.nocookie.net/helldivers_gamepedia/images/6/66/GL-21_Grenade_Launcher_Icon.png"},
|
||||||
{ "orbital-precision-strike", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/4/47/Orbital_Precision_Strike_Icon.png"},
|
{ "orbital-precision-strike", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/4/47/Orbital_Precision_Strike_Icon.png"},
|
||||||
|
{ "orbital-380-barrage", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/f/f4/Orbital_380MM_HE_Barrage_Icon.png"},
|
||||||
{ "mortar-sentry", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/1/1d/A_M-12_Mortar_Sentry_Icon.png"},
|
{ "mortar-sentry", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/1/1d/A_M-12_Mortar_Sentry_Icon.png"},
|
||||||
{ "gatling-sentry","https://static.wikia.nocookie.net/helldivers_gamepedia/images/4/48/A_G-16_Gatling_Sentry_Icon.png"},
|
{ "gatling-sentry","https://static.wikia.nocookie.net/helldivers_gamepedia/images/4/48/A_G-16_Gatling_Sentry_Icon.png"},
|
||||||
|
|
||||||
@@ -76,7 +79,7 @@ namespace FakeeDeck.ButtonType
|
|||||||
|
|
||||||
public static string getButton(string Key)
|
public static string getButton(string Key)
|
||||||
{
|
{
|
||||||
return getButtonHTML(null, stratogemsIcons[Key].ToString(), Key, "button\\HelldiversTwoMacro", new Dictionary<string, string>() { { "stratogem", Key } });
|
return getButtonHTML(null, stratogemsIcons[Key].ToString(), Key, "button\\HelldiversTwoMacro", null, new Dictionary<string, string>() { { "stratogem", Key } });
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool invokeAction(string stratogem)
|
public static bool invokeAction(string stratogem)
|
||||||
|
@@ -5,10 +5,12 @@ using System.Runtime.InteropServices;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace FakeeDeck.ButtonType
|
namespace FakeDeck.ButtonType
|
||||||
{
|
{
|
||||||
internal class KeyboardMacro
|
internal class KeyboardMacro
|
||||||
{
|
{
|
||||||
|
//https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
|
||||||
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
||||||
public static extern void keybd_event(uint bVk, uint bScan, uint dwFlags, uint dwExtraInfo);
|
public static extern void keybd_event(uint bVk, uint bScan, uint dwFlags, uint dwExtraInfo);
|
||||||
|
|
||||||
|
@@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace FakeeDeck.ButtonType
|
namespace FakeDeck.ButtonType
|
||||||
{
|
{
|
||||||
internal class MediaMacro : Button
|
internal class MediaMacro : Button
|
||||||
{
|
{
|
||||||
@@ -12,17 +12,22 @@ namespace FakeeDeck.ButtonType
|
|||||||
{
|
{
|
||||||
{ "play/pause", new uint[] { 0xB3}},
|
{ "play/pause", new uint[] { 0xB3}},
|
||||||
{ "mute", new uint[] { 0xAD }},
|
{ "mute", new uint[] { 0xAD }},
|
||||||
|
{ "next", new uint[] { 0xB0 }},
|
||||||
|
{ "previous", new uint[] { 0xB1 }},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public static Dictionary<string, string> mediaIcons = new Dictionary<string, string>
|
public static Dictionary<string, string> mediaIcons = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{ "play/pause", "fa-play"},
|
{ "play/pause", "fa-play"},
|
||||||
{ "mute", "fa-volume-xmark"},
|
{ "mute", "fa-volume-xmark"},
|
||||||
|
{ "next", "fa-forward"},
|
||||||
|
{ "previous", "fa-backward"},
|
||||||
};
|
};
|
||||||
|
|
||||||
public static string getButton(string Key)
|
public static string getButton(string Key)
|
||||||
{
|
{
|
||||||
return getButtonHTML(mediaIcons[Key], null, Key, "button\\MediaMacro", new Dictionary<string, string>() { { "control_action", Key } });
|
return getButtonHTML(mediaIcons[Key], null, Key, "button\\MediaMacro", null, new Dictionary<string, string>() { { "control_action", Key } });
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool invokeAction(string control_action)
|
public static bool invokeAction(string control_action)
|
||||||
|
54
FakeDeckUI/FakeDeck/ButtonType/ProcessMacro.cs
Normal file
54
FakeDeckUI/FakeDeck/ButtonType/ProcessMacro.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using static System.Text.Json.JsonElement;
|
||||||
|
|
||||||
|
namespace FakeDeck.ButtonType
|
||||||
|
{
|
||||||
|
class ProcessMacro : Button
|
||||||
|
{
|
||||||
|
public static string getButton(string process, string arguments = "", string? icon = null, string? image = null)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> parameters = new Dictionary<string, string>() { { "process", process } };
|
||||||
|
if (!string.IsNullOrEmpty(arguments))
|
||||||
|
{
|
||||||
|
parameters.Add("arguments", arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(icon) || !string.IsNullOrEmpty(image))
|
||||||
|
{
|
||||||
|
process = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return getButtonHTML(icon, image, process, "button\\ProcessMacro", null, parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool invokeAction(string process, string arguments = "")
|
||||||
|
{
|
||||||
|
if (!File.ReadAllText("./configuration.yaml").Contains(process))
|
||||||
|
{
|
||||||
|
Debug.WriteLine("not known process");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!File.ReadAllText("./configuration.yaml").Contains(arguments))
|
||||||
|
{
|
||||||
|
Debug.WriteLine("not known arguments");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Process notePad = new Process();
|
||||||
|
notePad.StartInfo.FileName = process;
|
||||||
|
notePad.StartInfo.Arguments = arguments;
|
||||||
|
notePad.Start();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -6,13 +6,13 @@ using System.Text;
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace FakeeDeck.Class
|
namespace FakeDeck.Class
|
||||||
{
|
{
|
||||||
internal class AbstractionHelper
|
internal class AbstractionHelper
|
||||||
{
|
{
|
||||||
public static Type? resolvType(string className)
|
public static Type? resolvType(string className)
|
||||||
{
|
{
|
||||||
string cleanClass = "FakeeDeck.ButtonType." + className.Trim('/');
|
string cleanClass = "FakeDeck.ButtonType." + className.Trim('/');
|
||||||
|
|
||||||
Type? buttonClass = Type.GetType(cleanClass, true);
|
Type? buttonClass = Type.GetType(cleanClass, true);
|
||||||
|
|
||||||
@@ -25,13 +25,20 @@ namespace FakeeDeck.Class
|
|||||||
public static string getButtonVisual(JsonElement button)
|
public static string getButtonVisual(JsonElement button)
|
||||||
{
|
{
|
||||||
string calssName = button.GetProperty("function").ToString();
|
string calssName = button.GetProperty("function").ToString();
|
||||||
MethodInfo? renderMethod = AbstractionHelper.resolvType(calssName).GetMethod("getButton");
|
MethodInfo? renderMethod = resolvType(calssName).GetMethod("getButton");
|
||||||
ParameterInfo[] pars = renderMethod.GetParameters();
|
ParameterInfo[] pars = renderMethod.GetParameters();
|
||||||
List<object> parameters = new List<object>();
|
List<object> parameters = new List<object>();
|
||||||
|
|
||||||
foreach (ParameterInfo p in pars)
|
foreach (ParameterInfo p in pars)
|
||||||
{
|
{
|
||||||
JsonElement parameter = button.GetProperty("parameters").EnumerateArray().SingleOrDefault(item => item.GetProperty("name").ToString() == p.Name);
|
JsonElement parameter = button.GetProperty("parameters").EnumerateArray().SingleOrDefault(item => item.GetProperty("name").ToString() == p.Name);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(parameter.ToString()))
|
||||||
|
{
|
||||||
|
parameters.Insert(p.Position, p.DefaultValue);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
parameters.Insert(p.Position, parameter.GetProperty("value").ToString());
|
parameters.Insert(p.Position, parameter.GetProperty("value").ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ using System.Text.Json;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace FakeeDeck.Class
|
namespace FakeDeck.Class
|
||||||
{
|
{
|
||||||
public class AutoUpdateHelper
|
public class AutoUpdateHelper
|
||||||
{
|
{
|
||||||
@@ -20,7 +20,8 @@ namespace FakeeDeck.Class
|
|||||||
AutoUpdater.ParseUpdateInfoEvent += AutoUpdaterOnParseUpdateInfoEvent;
|
AutoUpdater.ParseUpdateInfoEvent += AutoUpdaterOnParseUpdateInfoEvent;
|
||||||
AutoUpdater.Synchronous = true;
|
AutoUpdater.Synchronous = true;
|
||||||
AutoUpdater.ShowRemindLaterButton = false;
|
AutoUpdater.ShowRemindLaterButton = false;
|
||||||
AutoUpdater.ReportErrors = Debugger.IsAttached;
|
AutoUpdater.ClearAppDirectory = false;
|
||||||
|
//AutoUpdater.ReportErrors = Debugger.IsAttached;
|
||||||
AutoUpdater.HttpUserAgent = ("FakeDeck-v" + Assembly.GetExecutingAssembly().GetName().Version);
|
AutoUpdater.HttpUserAgent = ("FakeDeck-v" + Assembly.GetExecutingAssembly().GetName().Version);
|
||||||
AutoUpdater.Start("https://api.github.com/repos/GamerClassN7/FakeDeck/releases/latest");
|
AutoUpdater.Start("https://api.github.com/repos/GamerClassN7/FakeDeck/releases/latest");
|
||||||
}
|
}
|
||||||
|
@@ -1,71 +1,67 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Reflection.PortableExecutable;
|
using System.Reflection.PortableExecutable;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using System.Windows;
|
||||||
|
using static System.Text.Json.JsonElement;
|
||||||
|
|
||||||
namespace FakeeDeck.Class
|
namespace FakeDeck.Class
|
||||||
{
|
{
|
||||||
internal class FakeDeckMain
|
internal class FakeDeckMain
|
||||||
{
|
{
|
||||||
|
private static string cachePath = "./cache/";
|
||||||
public static string pageHeader =
|
public static string pageHeader =
|
||||||
"<!DOCTYPE>" +
|
"<!DOCTYPE>" +
|
||||||
"<html>" +
|
"<html lang=\"en\">" +
|
||||||
" <head>" +
|
" <head>" +
|
||||||
" <title>HttpListener Example</title>" +
|
" <title>HttpListener Example</title>" +
|
||||||
|
" <meta charset=\"utf-8\">" +
|
||||||
|
" <meta name = \"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=yes\">" +
|
||||||
" <link href=\"https://yarnpkg.com/en/package/normalize.css\" rel=\"stylesheet\">" +
|
" <link href=\"https://yarnpkg.com/en/package/normalize.css\" rel=\"stylesheet\">" +
|
||||||
" <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css\" rel=\"stylesheet\">" +
|
" <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css\" rel=\"stylesheet\">" +
|
||||||
" <link href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css\" rel=\"stylesheet\">" +
|
" <link href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css\" rel=\"stylesheet\">" +
|
||||||
|
" <link href=\"StaticFiles/style.css\" rel=\"stylesheet\">" +
|
||||||
|
" <link rel=\"manifest\" href=\"StaticFiles/manifest.json\" />" +
|
||||||
" </head>" +
|
" </head>" +
|
||||||
" <body>" +
|
" <body>" +
|
||||||
" <div class=\"d-flex flex-wrap\">" +
|
" <div id=\"main\" class=\"d-flex flex-wrap\" style=\"transform-origin: left top;\">";
|
||||||
" <div class=\"m-2\">" +
|
|
||||||
" <p style=\"margin-bottom: 0px; width: 150px;height: 150px;background-color: aquamarine;\" >Page Views: {0}</p>" +
|
|
||||||
" </div>";
|
|
||||||
public static string pageFooter =
|
public static string pageFooter =
|
||||||
" <div class=\"m-2\">" +
|
|
||||||
" <button style=\"width: 150px;height: 150px;background-color: aquamarine;\" onclick=\"!document.fullscreenElement ? document.documentElement.requestFullscreen() : document.exitFullscreen();\">" +
|
|
||||||
" <i class=\"fa-solid fa-maximize\"></i>" +
|
|
||||||
" </button>" +
|
|
||||||
" </div>" +
|
|
||||||
" </div>" +
|
" </div>" +
|
||||||
" <script src=\"StaticFiles/app.js\"></script>" +
|
" <script src=\"StaticFiles/app.js\"></script>" +
|
||||||
" </body>" +
|
" </body>" +
|
||||||
"</html>";
|
"</html>";
|
||||||
public string pageData = "";
|
public string pageData = "";
|
||||||
|
private ArrayEnumerator pages;
|
||||||
public FakeDeckMain(YamlHelper yaml)
|
public FakeDeckMain(YamlHelper yaml)
|
||||||
{
|
{
|
||||||
HttpServer server = new HttpServer(yaml.getData().GetProperty("server").GetProperty("port").ToString());
|
|
||||||
|
|
||||||
foreach (JsonElement item in yaml.getData().GetProperty("pages").EnumerateArray())
|
HttpServer server = new HttpServer(yaml.getData().GetProperty("server").GetProperty("port").ToString());
|
||||||
|
pages = yaml.getData().GetProperty("pages").EnumerateArray();
|
||||||
|
|
||||||
|
//ClearCache
|
||||||
|
if (Directory.Exists(cachePath))
|
||||||
{
|
{
|
||||||
Debug.WriteLine("PAGE: " + item.GetProperty("page"));
|
DirectoryInfo di = new DirectoryInfo(cachePath);
|
||||||
foreach (JsonElement button in item.GetProperty("buttons").EnumerateArray())
|
foreach (FileInfo file in di.EnumerateFiles())
|
||||||
{
|
{
|
||||||
pageData += AbstractionHelper.getButtonVisual(button);
|
file.Delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pageData = renderPageView();
|
||||||
|
|
||||||
server.addRoute(servViewResponseAsync, "GET", "/");
|
server.addRoute(servViewResponseAsync, "GET", "/");
|
||||||
server.addRoute(servButtonResponseAsync, "POST", "/button/");
|
server.addRoute(servButtonResponseAsync, "POST", "/button/");
|
||||||
|
server.addRoute(servPageResponseAsync, "POST", "/page");
|
||||||
/*foreach (var stratogem in HelldiversTwoMacro.stratogems)
|
|
||||||
{
|
|
||||||
server.pageData += HelldiversTwoMacro.getButton(stratogem.Key);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var control in MediaMacro.mediaControls)
|
|
||||||
{
|
|
||||||
server.pageData += MediaMacro.getButton(control.Key);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
server.serv();
|
server.serv();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void callButtonAction(string module, Dictionary<string, string> postParams)
|
private static void callButtonAction(string module, Dictionary<string, string> postParams)
|
||||||
{
|
{
|
||||||
string cleanClass = "FakeeDeck.ButtonType." + module.Trim('/');
|
string cleanClass = "FakeDeck.ButtonType." + module.Trim('/');
|
||||||
|
|
||||||
Type? buttonClass = Type.GetType(cleanClass, true);
|
Type? buttonClass = Type.GetType(cleanClass, true);
|
||||||
|
|
||||||
@@ -115,9 +111,10 @@ namespace FakeeDeck.Class
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
string module = req.Url.AbsolutePath.Replace("/button", "");
|
string module = req.Url.AbsolutePath.Replace("/button", "");
|
||||||
Console.WriteLine("Call module " + module);
|
Debug.WriteLine("Call module " + module);
|
||||||
callButtonAction(module, postParams);
|
callButtonAction(module, postParams);
|
||||||
resp.StatusCode = (int)HttpStatusCode.OK;
|
resp.StatusCode = (int)HttpStatusCode.OK;
|
||||||
|
await resp.OutputStream.FlushAsync();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -129,5 +126,56 @@ namespace FakeeDeck.Class
|
|||||||
await resp.OutputStream.WriteAsync(errorData, 0, errorData.Length);
|
await resp.OutputStream.WriteAsync(errorData, 0, errorData.Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task servPageResponseAsync(HttpListenerRequest req, HttpListenerResponse resp, Dictionary<string, string> postParams)
|
||||||
|
{
|
||||||
|
string pageContent = "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pageContent = renderPageView(postParams["Key"]);
|
||||||
|
resp.StatusCode = (int)HttpStatusCode.OK;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
pageContent = ex.Message;
|
||||||
|
resp.StatusCode = (int)HttpStatusCode.InternalServerError;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] errorData = Encoding.UTF8.GetBytes(pageContent);
|
||||||
|
resp.ContentType = "text/html";
|
||||||
|
resp.ContentEncoding = Encoding.UTF8;
|
||||||
|
resp.ContentLength64 = errorData.LongLength;
|
||||||
|
await resp.OutputStream.WriteAsync(errorData, 0, errorData.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string renderPageView(string page = null)
|
||||||
|
{
|
||||||
|
JsonElement selectedPage = pages.First();
|
||||||
|
|
||||||
|
if (page != null)
|
||||||
|
selectedPage = pages.SingleOrDefault(item => item.GetProperty("page").ToString() == page);
|
||||||
|
|
||||||
|
string SelectedPageName = selectedPage.GetProperty("page").ToString();
|
||||||
|
if (File.Exists(cachePath + SelectedPageName + ".html"))
|
||||||
|
return File.ReadAllText(cachePath + SelectedPageName + ".html");
|
||||||
|
|
||||||
|
string pageContent = "";
|
||||||
|
foreach (JsonElement button in selectedPage.GetProperty("buttons").EnumerateArray())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pageContent += AbstractionHelper.getButtonVisual(button);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Directory.Exists(cachePath))
|
||||||
|
Directory.CreateDirectory(cachePath);
|
||||||
|
|
||||||
|
File.WriteAllText(cachePath + SelectedPageName + ".html", pageContent);
|
||||||
|
return pageContent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@ using System.IO;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using FakeeDeck.ButtonType;
|
using FakeDeck.ButtonType;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using static System.Net.WebRequestMethods;
|
using static System.Net.WebRequestMethods;
|
||||||
using File = System.IO.File;
|
using File = System.IO.File;
|
||||||
@@ -21,7 +21,7 @@ using System.Collections;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace FakeeDeck.Class
|
namespace FakeDeck.Class
|
||||||
{
|
{
|
||||||
internal class HttpServer
|
internal class HttpServer
|
||||||
{
|
{
|
||||||
@@ -56,6 +56,7 @@ namespace FakeeDeck.Class
|
|||||||
{".img", "application/octet-stream"},
|
{".img", "application/octet-stream"},
|
||||||
{".iso", "application/octet-stream"},
|
{".iso", "application/octet-stream"},
|
||||||
{".jar", "application/java-archive"},
|
{".jar", "application/java-archive"},
|
||||||
|
{".json", "application/json"},
|
||||||
{".jardiff", "application/x-java-archive-diff"},
|
{".jardiff", "application/x-java-archive-diff"},
|
||||||
{".jng", "image/x-jng"},
|
{".jng", "image/x-jng"},
|
||||||
{".jnlp", "application/x-java-jnlp-file"},
|
{".jnlp", "application/x-java-jnlp-file"},
|
||||||
@@ -133,13 +134,13 @@ namespace FakeeDeck.Class
|
|||||||
Debug.WriteLine(req.UserHostName);
|
Debug.WriteLine(req.UserHostName);
|
||||||
Debug.WriteLine(req.UserAgent);*/
|
Debug.WriteLine(req.UserAgent);*/
|
||||||
|
|
||||||
|
bool isMatch = false;
|
||||||
if (req.HttpMethod == "GET" && req.Url.AbsolutePath.Contains("."))
|
if (req.HttpMethod == "GET" && req.Url.AbsolutePath.Contains("."))
|
||||||
{
|
{
|
||||||
await servFileResponseAsync(req, resp);
|
await servFileResponseAsync(req, resp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool isMatch = false;
|
|
||||||
foreach (var route in routes[req.HttpMethod])
|
foreach (var route in routes[req.HttpMethod])
|
||||||
{
|
{
|
||||||
isMatch = Regex.IsMatch(req.Url.AbsolutePath, route.Key, RegexOptions.IgnoreCase);
|
isMatch = Regex.IsMatch(req.Url.AbsolutePath, route.Key, RegexOptions.IgnoreCase);
|
||||||
@@ -151,16 +152,18 @@ namespace FakeeDeck.Class
|
|||||||
{
|
{
|
||||||
Dictionary<string, string> postParams = parsePostRequestParameters(req);
|
Dictionary<string, string> postParams = parsePostRequestParameters(req);
|
||||||
gelegate.DynamicInvoke([req, resp, postParams]);
|
gelegate.DynamicInvoke([req, resp, postParams]);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
gelegate.DynamicInvoke([req, resp]);
|
gelegate.DynamicInvoke([req, resp]);
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isMatch)
|
if (!isMatch)
|
||||||
{
|
{
|
||||||
|
Debug.WriteLine("NO ROUTE MATCHED");
|
||||||
resp.StatusCode = (int)HttpStatusCode.NotFound;
|
resp.StatusCode = (int)HttpStatusCode.NotFound;
|
||||||
await resp.OutputStream.FlushAsync();
|
await resp.OutputStream.FlushAsync();
|
||||||
}
|
}
|
||||||
@@ -192,6 +195,7 @@ namespace FakeeDeck.Class
|
|||||||
if (!File.Exists(filename))
|
if (!File.Exists(filename))
|
||||||
{
|
{
|
||||||
resp.StatusCode = (int)HttpStatusCode.NotFound;
|
resp.StatusCode = (int)HttpStatusCode.NotFound;
|
||||||
|
resp.OutputStream.Flush();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,8 +216,8 @@ namespace FakeeDeck.Class
|
|||||||
while ((nbytes = input.Read(buffer, 0, buffer.Length)) > 0)
|
while ((nbytes = input.Read(buffer, 0, buffer.Length)) > 0)
|
||||||
resp.OutputStream.Write(buffer, 0, nbytes);
|
resp.OutputStream.Write(buffer, 0, nbytes);
|
||||||
input.Close();
|
input.Close();
|
||||||
resp.OutputStream.Flush();
|
|
||||||
resp.StatusCode = (int)HttpStatusCode.OK;
|
resp.StatusCode = (int)HttpStatusCode.OK;
|
||||||
|
resp.OutputStream.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace FakeeDeck.Class
|
namespace FakeDeck.Class
|
||||||
{
|
{
|
||||||
internal class KeyboardCode
|
internal class KeyboardCode
|
||||||
{
|
{
|
||||||
|
@@ -7,7 +7,7 @@ using System.Text.Json;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using YamlDotNet.Serialization;
|
using YamlDotNet.Serialization;
|
||||||
|
|
||||||
namespace FakeeDeck.Class
|
namespace FakeDeck.Class
|
||||||
{
|
{
|
||||||
public class YamlHelper
|
public class YamlHelper
|
||||||
{
|
{
|
||||||
|
@@ -19,6 +19,12 @@
|
|||||||
<None Update="StaticFiles\app.js">
|
<None Update="StaticFiles\app.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="StaticFiles\manifest.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
<None Update="StaticFiles\style.css">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@@ -5,13 +5,16 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:FakeDeck"
|
xmlns:local="clr-namespace:FakeDeck"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="MainWindow" Height="450" Width="270" Activated="FakeDeckUI_Activated" WindowStartupLocation="CenterScreen">
|
Title="MainWindow"
|
||||||
|
Activated="FakeDeckUI_Activated"
|
||||||
|
WindowStartupLocation="CenterScreen"
|
||||||
|
Width="280" Height="340">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="270*"/>
|
<RowDefinition Height="270"/>
|
||||||
<RowDefinition Height="50*"/>
|
<RowDefinition Height="50*"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Image x:Name="qr_code" Margin="10,10,10,10"/>
|
<Image x:Name="qr_code" Margin="10,10,10,0"/>
|
||||||
<TextBox Margin="10,10,10,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Grid.Row="1"/>
|
<TextBox Margin="10,10,10,10" TextWrapping="Wrap" Text="TextBox" Grid.Row="1" Height="20" VerticalAlignment="Center"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
using FakeDeck.Class;
|
using FakeDeck.Class;
|
||||||
using FakeeDeck.Class;
|
using FakeDeck.Class;
|
||||||
using QRCoder;
|
using QRCoder;
|
||||||
using System.Reflection.Emit;
|
using System.Reflection.Emit;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -17,6 +17,7 @@ using static System.Runtime.CompilerServices.RuntimeHelpers;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using Color = System.Drawing.Color;
|
using Color = System.Drawing.Color;
|
||||||
using AutoUpdaterDotNET;
|
using AutoUpdaterDotNET;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace FakeDeck
|
namespace FakeDeck
|
||||||
{
|
{
|
||||||
@@ -32,6 +33,7 @@ namespace FakeDeck
|
|||||||
|
|
||||||
private void FakeDeckUI_Activated(object sender, EventArgs e)
|
private void FakeDeckUI_Activated(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
string port = ((App)Application.Current).yaml.getData().GetProperty("server").GetProperty("port").ToString();
|
string port = ((App)Application.Current).yaml.getData().GetProperty("server").GetProperty("port").ToString();
|
||||||
string url = "http://localhost:" + port;
|
string url = "http://localhost:" + port;
|
||||||
|
|
||||||
@@ -41,7 +43,14 @@ namespace FakeDeck
|
|||||||
QRCode qrCode = new QRCode(qrCodeData);
|
QRCode qrCode = new QRCode(qrCodeData);
|
||||||
qr_code.Source = GeneralHelper.BitmapToImageSource(qrCode.GetGraphic(20, Color.Black, Color.White, false));
|
qr_code.Source = GeneralHelper.BitmapToImageSource(qrCode.GetGraphic(20, Color.Black, Color.White, false));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
AutoUpdateHelper updater = new AutoUpdateHelper();
|
AutoUpdateHelper updater = new AutoUpdateHelper();
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,7 +1,74 @@
|
|||||||
|
|
||||||
|
function urlencodeFormData(fd){
|
||||||
|
var s = '';
|
||||||
|
function encode(s){ return encodeURIComponent(s).replace(/%20/g,'+'); }
|
||||||
|
for(var pair of fd.entries()){
|
||||||
|
if(typeof pair[1]=='string'){
|
||||||
|
s += (s?'&':'') + encode(pair[0])+'='+encode(pair[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resizeGrid(){
|
||||||
|
var width = document.body.clientWidth;
|
||||||
|
var height = document.body.clientHeight;
|
||||||
|
width = window.screen.availWidth;
|
||||||
|
height = window.screen.availHeight;
|
||||||
|
|
||||||
|
|
||||||
|
var biggerSizeW = (width / 7);
|
||||||
|
var biggerSizeH = (height / 5);
|
||||||
|
|
||||||
|
var biggerSize = biggerSizeW;
|
||||||
|
if(biggerSizeW < biggerSizeH){
|
||||||
|
biggerSize = biggerSizeW;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(biggerSize);
|
||||||
|
|
||||||
|
[].forEach.call(document.querySelectorAll('.button'), function (button) {
|
||||||
|
var size = biggerSize
|
||||||
|
button.style.height = size;
|
||||||
|
button.style.width = size;
|
||||||
|
//console.log(size);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadPage(pageId){
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
var formData = new FormData();
|
||||||
|
formData.append('Key', pageId)
|
||||||
|
|
||||||
|
const xhttp = new XMLHttpRequest();
|
||||||
|
xhttp.onload = function () { }
|
||||||
|
xhttp.onreadystatechange = function () {
|
||||||
|
if (xhttp.readyState === 4) {
|
||||||
|
if (xhttp.status === 200) {
|
||||||
|
console.log('successful');
|
||||||
|
document.querySelector('div#main').innerHTML = xhttp.responseText;
|
||||||
|
console.log(xhttp.responseText);
|
||||||
|
resizeGrid();
|
||||||
|
formToAjax();
|
||||||
|
} else {
|
||||||
|
console.log('failed');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xhttp.open("POST", "/page", true);
|
||||||
|
xhttp.send(urlencodeFormData(formData));
|
||||||
|
}
|
||||||
|
|
||||||
|
function formToAjax(){
|
||||||
[].forEach.call(document.querySelectorAll('form'), function (form) {
|
[].forEach.call(document.querySelectorAll('form'), function (form) {
|
||||||
form.addEventListener('submit', function (event) {
|
form.addEventListener('submit', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const target = event.currentTarget;
|
const target = event.currentTarget;
|
||||||
|
target.style.opacity = "0.5"
|
||||||
|
|
||||||
|
navigator.vibrate(200);
|
||||||
|
|
||||||
console.log(target.method, target.action);
|
console.log(target.method, target.action);
|
||||||
console.log(form.method, form.action);
|
console.log(form.method, form.action);
|
||||||
@@ -18,6 +85,7 @@
|
|||||||
} else {
|
} else {
|
||||||
console.log('failed');
|
console.log('failed');
|
||||||
}
|
}
|
||||||
|
target.style.opacity = "1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,14 +93,16 @@
|
|||||||
xhttp.send(urlencodeFormData(formData));
|
xhttp.send(urlencodeFormData(formData));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function urlencodeFormData(fd){
|
window.addEventListener('resize', function(event) {
|
||||||
var s = '';
|
resizeGrid();
|
||||||
function encode(s){ return encodeURIComponent(s).replace(/%20/g,'+'); }
|
}, true);
|
||||||
for(var pair of fd.entries()){
|
|
||||||
if(typeof pair[1]=='string'){
|
window.addEventListener('orientationchange', function(event) {
|
||||||
s += (s?'&':'') + encode(pair[0])+'='+encode(pair[1]);
|
console.log("Rotated");
|
||||||
}
|
resizeGrid();
|
||||||
}
|
}, true);
|
||||||
return s;
|
|
||||||
}
|
resizeGrid();
|
||||||
|
formToAjax();
|
10
FakeDeckUI/FakeDeck/StaticFiles/manifest.json
Normal file
10
FakeDeckUI/FakeDeck/StaticFiles/manifest.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"name": "FakeDeck",
|
||||||
|
"short_name": "FakeDeck",
|
||||||
|
"theme_color": "#fff",
|
||||||
|
"background_color": "#fff",
|
||||||
|
"display": "fullscreen",
|
||||||
|
"orientation": "landscape",
|
||||||
|
"scope": "/",
|
||||||
|
"start_url": "/"
|
||||||
|
}
|
1
FakeDeckUI/FakeDeck/StaticFiles/style.css
Normal file
1
FakeDeckUI/FakeDeck/StaticFiles/style.css
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/*https://stackoverflow.com/questions/62371077/create-dynamic-equal-sized-small-squares-grid-in-fixed-size-big-square/
|
@@ -11,6 +11,50 @@ pages:
|
|||||||
- name: Key
|
- name: Key
|
||||||
value: "reinforce"
|
value: "reinforce"
|
||||||
|
|
||||||
|
- button: flamethrower
|
||||||
|
function: HelldiversTwoMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "flamethrower"
|
||||||
|
|
||||||
|
- button: anti-material
|
||||||
|
function: HelldiversTwoMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "anti-material"
|
||||||
|
|
||||||
|
- button: spacer
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "spacer"
|
||||||
|
- name: Color
|
||||||
|
value: red
|
||||||
|
|
||||||
|
- button: spacer
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "spacer"
|
||||||
|
- name: Color
|
||||||
|
value: red
|
||||||
|
|
||||||
|
- button: spacer
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "spacer"
|
||||||
|
- name: Color
|
||||||
|
value: red
|
||||||
|
|
||||||
|
- button: spacer
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "spacer"
|
||||||
|
- name: Color
|
||||||
|
value: red
|
||||||
|
|
||||||
- button: strafing-run
|
- button: strafing-run
|
||||||
function: HelldiversTwoMacro
|
function: HelldiversTwoMacro
|
||||||
parameters:
|
parameters:
|
||||||
@@ -53,8 +97,152 @@ pages:
|
|||||||
- name: Key
|
- name: Key
|
||||||
value: bomb
|
value: bomb
|
||||||
|
|
||||||
|
- button: full-screen
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "full-screen"
|
||||||
|
- name: Color
|
||||||
|
value: orange
|
||||||
|
|
||||||
|
- button: spacer
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "spacer"
|
||||||
|
- name: Color
|
||||||
|
value: orange
|
||||||
|
|
||||||
|
- button: spacer
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "spacer"
|
||||||
|
- name: Color
|
||||||
|
value: red
|
||||||
|
|
||||||
|
- button: spacer
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "spacer"
|
||||||
|
- name: Color
|
||||||
|
value: red
|
||||||
|
|
||||||
|
- button: spacer
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "spacer"
|
||||||
|
- name: Color
|
||||||
|
value: red
|
||||||
|
|
||||||
|
- button: orbital-380-barrage
|
||||||
|
function: HelldiversTwoMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: orbital-380-barrage
|
||||||
|
|
||||||
|
- button: page
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "set-page"
|
||||||
|
- name: PageId
|
||||||
|
value: "media"
|
||||||
|
- name: Image
|
||||||
|
value: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTdEjIsQcn8NwYWhwISL74xXLGtRHeW1Mn67g&s"
|
||||||
|
|
||||||
|
|
||||||
|
- page: media
|
||||||
|
buttons:
|
||||||
|
- button: notepad
|
||||||
|
function: ProcessMacro
|
||||||
|
parameters:
|
||||||
|
- name: process
|
||||||
|
value: "notepad.exe"
|
||||||
|
- name: image
|
||||||
|
value: "https://www.club386.com/wp-content/uploads/2021/12/notepad-icon-696x632.jpg"
|
||||||
|
|
||||||
|
- button: cmd
|
||||||
|
function: ProcessMacro
|
||||||
|
parameters:
|
||||||
|
- name: process
|
||||||
|
value: "cmd.exe"
|
||||||
|
- name: arguments
|
||||||
|
value: "/C ping google.com -t"
|
||||||
|
- name: image
|
||||||
|
value: "https://winaero.com/blog/wp-content/uploads/2019/06/WIndows-Terminal-icon.png"
|
||||||
|
|
||||||
- button: mute
|
- button: mute
|
||||||
function: MediaMacro
|
function: MediaMacro
|
||||||
parameters:
|
parameters:
|
||||||
- name: Key
|
- name: Key
|
||||||
value: "mute"
|
value: "mute"
|
||||||
|
|
||||||
|
- button: mute
|
||||||
|
function: MediaMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "previous"
|
||||||
|
|
||||||
|
- button: mute
|
||||||
|
function: MediaMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "play/pause"
|
||||||
|
|
||||||
|
- button: mute
|
||||||
|
function: MediaMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "next"
|
||||||
|
|
||||||
|
- button: spacer
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "full-screen"
|
||||||
|
- name: Color
|
||||||
|
value: orange
|
||||||
|
|
||||||
|
- button: spacer
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "spacer"
|
||||||
|
- name: Color
|
||||||
|
value: red
|
||||||
|
|
||||||
|
- button: spacer
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "spacer"
|
||||||
|
- name: Color
|
||||||
|
value: red
|
||||||
|
|
||||||
|
- button: spacer
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "spacer"
|
||||||
|
- name: Color
|
||||||
|
value: red
|
||||||
|
|
||||||
|
- button: spacer
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "spacer"
|
||||||
|
- name: Color
|
||||||
|
value: red
|
||||||
|
- button: page
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: "set-page"
|
||||||
|
- name: PageId
|
||||||
|
value: "helldivers"
|
||||||
|
- name: Image
|
||||||
|
value: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT2oyk6yqmBxt9ejwqBaordr6X9s-dZFnHrvg&s"
|
@@ -1,47 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FakeeDeck.ButtonType
|
|
||||||
{
|
|
||||||
internal class Button
|
|
||||||
{
|
|
||||||
public static string getButtonHTML(string icon, string image, string name, string action, Dictionary<string, string> parameters = null)
|
|
||||||
{
|
|
||||||
|
|
||||||
string body = "";
|
|
||||||
|
|
||||||
body += "<div class=\"m-2\">";
|
|
||||||
body += "<form style=\"margin-bottom: 0px;\" method=\"post\" action=\"" + action + "\">";
|
|
||||||
|
|
||||||
if (parameters is not null)
|
|
||||||
{
|
|
||||||
foreach (var parameter in parameters)
|
|
||||||
{
|
|
||||||
body += "<input type=\"hidden\" name=\"" + parameter.Key + "\" value=\"" + parameter.Value + "\">";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
body += "<button type=\"submit\" value=\"submit\" style=\"background-size: cover; " + (!string.IsNullOrEmpty(image) ? "background-image: url('" + image + "');" : "") + " width: 150px;height: 150px; background-color: aquamarine;\" >";
|
|
||||||
body += (!string.IsNullOrEmpty(icon) ? "<i class=\"fa-solid " + icon + "\"></i>" : name);
|
|
||||||
body += "</button>";
|
|
||||||
|
|
||||||
body += "</form>";
|
|
||||||
body += "</div>";
|
|
||||||
|
|
||||||
return body;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string getButton(string Key)
|
|
||||||
{
|
|
||||||
return getButtonHTML(null, "https://docs.itego.cz/uploads/images/system/2022-04/OdRTPJ4iTTInmhdP-jagq7dfjpi2lilfg-imageedit-2-6604933313.gif", "Test", "test/test");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool invokeAction(string Key)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,102 +0,0 @@
|
|||||||
using FakeeDeck.Class;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using static System.Net.WebRequestMethods;
|
|
||||||
|
|
||||||
namespace FakeeDeck.ButtonType
|
|
||||||
{
|
|
||||||
class HelldiversTwoMacro : Button
|
|
||||||
{
|
|
||||||
const uint Key_Up = 0x68;
|
|
||||||
const uint Key_Down = 0x62;
|
|
||||||
const uint Key_Left = 0x64;
|
|
||||||
const uint Key_Right = 0x66;
|
|
||||||
|
|
||||||
//https://helldivers.wiki.gg/wiki/Stratagems
|
|
||||||
//https://helldivers.fandom.com/wiki/Stratagems_(Helldivers_2)
|
|
||||||
|
|
||||||
public static Dictionary<string, uint[]> stratogems = new Dictionary<string, uint[]>
|
|
||||||
{
|
|
||||||
//Mission
|
|
||||||
{ "reinforce", new uint[] { 0x65, Key_Up, Key_Down, Key_Right, Key_Left, Key_Up}},
|
|
||||||
{ "resupply", new uint[] { 0x65, Key_Down, Key_Down, Key_Up, Key_Right }},
|
|
||||||
|
|
||||||
//Support Weapons
|
|
||||||
{ "anti-material", new uint[] { 0x65, Key_Down, Key_Left, Key_Right, Key_Up, Key_Down}},
|
|
||||||
{ "flamethrower", new uint[] { 0x65, Key_Down, Key_Left, Key_Up, Key_Down, Key_Up}},
|
|
||||||
{ "autocannon", new uint[] { 0x65, Key_Down, Key_Left, Key_Down, Key_Up, Key_Up, Key_Right}},
|
|
||||||
{ "grenade-launcher", new uint[] { 0x65, Key_Down, Key_Left, Key_Up, Key_Left, Key_Down}},
|
|
||||||
|
|
||||||
//Offensive: Orbital Strikes
|
|
||||||
{ "orbital-precision-strike", new uint[] { 0x65, Key_Right, Key_Right, Key_Up}},
|
|
||||||
|
|
||||||
//Defensive
|
|
||||||
{ "mortar-sentry", new uint[] { 0x65, Key_Down, Key_Up, Key_Right, Key_Down}},
|
|
||||||
{ "gatling-sentry", new uint[] { 0x65, Key_Down, Key_Up, Key_Right, Key_Left}},
|
|
||||||
|
|
||||||
|
|
||||||
//Supply: Backpacks
|
|
||||||
|
|
||||||
//Offensive: Eagle
|
|
||||||
{ "strafing-run", new uint[] { 0x65, Key_Up, Key_Right, Key_Right}},
|
|
||||||
{ "airstrike", new uint[] { 0x65, Key_Up, Key_Right, Key_Down, Key_Right}},
|
|
||||||
{ "cluster-bomb", new uint[] { 0x65, Key_Up, Key_Right, Key_Down, Key_Down, Key_Right}},
|
|
||||||
{ "napalm-airstrike", new uint[] { 0x65, Key_Up, Key_Right, Key_Down, Key_Up}},
|
|
||||||
{ "smoke-strike", new uint[] { 0x65, Key_Up, Key_Right, Key_Up, Key_Down}},
|
|
||||||
{ "rocket-pods", new uint[] { 0x65, Key_Up, Key_Right, Key_Up, Key_Left}},
|
|
||||||
{ "bomb", new uint[] { 0x65, Key_Up, Key_Right, Key_Up, Key_Right}},
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
public static Dictionary<string, string> stratogemsIcons = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{ "reinforce", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/5/5a/HD2_Reinforce.png"},
|
|
||||||
{ "resupply", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/7/72/HD2_Resupply.png"},
|
|
||||||
{ "anti-material", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/c/c3/APW-1_Anti-Materiel_Rifle_Icon.png"},
|
|
||||||
{ "flamethrower", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/c/cc/FLAM-40_Flamethrower_Icon.png"},
|
|
||||||
{ "autocannon", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/c/c6/AC-8_Autocannon_Icon.png"},
|
|
||||||
{ "grenade-launcher","https://static.wikia.nocookie.net/helldivers_gamepedia/images/6/66/GL-21_Grenade_Launcher_Icon.png"},
|
|
||||||
{ "orbital-precision-strike", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/4/47/Orbital_Precision_Strike_Icon.png"},
|
|
||||||
{ "mortar-sentry", "https://static.wikia.nocookie.net/helldivers_gamepedia/images/1/1d/A_M-12_Mortar_Sentry_Icon.png"},
|
|
||||||
{ "gatling-sentry","https://static.wikia.nocookie.net/helldivers_gamepedia/images/4/48/A_G-16_Gatling_Sentry_Icon.png"},
|
|
||||||
|
|
||||||
//Offensive: Eagle
|
|
||||||
{ "strafing-run","https://static.wikia.nocookie.net/helldivers_gamepedia/images/3/33/Eagle_Strafing_Run_Icon.png"},
|
|
||||||
{ "airstrike","https://static.wikia.nocookie.net/helldivers_gamepedia/images/7/7e/Eagle_Airstrike_Icon.png"},
|
|
||||||
{ "cluster-bomb","https://static.wikia.nocookie.net/helldivers_gamepedia/images/8/89/Eagle_Cluster_Bomb_Icon.png"},
|
|
||||||
{ "napalm-airstrike","https://static.wikia.nocookie.net/helldivers_gamepedia/images/d/d4/Eagle_Napalm_Airstrike_Icon.png"},
|
|
||||||
{ "smoke-strike","https://static.wikia.nocookie.net/helldivers_gamepedia/images/1/1a/Eagle_Smoke_Strike_Icon.png"},
|
|
||||||
{ "rocket-pods","https://static.wikia.nocookie.net/helldivers_gamepedia/images/e/e3/Eagle_110MM_Rocket_Pods_Icon.png"},
|
|
||||||
{ "bomb","https://static.wikia.nocookie.net/helldivers_gamepedia/images/5/5a/Eagle_500KG_Bomb_Icon.png"},
|
|
||||||
};
|
|
||||||
|
|
||||||
public static string getButton(string Key)
|
|
||||||
{
|
|
||||||
return getButtonHTML(null, stratogemsIcons[Key].ToString(), Key, "button\\HelldiversTwoMacro", new Dictionary<string, string>() { { "stratogem", Key } });
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool invokeAction(string stratogem)
|
|
||||||
{
|
|
||||||
foreach (var key in stratogems[stratogem])
|
|
||||||
{
|
|
||||||
KeyboardMacro.SendKey(key);
|
|
||||||
Console.WriteLine(key);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string FirstLetterToUpper(string str)
|
|
||||||
{
|
|
||||||
if (str == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (str.Length > 1)
|
|
||||||
return char.ToUpper(str[0]) + str.Substring(1);
|
|
||||||
|
|
||||||
return str.ToUpper();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,24 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FakeeDeck.ButtonType
|
|
||||||
{
|
|
||||||
internal class KeyboardMacro
|
|
||||||
{
|
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
|
|
||||||
public static extern void keybd_event(uint bVk, uint bScan, uint dwFlags, uint dwExtraInfo);
|
|
||||||
|
|
||||||
public static void SendKey(uint Key)
|
|
||||||
{
|
|
||||||
System.Threading.Thread.Sleep(60);
|
|
||||||
keybd_event(Key, 0, 0, 0);
|
|
||||||
System.Threading.Thread.Sleep(60);
|
|
||||||
keybd_event(Key, 0, 2, 0);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,35 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FakeeDeck.ButtonType
|
|
||||||
{
|
|
||||||
internal class MediaMacro : Button
|
|
||||||
{
|
|
||||||
public static Dictionary<string, uint[]> mediaControls = new Dictionary<string, uint[]>
|
|
||||||
{
|
|
||||||
{ "play/pause", new uint[] { 0xB3}},
|
|
||||||
{ "mute", new uint[] { 0xAD }},
|
|
||||||
};
|
|
||||||
|
|
||||||
public static Dictionary<string, string> mediaIcons = new Dictionary<string, string>
|
|
||||||
{
|
|
||||||
{ "play/pause", "fa-play"},
|
|
||||||
{ "mute", "fa-volume-xmark"},
|
|
||||||
};
|
|
||||||
|
|
||||||
public static string getButton(string Key)
|
|
||||||
{
|
|
||||||
return getButtonHTML(mediaIcons[Key], null, Key, "button\\MediaMacro", new Dictionary<string, string>() { { "control_action", Key } });
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool invokeAction(string control_action)
|
|
||||||
{
|
|
||||||
KeyboardMacro.SendKey(mediaControls[control_action][0]);
|
|
||||||
Console.WriteLine(control_action);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,41 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FakeeDeck.Class
|
|
||||||
{
|
|
||||||
internal class AbstractionHelper
|
|
||||||
{
|
|
||||||
public static Type? resolvType(string className)
|
|
||||||
{
|
|
||||||
string cleanClass = "FakeeDeck.ButtonType." + className.Trim('/');
|
|
||||||
|
|
||||||
Type? buttonClass = Type.GetType(cleanClass, true);
|
|
||||||
|
|
||||||
if (buttonClass is null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return buttonClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string getButtonVisual(JsonElement button)
|
|
||||||
{
|
|
||||||
string calssName = button.GetProperty("function").ToString();
|
|
||||||
MethodInfo? renderMethod = AbstractionHelper.resolvType(calssName).GetMethod("getButton");
|
|
||||||
ParameterInfo[] pars = renderMethod.GetParameters();
|
|
||||||
List<object> parameters = new List<object>();
|
|
||||||
|
|
||||||
foreach (ParameterInfo p in pars)
|
|
||||||
{
|
|
||||||
JsonElement parameter = button.GetProperty("parameters").EnumerateArray().SingleOrDefault(item => item.GetProperty("name").ToString() == p.Name);
|
|
||||||
parameters.Insert(p.Position, parameter.GetProperty("value").ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return renderMethod.Invoke(null, [.. parameters]).ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,33 +0,0 @@
|
|||||||
using AutoUpdaterDotNET;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http.Json;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FakeeDeck.Class
|
|
||||||
{
|
|
||||||
internal class AutoUpdateHelper
|
|
||||||
{
|
|
||||||
public AutoUpdateHelper() {
|
|
||||||
AutoUpdater.ParseUpdateInfoEvent += AutoUpdaterOnParseUpdateInfoEvent;
|
|
||||||
AutoUpdater.Synchronous = true;
|
|
||||||
AutoUpdater.ShowRemindLaterButton = false;
|
|
||||||
AutoUpdater.Start("https://github.com/GamerClassN7/FakeDeck/releases/latest/download/meta.xml");
|
|
||||||
}
|
|
||||||
private void AutoUpdaterOnParseUpdateInfoEvent(ParseUpdateInfoEventArgs args)
|
|
||||||
{
|
|
||||||
JsonElement json = JsonDocument.Parse(args.RemoteData).RootElement;
|
|
||||||
args.UpdateInfo = new UpdateInfoEventArgs
|
|
||||||
{
|
|
||||||
CurrentVersion = json.GetProperty("tag_name").ToString().TrimStart('v'),
|
|
||||||
DownloadURL = json.GetProperty("zipball_url").ToString(),
|
|
||||||
};
|
|
||||||
|
|
||||||
Debug.WriteLine(json.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,49 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using YamlDotNet.Serialization.NamingConventions;
|
|
||||||
using YamlDotNet.Serialization;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Reflection;
|
|
||||||
using FakeeDeck.ButtonType;
|
|
||||||
using YamlDotNet.Serialization;
|
|
||||||
|
|
||||||
namespace FakeeDeck.Class
|
|
||||||
{
|
|
||||||
internal class FakeDeck
|
|
||||||
{
|
|
||||||
public FakeDeck()
|
|
||||||
{
|
|
||||||
|
|
||||||
YamlHelper yaml = new YamlHelper();
|
|
||||||
HttpServer server = new HttpServer();
|
|
||||||
|
|
||||||
foreach (JsonElement item in yaml.getData().GetProperty("pages").EnumerateArray())
|
|
||||||
{
|
|
||||||
Debug.WriteLine("PAGE: " + item.GetProperty("page"));
|
|
||||||
foreach (JsonElement button in item.GetProperty("buttons").EnumerateArray())
|
|
||||||
{
|
|
||||||
server.pageData += AbstractionHelper.getButtonVisual(button);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*foreach (var stratogem in HelldiversTwoMacro.stratogems)
|
|
||||||
{
|
|
||||||
server.pageData += HelldiversTwoMacro.getButton(stratogem.Key);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var control in MediaMacro.mediaControls)
|
|
||||||
{
|
|
||||||
server.pageData += MediaMacro.getButton(control.Key);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
server.serv();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,316 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
using System.Net;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using FakeeDeck.ButtonType;
|
|
||||||
using System.Web;
|
|
||||||
using static System.Net.WebRequestMethods;
|
|
||||||
using File = System.IO.File;
|
|
||||||
using System.Reflection.Metadata;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Collections;
|
|
||||||
|
|
||||||
namespace FakeeDeck.Class
|
|
||||||
{
|
|
||||||
internal class HttpServer
|
|
||||||
{
|
|
||||||
private static IDictionary<string, string> mimeTypes = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase) {
|
|
||||||
{".asf", "video/x-ms-asf"},
|
|
||||||
{".asx", "video/x-ms-asf"},
|
|
||||||
{".avi", "video/x-msvideo"},
|
|
||||||
{".bin", "application/octet-stream"},
|
|
||||||
{".cco", "application/x-cocoa"},
|
|
||||||
{".crt", "application/x-x509-ca-cert"},
|
|
||||||
{".css", "text/css"},
|
|
||||||
{".deb", "application/octet-stream"},
|
|
||||||
{".der", "application/x-x509-ca-cert"},
|
|
||||||
{".dll", "application/octet-stream"},
|
|
||||||
{".dmg", "application/octet-stream"},
|
|
||||||
{".ear", "application/java-archive"},
|
|
||||||
{".eot", "application/octet-stream"},
|
|
||||||
{".exe", "application/octet-stream"},
|
|
||||||
{".flv", "video/x-flv"},
|
|
||||||
{".gif", "image/gif"},
|
|
||||||
{".hqx", "application/mac-binhex40"},
|
|
||||||
{".htc", "text/x-component"},
|
|
||||||
{".htm", "text/html"},
|
|
||||||
{".html", "text/html"},
|
|
||||||
{".ico", "image/x-icon"},
|
|
||||||
{".img", "application/octet-stream"},
|
|
||||||
{".iso", "application/octet-stream"},
|
|
||||||
{".jar", "application/java-archive"},
|
|
||||||
{".jardiff", "application/x-java-archive-diff"},
|
|
||||||
{".jng", "image/x-jng"},
|
|
||||||
{".jnlp", "application/x-java-jnlp-file"},
|
|
||||||
{".jpeg", "image/jpeg"},
|
|
||||||
{".jpg", "image/jpeg"},
|
|
||||||
{".js", "application/x-javascript"},
|
|
||||||
{".mml", "text/mathml"},
|
|
||||||
{".mng", "video/x-mng"},
|
|
||||||
{".mov", "video/quicktime"},
|
|
||||||
{".mp3", "audio/mpeg"},
|
|
||||||
{".mpeg", "video/mpeg"},
|
|
||||||
{".mpg", "video/mpeg"},
|
|
||||||
{".msi", "application/octet-stream"},
|
|
||||||
{".msm", "application/octet-stream"},
|
|
||||||
{".msp", "application/octet-stream"},
|
|
||||||
{".pdb", "application/x-pilot"},
|
|
||||||
{".pdf", "application/pdf"},
|
|
||||||
{".pem", "application/x-x509-ca-cert"},
|
|
||||||
{".pl", "application/x-perl"},
|
|
||||||
{".pm", "application/x-perl"},
|
|
||||||
{".png", "image/png"},
|
|
||||||
{".prc", "application/x-pilot"},
|
|
||||||
{".ra", "audio/x-realaudio"},
|
|
||||||
{".rar", "application/x-rar-compressed"},
|
|
||||||
{".rpm", "application/x-redhat-package-manager"},
|
|
||||||
{".rss", "text/xml"},
|
|
||||||
{".run", "application/x-makeself"},
|
|
||||||
{".sea", "application/x-sea"},
|
|
||||||
{".shtml", "text/html"},
|
|
||||||
{".sit", "application/x-stuffit"},
|
|
||||||
{".swf", "application/x-shockwave-flash"},
|
|
||||||
{".tcl", "application/x-tcl"},
|
|
||||||
{".tk", "application/x-tcl"},
|
|
||||||
{".txt", "text/plain"},
|
|
||||||
{".war", "application/java-archive"},
|
|
||||||
{".wbmp", "image/vnd.wap.wbmp"},
|
|
||||||
{".wmv", "video/x-ms-wmv"},
|
|
||||||
{".xml", "text/xml"},
|
|
||||||
{".xpi", "application/x-xpinstall"},
|
|
||||||
{".zip", "application/zip"},
|
|
||||||
};
|
|
||||||
|
|
||||||
public static HttpListener listener;
|
|
||||||
public static string url = "http://*:8000/";
|
|
||||||
public static int pageViews = 0;
|
|
||||||
public static int requestCount = 0;
|
|
||||||
public static string pageHeader =
|
|
||||||
"<!DOCTYPE>" +
|
|
||||||
"<html>" +
|
|
||||||
" <head>" +
|
|
||||||
" <title>HttpListener Example</title>" +
|
|
||||||
" <link href=\"https://yarnpkg.com/en/package/normalize.css\" rel=\"stylesheet\">" +
|
|
||||||
" <link href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css\" rel=\"stylesheet\">" +
|
|
||||||
" <link href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css\" rel=\"stylesheet\">" +
|
|
||||||
" </head>" +
|
|
||||||
" <body>" +
|
|
||||||
" <div class=\"d-flex flex-wrap\">" +
|
|
||||||
" <div class=\"m-2\">" +
|
|
||||||
" <p style=\"margin-bottom: 0px; width: 150px;height: 150px;background-color: aquamarine;\" >Page Views: {0}</p>" +
|
|
||||||
" </div>";
|
|
||||||
public static string pageFooter =
|
|
||||||
" <div class=\"m-2\">" +
|
|
||||||
" <button style=\"width: 150px;height: 150px;background-color: aquamarine;\" onclick=\"!document.fullscreenElement ? document.documentElement.requestFullscreen() : document.exitFullscreen();\">" +
|
|
||||||
" <i class=\"fa-solid fa-maximize\"></i>" +
|
|
||||||
" </button>" +
|
|
||||||
" </div>" +
|
|
||||||
" </div>" +
|
|
||||||
" <script src=\"StaticFiles/app.js\"></script>" +
|
|
||||||
" </body>" +
|
|
||||||
"</html>";
|
|
||||||
public string pageData = "";
|
|
||||||
private Dictionary<string, Dictionary<string, Action>> routes;
|
|
||||||
public async Task HandleIncomingConnections()
|
|
||||||
{
|
|
||||||
bool runServer = true;
|
|
||||||
|
|
||||||
// While a user hasn't visited the `shutdown` url, keep on handling requests
|
|
||||||
while (runServer)
|
|
||||||
{
|
|
||||||
// Will wait here until we hear from a connection
|
|
||||||
HttpListenerContext ctx = await listener.GetContextAsync();
|
|
||||||
|
|
||||||
// Peel out the requests and response objects
|
|
||||||
HttpListenerRequest req = ctx.Request;
|
|
||||||
HttpListenerResponse resp = ctx.Response;
|
|
||||||
|
|
||||||
// Print out some info about the request
|
|
||||||
Console.WriteLine("Request #: {0}", ++requestCount);
|
|
||||||
Console.WriteLine(req.Url.ToString());
|
|
||||||
Console.WriteLine(req.HttpMethod);
|
|
||||||
Console.WriteLine(req.UserHostName);
|
|
||||||
Console.WriteLine(req.UserAgent);
|
|
||||||
Console.WriteLine();
|
|
||||||
|
|
||||||
if (req.HttpMethod == "POST")
|
|
||||||
{
|
|
||||||
//Parse Port Parameters
|
|
||||||
Dictionary<string, string> postParams = parsePostRequestParameters(req);
|
|
||||||
// If `shutdown` url requested w/ POST, then shutdown the server after serving the page
|
|
||||||
if (req.Url.AbsolutePath == "/shutdown")
|
|
||||||
{
|
|
||||||
Console.WriteLine("Shutdown requested");
|
|
||||||
runServer = false;
|
|
||||||
}
|
|
||||||
else if (req.Url.AbsolutePath.StartsWith("/button"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string module = req.Url.AbsolutePath.Replace("/button", "");
|
|
||||||
Console.WriteLine("Call module " + module);
|
|
||||||
callButtonAction(module, postParams);
|
|
||||||
resp.StatusCode = (int)HttpStatusCode.OK;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
byte[] errorData = Encoding.UTF8.GetBytes(ex.Message);
|
|
||||||
resp.ContentType = "text/html";
|
|
||||||
resp.ContentEncoding = Encoding.UTF8;
|
|
||||||
resp.ContentLength64 = errorData.LongLength;
|
|
||||||
resp.StatusCode = (int)HttpStatusCode.InternalServerError;
|
|
||||||
await resp.OutputStream.WriteAsync(errorData, 0, errorData.Length);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
resp.Close();
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (req.HttpMethod == "GET")
|
|
||||||
{
|
|
||||||
if (req.Url.AbsolutePath.Contains("."))
|
|
||||||
{
|
|
||||||
await servFileResponseAsync(req, resp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
await servViewResponseAsync(req, resp);
|
|
||||||
}
|
|
||||||
resp.Close();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void serv()
|
|
||||||
{
|
|
||||||
// Create a Http server and start listening for incoming connections
|
|
||||||
listener = new HttpListener();
|
|
||||||
listener.Prefixes.Add(url);
|
|
||||||
listener.Start();
|
|
||||||
Console.WriteLine("Listening for connections on {0}", url);
|
|
||||||
|
|
||||||
// Handle requests
|
|
||||||
Task listenTask = HandleIncomingConnections();
|
|
||||||
listenTask.GetAwaiter().GetResult();
|
|
||||||
|
|
||||||
// Close the listener
|
|
||||||
listener.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void callButtonAction(string module, Dictionary<string, string> postParams)
|
|
||||||
{
|
|
||||||
string cleanClass = "FakeeDeck.ButtonType." + module.Trim('/');
|
|
||||||
|
|
||||||
Type? buttonClass = Type.GetType(cleanClass, true);
|
|
||||||
|
|
||||||
if (buttonClass is null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
MethodInfo? method = buttonClass.GetMethod("invokeAction");
|
|
||||||
|
|
||||||
if (method is null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ParameterInfo[] pars = method.GetParameters();
|
|
||||||
List<object> parameters = new List<object>();
|
|
||||||
|
|
||||||
foreach (ParameterInfo p in pars)
|
|
||||||
{
|
|
||||||
if (p == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p.Name != null && postParams.ContainsKey(p.Name))
|
|
||||||
{
|
|
||||||
parameters.Insert(p.Position, postParams[p.Name]);
|
|
||||||
}
|
|
||||||
else if (p.IsOptional && p.DefaultValue != null)
|
|
||||||
{
|
|
||||||
parameters.Insert(p.Position, p.DefaultValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = method.Invoke(null, [.. parameters]).ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static async Task servFileResponseAsync(HttpListenerRequest req, HttpListenerResponse resp)
|
|
||||||
{
|
|
||||||
string filename = Path.Combine("./", req.Url.AbsolutePath.Substring(1));
|
|
||||||
if (!File.Exists(filename))
|
|
||||||
{
|
|
||||||
resp.StatusCode = (int)HttpStatusCode.NotFound;
|
|
||||||
resp.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Stream input = new FileStream(filename, FileMode.Open);
|
|
||||||
|
|
||||||
string mime;
|
|
||||||
resp.ContentType = mimeTypes.TryGetValue(Path.GetExtension(filename), out mime)
|
|
||||||
? mime
|
|
||||||
: "application/octet-stream";
|
|
||||||
resp.ContentLength64 = input.Length;
|
|
||||||
resp.AddHeader("Date", DateTime.Now.ToString("r"));
|
|
||||||
resp.AddHeader("Last-Modified", File.GetLastWriteTime(filename).ToString("r"));
|
|
||||||
|
|
||||||
byte[] buffer = new byte[1024 * 32];
|
|
||||||
int nbytes;
|
|
||||||
while ((nbytes = input.Read(buffer, 0, buffer.Length)) > 0)
|
|
||||||
resp.OutputStream.Write(buffer, 0, nbytes);
|
|
||||||
input.Close();
|
|
||||||
resp.OutputStream.Flush();
|
|
||||||
resp.StatusCode = (int)HttpStatusCode.OK;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
byte[] errorData = Encoding.UTF8.GetBytes(ex.Message);
|
|
||||||
resp.ContentType = "text/html";
|
|
||||||
resp.ContentEncoding = Encoding.UTF8;
|
|
||||||
resp.ContentLength64 = errorData.LongLength;
|
|
||||||
resp.StatusCode = (int)HttpStatusCode.InternalServerError;
|
|
||||||
await resp.OutputStream.WriteAsync(errorData, 0, errorData.Length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task servViewResponseAsync(HttpListenerRequest req, HttpListenerResponse resp)
|
|
||||||
{
|
|
||||||
string disableSubmit = false ? "disabled" : "";
|
|
||||||
byte[] data = Encoding.UTF8.GetBytes(string.Format(pageHeader + this.pageData + pageFooter, pageViews, disableSubmit));
|
|
||||||
resp.ContentType = "text/html";
|
|
||||||
resp.ContentEncoding = Encoding.UTF8;
|
|
||||||
resp.ContentLength64 = data.LongLength;
|
|
||||||
await resp.OutputStream.WriteAsync(data, 0, data.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Dictionary<string, string> parsePostRequestParameters(HttpListenerRequest req)
|
|
||||||
{
|
|
||||||
Dictionary<string, string> postParams = new Dictionary<string, string>();
|
|
||||||
|
|
||||||
using (var reader = new StreamReader(req.InputStream, req.ContentEncoding))
|
|
||||||
{
|
|
||||||
string postData = reader.ReadToEnd();
|
|
||||||
var parsedData = HttpUtility.ParseQueryString(postData);
|
|
||||||
foreach (string key in parsedData)
|
|
||||||
{
|
|
||||||
postParams[key] = parsedData[key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return postParams;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,201 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace FakeeDeck.Class
|
|
||||||
{
|
|
||||||
internal class KeyboardCode
|
|
||||||
{
|
|
||||||
public const uint LBUTTON = 0x01; // Left mouse button
|
|
||||||
public const uint RBUTTON = 0x02; // Right mouse button
|
|
||||||
public const uint CANCEL = 0x03; // Control-break processing
|
|
||||||
public const uint MBUTTON = 0x04; // Middle mouse button (three-button mouse)
|
|
||||||
public const uint XBUTTON1 = 0x05; // X1 mouse button
|
|
||||||
public const uint XBUTTON2 = 0x06; // X2 mouse button
|
|
||||||
public const uint BACK = 0x08; // BACKSPACE key
|
|
||||||
public const uint TAB = 0x09; // TAB key
|
|
||||||
public const uint CLEAR = 0x0C; // CLEAR key
|
|
||||||
public const uint RETURN = 0x0D; // ENTER key
|
|
||||||
public const uint SHIFT = 0x10; // SHIFT key
|
|
||||||
public const uint CONTROL = 0x11; // CTRL key
|
|
||||||
public const uint MENU = 0x12; // ALT key
|
|
||||||
public const uint PAUSE = 0x13; // PAUSE key
|
|
||||||
public const uint CAPITAL = 0x14; // CAPS LOCK key
|
|
||||||
public const uint KANA = 0x15; // IME Kana mode
|
|
||||||
public const uint HANGUL = 0x15; // IME Hangul mode
|
|
||||||
public const uint JUNJA = 0x17; // IME Junja mode
|
|
||||||
public const uint FINAL = 0x18; // IME final mode
|
|
||||||
public const uint HANJA = 0x19; // IME Hanja mode
|
|
||||||
public const uint KANJI = 0x19; // IME Kanji mode
|
|
||||||
public const uint ESCAPE = 0x1B; // ESC key
|
|
||||||
public const uint CONVERT = 0x1C; // IME convert
|
|
||||||
public const uint NONCONVERT = 0x1D; // IME nonconvert
|
|
||||||
public const uint ACCEPT = 0x1E; // IME accept
|
|
||||||
public const uint MODECHANGE = 0x1F; // IME mode change request
|
|
||||||
public const uint SPACE = 0x20; // SPACEBAR
|
|
||||||
public const uint PRIOR = 0x21; // PAGE UP key
|
|
||||||
public const uint NEXT = 0x22; // PAGE DOWN key
|
|
||||||
public const uint END = 0x23; // END key
|
|
||||||
public const uint HOME = 0x24; // HOME key
|
|
||||||
public const uint LEFT = 0x25; // LEFT ARROW key
|
|
||||||
public const uint UP = 0x26; // UP ARROW key
|
|
||||||
public const uint RIGHT = 0x27; // RIGHT ARROW key
|
|
||||||
public const uint DOWN = 0x28; // DOWN ARROW key
|
|
||||||
public const uint SELECT = 0x29; // SELECT key
|
|
||||||
public const uint PRINT = 0x2A; // PRINT key
|
|
||||||
public const uint EXECUTE = 0x2B; // EXECUTE key
|
|
||||||
public const uint SNAPSHOT = 0x2C; // PRINT SCREEN key
|
|
||||||
public const uint INSERT = 0x2D; // INS key
|
|
||||||
public const uint DELETE = 0x2E; // DEL key
|
|
||||||
public const uint HELP = 0x2F; // HELP key
|
|
||||||
public const uint N0 = 0x30; // '0' key
|
|
||||||
public const uint N1 = 0x31; // '1' key
|
|
||||||
public const uint N2 = 0x32; // '2' key
|
|
||||||
public const uint N3 = 0x33; // '3' key
|
|
||||||
public const uint N4 = 0x34; // '4' key
|
|
||||||
public const uint N5 = 0x35; // '5' key
|
|
||||||
public const uint N6 = 0x36; // '6' key
|
|
||||||
public const uint N7 = 0x37; // '7' key
|
|
||||||
public const uint N8 = 0x38; // '8' key
|
|
||||||
public const uint N9 = 0x39; // '9' key
|
|
||||||
public const uint A = 0x41; // 'A' key
|
|
||||||
public const uint B = 0x42; // 'B' key
|
|
||||||
public const uint C = 0x43; // 'C' key
|
|
||||||
public const uint D = 0x44; // 'D' key
|
|
||||||
public const uint E = 0x45; // 'E' key
|
|
||||||
public const uint F = 0x46; // 'F' key
|
|
||||||
public const uint G = 0x47; // 'G' key
|
|
||||||
public const uint H = 0x48; // 'H' key
|
|
||||||
public const uint I = 0x49; // 'I' key
|
|
||||||
public const uint J = 0x4A; // 'J' key
|
|
||||||
public const uint K = 0x4B; // 'K' key
|
|
||||||
public const uint L = 0x4C; // 'L' key
|
|
||||||
public const uint M = 0x4D; // 'M' key
|
|
||||||
public const uint N = 0x4E; // 'N' key
|
|
||||||
public const uint O = 0x4F; // 'O' key
|
|
||||||
public const uint P = 0x50; // 'P' key
|
|
||||||
public const uint Q = 0x51; // 'Q' key
|
|
||||||
public const uint R = 0x52; // 'R' key
|
|
||||||
public const uint S = 0x53; // 'S' key
|
|
||||||
public const uint T = 0x54; // 'T' key
|
|
||||||
public const uint U = 0x55; // 'U' key
|
|
||||||
public const uint V = 0x56; // 'V' key
|
|
||||||
public const uint W = 0x57; // 'W' key
|
|
||||||
public const uint X = 0x58; // 'X' key
|
|
||||||
public const uint Y = 0x59; // 'Y' key
|
|
||||||
public const uint Z = 0x5A; // 'Z' key
|
|
||||||
public const uint LWIN = 0x5B; // Left Windows key (Natural keyboard)
|
|
||||||
public const uint RWIN = 0x5C; // Right Windows key (Natural keyboard)
|
|
||||||
public const uint APPS = 0x5D; // Applications key (Natural keyboard)
|
|
||||||
public const uint SLEEP = 0x5F; // Computer Sleep key
|
|
||||||
public const uint NUMPAD0 = 0x60; // Numeric keypad '0' key
|
|
||||||
public const uint NUMPAD1 = 0x61; // Numeric keypad '1' key
|
|
||||||
public const uint NUMPAD2 = 0x62; // Numeric keypad '2' key
|
|
||||||
public const uint NUMPAD3 = 0x63; // Numeric keypad '3' key
|
|
||||||
public const uint NUMPAD4 = 0x64; // Numeric keypad '4' key
|
|
||||||
public const uint NUMPAD5 = 0x65; // Numeric keypad '5' key
|
|
||||||
public const uint NUMPAD6 = 0x66; // Numeric keypad '6' key
|
|
||||||
public const uint NUMPAD7 = 0x67; // Numeric keypad '7' key
|
|
||||||
public const uint NUMPAD8 = 0x68; // Numeric keypad '8' key
|
|
||||||
public const uint NUMPAD9 = 0x69; // Numeric keypad '9' key
|
|
||||||
public const uint MULTIPLY = 0x6A; // Multiply key
|
|
||||||
public const uint ADD = 0x6B; // Add key
|
|
||||||
public const uint SEPARATOR = 0x6C; // Separator key
|
|
||||||
public const uint SUBTRACT = 0x6D; // Subtract key
|
|
||||||
public const uint DECIMAL = 0x6E; // Decimal key
|
|
||||||
public const uint DIVIDE = 0x6F; // Divide key
|
|
||||||
public const uint F1 = 0x70; // F1 key
|
|
||||||
public const uint F2 = 0x71; // F2 key
|
|
||||||
public const uint F3 = 0x72; // F3 key
|
|
||||||
public const uint F4 = 0x73; // F4 key
|
|
||||||
public const uint F5 = 0x74; // F5 key
|
|
||||||
public const uint F6 = 0x75; // F6 key
|
|
||||||
public const uint F7 = 0x76; // F7 key
|
|
||||||
public const uint F8 = 0x77; // F8 key
|
|
||||||
public const uint F9 = 0x78; // F9 key
|
|
||||||
public const uint F10 = 0x79; // F10 key
|
|
||||||
public const uint F11 = 0x7A; // F11 key
|
|
||||||
public const uint F12 = 0x7B; // F12 key
|
|
||||||
public const uint F13 = 0x7C; // F13 key
|
|
||||||
public const uint F14 = 0x7D; // F14 key
|
|
||||||
public const uint F15 = 0x7E; // F15 key
|
|
||||||
public const uint F16 = 0x7F; // F16 key
|
|
||||||
public const uint F17 = 0x80; // F17 key
|
|
||||||
public const uint F18 = 0x81; // F18 key
|
|
||||||
public const uint F19 = 0x82; // F19 key
|
|
||||||
public const uint F20 = 0x83; // F20 key
|
|
||||||
public const uint F21 = 0x84; // F21 key
|
|
||||||
public const uint F22 = 0x85; // F22 key
|
|
||||||
public const uint F23 = 0x86; // F23 key
|
|
||||||
public const uint F24 = 0x87; // F24 key
|
|
||||||
public const uint NUMLOCK = 0x90; // NUM LOCK key
|
|
||||||
public const uint SCROLL = 0x91; // SCROLL LOCK key
|
|
||||||
public const uint LSHIFT = 0xA0; // Left SHIFT key
|
|
||||||
public const uint RSHIFT = 0xA1; // Right SHIFT key
|
|
||||||
public const uint LCONTROL = 0xA2; // Left CONTROL key
|
|
||||||
public const uint RCONTROL = 0xA3; // Right CONTROL key
|
|
||||||
public const uint LMENU = 0xA4; // Left MENU key
|
|
||||||
public const uint RMENU = 0xA5; // Right MENU key
|
|
||||||
public const uint BROWSER_BACK = 0xA6; // Browser Back key
|
|
||||||
public const uint BROWSER_FORWARD = 0xA7; // Browser Forward key
|
|
||||||
public const uint BROWSER_REFRESH = 0xA8; // Browser Refresh key
|
|
||||||
public const uint BROWSER_STOP = 0xA9; // Browser Stop key
|
|
||||||
public const uint BROWSER_SEARCH = 0xAA; // Browser Search key
|
|
||||||
public const uint BROWSER_FAVORITES = 0xAB; // Browser Favorites key
|
|
||||||
public const uint BROWSER_HOME = 0xAC; // Browser Start and Home key
|
|
||||||
public const uint VOLUME_MUTE = 0xAD; // Volume Mute key
|
|
||||||
public const uint VOLUME_DOWN = 0xAE; // Volume Down key
|
|
||||||
public const uint VOLUME_UP = 0xAF; // Volume Up key
|
|
||||||
public const uint MEDIA_NEXT_TRACK = 0xB0; // Next Track key
|
|
||||||
public const uint MEDIA_PREV_TRACK = 0xB1; // Previous Track key
|
|
||||||
public const uint MEDIA_STOP = 0xB2; // Stop Media key
|
|
||||||
public const uint MEDIA_PLAY_PAUSE = 0xB3; // Play/Pause Media key
|
|
||||||
public const uint LAUNCH_MAIL = 0xB4; // Start Mail key
|
|
||||||
public const uint LAUNCH_MEDIA_SELECT = 0xB5; // Select Media key
|
|
||||||
public const uint LAUNCH_APP1 = 0xB6; // Start Application 1 key
|
|
||||||
public const uint LAUNCH_APP2 = 0xB7; // Start Application 2 key
|
|
||||||
public const uint OEM_1 = 0xBA; // For the US standard keyboard, the ';:' key
|
|
||||||
public const uint OEM_PLUS = 0xBB; // For any country/region, the '+' key
|
|
||||||
public const uint OEM_COMMA = 0xBC; // For any country/region, the ',' key
|
|
||||||
public const uint OEM_MINUS = 0xBD; // For any country/region, the '-' key
|
|
||||||
public const uint OEM_PERIOD = 0xBE; // For any country/region, the '.' key
|
|
||||||
public const uint OEM_2 = 0xBF; // For the US standard keyboard, the '/?' key
|
|
||||||
public const uint OEM_3 = 0xC0; // For the US standard keyboard, the '`~' key
|
|
||||||
public const uint OEM_4 = 0xDB; // For the US standard keyboard, the '[{' key
|
|
||||||
public const uint OEM_5 = 0xDC; // For the US standard keyboard, the '\|' key
|
|
||||||
public const uint OEM_6 = 0xDD; // For the US standard keyboard, the ']}' key
|
|
||||||
public const uint OEM_7 = 0xDE; // For the US standard keyboard, the 'single-quote/double-quote' key
|
|
||||||
public const uint OEM_8 = 0xDF; // Used for miscellaneous characters; it can vary by keyboard.
|
|
||||||
public const uint OEM_AX = 0xE1; // OEM specific
|
|
||||||
public const uint OEM_102 = 0xE2; // The angle bracket key or the backslash key on the RT 102-key keyboard
|
|
||||||
public const uint ICO_HELP = 0xE3; // Help key on ICO
|
|
||||||
public const uint ICO_00 = 0xE4; // 00 key on ICO
|
|
||||||
public const uint PROCESSKEY = 0xE5; // IME PROCESS key
|
|
||||||
public const uint ICO_CLEAR = 0xE6; // Clear key on ICO
|
|
||||||
public const uint PACKET = 0xE7; // Used to pass Unicode characters as if they were keystrokes.
|
|
||||||
public const uint OEM_RESET = 0xE9; // OEM specific
|
|
||||||
public const uint OEM_JUMP = 0xEA; // OEM specific
|
|
||||||
public const uint OEM_PA1 = 0xEB; // OEM specific
|
|
||||||
public const uint OEM_PA2 = 0xEC; // OEM specific
|
|
||||||
public const uint OEM_PA3 = 0xED; // OEM specific
|
|
||||||
public const uint OEM_WSCTRL = 0xEE; // OEM specific
|
|
||||||
public const uint OEM_CUSEL = 0xEF; // OEM specific
|
|
||||||
public const uint OEM_ATTN = 0xF0; // OEM specific
|
|
||||||
public const uint OEM_FINISH = 0xF1; // OEM specific
|
|
||||||
public const uint OEM_COPY = 0xF2; // OEM specific
|
|
||||||
public const uint OEM_AUTO = 0xF3; // OEM specific
|
|
||||||
public const uint OEM_ENLW = 0xF4; // OEM specific
|
|
||||||
public const uint OEM_BACKTAB = 0xF5; // OEM specific
|
|
||||||
public const uint ATTN = 0xF6; // Attn key
|
|
||||||
public const uint CRSEL = 0xF7; // CrSel key
|
|
||||||
public const uint EXSEL = 0xF8; // ExSel key
|
|
||||||
public const uint EREOF = 0xF9; // Erase EOF key
|
|
||||||
public const uint PLAY = 0xFA; // Play key
|
|
||||||
public const uint ZOOM = 0xFB; // Zoom key
|
|
||||||
public const uint NONAME = 0xFC; // Reserved
|
|
||||||
public const uint PA1 = 0xFD; // PA1 key
|
|
||||||
public const uint OEM_CLEAR = 0xFE; // Clear key
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,28 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using YamlDotNet.Serialization;
|
|
||||||
|
|
||||||
namespace FakeeDeck.Class
|
|
||||||
{
|
|
||||||
internal class YamlHelper
|
|
||||||
{
|
|
||||||
JsonDocument jsonObjecz;
|
|
||||||
public YamlHelper()
|
|
||||||
{
|
|
||||||
var r = new StreamReader("./configuration.yaml");
|
|
||||||
var deserializer = new Deserializer();
|
|
||||||
object yamlObject = deserializer.Deserialize(r);
|
|
||||||
string json = System.Text.Json.JsonSerializer.Serialize(yamlObject);
|
|
||||||
jsonObjecz = JsonDocument.Parse(json);
|
|
||||||
}
|
|
||||||
|
|
||||||
public JsonElement getData()
|
|
||||||
{
|
|
||||||
return jsonObjecz.RootElement;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,28 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>net8.0-windows</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="StaticFiles\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Autoupdater.NET.Official" Version="1.9.2" />
|
|
||||||
<PackageReference Include="YamlDotNet" Version="16.1.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="configuration.yaml">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="StaticFiles\app.js">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@@ -1,9 +0,0 @@
|
|||||||
using FakeeDeck;
|
|
||||||
using FakeeDeck.Class;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Text.Json;
|
|
||||||
using AutoUpdaterDotNET;
|
|
||||||
|
|
||||||
|
|
||||||
AutoUpdateHelper updater = new AutoUpdateHelper();
|
|
||||||
FakeDeck fakeDeck = new FakeDeck();
|
|
@@ -1,38 +0,0 @@
|
|||||||
[].forEach.call(document.querySelectorAll('form'), function (form) {
|
|
||||||
form.addEventListener('submit', function (event) {
|
|
||||||
event.preventDefault();
|
|
||||||
const target = event.currentTarget;
|
|
||||||
|
|
||||||
console.log(target.method, target.action);
|
|
||||||
console.log(form.method, form.action);
|
|
||||||
console.log(form === target);
|
|
||||||
|
|
||||||
var formData = new FormData(form);
|
|
||||||
|
|
||||||
const xhttp = new XMLHttpRequest();
|
|
||||||
xhttp.onload = function () { }
|
|
||||||
xhttp.onreadystatechange = function () {
|
|
||||||
if (xhttp.readyState === 4) {
|
|
||||||
if (xhttp.status === 200) {
|
|
||||||
console.log('successful');
|
|
||||||
} else {
|
|
||||||
console.log('failed');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
xhttp.open(target.method, target.action, true);
|
|
||||||
xhttp.send(urlencodeFormData(formData));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function urlencodeFormData(fd){
|
|
||||||
var s = '';
|
|
||||||
function encode(s){ return encodeURIComponent(s).replace(/%20/g,'+'); }
|
|
||||||
for(var pair of fd.entries()){
|
|
||||||
if(typeof pair[1]=='string'){
|
|
||||||
s += (s?'&':'') + encode(pair[0])+'='+encode(pair[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
|
@@ -1,60 +0,0 @@
|
|||||||
|
|
||||||
server:
|
|
||||||
port: 8000
|
|
||||||
|
|
||||||
pages:
|
|
||||||
- page: helldivers
|
|
||||||
buttons:
|
|
||||||
- button: reinforce
|
|
||||||
function: HelldiversTwoMacro
|
|
||||||
parameters:
|
|
||||||
- name: Key
|
|
||||||
value: "reinforce"
|
|
||||||
|
|
||||||
- button: strafing-run
|
|
||||||
function: HelldiversTwoMacro
|
|
||||||
parameters:
|
|
||||||
- name: Key
|
|
||||||
value: strafing-run
|
|
||||||
|
|
||||||
- button: airstrike
|
|
||||||
function: HelldiversTwoMacro
|
|
||||||
parameters:
|
|
||||||
- name: Key
|
|
||||||
value: airstrike
|
|
||||||
|
|
||||||
- button: cluster-bomb
|
|
||||||
function: HelldiversTwoMacro
|
|
||||||
parameters:
|
|
||||||
- name: Key
|
|
||||||
value: cluster-bomb
|
|
||||||
|
|
||||||
- button: napalm-airstrike
|
|
||||||
function: HelldiversTwoMacro
|
|
||||||
parameters:
|
|
||||||
- name: Key
|
|
||||||
value: napalm-airstrike
|
|
||||||
|
|
||||||
- button: smoke-strike
|
|
||||||
function: HelldiversTwoMacro
|
|
||||||
parameters:
|
|
||||||
- name: Key
|
|
||||||
value: smoke-strike
|
|
||||||
|
|
||||||
- button: rocket-pods
|
|
||||||
function: HelldiversTwoMacro
|
|
||||||
parameters:
|
|
||||||
- name: Key
|
|
||||||
value: rocket-pods
|
|
||||||
|
|
||||||
- button: bomb
|
|
||||||
function: HelldiversTwoMacro
|
|
||||||
parameters:
|
|
||||||
- name: Key
|
|
||||||
value: bomb
|
|
||||||
|
|
||||||
- button: mute
|
|
||||||
function: MediaMacro
|
|
||||||
parameters:
|
|
||||||
- name: Key
|
|
||||||
value: "mute"
|
|
150
README.md
150
README.md
@@ -1,5 +1,153 @@
|
|||||||
## FakeDeck - Poor Man Macro Pad
|
<div align="center">
|
||||||
|
<img style="border-radius:10px" src="images/logo.png" title="Logo"><br>
|
||||||
|
<img src="https://img.shields.io/github/downloads/GamerClassN7/FakeDeck/total.svg" alt="Github All Releases">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
# FakeDeck - Poor Man Macro Pad
|
||||||
|
|
||||||
Creates simple webserver with buttons whitch can be opened on any device an can be used as macro pad/keyboard
|
Creates simple webserver with buttons whitch can be opened on any device an can be used as macro pad/keyboard
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## How to use it ?
|
||||||
|
|
||||||
|
Just add desired macros to `configuration.yaml` and start the application, tahn zou can load dashboard on any web capable device inside of your network.
|
||||||
|
|
||||||
|
## Example Macros:
|
||||||
|
### Helldivers 2 Macros
|
||||||
|
```yaml
|
||||||
|
- button: reinforce
|
||||||
|
function: HelldiversTwoMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: reinforce
|
||||||
|
```
|
||||||
|
```yaml
|
||||||
|
- button: strafing-run
|
||||||
|
function: HelldiversTwoMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: strafing-run
|
||||||
|
```
|
||||||
|
```yaml
|
||||||
|
- button: airstrike
|
||||||
|
function: HelldiversTwoMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: airstrike
|
||||||
|
```
|
||||||
|
```yaml
|
||||||
|
- button: cluster-bomb
|
||||||
|
function: HelldiversTwoMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: cluster-bomb
|
||||||
|
```
|
||||||
|
```yaml
|
||||||
|
- button: napalm-airstrike
|
||||||
|
function: HelldiversTwoMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: napalm-airstrike
|
||||||
|
```
|
||||||
|
```yaml
|
||||||
|
- button: smoke-strike
|
||||||
|
function: HelldiversTwoMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: smoke-strike
|
||||||
|
```
|
||||||
|
```yaml
|
||||||
|
- button: rocket-pods
|
||||||
|
function: HelldiversTwoMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: rocket-pods
|
||||||
|
```
|
||||||
|
```yaml
|
||||||
|
- button: bomb
|
||||||
|
function: HelldiversTwoMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: bomb
|
||||||
|
```
|
||||||
|
### Media Control Macros
|
||||||
|
```yaml
|
||||||
|
- button: mute
|
||||||
|
function: MediaMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: mute
|
||||||
|
```
|
||||||
|
```yaml
|
||||||
|
- button: previous
|
||||||
|
function: MediaMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: previous
|
||||||
|
```
|
||||||
|
```yaml
|
||||||
|
- button: play
|
||||||
|
function: MediaMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: play/pause
|
||||||
|
```
|
||||||
|
```yaml
|
||||||
|
- button: next
|
||||||
|
function: MediaMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: next
|
||||||
|
```
|
||||||
|
### FakeDeck UI Control Macros
|
||||||
|
```yaml
|
||||||
|
- button: full-screen
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: full-screen
|
||||||
|
```
|
||||||
|
```yaml
|
||||||
|
- button: set-page
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: set-page
|
||||||
|
- name: PageId
|
||||||
|
value: {{page-id}}
|
||||||
|
```
|
||||||
|
```yaml
|
||||||
|
- button: spacer
|
||||||
|
function: FakeDeckMacro
|
||||||
|
parameters:
|
||||||
|
- name: Key
|
||||||
|
value: spacer
|
||||||
|
```
|
||||||
|
### Process Macro
|
||||||
|
```yaml
|
||||||
|
- button: cmd
|
||||||
|
function: ProcessMacro
|
||||||
|
parameters:
|
||||||
|
- name: process
|
||||||
|
value: "cmd.exe"
|
||||||
|
- name: arguments #Optional Proces Arguments
|
||||||
|
value: "/C ipconfig"
|
||||||
|
```
|
||||||
|
### Comon Macro Parameters
|
||||||
|
```yaml
|
||||||
|
...
|
||||||
|
parameters:
|
||||||
|
- name: Color
|
||||||
|
value: White #CSS friendly color
|
||||||
|
- name: Image
|
||||||
|
value: White #URL To Image (Local Path is not supported now)
|
||||||
|
...
|
||||||
|
```
|
||||||
|
## Contributors
|
||||||
|
<a href="https://github.com/GamerClassN7/FakeDeck/graphs/contributors">
|
||||||
|
<img src="https://contrib.rocks/image?repo=GamerClassN7/FakeDeck" />
|
||||||
|
</a>
|
||||||
|
|
||||||
|
## Star History
|
||||||
|
[](https://star-history.com/#GamerClassN7/FakeDeck&Timeline)]
|
BIN
images/logo.png
Normal file
BIN
images/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.6 KiB |
Reference in New Issue
Block a user