From 8758151dcdb0f89e362dd297405a384d3a034380 Mon Sep 17 00:00:00 2001
From: chenlh <2008get@163.com>
Date: 星期三, 28 一月 2026 20:21:37 +0800
Subject: [PATCH] 天宫输入源模块设置时爆音及参数拷贝更新
---
src/param_ctrl.h | 71 ++++++++++++++++++++++++++---------
1 files changed, 52 insertions(+), 19 deletions(-)
diff --git a/src/param_ctrl.h b/src/param_ctrl.h
index 88aa16b..57a4b76 100644
--- a/src/param_ctrl.h
+++ b/src/param_ctrl.h
@@ -14,7 +14,7 @@
//预设参数解析用
typedef u32 (*ParamCtrl_fn)(IModule* m, void* handle, int &plen);
//参数控制用
-typedef u32 (*Ctrl_fn)(IModule* m, u32 pID, s16* val_c);
+typedef u32 (*Ctrl_fn)(IModule* m, u32 pID, s16* val_c, u32 num, void* param);
class ParamEntry {
private:
@@ -23,11 +23,11 @@
Ctrl_fn ctrl;
public:
- ParamCtrl_fn GetParamEntry(){
+ ParamCtrl_fn GetParamEntry() const {
return param;
}
- Ctrl_fn GetCtrlEntry(){
+ Ctrl_fn GetCtrlEntry() const {
return ctrl;
}
ParamEntry() : param(nullptr), ctrl(nullptr) {}
@@ -40,24 +40,57 @@
class param_ctrl_t{
protected:
- std::map<u32, ParamEntry> mctrl_list;
-public:
- ParamCtrl_fn GetParamEntry(u32 mtype)
- {
- if(mctrl_list.count(mtype))
- return mctrl_list[mtype].GetParamEntry();
- else
- return NULL;
- }
+ std::map<u32, ParamEntry> mctrl_list;
- Ctrl_fn GetCtrlEntry(u32 mtype)
- {
- if(mctrl_list.count(mtype))
- return mctrl_list[mtype].GetCtrlEntry();
- else
- return NULL;
- }
+public:
+ // 返回pair避免重复查找
+ std::pair<ParamCtrl_fn, Ctrl_fn> GetEntries(u32 mtype) const
+ {
+ auto it = mctrl_list.find(mtype);
+ if(it != mctrl_list.end()) {
+ return {it->second.GetParamEntry(), it->second.GetCtrlEntry()};
+ }
+ return {nullptr, nullptr};
+ }
+
+ ParamCtrl_fn GetParamEntry(u32 mtype) const
+ {
+ auto it = mctrl_list.find(mtype);
+ return (it != mctrl_list.end()) ? it->second.GetParamEntry() : nullptr;
+ }
+
+ Ctrl_fn GetCtrlEntry(u32 mtype) const
+ {
+ auto it = mctrl_list.find(mtype);
+ return (it != mctrl_list.end()) ? it->second.GetCtrlEntry() : nullptr;
+ }
+
+ // 检查是否存在
+ bool HasEntry(u32 mtype) const
+ {
+ return mctrl_list.find(mtype) != mctrl_list.end();
+ }
};
+//class param_ctrl_t{
+//protected:
+// std::map<u32, ParamEntry> mctrl_list;
+//public:
+// ParamCtrl_fn GetParamEntry(u32 mtype)
+// {
+// if(mctrl_list.count(mtype))
+// return mctrl_list[mtype].GetParamEntry();
+// else
+// return NULL;
+// }
+//
+// Ctrl_fn GetCtrlEntry(u32 mtype)
+// {
+// if(mctrl_list.count(mtype))
+// return mctrl_list[mtype].GetCtrlEntry();
+// else
+// return NULL;
+// }
+//};
--
Gitblit v1.9.3