2 JPC-RR: A x86 PC Hardware Emulator
5 Copyright (C) 2007-2009 Isis Innovation Limited
6 Copyright (C) 2009-2010 H. Ilari Liusvaara
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 2 as published by
10 the Free Software Foundation.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 Based on JPC x86 PC Hardware emulator,
22 A project from the Physics Dept, The University of Oxford
24 Details about original JPC can be found at:
26 www-jpc.physics.ox.ac.uk
30 package org
.jpc
.plugins
;
32 import java
.awt
.event
.ActionEvent
;
33 import java
.awt
.event
.ActionListener
;
34 import java
.security
.AccessControlException
;
37 import org
.jpc
.pluginsbase
.Plugins
;
38 import org
.jpc
.pluginsbase
.Plugin
;
39 import org
.jpc
.emulator
.PC
;
40 import org
.jpc
.emulator
.peripheral
.Keyboard
;
41 import static org
.jpc
.Misc
.errorDialog
;
42 import static org
.jpc
.Misc
.moveWindow
;
44 public class PCStartStopTest
extends JFrame
implements Plugin
46 private static final long serialVersionUID
= 8;
47 private Plugins vPluginManager
;
48 private Keyboard keyboard
;
50 public boolean systemShutdown()
52 //Not interested (JVM kill ok)
56 public void reconnect(PC pc
)
59 keyboard
= (Keyboard
)pc
.getComponent(Keyboard
.class);
65 public void pcStarting()
70 public void pcStopping()
80 public void connectPC(PC pc
)
85 public void eci_pcstartstoptest_setwinpos(Integer x
, Integer y
)
87 moveWindow(this, x
.intValue(), y
.intValue(), 720, 50);
91 public PCStartStopTest(Plugins manager
) throws Exception
93 super("Control test");
95 this.vPluginManager
= manager
;
97 JMenuBar bar
= new JMenuBar();
100 JMenu file
= new JMenu("Action");
101 (tmp
= file
.add("Vretrace start trap on")).addActionListener(new ActionListener() {
102 public void actionPerformed(ActionEvent e
)
104 vPluginManager
.invokeExternalCommand("trap-vretrace-start-on", null);
107 tmp
.setAccelerator(KeyStroke
.getKeyStroke("3"));
109 (tmp
= file
.add("Vretrace start trap off")).addActionListener(new ActionListener() {
110 public void actionPerformed(ActionEvent e
)
112 vPluginManager
.invokeExternalCommand("trap-vretrace-start-off", null);
115 tmp
.setAccelerator(KeyStroke
.getKeyStroke("4"));
117 (tmp
= file
.add("Start")).addActionListener(new ActionListener() {
118 public void actionPerformed(ActionEvent e
)
120 vPluginManager
.invokeExternalCommand("pc-start", null);
123 tmp
.setAccelerator(KeyStroke
.getKeyStroke("5"));
125 (tmp
= file
.add("Stop")).addActionListener(new ActionListener() {
126 public void actionPerformed(ActionEvent e
)
128 vPluginManager
.invokeExternalCommand("pc-stop", null);
131 tmp
.setAccelerator(KeyStroke
.getKeyStroke("6"));
133 (tmp
= file
.add("Send <Left> Edge")).addActionListener(new ActionListener() {
134 public void actionPerformed(ActionEvent e
)
137 keyboard
.sendEdge(128 + 75);
138 } catch(Exception f
) {
139 errorDialog(f
, "Failed to send keyboard event", null, "Dismiss");
143 tmp
.setAccelerator(KeyStroke
.getKeyStroke("J"));
145 (tmp
= file
.add("Send <Down> Edge")).addActionListener(new ActionListener() {
146 public void actionPerformed(ActionEvent e
)
149 keyboard
.sendEdge(128 + 80);
150 } catch(Exception f
) {
151 errorDialog(f
, "Failed to send keyboard event", null, "Dismiss");
155 tmp
.setAccelerator(KeyStroke
.getKeyStroke("K"));
157 (tmp
= file
.add("Send <Right> Edge")).addActionListener(new ActionListener() {
158 public void actionPerformed(ActionEvent e
)
161 keyboard
.sendEdge(128 + 77);
162 } catch(Exception f
) {
163 errorDialog(f
, "Failed to send keyboard event", null, "Dismiss");
167 tmp
.setAccelerator(KeyStroke
.getKeyStroke("L"));
169 (tmp
= file
.add("Send <Up> Edge")).addActionListener(new ActionListener() {
170 public void actionPerformed(ActionEvent e
)
173 keyboard
.sendEdge(128 + 72);
174 } catch(Exception f
) {
175 errorDialog(f
, "Failed to send keyboard event", null, "Dismiss");
179 tmp
.setAccelerator(KeyStroke
.getKeyStroke("I"));
181 (tmp
= file
.add("Send <Enter> Edge")).addActionListener(new ActionListener() {
182 public void actionPerformed(ActionEvent e
)
185 keyboard
.sendEdge(28);
186 } catch(Exception f
) {
187 errorDialog(f
, "Failed to send keyboard event", null, "Dismiss");
191 tmp
.setAccelerator(KeyStroke
.getKeyStroke("M"));
193 (tmp
= file
.add("Send <Escape> Edge")).addActionListener(new ActionListener() {
194 public void actionPerformed(ActionEvent e
)
197 keyboard
.sendEdge(1);
198 } catch(Exception f
) {
199 errorDialog(f
, "Failed to send keyboard event", null, "Dismiss");
203 tmp
.setAccelerator(KeyStroke
.getKeyStroke("N"));
205 (tmp
= file
.add("Send <RShift> Edge")).addActionListener(new ActionListener() {
206 public void actionPerformed(ActionEvent e
)
209 keyboard
.sendEdge(54);
210 } catch(Exception f
) {
211 errorDialog(f
, "Failed to send keyboard event", null, "Dismiss");
215 tmp
.setAccelerator(KeyStroke
.getKeyStroke("B"));
217 (tmp
= file
.add("Send <RCTRL> Edge")).addActionListener(new ActionListener() {
218 public void actionPerformed(ActionEvent e
)
221 keyboard
.sendEdge(128 + 29);
222 } catch(Exception f
) {
223 errorDialog(f
, "Failed to send keyboard event", null, "Dismiss");
227 tmp
.setAccelerator(KeyStroke
.getKeyStroke("V"));
229 (tmp
= file
.add("Send <RALT> Edge")).addActionListener(new ActionListener() {
230 public void actionPerformed(ActionEvent e
)
233 keyboard
.sendEdge(128 + 56);
234 } catch(Exception f
) {
235 errorDialog(f
, "Failed to send keyboard event", null, "Dismiss");
239 tmp
.setAccelerator(KeyStroke
.getKeyStroke("C"));
241 (tmp
= file
.add("Send <SPACE> Edge")).addActionListener(new ActionListener() {
242 public void actionPerformed(ActionEvent e
)
245 keyboard
.sendEdge(57);
246 } catch(Exception f
) {
247 errorDialog(f
, "Failed to send keyboard event", null, "Dismiss");
251 tmp
.setAccelerator(KeyStroke
.getKeyStroke("X"));
255 JMenu save
= new JMenu("Save");
256 for(int i
= 1; i
<= 12; i
++) {
258 (tmp
= save
.add("Save slot #" + i
)).addActionListener(new ActionListener() {
259 public void actionPerformed(ActionEvent e
)
262 vPluginManager
.invokeExternalCommand("state-save", new String
[]{"saveslot-" + i2
+ ".jrsr"});
263 } catch(Exception f
) {
264 errorDialog(f
, "Failed to save state", null, "Dismiss");
268 tmp
.setAccelerator(KeyStroke
.getKeyStroke("F" + i
));
270 (tmp
= save
.add("Load slot #" + i
)).addActionListener(new ActionListener() {
271 public void actionPerformed(ActionEvent e
)
274 vPluginManager
.invokeExternalCommand("state-load", new String
[]{"saveslot-" + i2
+ ".jrsr"});
275 } catch(Exception f
) {
276 errorDialog(f
, "Failed to load state", null, "Dismiss");
280 tmp
.setAccelerator(KeyStroke
.getKeyStroke("shift F" + i
));
288 setDefaultCloseOperation(JFrame
.DO_NOTHING_ON_CLOSE
);
290 catch (AccessControlException e
)
292 System
.err
.println("Error: Not able to add some components to frame: " + e
.getMessage());
295 setBounds(150, 150, 720, 50);