From 577865c69eaa8716ad6feb93d6b484284696c7e1 Mon Sep 17 00:00:00 2001
From: June Tate-Gans <june@theonelab.com>
Date: Tue, 27 Apr 2021 18:04:51 -0500
Subject: [PATCH] g13gui: Make stick regions and stick modes enums

This simplifies quite a bit, and reduces coding errors by using symbols instead
of "stringified" types.
---
 g13gui/g13gui/bindings.py | 45 ++++++++++++++++++++++++++++-----------
 1 file changed, 33 insertions(+), 12 deletions(-)

diff --git a/g13gui/g13gui/bindings.py b/g13gui/g13gui/bindings.py
index ca11c52..48b538f 100644
--- a/g13gui/g13gui/bindings.py
+++ b/g13gui/g13gui/bindings.py
@@ -1,5 +1,8 @@
 #!/usr/bin/python3
 
+import enum
+
+
 G13D_TO_GDK_KEYBINDS = {
     '0': '0',
     '1': '1',
@@ -178,23 +181,41 @@ DEFAULT_KEY_BINDINGS = {
     'DOWN': ['M'],
 }
 
+
+class StickRegion(enum.Enum):
+    UP = 'STICK_UP'
+    DOWN = 'STICK_DOWN'
+    LEFT = 'STICK_LEFT'
+    RIGHT = 'STICK_RIGHT'
+
+
+ALL_STICK_REGIONS = frozenset({
+    StickRegion.UP,
+    StickRegion.DOWN,
+    StickRegion.LEFT,
+    StickRegion.RIGHT
+})
+
+
 DEFAULT_STICK_REGION_BINDINGS = {
-    'STICK_UP': ['W'],
-    'STICK_DOWN': ['S'],
-    'STICK_LEFT': ['A'],
-    'STICK_RIGHT': ['D']
+    StickRegion.UP: ['W'],
+    StickRegion.DOWN: ['S'],
+    StickRegion.LEFT: ['A'],
+    StickRegion.RIGHT: ['D']
 }
 
-STICK_MODES = [
-    'ABSOLUTE',
-    'RELATIVE',
-    'KEYS'
-]
+
+class StickMode(enum.Enum):
+    ABSOLUTE = 'ABSOLUTE'
+    RELATIVE = 'RELATIVE'
+    KEYS = 'KEYS'
 
 
-def GetStickModeNum(modeName):
-    return STICK_MODES.index(modeName.upper())
-
+ALL_STICK_MODES = frozenset({
+    StickMode.ABSOLUTE,
+    StickMode.RELATIVE,
+    StickMode.KEYS
+})
 
 def G13DKeyIsModifier(key):
     key = key.upper()