keyboard.cc (12653:4f6b6c1a8e2f) | keyboard.cc (12654:749de33b7af6) |
---|---|
1/* 2 * Copyright (c) 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 --- 31 unchanged lines hidden (view full) --- 40 * Authors: Gabe Black 41 * Andreas Sandberg 42 */ 43 44#include "dev/ps2/keyboard.hh" 45 46#include "base/logging.hh" 47#include "debug/PS2.hh" | 1/* 2 * Copyright (c) 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 --- 31 unchanged lines hidden (view full) --- 40 * Authors: Gabe Black 41 * Andreas Sandberg 42 */ 43 44#include "dev/ps2/keyboard.hh" 45 46#include "base/logging.hh" 47#include "debug/PS2.hh" |
48#include "dev/ps2.hh" |
|
48#include "params/PS2Keyboard.hh" 49 50const uint8_t PS2Keyboard::ID[] = {0xab, 0x83}; 51 52PS2Keyboard::PS2Keyboard(const PS2KeyboardParams *p) 53 : PS2Device(p), | 49#include "params/PS2Keyboard.hh" 50 51const uint8_t PS2Keyboard::ID[] = {0xab, 0x83}; 52 53PS2Keyboard::PS2Keyboard(const PS2KeyboardParams *p) 54 : PS2Device(p), |
54 lastCommand(NoCommand) | 55 lastCommand(NoCommand), 56 shiftDown(false), 57 enabled(false) |
55{ | 58{ |
59 if (p->vnc) 60 p->vnc->setKeyboard(this); |
|
56} 57 58void 59PS2Keyboard::serialize(CheckpointOut &cp) const 60{ 61 PS2Device::serialize(cp); 62 SERIALIZE_SCALAR(lastCommand); | 61} 62 63void 64PS2Keyboard::serialize(CheckpointOut &cp) const 65{ 66 PS2Device::serialize(cp); 67 SERIALIZE_SCALAR(lastCommand); |
68 SERIALIZE_SCALAR(shiftDown); 69 SERIALIZE_SCALAR(enabled); |
|
63} 64 65void 66PS2Keyboard::unserialize(CheckpointIn &cp) 67{ 68 PS2Device::unserialize(cp); 69 UNSERIALIZE_SCALAR(lastCommand); | 70} 71 72void 73PS2Keyboard::unserialize(CheckpointIn &cp) 74{ 75 PS2Device::unserialize(cp); 76 UNSERIALIZE_SCALAR(lastCommand); |
77 UNSERIALIZE_SCALAR(shiftDown); 78 UNSERIALIZE_SCALAR(enabled); |
|
70} 71 72void 73PS2Keyboard::recv(uint8_t data) 74{ 75 if (lastCommand != NoCommand) { 76 switch (lastCommand) { 77 case LEDWrite: --- 31 unchanged lines hidden (view full) --- 109 break; 110 case TypematicInfo: 111 DPRINTF(PS2, "Setting typematic info.\n"); 112 sendAck(); 113 lastCommand = TypematicInfo; 114 break; 115 case Enable: 116 DPRINTF(PS2, "Enabling the keyboard.\n"); | 79} 80 81void 82PS2Keyboard::recv(uint8_t data) 83{ 84 if (lastCommand != NoCommand) { 85 switch (lastCommand) { 86 case LEDWrite: --- 31 unchanged lines hidden (view full) --- 118 break; 119 case TypematicInfo: 120 DPRINTF(PS2, "Setting typematic info.\n"); 121 sendAck(); 122 lastCommand = TypematicInfo; 123 break; 124 case Enable: 125 DPRINTF(PS2, "Enabling the keyboard.\n"); |
126 enabled = true; |
|
117 sendAck(); 118 break; 119 case Disable: 120 DPRINTF(PS2, "Disabling the keyboard.\n"); | 127 sendAck(); 128 break; 129 case Disable: 130 DPRINTF(PS2, "Disabling the keyboard.\n"); |
131 enabled = false; |
|
121 sendAck(); 122 break; 123 case DefaultsAndDisable: 124 DPRINTF(PS2, "Disabling and resetting the keyboard.\n"); | 132 sendAck(); 133 break; 134 case DefaultsAndDisable: 135 DPRINTF(PS2, "Disabling and resetting the keyboard.\n"); |
136 enabled = false; |
|
125 sendAck(); 126 break; 127 case AllKeysToTypematic: 128 panic("Setting all keys to typemantic unimplemented.\n"); 129 case AllKeysToMakeRelease: 130 panic("Setting all keys to make/release unimplemented.\n"); 131 case AllKeysToMake: 132 panic("Setting all keys to make unimplemented.\n"); --- 10 unchanged lines hidden (view full) --- 143 panic("Keyboard resend unimplemented.\n"); 144 case Reset: 145 panic("Keyboard reset unimplemented.\n"); 146 default: 147 panic("Unknown keyboard command %#02x.\n", data); 148 } 149} 150 | 137 sendAck(); 138 break; 139 case AllKeysToTypematic: 140 panic("Setting all keys to typemantic unimplemented.\n"); 141 case AllKeysToMakeRelease: 142 panic("Setting all keys to make/release unimplemented.\n"); 143 case AllKeysToMake: 144 panic("Setting all keys to make unimplemented.\n"); --- 10 unchanged lines hidden (view full) --- 155 panic("Keyboard resend unimplemented.\n"); 156 case Reset: 157 panic("Keyboard reset unimplemented.\n"); 158 default: 159 panic("Unknown keyboard command %#02x.\n", data); 160 } 161} 162 |
163void 164PS2Keyboard::keyPress(uint32_t key, bool down) 165{ 166 std::list<uint8_t> keys; 167 168 // convert the X11 keysym into ps2 codes and update the shift 169 // state (shiftDown) 170 Ps2::keySymToPs2(key, down, shiftDown, keys); 171 172 // Drop key presses if the keyboard hasn't been enabled by the 173 // host. We do that after translating the key code to ensure that 174 // we keep track of the shift state. 175 if (!enabled) 176 return; 177 178 // Insert into our queue of characters 179 for (uint8_t c : keys) 180 send(c); 181} 182 183 |
|
151PS2Keyboard * 152PS2KeyboardParams::create() 153{ 154 return new PS2Keyboard(this); 155} | 184PS2Keyboard * 185PS2KeyboardParams::create() 186{ 187 return new PS2Keyboard(this); 188} |