server: Use create_request_async for write requests.
[wine.git] / dlls / xinput1_3 / xinput1_3_main.c
blob402bd2f468f684a33d5f88a21e6b546b08ca4b97
1 /*
2 * The Wine project - Xinput Joystick Library
3 * Copyright 2008 Andrew Fenn
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "config.h"
21 #include <assert.h>
22 #include <stdarg.h>
23 #include <string.h>
25 #include "wine/debug.h"
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winerror.h"
30 #include "xinput.h"
32 /* Not defined in the headers, used only by XInputGetStateEx */
33 #define XINPUT_GAMEPAD_GUIDE 0x0400
35 WINE_DEFAULT_DEBUG_CHANNEL(xinput);
37 struct
39 BOOL connected;
40 } controllers[XUSER_MAX_COUNT];
42 BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved)
44 switch(reason)
46 case DLL_PROCESS_ATTACH:
47 DisableThreadLibraryCalls(inst);
48 break;
50 return TRUE;
53 void WINAPI DECLSPEC_HOTPATCH XInputEnable(BOOL enable)
55 /* Setting to false will stop messages from XInputSetState being sent
56 to the controllers. Setting to true will send the last vibration
57 value (sent to XInputSetState) to the controller and allow messages to
58 be sent */
59 FIXME("(enable %d) Stub!\n", enable);
62 DWORD WINAPI XInputSetState(DWORD index, XINPUT_VIBRATION* vibration)
64 FIXME("(index %u, vibration %p) Stub!\n", index, vibration);
66 if (index >= XUSER_MAX_COUNT)
67 return ERROR_BAD_ARGUMENTS;
68 if (!controllers[index].connected)
69 return ERROR_DEVICE_NOT_CONNECTED;
71 return ERROR_NOT_SUPPORTED;
74 DWORD WINAPI DECLSPEC_HOTPATCH XInputGetState(DWORD index, XINPUT_STATE* state)
76 union
78 XINPUT_STATE state;
79 XINPUT_STATE_EX state_ex;
80 } xinput;
81 DWORD ret;
82 static int warn_once;
84 if (!warn_once++)
85 FIXME("(index %u, state %p) Stub!\n", index, state);
87 ret = XInputGetStateEx(index, &xinput.state_ex);
88 if (ret != ERROR_SUCCESS)
89 return ret;
91 /* The main difference between this and the Ex version is the media guide button */
92 xinput.state.Gamepad.wButtons &= ~XINPUT_GAMEPAD_GUIDE;
93 *state = xinput.state;
95 return ERROR_SUCCESS;
98 DWORD WINAPI DECLSPEC_HOTPATCH XInputGetStateEx(DWORD index, XINPUT_STATE_EX* state_ex)
100 static int warn_once;
102 if (!warn_once++)
103 FIXME("(index %u, state %p) Stub!\n", index, state_ex);
105 if (index >= XUSER_MAX_COUNT)
106 return ERROR_BAD_ARGUMENTS;
107 if (!controllers[index].connected)
108 return ERROR_DEVICE_NOT_CONNECTED;
110 return ERROR_NOT_SUPPORTED;
113 DWORD WINAPI XInputGetKeystroke(DWORD index, DWORD reserved, PXINPUT_KEYSTROKE keystroke)
115 static int warn_once;
117 if (!warn_once++)
118 FIXME("(index %u, reserved %u, keystroke %p) Stub!\n", index, reserved, keystroke);
120 if (index >= XUSER_MAX_COUNT)
121 return ERROR_BAD_ARGUMENTS;
122 if (!controllers[index].connected)
123 return ERROR_DEVICE_NOT_CONNECTED;
125 return ERROR_NOT_SUPPORTED;
128 DWORD WINAPI XInputGetCapabilities(DWORD index, DWORD flags, XINPUT_CAPABILITIES* capabilities)
130 static int warn_once;
132 if (!warn_once++)
133 FIXME("(index %u, flags 0x%x, capabilities %p) Stub!\n", index, flags, capabilities);
135 if (index >= XUSER_MAX_COUNT)
136 return ERROR_BAD_ARGUMENTS;
137 if (!controllers[index].connected)
138 return ERROR_DEVICE_NOT_CONNECTED;
140 return ERROR_NOT_SUPPORTED;
143 DWORD WINAPI XInputGetDSoundAudioDeviceGuids(DWORD index, GUID* render_guid, GUID* capture_guid)
145 FIXME("(index %u, render guid %p, capture guid %p) Stub!\n", index, render_guid, capture_guid);
147 if (index >= XUSER_MAX_COUNT)
148 return ERROR_BAD_ARGUMENTS;
149 if (!controllers[index].connected)
150 return ERROR_DEVICE_NOT_CONNECTED;
152 return ERROR_NOT_SUPPORTED;
155 DWORD WINAPI XInputGetBatteryInformation(DWORD index, BYTE type, XINPUT_BATTERY_INFORMATION* battery)
157 FIXME("(index %u, type %u, battery %p) Stub!\n", index, type, battery);
159 if (index >= XUSER_MAX_COUNT)
160 return ERROR_BAD_ARGUMENTS;
161 if (!controllers[index].connected)
162 return ERROR_DEVICE_NOT_CONNECTED;
164 return ERROR_NOT_SUPPORTED;