winejoystick.drv: Implement POV support.

This commit is contained in:
Vincent Pelletier 2009-01-17 12:54:07 +01:00 committed by Alexandre Julliard
parent b04e8226e5
commit a4b201a287
1 changed files with 35 additions and 2 deletions

View File

@ -100,6 +100,8 @@ typedef struct tagWINE_JSTCK {
int r; int r;
int u; int u;
int v; int v;
int pov_x;
int pov_y;
int buttons; int buttons;
char axesMap[ABS_MAX + 1]; char axesMap[ABS_MAX + 1];
} WINE_JSTCK; } WINE_JSTCK;
@ -278,11 +280,14 @@ static const WCHAR ini[] = {'W','i','n','e',' ','J','o','y','s','t','i','c','k',
lpCaps->wNumAxes++; lpCaps->wNumAxes++;
lpCaps->wCaps |= JOYCAPS_HASV; lpCaps->wCaps |= JOYCAPS_HASV;
break; break;
case 16: /* Hat 0 X */
case 17: /* Hat 0 Y */
lpCaps->wCaps |= JOYCAPS_HASPOV | JOYCAPS_POV4DIR;
/* TODO: JOYCAPS_POVCTS handling */
break;
default: default:
WARN("Unknown axis %hhu(%hhu). Skipped.\n", jstck->axesMap[i], i); WARN("Unknown axis %hhu(%hhu). Skipped.\n", jstck->axesMap[i], i);
} }
/* FIXME: don't know how to detect for
JOYCAPS_HASPOV, JOYCAPS_POV4DIR, JOYCAPS_POVCTS */
} }
} }
#else #else
@ -359,6 +364,12 @@ static LRESULT JSTCK_GetPosEx(DWORD_PTR dwDevID, LPJOYINFOEX lpInfo)
case 4: /* Ry */ case 4: /* Ry */
jstck->v = ev.value; jstck->v = ev.value;
break; break;
case 16: /* Hat 0 X */
jstck->pov_x = ev.value;
break;
case 17: /* Hat 0 Y */
jstck->pov_y = ev.value;
break;
default: default:
FIXME("Unknown joystick event '%d'\n", ev.number); FIXME("Unknown joystick event '%d'\n", ev.number);
} }
@ -413,6 +424,28 @@ static LRESULT JSTCK_GetPosEx(DWORD_PTR dwDevID, LPJOYINFOEX lpInfo)
# endif # endif
if (lpInfo->dwFlags & JOY_RETURNV) if (lpInfo->dwFlags & JOY_RETURNV)
lpInfo->dwVpos = jstck->v + 32767; lpInfo->dwVpos = jstck->v + 32767;
if (lpInfo->dwFlags & JOY_RETURNPOV) {
if (jstck->pov_y > 0) {
if (jstck->pov_x < 0)
lpInfo->dwPOV = 22500; /* SW */
else if (jstck->pov_x > 0)
lpInfo->dwPOV = 13500; /* SE */
else
lpInfo->dwPOV = 18000; /* S, JOY_POVBACKWARD */
} else if (jstck->pov_y < 0) {
if (jstck->pov_x < 0)
lpInfo->dwPOV = 31500; /* NW */
else if (jstck->pov_x > 0)
lpInfo->dwPOV = 4500; /* NE */
else
lpInfo->dwPOV = 0; /* N, JOY_POVFORWARD */
} else if (jstck->pov_x < 0)
lpInfo->dwPOV = 27000; /* W, JOY_POVLEFT */
else if (jstck->pov_x > 0)
lpInfo->dwPOV = 9000; /* E, JOY_POVRIGHT */
else
lpInfo->dwPOV = JOY_POVCENTERED; /* Center */
}
#else #else
dev_stat = read(dev, &js, sizeof(js)); dev_stat = read(dev, &js, sizeof(js));