This repository was archived by the owner on May 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowsProc.h
More file actions
61 lines (46 loc) · 1.58 KB
/
WindowsProc.h
File metadata and controls
61 lines (46 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once
#include <windows.h>
#include <windowsx.h>
#include <jni.h>
#include <thread>
#include <map>
#include <iostream>
extern "C" {
JNIEXPORT void JNICALL Java_ca_utoronto_utm_pointer_WindowsPointer_init(JNIEnv *, jobject, jlong);
}
const int CONTROL = 1 << 1; //2
const int SHIFT = 1 << 0; //1
const int ALT = 1 << 3; //8
const int LBUTTON = 1 << 4; //16
const int RBUTTON = 1 << 2; //4
const int MBUTTON = 1 << 3; //8
const int JMOUSE_FIRST = 500;
const int JMOUSE_LAST = 507;
const int JMOUSE_PRESSED = 1 + JMOUSE_FIRST;
const int JMOUSE_RELEASED = 2 + JMOUSE_FIRST;
const int JMOUSE_MOVED = 3 + JMOUSE_FIRST;
const int JMOUSE_ENTERED = 4 + JMOUSE_FIRST;
const int JMOUSE_EXITED = 5 + JMOUSE_FIRST;
const int JKEY_PRESS = 401;
const int JKEY_RELEASE = 402;
class WindowsProc
{
public:
WindowsProc(JavaVM *jvm, jobject object, WNDPROC wndprocOrig);
~WindowsProc();
static std::map <HWND, WindowsProc*> windObjects;
static LRESULT CALLBACK PtrSetup(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
static LRESULT CALLBACK WndProcProxy(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
private:
JavaVM *jvm;
jobject pairedObject;
WNDPROC wndprocOrig;
jmethodID update, key;
void getMethods();
jint getButton(POINTER_FLAGS flags);
void sendKeyUpdate(int eventId, int modifiers, WPARAM wParam);
void sendUpdate(int eventId, POINTER_INFO pointerInfo, int modifiers, int pressure);
LRESULT _PtrSetup(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT _WndProcProxy(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
static jint getModifiers();
};