19 struct IDirectInputA *result;
28 IDirectInputDeviceA *base_device;
30 if (dinput_interface->lpVtbl->CreateDevice(dinput_interface, &device_guid, &base_device, NULL))
34 base_device->lpVtbl->Release(base_device);
44 void *result = device;
48 return (IDirectInputDevice2A *)result;
57 return !(device->lpVtbl->SetCooperativeLevel(device, hwnd, flags));
64 return !(device->lpVtbl->SetDataFormat(device, data_format));
74 return !(device->lpVtbl->Acquire(device));
83 return device->lpVtbl->GetDeviceState(device, state_size, state_buffer) == 0 ? state_buffer : NULL;
91 if (!device_instance || !enum_context)
94 enum_context->
guid_list[enum_context->
count] = device_instance->guidInstance;
95 enum_context->
count += 1;
105 DIPROPRANGE range_property;
107 range_property.diph.dwObj = axis_offset;
108 range_property.lMax = max_value;
109 range_property.lMin = min_value;
110 IDirectInputDeviceAVtbl *vtable = device->lpVtbl;
111 range_property.diph.dwSize =
sizeof(DIPROPRANGE);
112 range_property.diph.dwHeaderSize =
sizeof(DIPROPHEADER);
113 range_property.diph.dwHow = DIPH_BYOFFSET;
115 return !(vtable->SetProperty(device, DIPROP_RANGE, &range_property.diph));
152 &enum_context, DIEDFL_ATTACHEDONLY);
153 return enum_context.
count;
181 IDirectInputDeviceA *base_device = (IDirectInputDeviceA *)device;
182 device->lpVtbl->Poll(device);
197 return joy_state->
pos.
x;
206 return joy_state->
pos.
y;
215 return joy_state->
rot.
z;
244 if (device_index >= count)
269 DIPROPDWORD auto_center = {{
sizeof(DIPROPDWORD),
sizeof(DIPROPHEADER), 0, 0}, 0};
271 if (device->lpVtbl->SetProperty(device, DIPROP_AUTOCENTER, &auto_center.diph) < 0)
274 DWORD axes[2] = {DIJOFS_X, DIJOFS_Y};
276 LONG direction[2] = {0, 0};
277 DICONSTANTFORCE force = {0};
278 DIEFFECT effect = {0};
279 effect.dwSize =
sizeof(DIEFFECT);
280 effect.dwFlags = DIEFF_OBJECTOFFSETS | DIEFF_CARTESIAN;
281 effect.dwDuration = INFINITE;
282 effect.dwGain = DI_FFNOMINALMAX;
283 effect.dwTriggerButton = DIEB_NOTRIGGER;
285 effect.rgdwAxes = axes;
286 effect.rglDirection = direction;
287 effect.cbTypeSpecificParams =
sizeof(DICONSTANTFORCE);
288 effect.lpvTypeSpecificParams = &force;
322 if (!attached_joystick_count)
323 return attached_joystick_count;
326 IDirectInputDevice2A *device =
333 IDirectInputDeviceA *base_device = (IDirectInputDeviceA *)device;
346 (void)unused_player_index;
358 if (old_joystick_state)
368 joystick_device->lpVtbl->Release(joystick_device);
376 input_interface->lpVtbl->Release(input_interface);
399HRESULT __stdcall
DInput_CreateA(HINSTANCE hinst, DWORD dw_version, IDirectInputA **pp_di, IUnknown *p_unk_outer)
int32_t Input_GetJoystickAxisY(struct Input_JoystickState *joy_state)
uint8_t Input_GetJoystickButtonByte(struct Input_JoystickState *joy_state, int32_t button_index)
BOOL Input_SetJoystickDataFormat(IDirectInputDeviceA *device)
BOOL Input_SetJoystick2DataFormat(IDirectInputDeviceA *device)
BOOL Input_SetJoystickXAxisRange(IDirectInputDeviceA *device, LONG min_value, LONG max_value)
void Input_ReadDevices(int32_t unused_player_index, struct Input_State *state)
BOOL Input_SetJoystickRzAxisRange(IDirectInputDeviceA *device, LONG min_value, LONG max_value)
BOOL Input_SetDeviceCooperativeLevel(IDirectInputDeviceA *device, HWND hwnd, DWORD flags)
BOOL DInput_InitializeJoystickInput(HWND hwnd, HINSTANCE h_instance)
int32_t Input_GetJoystickAxisRz(struct Input_JoystickState *joy_state)
struct Input_JoystickState * Input_PollJoystickState(IDirectInputDevice2A *device)
void DInput_ReleaseResources()
HRESULT DInput_CreateA(HINSTANCE hinst, DWORD dw_version, IDirectInputA **pp_di, IUnknown *p_unk_outer)
IDirectInputDevice2A * DInput_CreateJoystickDevice(IDirectInputA *direct_input, HWND hwnd, int32_t device_index)
void * Input_GetDeviceStateBuffer(IDirectInputDeviceA *device, DWORD state_size)
BOOL Input_IsJoystickButtonPressed(struct Input_JoystickState *joy_state, int32_t button_index)
IDirectInputDevice2A * DInput_CreateDevice2A(IDirectInputA *dinput_interface, GUID device_guid)
IDirectInputDevice2A * DInput_CreateConfiguredJoystickDevice(IDirectInputA *direct_input, HWND hwnd, int32_t device_index, int32_t setup_mode)
IDirectInputDevice2A * DInput_QueryDevice2AInterface(IDirectInputDeviceA *device)
BOOL Input_SetDeviceDataFormat(IDirectInputDeviceA *device, DIDATAFORMAT const *data_format)
BOOL Input_SetExclusiveForegroundCooperativeLevel(IDirectInputDeviceA *device, HWND hwnd)
BOOL Input_SetJoystickZAxisRange(IDirectInputDeviceA *device, LONG min_value, LONG max_value)
BOOL Input_SetJoystickYAxisRange(IDirectInputDeviceA *device, LONG min_value, LONG max_value)
int32_t DInput_EnumerateAttachedJoysticks(IDirectInputA *direct_input, GUID *device_guid_buffer)
BOOL DInput_EnumJoystickDeviceCallback(DIDEVICEINSTANCEA const *device_instance, void *context)
BOOL Input_AcquireDevice(IDirectInputDeviceA *device)
IDirectInputA * DInput_CreateInterface(HINSTANCE h_instance)
BOOL Input_SetJoystickAxisRangeProperty(IDirectInputDeviceA *device, DWORD axis_offset, LONG min_value, LONG max_value)
int32_t Input_GetJoystickAxisX(struct Input_JoystickState *joy_state)
#define Input_Joystick2DataFormat
#define Input_JoystickDataFormat
#define Input_GUID_ConstantForce
void * CRT_malloc(uint32_t size)
#define g_keyboardMappingButtons
#define g_keyboardMappingKeys