Deleted Added
sdiff udiff text old ( 12658:eaa132294582 ) new ( 12660:c5caca5f7d68 )
full compact
1/*
2 * Copyright (c) 2010, 2017-2018 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 32 unchanged lines hidden (view full) ---

41 * William Wang
42 * Andreas Sandberg
43 */
44
45#include "dev/ps2/touchkit.hh"
46
47#include "base/logging.hh"
48#include "debug/PS2.hh"
49#include "dev/ps2.hh"
50#include "params/PS2TouchKit.hh"
51
52const uint8_t PS2TouchKit::ID[] = {0x00};
53
54PS2TouchKit::PS2TouchKit(const PS2TouchKitParams *p)
55 : PS2Device(p),
56 vnc(p->vnc),
57 enabled(false), touchKitEnabled(false)
58{
59 if (vnc)
60 vnc->setMouse(this);
61}

--- 15 unchanged lines hidden (view full) ---

77 UNSERIALIZE_SCALAR(enabled);
78 UNSERIALIZE_SCALAR(touchKitEnabled);
79}
80
81bool
82PS2TouchKit::recv(const std::vector<uint8_t> &data)
83{
84 switch (data[0]) {
85 case Ps2::Ps2Reset:
86 DPRINTF(PS2, "Resetting device.\n");
87 enabled = false;
88 touchKitEnabled = false;
89 sendAck();
90 send(Ps2::SelfTestPass);
91 return true;
92
93 case Ps2::SetResolution:
94 case Ps2::SetRate:
95 case Ps2::SetStatusLed:
96 sendAck();
97 return data.size() == 2;
98
99 case Ps2::ReadId:
100 sendAck();
101 send((const uint8_t *)&ID, sizeof(ID));
102 return true;
103
104 case Ps2::TpReadId:
105 // We're not a trackpoint device, this should make the probe
106 // go away
107 sendAck();
108 send(0);
109 send(0);
110 sendAck();
111 return true;
112
113 case Ps2::SetScaling1_1:
114 case Ps2::SetScaling1_2:
115 sendAck();
116 return true;
117
118 case Ps2::Disable:
119 DPRINTF(PS2, "Disabling device.\n");
120 enabled = false;
121 sendAck();
122 return true;
123
124 case Ps2::Enable:
125 DPRINTF(PS2, "Enabling device.\n");
126 enabled = true;
127 sendAck();
128 return true;
129
130 case Ps2::SetDefaults:
131 DPRINTF(PS2, "Setting defaults and disabling device.\n");
132 enabled = false;
133 sendAck();
134 return true;
135
136 case Ps2::StatusRequest:
137 sendAck();
138 send(0);
139 send(2); // default resolution
140 send(100); // default sample rate
141 return true;
142
143 case Ps2::TouchKitId:
144 return recvTouchKit(data);
145
146 default:
147 panic("Unknown byte received: %#x\n", data[0]);
148 }
149}
150
151bool
152PS2TouchKit::recvTouchKit(const std::vector<uint8_t> &data)
153{
154 // Ack all incoming bytes
155 sendAck();
156
157 // Packet format is: 0x0A SIZE CMD DATA
158 assert(data[0] == Ps2::TouchKitId);
159 if (data.size() < 3 || data.size() - 2 < data[1])
160 return false;
161
162 const uint8_t len = data[1];
163 const uint8_t cmd = data[2];
164
165 // We have received at least one TouchKit diagnostic
166 // command. Enabled TouchKit reports.

--- 9 unchanged lines hidden (view full) ---

176 default:
177 panic("Unimplemented touchscreen command: %#x\n", cmd);
178 }
179}
180
181void
182PS2TouchKit::sendTouchKit(const uint8_t *data, size_t size)
183{
184 send(Ps2::TouchKitId);
185 send(size);
186 for (int i = 0; i < size; ++i)
187 send(data[i]);
188}
189
190
191void
192PS2TouchKit::mouseAt(uint16_t x, uint16_t y, uint8_t buttons)

--- 26 unchanged lines hidden ---