@@ -35,11 +35,11 @@ public void Tick()
/// Whether the key pressed event should be passed to the next piece of
/// software down the chain.
/// </returns>
public bool KeyPressed(keyboardNames key)
public bool KeyPressed(KeyboardNames key)
{
if (this.active)
{
if (key == keyboardNames.ESC)
if (key == KeyboardNames.ESC)
{
this.game.Dispose();
this.game = null;
@@ -49,7 +49,7 @@ public bool KeyPressed(keyboardNames key)
this.game.KeyPress(key);
return false;
}
if (key == keyboardNames.ESC)
if (key == KeyboardNames.ESC)
{
this.game = new T();
this.active = true;
@@ -15,7 +15,7 @@ namespace teethris.NET.SDK
{
public interface IGame : IDisposable
{
void KeyPress(keyboardNames key);
void KeyPress(KeyboardNames key);
void Tick();
}
}

Large diffs are not rendered by default.

@@ -14,7 +14,7 @@

namespace LedCSharp
{
public enum keyboardNames
public enum KeyboardNames
{
ESC = 0x01,
F1 = 0x3b,
@@ -188,15 +188,15 @@ public class LogitechGSDK
int greenPercentage, int bluePercentage);

[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSetLightingForKeyWithKeyName(keyboardNames keyCode, int redPercentage,
public static extern bool LogiLedSetLightingForKeyWithKeyName(KeyboardNames keyCode, int redPercentage,
int greenPercentage, int bluePercentage);

public static bool SetLighting(keyboardNames keyCode, int redPercentage, int greenPercentage, int bluePercentage)
public static bool SetLighting(KeyboardNames keyCode, int redPercentage, int greenPercentage, int bluePercentage)
{
return LogiLedSetLightingForKeyWithKeyName(keyCode, redPercentage, greenPercentage, bluePercentage);
}

public static bool SetLighting(keyboardNames keyCode, PlayerColor color, int percentage)
public static bool SetLighting(KeyboardNames keyCode, PlayerColor color, int percentage)
{
switch (color)
{
@@ -210,22 +210,22 @@ public static bool SetLighting(keyboardNames keyCode, PlayerColor color, int per
}

[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedSaveLightingForKey(keyboardNames keyName);
public static extern bool LogiLedSaveLightingForKey(KeyboardNames keyName);

[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedRestoreLightingForKey(keyboardNames keyName);
public static extern bool LogiLedRestoreLightingForKey(KeyboardNames keyName);

[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedFlashSingleKey(keyboardNames keyName, int redPercentage, int greenPercentage,
public static extern bool LogiLedFlashSingleKey(KeyboardNames keyName, int redPercentage, int greenPercentage,
int bluePercentage, int msDuration, int msInterval);

[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedPulseSingleKey(keyboardNames keyName, int startRedPercentage,
public static extern bool LogiLedPulseSingleKey(KeyboardNames keyName, int startRedPercentage,
int startGreenPercentage, int startBluePercentage, int finishRedPercentage, int finishGreenPercentage,
int finishBluePercentage, int msDuration, bool isInfinite);

[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiLedStopEffectsOnKey(keyboardNames keyName);
public static extern bool LogiLedStopEffectsOnKey(KeyboardNames keyName);

[DllImport("LogitechLedEnginesWrapper ", CallingConvention = CallingConvention.Cdecl)]
public static extern void LogiLedShutdown();
@@ -11,32 +11,36 @@
using System.Collections.Generic;
using System.Linq;
using LedCSharp;
using teethris.NET.SDK;
using static LedCSharp.LogitechGSDK;

namespace teethris.NET
{
public class Snake
{
private readonly List<keyboardNames> keys = new List<keyboardNames>();
private readonly List<KeyboardNames> keys = new List<KeyboardNames>();
private readonly PlayerColor color;

public Snake(keyboardNames key, PlayerColor color)
public Snake(KeyboardNames key, PlayerColor color)
{
this.color = color;
this.keys.Add(key);

SetLighting(key, color, 100);
}

public keyboardNames Head => this.keys.Last();
public KeyboardNames Head => this.keys.Last();

public void AddIfNeighbour(keyboardNames key)
public bool AddIfNeighbour(KeyboardNames key)
{
if (this.keys.Contains(key) || !KeyboardLayout.Instance[this.Head].Contains(key)) return false;

SetLighting(this.Head, this.color, 30);

this.keys.Add(key);

SetLighting(this.Head, this.color, 100);
return true;
}
}
}