29 #include YFM_Helper_InputManager
30 #include YFM_YCLib_Input
31 #include YFM_Helper_Host
32 #include YFM_Helper_HostRenderer // for Host::Window, Host::RenderWindow;
33 #include YFM_Helper_GUIApplication // for FetchEnvironment;
43 InputManager::InputManager()
46 , env(Host::FetchEnvironment())
51 # define YCL_CURSOR_VALID
53 # define YCL_CURSOR_VALID if(cursor_state != Point::Invalid)
55 # error "Unsupported platform found."
61 const auto disp([&](
const KeyInput& keyset, VisualEvent key_evt,
62 VisualEvent touch_evt){
63 if(keyset[KeyCodes::Primary] || keyset[KeyCodes::Secondary]
64 || keyset[KeyCodes::Tertiary])
70 st.ResponseCursor(e, touch_evt);
77 st.ResponseKey(e, key_evt);
82 disp(keys, KeyUp, TouchUp);
88 st.ResponseCursor(e, CursorOver);
92 disp(keys, KeyDown, TouchDown);
94 disp(keys, KeyHeld, TouchHeld);
102 st.ResponseCursor(e, CursorWheel);
103 env.get().RawMouseButton = 0;
112 const auto p_wnd(env.get().GetForegroundWindow());
118 using namespace platform::KeyCodes;
135 ::GetCursorPos(&cursor);
136 ::ScreenToClient(p_wnd->GetNativeHandle(), &cursor);
138 const auto& pr(p_wnd->GetInputBounds());
140 if(
YB_LIKELY(pr.first.X != pr.second.X && pr.first.Y != pr.second.Y)
141 && (!p_wnd->BoundsLimited
142 || (IsInInterval<::LONG>(cursor.x, pr.first.X, pr.second.X)
143 && IsInInterval<::LONG>(cursor.y, pr.first.Y, pr.second.Y))))
151 if(
const auto p_render_wnd = dynamic_cast<Host::RenderWindow*>(p_wnd))
152 return &p_render_wnd->GetRenderer().GetWidgetRef();
156 #undef YCL_CURSOR_VALID
YF_API const platform::KeyInput & FetchKeyState()
取按键状态。
YF_API GUIState & FetchGUIState()
取默认图形用户界面公共状态。
void DispatchInput(UI::IWidget &)
向指定部件分发响应输入状态。
std::reference_wrapper< UI::GUIState > GUI_state
static const GBinaryGroup Invalid
无效(不在屏幕坐标系中)对象。
Drawing::Point cursor_state
指针设备光标位置。
#define yunseq
无序列依赖表达式组求值。
UI::IWidget * Update()
更新输入状态。
if(YB_LIKELY(!error)) if(YB_LIKELY(!(error
YF_API platform::KeyInput FetchKeyUpState()
取键释放状态。
ptrdiff_t WheelDelta
滚轮度量:以角度计量的转动滚轮的幅度。
YF_API platform::KeyInput FetchKeyDownState()
取键按下状态。
YF_API void UpdateKeyStates()
更新按键状态。
std::bitset< KeyBitsetWidth > KeyInput
按键并行位宽。