[PATCH 3/7] server: Add request for sending native raw-input messages.

Derek Lesho dereklesho52 at gmail.com
Tue Jun 25 22:32:05 CDT 2019


Signed-off-by: Derek Lesho <dereklesho52 at Gmail.com>
---
 server/protocol.def | 28 ++++++++++++++++++++++++++++
 server/queue.c      | 41 +++++++++++++++++++++++++++++++++++++++++
 server/trace.c      | 21 +++++++++++++++++++++
 tools/make_requests |  1 +
 4 files changed, 91 insertions(+)

diff --git a/server/protocol.def b/server/protocol.def
index 8b8a8a1512..3a6a202f49 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -358,6 +358,29 @@ typedef union
     } hw;
 } hw_input_t;
 
+typedef union
+{
+    int type;
+    struct
+    {
+        int type;                     /* RIM_TYPEMOUSE */
+        int x;                        /* relative x movement */
+        int y;                        /* relative y movement */
+        unsigned short button_flags;  /* mouse button */
+        unsigned short button_data;   /* event details */
+    } mouse;
+    struct
+    {
+        int type; /* RIM_TYPEKEYBOARD */
+        /* TODO: fill this in if/when necessary */
+    } kbd;
+    struct
+    {
+        int type; /* RIM_TYPEHID */
+        /* TODO: fill this in if/when necessary */
+    } hid;
+} hw_rawinput_t;
+
 typedef union
 {
     unsigned char            bytes[1];   /* raw data for sent messages */
@@ -2294,6 +2317,11 @@ enum message_type
 #define SEND_HWMSG_INJECTED    0x01
 
 
+ at REQ(send_rawinput_message)
+    hw_rawinput_t input;
+ at END
+
+
 /* Get a message from the current queue */
 @REQ(get_message)
     unsigned int    flags;     /* PM_* flags */
diff --git a/server/queue.c b/server/queue.c
index 5a001a87fe..26a2282809 100644
--- a/server/queue.c
+++ b/server/queue.c
@@ -2418,6 +2418,47 @@ DECL_HANDLER(send_hardware_message)
     release_object( desktop );
 }
 
+/* send a hardware rawinput message to the queue thread */
+DECL_HANDLER(send_rawinput_message)
+{
+    const struct rawinput_device *device;
+    struct hardware_msg_data *msg_data;
+    struct message *msg;
+    struct desktop *desktop;
+    struct hw_msg_source source = { IMDT_MOUSE, IMO_HARDWARE };
+
+    desktop = get_thread_desktop( current, 0 );
+
+    switch (req->input.type)
+    {
+    case RIM_TYPEMOUSE:
+        if ((device = current->process->rawinput_mouse))
+        {
+            if (!(msg = alloc_hardware_message( 0, source, 0 ))) return;
+            msg_data = msg->data;
+
+            msg->win       = device->target;
+            msg->msg       = WM_INPUT;
+            msg->wparam    = RIM_INPUT;
+            msg->lparam    = 0;
+
+            msg_data->flags               = 0;
+            msg_data->rawinput.type       = RIM_TYPEMOUSE;
+            msg_data->rawinput.mouse.x    = req->input.mouse.x;
+            msg_data->rawinput.mouse.y    = req->input.mouse.y;
+            msg_data->rawinput.mouse.button_flags = req->input.mouse.button_flags;
+            msg_data->rawinput.mouse.button_data = req->input.mouse.button_data;
+
+            queue_hardware_message( desktop, msg, 0 );
+        }
+        break;
+    default:
+        set_error( STATUS_INVALID_PARAMETER );
+    }
+
+    release_object(desktop);
+}
+
 /* post a quit message to the current queue */
 DECL_HANDLER(post_quit_message)
 {
diff --git a/server/trace.c b/server/trace.c
index 3562823659..bccab449cf 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -390,6 +390,27 @@ static void dump_hw_input( const char *prefix, const hw_input_t *input )
     }
 }
 
+static void dump_hw_rawinput( const char *prefix, const hw_rawinput_t *rawinput )
+{
+    switch (rawinput->type)
+    {
+    case RIM_TYPEMOUSE:
+        fprintf( stderr, "%s{type=MOUSE,x=%d,y=%d,button_flags=%04hx,button_data=%04hx}",
+                 prefix, rawinput->mouse.x, rawinput->mouse.y, rawinput->mouse.button_flags,
+                 rawinput->mouse.button_data);
+        break;
+    case RIM_TYPEKEYBOARD:
+        fprintf( stderr, "%s{type=KEYBOARD}\n", prefix);
+        break;
+    case RIM_TYPEHID:
+        fprintf( stderr, "%s{type=HID}\n", prefix);
+        break;
+    default:
+        fprintf( stderr, "%s{type=%04x}", prefix, rawinput->type);
+        break;
+    }
+}
+
 static void dump_luid( const char *prefix, const luid_t *luid )
 {
     fprintf( stderr, "%s%d.%u", prefix, luid->high_part, luid->low_part );
diff --git a/tools/make_requests b/tools/make_requests
index 367f245653..cf631923a7 100755
--- a/tools/make_requests
+++ b/tools/make_requests
@@ -53,6 +53,7 @@ my %formats =
     "ioctl_code_t"  => [  4,   4,  "&dump_ioctl_code" ],
     "cpu_type_t"    => [  4,   4,  "&dump_cpu_type" ],
     "hw_input_t"    => [  32,  8,  "&dump_hw_input" ],
+    "hw_rawinput_t" => [  16,  8,  "&dump_hw_rawinput" ]
 );
 
 my @requests = ();
-- 
2.21.0




More information about the wine-devel mailing list