X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FApplications%2Faxwin4_src%2FServer%2Finput.cpp;h=c120ed458a0f07f5492b142da41bd64fa11492aa;hb=0868c6e02b76236ea70a6daa232b3c373f61e131;hp=bea47775fc23f8f13425b02a92fc687e84192eab;hpb=340e7923b1e95c39ac85a4b22af7f1b53b315cd9;p=tpg%2Facess2.git diff --git a/Usermode/Applications/axwin4_src/Server/input.cpp b/Usermode/Applications/axwin4_src/Server/input.cpp index bea47775..c120ed45 100644 --- a/Usermode/Applications/axwin4_src/Server/input.cpp +++ b/Usermode/Applications/axwin4_src/Server/input.cpp @@ -7,26 +7,67 @@ */ #include #include +#include +#include namespace AxWin { -namespace Input { - -void Initialise(const ::AxWin::CConfigInput& config) +CInput::CInput(const ::AxWin::CConfigInput& config, CCompositor& compositor): + m_compositor(compositor), + m_keyboardFD(0), + m_mouseFD(-1) { } -int FillSelect(::fd_set& rfds) +int CInput::FillSelect(::fd_set& rfds) { - return 0; + FD_SET(m_keyboardFD, &rfds); + if( m_mouseFD != -1 ) + FD_SET(m_mouseFD, &rfds); + return ::std::max(m_keyboardFD, m_mouseFD)+1; } -void HandleSelect(::fd_set& rfds) +void CInput::HandleSelect(::fd_set& rfds) { + if( FD_ISSET(m_keyboardFD, &rfds) ) + { + uint32_t codepoint; + static uint32_t scancode; + #define KEY_CODEPOINT_MASK 0x3FFFFFFF + + size_t readlen = _SysRead(m_keyboardFD, &codepoint, sizeof(codepoint)); + if( readlen != sizeof(codepoint) ) + { + // oops, error + _SysDebug("Terminal read failed? (%i != %i)", readlen, sizeof(codepoint)); + } + +// _SysDebug("Keypress 0x%x", codepoint); + + switch(codepoint & 0xC0000000) + { + case 0x00000000: // Key pressed + //WM_Input_KeyDown(codepoint & KEY_CODEPOINT_MASK, scancode); + case 0x80000000: // Key release + //WM_Input_KeyFire(codepoint & KEY_CODEPOINT_MASK, scancode); + scancode = 0; + break; + case 0x40000000: // Key refire + //WM_Input_KeyUp(codepoint & KEY_CODEPOINT_MASK, scancode); + scancode = 0; + break; + case 0xC0000000: // Raw scancode + scancode = codepoint & KEY_CODEPOINT_MASK; + break; + } + } + + if( m_mouseFD != -1 && FD_ISSET(m_mouseFD, &rfds) ) + { + // TODO: Read mouse event and handle + } } -}; - }; // namespace AxWin