Cleanup of the _BJoystickTweaker:

* Include sorting, header style, macro naming, variable naming, spacing, ...
* Some simplifications, early returns and the like.
* The device name list items were allocated with new but deleted with free. The
  whole private BJoystick list being modified by a friend class is dubious
  though and should be reworked. Ideally node monitoring would be implemented
  so that the list can be re-populated on demand instead of scanning through
  every time.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41868 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2011-06-02 12:42:18 +00:00
parent 258cffcde2
commit 393ca9a124
3 changed files with 94 additions and 71 deletions
+24 -19
View File
@@ -8,15 +8,18 @@
#include <joystick_driver.h>
#include <List.h>
#include <Entry.h>
#include <List.h>
#if DEBUG
#include <stdio.h>
#endif
#define DEVICEPATH "/dev/joystick/"
#define JOYSTICKPATH "/boot/home/config/settings/joysticks/"
#define DEVICE_BASE_PATH "/dev/joystick/"
#define JOYSTICK_CONFIG_BASE_PATH "/boot/home/config/settings/joysticks/"
// TODO: this should use find_directory() instead and it should take
// common/system into account as well
class BJoystick;
@@ -29,29 +32,31 @@ typedef struct _joystick_info {
BList button_names;
} joystick_info;
class _BJoystickTweaker {
public:
_BJoystickTweaker();
_BJoystickTweaker(BJoystick &stick);
virtual ~_BJoystickTweaker();
status_t SendIOCT(uint32 op);
status_t GetInfo(_joystick_info* info, const char * ref);
_BJoystickTweaker();
_BJoystickTweaker(BJoystick &stick);
virtual ~_BJoystickTweaker();
status_t SendIOCT(uint32 op);
status_t GetInfo(_joystick_info* info, const char *ref);
// BeOS R5's joystick pref need these
status_t save_config(const entry_ref * ref = NULL);
void scan_including_disabled();
status_t get_info();
// BeOS R5's joystick pref need these
status_t save_config(const entry_ref *ref = NULL);
void scan_including_disabled();
status_t get_info();
private:
void _BuildFromJoystickDesc(char *string, _joystick_info* info);
status_t _ScanIncludingDisabled(const char* rootPath, BList *list,
BEntry *rootEntry = NULL);
void _BuildFromJoystickDesc(char *string,
_joystick_info *info);
status_t _ScanIncludingDisabled(const char *rootPath,
BList *list, BEntry *rootEntry = NULL);
void _EmpyList(BList *list);
BJoystick* fJoystick;
void _EmpyList(BList *list);
BJoystick * fJoystick;
#if DEBUG
public:
static FILE *sLogFile;
static FILE * sLogFile;
#endif
};