Dorp last sync with wine and userhook 
Before we can sync with wine we need to rewrite the enum 
and reg of device so it working fine in reactos and windows.

Add svn rev 15043 + only userhooks for the mouse
at last the mouse are working in tribles windows mode
but in full screen it is bit chopy. Not tested tribles 
in reactos with the new code.
Modified: trunk/reactos/lib/dinput/Makefile.in
Modified: trunk/reactos/lib/dinput/data_formats.c
Modified: trunk/reactos/lib/dinput/device.c
Modified: trunk/reactos/lib/dinput/dinput_main.c
Modified: trunk/reactos/lib/dinput/dinput_private.h
Modified: trunk/reactos/lib/dinput/joystick_linux.c
Modified: trunk/reactos/lib/dinput/joystick_linuxinput.c
Modified: trunk/reactos/lib/dinput/keyboard.c
Modified: trunk/reactos/lib/dinput/mouse.c

Modified: trunk/reactos/lib/dinput/Makefile.in
--- trunk/reactos/lib/dinput/Makefile.in	2005-05-17 12:30:52 UTC (rev 15375)
+++ trunk/reactos/lib/dinput/Makefile.in	2005-05-17 15:20:24 UTC (rev 15376)
@@ -11,7 +11,7 @@
 	device.c \
 	dinput_main.c \
 	joystick_linux.c \
-	joystick_linuxinput.c \      
+	joystick_linuxinput.c \
 	keyboard.c \
 	mouse.c \
 	regsvr.c

Modified: trunk/reactos/lib/dinput/data_formats.c
--- trunk/reactos/lib/dinput/data_formats.c	2005-05-17 12:30:52 UTC (rev 15375)
+++ trunk/reactos/lib/dinput/data_formats.c	2005-05-17 15:20:24 UTC (rev 15376)
@@ -16,6 +16,10 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+/* TODO:
+ * add keyboard
+ */
+
 #include <stdarg.h>
 
 #include "windef.h"
@@ -23,7 +27,7 @@
 
 #define numObjects(x) (sizeof(x) / sizeof(x[0]))
 
-static const DIOBJECTDATAFORMAT dfDIJoystick[] = {
+DIOBJECTDATAFORMAT dfDIJoystick[] = {
   { &GUID_XAxis,DIJOFS_X,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   { &GUID_YAxis,DIJOFS_Y,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   { &GUID_ZAxis,DIJOFS_Z,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
@@ -76,10 +80,10 @@
     DIDF_ABSAXIS,
     sizeof(DIJOYSTATE2),
     numObjects(dfDIJoystick),
-    (LPDIOBJECTDATAFORMAT)dfDIJoystick
+    dfDIJoystick
 };
 
-static const DIOBJECTDATAFORMAT dfDIJoystick2[] = {
+DIOBJECTDATAFORMAT dfDIJoystick2[] = {
   { &GUID_XAxis,DIJOFS_X,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   { &GUID_YAxis,DIJOFS_Y,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
   { &GUID_ZAxis,DIJOFS_Z,DIDFT_OPTIONAL|DIDFT_AXIS|DIDFT_ANYINSTANCE,0},
@@ -252,10 +256,10 @@
     DIDF_ABSAXIS,
     sizeof(DIJOYSTATE2),
     numObjects(dfDIJoystick2),
-    (LPDIOBJECTDATAFORMAT)dfDIJoystick2
+    dfDIJoystick2
 };
 
-static const DIOBJECTDATAFORMAT dfDIMouse[] = {
+DIOBJECTDATAFORMAT dfDIMouse[] = {
   { &GUID_XAxis,  DIMOFS_X, DIDFT_ANYINSTANCE | DIDFT_AXIS, 0 },
   { &GUID_YAxis,  DIMOFS_Y, DIDFT_ANYINSTANCE | DIDFT_AXIS, 0 },
   { &GUID_ZAxis,  DIMOFS_Z, DIDFT_OPTIONAL | DIDFT_ANYINSTANCE | DIDFT_AXIS, 0 },
@@ -271,10 +275,10 @@
     DIDF_RELAXIS,
     sizeof(DIMOUSESTATE),
     numObjects(dfDIMouse),
-    (LPDIOBJECTDATAFORMAT)dfDIMouse
+    dfDIMouse
 };
 
-static const DIOBJECTDATAFORMAT dfDIMouse2[] = {
+DIOBJECTDATAFORMAT dfDIMouse2[] = {
   { &GUID_XAxis,  DIMOFS_X, DIDFT_ANYINSTANCE | DIDFT_AXIS, 0 },
   { &GUID_YAxis,  DIMOFS_Y, DIDFT_ANYINSTANCE | DIDFT_AXIS, 0 },
   { &GUID_ZAxis,  DIMOFS_Z, DIDFT_OPTIONAL | DIDFT_ANYINSTANCE | DIDFT_AXIS, 0 },
@@ -294,273 +298,5 @@
     DIDF_RELAXIS,
     sizeof(DIMOUSESTATE2),
     numObjects(dfDIMouse2),
-    (LPDIOBJECTDATAFORMAT)dfDIMouse2
+    dfDIMouse2
 };
-
-static const DIOBJECTDATAFORMAT dfDIKeyboard[] = {
-  { &GUID_Key,0,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(0),0},
-  { &GUID_Key,1,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(1),0},
-  { &GUID_Key,2,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(2),0},
-  { &GUID_Key,3,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(3),0},
-  { &GUID_Key,4,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(4),0},
-  { &GUID_Key,5,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(5),0},
-  { &GUID_Key,6,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(6),0},
-  { &GUID_Key,7,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(7),0},
-  { &GUID_Key,8,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(8),0},
-  { &GUID_Key,9,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(9),0},
-  { &GUID_Key,10,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(10),0},
-  { &GUID_Key,11,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(11),0},
-  { &GUID_Key,12,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(12),0},
-  { &GUID_Key,13,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(13),0},
-  { &GUID_Key,14,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(14),0},
-  { &GUID_Key,15,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(15),0},
-  { &GUID_Key,16,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(16),0},
-  { &GUID_Key,17,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(17),0},
-  { &GUID_Key,18,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(18),0},
-  { &GUID_Key,19,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(19),0},
-  { &GUID_Key,20,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(20),0},
-  { &GUID_Key,21,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(21),0},
-  { &GUID_Key,22,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(22),0},
-  { &GUID_Key,23,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(23),0},
-  { &GUID_Key,24,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(24),0},
-  { &GUID_Key,25,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(25),0},
-  { &GUID_Key,26,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(26),0},
-  { &GUID_Key,27,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(27),0},
-  { &GUID_Key,28,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(28),0},
-  { &GUID_Key,29,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(29),0},
-  { &GUID_Key,30,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(30),0},
-  { &GUID_Key,31,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(31),0},
-  { &GUID_Key,32,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(32),0},
-  { &GUID_Key,33,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(33),0},
-  { &GUID_Key,34,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(34),0},
-  { &GUID_Key,35,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(35),0},
-  { &GUID_Key,36,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(36),0},
-  { &GUID_Key,37,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(37),0},
-  { &GUID_Key,38,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(38),0},
-  { &GUID_Key,39,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(39),0},
-  { &GUID_Key,40,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(40),0},
-  { &GUID_Key,41,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(41),0},
-  { &GUID_Key,42,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(42),0},
-  { &GUID_Key,43,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(43),0},
-  { &GUID_Key,44,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(44),0},
-  { &GUID_Key,45,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(45),0},
-  { &GUID_Key,46,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(46),0},
-  { &GUID_Key,47,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(47),0},
-  { &GUID_Key,48,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(48),0},
-  { &GUID_Key,49,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(49),0},
-  { &GUID_Key,50,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(50),0},
-  { &GUID_Key,51,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(51),0},
-  { &GUID_Key,52,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(52),0},
-  { &GUID_Key,53,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(53),0},
-  { &GUID_Key,54,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(54),0},
-  { &GUID_Key,55,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(55),0},
-  { &GUID_Key,56,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(56),0},
-  { &GUID_Key,57,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(57),0},
-  { &GUID_Key,58,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(58),0},
-  { &GUID_Key,59,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(59),0},
-  { &GUID_Key,60,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(60),0},
-  { &GUID_Key,61,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(61),0},
-  { &GUID_Key,62,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(62),0},
-  { &GUID_Key,63,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(63),0},
-  { &GUID_Key,64,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(64),0},
-  { &GUID_Key,65,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(65),0},
-  { &GUID_Key,66,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(66),0},
-  { &GUID_Key,67,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(67),0},
-  { &GUID_Key,68,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(68),0},
-  { &GUID_Key,69,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(69),0},
-  { &GUID_Key,70,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(70),0},
-  { &GUID_Key,71,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(71),0},
-  { &GUID_Key,72,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(72),0},
-  { &GUID_Key,73,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(73),0},
-  { &GUID_Key,74,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(74),0},
-  { &GUID_Key,75,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(75),0},
-  { &GUID_Key,76,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(76),0},
-  { &GUID_Key,77,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(77),0},
-  { &GUID_Key,78,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(78),0},
-  { &GUID_Key,79,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(79),0},
-  { &GUID_Key,80,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(80),0},
-  { &GUID_Key,81,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(81),0},
-  { &GUID_Key,82,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(82),0},
-  { &GUID_Key,83,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(83),0},
-  { &GUID_Key,84,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(84),0},
-  { &GUID_Key,85,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(85),0},
-  { &GUID_Key,86,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(86),0},
-  { &GUID_Key,87,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(87),0},
-  { &GUID_Key,88,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(88),0},
-  { &GUID_Key,89,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(89),0},
-  { &GUID_Key,90,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(90),0},
-  { &GUID_Key,91,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(91),0},
-  { &GUID_Key,92,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(92),0},
-  { &GUID_Key,93,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(93),0},
-  { &GUID_Key,94,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(94),0},
-  { &GUID_Key,95,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(95),0},
-  { &GUID_Key,96,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(96),0},
-  { &GUID_Key,97,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(97),0},
-  { &GUID_Key,98,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(98),0},
-  { &GUID_Key,99,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(99),0},
-  { &GUID_Key,100,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(100),0},
-  { &GUID_Key,101,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(101),0},
-  { &GUID_Key,102,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(102),0},
-  { &GUID_Key,103,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(103),0},
-  { &GUID_Key,104,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(104),0},
-  { &GUID_Key,105,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(105),0},
-  { &GUID_Key,106,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(106),0},
-  { &GUID_Key,107,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(107),0},
-  { &GUID_Key,108,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(108),0},
-  { &GUID_Key,109,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(109),0},
-  { &GUID_Key,110,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(110),0},
-  { &GUID_Key,111,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(111),0},
-  { &GUID_Key,112,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(112),0},
-  { &GUID_Key,113,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(113),0},
-  { &GUID_Key,114,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(114),0},
-  { &GUID_Key,115,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(115),0},
-  { &GUID_Key,116,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(116),0},
-  { &GUID_Key,117,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(117),0},
-  { &GUID_Key,118,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(118),0},
-  { &GUID_Key,119,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(119),0},
-  { &GUID_Key,120,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(120),0},
-  { &GUID_Key,121,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(121),0},
-  { &GUID_Key,122,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(122),0},
-  { &GUID_Key,123,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(123),0},
-  { &GUID_Key,124,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(124),0},
-  { &GUID_Key,125,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(125),0},
-  { &GUID_Key,126,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(126),0},
-  { &GUID_Key,127,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(127),0},
-  { &GUID_Key,128,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(128),0},
-  { &GUID_Key,129,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(129),0},
-  { &GUID_Key,130,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(130),0},
-  { &GUID_Key,131,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(131),0},
-  { &GUID_Key,132,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(132),0},
-  { &GUID_Key,133,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(133),0},
-  { &GUID_Key,134,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(134),0},
-  { &GUID_Key,135,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(135),0},
-  { &GUID_Key,136,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(136),0},
-  { &GUID_Key,137,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(137),0},
-  { &GUID_Key,138,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(138),0},
-  { &GUID_Key,139,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(139),0},
-  { &GUID_Key,140,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(140),0},
-  { &GUID_Key,141,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(141),0},
-  { &GUID_Key,142,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(142),0},
-  { &GUID_Key,143,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(143),0},
-  { &GUID_Key,144,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(144),0},
-  { &GUID_Key,145,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(145),0},
-  { &GUID_Key,146,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(146),0},
-  { &GUID_Key,147,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(147),0},
-  { &GUID_Key,148,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(148),0},
-  { &GUID_Key,149,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(149),0},
-  { &GUID_Key,150,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(150),0},
-  { &GUID_Key,151,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(151),0},
-  { &GUID_Key,152,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(152),0},
-  { &GUID_Key,153,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(153),0},
-  { &GUID_Key,154,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(154),0},
-  { &GUID_Key,155,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(155),0},
-  { &GUID_Key,156,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(156),0},
-  { &GUID_Key,157,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(157),0},
-  { &GUID_Key,158,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(158),0},
-  { &GUID_Key,159,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(159),0},
-  { &GUID_Key,160,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(160),0},
-  { &GUID_Key,161,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(161),0},
-  { &GUID_Key,162,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(162),0},
-  { &GUID_Key,163,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(163),0},
-  { &GUID_Key,164,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(164),0},
-  { &GUID_Key,165,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(165),0},
-  { &GUID_Key,166,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(166),0},
-  { &GUID_Key,167,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(167),0},
-  { &GUID_Key,168,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(168),0},
-  { &GUID_Key,169,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(169),0},
-  { &GUID_Key,170,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(170),0},
-  { &GUID_Key,171,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(171),0},
-  { &GUID_Key,172,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(172),0},
-  { &GUID_Key,173,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(173),0},
-  { &GUID_Key,174,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(174),0},
-  { &GUID_Key,175,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(175),0},
-  { &GUID_Key,176,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(176),0},
-  { &GUID_Key,177,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(177),0},
-  { &GUID_Key,178,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(178),0},
-  { &GUID_Key,179,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(179),0},
-  { &GUID_Key,180,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(180),0},
-  { &GUID_Key,181,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(181),0},
-  { &GUID_Key,182,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(182),0},
-  { &GUID_Key,183,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(183),0},
-  { &GUID_Key,184,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(184),0},
-  { &GUID_Key,185,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(185),0},
-  { &GUID_Key,186,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(186),0},
-  { &GUID_Key,187,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(187),0},
-  { &GUID_Key,188,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(188),0},
-  { &GUID_Key,189,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(189),0},
-  { &GUID_Key,190,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(190),0},
-  { &GUID_Key,191,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(191),0},
-  { &GUID_Key,192,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(192),0},
-  { &GUID_Key,193,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(193),0},
-  { &GUID_Key,194,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(194),0},
-  { &GUID_Key,195,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(195),0},
-  { &GUID_Key,196,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(196),0},
-  { &GUID_Key,197,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(197),0},
-  { &GUID_Key,198,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(198),0},
-  { &GUID_Key,199,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(199),0},
-  { &GUID_Key,200,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(200),0},
-  { &GUID_Key,201,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(201),0},
-  { &GUID_Key,202,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(202),0},
-  { &GUID_Key,203,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(203),0},
-  { &GUID_Key,204,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(204),0},
-  { &GUID_Key,205,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(205),0},
-  { &GUID_Key,206,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(206),0},
-  { &GUID_Key,207,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(207),0},
-  { &GUID_Key,208,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(208),0},
-  { &GUID_Key,209,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(209),0},
-  { &GUID_Key,210,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(210),0},
-  { &GUID_Key,211,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(211),0},
-  { &GUID_Key,212,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(212),0},
-  { &GUID_Key,213,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(213),0},
-  { &GUID_Key,214,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(214),0},
-  { &GUID_Key,215,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(215),0},
-  { &GUID_Key,216,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(216),0},
-  { &GUID_Key,217,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(217),0},
-  { &GUID_Key,218,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(218),0},
-  { &GUID_Key,219,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(219),0},
-  { &GUID_Key,220,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(220),0},
-  { &GUID_Key,221,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(221),0},
-  { &GUID_Key,222,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(222),0},
-  { &GUID_Key,223,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(223),0},
-  { &GUID_Key,224,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(224),0},
-  { &GUID_Key,225,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(225),0},
-  { &GUID_Key,226,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(226),0},
-  { &GUID_Key,227,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(227),0},
-  { &GUID_Key,228,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(228),0},
-  { &GUID_Key,229,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(229),0},
-  { &GUID_Key,230,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(230),0},
-  { &GUID_Key,231,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(231),0},
-  { &GUID_Key,232,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(232),0},
-  { &GUID_Key,233,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(233),0},
-  { &GUID_Key,234,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(234),0},
-  { &GUID_Key,235,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(235),0},
-  { &GUID_Key,236,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(236),0},
-  { &GUID_Key,237,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(237),0},
-  { &GUID_Key,238,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(238),0},
-  { &GUID_Key,239,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(239),0},
-  { &GUID_Key,240,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(240),0},
-  { &GUID_Key,241,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(241),0},
-  { &GUID_Key,242,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(242),0},
-  { &GUID_Key,243,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(243),0},
-  { &GUID_Key,244,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(244),0},
-  { &GUID_Key,245,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(245),0},
-  { &GUID_Key,246,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(246),0},
-  { &GUID_Key,247,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(247),0},
-  { &GUID_Key,248,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(248),0},
-  { &GUID_Key,249,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(249),0},
-  { &GUID_Key,250,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(250),0},
-  { &GUID_Key,251,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(251),0},
-  { &GUID_Key,252,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(252),0},
-  { &GUID_Key,253,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(253),0},
-  { &GUID_Key,254,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(254),0},
-  { &GUID_Key,255,DIDFT_OPTIONAL|DIDFT_BUTTON|DIDFT_MAKEINSTANCE(255),0}
-};
-
-const DIDATAFORMAT c_dfDIKeyboard = {
-    sizeof(DIDATAFORMAT),
-    sizeof(DIOBJECTDATAFORMAT),
-    DIDF_RELAXIS,
-    256,
-    numObjects(dfDIKeyboard),
-    (LPDIOBJECTDATAFORMAT)dfDIKeyboard
-};

Modified: trunk/reactos/lib/dinput/device.c
--- trunk/reactos/lib/dinput/device.c	2005-05-17 12:30:52 UTC (rev 15375)
+++ trunk/reactos/lib/dinput/device.c	2005-05-17 15:20:24 UTC (rev 15376)
@@ -290,12 +290,12 @@
     int index = 0;
     DWORD next = 0;
     
-    ret = HeapAlloc(GetProcessHeap(), 0, sizeof(DataFormat));
+    ret = (DataFormat *) HeapAlloc(GetProcessHeap(), 0, sizeof(DataFormat));
     
-    done = HeapAlloc(GetProcessHeap(), 0, sizeof(int) * asked_format->dwNumObjs);
+    done = (int *) HeapAlloc(GetProcessHeap(), 0, sizeof(int) * asked_format->dwNumObjs);
     memset(done, 0, sizeof(int) * asked_format->dwNumObjs);
     
-    dt = HeapAlloc(GetProcessHeap(), 0, asked_format->dwNumObjs * sizeof(DataTransform));
+    dt = (DataTransform *) HeapAlloc(GetProcessHeap(), 0, asked_format->dwNumObjs * sizeof(DataTransform));
     
     TRACE("Creating DataTransform : \n");
     

Modified: trunk/reactos/lib/dinput/dinput_main.c
--- trunk/reactos/lib/dinput/dinput_main.c	2005-05-17 12:30:52 UTC (rev 15375)
+++ trunk/reactos/lib/dinput/dinput_main.c	2005-05-17 15:20:24 UTC (rev 15376)
@@ -53,14 +53,10 @@
 static IDirectInput8AVtbl ddi8avt;
 static IDirectInput8WVtbl ddi8wvt;
 
-static const struct dinput_device *dinput_devices[] =
-{
-    &mouse_device,
-    &keyboard_device,
-    &joystick_linuxinput_device,
-    &joystick_linux_device
-};
-#define NB_DINPUT_DEVICES (sizeof(dinput_devices)/sizeof(dinput_devices[0]))
+/* This array will be filled a dinput.so loading */
+#define MAX_WINE_DINPUT_DEVICES 4
+static dinput_device * dinput_devices[MAX_WINE_DINPUT_DEVICES];
+static int nrof_dinput_devices = 0;
 
 HINSTANCE DINPUT_instance = NULL;
 
@@ -78,8 +74,29 @@
     return TRUE;
 }
 
+/* register a direct draw driver. We better not use malloc for we are in
+ * the ELF startup initialisation at this point.
+ */
+void dinput_register_device(dinput_device *device) {
+    int	i;
 
+    /* insert according to priority */
+    for (i=0;i<nrof_dinput_devices;i++) {
+	if (dinput_devices[i]->pref <= device->pref) {
+	    memcpy(dinput_devices+i+1,dinput_devices+i,sizeof(dinput_devices[0])*(nrof_dinput_devices-i));
+	    dinput_devices[i] = device;
+	    break;
+	}
+    }
+    if (i==nrof_dinput_devices)	/* not found, or too low priority */
+	dinput_devices[nrof_dinput_devices] = device;
 
+    nrof_dinput_devices++;
+
+    /* increase MAX_DDRAW_DRIVERS if the line below triggers */
+    assert(nrof_dinput_devices <= MAX_WINE_DINPUT_DEVICES);
+}
+
 /******************************************************************************
  *	DirectInputCreateEx (DINPUT.@)
  */
@@ -94,7 +111,7 @@
 	if (IsEqualGUID(&IID_IDirectInputA,riid) ||
 	    IsEqualGUID(&IID_IDirectInput2A,riid) ||
 	    IsEqualGUID(&IID_IDirectInput7A,riid)) {
-	  This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
+	  This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
 	  This->lpVtbl = &ddi7avt;
 	  This->ref = 1;
 	  This->version = 1;
@@ -106,7 +123,7 @@
 	if (IsEqualGUID(&IID_IDirectInputW,riid) ||
 	    IsEqualGUID(&IID_IDirectInput2W,riid) ||
 	    IsEqualGUID(&IID_IDirectInput7W,riid)) {
-	  This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
+	  This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
 	  This->lpVtbl = &ddi7wvt;
 	  This->ref = 1;
 	  This->version = 1;
@@ -116,7 +133,7 @@
 	}
 
 	if (IsEqualGUID(&IID_IDirectInput8A,riid)) {
-	  This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
+	  This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
 	  This->lpVtbl = &ddi8avt;
 	  This->ref = 1;
 	  This->version = 8;
@@ -126,7 +143,7 @@
 	}
 
 	if (IsEqualGUID(&IID_IDirectInput8W,riid)) {
-	  This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
+	  This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
 	  This->lpVtbl = &ddi8wvt;
 	  This->ref = 1;
 	  This->version = 8;
@@ -147,7 +164,7 @@
 	TRACE("(0x%08lx,%04lx,%p,%p)\n", (DWORD)hinst,dwVersion,ppDI,punkOuter);
 
 	//trace:dinput:DirectInputCreateA (0x00400000,0500,0x42bafc54,(nil))
-	This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
+	This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
 	This->lpVtbl = &ddi7avt;
 	This->ref = 1;
 	if (dwVersion > 0x0700) {
@@ -168,7 +185,7 @@
 {
 	IDirectInputImpl* This;
 	TRACE("(0x%08lx,%04lx,%p,%p)\n", (DWORD)hinst,dwVersion,ppDI,punkOuter);
-	This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
+	This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
 	This->lpVtbl = &ddi7wvt;
 	This->ref = 1;
 	if (dwVersion >= 0x0800) {
@@ -185,7 +202,7 @@
     switch (dwDevType) {
         case 0: return "All devices";
 	case DIDEVTYPE_MOUSE: return "DIDEVTYPE_MOUSE";
-	case DIDEVTYPE_KEYBOARD: return "DIDEVTYPE_KEYBOARD";    
+	case DIDEVTYPE_KEYBOARD: return "DIDEVTYPE_KEYBOARD";
 	case DIDEVTYPE_JOYSTICK: return "DIDEVTYPE_JOYSTICK";
 	case DIDEVTYPE_DEVICE: return "DIDEVTYPE_DEVICE";
 	default: return "Unkown";
@@ -231,22 +248,16 @@
     TRACE("(this=%p,0x%04lx '%s',%p,%p,%04lx)\n",
 	  This, dwDevType, _dump_DIDEVTYPE_value(dwDevType),
 	  lpCallback, pvRef, dwFlags);
-#ifdef __REACTOS__
-	/* hack geting keyboard and mouse working */
-	if (NB_DINPUT_DEVICES==0){
+
+	if (nrof_dinput_devices==0){
 	  scan_mouse();
 	  scan_keyboard();
 	}
-#endif	
+	
     TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n");
     
 
-    for (i = 0; i < NB_DINPUT_DEVICES; i++) {
-#ifndef __REACTOS__   
-		/* Wine Dinput does not support windows enum 
-		   we need a hack here                     */
-        if (!dinput_devices[i]->enum_deviceA) continue;
-#endif
+    for (i = 0; i < nrof_dinput_devices; i++) {
         for (j = 0, r = -1; r != 0; j++) {
 	    devInstance.dwSize = sizeof(devInstance);
 	    TRACE("  - checking device %d ('%s')\n", i, dinput_devices[i]->name);
@@ -272,13 +283,10 @@
     DIDEVICEINSTANCEW devInstance;
     int i, j, r;
     
-#ifdef __REACTOS__
-	/* hack geting keyboard and mouse working */
-	if (NB_DINPUT_DEVICES==0){
+		if (nrof_dinput_devices==0){
 	  scan_mouse();
 	  scan_keyboard();
 	}
-#endif	
 
     TRACE("(this=%p,0x%04lx '%s',%p,%p,%04lx)\n",
 	  This, dwDevType, _dump_DIDEVTYPE_value(dwDevType),
@@ -286,13 +294,7 @@
     TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n");
 
 
-    for (i = 0; i < NB_DINPUT_DEVICES; i++) {
-#ifndef __REACTOS__   
-		/* Wine Dinput does not support windows enum 
-		   we need a hack here                     */
-        if (!dinput_devices[i]->enum_deviceW) continue;
-#endif
-
+    for (i = 0; i < nrof_dinput_devices; i++) {
         for (j = 0, r = -1; r != 0; j++) {
 	    devInstance.dwSize = sizeof(devInstance);
 	    TRACE("  - checking device %d ('%s')\n", i, dinput_devices[i]->name);
@@ -364,20 +366,14 @@
 
 	TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
 	
-#ifdef __REACTOS__
-	/* hack geting keyboard and mouse working */
-	if (NB_DINPUT_DEVICES==0){
+	if (nrof_dinput_devices==0){
 	  scan_mouse();
 	  scan_keyboard();
 	}
-#endif	
 	
 	/* Loop on all the devices to see if anyone matches the given GUID */
-	for (i = 0; i < NB_DINPUT_DEVICES; i++) {
+	for (i = 0; i < nrof_dinput_devices; i++) {
 	  HRESULT ret;
-#ifndef __REACTOS__        
-	  if (!dinput_devices[i]->create_deviceA) continue; 
-#endif
 	  if ((ret = dinput_devices[i]->create_deviceA(This, rguid, NULL, pdev)) == DI_OK)
 	    return DI_OK;
 
@@ -396,20 +392,14 @@
     
 	TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
 
-#ifdef __REACTOS__
-	/* hack geting keyboard and mouse working */
-	if (NB_DINPUT_DEVICES==0){
+	if (nrof_dinput_devices==0){
 	  scan_mouse();
 	  scan_keyboard();
 	}
-#endif	
 	
 	/* Loop on all the devices to see if anyone matches the given GUID */
-	for (i = 0; i < NB_DINPUT_DEVICES; i++) {
+	for (i = 0; i < nrof_dinput_devices; i++) {
 	  HRESULT ret;
-#ifndef __REACTOS__
-	  if (!dinput_devices[i]->create_deviceW) continue;
-#endif
 	  if ((ret = dinput_devices[i]->create_deviceW(This, rguid, NULL, pdev)) == DI_OK)
 	    return DI_OK;
 
@@ -467,20 +457,14 @@
 
   TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
 
-#ifdef __REACTOS__
-	/* hack geting keyboard and mouse working */
-	if (NB_DINPUT_DEVICES==0){
-	  scan_mouse();
-	  scan_keyboard();
-	}
-#endif	
+  if (nrof_dinput_devices==0){
+    scan_mouse();
+    scan_keyboard();
+  }  
 
   /* Loop on all the devices to see if anyone matches the given GUID */
-  for (i = 0; i < NB_DINPUT_DEVICES; i++) {
+  for (i = 0; i < nrof_dinput_devices; i++) {
     HRESULT ret;
-#ifndef __REACTOS__
-    if (!dinput_devices[i]->create_deviceA) continue;
-#endif
     if ((ret = dinput_devices[i]->create_deviceA(This, rguid, riid, (LPDIRECTINPUTDEVICEA*) pvOut)) == DI_OK)
       return DI_OK;
 
@@ -500,7 +484,7 @@
 
   TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
 
-  	if (NB_DINPUT_DEVICES==0){
+  	if (nrof_dinput_devices==0){
 	  scan_mouse();
 	  scan_keyboard();
 	}
@@ -508,11 +492,8 @@
 
 
   /* Loop on all the devices to see if anyone matches the given GUID */
-  for (i = 0; i < NB_DINPUT_DEVICES; i++) {
+  for (i = 0; i < nrof_dinput_devices; i++) {
     HRESULT ret;
-#ifndef __REACTOS__
-    if (!dinput_devices[i]->create_deviceW) continue;
-#endif
     if ((ret = dinput_devices[i]->create_deviceW(This, rguid, riid, (LPDIRECTINPUTDEVICEW*) pvOut)) == DI_OK)
       return DI_OK;
 

Modified: trunk/reactos/lib/dinput/dinput_private.h
--- trunk/reactos/lib/dinput/dinput_private.h	2005-05-17 12:30:52 UTC (rev 15375)
+++ trunk/reactos/lib/dinput/dinput_private.h	2005-05-17 15:20:24 UTC (rev 15376)
@@ -39,18 +39,16 @@
 };
 
 /* Function called by all devices that Wine supports */
-struct dinput_device {
+typedef struct dinput_device {
+    INT pref;
     const char *name;
     BOOL (*enum_deviceA)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version, int id);
     BOOL (*enum_deviceW)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version, int id);
     HRESULT (*create_deviceA)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev);
     HRESULT (*create_deviceW)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev);
-};
+} dinput_device;
 
-extern const struct dinput_device mouse_device;
-extern const struct dinput_device keyboard_device;
-extern const struct dinput_device joystick_linux_device;
-extern const struct dinput_device joystick_linuxinput_device;
+extern void dinput_register_device(dinput_device *device);
 
 extern HINSTANCE DINPUT_instance;
 

Modified: trunk/reactos/lib/dinput/joystick_linux.c
--- trunk/reactos/lib/dinput/joystick_linux.c	2005-05-17 12:30:52 UTC (rev 15375)
+++ trunk/reactos/lib/dinput/joystick_linux.c	2005-05-17 15:20:24 UTC (rev 15376)
@@ -28,6 +28,8 @@
 #include "config.h"
 #include "wine/port.h"
 
+#ifdef HAVE_LINUX_22_JOYSTICK_API
+
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
@@ -53,6 +55,7 @@
 #ifdef HAVE_LINUX_JOYSTICK_H
 # include <linux/joystick.h>
 #endif
+#define JOYDEV	"/dev/js"
 
 #include "wine/debug.h"
 #include "wine/unicode.h"
@@ -67,10 +70,6 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
 
-#ifdef HAVE_LINUX_22_JOYSTICK_API
-
-#define JOYDEV "/dev/js"
-
 typedef struct {
     LONG lMin;
     LONG lMax;
@@ -647,7 +646,8 @@
   return DIERR_DEVICENOTREG;
 }
 
-const struct dinput_device joystick_linux_device = {
+static dinput_device joydev = {
+  10,
   "Wine Linux joystick driver",
   joydev_enum_deviceA,
   joydev_enum_deviceW,
@@ -655,8 +655,10 @@
   joydev_create_deviceW
 };
 
+DECL_GLOBAL_CONSTRUCTOR(joydev_register) { dinput_register_device(&joydev); }
 
 
+
 /******************************************************************************
  *	Joystick
  */
@@ -1695,14 +1697,4 @@
 };
 #undef XCAST
 
-#else  /* HAVE_LINUX_22_JOYSTICK_API */
-
-const struct dinput_device joystick_linux_device = {
-  "Wine Linux joystick driver",
-  NULL,
-  NULL,
-  NULL,
-  NULL
-};
-
 #endif  /* HAVE_LINUX_22_JOYSTICK_API */

Modified: trunk/reactos/lib/dinput/joystick_linuxinput.c
--- trunk/reactos/lib/dinput/joystick_linuxinput.c	2005-05-17 12:30:52 UTC (rev 15375)
+++ trunk/reactos/lib/dinput/joystick_linuxinput.c	2005-05-17 15:20:24 UTC (rev 15376)
@@ -22,6 +22,8 @@
 #include "config.h"
 #include "wine/port.h"
 
+#ifdef HAVE_LINUX_INPUT_H
+
 #include <assert.h>
 #include <stdarg.h>
 #include <stdio.h>
@@ -41,10 +43,16 @@
 #ifdef HAVE_SYS_ERRNO_H
 # include <sys/errno.h>
 #endif
+
+#ifdef HAVE_CORRECT_LINUXINPUT_H
+
 #ifdef HAVE_LINUX_INPUT_H
 # include <linux/input.h>
 #endif
 
+
+#define EVDEVPREFIX	"/dev/input/event"
+
 #include "wine/debug.h"
 #include "wine/unicode.h"
 #include "windef.h"
@@ -57,10 +65,6 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
 
-#ifdef HAVE_CORRECT_LINUXINPUT_H
-
-#define EVDEVPREFIX	"/dev/input/event"
-
 /* Wine joystick driver object instances */
 #define WINE_JOYSTICK_AXIS_BASE   0
 #define WINE_JOYSTICK_BUTTON_BASE 8
@@ -318,7 +322,8 @@
   return DIERR_DEVICENOTREG;
 }
 
-const struct dinput_device joystick_linuxinput_device = {
+static dinput_device joydev = {
+  20,
   "Wine Linux-input joystick driver",
   joydev_enum_deviceA,
   joydev_enum_deviceW,
@@ -326,6 +331,8 @@
   joydev_create_deviceW
 };
 
+DECL_GLOBAL_CONSTRUCTOR(joydev_register) { dinput_register_device(&joydev); }
+
 /******************************************************************************
  *	Joystick
  */
@@ -971,7 +978,7 @@
 {
   JoystickImpl *This = (JoystickImpl *)iface;
 
-  TRACE("(this=%p,%s,%p)\n",
+  TRACE("(this=%p,%s,%p): stub!\n",
 	iface, debugstr_guid(rguid), pdiph);
 
   if (TRACE_ON(dinput))
@@ -1087,14 +1094,6 @@
 };
 #undef XCAST
 
-#else  /* HAVE_CORRECT_LINUXINPUT_H */
+#endif  /* HAVE_LINUX_INPUT_H */
 
-const struct dinput_device joystick_linuxinput_device = {
-  "Wine Linux-input joystick driver",
-  NULL,
-  NULL,
-  NULL,
-  NULL
-};
-
-#endif  /* HAVE_CORRECT_LINUXINPUT_H */
+#endif

Modified: trunk/reactos/lib/dinput/keyboard.c
--- trunk/reactos/lib/dinput/keyboard.c	2005-05-17 12:30:52 UTC (rev 15375)
+++ trunk/reactos/lib/dinput/keyboard.c	2005-05-17 15:20:24 UTC (rev 15376)
@@ -3,7 +3,6 @@
  * Copyright 1998 Marcus Meissner
  * Copyright 1998,1999 Lionel Ulmer
  * Copyright 2000-2001 TransGaming Technologies Inc.
- * Copyright 2005 Raphael Junqueira
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -38,7 +37,10 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
 
-#define WINE_DINPUT_KEYBOARD_MAX_KEYS 256
+//fast fix misning from mingw headers
+#ifdef __REACTOS__
+#define LLKHF_INJECTED       0x00000010
+#endif
 
 static IDirectInputDevice8AVtbl SysKeyboardAvt;
 static IDirectInputDevice8WVtbl SysKeyboardWvt;
@@ -68,15 +70,14 @@
         CRITICAL_SECTION                crit;
 };
 
-static SysKeyboardImpl* current_lock = NULL; 
-/* Today's acquired device
- * FIXME: currently this can be only one.
- * Maybe this should be a linked list or st.
- * I don't know what the rules are for multiple acquired keyboards,
- * but 'DI_LOSTFOCUS' and 'DI_UNACQUIRED' exist for a reason.
+SysKeyboardImpl *current; /* Today's acquired device
+FIXME: currently this can be only one.
+Maybe this should be a linked list or st.
+I don't know what the rules are for multiple acquired keyboards,
+but 'DI_LOSTFOCUS' and 'DI_UNACQUIRED' exist for a reason.
 */
 
-static BYTE DInputKeyState[WINE_DINPUT_KEYBOARD_MAX_KEYS]; /* array for 'GetDeviceState' */
+static BYTE DInputKeyState[256]; /* array for 'GetDeviceState' */
 
 static CRITICAL_SECTION keyboard_crit;
 static CRITICAL_SECTION_DEBUG critsect_debug =
@@ -87,65 +88,118 @@
 };
 static CRITICAL_SECTION keyboard_crit = { &critsect_debug, -1, 0, 0, 0, 0 };
 
-static DWORD keyboard_users = 0;
-static HHOOK keyboard_hook = NULL;
+static DWORD keyboard_users;
 
-LRESULT CALLBACK KeyboardCallback( int code, WPARAM wparam, LPARAM lparam )
+#ifndef __REACTOS__
+static HHOOK keyboard_hook;
+#endif
+
+#ifdef __REACTOS__
+void reactos_input_keyboard();
+
+void reactos_input_keyboard()
 {
-  BYTE dik_code;
+  MSG msg;
+  BOOL fDone;
+  int disk_code = -1;
   BOOL down;
-  DWORD timestamp;
-  KBDLLHOOKSTRUCT *hook = (KBDLLHOOKSTRUCT *)lparam;
-  BYTE new_diks;
-
-  TRACE("(%d,%d,%ld)\n", code, wparam, lparam);
-
-  /** returns now if not HC_ACTION */
-  if (code != HC_ACTION) return CallNextHookEx(keyboard_hook, code, wparam, lparam);
+  BYTE oldDInputKeyState[256];
+  int t;
   
+  memcpy(&oldDInputKeyState,&DInputKeyState,256);
+  GetKeyboardState(DInputKeyState);
+  
+  for( t=0;t<255;t++)
   {
-    dik_code = hook->scanCode;
-    if (hook->flags & LLKHF_EXTENDED) dik_code |= 0x80;
-    down = !(hook->flags & LLKHF_UP);
-    timestamp = hook->time;
+	  if (oldDInputKeyState[t]!=DInputKeyState[t]) disk_code=t;	  
   }
+  	
 
-  /** returns now if key event already known */
-  new_diks = (down ? 0x80 : 0);
-  /*if (new_diks != DInputKeyState[dik_code]) return CallNextHookEx(keyboard_hook, code, wparam, lparam); TO BE FIXED */
+  if (disk_code!=-1) {
+	  if (current->buffer != NULL)
+     {
+      int n;
+      n = (current->start + current->count) % current->buffersize;
 
-  DInputKeyState[dik_code] = new_diks;
-  TRACE(" setting %02X to %02X\n", dik_code, DInputKeyState[dik_code]);
+      current->buffer[n].dwOfs = (BYTE) disk_code;
+      current->buffer[n].dwData = DInputKeyState[disk_code];
+      current->buffer[n].dwTimeStamp = 10;
+      current->buffer[n].dwSequence = current->dinput->evsequence++;
+
+	  
+      if (current->count == current->buffersize)
+                {
+                  current->start = ++current->start % current->buffersize;
+                  current->overflow = TRUE;
+                }
+              else
+                current->count++;
+              
+            }
+  }
+
+
+}
+#endif
+#ifndef __REACTOS__
+LRESULT CALLBACK KeyboardCallback( int code, WPARAM wparam, LPARAM lparam )
+{
+  TRACE("(%d,%d,%ld)\n", code, wparam, lparam);
+
+  if (code == HC_ACTION)
+    {
+      BYTE dik_code;
+      BOOL down;
+      DWORD timestamp;
       
-  if (current_lock != NULL) {
-    if (current_lock->hEvent) SetEvent(current_lock->hEvent);
-    
-    if (current_lock->buffer != NULL) {
-      int n;
+      {
+        KBDLLHOOKSTRUCT *hook = (KBDLLHOOKSTRUCT *)lparam;
+        dik_code = hook->scanCode;
+        if (hook->flags & LLKHF_EXTENDED) dik_code |= 0x80;
+        down = !(hook->flags & LLKHF_UP);
+        timestamp = hook->time;
+      }
+
+      DInputKeyState[dik_code] = (down ? 0x80 : 0);
+      TRACE(" setting %02X to %02X\n", dik_code, DInputKeyState[dik_code]);
       
-      EnterCriticalSection(&(current_lock->crit));
-      
-      n = (current_lock->start + current_lock->count) % current_lock->buffersize;
-      
-      current_lock->buffer[n].dwOfs = dik_code;
-      current_lock->buffer[n].dwData = down ? 0x80 : 0;
-      current_lock->buffer[n].dwTimeStamp = timestamp;
-      current_lock->buffer[n].dwSequence = current_lock->dinput->evsequence++;
-      
-      TRACE("Adding event at offset %d : %ld - %ld - %ld - %ld\n", n,
-	    current_lock->buffer[n].dwOfs, current_lock->buffer[n].dwData, current_lock->buffer[n].dwTimeStamp, current_lock->buffer[n].dwSequence);
-      
-      if (current_lock->count == current_lock->buffersize) {
-	current_lock->start = ++current_lock->start % current_lock->buffersize;
-	current_lock->overflow = TRUE;
-      } else
-	current_lock->count++;
-      
-      LeaveCriticalSection(&(current_lock->crit));
+      if (current != NULL)
+        {
+          if (current->hEvent)
+            SetEvent(current->hEvent);
+
+          if (current->buffer != NULL)
+            {
+              int n;
+
+              EnterCriticalSection(&(current->crit));
+
[truncated at 1000 lines; 822 more skipped]