I want to emulate wacom tablet in such way, that different apps like photoshop will resive my mouse events with pressure. How can I do it?
Java API is oriented to normal mouse events. Using a mouse device does not give you a sense of pressure, as the device does not provide such input. If a normal mouse is your input device, then you have no way to get such info.
You could however imitate such input functionality, using the time interval of the mouse button being clicked. I would suggest using the "key down" and the "key up" event of the mouse click and translate the time difference between them as an indicator of the "pressure". Perhaps this tutorial could give you some guidance.
Another idea would be to get somehow info from the device directly. You could use the device API to get direct input and wrap it in your application.
Hope I helped!
Related
I am attempting to create a a java GUI for use on Zedboard with the 7" touchscreen display. The GUI I am creating is supposed to mimic exactly (though scaled down) a physical console with many interactive buttons.
My question is what would be the best method in making the buttons interactive, my first thought was to cut out the buttons of the console and have each one a separate image that can be set as interactive, but I feel there may be another simpler method.
Thanks
LDY
For the console mimicking, you could take an image of the entire console and then listen to touch event at specific points in the image which corresponds to a button. Based on where the touch event occurs, you could do different actions.
For this you need to get the coordinates of the touch event and check if it corresponds to any of the buttons on the console.
I'm currently teaching myself LWJGL's mouse class, but there is something I still don't know how to do. I want to be able to handle double-click mouse events, but I don't know how.
It is not (AFAIK) natively supported. You have to do it yourself.
One way to do that : memorize the event date (System.curentTimeMS() or equivalent).
If the previous clic event was recent (~200 ms), it's a double-clic. else, simple clic.
Hope it helps...
I'm a novice Android monkey and I've hit a snag trying to implement a feature on my app. What I want to do is have my users be able to long click an overlay item (it's a bus stop) and add that marker (stop number and address) to their favorites tab. The problem is... how do I listen for and handle a long click(tap) on an overlay item??
Currently I'm #overriding the onTap function in my Overlay class to handle regular taps, but I don't see an onLongTap function to override in the documentation... Can anyone set me along the right path? Am I missing something obvious here? Thanks for reading this
P.S. This is my first SO question :-)
You probably want to override onTouchEvent(MotionEvent, MapView) for more complex user interactions. For a 'long' tap, you should start some sort of timer that will indicate how long the user has been pressing on a specific Overlay item. Once a certain threshold is reached - I believe the default delay for a 'long' press is roughly 1500 ms - you then execute the relevant code.
Alternatively, you could take a look at including the mapview-overlay-manager project, which, from the reads of it, should offer exactly what your looking for (and then some):
OnOverlayGestureListener
Simplified OnGestureListener. A ManagedOverlayer uses its own build-in GestureDetector that fires
events like:
onSingleTap(MotionEvent, ManagedOverlay, GeoPoint, OverlayItem)
onDoubleTap(MotionEvent, ManagedOverlay, GeoPoint, OverlayItem)
onLongPress(MotionEvent, ManagedOverlay, GeoPoint, OverlayItem)
onZoom(ZoomEvent, ManagedOverlay) onScrolled(...)
I am trying to develop an application which responds to multiple digital pens (IRIS Pens) so that if any of the pen writes on paper; I relay the output to a single screen. Thus making a multi-input whiteboard for myself.
In Ubuntu these pens are recognized as mouse and thus can be handled in a similar manner as mouse events are handled.
So now what I plan to do is to handle these events in C/C++ using XLib and pass these events to a Java Swing application using JNI callback. I am able to do this but when the X11 window looses focus no events are transferred to the Swing frame. I also tried to use the root window in X11 but it does not seem to work.
Any help would be really appreciated. Thanking you in advance.
How about maximizing the C/X11 window in front of the Java one, and making it transparent? You should be able to see the Java window while still focusing on the C/X11 one.
Since you are using Ubuntu, you can achieve this using the "Opacity, brightness and saturation" plugin for Compiz. It is in the compiz-plugins-main package, and you can activate it with Compiz Settings Manager (from the compizconfig-settings-manager package). When you activate the plugin, alt+wheel is bound by default to change the transparency of the focused window.
Try reading the mouse directly. I don't remember the exact location, but you should find it in something like '/dev/input/mouseX', where X is the number of your device, ranging from 0 to n-1 devices..
When you read the packet, your application should block until the mouse moves and then your read function will return a raw mouse packet which describes the delta (which is probably more useful then the screen coordinates, in your case) and the mouse button statuses.
The raw packet can be decoded as described here: http://www.computer-engineering.org/ps2mouse/
Create a modal dialog and set it to XmDIALOG_SYSTEM_MODAL (the actual name of the property depends on your toolkit: Motif, Gtk, Qt, ...). Dialogs like this block the whole display and can never loose focus.
The drawback is of course that you can't do anything else while this dialog is on the screen.
This entry in the X11 FAQ might help.
I have an application which i am going to install on Linux touch system. The touch system is not giving me the touch sound so i decided to have that feature on my application. What is the best way to do it ? I dont want to go through each and every buttons and other components and write the codes there. Is there any global way to handle that so that the sound works throughout the application when ever the screen is touched or mouse is clicked ??
Try this
Toolkit.getDefaultToolkit().beep();
To play it in all MouseEvent make your MouseEvent listener single and everytime when you need use that listener and write above code in that mouse listener.
Take this answer:
How can I play sound in Java?
... and trigger the playback in the mouse click event.
Assuming that you are using the JFC/Swing toolkit, you might want to read a bit about using the Multiplexing Look & Feel. Even though I don't know of any ready-to-use auxiliary look and feel(s) that might fit your needs, it should be possible to write your own auxiliary look and feel which behaves as you describe above ...
... after you have created your own auxiliary look and feel make sure to start your java interpreter with the "-Dswing.auxiliarylaf=your.auxiliary.look.and.feel.Classname" parameter.