Hi,
Attached is a patch adding two new input events DIET_DEVICEPLUG and
DIET_DEVICEUNPLUG
those events are dispatched each time an input device is plugged or
unplugged.
It also adds a new flag "[no-]input-device-notify" to enable/disable them.
regards
Haithem.
--
*
"If you ask a question - you will be a fool for 5 minutes, otherwise
ignorant for rest of your life"
*
diff --git a/include/directfb.h b/include/directfb.h
index a402818..c859423 100644
--- a/include/directfb.h
+++ b/include/directfb.h
@@ -5073,7 +5073,10 @@ typedef enum {
DIET_KEYRELEASE, /* a key is been released */
DIET_BUTTONPRESS, /* a (mouse) button is been pressed */
DIET_BUTTONRELEASE, /* a (mouse) button is been released */
- DIET_AXISMOTION /* mouse/joystick movement */
+ DIET_AXISMOTION, /* mouse/joystick movement */
+ DIET_DEVICEPLUG, /* a device has been plugged */
+ DIET_DEVICEUNPLUG /* a device has been unplugged */
+
} DFBInputEventType;
/*
diff --git a/src/core/input.c b/src/core/input.c
index 86ce072..b4d97a6 100644
--- a/src/core/input.c
+++ b/src/core/input.c
@@ -1728,6 +1728,21 @@ dfb_input_create_device(int device_index, CoreDFB *core_in, void *driver_in)
#else
local_processing_hotplug((const void *) &message, (void*) core_in);
#endif
+
+ /*
+ * Once Device registread, the DIET_DEVICEPLUG event is dispatched
+ */
+ if (dfb_config->device_plug_notify) {
+ DFBInputEvent event;
+
+ event.type = DIET_DEVICEPLUG;
+ event.device_id = dfb_input_device_id( device );
+
+ dfb_input_dispatch( device, &event );
+ }
+
+ dfb_input_dispatch (device, &event);
+
return DFB_OK;
errorExit:
@@ -1799,6 +1814,19 @@ dfb_input_remove_device(int device_index, void *driver_in)
D_DEBUG_AT(Core_Input, "Find the device with dev_id=%d\n", device_id);
+ /*
+ * Dispatch the DIET_DEVICEUNPLUG event before closing the device
+ */
+
+ if (dfb_config->device_plug_notify) {
+ DFBInputEvent event;
+
+ event.type = DIET_DEVICEUNPLUG;
+ event.device_id = dfb_input_device_id( device );
+
+ dfb_input_dispatch( device, &event );
+ }
+
device->driver->funcs->CloseDevice( device->driver_data );
if (core_local->hub)
diff --git a/src/misc/conf.c b/src/misc/conf.c
index 8ef4afd..c8bfd62 100644
--- a/src/misc/conf.c
+++ b/src/misc/conf.c
@@ -115,6 +115,7 @@ static const char *config_usage =
" linux-input-ir-only Ignore all non-IR Linux Input devices\n"
" [no-]linux-input-grab Grab Linux Input devices?\n"
" [no-]linux-input-force Force using linux-input with all system modules\n"
+ " [no-]input-device-notify Enable/disable input device plug/unplug notification\n"
" [no-]cursor Never create a cursor or handle it\n"
" [no-]cursor-automation Automated cursor show/hide for windowed primary surfaces\n"
" [no-]cursor-updates Never show a cursor, but still handle it\n"
@@ -455,6 +456,8 @@ static void config_allocate( void )
dfb_config->core_sighandler = true;
dfb_config->flip_notify_max_latency = 200;
+
+ dfb_config->device_plug_notify = false;
}
const char *dfb_config_usage( void )
@@ -898,6 +901,15 @@ DFBResult dfb_config_set( const char *name, const char *value )
if (strcmp (name, "no-linux-input-force" ) == 0) {
dfb_config->linux_input_force = false;
} else
+ if (strcmp (name, "input-device-notify" ) == 0) {
+ dfb_config->device_plug_notify = true;
+ } else
+ if (strcmp (name, "no-input-device-notify" ) == 0) {
+ dfb_config->device_plug_notify = false;
+ } else
+ if (strcmp (name, "motion-compression" ) == 0) {
+ dfb_config->mouse_motion_compression = true;
+ } else
if (strcmp (name, "motion-compression" ) == 0) {
dfb_config->mouse_motion_compression = true;
} else
diff --git a/src/misc/conf.h b/src/misc/conf.h
index 6427510..aca99d2 100644
--- a/src/misc/conf.h
+++ b/src/misc/conf.h
@@ -276,6 +276,7 @@ typedef struct
DFBWindowCursorFlags default_cursor_flags;
bool discard_repeat_events;
+ bool device_plug_notify;
} DFBConfig;
extern DFBConfig DIRECTFB_API *dfb_config;
diff --git a/wm/default/default.c b/wm/default/default.c
index 9c2bf41..c9391e9 100644
--- a/wm/default/default.c
+++ b/wm/default/default.c
@@ -3498,6 +3498,11 @@ wm_process_input( CoreWindowStack *stack,
ret = handle_axis_motion( stack, data, wm_data, event );
break;
+ case DIET_DEVICEPLUG:
+ case DIET_DEVICEUNPLUG:
+ ret = DFB_OK;
+ break;
+
default:
D_ONCE( "unknown input event type" );
ret = DFB_UNSUPPORTED;
_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev