File indexing completed on 2024-04-28 07:54:56

0001 /*
0002     This file is part of the KDE games lskat program
0003     SPDX-FileCopyrightText: 2006 Martin Heni <kde@heni-online.de>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef ABSTRACT_INPUT_H
0009 #define ABSTRACT_INPUT_H
0010 
0011 // Qt includes
0012 #include <QObject>
0013 
0014 // KF includes
0015 
0016 // Local includes
0017 #include "lskat_debug.h"
0018 
0019 namespace InputDevice
0020 {
0021 /** Determine the type of input to use for the player */
0022 typedef enum {TypeMouseInput = 0, TypeAiInput = 1} InputDeviceType;
0023 }
0024 
0025 /**
0026  * Abstract input device for the game.
0027  */
0028 class AbstractInput : public QObject
0029 {
0030     Q_OBJECT
0031 
0032 public:
0033     /**
0034      * Constructor for the input
0035      * @param parent The parent object
0036      */
0037     explicit AbstractInput(QObject *parent);
0038 
0039     /**
0040      * Allow or disallow input with this device
0041      * @param allowed True if input is allowed
0042      */
0043     virtual void setInputAllowed(bool allowed);
0044 
0045     /**
0046      * Retrieve whether input is allowed or not.
0047      * @return True if input from this device is allowed.
0048      */
0049     virtual bool inputAllowed();
0050 
0051     /**
0052      * Set the player id number to whom this input belongs to.
0053      * @param id The id number
0054      */
0055     virtual void setId(int id);
0056 
0057     /**
0058      * Retrieve the type of device.
0059      * @return The device type.
0060      */
0061     virtual InputDevice::InputDeviceType type() = 0;
0062 
0063 Q_SIGNALS:
0064     /**
0065      * Signals the availability of player input
0066      * @param id           The input device id
0067      * @param playerNumber The player number [0-1]
0068      * @param cardNumber   The card number [0-7]
0069      */
0070     void signalPlayerInput(int id, int playerNumber, int cardNumber);
0071 
0072 protected:
0073     /** Player id to whom this input belongs */
0074     int mId;
0075     /** Is input allowed? */
0076     bool mInputAllowed;
0077 };
0078 
0079 #endif