private void processKey(KeyboardEventArgs k, bool skipMapCheck) { if (!skipMapCheck) { JoystickFunction jf = checkMap(1, k.Key); if (jf != JoystickFunction.None) { processJoy(1, jf, k.Down); return; } jf = checkMap(2, k.Key); if (jf != JoystickFunction.None) { processJoy(2, jf, k.Down); return; } } if (C64.network.IsClient) { sendNetKey(k); } else { C64Key key = KeyboardMatrix.GetC64Key(k); if (key.KeyValue > 0) { if (k.Down) { keyboardMatrix[key.KeyColumn] &= (byte)(~key.KeyValue); if (key.Shift == ShiftStatus.Enable) { keyboardMatrix[1] &= 0x7F; } else if (key.Shift == ShiftStatus.Disable) { keyboardMatrix[1] |= 0x80; keyboardMatrix[6] |= 0x10; } } else { keyboardMatrix[key.KeyColumn] |= key.KeyValue; if (key.Shift == ShiftStatus.Enable) { keyboardMatrix[1] |= 0x80; } } } } }
public static C64Key GetC64Key(KeyboardEventArgs k) { C64Key key = new C64Key(); key.KeyColumn = 0; key.KeyValue = 0; key.Shift = (shiftPressed(k) ? ShiftStatus.Enable : ShiftStatus.Disable); switch (k.Key) { case Key.Insert: key.KeyColumn = 0; key.KeyValue = 0x01; key.Shift = ShiftStatus.Enable; break; case Key.Delete: case Key.Backspace: key.KeyColumn = 0; key.KeyValue = 0x01; key.Shift = ShiftStatus.Disable; break; case Key.Return: key.KeyColumn = 0; key.KeyValue = 0x02; key.Shift = ShiftStatus.None; break; case Key.LeftArrow: key.KeyColumn = 0; key.KeyValue = 0x04; key.Shift = ShiftStatus.Enable; break; case Key.RightArrow: key.KeyColumn = 0; key.KeyValue = 0x04; key.Shift = ShiftStatus.Disable; break; case Key.F7: key.KeyColumn = 0; key.KeyValue = 0x08; key.Shift = ShiftStatus.Disable; break; case Key.F8: key.KeyColumn = 0; key.KeyValue = 0x08; key.Shift = ShiftStatus.Enable; break; case Key.F1: key.KeyColumn = 0; key.KeyValue = 0x10; key.Shift = ShiftStatus.Disable; break; case Key.F2: key.KeyColumn = 0; key.KeyValue = 0x10; key.Shift = ShiftStatus.Enable; break; case Key.F3: key.KeyColumn = 0; key.KeyValue = 0x20; key.Shift = ShiftStatus.Disable; break; case Key.F4: key.KeyColumn = 0; key.KeyValue = 0x20; key.Shift = ShiftStatus.Enable; break; case Key.F5: key.KeyColumn = 0; key.KeyValue = 0x40; key.Shift = ShiftStatus.Disable; break; case Key.F6: key.KeyColumn = 0; key.KeyValue = 0x40; key.Shift = ShiftStatus.Enable; break; case Key.UpArrow: key.KeyColumn = 0; key.KeyValue = 0x80; key.Shift = ShiftStatus.Enable; break; case Key.DownArrow: key.KeyColumn = 0; key.KeyValue = 0x80; key.Shift = ShiftStatus.Disable; break; case Key.Three: key.KeyColumn = 1; key.KeyValue = 0x01; break; case Key.W: key.KeyColumn = 1; key.KeyValue = 0x02; break; case Key.A: key.KeyColumn = 1; key.KeyValue = 0x04; break; case Key.Four: key.KeyColumn = 1; key.KeyValue = 0x08; break; case Key.Z: key.KeyColumn = 1; key.KeyValue = 0x10; break; case Key.S: key.KeyColumn = 1; key.KeyValue = 0x20; break; case Key.E: key.KeyColumn = 1; key.KeyValue = 0x40; break; case Key.LeftShift: key.KeyColumn = 1; key.KeyValue = 0x80; key.Shift = ShiftStatus.None; break; case Key.Five: key.KeyColumn = 2; key.KeyValue = 0x01; break; case Key.R: key.KeyColumn = 2; key.KeyValue = 0x02; break; case Key.D: key.KeyColumn = 2; key.KeyValue = 0x04; break; case Key.Six: key.KeyColumn = (shiftPressed(k) ? 0 : 2); key.KeyValue = (byte)(shiftPressed(k) ? 0 : 0x08); key.Shift = (shiftPressed(k) ? ShiftStatus.None : ShiftStatus.Disable); break; case Key.C: key.KeyColumn = 2; key.KeyValue = 0x10; break; case Key.F: key.KeyColumn = 2; key.KeyValue = 0x20; break; case Key.T: key.KeyColumn = 2; key.KeyValue = 0x40; break; case Key.X: key.KeyColumn = 2; key.KeyValue = 0x80; break; case Key.Seven: key.KeyColumn = (shiftPressed(k) ? 2 : 3); key.KeyValue = (byte)(shiftPressed(k) ? 0x08 : 0x01); break; case Key.Y: key.KeyColumn = 3; key.KeyValue = 0x02; break; case Key.G: key.KeyColumn = 3; key.KeyValue = 0x04; break; case Key.Eight: key.KeyColumn = (shiftPressed(k) ? 6 : 3); key.KeyValue = (byte)(shiftPressed(k) ? 0x02 : 0x08); key.Shift = ShiftStatus.Disable; break; case Key.B: key.KeyColumn = 3; key.KeyValue = 0x10; break; case Key.H: key.KeyColumn = 3; key.KeyValue = 0x20; break; case Key.U: key.KeyColumn = 3; key.KeyValue = 0x40; break; case Key.V: key.KeyColumn = 3; key.KeyValue = 0x80; break; case Key.Nine: key.KeyColumn = (shiftPressed(k) ? 3 : 4); key.KeyValue = (byte)(shiftPressed(k) ? 0x08 : 0x01); break; case Key.I: key.KeyColumn = 4; key.KeyValue = 0x02; break; case Key.J: key.KeyColumn = 4; key.KeyValue = 0x04; break; case Key.Zero: key.KeyColumn = (shiftPressed(k) ? 4 : 4); key.KeyValue = (byte)(shiftPressed(k) ? 0x01 : 0x08); break; case Key.M: key.KeyColumn = 4; key.KeyValue = 0x10; break; case Key.K: key.KeyColumn = 4; key.KeyValue = 0x20; break; case Key.O: key.KeyColumn = 4; key.KeyValue = 0x40; break; case Key.N: key.KeyColumn = 4; key.KeyValue = 0x80; break; case Key.Equals: key.KeyColumn = (shiftPressed(k) ? 5 : 6); key.KeyValue = (byte)(shiftPressed(k) ? 0x01 : 0x20); key.Shift = ShiftStatus.Disable; break; case Key.P: key.KeyColumn = 5; key.KeyValue = 0x02; break; case Key.L: key.KeyColumn = 5; key.KeyValue = 0x04; break; case Key.Minus: key.KeyColumn = (shiftPressed(k) ? 0 : 5); key.KeyValue = (byte)(shiftPressed(k) ? 0x00 : 0x08); key.Shift = (shiftPressed(k) ? ShiftStatus.None : ShiftStatus.Disable); break; case Key.Period: key.KeyColumn = 5; key.KeyValue = 0x10; break; case Key.Semicolon: key.KeyColumn = (shiftPressed(k) ? 5 : 6); key.KeyValue = (byte)(shiftPressed(k) ? 0x20 : 0x04); key.Shift = ShiftStatus.Disable; break; case Key.Two: key.KeyColumn = (shiftPressed(k) ? 5 : 7); key.KeyValue = (byte)(shiftPressed(k) ? 0x40 : 0x08); key.Shift = ShiftStatus.Disable; break; case Key.Comma: key.KeyColumn = 5; key.KeyValue = 0x80; break; case Key.LeftBracket: key.KeyColumn = (shiftPressed(k) ? 6 : 5); key.KeyValue = (byte)(shiftPressed(k) ? 0x01 : 0x20); key.Shift = (shiftPressed(k) ? ShiftStatus.Disable : ShiftStatus.Enable); break; case Key.Home: key.KeyColumn = 6; key.KeyValue = 0x08; key.Shift = ShiftStatus.Disable; break; case Key.End: key.KeyColumn = 6; key.KeyValue = 0x08; key.Shift = ShiftStatus.Enable; break; case Key.RightShift: case Key.CapsLock: key.KeyColumn = 6; key.KeyValue = 0x10; key.Shift = ShiftStatus.None; break; case Key.Backslash: key.KeyColumn = 6; key.KeyValue = 0x40; break; case Key.Slash: key.KeyColumn = 6; key.KeyValue = 0x80; break; case Key.One: key.KeyColumn = 7; key.KeyValue = 0x01; break; case Key.BackQuote: key.KeyColumn = (shiftPressed(k) ? 0 : 7); key.KeyValue = (byte)(shiftPressed(k) ? 0x00 : 0x02); key.Shift = ShiftStatus.None; break; case Key.LeftControl: case Key.RightControl: key.KeyColumn = 7; key.KeyValue = 0x04; key.Shift = ShiftStatus.None; break; case Key.Space: key.KeyColumn = 7; key.KeyValue = 0x10; key.Shift = ShiftStatus.None; break; case Key.PageUp: case Key.PageDown: key.KeyColumn = 7; key.KeyValue = 0x20; key.Shift = ShiftStatus.None; break; case Key.Q: key.KeyColumn = 7; key.KeyValue = 0x40; break; case Key.Escape: key.KeyColumn = 7; key.KeyValue = 0x80; break; case Key.RightBracket: key.KeyColumn = (shiftPressed(k) ? 0 : 6); key.KeyValue = (byte)(shiftPressed(k) ? 0x00 : 0x04); key.Shift = (shiftPressed(k) ? ShiftStatus.Disable : ShiftStatus.Enable); break; case Key.Quote: key.KeyColumn = (shiftPressed(k) ? 7 : 3); key.KeyValue = (byte)(shiftPressed(k) ? 0x08 : 0x01); key.Shift = ShiftStatus.Enable; break; } return(key); }