VirtualC64 v5.0 beta
Commodore 64 Emulator
Loading...
Searching...
No Matches
Mouse1350.h
1// -----------------------------------------------------------------------------
2// This file is part of VirtualC64
3//
4// Copyright (C) Dirk W. Hoffmann. www.dirkwhoffmann.de
5// This FILE is dual-licensed. You are free to choose between:
6//
7// - The GNU General Public License v3 (or any later version)
8// - The Mozilla Public License v2
9//
10// SPDX-License-Identifier: GPL-3.0-or-later OR MPL-2.0
11// -----------------------------------------------------------------------------
12
13#pragma once
14
15#include "SubComponent.h"
16
17namespace vc64 {
18
19class Mouse1350 final : public SubComponent {
20
21 Descriptions descriptions = {{
22
23 .name = "Mouse1350",
24 .description = "Mouse 1350"
25 }};
26
27private:
28
29 // Mouse position
30 i64 mouseX;
31 i64 mouseY;
32
33 // Mouse button states
34 bool leftButton;
35 bool rightButton;
36
37 // Dividers applied to raw coordinates in setXY()
38 int dividerX = 64;
39 int dividerY = 64;
40
41 // Latched mouse positions
42 i64 latchedX[3];
43 i64 latchedY[3];
44
45 // Control port bits
46 u8 controlPort;
47
48
49 //
50 // Methods
51 //
52
53public:
54
55 Mouse1350(C64 &ref) : SubComponent(ref) { }
56
57 Mouse1350& operator= (const Mouse1350& other) {
58
59 CLONE(mouseX)
60 CLONE(mouseY)
61 CLONE(leftButton)
62 CLONE(rightButton)
63 CLONE(dividerX)
64 CLONE(dividerY)
65 CLONE_ARRAY(latchedX)
66 CLONE_ARRAY(latchedY)
67 CLONE(controlPort)
68
69 return *this;
70 }
71
72 //
73 // Methods from Serializable
74 //
75
76public:
77
78 template <class T> void serialize(T& worker) { } SERIALIZERS(serialize);
79 void _reset(bool hard) override;
80
81
82 //
83 // Methods from CoreComponent
84 //
85
86public:
87
88 const Descriptions &getDescriptions() const override { return descriptions; }
89
90
91 //
92 // Accessing
93 //
94
95public:
96
97 // Updates the button state
98 void setLeftMouseButton(bool value) { leftButton = value; }
99 void setRightMouseButton(bool value) { rightButton = value; }
100
101 // Returns the pot bits as set by the mouse
102 u8 readPotX() const;
103 u8 readPotY() const;
104
105 // Returns the control port bits triggered by the mouse
106 u8 readControlPort() const;
107
108 // Execution function (Translates movement deltas into joystick events)
109 void execute(i64 targetX, i64 targetY);
110};
111
112}
VirtualC64 project namespace.
Definition CmdQueue.cpp:16