OSDN Git Service

[VM] Add vm_template.h . This class, VM_TEMPLATE:: must be mother of VM:: .See fm7...
[csp-qt/common_source_project-fm7.git] / source / src / vm / fm7 / joystick.h
1 /*
2  * FM-7 Keyboard [joystick.h]
3  *
4  * Author: K.Ohta <whatisthis.sowhat _at_ gmail.com>
5  * License: GPLv2
6  * History:
7  *   Jun 16, 2015 : Initial
8  *
9  */
10
11 #ifndef _VM_FM7_JOYSTICK_H_
12 #define _VM_FM7_JOYSTICK_H_
13 #include "../device.h"
14
15 #include "fm7_common.h"
16 #include "../../fileio.h"
17
18 class JOYSTICK : public DEVICE {
19  private:
20         bool emulate_mouse[2];
21         uint32_t joydata[2];
22         const uint32_t *rawdata;
23         const int32_t *mouse_state;
24         int dx, dy;
25         int lx, ly;
26         uint32_t mouse_button;
27         bool mouse_strobe;
28         uint32_t mouse_data;
29         int mouse_phase;
30         int mouse_timeout_event;
31         uint8_t port_b_val;
32         uint8_t lpmask;
33         int lpt_type;
34  protected:
35         DEVICE *opn;
36         
37  private:
38         uint32_t update_mouse(uint32_t mask);
39         void   update_strobe(bool flag);
40         uint32_t mouse_type;
41  public:
42         JOYSTICK(VM_TEMPLATE* parent_vm, EMU *parent_emu);
43         ~JOYSTICK();
44
45         void initialize(void);
46         void event_frame(void);
47         //void event_vline(int v, int clock);
48         
49         uint32_t read_data8(uint32_t addr);
50         void write_data8(uint32_t addr, uint32_t data);
51         void write_signal(int id, uint32_t data, uint32_t mask);
52         void event_callback(int event_id, int err);
53         
54         void reset(void);
55         void update_config();
56         void decl_state();
57         void save_state(FILEIO *state_fio);
58         bool load_state(FILEIO *state_fio);
59         
60         void set_context_opn(DEVICE *p) {
61                 opn = p;
62         }
63 };
64
65 #endif