diff --git a/src/Input/Input.bf b/src/Input/Input.bf index ca84905..9784437 100644 --- a/src/Input/Input.bf +++ b/src/Input/Input.bf @@ -45,9 +45,11 @@ namespace Strawberry } } - static public bool Ctrl => KeyCheck(.LCtrl) || KeyCheck(.RCtrl); - static public bool Alt => KeyCheck(.LAlt) || KeyCheck(.RAlt); - static public bool Shift => KeyCheck(.LShift) || KeyCheck(.RShift); + static public bool Ctrl => SDL.GetModState() & .CTRL > 0; + static public bool Alt => SDL.GetModState() & .ALT > 0; + static public bool Shift => SDL.GetModState() & .SHIFT > 0; + static public bool CapsLock => SDL.GetModState() & .Caps > 0; + static public bool NumLock => SDL.GetModState() & .Num > 0; static public bool KeyCheck(SDL.Scancode key) { diff --git a/src/Static/Console.bf b/src/Static/Console.bf index b338c86..cff3946 100644 --- a/src/Static/Console.bf +++ b/src/Static/Console.bf @@ -55,20 +55,90 @@ namespace Strawberry { if (key >= .A && key <= .Z) { - char8 c = 'a' + (int)(key - .A); + char8 c; + if (Input.Shift || Input.CapsLock) + c = 'A' + (int)(key - .A); + else + c = 'a' + (int)(key - .A); + entry.Append(c); + } + else if (key >= .Key1 && key <= .Key9 && !Input.Shift) + { + char8 c = '1' + (int)(key - .Key1); entry.Append(c); } else { switch (key) { + case .Key1 when Input.Shift: + entry.Append('!'); + case .Key2 when Input.Shift: + entry.Append('@'); + case .Key3 when Input.Shift: + entry.Append('#'); + case .Key4 when Input.Shift: + entry.Append('$'); + case .Key5 when Input.Shift: + entry.Append('%'); + case .Key6 when Input.Shift: + entry.Append('^'); + case .Key7 when Input.Shift: + entry.Append('&'); + case .Key8 when Input.Shift: + entry.Append('*'); + case .Key9 when Input.Shift: + entry.Append('('); + case .Key0 when Input.Shift: + entry.Append(')'); + case .Key0: + entry.Append('0'); case .Space: entry.Append(' '); + case .Minus when Input.Shift: + entry.Append('_'); + case .Minus: + entry.Append('-'); + case .Equals when Input.Shift: + entry.Append('+'); + case .Equals: + entry.Append('='); + case .LeftBracket when Input.Shift: + entry.Append('{'); + case .LeftBracket: + entry.Append('['); + case .RightBracket when Input.Shift: + entry.Append('}'); + case .RightBracket: + entry.Append(']'); + case .BackSlash when Input.Shift: + entry.Append('|'); + case .BackSlash: + entry.Append('\\'); + case .Semicolon when Input.Shift: + entry.Append(':'); + case .Semicolon: + entry.Append(';'); + case .Apostrophe when Input.Shift: + entry.Append('"'); + case .Apostrophe: + entry.Append('\''); + case .Comma when Input.Shift: + entry.Append('<'); + case .Comma: + entry.Append(','); + case .Period when Input.Shift: + entry.Append('>'); + case .Period: + entry.Append('.'); + case .Slash when Input.Shift: + entry.Append('?'); + case .Slash: + entry.Append('/'); case .BackSpace: if (entry.Length > 0) entry.RemoveFromEnd(1); - case .Delete: entry.Clear();