1 /////////////////////////////////////////////////////////////////////////
2 // $Id: busmouse.h 14112 2021-01-31 10:50:53Z vruppert $
3 /////////////////////////////////////////////////////////////////////////
4 //
5 //  Copyright (C) 2004-2021  The Bochs Project
6 //
7 //  This library is free software; you can redistribute it and/or
8 //  modify it under the terms of the GNU Lesser General Public
9 //  License as published by the Free Software Foundation; either
10 //  version 2 of the License, or (at your option) any later version.
11 //
12 //  This library is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 //  Lesser General Public License for more details.
16 //
17 //  You should have received a copy of the GNU Lesser General Public
18 //  License along with this library; if not, write to the Free Software
19 //  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
20 
21 
22 #ifndef _PCBUSM_H
23 #define _PCBUSM_H
24 
25 #if BX_SUPPORT_BUSMOUSE
26 
27 // these keywords should only be used in busmouse.cc
28 #if BX_USE_BUSM_SMF
29 #  define BX_BUSM_SMF  static
30 #  define BX_BUSM_THIS theBusMouse->
31 #else
32 #  define BX_BUSM_SMF
33 #  define BX_BUSM_THIS
34 #endif
35 
36 class bx_busm_c : public bx_devmodel_c {
37 public:
38   bx_busm_c();
39   virtual ~bx_busm_c();
40 
41   virtual void init(void);
reset(unsigned type)42   virtual void reset(unsigned type) {}
43   virtual void register_state(void);
44 
45 private:
46   static void timer_handler(void *);
47   void busm_timer(void);
48 
49   static void mouse_enq_static(void *dev, int delta_x, int delta_y, int delta_z, unsigned button_state, bool absxy);
50   void mouse_enq(int delta_x, int delta_y, int delta_z, unsigned button_state);
51   void update_mouse_data(void);
52 
53   static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len);
54   static void   write_handler(void *this_ptr, Bit32u address, Bit32u value, unsigned io_len);
55 #if !BX_USE_BUSM_SMF
56   void   write(Bit32u address, Bit32u value, unsigned io_len);
57   Bit32u  read(Bit32u address, unsigned io_len);
58 #endif
59 
60   int   type;
61   int   timer_index; // our timer index
62 
63   int   mouse_delayed_dx;
64   int   mouse_delayed_dy;
65   Bit8u mouse_buttons;
66   Bit8u mouse_buttons_last;
67   Bit8u current_x, current_y, current_b;
68 
69   Bit8u control_val;
70   Bit8u command_val;     // current command val
71   Bit8u config_val;
72   Bit8u sig_val;
73   Bit16u toggle_counter;
74   bool interrupts;       // 0 or 1.  interrupts off or on.
75 };
76 
77 #endif  // BX_SUPPORT_BUSMOUSE
78 
79 #endif  // #ifndef _PCBUSM_H
80