#include <rclcpp/rclcpp.hpp>
#include "interfaces/msg/input_msg.hpp"// 自定义消息头文件
#include "input_dev/input_cfg.hpp"
#include <message_filters/subscriber.h>
#include <message_filters/sync_policies/approximate_time.hpp>
#include <message_filters/synchronizer.h>
#include"input_dev/input_dev_node.hpp"
namespace input_dev{
InputSub::InputSub() : Node("InputSub") {
    input_msg= std::make_shared<interfaces::msg::InputMsg>();
    input_pub = this->create_publisher<interfaces::msg::InputMsg>("/input_msg", 10);
}
static long long pub_cnt=0;
void InputSub::pub_msg(const int key,const float val,const InputCfg& cfg){
    input_msg->source = cfg.getSource();
    input_msg->type = cfg.getType();
    input_msg->position=cfg.getPosition();
    input_msg->code=key;
    input_msg->value=val;
    input_pub->publish(*input_msg);
    pub_cnt+=1;
    std::cout<<"pub msg["<<pub_cnt<<"]:"<<key<<std::endl;
}
void InputSub::pub_msg(const int key,const InputCfg& cfg){
    input_msg->source = cfg.getSource();
    input_msg->type = cfg.getType();
    input_msg->position=cfg.getPosition();
    input_msg->code=key;
    input_pub->publish(*input_msg);
    pub_cnt+=1;
    std::cout<<"pub msg["<<pub_cnt<<"]:"<<key<<std::endl;
}

}
