Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/bezierTrack/gui/orxonox_gui_keys.cc @ 3233

Last change on this file since 3233 was 2819, checked in by bensch, 20 years ago

orxonox/trunk: fixed importer autoconf in configure.ac

File size: 5.2 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   This program is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with this program; if not, write to the Free Software Foundation,
18   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
19
20
21   ### File Specific:
22   main-programmer: Benjamin Grauer
23
24*/
25
26#include "orxonox_gui_keys.h"
27#include <iostream.h>
28
29/**
30   \brief Creates an Keyboard-Frame
31*/
32OrxonoxGuiKeys::OrxonoxGuiKeys ()
33{
34  keysFrame = new Frame ("Keyboard-Options:");
35  keysFrame->setGroupName("Keyboard");
36  keysBox = new Box ('v');
37  player1 = new Player("player1");
38  //  player2 = new Player("player2");
39
40  keysBox->fill(player1->getOpenButton());
41  //  keysBox->fill(player2->getOpenButton());
42
43  keysFrame->fill (keysBox);
44}
45
46/**
47   \brief Return the Frame
48   \return Returns the Audio-frame
49*/
50Widget* OrxonoxGuiKeys::getWidget ()
51{
52  return keysFrame;
53}
54
55
56
57/* PLAYER */
58Player::Player(char* player)
59{
60  openButton = new Button (player);
61  openButton->connectSignal("button_press_event", this, openWindowEvent);
62
63  keyWindow = new Window("keys of player");
64
65  keysBox = new Box('v');
66  keysBox->fill(addKey(UP, "up"));
67  keysBox->fill(addKey(DOWN, "down"));
68  keysBox->fill(addKey(LEFT, "left"));
69  keysBox->fill(addKey(RIGHT, "right"));
70  keysBox->fill(addKey(SHOOT, "shoot"));
71  keyWindow->fill(keysBox);
72  windowIsOpen = false;
73
74}
75
76Widget* Player::addKey (KEYS key, char* name)
77{
78  keyBox[key] = new Box();
79  keyLabel[key] = new Label (name);
80  keyButton[key] = new Button(name);
81  keyButton[key]->saveable;
82 
83  keyButton[key]->connectSignal("key_press_event", keyButton[key], key_cb);
84 
85  keyBox[key]->fill(keyLabel[key]);
86  keyBox[key]->fill(keyButton[key]);
87  return keyBox[key];
88}
89
90Button* Player::getOpenButton()
91{
92  return openButton;
93}
94
95
96void Player::setkey(KEYS key)
97{
98  cout << "setting up Key: "<< key <<endl;
99
100}
101
102/**
103   \brief function to display, hide the palyer window
104   Buggy, segmentation fault on WindowMaker
105*/
106void Player::openWindow ()
107{
108  if (!windowIsOpen)
109    keyWindow->showall();
110  else
111    keyWindow->hide();
112  windowIsOpen = !windowIsOpen;
113}
114
115gint Player::openWindowEvent (GtkWidget* widget, GdkEvent* event, void* player)
116{
117
118  static_cast<Player*>(player)->openWindow();
119}
120
121
122/**
123   \brief Function which gets keystrokes
124   \param w the widget that released the Function.
125   \param event The event that happened.
126   \param Widget the Widget which will be applied.
127   \returns Nothing
128*/
129gint Player::key_cb(GtkWidget* w, GdkEventKey* event, void* widget)
130{
131  Button* button = static_cast<Button*>(widget);
132
133  switch(event->keyval) {
134  case GDK_Up:
135    printf("Up arrow key!\n");
136    button->setTitle("up");
137    break;
138  case GDK_Down:
139    printf("Down arrow key!\n");
140    button->setTitle("down");
141    break;
142  case GDK_Left:
143    printf("Left arrow key!\n");
144    button->setTitle("left");
145    break;
146  case GDK_Right:
147    printf("Right arrow key!\n");
148    button->setTitle("right");
149    break;
150
151  case GDK_space:
152    printf("Space Pressed.\n");
153    button->setTitle("space");
154    break;
155
156  case 65293:
157    printf("Enter Pressed\n");
158    button->setTitle("enter");
159    break;
160
161    // Special Keys //
162  case GDK_Shift_L:
163    printf("Left Shift!\n");
164    button->setTitle("l_shift");
165    break;
166  case GDK_Shift_R:
167    printf("Right Shift!\n");
168    button->setTitle("r_shift");
169    break;
170  case GDK_Control_L:
171    printf("Left Control!\n");
172    button->setTitle("l_ctrl");
173    break;
174  case GDK_Control_R:
175    printf("Right Control!\n");
176    button->setTitle("r_ctrl");
177    break;
178  case GDK_Alt_L:
179    printf("Left Alt!\n");
180    button->setTitle("l_alt");
181    break;
182  case GDK_Alt_R:
183    printf("Rigth Alt!\n");
184    button->setTitle("r_alt");
185    break;
186    // FXX KEYS //
187  case GDK_F1:
188    printf("F1!\n");
189    button->setTitle("f1");
190    break;
191  case GDK_F2:
192    printf("F2!\n");
193    button->setTitle("f2");
194    break;
195  case GDK_F3:
196    printf("F3!\n");
197    button->setTitle("f3");
198    break;
199  case GDK_F4:
200    printf("F4!\n");
201    button->setTitle("f4");
202    break;
203  case GDK_F5:
204    printf("F5!\n");
205    button->setTitle("f5");
206    break;
207  case GDK_F6:
208    printf("F6!\n");
209    button->setTitle("f6");
210    break;
211  case GDK_F7:
212    printf("F7!\n");
213    button->setTitle("f7");
214    break;
215  case GDK_F8:
216    printf("F8!\n");
217    button->setTitle("f8");
218    break;
219  case GDK_F9:
220    printf("F9\n");
221    button->setTitle("f9");
222    break;
223  case GDK_F10:
224    printf("F10!\n");
225    button->setTitle("f10");
226    break;
227  case GDK_F11:
228    printf("F11!\n");
229    button->setTitle("f11");
230    break;
231  case GDK_F12:
232    printf("F12!\n");
233    button->setTitle("f12");
234    break;
235
236
237  default:
238    char* tmp;
239    sprintf(tmp, "%c", event->keyval);
240    printf ("other key %s \n", tmp);
241    button->setTitle(tmp);
242    break;
243  }
244}
Note: See TracBrowser for help on using the repository browser.