kwhat / jnativehook

Global keyboard and mouse listeners for Java.
Other
1.75k stars 348 forks source link

Could jnativehook support Apple Silicon #326

Closed fy-create closed 3 years ago

fy-create commented 3 years ago

Could jnativehook support Apple Silicon

kwhat commented 3 years ago

Sure, as soon as I find some docs from apple that talk about how to to actually target the M1. See: https://github.com/kwhat/libuiohook/runs/2011216721

    error: unknown target CPU 'aarch64'
    note: valid target CPU values are: nocona, core2, penryn, bonnell, atom, silvermont, slm, goldmont, goldmont-plus, tremont, nehalem, corei7, westmere, sandybridge, corei7-avx, ivybridge, core-avx-i, haswell, core-avx2, broadwell, skylake, skylake-avx512, skx, cascadelake, cooperlake, cannonlake, icelake-client, icelake-server, tigerlake, knl, knm, k8, athlon64, athlon-fx, opteron, k8-sse3, athlon64-sse3, opteron-sse3, amdfam10, barcelona, btver1, btver2, bdver1, bdver2, bdver3, bdver4, znver1, znver2, x86-64
    make[1]: *** [CMakeFiles/cmTC_1ee3a.dir/testCCompiler.c.o] Error 1
    make: *** [cmTC_1ee3a/fast] Error 2
kwhat commented 3 years ago

I've posted on numerios forums to try and figure out how to do this with absolutely zero useful answers. If you or anyone else wants it, figure out how to do it.

cheenar commented 3 years ago

I am currently on an M1 Mac Mini and I am able to use the JNI for Keyboard Input monitoring, at the very least, as well as mouse movement and position.

There are some bugs such as the keyCode being set to 0 for each key, however, a raw key code is being displayed so I imagine it's possible to fix getKeyCode()

kwhat commented 3 years ago

Are you able to compile it on the M1 or are you using the x86 emulation? I do not have access to the hardware so unless I can get a lot more info there isn't much I can do.

kwhat commented 3 years ago

Support has been added, please test and let me know if it works ok.

kwhat commented 3 years ago

There maybe some issues with what Apple reports for System.getProperty("os.arch") on the M1, if it does not work a simple patch will be needed at NativeSystem.java#L114

kwhat commented 3 years ago

Artifacts should be on maven as snapshots as well as https://github.com/kwhat/jnativehook/actions/runs/1239449442

Update: fixed a number of issues, the link should reflect the latest build that includes the correct binaries.