From 6b75e4b087779fecd03b9dbed7f5eb969b5e0722 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Tue, 21 Sep 2010 18:45:24 +0300 Subject: [PATCH] Send clicks to monitor panel to Lua (for instance for mouse emulation) --- Changelog.utf8 | 5 +-- VERSIONINFO | 2 +- lua/generic-watch.lua | 4 ++- org/jpc/plugins/PCControl.java | 5 +++ org/jpc/plugins/PCMonitor.java | 5 +++ org/jpc/pluginsaux/PCMonitorPanel.java | 49 +++++++++++++++++++++++++- org/jpc/pluginsaux/PCMonitorPanelEmbedder.java | 1 + 7 files changed, 66 insertions(+), 5 deletions(-) diff --git a/Changelog.utf8 b/Changelog.utf8 index ecbde94..9a2eaef 100644 --- a/Changelog.utf8 +++ b/Changelog.utf8 @@ -1,5 +1,5 @@ -Changes since JPC-RR Release 11: -================================ +Changes from JPC-RR Release 11 to JPC-RR Release 11.1: +====================================================== - Fix palette buffer overruns in VGA code. - Add HQX resize driver. - Output-drv-x264: Automatically pass correct constant framerate. @@ -7,6 +7,7 @@ Changes since JPC-RR Release 11: - Make other file ops than save/load use different dialog. - Fix = vs space in x264 and oggenc drivers. - New FAAC output driver. +- Send clicks to monitor panel to Lua (for instance for mouse emulation). Changes from JPC-RR Release 10.5 to JPC-RR Release 11: ====================================================== diff --git a/VERSIONINFO b/VERSIONINFO index b4de394..ef32e32 100644 --- a/VERSIONINFO +++ b/VERSIONINFO @@ -1 +1 @@ -11 +11.1 diff --git a/lua/generic-watch.lua b/lua/generic-watch.lua index 6fd5903..846daf3 100644 --- a/lua/generic-watch.lua +++ b/lua/generic-watch.lua @@ -102,10 +102,12 @@ add_field("Joystick button 2-2: ", function() return fmt_jbutton(bD); end); win:show(); while true do - a = jpcrr.wait_event(); + a, b = jpcrr.wait_event(); if a == "lock" then hA, hB, hC, hD, bA, bB, bC, bD = jpcrr.joystick_state(); do_update(); jpcrr.release_vga(); + elseif a == "message" then + print("Message: " .. b); end end diff --git a/org/jpc/plugins/PCControl.java b/org/jpc/plugins/PCControl.java index ddbc4b3..ddcf941 100644 --- a/org/jpc/plugins/PCControl.java +++ b/org/jpc/plugins/PCControl.java @@ -841,6 +841,11 @@ public class PCControl implements Plugin, PCMonitorPanelEmbedder window.setVisible(true); } + public void sendMessage(String msg) + { + vPluginManager.invokeExternalCommand("luaplugin-sendmessage", new Object[]{msg}); + } + private String debugShowName(String name) { name = name.substring(12); diff --git a/org/jpc/plugins/PCMonitor.java b/org/jpc/plugins/PCMonitor.java index 850f886..1aa6bd8 100644 --- a/org/jpc/plugins/PCMonitor.java +++ b/org/jpc/plugins/PCMonitor.java @@ -82,6 +82,11 @@ public class PCMonitor implements Plugin, PCMonitorPanelEmbedder monitorWindow.setVisible(true); } + public void sendMessage(String msg) + { + pManager.invokeExternalCommand("luaplugin-sendmessage", new Object[]{msg}); + } + public void eci_pcmonitor_setwinpos(Integer x, Integer y) { moveWindow(monitorWindow, x.intValue(), y.intValue(), nativeWidth, nativeHeight); diff --git a/org/jpc/pluginsaux/PCMonitorPanel.java b/org/jpc/pluginsaux/PCMonitorPanel.java index 498eedd..88bf990 100644 --- a/org/jpc/pluginsaux/PCMonitorPanel.java +++ b/org/jpc/pluginsaux/PCMonitorPanel.java @@ -32,7 +32,9 @@ package org.jpc.pluginsaux; import java.awt.*; import java.util.*; import java.awt.event.ActionListener; +import java.awt.event.MouseListener; import java.awt.event.ActionEvent; +import java.awt.event.MouseEvent; import javax.swing.*; import org.jpc.pluginsbase.Plugins; import org.jpc.pluginsbase.Plugin; @@ -50,7 +52,7 @@ import org.jpc.pluginsaux.PNGSaver; * * @author Rhys Newman */ -public class PCMonitorPanel implements ActionListener +public class PCMonitorPanel implements ActionListener, MouseListener { private static final long serialVersionUID = 6; private OutputStatic outputServer; @@ -135,6 +137,7 @@ public class PCMonitorPanel implements ActionListener lampx.addActionListener(this); lamp.add(lampx); + monitorPanel.addMouseListener(this); resizeDisplay(480, 360, true); } @@ -328,4 +331,48 @@ public class PCMonitorPanel implements ActionListener g.fillRect(0, s2h, s.width, s.height - s2h); } } + + private int getButtonNumber(MouseEvent e) + { + int button = e.getButton(); + if(button == MouseEvent.BUTTON1) + return 1; + else if(button == MouseEvent.BUTTON2) + return 2; + else if(button == MouseEvent.BUTTON3) + return 3; + return 0; + } + + public void mouseClicked(MouseEvent e) + { + int button = getButtonNumber(e); + int x = e.getX(); + int y = e.getY(); + embedder.sendMessage("MouseClicked " + button + " " + x + " " + y); + } + + public void mouseEntered(MouseEvent e) + { + } + + public void mouseExited(MouseEvent e) + { + } + + public void mousePressed(MouseEvent e) + { + int button = getButtonNumber(e); + int x = e.getX(); + int y = e.getY(); + embedder.sendMessage("MousePressed " + button + " " + x + " " + y); + } + + public void mouseReleased(MouseEvent e) + { + int button = getButtonNumber(e); + int x = e.getX(); + int y = e.getY(); + embedder.sendMessage("MouseReleased " + button + " " + x + " " + y); + } } diff --git a/org/jpc/pluginsaux/PCMonitorPanelEmbedder.java b/org/jpc/pluginsaux/PCMonitorPanelEmbedder.java index ed5eb40..eaef19a 100644 --- a/org/jpc/pluginsaux/PCMonitorPanelEmbedder.java +++ b/org/jpc/pluginsaux/PCMonitorPanelEmbedder.java @@ -35,4 +35,5 @@ public interface PCMonitorPanelEmbedder public abstract void notifySizeChange(int w, int h); public abstract void notifyFrameReceived(int w, int h); public abstract void notifyRenderer(HUDRenderer r); + public abstract void sendMessage(String msg); } -- 2.11.4.GIT