1 /*
2  *  KCemu -- The emulator for the KC85 homecomputer series and much more.
3  *  Copyright (C) 1997-2010 Torsten Paul
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License along
16  *  with this program; if not, write to the Free Software Foundation, Inc.,
17  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef __kc_keyb0_h
21 #define __kc_keyb0_h
22 
23 #include "kc/prefs/types.h"
24 
25 #include "kc/cb.h"
26 #include "kc/pio.h"
27 #include "kc/keyboard.h"
28 
29 class Keyboard0 : public Keyboard, public PIOCallbackInterface
30 {
31  private:
32   enum {
33     SHIFT_DELAY = 5
34   };
35 
36   kc_variant_t _variant;
37 
38  private:
39   byte_t _ext;
40   byte_t _value;
41   byte_t _pio_value;
42 
43   bool _control;
44   unsigned int _key;
45   unsigned int _keysym;
46 
47  protected:
48   void init(void);
49   void keyboard_handler(void);
50   void keyboard_handler_rb(void);
51   void keyboard_handler_a2(void);
52   void keyboard_handler_default(void);
53 
54  public:
55   Keyboard0(void);
56   virtual ~Keyboard0(void);
57   virtual void keyPressed(int keysym, int keycode);
58   virtual void keyReleased(int keysym, int keycode);
59   virtual void replayString(const char *text);
60 
61   virtual void callback(void *data);
62 
63   /*
64    *  set value for keyboard output lines (coming from
65    *  the B/D decoder chip
66    */
67   virtual void set_value(byte_t value);
68 
69   /*
70    *  InterfaceCircuit
71    */
72   virtual void reti(void);
irqreq(void)73   virtual void irqreq(void) {}
irqack()74   virtual word_t irqack() { return IRQ_NOT_ACK; }
75   virtual void reset(bool power_on = false);
76 
77   /*
78    *  PIOCallbackInterface
79    */
80   virtual int callback_A_in(void);
81   virtual int callback_B_in(void);
82   virtual void callback_A_out(byte_t val);
83   virtual void callback_B_out(byte_t val);
84 };
85 
86 #endif /* __kc_keyb0_h */
87