1 //============================================================================
2 //
3 //   SSSS    tt          lll  lll
4 //  SS  SS   tt           ll   ll
5 //  SS     tttttt  eeee   ll   ll   aaaa
6 //   SSSS    tt   ee  ee  ll   ll      aa
7 //      SS   tt   eeeeee  ll   ll   aaaaa  --  "An Atari 2600 VCS Emulator"
8 //  SS  SS   tt   ee      ll   ll  aa  aa
9 //   SSSS     ttt  eeeee llll llll  aaaaa
10 //
11 // Copyright (c) 1995-2021 by Bradford W. Mott, Stephen Anthony
12 // and the Stella Team
13 //
14 // See the file "License.txt" for information on usage and redistribution of
15 // this file, and for a DISCLAIMER OF ALL WARRANTIES.
16 //============================================================================
17 
18 #ifndef CONTROLLER_WIDGET_HXX
19 #define CONTROLLER_WIDGET_HXX
20 
21 class GuiObject;
22 class ButtonWidget;
23 
24 #include "Font.hxx"
25 #include "Widget.hxx"
26 #include "OSystem.hxx"
27 #include "Console.hxx"
28 #include "Command.hxx"
29 #include "ControlLowLevel.hxx"
30 
31 class ControllerWidget : public Widget, public CommandSender, public ControllerLowLevel
32 {
33   public:
ControllerWidget(GuiObject * boss,const GUI::Font & font,int x,int y,Controller & controller)34     ControllerWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
35                      Controller& controller)
36       : Widget(boss, font, x, y, 16, 16),
37         CommandSender(boss),
38         ControllerLowLevel(controller)
39     {
40       _w = 18 * font.getMaxCharWidth();
41       _h = 8 * font.getLineHeight();
42     }
43     ~ControllerWidget() override = default;
44 
loadConfig()45     virtual void loadConfig() override { }
46 
47   protected:
isLeftPort()48     bool isLeftPort()
49     {
50       bool swappedPorts =
51         instance().console().properties().get(PropType::Console_SwapPorts) == "YES";
52       return (controller().jack() == Controller::Jack::Left) ^ swappedPorts;
53     }
54 
getHeader()55     string getHeader()
56     {
57       return (isLeftPort() ? "Left (" : "Right (") + controller().name() + ")";
58     }
59 
60   private:
handleCommand(CommandSender * sender,int cmd,int data,int id)61     virtual void handleCommand(CommandSender* sender, int cmd, int data, int id) override { }
62 
63     // Following constructors and assignment operators not supported
64     ControllerWidget() = delete;
65     ControllerWidget(const ControllerWidget&) = delete;
66     ControllerWidget(ControllerWidget&&) = delete;
67     ControllerWidget& operator=(const ControllerWidget&) = delete;
68     ControllerWidget& operator=(ControllerWidget&&) = delete;
69 };
70 
71 #endif
72