~ubuntu-branches/debian/sid/stella/sid

« back to all changes in this revision

Viewing changes to src/common/MouseControl.hxx

  • Committer: Package Import Robot
  • Author(s): Stephen Kitt
  • Date: 2012-02-05 08:09:05 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20120205080905-9ej05rmkibowsm7j
Tags: 3.5.5-1
* New upstream version.
* Rewrite debian/copyright, using DEP-5 and updating for 2012.
* Update manpage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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-2012 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
// $Id: MouseControl.hxx 2371 2012-01-29 17:08:51Z stephena $
 
18
//============================================================================
 
19
 
 
20
#ifndef MOUSE_CONTROL_HXX
 
21
#define MOUSE_CONTROL_HXX
 
22
 
 
23
class Console;
 
24
class Controller;
 
25
class Properties;
 
26
 
 
27
#include "bspf.hxx"
 
28
#include "Array.hxx"
 
29
 
 
30
/**
 
31
  The mouse can control various virtual 'controllers' in many different
 
32
  ways.  In 'auto' mode, the entire mouse (both axes and buttons) are used
 
33
  as one controller.  In per-ROM axis mode, each axis/button may control
 
34
  separate controllers.  As well, we'd like to switch dynamically between
 
35
  each of these modes at runtime.
 
36
 
 
37
  This class encapsulates all required info to implement this functionality.
 
38
 
 
39
  @author  Stephen Anthony
 
40
*/
 
41
class MouseControl
 
42
{
 
43
  public:
 
44
    /**
 
45
      Enumeration of mouse axis control types
 
46
    */
 
47
    enum Axis
 
48
    {
 
49
      Paddle0 = 0, Paddle1, Paddle2, Paddle3,
 
50
      Driving0, Driving1, Automatic, NoControl
 
51
    };
 
52
 
 
53
  public:
 
54
    /**
 
55
      Create a new MouseControl object
 
56
 
 
57
      @param console The console in use by the system
 
58
      @param mode    Contains information about how to use the mouse axes/buttons
 
59
    */
 
60
    MouseControl(Console& console, const string& mode);
 
61
 
 
62
    /**
 
63
      Destructor
 
64
    */
 
65
    virtual ~MouseControl();
 
66
 
 
67
  public:
 
68
    /**
 
69
      Cycle through each available mouse control mode
 
70
 
 
71
      @return  A message explaining the current mouse mode
 
72
    */
 
73
    const string& next();
 
74
 
 
75
  private:
 
76
    void addLeftControllerModes(bool noswap);
 
77
    void addRightControllerModes(bool noswap);
 
78
    void addPaddleModes(int lport, int rport, int lname, int rname);
 
79
 
 
80
  private:
 
81
    const Properties& myProps;
 
82
    Controller& myLeftController;
 
83
    Controller& myRightController;
 
84
 
 
85
    struct MouseMode {
 
86
      Axis xaxis, yaxis;
 
87
      int controlID;
 
88
      string message;
 
89
 
 
90
      MouseMode()
 
91
        : xaxis(NoControl),
 
92
          yaxis(NoControl),
 
93
          controlID(-1),
 
94
          message("")  { }
 
95
      MouseMode(const string& msg)
 
96
        : xaxis(NoControl),
 
97
          yaxis(NoControl),
 
98
          controlID(-1),
 
99
          message(msg)  { }
 
100
      MouseMode(Axis x, Axis y, int id, const string& msg)
 
101
        : xaxis(x),
 
102
          yaxis(y),
 
103
          controlID(id),
 
104
          message(msg)  { }
 
105
      friend ostream& operator<<(ostream& os, const MouseMode& mm)
 
106
      {
 
107
        os << "xaxis=" << mm.xaxis << ", yaxis=" << mm.yaxis
 
108
           << ", id=" << mm.controlID << ", msg=" << mm.message;
 
109
        return os;
 
110
      }
 
111
    };
 
112
 
 
113
    int myCurrentModeNum;
 
114
    Common::Array<MouseMode> myModeList;
 
115
};
 
116
 
 
117
#endif