Skip to content

Commit

Permalink
add event node for all events
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Nyberg <jens.nyberg@gmail.com>
  • Loading branch information
jezze committed Apr 19, 2018
1 parent 7a8d22f commit 0d021ad
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
28 changes: 28 additions & 0 deletions src/modules/keyboard/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "keyboard.h"

static struct system_node root;
static struct system_node event;
static struct list eventstates;

void keyboard_notify(struct keyboard_interface *interface, void *buffer, unsigned int count)
{
Expand All @@ -24,6 +26,7 @@ void keyboard_notifypress(struct keyboard_interface *interface, unsigned char sc
message.header.destination = EVENT_ADDR_BROADCAST;
message.keypress.scancode = scancode;

event_multicast(&eventstates, &message.header, sizeof (struct event_header) + sizeof (struct event_keypress));
event_multicast(&interface->eventstates, &message.header, sizeof (struct event_header) + sizeof (struct event_keypress));

}
Expand All @@ -38,10 +41,29 @@ void keyboard_notifyrelease(struct keyboard_interface *interface, unsigned char
message.header.destination = EVENT_ADDR_BROADCAST;
message.keyrelease.scancode = scancode;

event_multicast(&eventstates, &message.header, sizeof (struct event_header) + sizeof (struct event_keyrelease));
event_multicast(&interface->eventstates, &message.header, sizeof (struct event_header) + sizeof (struct event_keyrelease));

}

static struct system_node *event_open(struct system_node *self, struct service_state *state)
{

list_add(&eventstates, &state->item);

return self;

}

static struct system_node *event_close(struct system_node *self, struct service_state *state)
{

list_remove(&eventstates, &state->item);

return self;

}

static struct system_node *interfacedata_open(struct system_node *self, struct service_state *state)
{

Expand Down Expand Up @@ -127,20 +149,26 @@ void module_init(void)
{

system_initnode(&root, SYSTEM_NODETYPE_GROUP, "keyboard");
system_initnode(&event, SYSTEM_NODETYPE_MAILBOX, "event");

event.open = event_open;
event.close = event_close;

}

void module_register(void)
{

system_registernode(&root);
system_addchild(&root, &event);

}

void module_unregister(void)
{

system_unregisternode(&root);
system_removechild(&root, &event);

}

28 changes: 28 additions & 0 deletions src/modules/mouse/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "mouse.h"

static struct system_node root;
static struct system_node event;
static struct list eventstates;

void mouse_notify(struct mouse_interface *interface, void *buffer, unsigned int count)
{
Expand All @@ -25,6 +27,7 @@ void mouse_notifymove(struct mouse_interface *interface, char relx, char rely)
message.mousemove.relx = relx;
message.mousemove.rely = rely;

event_multicast(&eventstates, &message.header, sizeof (struct event_header) + sizeof (struct event_mousemove));
event_multicast(&interface->eventstates, &message.header, sizeof (struct event_header) + sizeof (struct event_mousemove));

}
Expand All @@ -39,6 +42,7 @@ void mouse_notifypress(struct mouse_interface *interface, unsigned int button)
message.header.destination = EVENT_ADDR_BROADCAST;
message.mousepress.button = button;

event_multicast(&eventstates, &message.header, sizeof (struct event_header) + sizeof (struct event_mousepress));
event_multicast(&interface->eventstates, &message.header, sizeof (struct event_header) + sizeof (struct event_mousepress));

}
Expand All @@ -57,6 +61,24 @@ void mouse_notifyrelease(struct mouse_interface *interface, unsigned int button)

}

static struct system_node *event_open(struct system_node *self, struct service_state *state)
{

list_add(&eventstates, &state->item);

return self;

}

static struct system_node *event_close(struct system_node *self, struct service_state *state)
{

list_remove(&eventstates, &state->item);

return self;

}

static struct system_node *interfacedata_open(struct system_node *self, struct service_state *state)
{

Expand Down Expand Up @@ -142,20 +164,26 @@ void module_init(void)
{

system_initnode(&root, SYSTEM_NODETYPE_GROUP, "mouse");
system_initnode(&event, SYSTEM_NODETYPE_MAILBOX, "event");

event.open = event_open;
event.close = event_close;

}

void module_register(void)
{

system_registernode(&root);
system_addchild(&root, &event);

}

void module_unregister(void)
{

system_unregisternode(&root);
system_removechild(&root, &event);

}

4 changes: 2 additions & 2 deletions src/wm/wm.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,10 +793,10 @@ void main(void)
if (!file_walk(FILE_L2, "/system/wm/event"))
return;

if (!file_walk(FILE_L3, "/system/keyboard/if:0/event"))
if (!file_walk(FILE_L3, "/system/keyboard/event"))
return;

if (!file_walk(FILE_L4, "/system/mouse/if:0/event"))
if (!file_walk(FILE_L4, "/system/mouse/event"))
return;

if (!file_walk(FILE_L5, "/system/video/if:0/event"))
Expand Down

0 comments on commit 0d021ad

Please sign in to comment.