$100 to create Mouse Library (getting desperate!)

almontgreen

Active Member
Licensed User
Longtime User
I've scoured this list and can't find a way through basic4android to capture the mouse scroll button. If anyone could add this to the onHover library (or create something similar) I'd paypal $100 to them and would be happy to have that library shared.

Another nice feature to include in the library would be to hide the cursor and trap for the other buttons but I'd be happy with just the scroll feature. I'm running Android 4.2.2 on a QC802 miniPC and this library only needs to work on that platform.
 

vpires

Member
Licensed User
Longtime User
Hello. Usb or bluetooth mouse ?
If bluetooth, i'll by one and will take a look at it.

Nelson
 

almontgreen

Active Member
Licensed User
Longtime User
I can specify the mouse and system, so not a problem for bluetooth (using QC802 MiniPC). Thanks!!! If you can do it that would be great as I'm still struggling to figure out something to get Scroll wheel up and Scroll wheel down and capture those events without passing to the system.
 

almontgreen

Active Member
Licensed User
Longtime User
Hello. Usb or bluetooth mouse ?
If bluetooth, i'll by one and will take a look at it.

Nelson
Still dead in the water with Bluetooth mouse and no way to get ACTION_SCROLL ??? This should be the fastest $100 anybody can earn who knows about API 12+ and the onMotionListener. I sure feel like a dope - just can't figure it out.
 

obscure

Member
Licensed User
Longtime User
B4X:
Sub Process_Globals

End Sub

Sub Globals
    Dim wheel As ScrollWheelListener
End Sub

Sub Activity_Create(FirstTime As Boolean)
    wheel.Initialize(Activity, "act")
End Sub

Sub Activity_Resume
   
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub act_WheelMoved(y As Float)
    Select y
        Case -1
            Log("down")
        Case 1
            Log("up")
    End Select
End Sub
 

Attachments

  • ScrollWheel.zip
    4.1 KB · Views: 345

barx

Well-Known Member
Licensed User
Longtime User
It is a bit strange that you haven't had any offers on this yet. I would attempt it for if I wasn't so busy, but very busy work wise and then doing a lot of web dev work on evenings and weekends. IF I can find a little time at the weekend then I will have a try at it. What features are you wanting? Have you tried creating the library yourself? You could use the available source of the AirView lib as a starting ground. Click
 

barx

Well-Known Member
Licensed User
Longtime User
Oh , and do you have an example found on the net that shows what your after but in java?
 

almontgreen

Active Member
Licensed User
Longtime User
Oh , and do you have an example found on the net that shows what your after but in java?
Thanks to "obscure" for getting me going! However, it's not going to be easy to get rid of the mouse cursor either by moving it to the top right of the screen or hiding it somehow (user intervention is not an option and that would have to happen programmatically). Also, the act_wheelMoved event in the example above is linked to a specific screen or layout and it would be better if it captured the event as a system event and trapped it so as to not pass it along like the OnHover library does. Maybe a simple edit to that library would be better?

At any rate, I think this could be useful to a lot of people and hope somebody adds to the above (I did send Obscure a paypal and really appreciate somebody doing something!) I'd be willing to donate some more for the effort to anyone that steps up and adds more functionality as I described.

Oh, and note that it works with usb mouse as well as bluetooth.
 

barx

Well-Known Member
Licensed User
Longtime User
i hadn't seen obscure's post...
 

almontgreen

Active Member
Licensed User
Longtime User
I have a working lib from obscure but the center mouse button event doesn't work. argh! Haven't been able to get in touch with him to fix it and I don't have the source to look at... what's that everyone says: "Bang head?" If anyone has a quick solution to snagging the middle mouse button event (actually mouse up) that would be super! I just don't have the know how to do it myself yet. Obscure... if you are out there I could use a hand ;^) thx.
 

stevel05

Expert
Licensed User
Longtime User
OK, there appears to be no direct way to get a mouse up event from Android. I assume the library I found was an early version as it had hardly any functionality.

I've changed the design and everything is done in one subroutine. The library passes the raw data to B4A which then does the processing.

The demo app uses a global variable to keep track of which mouse button is pressed and uses that to determine which is released.

Only one mouse press registers at a time (you can't press the left and right buttons together) and currently it doesn't check the ctrl and shift buttons. I may update that if requested.

Try it and let me know if it works for you.

BTW it required API 14+ (as did the lib I saw to start with).
 

Attachments

  • SWT1-1.zip
    12.2 KB · Views: 316
Last edited:

stevel05

Expert
Licensed User
Longtime User
I have made a small update to the library in the above post, The documentation is clearer and you should see the Event available in the IDE.

I've just read one of your earlier posts, the event handlers have to be attached to a view of some kind, it is not possible to get a system wide handler. although you can attach listeners to many views, as the new example shows the events will pass all the way back to activity unless you stop it by returning false, so if you put your code for the scroll wheel in the activity Action sub it will catch it there. Although you won't then know where the event originated from.

It also handles onHover and various input sources.
 

stevel05

Expert
Licensed User
Longtime User
Ok last update at least for today.

I've changed the name of the library to SLMotionEventListener as it does much more than just listen for the scroll wheel.

Update in post #12
 

stevel05

Expert
Licensed User
Longtime User
For the sake of completeness, I have added the x and y coordinates and the MetaStates to the library. You can check the key states as well as the mouse clicks. Updated in post #12.

The new demo demonstrates it's use.
 
Last edited:

almontgreen

Active Member
Licensed User
Longtime User
For the sake of completeness, I have added the x and y coordinates and the MetaStates to the library. You can check the key states as well as the mouse clicks. Updated in post #12.
Thanks, I'll have a look. In discussions with "obscure" I believe there is an issue with the device firmware (I'm working with a Tronsmart T428 miniPC) that is causing a problem with trapping the center mouse button event since he can demonstrate it working with a tablet device. At least, that's the initial thinking. I'll try your lib and see where we are at.
 

stevel05

Expert
Licensed User
Longtime User
I tested it on my ASUS TF101 10" Tablet and it worked fine, let me know if it works for you.

Re another one of you posts I've searched the Internet and cannot find a way to hide or programatically move the mouse pointer.
 

almontgreen

Active Member
Licensed User
Longtime User
I tested it on my ASUS TF101 10" Tablet and it worked fine, let me know if it works for you.

Re another one of you posts I've searched the Internet and cannot find a way to hide or programatically move the mouse pointer.
To hide the mouse pointer I created a new pointer_arrow.png (invisible) and copied it into the framework-res.apk replacing the pointer_arrow.png that is in there. To hide the bar at the bottom, I deleted the System_UI.apk file. Of course, the device has to be rooted. I haven't looked into placing the mouse pointer at boot time but one would guess it is in the firmware somewhere given that it is in the middle of the screen when it boots and I don't think that is an accident.

I suspect that I can do file manipulation with the B4ARootCmd library or maybe even with the file handling procedures? Although, a reboot is required I believe. So, a simple toggle function within an application isn't likely I'm guessing.

I tested the SWT1 above and I'm pretty convinced there is something up with the firmware for the device (Tronsmart T428) that prohibits the middle mouse button event from triggering. It is probably intercepted somewhere in the firmware? I have no doubt that it works on other devices.

Note: I've been experimenting with firmware tools and YIKES, that's a bit like drinking from a fire hose. Packing and unpacking, finding resources to manipulate and so forth. Not for the faint of heart.

I would encourage you (Stevel05) to publish the source of the SWT1 library and make it available to everyone. The ability to trap all the keys/mouse input events is potentially quite useful for many controller type applications.

While frustrating, it would be interesting to learn why the middle mouse button doesn't get through on my device with the firmware I have. Given the complexities of creating firmware, I suspect the middle mouse button is low on the priority list for a firmware developer.

Oh, one other thing - the right mouse button doesn't get captured, it exits the program and the action doesn't occur on the down event as expected? Maybe I'm not implementing correctly? At any rate, this isn't as simple as it seems and adapting the library to handle all possibilities, I would think, would be worthwhile...? Maybe not a commercially viable library, but an important one nonetheless and something I'm happy to support. I've discovered that there are some unusual things going on with event trapping and there are some confusing things with regards to where to put DoEvents for example. I've seen some undesirable side effects and don't fully understand what's going on. For example, I've had the app exit unexpectedly or hang and the problem went away when I eliminated a DoEvent... odd?
 

almontgreen

Active Member
Licensed User
Longtime User
Oh, one more thing... how hard is it to trap for left mouse down while scroll wheel is going up/down? Or for that matter, trapping for any key being held down while another key is pressed or the scrollwheel is being moved? In messing about with this, I've discovered that there is a key repeat rate that keeps firing events that are difficult to trap and that's why I think sometimes the program exits or hangs. Events go into a buffer and bad things happen... I used timer events to ignore key presses, but it only got stable once I used key_up event trapping. Key down caused problems because the event fires over and over and the trapping doesn't happen on a one to one basis.
 

stevel05

Expert
Licensed User
Longtime User
Ah ha, I've just dug out my old Zenithink tablet Android 4.01 and it behaves exactly as you describe. I'll investigate a bit further.
 
Top