* Add Jamfiles to allow building the stickit sample code. It allows testing of
the BJoystick API and joystick drivers. * Also fix a few warnings in the code that were caused by using NULL instead of 0 for BWindow/BView flags. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41852 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f46bc7f19e
commit
f202fdc6ed
@ -1,6 +1,7 @@
|
||||
SubDir HAIKU_TOP src tests kits ;
|
||||
|
||||
SubInclude HAIKU_TOP src tests kits app ;
|
||||
SubInclude HAIKU_TOP src tests kits device ;
|
||||
SubInclude HAIKU_TOP src tests kits game ;
|
||||
SubInclude HAIKU_TOP src tests kits interface ;
|
||||
SubInclude HAIKU_TOP src tests kits locale ;
|
||||
|
3
src/tests/kits/device/Jamfile
Normal file
3
src/tests/kits/device/Jamfile
Normal file
@ -0,0 +1,3 @@
|
||||
SubDir HAIKU_TOP src tests kits device ;
|
||||
|
||||
SubInclude HAIKU_TOP src tests kits device stickit_BJoystick ;
|
7
src/tests/kits/device/stickit_BJoystick/Jamfile
Normal file
7
src/tests/kits/device/stickit_BJoystick/Jamfile
Normal file
@ -0,0 +1,7 @@
|
||||
SubDir HAIKU_TOP src tests kits device stickit_BJoystick ;
|
||||
|
||||
SimpleTest stickit :
|
||||
JoystickWindow.cpp
|
||||
StickItApp.cpp
|
||||
StickItWindow.cpp
|
||||
: be device ;
|
@ -29,7 +29,7 @@
|
||||
#include "StickItWindow.h"
|
||||
|
||||
StickItWindow::StickItWindow(BRect frame)
|
||||
: BWindow(frame, "StickIt", B_TITLED_WINDOW, NULL)
|
||||
: BWindow(frame, "StickIt", B_TITLED_WINDOW, 0)
|
||||
{
|
||||
frame = Bounds();
|
||||
frame.InsetBy(5, 5);
|
||||
@ -37,42 +37,42 @@ StickItWindow::StickItWindow(BRect frame)
|
||||
|
||||
|
||||
// Allocate object
|
||||
BView* view = new BView(Bounds(), "", B_FOLLOW_ALL_SIDES, NULL);
|
||||
BView* view = new BView(Bounds(), "", B_FOLLOW_ALL_SIDES, 0);
|
||||
view->SetViewColor(216, 216, 216);
|
||||
view->SetLowColor(216, 216, 216);
|
||||
|
||||
|
||||
BRect rectString = BRect(frame.left, frame.top-10, frame.right -30, 30);
|
||||
BStringView* stringview1 = new BStringView(rectString,"StringView1",
|
||||
"This list, lists action that StickIt makes.");
|
||||
|
||||
BRect rect = BRect(rectString.left, rectString.bottom + SPACE,
|
||||
BRect rect = BRect(rectString.left, rectString.bottom + SPACE,
|
||||
rectString.right, rectString.bottom + SPACE + 200);
|
||||
fListView1 = new BListView(rect,"ListView1");
|
||||
|
||||
rectString = BRect(rect.left, rect.bottom + SPACE, rect.right,
|
||||
rectString = BRect(rect.left, rect.bottom + SPACE, rect.right,
|
||||
rect.bottom + SPACE + 15);
|
||||
BStringView* stringview2 = new BStringView(rectString,"StringView2",
|
||||
"Choose Joystick below if any exists");
|
||||
|
||||
rect = BRect(rectString.left, rectString.bottom + SPACE, rectString.right,
|
||||
|
||||
rect = BRect(rectString.left, rectString.bottom + SPACE, rectString.right,
|
||||
Bounds().bottom -20);
|
||||
fListView2 = new BListView(rect,"ListView2");
|
||||
fListView2->SetSelectionMessage(new BMessage(SELECTED));
|
||||
fListView2->SetInvocationMessage(new BMessage(INVOKE));
|
||||
|
||||
|
||||
// Adding object
|
||||
box->AddChild(new BScrollView("fListView1", fListView1,
|
||||
B_FOLLOW_LEFT_RIGHT, NULL, false, true));
|
||||
|
||||
box->AddChild(new BScrollView("fListView2", fListView2,
|
||||
B_FOLLOW_ALL_SIDES, NULL, false, true));
|
||||
// Adding object
|
||||
box->AddChild(new BScrollView("fListView1", fListView1,
|
||||
B_FOLLOW_LEFT_RIGHT, 0, false, true));
|
||||
|
||||
box->AddChild(new BScrollView("fListView2", fListView2,
|
||||
B_FOLLOW_ALL_SIDES, 0, false, true));
|
||||
|
||||
box->AddChild(stringview1);
|
||||
box->AddChild(stringview2);
|
||||
view->AddChild(box);
|
||||
AddChild(view);
|
||||
|
||||
|
||||
fJoystick = new BJoystick;
|
||||
PickJoystick(fJoystick);
|
||||
}
|
||||
@ -85,22 +85,22 @@ StickItWindow::QuitRequested(void) {
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
StickItWindow::MessageReceived(BMessage *message)
|
||||
{
|
||||
// message->PrintToStream();
|
||||
switch(message->what)
|
||||
{
|
||||
{
|
||||
case INVOKE:
|
||||
case SELECTED:
|
||||
{
|
||||
{
|
||||
int32 id = fListView2->CurrentSelection();
|
||||
BString temp1;
|
||||
if (id > -1) {
|
||||
char devName[B_OS_NAME_LENGTH];
|
||||
status_t err = fJoystick->GetDeviceName(id, devName);
|
||||
status_t err = fJoystick->GetDeviceName(id, devName);
|
||||
if (err == B_OK) {
|
||||
temp1 << "BJoystick::GetDeviceName(), id = " << id
|
||||
temp1 << "BJoystick::GetDeviceName(), id = " << id
|
||||
<< ", name = " << devName;
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
err = fJoystick->Open(devName);
|
||||
@ -108,16 +108,16 @@ StickItWindow::MessageReceived(BMessage *message)
|
||||
temp1 = AddToList(fListView1, "BJoystick::Open()");
|
||||
temp1 = AddToList(fListView1, "BJoystick::Open()");
|
||||
if(fJoystick->IsCalibrationEnabled())
|
||||
temp1 = AddToList(fListView1,
|
||||
temp1 = AddToList(fListView1,
|
||||
"BJoystick::IsCalibrationEnabled() - True");
|
||||
else
|
||||
temp1 = AddToList(fListView1,
|
||||
temp1 = AddToList(fListView1,
|
||||
"BJoystick::IsCalibrationEnabled() - False");
|
||||
fJoystickWindow = new JoystickWindow(fJoystick,
|
||||
fJoystickWindow = new JoystickWindow(fJoystick,
|
||||
BRect(50, 50, 405, 350));
|
||||
fJoystickWindow->Show();
|
||||
} else
|
||||
AddToList(fListView1,
|
||||
AddToList(fListView1,
|
||||
"No controller connected on that port. Try again.");
|
||||
} else
|
||||
AddToList(fListView1, "Can't use that stick. Try again.");
|
||||
@ -127,7 +127,7 @@ StickItWindow::MessageReceived(BMessage *message)
|
||||
default:
|
||||
BWindow::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -151,61 +151,61 @@ StickItWindow::PickJoystick(BJoystick *stick)
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
status_t err = B_ERROR;
|
||||
if (numDevices) {
|
||||
temp1 << "There are " << numDevices
|
||||
temp1 << "There are " << numDevices
|
||||
<< " Joysticks device types available";
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
for (int32 i = 0; i < numDevices; i++) {
|
||||
char devName[B_OS_NAME_LENGTH];
|
||||
char devName[B_OS_NAME_LENGTH];
|
||||
err = stick->GetDeviceName(i, devName);
|
||||
temp1 << "BJoystick::GetDeviceName(), id = " << i << ", name = "
|
||||
temp1 << "BJoystick::GetDeviceName(), id = " << i << ", name = "
|
||||
<< devName;
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
if (err == B_OK) {
|
||||
err = stick->Open(devName);
|
||||
temp1 = AddToList(fListView1, "BJoystick::Open()");
|
||||
int32 count = stick->CountSticks();
|
||||
temp1 << "BJoystick::CountSticks(), number of sticks = "
|
||||
int32 count = stick->CountSticks();
|
||||
temp1 << "BJoystick::CountSticks(), number of sticks = "
|
||||
<< count;
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
|
||||
count = stick->CountAxes();
|
||||
temp1 << "BJoystick::CountAxes(), number of Axes = "
|
||||
|
||||
count = stick->CountAxes();
|
||||
temp1 << "BJoystick::CountAxes(), number of Axes = "
|
||||
<< count;
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
|
||||
count = stick->CountButtons();
|
||||
temp1 << "BJoystick::CountButtons(), number of Buttons = "
|
||||
|
||||
count = stick->CountButtons();
|
||||
temp1 << "BJoystick::CountButtons(), number of Buttons = "
|
||||
<< count;
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
|
||||
count = stick->CountHats();
|
||||
temp1 << "BJoystick::CountHats(), number of Hats = "
|
||||
|
||||
count = stick->CountHats();
|
||||
temp1 << "BJoystick::CountHats(), number of Hats = "
|
||||
<< count;
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
|
||||
count = stick->CountDevices();
|
||||
temp1 << "BJoystick::CountDevices(), number of Devices = "
|
||||
|
||||
count = stick->CountDevices();
|
||||
temp1 << "BJoystick::CountDevices(), number of Devices = "
|
||||
<< count;
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
|
||||
|
||||
if (err != B_ERROR) {
|
||||
BString name;
|
||||
err = stick->GetControllerModule(&name);
|
||||
temp1 << "BJoystick::GetControllerModule(), name = "
|
||||
temp1 << "BJoystick::GetControllerModule(), name = "
|
||||
<< name;
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
|
||||
if (name == "Legacy") {
|
||||
bool b = stick->EnterEnhancedMode();
|
||||
if (b) {
|
||||
temp1 << "BJoystick::EnterEnhancedMode(), OK";
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
} else {
|
||||
temp1 << "BJoystick::EnterEnhancedMode(), Not OK";
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
err = stick->GetControllerName(&name);
|
||||
temp1 << "BJoystick::GetControllerName(), name = " << name;
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
@ -217,11 +217,11 @@ StickItWindow::PickJoystick(BJoystick *stick)
|
||||
} else {
|
||||
temp1 << "Error = " << strerror(err);
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
temp1 << "*** Can't get name of controller "
|
||||
temp1 << "*** Can't get name of controller "
|
||||
<< devName;
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
temp1 << "Error = " << strerror(err) << "err nr = " << err;
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
temp1 << "No controller on " << devName;
|
||||
@ -232,7 +232,7 @@ StickItWindow::PickJoystick(BJoystick *stick)
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
temp1 << "*** Error while reading controller list.";
|
||||
temp1 = AddToList(fListView1, temp1.String());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
temp1 << "Error = " << strerror(err);
|
||||
|
Loading…
Reference in New Issue
Block a user