mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-19 17:43:35 -04:00
@@ -53,10 +53,10 @@ ohos_shared_library("libdinput_sink") {
|
||||
|
||||
deps = [
|
||||
"${dfx_utils_path}:libdinput_dfx_utils",
|
||||
"${distributedinput_path}/services/state:libdinput_state",
|
||||
"${innerkits_path}:libdinput_sdk",
|
||||
"${services_sink_path}/inputcollector:libdinput_collector",
|
||||
"${services_sink_path}/transport:libdinput_sink_trans",
|
||||
"${distributedinput_path}/services/state:libdinput_state",
|
||||
"${utils_path}:libdinput_utils",
|
||||
"//third_party/libevdev:libevdev",
|
||||
]
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
const std::string &sinkNodeDesc);
|
||||
void SyncNodeOfflineInfo(const std::string &srcDevId, const std::string &sinkDevId, const std::string &sinkNodeId);
|
||||
|
||||
void GetVirtualKeyboardPathByDhId(std::vector<std::string> &dhIds, std::vector<std::string> &shareDhidsPaths,
|
||||
void GetVirtualKeyboardPathByDhId(const std::vector<std::string> &dhIds, std::vector<std::string> &shareDhidsPaths,
|
||||
std::vector<std::string> &shareDhIds);
|
||||
|
||||
private:
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
void GetDevicesInfoByDhId(std::vector<std::string> dhidsVec, std::map<int32_t, std::string> &datas);
|
||||
void ProcessInjectEvent(const std::shared_ptr<RawEvent> &rawEvent);
|
||||
|
||||
void GetVirtualKeyboardPathByDhId(std::vector<std::string> &dhIds, std::vector<std::string> &shareDhidsPaths,
|
||||
void GetVirtualKeyboardPathByDhId(const std::vector<std::string> &dhIds, std::vector<std::string> &shareDhidsPaths,
|
||||
std::vector<std::string> &shareDhIds);
|
||||
private:
|
||||
void AddDeviceLocked(const std::string& dhId, std::unique_ptr<VirtualDevice> device);
|
||||
|
||||
@@ -256,8 +256,8 @@ int32_t DistributedInputInject::GetVirtualTouchScreenFd()
|
||||
return inputNodeManager_->GetVirtualTouchScreenFd();
|
||||
}
|
||||
|
||||
void GetVirtualKeyboardPathByDhId(std::vector<std::string> &dhIds, std::vector<std::string> &shareDhidsPaths,
|
||||
std::vector<std::string> &shareDhIds)
|
||||
void DistributedInputInject::GetVirtualKeyboardPathByDhId(const std::vector<std::string> &dhIds,
|
||||
std::vector<std::string> &shareDhidsPaths, std::vector<std::string> &shareDhIds)
|
||||
{
|
||||
if (inputNodeManager_ == nullptr) {
|
||||
DHLOGI("inputNodeManager_ is nullptr!");
|
||||
|
||||
@@ -145,7 +145,7 @@ static std::string ConvertErrNo()
|
||||
return errNoMsg;
|
||||
}
|
||||
|
||||
void Closed(int fd)
|
||||
void CloseFd(int fd)
|
||||
{
|
||||
if (fd < 0) {
|
||||
DHLOGE("No fd need to beclosed.");
|
||||
@@ -173,7 +173,7 @@ void DistributedInputNodeManager::ScanSinkInputDevices(const std::string& dirNam
|
||||
continue;
|
||||
}
|
||||
std::string tmpDevName = dirName + "/" + std::string(de->d_name);
|
||||
OpenInputDeviceLocked(tmpDevName);
|
||||
OpenInputDevice(tmpDevName);
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
@@ -190,7 +190,7 @@ bool DistributedInputNodeManager::IsVirtualDev(int fd)
|
||||
deviceName = buffer;
|
||||
|
||||
DHLOGD("IsVirtualDev deviceName: %s", buffer);
|
||||
if (identifier.name.find(VIRTUAL_DEVICE_NAME) == std::string::npos) {
|
||||
if (deviceName.find(VIRTUAL_DEVICE_NAME) == std::string::npos) {
|
||||
DHLOGD("This is not a virtual device, fd %d, deviceName: %s", fd, deviceName.c_str());
|
||||
return false;
|
||||
}
|
||||
@@ -224,7 +224,7 @@ void DistributedInputNodeManager::SetPathForDevMap(std::string& dhId, const std:
|
||||
DHLOGD("Virtual device map dhid %s.", iter->first.c_str());
|
||||
if (dhId.compare(iter->first) == 0) {
|
||||
DHLOGI("Found the virtual device, set path :%s", devicePath.c_str());
|
||||
iter->second->SetPath(devicePath)
|
||||
iter->second->SetPath(devicePath);
|
||||
break;
|
||||
}
|
||||
iter++;
|
||||
@@ -263,7 +263,7 @@ void DistributedInputNodeManager::OpenInputDevice(const std::string& devicePath)
|
||||
CloseFd(fd);
|
||||
return;
|
||||
}
|
||||
if (fd =-1) {
|
||||
if (fd == -1) {
|
||||
DHLOGE("The fd open failed, devicePath %s\n", devicePath.c_str());
|
||||
return;
|
||||
}
|
||||
@@ -278,8 +278,8 @@ void DistributedInputNodeManager::OpenInputDevice(const std::string& devicePath)
|
||||
SetPathForDevMap(dhId, devicePath);
|
||||
}
|
||||
|
||||
void GetVirtualKeyboardPathByDhId(std::vector<std::string> &dhIds, std::vector<std::string> &shareDhidsPaths,
|
||||
std::vector<std::string> &shareDhIds);
|
||||
void DistributedInputNodeManager::GetVirtualKeyboardPathByDhId(const std::vector<std::string> &dhIds,
|
||||
std::vector<std::string> &shareDhidsPaths, std::vector<std::string> &shareDhIds)
|
||||
{
|
||||
for (auto dhId_ : dhIds) {
|
||||
auto iter = virtualDeviceMap_.begin();
|
||||
@@ -289,8 +289,8 @@ void GetVirtualKeyboardPathByDhId(std::vector<std::string> &dhIds, std::vector<s
|
||||
continue;
|
||||
}
|
||||
if ((iter->first.compare(dhId_) == 0) && ((iter->second->GetClasses() & INPUT_DEVICE_CLASS_KEYBOARD) != 0)) {
|
||||
DHLOGI("Found vir keyboard path %s, dhid %s", itersecond->GetPath().c_str());
|
||||
shareDhidsPath.push_back(diter->second->GetPath());
|
||||
DHLOGI("Found vir keyboard path %s, dhid %s", iter->second->GetPath().c_str());
|
||||
shareDhidsPaths.push_back(iter->second->GetPath());
|
||||
shareDhIds.push_back(dhId_);
|
||||
}
|
||||
iter++;
|
||||
|
||||
@@ -185,7 +185,7 @@ void VirtualDevice::SetNetWorkId(const std::string netWorkId)
|
||||
netWorkId_ = netWorkId;
|
||||
}
|
||||
|
||||
void SetPath(const std::string path)
|
||||
void VirtualDevice::SetPath(const std::string path)
|
||||
{
|
||||
path_ = path;
|
||||
}
|
||||
@@ -195,12 +195,12 @@ std::string VirtualDevice::GetNetWorkId()
|
||||
return netWorkId_;
|
||||
}
|
||||
|
||||
std::string GetPath()
|
||||
std::string VirtualDevice::GetPath()
|
||||
{
|
||||
return path_;
|
||||
}
|
||||
|
||||
uint16_t GetClasses()
|
||||
uint16_t VirtualDevice::GetClasses()
|
||||
{
|
||||
return classes_;
|
||||
}
|
||||
|
||||
@@ -88,11 +88,11 @@ ohos_shared_library("libdinput_source") {
|
||||
|
||||
deps = [
|
||||
"${dfx_utils_path}:libdinput_dfx_utils",
|
||||
"${distributedinput_path}/services/state:libdinput_state",
|
||||
"${innerkits_path}:libdinput_sdk",
|
||||
"${services_source_path}/inputinject:libdinput_inject",
|
||||
"${services_source_path}/transport:libdinput_source_trans",
|
||||
"${utils_path}:libdinput_utils",
|
||||
"${distributedinput_path}/services/state:libdinput_state",
|
||||
"//third_party/libevdev:libevdev",
|
||||
]
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ void DistributedInputSourceManager::DInputSourceListener::OnResponseStartRemoteI
|
||||
|
||||
std::vector<std::string> vecStr;
|
||||
sourceManagerObj_->StringSplitToVector(dhids, INPUT_STRING_SPLIT_POINT, vecStr);
|
||||
StateMachine::GetInstance().AddDhid(vecStr);
|
||||
StateMachine::GetInstance().AddDhids(vecStr);
|
||||
StateMachine::GetInstance().SwitchState(vecStr, DhidState::THROUGH_IN);
|
||||
|
||||
std::shared_ptr<nlohmann::json> jsonArrayMsg = std::make_shared<nlohmann::json>();
|
||||
|
||||
@@ -44,9 +44,9 @@ ohos_shared_library("libdinput_source_trans") {
|
||||
|
||||
deps = [
|
||||
"${dfx_utils_path}:libdinput_dfx_utils",
|
||||
"${distributedinput_path}/services/state:libdinput_state",
|
||||
"${distributedinput_path}/services/transportbase:libdinput_trans_base",
|
||||
"${services_source_path}/inputinject:libdinput_inject",
|
||||
"${services_source_path}/services/state:libdinput_state",
|
||||
"${utils_path}:libdinput_utils",
|
||||
"//third_party/libevdev:libevdev",
|
||||
]
|
||||
|
||||
@@ -21,10 +21,10 @@ ohos_shared_library("libdinput_state") {
|
||||
"${common_path}/include",
|
||||
"${utils_path}/include",
|
||||
"${services_sink_path}/inputcollector/include",
|
||||
"${services_source_path}/inputdevicehandler/include",
|
||||
"${services_sink_path}/inputcollector/include",
|
||||
"${distributedinput_path}/inputdevicehandler/include",
|
||||
"${services_source_path}/inputinject/include",
|
||||
"${frameworks_path}/include",
|
||||
"${fWK_common_path}/utils/include",
|
||||
"${fwk_common_path}/utils/include",
|
||||
]
|
||||
|
||||
sources = [ "src/dinput_state.cpp" ]
|
||||
@@ -37,8 +37,8 @@ ohos_shared_library("libdinput_state") {
|
||||
|
||||
deps = [
|
||||
"${dfx_utils_path}:libdinput_dfx_utils",
|
||||
"${services_source_path}/inputinject:libdinput_inject",
|
||||
"${services_sink_path}/inputcollector:libdinput_collector",
|
||||
"${services_source_path}/inputinject:libdinput_inject",
|
||||
"${utils_path}:libdinput_utils",
|
||||
"//third_party/libevdev:libevdev",
|
||||
]
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "dinput_utils_tool.h"
|
||||
#include "constants_dinput.h"
|
||||
#include "distributed_input_collector.h"
|
||||
#include "distributed_input_inject.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
@@ -43,7 +44,7 @@ int32_t StateMachine::Release()
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t StateMachine::AddDhids(std::vector<std::string> &dhids)
|
||||
int32_t StateMachine::AddDhids(const std::vector<std::string> &dhids)
|
||||
{
|
||||
DHLOGI("AddDhid dhids size = %zu", dhids.size());
|
||||
for (auto &dhid : dhids) {
|
||||
@@ -57,7 +58,7 @@ int32_t StateMachine::AddDhids(std::vector<std::string> &dhids)
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t StateMachine::DeleteDhids(std::vector<std::string> &dhids)
|
||||
int32_t StateMachine::DeleteDhids(const std::vector<std::string> &dhids)
|
||||
{
|
||||
DHLOGI("DeleteDhid dhids size = %zu", dhids.size());
|
||||
for (auto &dhid : dhids) {
|
||||
@@ -71,7 +72,7 @@ int32_t StateMachine::DeleteDhids(std::vector<std::string> &dhids)
|
||||
return DH_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t StateMachine::SwitchState(std::vector<std::string> &dhids, DhidState state)
|
||||
int32_t StateMachine::SwitchState(const std::vector<std::string> &dhids, DhidState state)
|
||||
{
|
||||
for (auto &dhid : dhids) {
|
||||
DHLOGD("SwitchState dhid : %s, state : %d.", GetAnonyString(dhid).c_str(), state);
|
||||
@@ -98,7 +99,7 @@ DhidState StateMachine::GetStateByDhid(std::string &dhid)
|
||||
return dhidStateMap_[dhid];
|
||||
}
|
||||
|
||||
bool StateMachine::IsExistDhid(std::string &dhid)
|
||||
bool StateMachine::IsExistDhid(const std::string &dhid)
|
||||
{
|
||||
if (dhidStateMap_.find(dhid) == dhidStateMap_.end()) {
|
||||
return false;
|
||||
@@ -125,7 +126,7 @@ void StateMachine::CreateKeyUpInjectThread(const std::vector<std::string> &dhids
|
||||
|
||||
void StateMachine::KeyUpInject(std::vector<std::string> &shareDhidsPaths, std::vector<std::string> &shareDhIds)
|
||||
{
|
||||
ssize len = shareDhidsPaths.size();
|
||||
ssize_t len = shareDhidsPaths.size();
|
||||
for (int32_t i = 0; i < len; ++i) {
|
||||
CheckKeyState(shareDhIds[i], shareDhidsPaths[i]);
|
||||
}
|
||||
@@ -194,7 +195,7 @@ void StateMachine::UpInject(int fd, std::vector<uint32_t> &keyboardPressedKeys,
|
||||
}
|
||||
RecordEventLog(event);
|
||||
|
||||
struct input_event event = {
|
||||
event = {
|
||||
.type = EV_SYN,
|
||||
.code = 0,
|
||||
.value = KEY_UP_STATE
|
||||
|
||||
Reference in New Issue
Block a user