Sync aginst a older version of wine, fixed GvG patch for so we do not lose poll_mouse, tested in few apps and games in ros and windows. Next sync is against current version of wine. and it does remove almost whole my patch for wine dinput thx to GvG implemet userhook for mouse and keyboard in reactos.

svn path=/trunk/; revision=18318
This commit is contained in:
Magnus Olsen 2005-10-08 00:21:29 +00:00
parent c968095964
commit f66d835b98
11 changed files with 745 additions and 601 deletions

View file

@ -3,6 +3,7 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = dinput.dll
IMPORTLIB = libdinput.$(IMPLIBEXT)
IMPORTS = ole32 user32 advapi32 kernel32
EXTRALIBS = -ldxguid -luuid
@ -16,8 +17,12 @@ C_SRCS = \
mouse.c \
regsvr.c
IMPLIB_SRCS = data_formats.c
RC_SRCS = version.rc
SUBDIRS = tests
@MAKE_DLL_RULES@
### Dependencies:

View file

@ -16,10 +16,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* TODO:
* add keyboard
*/
#include <stdarg.h>
#include "windef.h"
@ -27,7 +23,7 @@
#define numObjects(x) (sizeof(x) / sizeof(x[0]))
DIOBJECTDATAFORMAT dfDIJoystick[] = {
static const 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},
@ -80,10 +76,10 @@ const DIDATAFORMAT c_dfDIJoystick = {
DIDF_ABSAXIS,
sizeof(DIJOYSTATE2),
numObjects(dfDIJoystick),
dfDIJoystick
(LPDIOBJECTDATAFORMAT)dfDIJoystick
};
DIOBJECTDATAFORMAT dfDIJoystick2[] = {
static const 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},
@ -256,10 +252,10 @@ const DIDATAFORMAT c_dfDIJoystick2 = {
DIDF_ABSAXIS,
sizeof(DIJOYSTATE2),
numObjects(dfDIJoystick2),
dfDIJoystick2
(LPDIOBJECTDATAFORMAT)dfDIJoystick2
};
DIOBJECTDATAFORMAT dfDIMouse[] = {
static const 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 },
@ -275,10 +271,10 @@ const DIDATAFORMAT c_dfDIMouse = {
DIDF_RELAXIS,
sizeof(DIMOUSESTATE),
numObjects(dfDIMouse),
dfDIMouse
(LPDIOBJECTDATAFORMAT)dfDIMouse
};
DIOBJECTDATAFORMAT dfDIMouse2[] = {
static const 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 },
@ -298,5 +294,273 @@ const DIDATAFORMAT c_dfDIMouse2 = {
DIDF_RELAXIS,
sizeof(DIMOUSESTATE2),
numObjects(dfDIMouse2),
dfDIMouse2
(LPDIOBJECTDATAFORMAT)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
};

View file

@ -80,7 +80,10 @@ void _dump_EnumObjects_flags(DWORD dwFlags) {
FE(DIDFT_NODATA),
FE(DIDFT_FFACTUATOR),
FE(DIDFT_FFEFFECTTRIGGER),
FE(DIDFT_OUTPUT)
FE(DIDFT_OUTPUT),
FE(DIDFT_VENDORDEFINED),
FE(DIDFT_ALIAS),
FE(DIDFT_OPTIONAL)
#undef FE
};
type = (dwFlags & 0xFF0000FF);
@ -290,12 +293,12 @@ DataFormat *create_DataFormat(const DIDATAFORMAT *wine_format, LPCDIDATAFORMAT a
int index = 0;
DWORD next = 0;
ret = (DataFormat *) HeapAlloc(GetProcessHeap(), 0, sizeof(DataFormat));
ret = HeapAlloc(GetProcessHeap(), 0, sizeof(DataFormat));
done = (int *) HeapAlloc(GetProcessHeap(), 0, sizeof(int) * asked_format->dwNumObjs);
done = HeapAlloc(GetProcessHeap(), 0, sizeof(int) * asked_format->dwNumObjs);
memset(done, 0, sizeof(int) * asked_format->dwNumObjs);
dt = (DataTransform *) HeapAlloc(GetProcessHeap(), 0, asked_format->dwNumObjs * sizeof(DataTransform));
dt = HeapAlloc(GetProcessHeap(), 0, asked_format->dwNumObjs * sizeof(DataTransform));
TRACE("Creating DataTransform : \n");
@ -310,13 +313,18 @@ DataFormat *create_DataFormat(const DIDATAFORMAT *wine_format, LPCDIDATAFORMAT a
* the GUID of the Wine object.
*/
((asked_format->rgodf[j].pguid == NULL) ||
(wine_format->rgodf[i].pguid == NULL) ||
(IsEqualGUID(wine_format->rgodf[i].pguid, asked_format->rgodf[j].pguid)))
&&
(/* Then check if it accepts any instance id, and if not, if it matches Wine's
* instance id.
*/
((asked_format->rgodf[j].dwType & 0x00FFFF00) == DIDFT_ANYINSTANCE) ||
(wine_format->rgodf[i].dwType & asked_format->rgodf[j].dwType))) {
(DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == 0xFFFF) ||
(DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == 0x00FF) || /* This is mentionned in no DX docs, but it works fine - tested on WinXP */
(DIDFT_GETINSTANCE(asked_format->rgodf[j].dwType) == DIDFT_GETINSTANCE(wine_format->rgodf[i].dwType)))
&&
( /* Then if the asked type matches the one Wine provides */
wine_format->rgodf[i].dwType & asked_format->rgodf[j].dwType)) {
done[j] = 1;
@ -329,19 +337,19 @@ DataFormat *create_DataFormat(const DIDATAFORMAT *wine_format, LPCDIDATAFORMAT a
TRACE(" * dwType: %08lx\n", asked_format->rgodf[j].dwType);
TRACE(" "); _dump_EnumObjects_flags(asked_format->rgodf[j].dwType); TRACE("\n");
TRACE(" - Wine (%d) :\n", j);
TRACE(" - Wine (%d) :\n", i);
TRACE(" * GUID: %s ('%s')\n",
debugstr_guid(wine_format->rgodf[j].pguid),
_dump_dinput_GUID(wine_format->rgodf[j].pguid));
TRACE(" * Offset: %3ld\n", wine_format->rgodf[j].dwOfs);
TRACE(" * dwType: %08lx\n", wine_format->rgodf[j].dwType);
TRACE(" "); _dump_EnumObjects_flags(wine_format->rgodf[j].dwType); TRACE("\n");
debugstr_guid(wine_format->rgodf[i].pguid),
_dump_dinput_GUID(wine_format->rgodf[i].pguid));
TRACE(" * Offset: %3ld\n", wine_format->rgodf[i].dwOfs);
TRACE(" * dwType: %08lx\n", wine_format->rgodf[i].dwType);
TRACE(" "); _dump_EnumObjects_flags(wine_format->rgodf[i].dwType); TRACE("\n");
if (wine_format->rgodf[i].dwType & DIDFT_BUTTON)
dt[index].size = sizeof(BYTE);
else
dt[index].size = sizeof(DWORD);
dt[index].offset_in = wine_format ->rgodf[i].dwOfs;
dt[index].offset_in = wine_format->rgodf[i].dwOfs;
if (asked_format->rgodf[j].dwOfs < next) {
WARN("bad format: dwOfs=%ld, changing to %ld\n", asked_format->rgodf[j].dwOfs, next);
dt[index].offset_out = next;
@ -409,7 +417,7 @@ BOOL DIEnumDevicesCallbackAtoW(LPCDIDEVICEOBJECTINSTANCEA lpddi, LPVOID lpvRef)
data = (device_enumobjects_AtoWcb_data*) lpvRef;
memset(&ddtmp, 0, sizeof(DIDEVICEINSTANCEW));
memset(&ddtmp, 0, sizeof(ddtmp));
ddtmp.dwSize = sizeof(DIDEVICEINSTANCEW);
ddtmp.guidType = lpddi->guidType;
@ -749,8 +757,6 @@ HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(
{
FIXME("(this=%p,%p,%p,0x%08lx): stub!\n",
iface, lpCallback, lpvRef, dwFlags);
if (lpCallback)
lpCallback(NULL, lpvRef);
return DI_OK;
}

View file

@ -1,4 +1,4 @@
<module name="dinput" type="win32dll" baseaddress="${BASEADDRESS_DINPUT}" installbase="system32" installname="dinput.dll" allowwarnings="true">
<module name="dinput" type="win32dll" baseaddress="${BASEADDRESS_DINPUT}" installbase="system32" installname="dinput.dll" warnings="true">
<importlibrary definition="dinput.spec.def" />
<include base="dinput">.</include>
<include base="ReactOS">include/wine</include>

View file

@ -30,8 +30,6 @@
*/
#include "config.h"
#include "wine/port.h"
#include <assert.h>
#include <stdarg.h>
#include <string.h>
@ -53,10 +51,14 @@ static IDirectInput7WVtbl ddi7wvt;
static IDirectInput8AVtbl ddi8avt;
static IDirectInput8WVtbl ddi8wvt;
/* 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;
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]))
HINSTANCE DINPUT_instance = NULL;
@ -74,28 +76,6 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserv)
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.@)
@ -111,10 +91,10 @@ HRESULT WINAPI DirectInputCreateEx(
if (IsEqualGUID(&IID_IDirectInputA,riid) ||
IsEqualGUID(&IID_IDirectInput2A,riid) ||
IsEqualGUID(&IID_IDirectInput7A,riid)) {
This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi7avt;
This->ref = 1;
This->version = 1;
This->dwVersion = dwVersion;
*ppDI = This;
return DI_OK;
@ -123,30 +103,30 @@ HRESULT WINAPI DirectInputCreateEx(
if (IsEqualGUID(&IID_IDirectInputW,riid) ||
IsEqualGUID(&IID_IDirectInput2W,riid) ||
IsEqualGUID(&IID_IDirectInput7W,riid)) {
This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi7wvt;
This->ref = 1;
This->version = 1;
This->dwVersion = dwVersion;
*ppDI = This;
return DI_OK;
}
if (IsEqualGUID(&IID_IDirectInput8A,riid)) {
This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi8avt;
This->ref = 1;
This->version = 8;
This->dwVersion = dwVersion;
*ppDI = This;
return DI_OK;
}
if (IsEqualGUID(&IID_IDirectInput8W,riid)) {
This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi8wvt;
This->ref = 1;
This->version = 8;
This->dwVersion = dwVersion;
*ppDI = This;
return DI_OK;
@ -162,17 +142,10 @@ HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPU
{
IDirectInputImpl* This;
TRACE("(0x%08lx,%04lx,%p,%p)\n", (DWORD)hinst,dwVersion,ppDI,punkOuter);
//trace:dinput:DirectInputCreateA (0x00400000,0500,0x42bafc54,(nil))
This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi7avt;
This->ref = 1;
if (dwVersion > 0x0700) {
This->version = 8;
} else {
/* We do not differientiate between version 1, 2 and 7 */
This->version = 1;
}
This->dwVersion = dwVersion;
*ppDI = (IDirectInputA*)This;
return 0;
@ -185,15 +158,10 @@ HRESULT WINAPI DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPU
{
IDirectInputImpl* This;
TRACE("(0x%08lx,%04lx,%p,%p)\n", (DWORD)hinst,dwVersion,ppDI,punkOuter);
This = (IDirectInputImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This = HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputImpl));
This->lpVtbl = &ddi7wvt;
This->ref = 1;
if (dwVersion >= 0x0800) {
This->version = 8;
} else {
/* We do not differientiate between version 1, 2 and 7 */
This->version = 1;
}
This->dwVersion = dwVersion;
*ppDI = (IDirectInputW*)This;
return 0;
}
@ -248,22 +216,14 @@ static HRESULT WINAPI IDirectInputAImpl_EnumDevices(
TRACE("(this=%p,0x%04lx '%s',%p,%p,%04lx)\n",
This, dwDevType, _dump_DIDEVTYPE_value(dwDevType),
lpCallback, pvRef, dwFlags);
if (nrof_dinput_devices==0){
scan_mouse();
scan_keyboard();
}
TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n");
for (i = 0; i < nrof_dinput_devices; i++) {
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
if (!dinput_devices[i]->enum_deviceA) continue;
for (j = 0, r = -1; r != 0; j++) {
devInstance.dwSize = sizeof(devInstance);
TRACE(" - checking device %d ('%s')\n", i, dinput_devices[i]->name);
if ((r = dinput_devices[i]->enum_deviceA(dwDevType, dwFlags, &devInstance, This->version, j))) {
if ((r = dinput_devices[i]->enum_deviceA(dwDevType, dwFlags, &devInstance, This->dwVersion, j))) {
if (lpCallback(&devInstance,pvRef) == DIENUM_STOP)
return 0;
}
@ -283,22 +243,17 @@ static HRESULT WINAPI IDirectInputWImpl_EnumDevices(
DIDEVICEINSTANCEW devInstance;
int i, j, r;
if (nrof_dinput_devices==0){
scan_mouse();
scan_keyboard();
}
TRACE("(this=%p,0x%04lx '%s',%p,%p,%04lx)\n",
This, dwDevType, _dump_DIDEVTYPE_value(dwDevType),
lpCallback, pvRef, dwFlags);
TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n");
for (i = 0; i < nrof_dinput_devices; i++) {
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
if (!dinput_devices[i]->enum_deviceW) continue;
for (j = 0, r = -1; r != 0; j++) {
devInstance.dwSize = sizeof(devInstance);
TRACE(" - checking device %d ('%s')\n", i, dinput_devices[i]->name);
if ((r = dinput_devices[i]->enum_deviceW(dwDevType, dwFlags, &devInstance, This->version, j))) {
if ((r = dinput_devices[i]->enum_deviceW(dwDevType, dwFlags, &devInstance, This->dwVersion, j))) {
if (lpCallback(&devInstance,pvRef) == DIENUM_STOP)
return 0;
}
@ -365,15 +320,21 @@ static HRESULT WINAPI IDirectInputAImpl_CreateDevice(
int i;
TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
if (nrof_dinput_devices==0){
scan_mouse();
scan_keyboard();
if (pdev == NULL) {
WARN("invalid pointer: pdev == NULL\n");
return E_POINTER;
}
if (rguid == NULL) {
WARN("invalid pointer: rguid == NULL\n");
return E_POINTER;
}
/* Loop on all the devices to see if anyone matches the given GUID */
for (i = 0; i < nrof_dinput_devices; i++) {
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
HRESULT ret;
if (!dinput_devices[i]->create_deviceA) continue;
if ((ret = dinput_devices[i]->create_deviceA(This, rguid, NULL, pdev)) == DI_OK)
return DI_OK;
@ -389,17 +350,13 @@ static HRESULT WINAPI IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7A iface,
IDirectInputImpl *This = (IDirectInputImpl *)iface;
HRESULT ret_value = DIERR_DEVICENOTREG;
int i;
TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
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 < nrof_dinput_devices; i++) {
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
HRESULT ret;
if (!dinput_devices[i]->create_deviceW) continue;
if ((ret = dinput_devices[i]->create_deviceW(This, rguid, NULL, pdev)) == DI_OK)
return DI_OK;
@ -457,14 +414,10 @@ static HRESULT WINAPI IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface, R
TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
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 < nrof_dinput_devices; i++) {
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
HRESULT ret;
if (!dinput_devices[i]->create_deviceA) continue;
if ((ret = dinput_devices[i]->create_deviceA(This, rguid, riid, (LPDIRECTINPUTDEVICEA*) pvOut)) == DI_OK)
return DI_OK;
@ -484,16 +437,10 @@ static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, R
TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
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 < nrof_dinput_devices; i++) {
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
HRESULT ret;
if (!dinput_devices[i]->create_deviceW) continue;
if ((ret = dinput_devices[i]->create_deviceW(This, rguid, riid, (LPDIRECTINPUTDEVICEW*) pvOut)) == DI_OK)
return DI_OK;

View file

@ -35,24 +35,23 @@ struct IDirectInputImpl
/* Used to have an unique sequence number for all the events */
DWORD evsequence;
int version;
DWORD dwVersion;
};
/* Function called by all devices that Wine supports */
typedef struct dinput_device {
INT pref;
struct dinput_device {
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);
BOOL (*enum_deviceA)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id);
BOOL (*enum_deviceW)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD 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 void dinput_register_device(dinput_device *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 HINSTANCE DINPUT_instance;
void scan_keyboard();
void scan_mouse();
#endif /* __WINE_DLLS_DINPUT_DINPUT_PRIVATE_H */

View file

@ -28,8 +28,6 @@
#include "config.h"
#include "wine/port.h"
#ifdef HAVE_LINUX_22_JOYSTICK_API
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
@ -55,7 +53,6 @@
#ifdef HAVE_LINUX_JOYSTICK_H
# include <linux/joystick.h>
#endif
#define JOYDEV "/dev/js"
#include "wine/debug.h"
#include "wine/unicode.h"
@ -70,6 +67,10 @@
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
#ifdef HAVE_LINUX_22_JOYSTICK_API
#define JOYDEV "/dev/js"
typedef struct {
LONG lMin;
LONG lMax;
@ -147,7 +148,7 @@ static void _dump_DIDEVCAPS(LPDIDEVCAPS lpDIDevCaps)
}
}
static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version, int id)
static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
{
int fd = -1;
char dev[32];
@ -158,8 +159,8 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
}
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 8)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 8))) {
((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) {
/* check whether we have a joystick */
sprintf(dev, "%s%d", JOYDEV, id);
if ((fd = open(dev,O_RDONLY)) < 0) {
@ -172,7 +173,7 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
lpddi->guidInstance.Data3 = id;
lpddi->guidProduct = DInput_Wine_Joystick_GUID;
/* we only support traditional joysticks for now */
if (version >= 8)
if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
@ -195,7 +196,7 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
return FALSE;
}
static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version, int id)
static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
{
int fd = -1;
char name[MAX_PATH];
@ -208,8 +209,8 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
}
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 8)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 8))) {
((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) {
/* check whether we have a joystick */
sprintf(dev, "%s%d", JOYDEV, id);
if ((fd = open(dev,O_RDONLY)) < 0) {
@ -222,7 +223,7 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
lpddi->guidInstance.Data3 = id;
lpddi->guidProduct = DInput_Wine_Joystick_GUID;
/* we only support traditional joysticks for now */
if (version >= 8)
if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
@ -556,7 +557,7 @@ static HRESULT alloc_device(REFGUID rguid, LPVOID jvt, IDirectInputImpl *dinput,
newDevice->devcaps.dwSize = sizeof(newDevice->devcaps);
newDevice->devcaps.dwFlags = DIDC_ATTACHED;
if (newDevice->dinput->version >= 8)
if (newDevice->dinput->dwVersion >= 0x0800)
newDevice->devcaps.dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
newDevice->devcaps.dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
@ -646,8 +647,7 @@ static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, RE
return DIERR_DEVICENOTREG;
}
static dinput_device joydev = {
10,
const struct dinput_device joystick_linux_device = {
"Wine Linux joystick driver",
joydev_enum_deviceA,
joydev_enum_deviceW,
@ -655,10 +655,6 @@ static dinput_device joydev = {
joydev_create_deviceW
};
DECL_GLOBAL_CONSTRUCTOR(joydev_register) { dinput_register_device(&joydev); }
/******************************************************************************
* Joystick
*/
@ -717,6 +713,16 @@ static HRESULT WINAPI JoystickAImpl_SetDataFormat(
TRACE("(%p,%p)\n",This,df);
if (df == NULL) {
WARN("invalid pointer\n");
return E_POINTER;
}
if (df->dwSize != sizeof(*df)) {
WARN("invalid argument\n");
return DIERR_INVALIDPARAM;
}
if (This->acquired) {
WARN("acquired\n");
return DIERR_ACQUIRED;
@ -1117,6 +1123,11 @@ static HRESULT WINAPI JoystickAImpl_SetProperty(
TRACE("(%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
if (ph == NULL) {
WARN("invalid parameter: ph == NULL\n");
return DIERR_INVALIDPARAM;
}
if (TRACE_ON(dinput))
_dump_DIPROPHEADER(ph);
@ -1217,11 +1228,17 @@ static HRESULT WINAPI JoystickAImpl_GetCapabilities(
TRACE("%p->(%p)\n",iface,lpDIDevCaps);
if (lpDIDevCaps == NULL) {
WARN("invalid parameter: lpDIDevCaps = NULL\n");
return DIERR_INVALIDPARAM;
WARN("invalid pointer\n");
return E_POINTER;
}
size = lpDIDevCaps->dwSize;
if (!(size == sizeof(DIDEVCAPS) || size == sizeof(DIDEVCAPS_DX3))) {
WARN("invalid parameter\n");
return DIERR_INVALIDPARAM;
}
CopyMemory(lpDIDevCaps, &This->devcaps, size);
lpDIDevCaps->dwSize = size;
@ -1559,6 +1576,11 @@ HRESULT WINAPI JoystickAImpl_GetDeviceInfo(
TRACE("(%p,%p)\n", iface, pdidi);
if (pdidi == NULL) {
WARN("invalid pointer\n");
return E_POINTER;
}
if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3A)) &&
(pdidi->dwSize != sizeof(DIDEVICEINSTANCEA))) {
WARN("invalid parameter: pdidi->dwSize = %ld != %d or %d\n",
@ -1697,4 +1719,14 @@ static IDirectInputDevice8WVtbl SysJoystickWvt =
};
#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 */

View file

@ -22,8 +22,6 @@
#include "config.h"
#include "wine/port.h"
#ifdef HAVE_LINUX_INPUT_H
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
@ -43,16 +41,10 @@
#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"
@ -65,6 +57,10 @@
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
@ -168,7 +164,7 @@ static int joydev_have(void)
return havejoy;
}
static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version, int id)
static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
{
int havejoy = 0;
@ -176,8 +172,8 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
return FALSE;
if (!((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 8)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 8))))
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))))
return FALSE;
if (dwFlags & DIEDFL_FORCEFEEDBACK)
@ -195,7 +191,7 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
lpddi->guidProduct = DInput_Wine_Joystick_GUID;
lpddi->guidFFDriver = GUID_NULL;
if (version >= 8)
if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
@ -206,7 +202,7 @@ static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
return TRUE;
}
static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version, int id)
static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
{
int havejoy = 0;
@ -214,8 +210,8 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
return FALSE;
if (!((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 8)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 8))))
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))))
return FALSE;
if (dwFlags & DIEDFL_FORCEFEEDBACK)
@ -233,7 +229,7 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
lpddi->guidProduct = DInput_Wine_Joystick_GUID;
lpddi->guidFFDriver = GUID_NULL;
if (version >= 8)
if (version >= 0x0800)
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
@ -322,8 +318,7 @@ static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, RE
return DIERR_DEVICENOTREG;
}
static dinput_device joydev = {
20,
const struct dinput_device joystick_linuxinput_device = {
"Wine Linux-input joystick driver",
joydev_enum_deviceA,
joydev_enum_deviceW,
@ -331,8 +326,6 @@ static dinput_device joydev = {
joydev_create_deviceW
};
DECL_GLOBAL_CONSTRUCTOR(joydev_register) { dinput_register_device(&joydev); }
/******************************************************************************
* Joystick
*/
@ -762,7 +755,7 @@ static HRESULT WINAPI JoystickAImpl_GetCapabilities(
wasacquired = 0;
}
lpDIDevCaps->dwFlags = DIDC_ATTACHED;
if (This->dinput->version >= 8)
if (This->dinput->dwVersion >= 0x0800)
lpDIDevCaps->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
else
lpDIDevCaps->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
@ -978,7 +971,7 @@ static HRESULT WINAPI JoystickAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
{
JoystickImpl *This = (JoystickImpl *)iface;
TRACE("(this=%p,%s,%p): stub!\n",
TRACE("(this=%p,%s,%p)\n",
iface, debugstr_guid(rguid), pdiph);
if (TRACE_ON(dinput))
@ -1094,6 +1087,14 @@ static IDirectInputDevice8WVtbl JoystickWvt =
};
#undef XCAST
#endif /* HAVE_LINUX_INPUT_H */
#else /* HAVE_CORRECT_LINUXINPUT_H */
#endif
const struct dinput_device joystick_linuxinput_device = {
"Wine Linux-input joystick driver",
NULL,
NULL,
NULL,
NULL
};
#endif /* HAVE_CORRECT_LINUXINPUT_H */

View file

@ -3,6 +3,7 @@
* 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
@ -37,10 +38,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
//fast fix misning from mingw headers
#ifdef __REACTOS__
#define LLKHF_INJECTED 0x00000010
#endif
#define WINE_DINPUT_KEYBOARD_MAX_KEYS 256
static IDirectInputDevice8AVtbl SysKeyboardAvt;
static IDirectInputDevice8WVtbl SysKeyboardWvt;
@ -70,14 +68,15 @@ struct SysKeyboardImpl
CRITICAL_SECTION crit;
};
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 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.
*/
static BYTE DInputKeyState[256]; /* array for 'GetDeviceState' */
static BYTE DInputKeyState[WINE_DINPUT_KEYBOARD_MAX_KEYS]; /* array for 'GetDeviceState' */
static CRITICAL_SECTION keyboard_crit;
static CRITICAL_SECTION_DEBUG critsect_debug =
@ -88,114 +87,65 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
};
static CRITICAL_SECTION keyboard_crit = { &critsect_debug, -1, 0, 0, 0, 0 };
#ifndef __REACTOS__
static DWORD keyboard_users;
static HHOOK keyboard_hook;
#endif
static DWORD keyboard_users = 0;
static HHOOK keyboard_hook = NULL;
#ifdef __REACTOS__
void reactos_input_keyboard();
void reactos_input_keyboard()
{
int disk_code = -1;
BYTE oldDInputKeyState[256];
int t;
memcpy(&oldDInputKeyState,&DInputKeyState,256);
GetKeyboardState(DInputKeyState);
for( t=0;t<255;t++)
{
if (oldDInputKeyState[t]!=DInputKeyState[t]) disk_code=t;
}
if (disk_code!=-1) {
if (current->buffer != NULL)
{
int n;
n = (current->start + current->count) % current->buffersize;
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 )
{
BYTE dik_code;
BOOL down;
DWORD timestamp;
KBDLLHOOKSTRUCT *hook = (KBDLLHOOKSTRUCT *)lparam;
BYTE new_diks;
TRACE("(%d,%d,%ld)\n", code, wparam, lparam);
if (code == HC_ACTION)
{
BYTE dik_code;
BOOL down;
DWORD timestamp;
/** returns now if not HC_ACTION */
if (code != HC_ACTION) return CallNextHookEx(keyboard_hook, code, wparam, lparam);
{
dik_code = hook->scanCode;
if (hook->flags & LLKHF_EXTENDED) dik_code |= 0x80;
down = !(hook->flags & LLKHF_UP);
timestamp = hook->time;
}
/** 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 */
DInputKeyState[dik_code] = new_diks;
TRACE(" setting %02X to %02X\n", dik_code, DInputKeyState[dik_code]);
{
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]);
if (current_lock != NULL) {
if (current_lock->hEvent) SetEvent(current_lock->hEvent);
if (current_lock->buffer != NULL) {
int n;
if (current != NULL)
{
if (current->hEvent)
SetEvent(current->hEvent);
if (current->buffer != NULL)
{
int n;
EnterCriticalSection(&(current->crit));
n = (current->start + current->count) % current->buffersize;
current->buffer[n].dwOfs = dik_code;
current->buffer[n].dwData = down ? 0x80 : 0;
current->buffer[n].dwTimeStamp = timestamp;
current->buffer[n].dwSequence = current->dinput->evsequence++;
TRACE("Adding event at offset %d : %ld - %ld - %ld - %ld\n", n,
current->buffer[n].dwOfs, current->buffer[n].dwData, current->buffer[n].dwTimeStamp, current->buffer[n].dwSequence);
if (current->count == current->buffersize)
{
current->start = ++current->start % current->buffersize;
current->overflow = TRUE;
}
else
current->count++;
LeaveCriticalSection(&(current->crit));
}
}
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));
}
}
return CallNextHookEx(keyboard_hook, code, wparam, lparam);
}
#endif
static GUID DInput_Wine_Keyboard_GUID = { /* 0ab8648a-7735-11d2-8c73-71df54a96441 */
0x0ab8648a,
@ -204,7 +154,7 @@ static GUID DInput_Wine_Keyboard_GUID = { /* 0ab8648a-7735-11d2-8c73-71df54a9644
{0x8c, 0x73, 0x71, 0xdf, 0x54, 0xa9, 0x64, 0x41}
};
static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int version) {
static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version) {
DWORD dwSize;
DIDEVICEINSTANCEA ddi;
@ -218,7 +168,7 @@ static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int versi
ddi.dwSize = dwSize;
ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
if (version >= 8)
if (version >= 0x0800)
ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
else
ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
@ -228,7 +178,7 @@ static void fill_keyboard_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int versi
memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
}
static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int version) {
static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version) {
DWORD dwSize;
DIDEVICEINSTANCEW ddi;
@ -242,7 +192,7 @@ static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int versi
ddi.dwSize = dwSize;
ddi.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
ddi.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
if (version >= 8)
if (version >= 0x0800)
ddi.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
else
ddi.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
@ -252,14 +202,14 @@ static void fill_keyboard_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int versi
memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
}
static BOOL keyboarddev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version, int id)
static BOOL keyboarddev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
{
if (id != 0)
return FALSE;
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 8)) ||
(((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 8))) {
((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) {
TRACE("Enumerating the Keyboard device\n");
fill_keyboard_dideviceinstanceA(lpddi, version);
@ -270,14 +220,14 @@ static BOOL keyboarddev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEI
return FALSE;
}
static BOOL keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version, int id)
static BOOL keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
{
if (id != 0)
return FALSE;
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 8)) ||
(((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 8))) {
((dwDevType == DIDEVTYPE_KEYBOARD) && (version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_KEYBOARD) || (dwDevType == DI8DEVTYPE_KEYBOARD)) && (version >= 0x0800))) {
TRACE("Enumerating the Keyboard device\n");
fill_keyboard_dideviceinstanceW(lpddi, version);
@ -288,23 +238,25 @@ static BOOL keyboarddev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEI
return FALSE;
}
static SysKeyboardImpl *alloc_device_keyboard(REFGUID rguid, LPVOID kvt, IDirectInputImpl *dinput)
static SysKeyboardImpl *alloc_device(REFGUID rguid, LPVOID kvt, IDirectInputImpl *dinput)
{
SysKeyboardImpl* newDevice;
DWORD kbd_users;
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardImpl));
newDevice->lpVtbl = kvt;
newDevice->ref = 1;
memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
newDevice->dinput = dinput;
InitializeCriticalSection(&(newDevice->crit));
#ifndef __REACTOS__
EnterCriticalSection(&keyboard_crit);
if (!keyboard_users++)
keyboard_hook = SetWindowsHookExW( WH_KEYBOARD_LL, KeyboardCallback, DINPUT_instance, 0 );
kbd_users = InterlockedIncrement(&keyboard_users);
if (1 == kbd_users) {
keyboard_hook = SetWindowsHookExW( WH_KEYBOARD_LL, KeyboardCallback, DINPUT_instance, 0 );
}
LeaveCriticalSection(&keyboard_crit);
#endif
return newDevice;
}
@ -318,7 +270,7 @@ static HRESULT keyboarddev_create_deviceA(IDirectInputImpl *dinput, REFGUID rgui
IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
*pdev = (IDirectInputDeviceA*) alloc_device_keyboard(rguid, &SysKeyboardAvt, dinput);
*pdev = (IDirectInputDeviceA*) alloc_device(rguid, &SysKeyboardAvt, dinput);
TRACE("Creating a Keyboard device (%p)\n", *pdev);
return DI_OK;
} else
@ -336,7 +288,7 @@ static HRESULT keyboarddev_create_deviceW(IDirectInputImpl *dinput, REFGUID rgui
IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
*pdev = (IDirectInputDeviceW*) alloc_device_keyboard(rguid, &SysKeyboardWvt, dinput);
*pdev = (IDirectInputDeviceW*) alloc_device(rguid, &SysKeyboardWvt, dinput);
TRACE("Creating a Keyboard device (%p)\n", *pdev);
return DI_OK;
} else
@ -345,8 +297,7 @@ static HRESULT keyboarddev_create_deviceW(IDirectInputImpl *dinput, REFGUID rgui
return DIERR_DEVICENOTREG;
}
dinput_device keyboarddev = {
100,
const struct dinput_device keyboard_device = {
"Wine keyboard driver",
keyboarddev_enum_deviceA,
keyboarddev_enum_deviceW,
@ -354,30 +305,23 @@ dinput_device keyboarddev = {
keyboarddev_create_deviceW
};
void scan_keyboard()
{
dinput_register_device(&keyboarddev);
}
DECL_GLOBAL_CONSTRUCTOR(keyboarddev_register) { dinput_register_device(&keyboarddev); }
static ULONG WINAPI SysKeyboardAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
{
SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
ULONG ref;
DWORD kbd_users;
ref = InterlockedDecrement(&(This->ref));
if (ref)
return ref;
#ifndef __REACTOS__
EnterCriticalSection(&keyboard_crit);
if (!--keyboard_users) {
EnterCriticalSection(&keyboard_crit);
kbd_users = InterlockedDecrement(&keyboard_users);
if (0 == kbd_users) {
UnhookWindowsHookEx( keyboard_hook );
keyboard_hook = 0;
}
LeaveCriticalSection(&keyboard_crit);
#endif
/* Free the data queue */
HeapFree(GetProcessHeap(),0,This->buffer);
@ -419,33 +363,64 @@ static HRESULT WINAPI SysKeyboardAImpl_SetProperty(
return DI_OK;
}
static HRESULT WINAPI SysKeyboardAImpl_GetProperty(
LPDIRECTINPUTDEVICE8A iface,REFGUID rguid,LPDIPROPHEADER ph
)
{
SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
TRACE("(size=%ld,headersize=%ld,obj=%ld,how=%ld\n",
ph->dwSize,ph->dwHeaderSize,ph->dwObj,ph->dwHow);
if (!HIWORD(rguid)) {
switch ((DWORD)rguid) {
case (DWORD) DIPROP_BUFFERSIZE: {
LPDIPROPDWORD pd = (LPDIPROPDWORD)ph;
TRACE("(buffersize=%ld)\n",pd->dwData);
if (This->acquired)
return DIERR_INVALIDPARAM;
pd->dwData = This->buffersize;
break;
}
default:
WARN("Unknown type %ld\n",(DWORD)rguid);
break;
}
}
return DI_OK;
}
static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState(
LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
)
{
TRACE("(%p)->(%ld,%p)\n", iface, len, ptr);
#ifdef __REACTOS__
reactos_input_keyboard();
#endif
SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
TRACE("(%p)->(%ld,%p)\n", This, len, ptr);
/* Note: device does not need to be acquired */
if (len != 256)
if (len != WINE_DINPUT_KEYBOARD_MAX_KEYS)
return DIERR_INVALIDPARAM;
MsgWaitForMultipleObjectsEx(0, NULL, 0, 0, 0);
MsgWaitForMultipleObjectsEx(0, NULL, 0, QS_ALLINPUT, 0);
EnterCriticalSection(&(This->crit));
if (TRACE_ON(dinput)) {
int i;
for (i = 0; i < 256; i++) {
for (i = 0; i < WINE_DINPUT_KEYBOARD_MAX_KEYS; i++) {
if (DInputKeyState[i] != 0x00) {
TRACE(" - %02X: %02x\n", i, DInputKeyState[i]);
}
}
}
memcpy(ptr, DInputKeyState, 256);
memcpy(ptr, DInputKeyState, WINE_DINPUT_KEYBOARD_MAX_KEYS);
LeaveCriticalSection(&(This->crit));
return DI_OK;
}
@ -454,12 +429,8 @@ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceData(
LPDWORD entries,DWORD flags
)
{
SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
int ret = DI_OK, i = 0;
#ifdef __REACTOS__
reactos_input_keyboard();
#endif
TRACE("(this=%p,%ld,%p,%p(%ld)),0x%08lx)\n",
This,dodsize,dod,entries,entries?*entries:0,flags);
@ -473,7 +444,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceData(
if (dodsize < sizeof(DIDEVICEOBJECTDATA_DX3))
return DIERR_INVALIDPARAM;
MsgWaitForMultipleObjectsEx(0, NULL, 0, 0, 0);
MsgWaitForMultipleObjectsEx(0, NULL, 0, QS_ALLINPUT, 0);
EnterCriticalSection(&(This->crit));
@ -534,7 +505,7 @@ static HRESULT WINAPI SysKeyboardAImpl_EnumObjects(
memset(&ddoi, 0, sizeof(ddoi));
ddoi.dwSize = FIELD_OFFSET(DIDEVICEOBJECTINSTANCEA, dwFFMaxForce);
for (i = 0; i < 256; i++) {
for (i = 0; i < WINE_DINPUT_KEYBOARD_MAX_KEYS; i++) {
/* Report 255 keys :-) */
ddoi.guidType = GUID_Key;
ddoi.dwOfs = i;
@ -575,26 +546,24 @@ static HRESULT WINAPI SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
This->acquired = 1;
if (current != NULL)
{
FIXME("Not more than one keyboard can be acquired at the same time.\n");
SysKeyboardAImpl_Unacquire(iface);
}
if (current_lock != NULL) {
FIXME("Not more than one keyboard can be acquired at the same time.\n");
SysKeyboardAImpl_Unacquire(iface);
}
current_lock = This;
current = This;
if (This->buffersize > 0)
{
This->buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
This->buffersize * sizeof(*(This->buffer)));
This->start = 0;
This->count = 0;
This->overflow = FALSE;
InitializeCriticalSection(&(This->crit));
}
else
if (This->buffersize > 0) {
This->buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
This->buffersize * sizeof(*(This->buffer)));
This->start = 0;
This->count = 0;
This->overflow = FALSE;
} else {
This->buffer = NULL;
}
/*keyboard_hook = SetWindowsHookExW( WH_KEYBOARD_LL, KeyboardCallback, DINPUT_instance, 0 );*/
return DI_OK;
}
@ -607,19 +576,19 @@ static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
if (This->acquired == 0)
return DI_NOEFFECT;
if (current == This)
current = NULL;
/* No more locks */
if (current_lock == This)
current_lock = NULL;
else
ERR("this != current\n");
ERR("this != current_lock\n");
/* Unacquire device */
This->acquired = 0;
if (This->buffersize >= 0)
{
HeapFree(GetProcessHeap(), 0, This->buffer);
This->buffer = NULL;
DeleteCriticalSection(&(This->crit));
}
if (This->buffersize >= 0) {
HeapFree(GetProcessHeap(), 0, This->buffer);
This->buffer = NULL;
}
return DI_OK;
}
@ -653,12 +622,12 @@ static HRESULT WINAPI SysKeyboardAImpl_GetCapabilities(
devcaps.dwSize = lpDIDevCaps->dwSize;
devcaps.dwFlags = DIDC_ATTACHED;
if (This->dinput->version >= 8)
if (This->dinput->dwVersion >= 0x0800)
devcaps.dwDevType = DI8DEVTYPE_KEYBOARD | (DI8DEVTYPEKEYBOARD_UNKNOWN << 8);
else
devcaps.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
devcaps.dwAxes = 0;
devcaps.dwButtons = 256;
devcaps.dwButtons = WINE_DINPUT_KEYBOARD_MAX_KEYS;
devcaps.dwPOVs = 0;
devcaps.dwFFSamplePeriod = 0;
devcaps.dwFFMinTimeResolution = 0;
@ -754,11 +723,11 @@ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceInfo(
TRACE("(this=%p,%p)\n", This, pdidi);
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA)) {
WARN(" dinput3 not supporte yet...\n");
WARN(" dinput3 not supported yet...\n");
return DI_OK;
}
fill_keyboard_dideviceinstanceA(pdidi, This->dinput->version);
fill_keyboard_dideviceinstanceA(pdidi, This->dinput->dwVersion);
return DI_OK;
}
@ -769,11 +738,11 @@ static HRESULT WINAPI SysKeyboardWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface
TRACE("(this=%p,%p)\n", This, pdidi);
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
WARN(" dinput3 not supporte yet...\n");
WARN(" dinput3 not supported yet...\n");
return DI_OK;
}
fill_keyboard_dideviceinstanceW(pdidi, This->dinput->version);
fill_keyboard_dideviceinstanceW(pdidi, This->dinput->dwVersion);
return DI_OK;
}
@ -785,7 +754,7 @@ static IDirectInputDevice8AVtbl SysKeyboardAvt =
SysKeyboardAImpl_Release,
SysKeyboardAImpl_GetCapabilities,
SysKeyboardAImpl_EnumObjects,
IDirectInputDevice2AImpl_GetProperty,
SysKeyboardAImpl_GetProperty,
SysKeyboardAImpl_SetProperty,
SysKeyboardAImpl_Acquire,
SysKeyboardAImpl_Unacquire,
@ -827,7 +796,7 @@ static IDirectInputDevice8WVtbl SysKeyboardWvt =
XCAST(Release)SysKeyboardAImpl_Release,
XCAST(GetCapabilities)SysKeyboardAImpl_GetCapabilities,
SysKeyboardWImpl_EnumObjects,
XCAST(GetProperty)IDirectInputDevice2AImpl_GetProperty,
XCAST(GetProperty)SysKeyboardAImpl_GetProperty,
XCAST(SetProperty)SysKeyboardAImpl_SetProperty,
XCAST(Acquire)SysKeyboardAImpl_Acquire,
XCAST(Unacquire)SysKeyboardAImpl_Unacquire,

View file

@ -0,0 +1,5 @@
# This file is automatically generated.
TOP = ..\..
DEFAULT = dinput
include $(TOP)/proxy.mak

View file

@ -41,7 +41,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
/* Wine mouse driver object instances */
#define WINE_MOUSE_X_AXIS_INSTANCE 0
#define WINE_MOUSE_Y_AXIS_INSTANCE 1
@ -151,7 +150,6 @@ static IDirectInputDevice8A* current_lock = NULL;
/* FIXME: This is ugly but needed on Windows */
static int mouse_set = 0;
static GUID DInput_Wine_Mouse_GUID = { /* 9e573ed8-7734-11d2-8d4a-23903fb6bdf7 */
0x9e573ed8,
0x7734,
@ -159,7 +157,7 @@ static GUID DInput_Wine_Mouse_GUID = { /* 9e573ed8-7734-11d2-8d4a-23903fb6bdf7 *
{0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
};
static void fill_mouse_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int version) {
static void fill_mouse_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version) {
DWORD dwSize;
DIDEVICEINSTANCEA ddi;
@ -173,7 +171,7 @@ static void fill_mouse_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int version)
ddi.dwSize = dwSize;
ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */
ddi.guidProduct = DInput_Wine_Mouse_GUID; /* Vendor's GUID */
if (version >= 8)
if (version >= 0x0800)
ddi.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
else
ddi.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
@ -183,7 +181,7 @@ static void fill_mouse_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int version)
memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
}
static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int version) {
static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version) {
DWORD dwSize;
DIDEVICEINSTANCEW ddi;
@ -197,7 +195,7 @@ static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int version)
ddi.dwSize = dwSize;
ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */
ddi.guidProduct = DInput_Wine_Mouse_GUID; /* Vendor's GUID */
if (version >= 8)
if (version >= 0x0800)
ddi.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
else
ddi.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
@ -207,14 +205,14 @@ static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int version)
memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
}
static BOOL mousedev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version, int id)
static BOOL mousedev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
{
if (id != 0)
return FALSE;
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_MOUSE) && (version < 8)) ||
(((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 8))) {
((dwDevType == DIDEVTYPE_MOUSE) && (version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 0x0800))) {
TRACE("Enumerating the mouse device\n");
fill_mouse_dideviceinstanceA(lpddi, version);
@ -225,14 +223,14 @@ static BOOL mousedev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINST
return FALSE;
}
static BOOL mousedev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version, int id)
static BOOL mousedev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
{
if (id != 0)
return FALSE;
if ((dwDevType == 0) ||
((dwDevType == DIDEVTYPE_MOUSE) && (version < 8)) ||
(((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 8))) {
((dwDevType == DIDEVTYPE_MOUSE) && (version < 0x0800)) ||
(((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 0x0800))) {
TRACE("Enumerating the mouse device\n");
fill_mouse_dideviceinstanceW(lpddi, version);
@ -243,7 +241,7 @@ static BOOL mousedev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINST
return FALSE;
}
static SysMouseImpl *alloc_device_mouse(REFGUID rguid, LPVOID mvt, IDirectInputImpl *dinput)
static SysMouseImpl *alloc_device(REFGUID rguid, LPVOID mvt, IDirectInputImpl *dinput)
{
int offset_array[WINE_INTERNALMOUSE_NUM_OBJS] = {
FIELD_OFFSET(Wine_InternalMouseData, lX),
@ -257,15 +255,13 @@ static SysMouseImpl *alloc_device_mouse(REFGUID rguid, LPVOID mvt, IDirectInputI
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseImpl));
newDevice->ref = 1;
newDevice->lpVtbl = mvt;
#ifndef __REACTOS__
InitializeCriticalSection(&(newDevice->crit));
#endif
memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
/* Per default, Wine uses its internal data format */
newDevice->df = (DIDATAFORMAT *) &Wine_InternalMouseFormat;
memcpy(newDevice->offset_array, offset_array, WINE_INTERNALMOUSE_NUM_OBJS * sizeof(int));
newDevice->wine_df = (DataFormat *) HeapAlloc(GetProcessHeap(), 0, sizeof(DataFormat));
newDevice->wine_df = HeapAlloc(GetProcessHeap(), 0, sizeof(DataFormat));
newDevice->wine_df->size = 0;
newDevice->wine_df->internal_format_size = Wine_InternalMouseFormat.dwDataSize;
newDevice->wine_df->dt = NULL;
@ -283,7 +279,7 @@ static HRESULT mousedev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid,
IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
*pdev = (IDirectInputDeviceA*) alloc_device_mouse(rguid, &SysMouseAvt, dinput);
*pdev = (IDirectInputDeviceA*) alloc_device(rguid, &SysMouseAvt, dinput);
TRACE("Creating a Mouse device (%p)\n", *pdev);
return DI_OK;
} else
@ -302,7 +298,7 @@ static HRESULT mousedev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid,
IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
*pdev = (IDirectInputDeviceW*) alloc_device_mouse(rguid, &SysMouseWvt, dinput);
*pdev = (IDirectInputDeviceW*) alloc_device(rguid, &SysMouseWvt, dinput);
TRACE("Creating a Mouse device (%p)\n", *pdev);
return DI_OK;
} else
@ -312,8 +308,7 @@ static HRESULT mousedev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid,
return DIERR_DEVICENOTREG;
}
static dinput_device mousedev = {
100,
const struct dinput_device mouse_device = {
"Wine mouse driver",
mousedev_enum_deviceA,
mousedev_enum_deviceW,
@ -321,15 +316,6 @@ static dinput_device mousedev = {
mousedev_create_deviceW
};
#ifdef __REACTOS__
void scan_mouse()
{
dinput_register_device(&mousedev);
}
DECL_GLOBAL_CONSTRUCTOR(mousedev_register) { dinput_register_device(&mousedev); }
#endif
/******************************************************************************
* SysMouseA (DInput Mouse support)
*/
@ -348,18 +334,15 @@ static ULONG WINAPI SysMouseAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
/* Free the data queue */
HeapFree(GetProcessHeap(),0,This->data_queue);
if (This->hook) {
UnhookWindowsHookEx( This->hook );
if (This->dwCoopLevel & DISCL_EXCLUSIVE)
ShowCursor(TRUE); /* show cursor */
}
#ifndef __REACTOS__
DeleteCriticalSection(&(This->crit));
#endif
/* Free the DataFormat */
/* Free the DataFormat */
if (This->df != &(Wine_InternalMouseFormat)) {
HeapFree(GetProcessHeap(), 0, This->df->rgodf);
HeapFree(GetProcessHeap(), 0, This->df);
@ -443,10 +426,7 @@ static LRESULT CALLBACK dinput_mouse_hook( int code, WPARAM wparam, LPARAM lpara
if (code != HC_ACTION) return CallNextHookEx( This->hook, code, wparam, lparam );
#ifndef __REACTOS__
EnterCriticalSection(&(This->crit));
#endif
dwCoop = This->dwCoopLevel;
/* Only allow mouse events every 10 ms.
@ -563,9 +543,7 @@ static LRESULT CALLBACK dinput_mouse_hook( int code, WPARAM wparam, LPARAM lpara
This->m_state.rgbButtons[0], This->m_state.rgbButtons[2], This->m_state.rgbButtons[1]);
end:
#ifndef __REACTOS__
LeaveCriticalSection(&(This->crit));
#endif
if (dwCoop & DISCL_NONEXCLUSIVE) {
/* Pass the events down to previous handlers (e.g. win32 input) */
@ -602,66 +580,61 @@ static void dinput_window_check(SysMouseImpl* This) {
static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
{
SysMouseImpl *This = (SysMouseImpl *)iface;
RECT rect;
RECT rect;
POINT point;
TRACE("(this=%p)\n",This);
if (This->acquired)
return S_FALSE;
This->acquired = 1;
if (This->acquired == 0) {
POINT point;
/* Store (in a global variable) the current lock */
current_lock = (IDirectInputDevice8A*)This;
/* Init the mouse state */
GetCursorPos( &point );
if (This->absolute) {
This->m_state.lX = point.x;
This->m_state.lY = point.y;
This->prevX = point.x;
This->prevY = point.y;
} else {
This->m_state.lX = 0;
This->m_state.lY = 0;
This->org_coords = point;
}
This->m_state.lZ = 0;
This->m_state.rgbButtons[0] = ((GetKeyState(VK_LBUTTON) & 0x80) ? 0xFF : 0x00);
This->m_state.rgbButtons[1] = ((GetKeyState(VK_RBUTTON) & 0x80) ? 0xFF : 0x00);
This->m_state.rgbButtons[2] = ((GetKeyState(VK_MBUTTON) & 0x80) ? 0xFF : 0x00);
/* Install our mouse hook */
if (This->dwCoopLevel & DISCL_EXCLUSIVE)
ShowCursor(FALSE); /* hide cursor */
This->hook = SetWindowsHookExA( WH_MOUSE_LL, dinput_mouse_hook, DINPUT_instance, 0 );
/* Get the window dimension and find the center */
GetWindowRect(This->win, &rect);
This->win_centerX = (rect.right - rect.left) / 2;
This->win_centerY = (rect.bottom - rect.top ) / 2;
/* Warp the mouse to the center of the window */
if (This->absolute == 0) {
This->mapped_center.x = This->win_centerX;
This->mapped_center.y = This->win_centerY;
MapWindowPoints(This->win, HWND_DESKTOP, &This->mapped_center, 1);
TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
SetCursorPos( This->mapped_center.x, This->mapped_center.y );
#ifdef MOUSE_HACK
This->need_warp = WARP_DONE;
#else
This->need_warp = WARP_STARTED;
#endif
}
This->acquired = 1;
return DI_OK;
/* Store (in a global variable) the current lock */
current_lock = (IDirectInputDevice8A*)This;
/* Init the mouse state */
GetCursorPos( &point );
if (This->absolute) {
This->m_state.lX = point.x;
This->m_state.lY = point.y;
This->prevX = point.x;
This->prevY = point.y;
} else {
This->m_state.lX = 0;
This->m_state.lY = 0;
This->org_coords = point;
}
return S_FALSE;
This->m_state.lZ = 0;
This->m_state.rgbButtons[0] = GetKeyState(VK_LBUTTON) & 0x80;
This->m_state.rgbButtons[1] = GetKeyState(VK_RBUTTON) & 0x80;
This->m_state.rgbButtons[2] = GetKeyState(VK_MBUTTON) & 0x80;
/* Install our mouse hook */
if (This->dwCoopLevel & DISCL_EXCLUSIVE)
ShowCursor(FALSE); /* hide cursor */
This->hook = SetWindowsHookExA( WH_MOUSE_LL, dinput_mouse_hook, DINPUT_instance, 0 );
/* Get the window dimension and find the center */
GetWindowRect(This->win, &rect);
This->win_centerX = (rect.right - rect.left) / 2;
This->win_centerY = (rect.bottom - rect.top ) / 2;
/* Warp the mouse to the center of the window */
if (This->absolute == 0) {
This->mapped_center.x = This->win_centerX;
This->mapped_center.y = This->win_centerY;
MapWindowPoints(This->win, HWND_DESKTOP, &This->mapped_center, 1);
TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
SetCursorPos( This->mapped_center.x, This->mapped_center.y );
#ifdef MOUSE_HACK
This->need_warp = WARP_DONE;
#else
This->need_warp = WARP_STARTED;
#endif
}
return DI_OK;
}
/******************************************************************************
@ -673,33 +646,34 @@ static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
TRACE("(this=%p)\n",This);
if (This->acquired) {
/* Reinstall previous mouse event handler */
if (This->hook) {
UnhookWindowsHookEx( This->hook );
This->hook = 0;
if (This->dwCoopLevel & DISCL_EXCLUSIVE)
ShowCursor(TRUE); /* show cursor */
}
/* No more locks */
current_lock = NULL;
/* Unacquire device */
This->acquired = 0;
/* And put the mouse cursor back where it was at acquire time */
if (This->absolute == 0) {
TRACE(" warping mouse back to (%ld , %ld)\n", This->org_coords.x, This->org_coords.y);
SetCursorPos(This->org_coords.x, This->org_coords.y);
}
} else {
if (0 == This->acquired) {
return DI_NOEFFECT;
}
/* Reinstall previous mouse event handler */
if (This->hook) {
UnhookWindowsHookEx( This->hook );
This->hook = 0;
if (This->dwCoopLevel & DISCL_EXCLUSIVE)
ShowCursor(TRUE); /* show cursor */
}
/* No more locks */
if (current_lock == (IDirectInputDevice8A*) This)
current_lock = NULL;
else
ERR("this(%p) != current_lock(%p)\n", This, current_lock);
/* Unacquire device */
This->acquired = 0;
/* And put the mouse cursor back where it was at acquire time */
if (This->absolute == 0) {
TRACE(" warping mouse back to (%ld , %ld)\n", This->org_coords.x, This->org_coords.y);
SetCursorPos(This->org_coords.x, This->org_coords.y);
}
return DI_OK;
}
@ -707,53 +681,6 @@ static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
// it did not send back right value in windows
int poll_mouse=0;
#ifdef __REACTOS__
void getmousesvalue(LPDIRECTINPUTDEVICE8A iface);
int filp=0;
void getmousesvalue(LPDIRECTINPUTDEVICE8A iface)
{
POINT point;
SysMouseImpl *This = (SysMouseImpl *)iface;
This->m_state.rgbButtons[0] = ((GetKeyState(VK_LBUTTON) & 0x80) ? 0xFF : 0x00);
This->m_state.rgbButtons[1] = ((GetKeyState(VK_RBUTTON) & 0x80) ? 0xFF : 0x00);
This->m_state.rgbButtons[2] = ((GetKeyState(VK_MBUTTON) & 0x80) ? 0xFF : 0x00);
This->m_state.rgbButtons[3] = ((GetKeyState(VK_XBUTTON1) & 0x80) ? 0xFF : 0x00);
This->m_state.rgbButtons[4] = ((GetKeyState(VK_XBUTTON2) & 0x80) ? 0xFF : 0x00);
if (poll_mouse==1) filp=0;
if (filp==2) filp=0;
if (filp==0) {
GetCursorPos( &point );
if (This->prevX == point.x) This->m_state.lX = 0;
else {
This->prevX = point.x;
This->m_state.lX = point.x - This->org_coords.x;
}
if (This->prevY == point.y) This->m_state.lY = 0;
else {
This->prevY = point.y;
This->m_state.lY = point.y - This->org_coords.y;
}
}
else
{
This->m_state.lX = 0;
This->m_state.lY = 0;
}
filp++;
// check see if buffer have been set
}
#endif
static HRESULT WINAPI SysMouseAImpl_Poll(LPDIRECTINPUTDEVICE8A iface)
{
@ -779,36 +706,38 @@ static HRESULT WINAPI SysMouseAImpl_Poll(LPDIRECTINPUTDEVICE8A iface)
static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
) {
SysMouseImpl *This = (SysMouseImpl *)iface;
SysMouseImpl *This = (SysMouseImpl *)iface;
if(This->acquired == 0) return DIERR_NOTACQUIRED;
#ifndef __REACTOS__
EnterCriticalSection(&(This->crit));
#endif
TRACE("(this=%p,0x%08lx,%p): \n",This,len,ptr);
/* Copy the current mouse state */
TRACE("(X: %ld - Y: %ld - Z: %ld L: %02x M: %02x R: %02x)\n",
This->m_state.lX, This->m_state.lY, This->m_state.lZ,
This->m_state.rgbButtons[0], This->m_state.rgbButtons[2], This->m_state.rgbButtons[1]);
/* Copy the current mouse state */
fill_DataFormat(ptr, &(This->m_state), This->wine_df);
#ifdef __REACTOS__
// this fix windows bugs when
// some program calling on mouse poll
if (poll_mouse==1) poll_mouse=0;
else {
if (This->absolute == 0) {
This->m_state.lX = 0;
This->m_state.lY = 0;
This->m_state.lZ = 0;
}
if (This->absolute == 0) {
This->m_state.lX = 0;
This->m_state.lY = 0;
This->m_state.lZ = 0;
}
}
#endif
/* Check if we need to do a mouse warping */
if (This->need_warp == WARP_NEEDED) {
dinput_window_check(This);
TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
if (mouse_set==0){
SetCursorPos( This->mapped_center.x, This->mapped_center.y );
SetCursorPos( This->mapped_center.x, This->mapped_center.y );
mouse_set++;
}
@ -818,23 +747,15 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
This->need_warp = WARP_STARTED;
#endif
}
#ifndef __REACTOS__
LeaveCriticalSection(&(This->crit));
#endif
TRACE("(X: %ld - Y: %ld - Z: %ld L: %02x M: %02x R: %02x)\n",
This->m_state.lX, This->m_state.lY, This->m_state.lZ,
This->m_state.rgbButtons[0], This->m_state.rgbButtons[2], This->m_state.rgbButtons[1]);
return DI_OK;
}
/******************************************************************************
* GetDeviceState : gets buffered input data.
* GetDeviceData : gets buffered input data.
*/
static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
DWORD dodsize,
LPDIDEVICEOBJECTDATA dod,
@ -843,13 +764,13 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
) {
SysMouseImpl *This = (SysMouseImpl *)iface;
DWORD len;
int nqtail;
int nqtail = 0;
TRACE("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx)\n",This,dodsize,*entries,flags);
if (This->acquired == 0) {
TRACE("(%p)->(dods=%ld,dod=%p,entries=%p (%ld)%s,fl=0x%08lx%s)\n",This,dodsize,dod,
entries, *entries,*entries == INFINITE ? " (INFINITE)" : "",
flags, (flags & DIGDD_PEEK) ? " (DIGDD_PEEK)": "" );
if (This->acquired == 0) {
WARN(" application tries to get data from an unacquired device !\n");
//return DIERR_NOTACQUIRED;
@ -859,49 +780,48 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
// in windows GetdeviceData does always update first the data
// then return it.
SysMouseAImpl_Acquire(iface);
}
}
#ifndef __REACTOS__
EnterCriticalSection(&(This->crit));
#endif
// FIXME mouse are bit choppy here.
len = ((This->queue_head < This->queue_tail) ? This->queue_len : 0)
+ (This->queue_head - This->queue_tail);
if (len > *entries) len = *entries;
if ((*entries != INFINITE) && (len > *entries)) len = *entries;
if (dod == NULL) {
if (len)
TRACE("Application discarding %ld event(s).\n", len);
*entries = len;
nqtail = This->queue_tail + len;
while (nqtail >= This->queue_len) nqtail -= This->queue_len;
if (!(flags & DIGDD_PEEK)) {
if (len)
TRACE("Application discarding %ld event(s).\n", len);
nqtail = This->queue_tail + len;
while (nqtail >= This->queue_len) nqtail -= This->queue_len;
} else {
TRACE("Telling application that %ld event(s) are in the queue.\n", len);
}
} else {
if (dodsize < sizeof(DIDEVICEOBJECTDATA_DX3)) {
ERR("Wrong structure size !\n");
LeaveCriticalSection(&(This->crit));
return DIERR_INVALIDPARAM;
}
if (len)
TRACE("Application retrieving %ld event(s).\n", len);
TRACE("Application retrieving %ld event(s):\n", len);
*entries = 0;
nqtail = This->queue_tail;
while (len) {
/* Copy the buffered data into the application queue */
TRACE(" - queuing Offs:%2ld Data:%5ld TS:%8ld Seq:%8ld at address %p from queue tail %4d\n",
(This->data_queue)->dwOfs,
(This->data_queue)->dwData,
(This->data_queue)->dwTimeStamp,
(This->data_queue)->dwSequence,
(char *)dod + *entries * dodsize,
nqtail);
memcpy((char *)dod + *entries * dodsize, This->data_queue + nqtail, dodsize);
/* Advance position */
nqtail++;
if (nqtail >= This->queue_len)
@ -912,17 +832,15 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
}
if (!(flags & DIGDD_PEEK))
This->queue_tail = nqtail;
#ifndef __REACTOS__
LeaveCriticalSection(&(This->crit));
#endif
/* Check if we need to do a mouse warping */
if (This->need_warp == WARP_NEEDED) {
dinput_window_check(This);
TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
if (mouse_set==0){
SetCursorPos( This->mapped_center.x, This->mapped_center.y );
SetCursorPos( This->mapped_center.x, This->mapped_center.y );
mouse_set++;
}
@ -931,7 +849,7 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
#else
This->need_warp = WARP_STARTED;
#endif
}
}
return DI_OK;
}
@ -953,8 +871,7 @@ static HRESULT WINAPI SysMouseAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface,
TRACE("buffersize = %ld\n",pd->dwData);
This->data_queue = (LPDIDEVICEOBJECTDATA)HeapAlloc(GetProcessHeap(),0,
pd->dwData * sizeof(DIDEVICEOBJECTDATA));
This->data_queue = HeapAlloc(GetProcessHeap(),0, pd->dwData * sizeof(DIDEVICEOBJECTDATA));
This->queue_head = 0;
This->queue_tail = 0;
This->queue_len = pd->dwData;
@ -963,7 +880,6 @@ static HRESULT WINAPI SysMouseAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface,
case (DWORD) DIPROP_AXISMODE: {
LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
This->absolute = !(pd->dwData);
TRACE("Using %s coordinates mode now\n", This->absolute ? "absolute" : "relative");
break;
}
@ -985,7 +901,7 @@ static HRESULT WINAPI SysMouseAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
{
SysMouseImpl *This = (SysMouseImpl *)iface;
TRACE("(this=%p,%s,%p): stub!\n",
TRACE("(this=%p,%s,%p)\n",
iface, debugstr_guid(rguid), pdiph);
if (TRACE_ON(dinput))
@ -1070,7 +986,7 @@ static HRESULT WINAPI SysMouseAImpl_GetCapabilities(
devcaps.dwSize = lpDIDevCaps->dwSize;
devcaps.dwFlags = DIDC_ATTACHED;
if (This->dinput->version >= 8)
if (This->dinput->dwVersion >= 0x0800)
devcaps.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
else
devcaps.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
@ -1196,7 +1112,7 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceInfo(
return DI_OK;
}
fill_mouse_dideviceinstanceA(pdidi, This->dinput->version);
fill_mouse_dideviceinstanceA(pdidi, This->dinput->dwVersion);
return DI_OK;
}
@ -1211,7 +1127,7 @@ static HRESULT WINAPI SysMouseWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, L
return DI_OK;
}
fill_mouse_dideviceinstanceW(pdidi, This->dinput->version);
fill_mouse_dideviceinstanceW(pdidi, This->dinput->dwVersion);
return DI_OK;
}