* Make use of the new BJoystick::GetButtonValues() so any number of buttons can
be retrieved. I think the fixed layout will actually make it impossible to see anything beyond the 9th button however... The coding style of this app is, different, to say the least and I didn't really bother fixing it up right now, so the changes just mimic what's there. * Some automatic whitespace cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41883 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
4b5bcc6684
commit
660fe6bca9
@ -4,4 +4,4 @@ SimpleTest stickit :
|
||||
JoystickWindow.cpp
|
||||
StickItApp.cpp
|
||||
StickItWindow.cpp
|
||||
: be device $(TARGET_LIBSTDC++) ;
|
||||
: be libdevice.so $(TARGET_LIBSTDC++) ;
|
||||
|
@ -78,15 +78,16 @@ JoystickView::Draw(BRect updateRect)
|
||||
int32 numButtons = fStick->CountButtons();
|
||||
int32 numHats = fStick->CountHats();
|
||||
int32 numAxes = fStick->CountAxes();
|
||||
bool *buttons = (bool *) malloc(sizeof(bool) * numButtons);
|
||||
int16 *axes = (int16 *) malloc(sizeof(int16) * numAxes);
|
||||
uint8 *hats = (uint8 *) malloc(numHats);
|
||||
fStick->Update();
|
||||
|
||||
// Buttons first
|
||||
BRect r(105, 50, 115, 60);
|
||||
uint32 buttons = fStick->ButtonValues();
|
||||
fStick->GetButtonValues(buttons);
|
||||
for (int32 i = 0; i < numButtons; i++) {
|
||||
if (buttons & (1 << i)) {
|
||||
if (buttons[i]) {
|
||||
FillRect(r, B_SOLID_HIGH);
|
||||
} else {
|
||||
r.InsetBy(1, 1);
|
||||
@ -163,6 +164,7 @@ JoystickView::Draw(BRect updateRect)
|
||||
r.top += 20;
|
||||
r.bottom += 20;
|
||||
}
|
||||
free(buttons);
|
||||
free(axes);
|
||||
free(hats);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user