From 6e0cca2f9617670db2935daadcb4ecb28fa67ccb Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Fri, 3 Jun 2011 19:48:16 +0000 Subject: [PATCH] * Remove the JoystickPrivate.h again and move the variable_joystick structure into joystick_driver.h as it is convenient to have also on the driver side. * Added comments explaining the data structure and use case of the structure. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41886 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/device/JoystickPrivate.h | 25 -------------------- headers/private/device/joystick_driver.h | 30 ++++++++++++++++++++++++ src/kits/device/Joystick.cpp | 1 - 3 files changed, 30 insertions(+), 26 deletions(-) delete mode 100644 headers/private/device/JoystickPrivate.h diff --git a/headers/private/device/JoystickPrivate.h b/headers/private/device/JoystickPrivate.h deleted file mode 100644 index 4d1f001b25..0000000000 --- a/headers/private/device/JoystickPrivate.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2011 Michael Lotz - * Distributed under the terms of the MIT license. - */ -#ifndef _JOYSTICK_PRIVATE_H -#define _JOYSTICK_PRIVATE_H - -#include - -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 diff --git a/headers/private/device/joystick_driver.h b/headers/private/device/joystick_driver.h index b75ae3db9a..6716932af9 100644 --- a/headers/private/device/joystick_driver.h +++ b/headers/private/device/joystick_driver.h @@ -41,6 +41,36 @@ typedef struct _extended_joystick { uint8 hats[MAX_HATS]; /* 0 through 8 (1 == N, 3 == E, 5 == S, 7 == W) */ } _PACKED extended_joystick; + +// This is a helper structure to manage variably sized data. It is here to +// make storing and accessing the flat data in the "data" member easier. When +// transferring data via read/write/ioctl only the flat data in "data" is ever +// transmitted, not the whole structure. +typedef struct _variable_joystick { + uint32 axis_count; + uint32 hat_count; + uint32 button_blocks; + // count of 32 bit button bitmap blocks == (button_count + 31) / 32 + + // These pointers all point into the data section and are here for + // convenience. They need to be set up manually by the one who creates this + // structure. + bigtime_t * timestamp; + uint32 * buttons; + int16 * axes; + uint8 * hats; + + // The data is always structured in the following way (see extended_joystick + // for data interpretation): + // bigtime_t timestamp; + // uint32 button_bitmap_blocks[button_block]; + // int16 axes[axis_count]; + // uint8 hats[hat_count]; + size_t data_size; + uint8 * data; +} variable_joystick; + + #define MAX_CONFIG_SIZE 100 enum { /* flags for joystick module info */ diff --git a/src/kits/device/Joystick.cpp b/src/kits/device/Joystick.cpp index a0b85d01bf..9def31451c 100644 --- a/src/kits/device/Joystick.cpp +++ b/src/kits/device/Joystick.cpp @@ -6,7 +6,6 @@ #include -#include #include #include