OSDN Git Service

[VM][FMTOWNS][MOUSE][JOYSTICK] More integrate to common interface.
[csp-qt/common_source_project-fm7.git] / source / src / vm / fmtowns / mouse.h
1 /*
2         FUJITSU FM Towns Emulator 'eFMTowns'
3
4         Author : Kyuma.Ohta <whatisthis.sowhat _at_ gmail.com>
5         Date   : 2021.06.16 -
6     History : 2020.06.16 Initial.
7         [ Towns Mouse]
8
9 */
10
11 #pragma once
12
13 #include "../device.h"
14
15 #define SIG_MOUSE_ENABLE        1
16 #define SIG_MOUSE_NUM           3
17 #define SIG_MOUSE_DATA          4
18 #define SIG_MOUSE_QUERY         5
19
20 namespace FMTOWNS {
21         
22 class MOUSE : public DEVICE
23 {
24 private:
25         DEVICE* d_joyport;
26         const int32_t* mouse_state;
27         
28         int phase;
29         bool strobe;
30         bool trig_a;
31         bool trig_b;
32         int dx, dy;
33         int lx, ly;
34         
35         bool mouse_connected;
36         int port_num;
37
38
39         uint8_t axisdata;
40         
41         int event_timeout;
42         int event_sampling;
43
44         void sample_mouse_xy();
45         void __FASTCALL update_strobe(uint8_t data, bool force = false);
46         uint32_t update_mouse();
47         uint32_t __FASTCALL check_mouse_data(bool is_send_data);
48         
49 public:
50         MOUSE(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu)
51         {
52                 d_joyport = NULL;
53                 set_device_name(_T("FM-Towns MOUSE"));
54         }
55         ~MOUSE() {}
56         
57         void initialize();
58         void release();
59
60         void __FASTCALL event_callback(int event_id, int err);
61         
62         uint32_t __FASTCALL read_signal(int ch);
63         void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask);
64
65         bool process_state(FILEIO* state_fio, bool loading);
66         
67         void set_context_joyport(DEVICE* dev)
68         {
69                 d_joyport = dev;
70         }
71 };
72
73 }
74