comment fix and fixed some return error from BeBook
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26784 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -21,6 +21,8 @@ __8JoyCalibG5BRectR9BJoystickP7BWindow:
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
#include "Joystick.h"
|
#include "Joystick.h"
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -112,6 +114,10 @@ BJoystick::Open(const char *portName, bool enter_enhanced)
|
|||||||
_BJoystickTweaker jt(*this);
|
_BJoystickTweaker jt(*this);
|
||||||
jt.get_info(m_info, portName);
|
jt.get_info(m_info, portName);
|
||||||
|
|
||||||
|
LOG("ioctl - %d\n", m_info->num_buttons);
|
||||||
|
ioctl(ffd, B_JOYSTICK_SET_DEVICE_MODULE, m_info);
|
||||||
|
ioctl(ffd, B_JOYSTICK_GET_DEVICE_MODULE, m_info);
|
||||||
|
LOG("ioctl - %d\n", m_info->num_buttons);
|
||||||
if (ffd >= 0) {
|
if (ffd >= 0) {
|
||||||
return ffd;
|
return ffd;
|
||||||
} else
|
} else
|
||||||
@@ -161,19 +167,21 @@ status_t
|
|||||||
BJoystick::GetDeviceName(int32 n, char *name, size_t bufSize)
|
BJoystick::GetDeviceName(int32 n, char *name, size_t bufSize)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
status_t result = B_ERROR;
|
|
||||||
BString *temp = new BString();
|
BString *temp = new BString();
|
||||||
if (_fDevices != NULL)
|
if (_fDevices != NULL && _fDevices->CountItems() > n)
|
||||||
temp = static_cast<BString*>(_fDevices->ItemAt(n));
|
temp = static_cast<BString*>(_fDevices->ItemAt(n));
|
||||||
|
else
|
||||||
|
return B_BAD_INDEX;
|
||||||
|
|
||||||
if (temp != NULL && name != NULL) {
|
if (temp != NULL && name != NULL) {
|
||||||
|
if(temp->Length() > bufSize)
|
||||||
|
return B_NAME_TOO_LONG;
|
||||||
strncpy(name, temp->String(), bufSize);
|
strncpy(name, temp->String(), bufSize);
|
||||||
name[bufSize - 1] = '\0';
|
name[bufSize - 1] = '\0';
|
||||||
result = B_OK;
|
LOG("Device Name = %s\n", name);
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
return B_ERROR;
|
||||||
LOG("Device Name = %s\n", name);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -254,7 +262,11 @@ status_t
|
|||||||
BJoystick::EnableCalibration(bool calibrates)
|
BJoystick::EnableCalibration(bool calibrates)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
return m_info->calibration_enable = calibrates;
|
if(ffd >= 0) {
|
||||||
|
m_info->calibration_enable = calibrates;
|
||||||
|
return B_OK;
|
||||||
|
} else
|
||||||
|
return B_NO_INIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -263,6 +275,7 @@ BJoystick::SetMaxLatency(bigtime_t max_latency)
|
|||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
m_info->max_latency = max_latency;
|
m_info->max_latency = max_latency;
|
||||||
|
//else B_ERROR (when?)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +285,7 @@ status_t
|
|||||||
BJoystick::GetAxisNameAt(int32 index, BString *out_name)
|
BJoystick::GetAxisNameAt(int32 index, BString *out_name)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
return B_ERROR;
|
return B_BAD_INDEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -280,7 +293,7 @@ status_t
|
|||||||
BJoystick::GetHatNameAt(int32 index, BString *out_name)
|
BJoystick::GetHatNameAt(int32 index, BString *out_name)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
return B_ERROR;
|
return B_BAD_INDEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -288,7 +301,7 @@ status_t
|
|||||||
BJoystick::GetButtonNameAt(int32 index, BString *out_name)
|
BJoystick::GetButtonNameAt(int32 index, BString *out_name)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
return B_ERROR;
|
return B_BAD_INDEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -296,7 +309,7 @@ status_t
|
|||||||
BJoystick::GetAxisValues(int16 *out_values, int32 for_stick)
|
BJoystick::GetAxisValues(int16 *out_values, int32 for_stick)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
return B_ERROR;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -304,7 +317,7 @@ status_t
|
|||||||
BJoystick::GetHatValues(uint8 *out_hats, int32 for_stick)
|
BJoystick::GetHatValues(uint8 *out_hats, int32 for_stick)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
return B_ERROR;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -320,7 +333,10 @@ status_t
|
|||||||
BJoystick::Update(void)
|
BJoystick::Update(void)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
return B_ERROR;
|
if(ffd >= 0) {
|
||||||
|
return B_OK;
|
||||||
|
} else
|
||||||
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -126,11 +126,11 @@ _BJoystickTweaker::get_info(_joystick_info* info,
|
|||||||
|
|
||||||
FILE *file = fopen(str.String(), "r");
|
FILE *file = fopen(str.String(), "r");
|
||||||
if (file != NULL) {
|
if (file != NULL) {
|
||||||
char line [STRINGLENGTHCPY]; /* or other suitable maximum line size */
|
char line [STRINGLENGTHCPY];
|
||||||
while (fgets ( line, sizeof line, file ) != NULL ) { /* read a line */
|
while (fgets ( line, sizeof line, file ) != NULL ) {
|
||||||
int len = strlen(line);
|
int len = strlen(line);
|
||||||
if (len > 0 && line[len-1] == '\n') // if there's a newline
|
if (len > 0 && line[len-1] == '\n')
|
||||||
line[len-1] = '\0'; // truncate the string
|
line[len-1] = '\0';
|
||||||
BuildFromJoystickDesc(line, info);
|
BuildFromJoystickDesc(line, info);
|
||||||
}
|
}
|
||||||
fclose(file);
|
fclose(file);
|
||||||
@@ -155,23 +155,19 @@ _BJoystickTweaker::BuildFromJoystickDesc(char *string, _joystick_info* info)
|
|||||||
strncpy(info->controller_name, str.String(), STRINGLENGTHCPY);
|
strncpy(info->controller_name, str.String(), STRINGLENGTHCPY);
|
||||||
} else if (str.IFindFirst("num_axes") != -1) {
|
} else if (str.IFindFirst("num_axes") != -1) {
|
||||||
str.RemoveFirst("num_axes = ");
|
str.RemoveFirst("num_axes = ");
|
||||||
//strncpy(info->num_axes, str.String(), STRINGLENGTHCPY);
|
//info->num_axes = atoi(str.String());
|
||||||
info->num_axes = atoi(str.String());
|
|
||||||
//LOG("%s\n", str.String());
|
//LOG("%s\n", str.String());
|
||||||
} else if (str.IFindFirst("num_hats") != -1) {
|
} else if (str.IFindFirst("num_hats") != -1) {
|
||||||
str.RemoveFirst("num_hats = ");
|
str.RemoveFirst("num_hats = ");
|
||||||
info->num_hats = atoi(str.String());
|
//info->num_hats = atoi(str.String());
|
||||||
//strncpy(info->num_hats, str.String(), STRINGLENGTHCPY);
|
|
||||||
//LOG("%s\n", str.String());
|
//LOG("%s\n", str.String());
|
||||||
} else if (str.IFindFirst("num_buttons") != -1) {
|
} else if (str.IFindFirst("num_buttons") != -1) {
|
||||||
str.RemoveFirst("num_buttons = ");
|
str.RemoveFirst("num_buttons = ");
|
||||||
info->num_buttons = atoi(str.String());
|
//info->num_buttons = atoi(str.String());
|
||||||
//strncpy(info->num_buttons, str.String(), STRINGLENGTHCPY);
|
|
||||||
//LOG("%s\n", str.String());
|
//LOG("%s\n", str.String());
|
||||||
} else if (str.IFindFirst("num_sticks") != -1) {
|
} else if (str.IFindFirst("num_sticks") != -1) {
|
||||||
str.RemoveFirst("num_sticks = ");
|
str.RemoveFirst("num_sticks = ");
|
||||||
info->num_sticks = atoi(str.String());
|
//info->num_sticks = atoi(str.String());
|
||||||
//strncpy(info->num_sticks, str.String(), STRINGLENGTHCPY);
|
|
||||||
//LOG("%s\n", str.String());
|
//LOG("%s\n", str.String());
|
||||||
} else {
|
} else {
|
||||||
// LOG("Path = %s\n", str->String());
|
// LOG("Path = %s\n", str->String());
|
||||||
|
|||||||
Reference in New Issue
Block a user