+ WM_SendMessage(NULL, Win, WNDMSG_MOUSEBTN, sizeof(msg), &msg);
+}
+
+void WM_Input_MouseButton(int X, int Y, int ButtonIndex, int Pressed)
+{
+ tWindow *win;
+
+ win = WM_int_GetWindowAtPos(X, Y);
+
+ // Handle press of primary button to change focus
+ if( ButtonIndex == 0 && Pressed == 1 )
+ {
+// _SysDebug("Gave focus to %p", win);
+ WM_FocusWindow(win);
+ tWindow *tmpwin = win;
+ while( tmpwin )
+ {
+ WM_RaiseWindow(tmpwin);
+ tmpwin = tmpwin->Parent;
+ }
+ }
+
+ // Make sure that even if the mouse has moved out of the original window,
+ // mouse release messages reach the window.
+ if( !Pressed && ButtonIndex < MAX_BUTTONS && gpWM_DownStartWindow[ButtonIndex] != win )
+ {
+ WM_Input_int_SendBtnMsg(gpWM_DownStartWindow[ButtonIndex], X, Y, ButtonIndex, 0);
+ }
+ if( Pressed && ButtonIndex < MAX_BUTTONS )
+ {
+ gpWM_DownStartWindow[ButtonIndex] = win;
+ }
+
+ // Send Press/Release message
+ WM_Input_int_SendBtnMsg(win, X, Y, ButtonIndex, Pressed);
+}
+
+void WM_Input_KeyDown(uint32_t Character, uint32_t Scancode)
+{
+ struct sWndMsg_KeyAction msg;
+
+ WM_Hotkey_KeyDown(Scancode);
+
+ msg.KeySym = Scancode;
+ msg.UCS32 = Character;
+ WM_SendMessage(NULL, gpWM_FocusedWindow, WNDMSG_KEYDOWN, sizeof(msg), &msg);
+}
+
+void WM_Input_KeyFire(uint32_t Character, uint32_t Scancode)
+{
+ struct sWndMsg_KeyAction msg;
+
+ // TODO: Properly translate into KeySyms and Unicode
+
+ msg.KeySym = Scancode;
+ msg.UCS32 = Character;
+ WM_SendMessage(NULL, gpWM_FocusedWindow, WNDMSG_KEYFIRE, sizeof(msg), &msg);
+}
+
+void WM_Input_KeyUp(uint32_t Character, uint32_t Scancode)
+{
+ struct sWndMsg_KeyAction msg;
+
+ WM_Hotkey_KeyUp(Scancode);
+
+ msg.KeySym = Scancode;
+ msg.UCS32 = Character;
+ WM_SendMessage(NULL, gpWM_FocusedWindow, WNDMSG_KEYUP, sizeof(msg), &msg);