Deleted Added
sdiff udiff text old ( 12655:a1646f7c13ab ) new ( 12656:335489e574f3 )
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

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

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 ackNext(false),
58 driverInitialized(false)
59{
60 if (vnc)
61 vnc->setMouse(this);
62}
63
64void
65PS2TouchKit::serialize(CheckpointOut &cp) const
66{
67 PS2Device::serialize(cp);
68
69 SERIALIZE_SCALAR(ackNext);
70 SERIALIZE_SCALAR(driverInitialized);
71}
72
73void
74PS2TouchKit::unserialize(CheckpointIn &cp)
75{
76 PS2Device::unserialize(cp);
77
78 UNSERIALIZE_SCALAR(ackNext);
79 UNSERIALIZE_SCALAR(driverInitialized);
80}
81
82void
83PS2TouchKit::recv(uint8_t data)
84{
85 if (ackNext) {
86 ackNext--;
87 sendAck();
88 return;
89 }
90
91 switch (data) {
92 case Ps2::Ps2Reset:
93 sendAck();
94 send(Ps2::SelfTestPass);
95 break;
96
97 case Ps2::SetResolution:
98 case Ps2::SetRate:
99 case Ps2::SetStatusLed:
100 sendAck();
101 ackNext = 1;
102 break;
103
104 case Ps2::ReadId:
105 sendAck();
106 send((const uint8_t *)&ID, sizeof(ID));
107 break;
108
109 case Ps2::TpReadId:
110 // We're not a trackpoint device, this should make the probe
111 // go away
112 sendAck();
113 send(0);
114 send(0);
115 sendAck();
116 break;
117
118 case Ps2::SetScaling1_1:
119 case Ps2::SetScaling1_2:
120 case Ps2::Disable:
121 case Ps2::Enable:
122 case Ps2::SetDefaults:
123 sendAck();
124 break;
125
126 case Ps2::StatusRequest:
127 sendAck();
128 send(0);
129 send(2); // default resolution
130 send(100); // default sample rate
131 break;
132
133 case Ps2::TouchKitId:
134 ackNext = 2;
135 sendAck();
136 send(Ps2::TouchKitId);
137 send(1);
138 send('A');
139
140 driverInitialized = true;
141 break;
142
143 default:
144 panic("Unknown byte received: %d\n", data);
145 }
146}
147
148void
149PS2TouchKit::mouseAt(uint16_t x, uint16_t y, uint8_t buttons)
150{
151 // If the driver hasn't initialized the device yet, no need to try and send
152 // it anything. Similarly we can get vnc mouse events orders of magnitude

--- 23 unchanged lines hidden ---