Usermode/AxWin4 - Server implementation runnable
[tpg/acess2.git] / Usermode / Applications / axwin4_src / Server / input.cpp
1 /*
2  * Acess2 GUI v4
3  * - By John Hodge (thePowersGang)
4  *
5  * input.cpp
6  * - Input
7  */
8 #include <CConfigInput.hpp>
9 #include <input.hpp>
10 #include <CCompositor.hpp>
11 #include <algorithm>
12
13 namespace AxWin {
14
15 CInput::CInput(const ::AxWin::CConfigInput& config, CCompositor& compositor):
16         m_compositor(compositor),
17         m_keyboardFD(0),
18         m_mouseFD(-1)
19 {
20         
21 }
22
23 int CInput::FillSelect(::fd_set& rfds)
24 {
25         FD_SET(m_keyboardFD, &rfds);
26         if( m_mouseFD != -1 )
27                 FD_SET(m_mouseFD, &rfds);
28         return ::std::max(m_keyboardFD, m_mouseFD)+1;
29 }
30
31 void CInput::HandleSelect(::fd_set& rfds)
32 {
33         if( FD_ISSET(m_keyboardFD, &rfds) )
34         {
35                 uint32_t        codepoint;
36                 static uint32_t scancode;
37                 #define KEY_CODEPOINT_MASK      0x3FFFFFFF
38                 
39                 size_t readlen = _SysRead(m_keyboardFD, &codepoint, sizeof(codepoint));
40                 if( readlen != sizeof(codepoint) )
41                 {
42                         // oops, error
43                         _SysDebug("Terminal read failed? (%i != %i)", readlen, sizeof(codepoint));
44                 }
45         
46 //              _SysDebug("Keypress 0x%x", codepoint);
47         
48                 switch(codepoint & 0xC0000000)
49                 {
50                 case 0x00000000:        // Key pressed
51                         //WM_Input_KeyDown(codepoint & KEY_CODEPOINT_MASK, scancode);
52                 case 0x80000000:        // Key release
53                         //WM_Input_KeyFire(codepoint & KEY_CODEPOINT_MASK, scancode);
54                         scancode = 0;
55                         break;
56                 case 0x40000000:        // Key refire
57                         //WM_Input_KeyUp(codepoint & KEY_CODEPOINT_MASK, scancode);
58                         scancode = 0;
59                         break;
60                 case 0xC0000000:        // Raw scancode
61                         scancode = codepoint & KEY_CODEPOINT_MASK;
62                         break;
63                 }
64         }
65         
66         if( m_mouseFD != -1 && FD_ISSET(m_mouseFD, &rfds) )
67         {
68                 // TODO: Read mouse event and handle
69         }
70 }
71
72 };      // namespace AxWin
73

UCC git Repository :: git.ucc.asn.au