rnd-20090623-4-src
[rocksndiamonds.git] / src / game_sp / Input.c
1 // ----------------------------------------------------------------------------
2 // Input.c
3 // ----------------------------------------------------------------------------
4
5 #include "Input.h"
6
7 // static char *VB_Name = "modInput";
8
9 // --- Option Explicit
10
11 boolean KeyState[255 + 1];
12 DemoBufferObject DemoBuffer;
13
14 //
15 // Public KeyFlagSpace As Boolean
16 // Public KeyFlagUp As Boolean
17 // Public KeyFlagLeft As Boolean
18 // Public KeyFlagDown As Boolean
19 // Public KeyFlagRight As Boolean
20 // Public KeyFlagEnter As Boolean
21 // Public KeyFlagESC As Boolean
22 // Public KeyFlagR As Boolean
23 // Public KeyFlagRShift As Boolean
24
25 int KeyScanCode7;
26
27 void subCheckJoystick()
28 {
29 }
30
31 int subCheckRightMouseButton()
32 {
33   int subCheckRightMouseButton;
34
35   // return button state
36
37   return subCheckRightMouseButton;
38 }
39
40 int subProcessKeyboardInput()
41 {
42   int subProcessKeyboardInput;
43
44   int LastKey;
45
46   //  On Error GoTo NoKeyboardAccessEH
47   //    Call DKeyboard.Acquire
48   //  On Error GoTo 0
49   //  Call DKeyboard.GetDeviceStateKeyboard(KeyState)
50   //  With KeyState
51   if (DemoFlag != 0)
52   {
53     subGetNextDemoKey();
54     if (ExitToMenuFlag != 0)
55       return subProcessKeyboardInput;
56
57   }
58   else
59   {
60     if (KeyState[vbKeySpace])
61     {
62       if (KeyState[vbKeyUp])
63       {
64         DemoKeyCode = keySpaceUp;
65       }
66       else if (KeyState[vbKeyLeft])
67       {
68         DemoKeyCode = keySpaceLeft;
69       }
70       else if (KeyState[vbKeyDown])
71       {
72         DemoKeyCode = keySpaceDown;
73       }
74       else if (KeyState[vbKeyRight])
75       {
76         DemoKeyCode = keySpaceRight;
77       }
78       else
79       {
80         DemoKeyCode = keySpace;
81       }
82
83     }
84     else
85     {
86       if (KeyState[vbKeyUp])
87       {
88         DemoKeyCode = keyUp;
89       }
90       else if (KeyState[vbKeyLeft])
91       {
92         DemoKeyCode = keyLeft;
93       }
94       else if (KeyState[vbKeyDown])
95       {
96         DemoKeyCode = keyDown;
97       }
98       else if (KeyState[vbKeyRight])
99       {
100         DemoKeyCode = keyRight;
101       }
102       else
103       {
104         DemoKeyCode = keyNone;
105       }
106     }
107   }
108
109   // demo recording
110   if (RecordDemoFlag == 1)
111     DemoBuffer.AddDemoKey(DemoKeyCode);
112
113   if (DemoKeyCode != LastKey && ! NoDisplayFlag)
114   {
115 #if 0
116     MainForm.ShowKey(DemoKeyCode);
117 #endif
118     LastKey = DemoKeyCode;
119   }
120
121   if (KeyState[vbKeyEscape])
122   {
123     if (BlockingSpeed)
124     {
125       //        Call MainForm.menSpeed_Click(4)
126     }
127     else
128     {
129       KillMurphyFlag = 1;
130       //        ExplodeFieldSP MurphyPosIndex
131       //        LeadOutCounter = &H20
132     }
133   }
134
135   if (KeyState[vbKeyR])
136   {
137     subFetchAndInitLevelB();
138   }
139
140   if (KeyState[vbKeyShift])
141     subDisplayRedDiskCount();
142
143 #if 0
144   if (KeyState[vbKeyReturn])
145     MainForm.PanelVisible = (ShowPanel == 0);
146 #endif
147
148   //  End With
149   //  Call DKeyboard.Unacquire
150   return subProcessKeyboardInput;
151
152   // NoKeyboardAccessEH:
153   Debug.Print("! Keyboard access");
154
155   return subProcessKeyboardInput;
156 }