[dinput-6/6] implement range for GetProperty
Christoph Frick
frick at sc-networks.de
Mon Jul 3 04:33:19 CDT 2006
License: LGPL
ChangeLog:
2006-07-02 Christoph Frick <rid at zefix.tv>
implements the GetProperty call for getting the range of an axis
---
dlls/dinput/joystick_linuxinput.c | 45 ++++++++++++++++++++++---------------
1 files changed, 27 insertions(+), 18 deletions(-)
diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c
index 6d3f06a..d7ded74 100644
--- a/dlls/dinput/joystick_linuxinput.c
+++ b/dlls/dinput/joystick_linuxinput.c
@@ -145,6 +145,8 @@ struct JoystickImpl
/* LUT for KEY_ to offset in rgbButtons */
BYTE buttons[KEY_MAX];
+ BOOL base_setup;
+
#define AXE_ABS 0
#define AXE_ABSMIN 1
#define AXE_ABSMAX 2
@@ -159,6 +161,8 @@ static void find_joydevs(void);
static int lxinput_to_djoy2_offset(int ie_type, int ie_code);
static int offset_to_object(JoystickImpl *This, int offset);
static void calculate_ids(LPDIDATAFORMAT df);
+static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface);
+static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface);
/* This GUID is slightly different from the linux joystick one. Take note. */
static const GUID DInput_Wine_Joystick_Base_GUID = { /* 9e573eda-7734-11d2-8d4a-23903fb6bdf7 */
@@ -342,7 +346,6 @@ #endif
static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *dinput, struct JoyDev *joydev)
{
JoystickImpl* newDevice;
- int i;
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl));
if (newDevice==NULL) {
@@ -358,17 +361,6 @@ #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
newDevice->ff_state = FF_STATUS_STOPPED;
#endif
memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
- for (i=0;i<ABS_MAX;i++) {
- newDevice->wantmin[i] = -32768;
- newDevice->wantmax[i] = 32767;
- /* TODO:
- * direct input defines a default for the deadzone somewhere; but as long
- * as in map_axis the code for the dead zone is commented out its no
- * problem
- */
- newDevice->deadz[i] = 0;
- }
- fake_current_js_state(newDevice);
/* wine uses DIJOYSTATE2 as it's internal format so copy
* the already defined format c_dfDIJoystick2 */
@@ -406,6 +398,16 @@ #endif
newDevice->transform = create_DataFormat(newDevice->internal_df, newDevice->df, newDevice->offsets);
calculate_ids(newDevice->df);
+ /*
+ * TODO:
+ * GetProperty needs to work even if not acquired - but we read infos from
+ * the device while we acquire - so for now just acquire and release as this
+ * does not much harm and for the future we should move the axes/buttons
+ * members into to the JoyDev struct and init them while find_joydevs runs
+ */
+ JoystickAImpl_Acquire((LPDIRECTINPUTDEVICE8A)newDevice);
+ JoystickAImpl_Unacquire((LPDIRECTINPUTDEVICE8A)newDevice);
+
return newDevice;
FAILED:
@@ -624,6 +626,10 @@ static HRESULT WINAPI JoystickAImpl_Acqu
);
This->havemin[i] = This->axes[i][AXE_ABSMIN];
This->havemax[i] = This->axes[i][AXE_ABSMAX];
+ if (!This->base_setup) {
+ This->wantmin[i] = This->havemin[i];
+ This->wantmax[i] = This->havemax[i];
+ }
}
}
buttons = 0;
@@ -637,6 +643,8 @@ static HRESULT WINAPI JoystickAImpl_Acqu
fake_current_js_state(This);
+ This->base_setup = TRUE;
+
return 0;
}
@@ -1454,13 +1462,14 @@ static HRESULT WINAPI JoystickAImpl_GetP
}
case (DWORD) DIPROP_RANGE: {
- /* LPDIPROPRANGE pr = (LPDIPROPRANGE) pdiph; */
- if ((pdiph->dwHow == DIPH_BYID) &&
- (pdiph->dwObj & DIDFT_ABSAXIS)) {
- /* The app is querying the current range of the axis : return the lMin and lMax values */
- FIXME("unimplemented axis range query.\n");
+ LPDIPROPRANGE pr = (LPDIPROPRANGE) pdiph;
+ int obj = find_property_offset(This, pdiph);
+ if (obj >= 0) {
+ pr->lMin = This->havemin[obj];
+ pr->lMax = This->havemax[obj];
+ TRACE("range(%ld, %ld) obj=%d\n", pr->lMin, pr->lMax, obj);
+ return DI_OK;
}
-
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20060703/cf19fea0/attachment.pgp
More information about the wine-patches
mailing list