* Replace the fixed size extended_joystick structure with a variably sized one
inside BJoystick. * Add joystick_module_info flag to communicate support for variably sized reads. * The variably sized data structure is set up to describe either the actual amount of data, when variably sized reads are supported by the driver, or it is set up so that it exactly matches the data layout of the extended_joystick structure. This allows us to support both as input data, while only needing to care about a single format inside BJoystick. Convenience pointers allow the data to be retrieved without additional overhead or extra logic. * Add some sanity checks and ensure some boundaries when dealing reading data from the variably sized structure (as there might not be any buttons, hats, axis at all now). * Ensure that the extended_joystick structure doesn't change in size due to padding by making it _PACKED (it wasn't padded though). This is still supposed to work exactly as before. However, it opens up the possibility to actually support arbitrary controllers with arbitrary axis, hat and button counts. It therefore allows to actually deliver what the BJoystick API was designed to handle all along. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41885 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -103,7 +103,8 @@ friend class _BJoystickTweaker;
|
||||
int fFD;
|
||||
BList* fDevices;
|
||||
_joystick_info* fJoystickInfo;
|
||||
BList* fExtendedJoystick;
|
||||
BList* fJoystickData;
|
||||
|
||||
uint32 _reserved_Joystick_[10];
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2011 Michael Lotz <[email protected]>
|
||||
* Distributed under the terms of the MIT license.
|
||||
*/
|
||||
#ifndef _JOYSTICK_PRIVATE_H
|
||||
#define _JOYSTICK_PRIVATE_H
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
typedef struct _variable_joystick {
|
||||
uint32 axis_count;
|
||||
uint32 hat_count;
|
||||
uint32 button_blocks;
|
||||
|
||||
// these pointers all point into the data section
|
||||
bigtime_t * timestamp;
|
||||
uint32 * buttons;
|
||||
int16 * axes;
|
||||
uint8 * hats;
|
||||
|
||||
size_t data_size;
|
||||
uint8 * data;
|
||||
} variable_joystick;
|
||||
|
||||
#endif // _JOYSTICK_PRIVATE_H
|
||||
@@ -39,13 +39,14 @@ typedef struct _extended_joystick {
|
||||
uint32 buttons; /* lsb to msb, 1 == on */
|
||||
int16 axes[MAX_AXES]; /* -32768 to 32767, X, Y, Z, U, V, W */
|
||||
uint8 hats[MAX_HATS]; /* 0 through 8 (1 == N, 3 == E, 5 == S, 7 == W) */
|
||||
} extended_joystick;
|
||||
} _PACKED extended_joystick;
|
||||
|
||||
#define MAX_CONFIG_SIZE 100
|
||||
|
||||
enum { /* flags for joystick module info */
|
||||
js_flag_force_feedback = 0x1,
|
||||
js_flag_force_feedback_directional = 0x2
|
||||
js_flag_force_feedback_directional = 0x2,
|
||||
js_flag_variable_size_reads = 0x4
|
||||
};
|
||||
|
||||
typedef struct _joystick_module_info {
|
||||
|
||||
Reference in New Issue
Block a user