#
# Copyright (C) 1993-1996 Id Software, Inc.
# Copyright (C) 2019-2020 Nobuaki Tanaka
# Copyright (C) 2024 Devin Shwagginz
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#

module Doocr
  enum DoomKey
    def get_char
      case self
      when DoomKey::A
        return 'a'
      when DoomKey::B
        return 'b'
      when DoomKey::C
        return 'c'
      when DoomKey::D
        return 'd'
      when DoomKey::E
        return 'e'
      when DoomKey::F
        return 'f'
      when DoomKey::G
        return 'g'
      when DoomKey::H
        return 'h'
      when DoomKey::I
        return 'i'
      when DoomKey::J
        return 'j'
      when DoomKey::K
        return 'k'
      when DoomKey::L
        return 'l'
      when DoomKey::M
        return 'm'
      when DoomKey::N
        return 'n'
      when DoomKey::O
        return 'o'
      when DoomKey::P
        return 'p'
      when DoomKey::Q
        return 'q'
      when DoomKey::R
        return 'r'
      when DoomKey::S
        return 's'
      when DoomKey::T
        return 't'
      when DoomKey::U
        return 'u'
      when DoomKey::V
        return 'v'
      when DoomKey::W
        return 'w'
      when DoomKey::X
        return 'x'
      when DoomKey::Y
        return 'y'
      when DoomKey::Z
        return 'z'
      when DoomKey::Num0
        return '0'
      when DoomKey::Num1
        return '1'
      when DoomKey::Num2
        return '2'
      when DoomKey::Num3
        return '3'
      when DoomKey::Num4
        return '4'
      when DoomKey::Num5
        return '5'
      when DoomKey::Num6
        return '6'
      when DoomKey::Num7
        return '7'
      when DoomKey::Num8
        return '8'
      when DoomKey::Num9
        return '9'
      when DoomKey::LBracket
        return '['
      when DoomKey::RBracket
        return ']'
      when DoomKey::Semicolon
        return ';'
      when DoomKey::Comma
        return ','
      when DoomKey::Period
        return '.'
      when DoomKey::Quote
        return '"'
      when DoomKey::Slash
        return '/'
      when DoomKey::Backslash
        return '\\'
      when DoomKey::Equal
        return '='
      when DoomKey::Hyphen
        return '-'
      when DoomKey::Space
        return ' '
      when DoomKey::Add
        return '+'
      when DoomKey::Subtract
        return '-'
      when DoomKey::Multiply
        return '*'
      when DoomKey::Divide
        return '/'
      when DoomKey::Numpad0
        return '0'
      when DoomKey::Numpad1
        return '1'
      when DoomKey::Numpad2
        return '2'
      when DoomKey::Numpad3
        return '3'
      when DoomKey::Numpad4
        return '4'
      when DoomKey::Numpad5
        return '5'
      when DoomKey::Numpad6
        return '6'
      when DoomKey::Numpad7
        return '7'
      when DoomKey::Numpad8
        return '8'
      when DoomKey::Numpad9
        return '9'
      else
        return '\0'
      end
    end

    def to_s
      case self
      when DoomKey::A
        return "a"
      when DoomKey::B
        return "b"
      when DoomKey::C
        return "c"
      when DoomKey::D
        return "d"
      when DoomKey::E
        return "e"
      when DoomKey::F
        return "f"
      when DoomKey::G
        return "g"
      when DoomKey::H
        return "h"
      when DoomKey::I
        return "i"
      when DoomKey::J
        return "j"
      when DoomKey::K
        return "k"
      when DoomKey::L
        return "l"
      when DoomKey::M
        return "m"
      when DoomKey::N
        return "n"
      when DoomKey::O
        return "o"
      when DoomKey::P
        return "p"
      when DoomKey::Q
        return "q"
      when DoomKey::R
        return "r"
      when DoomKey::S
        return "s"
      when DoomKey::T
        return "t"
      when DoomKey::U
        return "u"
      when DoomKey::V
        return "v"
      when DoomKey::W
        return "w"
      when DoomKey::X
        return "x"
      when DoomKey::Y
        return "y"
      when DoomKey::Z
        return "z"
      when DoomKey::Num0
        return "num0"
      when DoomKey::Num1
        return "num1"
      when DoomKey::Num2
        return "num2"
      when DoomKey::Num3
        return "num3"
      when DoomKey::Num4
        return "num4"
      when DoomKey::Num5
        return "num5"
      when DoomKey::Num6
        return "num6"
      when DoomKey::Num7
        return "num7"
      when DoomKey::Num8
        return "num8"
      when DoomKey::Num9
        return "num9"
      when DoomKey::Escape
        return "escape"
      when DoomKey::LControl
        return "lcontrol"
      when DoomKey::LShift
        return "lshift"
      when DoomKey::LAlt
        return "lalt"
      when DoomKey::LSystem
        return "lsystem"
      when DoomKey::RControl
        return "rcontrol"
      when DoomKey::RShift
        return "rshift"
      when DoomKey::RAlt
        return "ralt"
      when DoomKey::RSystem
        return "rsystem"
      when DoomKey::Menu
        return "menu"
      when DoomKey::LBracket
        return "lbracket"
      when DoomKey::RBracket
        return "rbracket"
      when DoomKey::Semicolon
        return "semicolon"
      when DoomKey::Comma
        return "comma"
      when DoomKey::Period
        return "period"
      when DoomKey::Quote
        return "quote"
      when DoomKey::Slash
        return "slash"
      when DoomKey::Backslash
        return "backslash"
      when DoomKey::Tilde
        return "tilde"
      when DoomKey::Equal
        return "equal"
      when DoomKey::Hyphen
        return "hyphen"
      when DoomKey::Space
        return "space"
      when DoomKey::Enter
        return "enter"
      when DoomKey::Backspace
        return "backspace"
      when DoomKey::Tab
        return "tab"
      when DoomKey::PageUp
        return "pageup"
      when DoomKey::PageDown
        return "pagedown"
      when DoomKey::End
        return "end"
      when DoomKey::Home
        return "home"
      when DoomKey::Insert
        return "insert"
      when DoomKey::Delete
        return "delete"
      when DoomKey::Add
        return "add"
      when DoomKey::Subtract
        return "subtract"
      when DoomKey::Multiply
        return "multiply"
      when DoomKey::Divide
        return "divide"
      when DoomKey::Left
        return "left"
      when DoomKey::Right
        return "right"
      when DoomKey::Up
        return "up"
      when DoomKey::Down
        return "down"
      when DoomKey::Numpad0
        return "numpad0"
      when DoomKey::Numpad1
        return "numpad1"
      when DoomKey::Numpad2
        return "numpad2"
      when DoomKey::Numpad3
        return "numpad3"
      when DoomKey::Numpad4
        return "numpad4"
      when DoomKey::Numpad5
        return "numpad5"
      when DoomKey::Numpad6
        return "numpad6"
      when DoomKey::Numpad7
        return "numpad7"
      when DoomKey::Numpad8
        return "numpad8"
      when DoomKey::Numpad9
        return "numpad9"
      when DoomKey::F1
        return "f1"
      when DoomKey::F2
        return "f2"
      when DoomKey::F3
        return "f3"
      when DoomKey::F4
        return "f4"
      when DoomKey::F5
        return "f5"
      when DoomKey::F6
        return "f6"
      when DoomKey::F7
        return "f7"
      when DoomKey::F8
        return "f8"
      when DoomKey::F9
        return "f9"
      when DoomKey::F10
        return "f10"
      when DoomKey::F11
        return "f11"
      when DoomKey::F12
        return "f12"
      when DoomKey::F13
        return "f13"
      when DoomKey::F14
        return "f14"
      when DoomKey::F15
        return "f15"
      when DoomKey::Pause
        return "pause"
      else
        return "unknown"
      end
    end

    def self.parse(value : String)
      case value
      when "a"
        return DoomKey::A
      when "b"
        return DoomKey::B
      when "c"
        return DoomKey::C
      when "d"
        return DoomKey::D
      when "e"
        return DoomKey::E
      when "f"
        return DoomKey::F
      when "g"
        return DoomKey::G
      when "h"
        return DoomKey::H
      when "i"
        return DoomKey::I
      when "j"
        return DoomKey::J
      when "k"
        return DoomKey::K
      when "l"
        return DoomKey::L
      when "m"
        return DoomKey::M
      when "n"
        return DoomKey::N
      when "o"
        return DoomKey::O
      when "p"
        return DoomKey::P
      when "q"
        return DoomKey::Q
      when "r"
        return DoomKey::R
      when "s"
        return DoomKey::S
      when "t"
        return DoomKey::T
      when "u"
        return DoomKey::U
      when "v"
        return DoomKey::V
      when "w"
        return DoomKey::W
      when "x"
        return DoomKey::X
      when "y"
        return DoomKey::Y
      when "z"
        return DoomKey::Z
      when "num0"
        return DoomKey::Num0
      when "num1"
        return DoomKey::Num1
      when "num2"
        return DoomKey::Num2
      when "num3"
        return DoomKey::Num3
      when "num4"
        return DoomKey::Num4
      when "num5"
        return DoomKey::Num5
      when "num6"
        return DoomKey::Num6
      when "num7"
        return DoomKey::Num7
      when "num8"
        return DoomKey::Num8
      when "num9"
        return DoomKey::Num9
      when "escape"
        return DoomKey::Escape
      when "lcontrol"
        return DoomKey::LControl
      when "lshift"
        return DoomKey::LShift
      when "lalt"
        return DoomKey::LAlt
      when "lsystem"
        return DoomKey::LSystem
      when "rcontrol"
        return DoomKey::RControl
      when "rshift"
        return DoomKey::RShift
      when "ralt"
        return DoomKey::RAlt
      when "rsystem"
        return DoomKey::RSystem
      when "menu"
        return DoomKey::Menu
      when "lbracket"
        return DoomKey::LBracket
      when "rbracket"
        return DoomKey::RBracket
      when "semicolon"
        return DoomKey::Semicolon
      when "comma"
        return DoomKey::Comma
      when "period"
        return DoomKey::Period
      when "quote"
        return DoomKey::Quote
      when "slash"
        return DoomKey::Slash
      when "backslash"
        return DoomKey::Backslash
      when "tilde"
        return DoomKey::Tilde
      when "equal"
        return DoomKey::Equal
      when "hyphen"
        return DoomKey::Hyphen
      when "space"
        return DoomKey::Space
      when "enter"
        return DoomKey::Enter
      when "backspace"
        return DoomKey::Backspace
      when "tab"
        return DoomKey::Tab
      when "pageup"
        return DoomKey::PageUp
      when "pagedown"
        return DoomKey::PageDown
      when "end"
        return DoomKey::End
      when "home"
        return DoomKey::Home
      when "insert"
        return DoomKey::Insert
      when "delete"
        return DoomKey::Delete
      when "add"
        return DoomKey::Add
      when "subtract"
        return DoomKey::Subtract
      when "multiply"
        return DoomKey::Multiply
      when "divide"
        return DoomKey::Divide
      when "left"
        return DoomKey::Left
      when "right"
        return DoomKey::Right
      when "up"
        return DoomKey::Up
      when "down"
        return DoomKey::Down
      when "numpad0"
        return DoomKey::Numpad0
      when "numpad1"
        return DoomKey::Numpad1
      when "numpad2"
        return DoomKey::Numpad2
      when "numpad3"
        return DoomKey::Numpad3
      when "numpad4"
        return DoomKey::Numpad4
      when "numpad5"
        return DoomKey::Numpad5
      when "numpad6"
        return DoomKey::Numpad6
      when "numpad7"
        return DoomKey::Numpad7
      when "numpad8"
        return DoomKey::Numpad8
      when "numpad9"
        return DoomKey::Numpad9
      when "f1"
        return DoomKey::F1
      when "f2"
        return DoomKey::F2
      when "f3"
        return DoomKey::F3
      when "f4"
        return DoomKey::F4
      when "f5"
        return DoomKey::F5
      when "f6"
        return DoomKey::F6
      when "f7"
        return DoomKey::F7
      when "f8"
        return DoomKey::F8
      when "f9"
        return DoomKey::F9
      when "f10"
        return DoomKey::F10
      when "f11"
        return DoomKey::F11
      when "f12"
        return DoomKey::F12
      when "f13"
        return DoomKey::F13
      when "f14"
        return DoomKey::F14
      when "f15"
        return DoomKey::F15
      when "pause"
        return DoomKey::Pause
      else
        return DoomKey::Unknown
      end
    end
  end
end
