FreeRDP
Loading...
Searching...
No Matches
Mouse.java
1/*
2 Android Mouse Input Mapping
3
4 Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
6 This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7 If a copy of the MPL was not distributed with this file, You can obtain one at
8 http://mozilla.org/MPL/2.0/.
9*/
10
11package com.freerdp.freerdpcore.utils;
12
13import android.content.Context;
14
15import com.freerdp.freerdpcore.presentation.ApplicationSettingsActivity;
16
17public class Mouse
18{
19
20 private final static int PTRFLAGS_LBUTTON = 0x1000;
21 private final static int PTRFLAGS_RBUTTON = 0x2000;
22 private final static int PTRFLAGS_MBUTTON = 0x4000;
23
24 private final static int PTRFLAGS_DOWN = 0x8000;
25 private final static int PTRFLAGS_MOVE = 0x0800;
26
27 private final static int PTRFLAGS_WHEEL = 0x0200;
28 private final static int PTRFLAGS_WHEEL_NEGATIVE = 0x0100;
29 private final static int PTRFLAGS_HWHEEL = 0x0400;
30
31 public static int getLeftButtonEvent(Context context, boolean down)
32 {
33 if (ApplicationSettingsActivity.getSwapMouseButtons(context))
34 return (PTRFLAGS_RBUTTON | (down ? PTRFLAGS_DOWN : 0));
35 else
36 return (PTRFLAGS_LBUTTON | (down ? PTRFLAGS_DOWN : 0));
37 }
38
39 public static int getRightButtonEvent(Context context, boolean down)
40 {
41 if (ApplicationSettingsActivity.getSwapMouseButtons(context))
42 return (PTRFLAGS_LBUTTON | (down ? PTRFLAGS_DOWN : 0));
43 else
44 return (PTRFLAGS_RBUTTON | (down ? PTRFLAGS_DOWN : 0));
45 }
46
47 public static int getMiddleButtonEvent(boolean down)
48 {
49 return (PTRFLAGS_MBUTTON | (down ? PTRFLAGS_DOWN : 0));
50 }
51
52 public static int getMoveEvent()
53 {
54 return PTRFLAGS_MOVE;
55 }
56
57 public static int getScrollEvent(Context context, boolean down)
58 {
59 int flags = PTRFLAGS_WHEEL;
60
61 // invert scrolling?
62 if (ApplicationSettingsActivity.getInvertScrolling(context))
63 down = !down;
64
65 if (down)
66 flags |= (PTRFLAGS_WHEEL_NEGATIVE | 0x0088);
67 else
68 flags |= 0x0078;
69 return flags;
70 }
71
72 public static int getHScrollEvent(Context context, boolean right)
73 {
74 int flags = PTRFLAGS_HWHEEL;
75
76 if (ApplicationSettingsActivity.getInvertScrolling(context))
77 right = !right;
78
79 if (right)
80 flags |= 0x0078;
81 else
82 flags |= (PTRFLAGS_WHEEL_NEGATIVE | 0x0088);
83 return flags;
84 }
85}