Christoph Frick wrote:
with Vitaliy's patches i tried my games yesterday and everything seemed ok (RBR works again). but my clutch on the wheel did not work and also
That's a good news. I was hopping not to brake too many things while reorganizing the dinput.
@@ -128,11 +122,20 @@ struct JoystickImpl /* The 'parent' DInput */ IDirectInputImpl *dinput;
- /* autodetecting ranges per axe by following movement */
- LONG havemax[8];
- LONG havemin[8];
I could never understood why we need these? In other joystick_linux the range assumed to be 0 - 0xffff.
/* joystick private */ /* what range and deadzone the game wants */
- LONG wantmin[ABS_MAX];
- LONG wantmax[ABS_MAX];
- LONG deadz[ABS_MAX];
- LONG wantmin[8];
- LONG wantmax[8];
- LONG deadz[8];
Can we move these into separate struct like it's done in joystick_linux? It's much cleaner end eventually will allow a better integration of two.
And can you use spaces instead of tabs please?
@@ -395,19 +373,29 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm /* Supported Axis & POVs should map 1-to-1 */ for (i = 0; i < 8; i++) {
if (!test_bit(newDevice->joydev->absbits, i)) continue;
if (!test_bit(newDevice->joydev->absbits, i)) {
newDevice->axes[i] = -1;
continue;
}
Can you please don't brake the good readable style? Please put that curly bracket into separate line, and use 4 space indentation.
- fake_current_js_state(newDevice);
Can you explain what this suppose to do? Why do we need to "fake current state" everywhere?
int axe = This->axes[ie.code];
It's an "axis" not an "axe" :)
Vitaliy.
On Thu, Jan 11, 2007 at 10:25:51AM -0700, Vitaliy Margolen wrote:
@@ -128,11 +122,20 @@ struct JoystickImpl /* The 'parent' DInput */ IDirectInputImpl *dinput;
- /* autodetecting ranges per axe by following movement */
- LONG havemax[8];
- LONG havemin[8];
I could never understood why we need these? In other joystick_linux the range assumed to be 0 - 0xffff.
linux/input.h reports us the proper ranges from the device. these numbers will also be used as teh want(min|max). so what this numbers are good for. apps that want the input as "pure" as it gets dont SetProperty some something and just get what the hardware tells them (e.g. RBR does so).
/* joystick private */ /* what range and deadzone the game wants */
- LONG wantmin[ABS_MAX];
- LONG wantmax[ABS_MAX];
- LONG deadz[ABS_MAX];
- LONG wantmin[8];
- LONG wantmax[8];
- LONG deadz[8];
Can we move these into separate struct like it's done in joystick_linux? It's much cleaner end eventually will allow a better integration of two.
i will do this.
And can you use spaces instead of tabs please?
of course
@@ -395,19 +373,29 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm /* Supported Axis & POVs should map 1-to-1 */ for (i = 0; i < 8; i++) {
if (!test_bit(newDevice->joydev->absbits, i)) continue;
if (!test_bit(newDevice->joydev->absbits, i)) {
newDevice->axes[i] = -1;
continue;
}
Can you please don't brake the good readable style? Please put that curly bracket into separate line, and use 4 space indentation.
sorry - to a K&R guy that uses ts=8 as default this all is unreadable gibberish; i will try my best here.
- fake_current_js_state(newDevice);
Can you explain what this suppose to do? Why do we need to "fake current state" everywhere?
after e.g. SetProperties and initializing the device we have to put the values of the DIJOYSTATE2 in a sane state. e.g. GPL set the ranges to 1000-25k; where my pedals are in 0..512; so the app gets in the next step after the setting a default value of 512 (clutch not pressed) and gets nuts.
int axe = This->axes[ie.code];
It's an "axis" not an "axe" :)
it was 0300 and i guess i wished for an axe there ;)
Christoph Frick wrote:
On Thu, Jan 11, 2007 at 10:25:51AM -0700, Vitaliy Margolen wrote:
@@ -128,11 +122,20 @@ struct JoystickImpl /* The 'parent' DInput */ IDirectInputImpl *dinput;
- /* autodetecting ranges per axe by following movement */
- LONG havemax[8];
- LONG havemin[8];
I could never understood why we need these? In other joystick_linux the range assumed to be 0 - 0xffff.
linux/input.h reports us the proper ranges from the device. these numbers will also be used as teh want(min|max). so what this numbers are good for. apps that want the input as "pure" as it gets dont SetProperty some something and just get what the hardware tells them (e.g. RBR does so).
What you described is SetProperty(DIPROP_RANGE). What I'm talking about is the range we get from device itself. In the map_axis we have:
if (val > hmax) This->joydev->havemax[axis] = hmax = val; if (val < hmin) This->joydev->havemin[axis] = hmin = val;
We either need to query the device for what it's ranges are, or use default range (as it's done in joystick_linux). Auto-detecting range will work only if you move joystick on all axes from min to max. And even then it still doesn't work here. I'm using joystick sample from DXSDK and it always shows 0-128-256 range for accelerator - brake pedals (as a combined Z axis). joystick_linux shows it correctly - 0..1000 (it sets this range for all axes).
- fake_current_js_state(newDevice);
Can you explain what this suppose to do? Why do we need to "fake current state" everywhere?
after e.g. SetProperties and initializing the device we have to put the values of the DIJOYSTATE2 in a sane state. e.g. GPL set the ranges to 1000-25k; where my pedals are in 0..512; so the app gets in the next step after the setting a default value of 512 (clutch not pressed) and gets nuts.
Right. But can we query device for the current axes position? They are analog devices, and should provide absolute position.
Vitaliy.
On Thu, Jan 11, 2007 at 01:10:21PM -0700, Vitaliy Margolen wrote:
What you described is SetProperty(DIPROP_RANGE). What I'm talking about is the range we get from device itself. In the map_axis we have:
if (val > hmax) This->joydev->havemax[axis] = hmax = val; if (val < hmin) This->joydev->havemin[axis] = hmin = val;
to my knowledge this code is useless. it got copied over from the /dev/js branch.
We either need to query the device for what it's ranges are, or use default range (as it's done in joystick_linux).
we allready query it. see the code in alloc_device where the have(min|max) is set.
Right. But can we query device for the current axes position? They are analog devices, and should provide absolute position.
well instead of using ...[AXE_ABS] (another axe) we could use the current value from the device. what it is worth for is this:
i bet nearly all apps just call alloc_device and SetProperty in the beginning or when some config is involved. so AXE_ABS is for sure between MIN/MAX (kernel should assert that) and in nearly all cases represent the "null"-state of the device. so if someone fiddles with this input device between find_joydevs and alloc/setprop the value in DJOYSTATE2 would be wrong.
IMHO its not worth the hastle there.
On Thu, Jan 11, 2007 at 10:25:51AM -0700, Vitaliy Margolen wrote:
attached a patch with all the suggestions for Vitaliy.
Christoph Frick wrote:
with Vitaliy's patches i tried my games yesterday and everything seemed ok (RBR works again). but my clutch on the wheel did not work and also
That's a good news. I was hopping not to brake too many things while reorganizing the dinput.
@@ -128,11 +122,20 @@ struct JoystickImpl /* The 'parent' DInput */ IDirectInputImpl *dinput;
- /* autodetecting ranges per axe by following movement */
- LONG havemax[8];
- LONG havemin[8];
I could never understood why we need these? In other joystick_linux the range assumed to be 0 - 0xffff.
/* joystick private */ /* what range and deadzone the game wants */
- LONG wantmin[ABS_MAX];
- LONG wantmax[ABS_MAX];
- LONG deadz[ABS_MAX];
- LONG wantmin[8];
- LONG wantmax[8];
- LONG deadz[8];
Can we move these into separate struct like it's done in joystick_linux? It's much cleaner end eventually will allow a better integration of two.
And can you use spaces instead of tabs please?
@@ -395,19 +373,29 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm /* Supported Axis & POVs should map 1-to-1 */ for (i = 0; i < 8; i++) {
if (!test_bit(newDevice->joydev->absbits, i)) continue;
if (!test_bit(newDevice->joydev->absbits, i)) {
newDevice->axes[i] = -1;
continue;
}
Can you please don't brake the good readable style? Please put that curly bracket into separate line, and use 4 space indentation.
- fake_current_js_state(newDevice);
Can you explain what this suppose to do? Why do we need to "fake current state" everywhere?
int axe = This->axes[ie.code];
It's an "axis" not an "axe" :)