| 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-2019 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 "Console.hxx" | 
| 27 | #include "Command.hxx" | 
| 28 | #include "ControlLowLevel.hxx" | 
| 29 |  | 
| 30 | class ControllerWidget : public Widget, public CommandSender, public ControllerLowLevel | 
| 31 | { | 
| 32 |   public: | 
| 33 |     ControllerWidget(GuiObject* boss, const GUI::Font& font, int x, int y, | 
| 34 |                      Controller& controller) | 
| 35 |       : Widget(boss, font, x, y, 16, 16), | 
| 36 |         CommandSender(boss), | 
| 37 |         ControllerLowLevel(controller) | 
| 38 |     { | 
| 39 |       _w = 18 * font.getMaxCharWidth(); | 
| 40 |       _h = 8 * font.getLineHeight(); | 
| 41 |     } | 
| 42 |     virtual ~ControllerWidget() = default; | 
| 43 |  | 
| 44 |     virtual void loadConfig() override { } | 
| 45 |  | 
| 46 |   protected: | 
| 47 |     bool isLeftPort() | 
| 48 |     { | 
| 49 |       bool swappedPorts = | 
| 50 |         instance().console().properties().get(PropType::Console_SwapPorts) == "YES" ; | 
| 51 |       return (controller().jack() == Controller::Jack::Left) ^ swappedPorts; | 
| 52 |     } | 
| 53 |  | 
| 54 |     string () | 
| 55 |     { | 
| 56 |       return (isLeftPort() ? "Left ("  : "Right (" ) + controller().name() + ")" ; | 
| 57 |     } | 
| 58 |  | 
| 59 |   private: | 
| 60 |     virtual void handleCommand(CommandSender* sender, int cmd, int data, int id) override { } | 
| 61 |  | 
| 62 |     // Following constructors and assignment operators not supported | 
| 63 |     ControllerWidget() = delete; | 
| 64 |     ControllerWidget(const ControllerWidget&) = delete; | 
| 65 |     ControllerWidget(ControllerWidget&&) = delete; | 
| 66 |     ControllerWidget& operator=(const ControllerWidget&) = delete; | 
| 67 |     ControllerWidget& operator=(ControllerWidget&&) = delete; | 
| 68 | }; | 
| 69 |  | 
| 70 | #endif | 
| 71 |  |