[haiku-commits] haiku: hrev48807 - src/tests/kits/device/stickit_BJoystick

  • From: mmlr@xxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 15 Feb 2015 10:08:31 +0100 (CET)

hrev48807 adds 2 changesets to branch 'master'
old head: ecbca3feeca1f6d1fda98aa53190ed8a90d9f7ce
new head: d0f53f151d426e73d466030a942a344212c3ee4c
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=d0f53f151d42+%5Eecbca3feeca1

----------------------------------------------------------------------------

e2d7e6c4be91: StickIt: Construct a new BJoystick object to pass to the window.
  
  Previously the same BJoystick object was reused when opening a new
  window, which caused all windows to show the data of the same device.

d0f53f151d42: StickIt: Don't close the app when closing a JoystickWindow.
  
  Since it now actually works to open multiple windows for different
  devices, don't close the app when closing the device window.

                                            [ Michael Lotz <mmlr@xxxxxxxx> ]

----------------------------------------------------------------------------

4 files changed, 18 insertions(+), 9 deletions(-)
.../kits/device/stickit_BJoystick/JoystickWindow.cpp      | 11 ++++++++---
src/tests/kits/device/stickit_BJoystick/JoystickWindow.h  |  4 +++-
src/tests/kits/device/stickit_BJoystick/StickItWindow.cpp | 11 +++++++----
src/tests/kits/device/stickit_BJoystick/StickItWindow.h   |  1 -

############################################################################

Commit:      e2d7e6c4be9142efe0d8964943d674a6a784c6de
URL:         http://cgit.haiku-os.org/haiku/commit/?id=e2d7e6c4be91
Author:      Michael Lotz <mmlr@xxxxxxxx>
Date:        Sat Feb 14 21:50:57 2015 UTC

StickIt: Construct a new BJoystick object to pass to the window.

Previously the same BJoystick object was reused when opening a new
window, which caused all windows to show the data of the same device.

----------------------------------------------------------------------------

diff --git a/src/tests/kits/device/stickit_BJoystick/JoystickWindow.cpp 
b/src/tests/kits/device/stickit_BJoystick/JoystickWindow.cpp
index 35bc782..624a1b7 100644
--- a/src/tests/kits/device/stickit_BJoystick/JoystickWindow.cpp
+++ b/src/tests/kits/device/stickit_BJoystick/JoystickWindow.cpp
@@ -24,8 +24,9 @@ rgb_color rgb_grey = {216, 216, 216};
 int32 hatX[9] = {10, 10, 20, 20, 20, 10, 0, 0, 0};
 int32 hatY[9] = {10, 0, 0, 10, 20, 20, 20, 10, 0};
 
-JoystickWindow::JoystickWindow(BJoystick *stick, BRect rect)
-       : BWindow(rect, "StickIt", B_TITLED_WINDOW,
+JoystickWindow::JoystickWindow(const char *deviceName, BJoystick *stick,
+       BRect rect)
+       : BWindow(rect, deviceName, B_TITLED_WINDOW,
        B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
 {
        fView = new JoystickView(Bounds(), stick);
@@ -64,6 +65,11 @@ JoystickView::JoystickView(BRect frame, BJoystick *stick)
 }
 
 
+JoystickView::~JoystickView() {
+       delete fStick;
+}
+
+
 void
 JoystickView::Pulse(void) {
        Window()->Lock();
diff --git a/src/tests/kits/device/stickit_BJoystick/JoystickWindow.h 
b/src/tests/kits/device/stickit_BJoystick/JoystickWindow.h
index 6ffe731..c796ae4 100644
--- a/src/tests/kits/device/stickit_BJoystick/JoystickWindow.h
+++ b/src/tests/kits/device/stickit_BJoystick/JoystickWindow.h
@@ -13,6 +13,7 @@ class BJoystick;
 class JoystickView : public BView {
        public:
                                                        JoystickView(BRect 
bounds, BJoystick *stick);
+               virtual                         ~JoystickView();
                virtual void            Draw(BRect updateRect);
                virtual void            Pulse(void);
        
@@ -29,7 +30,8 @@ class JoystickView : public BView {
 
 class JoystickWindow : public BWindow {
        public:
-                                                       
JoystickWindow(BJoystick *stick, BRect rect);
+                                                       JoystickWindow(const 
char *deviceName,
+                                                               BJoystick 
*stick, BRect rect);
                virtual bool            QuitRequested(void);
        
        private:
diff --git a/src/tests/kits/device/stickit_BJoystick/StickItWindow.cpp 
b/src/tests/kits/device/stickit_BJoystick/StickItWindow.cpp
index 0f94731..cc2db40 100644
--- a/src/tests/kits/device/stickit_BJoystick/StickItWindow.cpp
+++ b/src/tests/kits/device/stickit_BJoystick/StickItWindow.cpp
@@ -103,19 +103,22 @@ StickItWindow::MessageReceived(BMessage *message)
                                        temp1 << "BJoystick::GetDeviceName(), 
id = " << id
                                                << ", name = " << devName;
                                        temp1 = AddToList(fListView1, 
temp1.String());
-                                       err = fJoystick->Open(devName);
+                                       BJoystick *joystick = new BJoystick();
+                                       err = joystick->Open(devName);
                                        if (err != B_ERROR) {
                                                temp1 = AddToList(fListView1, 
"BJoystick::Open()");
                                                temp1 = AddToList(fListView1, 
"BJoystick::Open()");
-                                               
if(fJoystick->IsCalibrationEnabled())
+                                               if 
(joystick->IsCalibrationEnabled())
                                                        temp1 = 
AddToList(fListView1,
                                                                
"BJoystick::IsCalibrationEnabled() - True");
                                                else
                                                        temp1 = 
AddToList(fListView1,
                                                                
"BJoystick::IsCalibrationEnabled() - False");
-                                               fJoystickWindow = new 
JoystickWindow(fJoystick,
+                                               JoystickWindow *window = 
new(std::nothrow)
+                                                       JoystickWindow(devName, 
joystick,
                                                        BRect(50, 50, 405, 
350));
-                                               fJoystickWindow->Show();
+                                               if (window != NULL)
+                                                       window->Show();
                                        } else
                                                AddToList(fListView1,
                                                        "No controller 
connected on that port. Try again.");
diff --git a/src/tests/kits/device/stickit_BJoystick/StickItWindow.h 
b/src/tests/kits/device/stickit_BJoystick/StickItWindow.h
index 9d77005..853e845 100644
--- a/src/tests/kits/device/stickit_BJoystick/StickItWindow.h
+++ b/src/tests/kits/device/stickit_BJoystick/StickItWindow.h
@@ -26,5 +26,4 @@ class StickItWindow : public BWindow {
                BListView*              fListView1;
                BListView*              fListView2;
                BJoystick*              fJoystick;
-               JoystickWindow* fJoystickWindow;
 };

############################################################################

Revision:    hrev48807
Commit:      d0f53f151d426e73d466030a942a344212c3ee4c
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d0f53f151d42
Author:      Michael Lotz <mmlr@xxxxxxxx>
Date:        Sat Feb 14 21:55:40 2015 UTC

StickIt: Don't close the app when closing a JoystickWindow.

Since it now actually works to open multiple windows for different
devices, don't close the app when closing the device window.

----------------------------------------------------------------------------

diff --git a/src/tests/kits/device/stickit_BJoystick/JoystickWindow.cpp 
b/src/tests/kits/device/stickit_BJoystick/JoystickWindow.cpp
index 624a1b7..db004e7 100644
--- a/src/tests/kits/device/stickit_BJoystick/JoystickWindow.cpp
+++ b/src/tests/kits/device/stickit_BJoystick/JoystickWindow.cpp
@@ -40,7 +40,6 @@ JoystickWindow::JoystickWindow(const char *deviceName, 
BJoystick *stick,
 
 bool
 JoystickWindow::QuitRequested(void) {
-       be_app->PostMessage(B_QUIT_REQUESTED);
        return true;
 }
 


Other related posts:

  • » [haiku-commits] haiku: hrev48807 - src/tests/kits/device/stickit_BJoystick - mmlr