Compare commits

..

351 commits

Author SHA1 Message Date
Shadowfacts 47fda71672 Build for arm64 macOS 2022-01-17 11:45:44 -05:00
Endolf 447ec94f22 Merge branch 'master' of github.com:jinput/jinput 2019-01-29 19:18:29 +00:00
Endolf d861b32778 Update the example pom to include an exec example 2019-01-29 19:18:13 +00:00
Endolf 8662748d00
Merge pull request #49 from aarre/master
Correct typo
2018-12-11 19:59:25 +00:00
gearcats b98ee86b13 Correct typo 2018-12-11 14:03:28 -05:00
Endolf 8eafaaa61e
Added basic license information. 2018-07-30 17:14:01 +01:00
Endolf 796c4780fd Close resources as per PR #10 2018-07-22 16:12:47 +01:00
Endolf b6150acbce Update example jinput version 2018-06-01 21:33:10 +01:00
Endolf d0487df592 Another attempt to get the release working. 2018-06-01 21:27:58 +01:00
Endolf 33640ec47d Next development release 2018-06-01 20:53:10 +01:00
Endolf f37172befd Produce a javadoc file for the uber jar 2018-06-01 19:33:07 +01:00
Endolf c826412056 Website updates 2018-06-01 18:46:42 +01:00
Endolf 847c20d89c Website updates 2018-06-01 18:32:56 +01:00
Endolf b70a38d9f1 Website updates 2018-06-01 18:31:56 +01:00
Endolf 3b79a57e9f Website updates 2018-06-01 18:30:04 +01:00
Endolf d8fd89c5f2 Website updates 2018-06-01 18:27:05 +01:00
Endolf 196fab2d6f Update the way the fat jar is built and the pom distributed. 2018-06-01 18:20:57 +01:00
Endolf be5f3a6307 Website updates 2018-06-01 17:42:33 +01:00
Endolf 341db62139 Website updates 2018-06-01 17:26:01 +01:00
Endolf ba876c7e34 Website updates 2018-06-01 17:06:16 +01:00
Endolf abceb81d56 Use theme default layout 2018-06-01 16:57:17 +01:00
Endolf 351e8e1201 Website updates 2018-06-01 16:54:05 +01:00
Endolf f7155114ce Website updates 2018-06-01 16:50:20 +01:00
Endolf f12daf06da Website updates 2018-06-01 16:44:38 +01:00
Endolf b15ffc59b4 Update maven dependency details 2018-06-01 16:40:55 +01:00
Endolf d5451041a7 Update maven dependency details 2018-06-01 16:40:35 +01:00
Endolf fc1f43c5cf Using the docs version now 2018-06-01 16:32:46 +01:00
Endolf 6c5b3cf39d
Merge pull request #39 from jinput/github-pages
GitHub pages
2018-06-01 16:30:46 +01:00
Endolf 78ca4c4d18 Update maven details 2018-06-01 16:29:56 +01:00
Endolf f7742fbd95
Merge pull request #31 from dyorgio/master
Included GitHub Pages  support
2018-06-01 16:20:17 +01:00
jinput d166d82729 Set theme jekyll-theme-architect 2018-06-01 16:16:59 +01:00
Endolf 62c5953307 Merge remote-tracking branch 'origin/master' into github-pages 2018-06-01 16:04:07 +01:00
Endolf 5a83f72422
Merge pull request #38 from jinput/issue/36
Issue/36
2018-06-01 16:02:17 +01:00
Endolf 43ba12c160 Move pom version declaration 2018-06-01 15:55:08 +01:00
Endolf 06d9d5ca66 Build uber jars 2018-06-01 15:49:09 +01:00
Endolf 4f6269fdd2 Create a pom that allows all dependencies to be imported easily 2018-06-01 15:04:43 +01:00
Endolf 92f17913ca Add information on log level changes. 2018-05-31 21:07:03 +01:00
Endolf 7ea0ebcc1f Handle packaging changes in readme badges 2018-05-31 21:03:48 +01:00
Endolf 16202823b5
Merge pull request #37 from jinput/issue/32
Issue/32
2018-05-31 20:58:11 +01:00
Endolf 466e4a6bdb Fixed compile warnings 2018-05-31 20:36:30 +01:00
Endolf 67902800ab Fixed compile warnings 2018-05-31 20:16:51 +01:00
Endolf af914ca5e4 Fixed compile warnings 2018-05-31 19:57:36 +01:00
Endolf d057119f79 Fixed compile warnings 2018-05-31 19:54:41 +01:00
Endolf a623d0c271 Fixed compile warnings 2018-05-31 19:42:43 +01:00
Endolf c77ad3226c Fixed compile warnings 2018-05-31 19:39:58 +01:00
Endolf ad452077d4 Fixed compile warnings 2018-05-31 19:31:37 +01:00
Endolf 83dd362c65 Fix license 2018-05-31 19:28:49 +01:00
Endolf 7d3e5f31ae Fixed compile warnings 2018-05-31 19:27:48 +01:00
Endolf 88395eef77 Fixed compile warnings 2018-05-31 19:15:35 +01:00
Endolf a775a55c46 Fixed compile warnings 2018-05-31 19:09:13 +01:00
Endolf 981587abbc Fixed compile warnings 2018-05-30 19:22:39 +01:00
Endolf b87aa830e8 Fixed compile warnings 2018-05-30 19:20:42 +01:00
Endolf 30304ba8f4 Fixed compile warnings 2018-05-30 19:18:31 +01:00
Endolf a19b3c9fa3 Fixed compile warnings 2018-05-30 19:11:46 +01:00
Endolf 59c21d42c5 Fixed compile warnings 2018-05-30 19:09:03 +01:00
Endolf 4ef9e03623 Fixed compile warnings 2018-05-30 18:41:48 +01:00
Endolf d80d2ad2b2 Fixed compile warnings 2018-05-30 18:23:15 +01:00
Endolf 91428ceee0 Fixed compile warnings 2018-05-30 18:19:00 +01:00
Endolf 0cfd2ae7cd Fixed compile warnings 2018-05-30 18:14:58 +01:00
Endolf db8c6804b4 Fixed compile warnings 2018-05-30 17:53:20 +01:00
Endolf c9152a679d Fixed compile warnings 2018-05-30 17:45:52 +01:00
Endolf 4b8183ead9 Fixed compile warnings 2018-05-30 17:42:06 +01:00
Endolf 5ba05aff65 Code tidy up 2018-05-30 17:39:34 +01:00
Endolf b853018676 Add serialVersionUID 2018-05-30 17:38:55 +01:00
Endolf f5f30e17ab Code tidy up 2018-05-30 17:38:20 +01:00
Endolf 516aed2c93 Fixed compile warnings 2018-05-30 17:19:18 +01:00
Endolf 72d4ca05a8 Fail on compiler warnings in the plugins 2018-05-30 17:04:07 +01:00
Endolf f0d7f6db03 Mostly fixed compiler warnings 2018-05-30 17:02:27 +01:00
Endolf 9c639cdfbc Mostly fixed compiler warnings 2018-05-29 22:30:06 +01:00
Endolf 4b00766888 Fail on compiler warnings in the plugins 2018-05-29 22:29:43 +01:00
Endolf 2bc8a793c8 Fixed compile warnings for awt plugin 2018-05-29 21:55:13 +01:00
Endolf 81c9c872cd Fixed compile warnings for core api 2018-05-29 21:43:15 +01:00
Endolf 98a19dbb1a Update to push tags 2018-05-25 22:26:29 +01:00
Endolf 974302e420 Next development release 2018-05-25 21:52:45 +01:00
Endolf 3bc6b827e0 Hopefully fix the release not incrementing or commiting 2018-05-25 21:51:40 +01:00
Endolf c63b09a047 Hopefully fix the release not incrementing or commiting 2018-05-25 21:50:06 +01:00
Endolf 6150206edb Change the release stage name 2018-05-25 21:00:38 +01:00
Endolf a4c7d312d2 Add the git push 2018-05-25 20:59:46 +01:00
Endolf 99debb71a0 Use a parameterised build for release 2018-05-25 20:52:21 +01:00
Endolf 9509787f01 Use a parameterised build for release 2018-05-25 20:43:17 +01:00
Endolf b6ca29e9f1 Move input out of an agent tied stage 2018-05-25 20:30:38 +01:00
Endolf a095351e4a Try and get the version scriptlet working. 2018-05-25 20:24:44 +01:00
Endolf bd571ad746 Add ordinals to milestone 2018-05-25 20:22:09 +01:00
Endolf c72d1fcb01 Input shouldn't have {} 2018-05-25 20:16:48 +01:00
Endolf b997ef8545 Milestone needs () 2018-05-25 20:13:22 +01:00
Endolf 97416d3813 Testing timeout 2018-05-25 20:09:45 +01:00
Endolf d4ce65b28b Try and work out where milestone and input live. 2018-05-25 20:09:15 +01:00
Endolf 8ba4395c2d Try and work out where milestone and input live. 2018-05-25 20:06:03 +01:00
Endolf 544e00cd5c Use the nexus staging plugin for release 2018-05-25 19:50:59 +01:00
Endolf 12496a9fbb Don't use the release plugin 2018-05-25 19:20:30 +01:00
Endolf 76613c2c6f Jenkins file updates for release 2018-05-25 19:17:41 +01:00
Endolf f1b1b5a74f Updates to plugins for release 2018-05-25 19:13:55 +01:00
Endolf ded17f0897 Updates to plugins for release 2018-05-25 19:10:10 +01:00
Endolf b6253e440e Start of a release pipeline build 2018-05-25 18:28:11 +01:00
Endolf 165a4d74e6
Merge pull request #34 from jinput/issue/26
Issue/26
2018-05-25 16:50:15 +01:00
Endolf b440e211e1
Merge pull request #35 from jinput/master
Merge master
2018-05-25 07:35:00 +01:00
Endolf 5eb89d4e12 Disable logging option 2018-05-24 22:41:39 +01:00
Endolf 771499a7ca Fix the javadoc jenkins archive 2018-05-24 21:57:01 +01:00
Endolf 5b799195e3 Build core first 2018-05-24 21:54:32 +01:00
Endolf bd61698f16 Only sign on deploy 2018-05-24 21:33:54 +01:00
Endolf 79a3fc9291 Only deploy on master branch 2018-05-24 20:54:29 +01:00
Endolf aa699f5ffb Remove the log call that added extra new lines 2018-05-24 20:52:18 +01:00
Endolf f228dbcf59
Merge pull request #33 from jinput/jenkinsfile
Jenkinsfile
2018-05-24 20:03:25 +01:00
Endolf b82395833a Update the example pom to use central snapshots and pull in all plugins 2018-05-24 19:56:04 +01:00
Endolf 8a569fdc63 Only run build on linux as windows doesn't like shell scripts.... 2018-05-24 19:28:58 +01:00
Endolf d9586e25bb Refactor the build in to build natives, build and deploy. 2018-05-24 19:25:57 +01:00
Endolf 98cf806325 Use the ready built artifacts 2018-05-24 19:00:01 +01:00
Endolf 0d466440d9 Activate all profiles and don't compile the code 2018-05-24 18:29:02 +01:00
Endolf b93ddcc46e Lower case the profile names 2018-05-24 18:27:46 +01:00
Endolf 70c9291774 Add cacerts property for JDK9 missing cacerts file. 2018-05-24 18:13:44 +01:00
Endolf 99df8dc84c Working towards a working deployment 2018-05-23 22:00:46 +01:00
Endolf 5d19200671 Use ID of settings file. 2018-05-23 21:00:23 +01:00
Endolf 6b177835ff Fix secret key importing. 2018-05-23 20:39:54 +01:00
Endolf 4731a08964 First attempt at deploying snapshots to maven central 2018-05-23 20:12:22 +01:00
Endolf 5b0cafeb36 Fix the stashing and unstashing 2018-05-23 17:49:04 +01:00
Endolf f541fdb219 Fix the stashing and unstashing 2018-05-23 17:29:25 +01:00
Endolf dc75289f96 Merge remote-tracking branch 'origin/master' into jenkinsfile 2018-05-23 17:26:51 +01:00
Endolf 5b7c6314ed Fix use of deprecated methods 2018-05-23 17:26:16 +01:00
Endolf 04b2dce53a Reduce the items we are stashing and unstashing. 2018-05-23 17:19:47 +01:00
dyorgio 676f94ed4c Fix some markdown issues (github pages). 2018-05-23 11:34:50 -03:00
dyorgio b1d6589b73 Added usage example (github pages). 2018-05-23 11:32:42 -03:00
dyorgio 55e0f46eec Fix some markdown issues (github pages). 2018-05-23 11:23:36 -03:00
dyorgio 9f650f8a5d Initial index page contents (github pages). 2018-05-23 11:20:15 -03:00
dyorgio 0f52875091 Included default layout (github pages). 2018-05-23 11:00:54 -03:00
dyorgio e0676a02df Included index.md (github pages). 2018-05-23 10:58:39 -03:00
dyorgio 5119891aa7 Included docs folder and Jekyll config (github pages). 2018-05-23 10:55:19 -03:00
Endolf 9d11cb04da Unstash artifacts 2018-05-23 01:39:46 +01:00
Endolf 517357401e Only keep 5 builds. 2018-05-23 01:29:14 +01:00
Endolf 69d6b1b8a6 Add the tools. 2018-05-23 01:16:53 +01:00
Endolf cc2c663916 Add the tools. 2018-05-23 01:02:13 +01:00
Endolf 4c7eff906e Add the tools. 2018-05-23 01:00:46 +01:00
Endolf 62451c9cb7 Trigger builds once a branch is discovered. 2018-05-23 00:58:17 +01:00
Endolf 49946e27e0 WIP jenkinsfile. 2018-05-23 00:50:27 +01:00
Endolf c6a6d2e8f8 WIP jenkinsfile. 2018-05-23 00:39:22 +01:00
Endolf 2acfe0edaa Start of GPG signing 2018-05-23 00:32:46 +01:00
Endolf 8a213d061c Update missing SCM data. 2018-05-22 23:37:20 +01:00
Endolf a5112ed015
Merge pull request #30 from jinput/issue5
Issue5
2018-05-22 22:46:31 +01:00
Endolf f4876067c1 Merge remote-tracking branch 'origin/master' into issue5 2018-05-22 22:43:00 +01:00
Endolf 4b66611142
Merge pull request #29 from jinput/maven
Maven
2018-05-22 22:38:45 +01:00
Endolf 0e321e77a2 Handle wintab not being available 2018-05-21 21:51:53 +01:00
Endolf 4a7f075d23 Fix typo in profile id 2018-05-20 22:56:51 +01:00
Endolf 92391498cf Activate the wintab profile if we are on windows and the SDK path is set. 2018-05-20 22:55:42 +01:00
Endolf 4cb3cc08fc Activate the wintab profile if we are on windows and the SDK path is set. 2018-05-20 22:49:27 +01:00
Endolf ee9aa09577 Wintab links 2018-05-20 22:01:48 +01:00
Endolf 76669f6b51 Wintab compiles, not linking yet though. 2018-05-20 13:13:50 +01:00
Endolf 9a6fd1cf66 Steps towards wintab build 2018-05-19 21:02:10 +01:00
Endolf c875ade848 Steps towards wintab build 2018-05-18 18:13:26 +01:00
Endolf 40f2e7fd25 Steps towards wintab build 2018-05-18 18:12:17 +01:00
Endolf 809334336c Example using maven 2018-05-17 18:41:04 +01:00
Endolf c82ba65e2b Compile under OSX 2018-05-16 23:54:53 +01:00
Endolf 96eea217e3 Fix the os family name 2018-05-16 22:18:25 +01:00
Endolf ba840b81f4 Wintab changes 2018-05-12 19:24:07 +01:00
Endolf b08843d82b Remove old ant files. 2018-05-12 19:08:54 +01:00
Endolf 64ec6fe8e4 Guard against null pointer 2018-05-12 18:59:54 +01:00
Endolf c8996c0581 Add the osx profile 2018-05-12 11:21:58 +01:00
Endolf 4e98105deb First stab at OSX maven build. 2018-05-12 11:17:38 +01:00
Endolf e0a512be48 Fix version file for generation from Maven. 2018-05-10 00:48:33 +01:00
Endolf 5a80ec7321 Use maven details for version information. 2018-05-10 00:07:24 +01:00
Endolf 557be525a2 Linking working. 2018-05-09 23:49:45 +01:00
Endolf f2b022b197 Compiling working. 2018-05-09 23:21:21 +01:00
Endolf 22b9ee15a4 Fix jni.h file location. 2018-05-09 21:58:39 +01:00
Endolf 3b886a200e Use normal paths, as they work. 2018-05-09 21:46:25 +01:00
Endolf 3faf26532e Remove the clean target and some commented out code. 2018-05-09 21:45:38 +01:00
Endolf 1eea3061f1 Fix path 2018-05-09 20:48:00 +01:00
Endolf 682ebbaf69 Refactor the sources 2018-05-09 20:38:48 +01:00
Endolf c71f96a708 Use javac with the -h arg instead of javah that's now deprecated. 2018-05-09 20:31:37 +01:00
Endolf 252ca8876f Use javac with the -h arg instead of javah that's now deprecated. 2018-05-09 20:16:04 +01:00
Endolf 2b7d10e435 Add profiles for OS builds 2018-05-09 18:56:25 +01:00
Endolf 289a6db298 First commit for windows 2018-05-09 18:55:55 +01:00
Endolf 4517180482 Linux native jar file building. 2018-05-02 11:54:06 +01:00
Endolf b2fd759065 Linux building under maven 2018-04-30 21:31:56 +01:00
Endolf 294629a312 Merge pull request #20 from leif81/patch-1
Add basic README with maven and javadoc badges
2017-06-07 20:29:31 +01:00
Leif Gruenwoldt 2c9654b300 Add basic README with maven and javadoc badges
The badges are handy way to discover the latest artifacts.
2017-06-07 15:20:31 -04:00
Endolf e730077f78 Merge pull request #13 from Razielwar/razielwar/button32
manage button 32
2017-06-06 18:34:00 +01:00
Endolf 822e0b4827 Delete README.txt 2017-05-09 12:37:40 +01:00
Endolf 2f7d29dd39 Delete CHANGES 2017-05-09 12:37:26 +01:00
Endolf e866ea5dc9 Prepare for next version 2017-05-08 22:35:29 +01:00
Endolf c1014ab8a6 Update repo information 2017-05-08 19:41:19 +01:00
Endolf 57586046d8 Add IntelliJ ignores 2017-05-08 19:25:38 +01:00
Razielwar e7ed731ceb manage button 32
manage button 32 (identifier 31) and remove discrepancy between windows identifier and jinput identifier (+1 from identifier 21)
2016-10-16 22:11:37 +02:00
Endolf b813d5594e Merge pull request #9 from jamesjer/master
Remove references to nonexistent EVIOCGUSAGE
2016-05-19 20:00:28 +01:00
Jerry James bbf4c985f0 Remove references to nonexistent EVIOCGUSAGE 2016-05-19 11:37:39 -06:00
Endolf 61edc6b2cd Merge pull request #4 from IceReaper/patch-1
Added Windows 10 to avoid warning.
2015-09-16 08:55:00 +01:00
IceReaper 643e6380ed Added Windows 10 to avoid warning. 2015-09-16 09:52:15 +02:00
Endolf 0943752c25 Fix for windows 8 and 8.1 version not found messages. 2015-06-13 21:50:39 +01:00
Endolf 3c24e13a83 More ignores 2014-07-14 13:36:25 +01:00
Endolf 335552cf71 Make jutils usable from snapshot jars. 2014-07-14 13:35:42 +01:00
Endolf 2837517753 Git ignores 2014-07-14 13:31:09 +01:00
endolf 350d8fec21 Changes for maven 2.0.6 release. 2014-05-26 22:08:04 +00:00
endolf 790b666865 Create the javadoc as part of a dist build 2013-03-25 18:01:56 +00:00
endolf a5c79be8d0 Fix return code for unknown controller buttons on linux controllers. Patch supplied by tctimmeh on JGO.
http://www.java-gaming.org/topics/updating-linux-stick-button-mappings/28838/view.html
2013-03-09 12:30:57 +00:00
endolf 29d8717a75 Add new buttons for linux and the missing start button. Patch supplied by tctimmeh on JGO.
http://www.java-gaming.org/topics/updating-linux-stick-button-mappings/28838/view.html
2013-03-09 12:27:43 +00:00
endolf 229d2c9dda Another update for newer kernels 2013-02-25 19:10:27 +00:00
endolf 9452bb5f80 Updated for version 3 kernels 2013-02-25 19:02:49 +00:00
endolf eee0db5b4f Update for os.arch values seen in the wild 2011-08-01 17:50:59 +00:00
endolf 900a46506a Put the JInput version out on the tests 2011-03-25 23:09:25 +00:00
endolf 87e7d8df2f Reduce the logging during normal running. 2011-03-23 18:54:48 +00:00
endolf 9646122032 Updated api version number after fixing maven release version class. 2011-03-23 18:33:26 +00:00
endolf c07fe191ea Put the correct api version information into the Version class. 2011-03-23 18:11:22 +00:00
endolf 62ed7dc473 Fix maven deploy. 2011-03-22 22:20:33 +00:00
endolf 3c352dc3cc Sepearate the natives out. 2011-03-22 21:35:43 +00:00
endolf 84be9b9b36 Updated maven build, eventually for working from maven central 2011-03-22 19:26:54 +00:00
endolf b1384277ad Update to 2.0.2 in maven 2011-02-20 14:34:23 +00:00
endolf 73fe22bc94 Make sure the files are returned in alpha order, so the order is consitent between runs. 2011-02-20 14:11:41 +00:00
endolf b7302c451f Updated javadoc 2011-02-05 17:38:53 +00:00
endolf 45e8a00390 Updated for windows os arch change. 2011-02-05 14:33:04 +00:00
endolf 823c47bc2b Add targets to ant that make it possible to place JInput in a maven repository. 2010-04-16 17:18:37 +00:00
endolf 0ad4010e80 Directx SDK has changed the location of the x86 libs.
Clean out the exp and libs that are created during a build when clean target is run.
2010-03-20 10:51:45 +00:00
endolf 40af67538f Updated link to latest distribution 2010-01-26 08:40:03 +00:00
endolf 2789d50724 Fix init and clean targets 2009-12-12 13:37:17 +00:00
endolf 32829e5df6 Add version information that hudson will update. 2009-12-12 13:29:01 +00:00
endolf 530a7eaf94 Fix incorrect log method call 2009-10-31 11:13:06 +00:00
endolf 967fde8a93 Use java logging instead of system out in core and plugins. 2009-10-31 11:06:12 +00:00
endolf 86fb3d5499 Recognise windows 7 2009-10-03 20:20:27 +00:00
endolf d4a1fd4ae6 Apply patch from bjunglas for issue 42 to allow 3D Connexions space navigator to be detected on osx 2009-07-15 16:19:15 +00:00
endolf bfce766c46 Make the plugins use the right dll name (oops) 2009-04-01 16:47:21 +00:00
endolf 3cc17edd10 Add the windows 64 bit natives 2009-03-31 21:53:47 +00:00
endolf 2644b47f44 Only build wintab stuff on windows 32 bit, which is the only environment wintab supports. 2009-03-31 21:29:28 +00:00
endolf d60c807a24 The environment under windows decides if it's a 64 bit build or not. On 64 bit windows assume a 64 bit one. 2009-03-31 20:16:53 +00:00
endolf c95cf4bddd Check the arch type before loading the native library 2009-03-28 16:36:03 +00:00
endolf b789b8cd52 Check the arch type before loading the .so 2009-03-28 16:25:28 +00:00
endolf 571769019e Check the arch type before loading the .so 2009-03-28 16:22:05 +00:00
endolf 8a606b3e3f Add linux 64 bit to the natives jar 2009-03-28 16:03:13 +00:00
endolf c5ff2100e2 Build for all 3 architectures 2009-03-26 12:36:38 +00:00
endolf ca1963aadc *** empty log message *** 2009-03-22 21:27:59 +00:00
endolf db9ebeccef *** empty log message *** 2009-03-22 21:16:20 +00:00
endolf 2ed5250bf4 All environment paths passed in. 2009-03-18 01:23:13 +00:00
endolf 8ed1ae2586 *** empty log message *** 2008-11-15 00:28:39 +00:00
endolf 971b9e3e39 *** empty log message *** 2008-11-14 22:31:08 +00:00
endolf eaa55d4860 *** empty log message *** 2008-11-14 22:09:05 +00:00
elias f2a679ae06 Made DirectAndRawInput the default windows plugin. Teach jinput about vista. 2007-11-27 09:14:51 +00:00
endolf 7d527dda1c When running the webstart rumble test, it doesn't seem to want to quit, it should now. 2007-11-13 20:37:47 +00:00
endolf b210efd1d0 Updated javadoc 2007-10-27 09:11:51 +00:00
endolf 3694ba5514 Rather than crashing, just disable the plugin if we an't load the dll 2007-09-23 02:09:55 +00:00
endolf 0015c724b3 Rather than crashing, just disable the plugin if we an't load the dll 2007-09-23 02:01:26 +00:00
endolf 69a2984615 Rather than crashing, just disable the plugin if we an't load the dll 2007-09-22 19:35:06 +00:00
endolf 13e1269023 Fix a potential Array index out of bounds exception. 2007-08-12 22:38:49 +00:00
endolf a2f62499b9 Make joysticks fire events 2007-08-12 22:10:37 +00:00
endolf c6a4aeaf1e Complete - task 36: Linux plugin not reporting normalised values
https://jinput.dev.java.net/issues/show_bug.cgi?id=36
2007-08-12 21:59:25 +00:00
endolf ea90a2d3b4 Make the joystick plugin on linux respect POV Hats 2007-08-12 20:09:14 +00:00
endolf ae8b23e4ba Remove stray debug 2007-08-12 16:02:23 +00:00
endolf 8699a0c8b1 Issue number: 35
Read the axis and button maps from the joystick nodes.
2007-08-12 15:47:51 +00:00
endolf 940c48b558 Bit of a tidy up 2007-08-02 20:30:42 +00:00
endolf aa96d5c1be Tidy up 2007-08-02 20:13:51 +00:00
endolf d418a10639 Changed the default plugin for XP to be the combined raw and direct input plugins. 2007-08-02 20:11:20 +00:00
endolf 0018c62842 Created a plugin that combines the multiple keyboard/mouse support of the raw plugin, with the game controller support of direct input. 2007-08-02 20:10:35 +00:00
endolf 75f65de075 Update the location of the dist folder. 2007-07-31 17:23:42 +00:00
endolf 9f2bd073fe Updated javadoc 2007-06-28 21:35:13 +00:00
endolf 92c7186445 Revert last change, might be a rumbling only device, or a device with only subdevices. 2007-06-28 20:41:47 +00:00
endolf db12311aa5 Don't create devices that are of an unknown type, with no components 2007-06-28 20:38:53 +00:00
endolf fd2a1b073d Make the API docs and the code match for the Mouse.get<button> methods. Add the methods that we actually wanted to be there. 2007-06-28 20:37:24 +00:00
endolf 10214031df Raw input has mouse buttons 4 and 5 as button 3 and 4 not side and extra. 2007-06-20 21:04:46 +00:00
endolf 083eee58ee Implement the isSupported method and make plugins work again. There was an issue where accessing the static methods in DefaultControllerEnvironment and ControllerEnvironment would cause ploblems when the plugins were loaded using the PluginLoader class loader. 2007-06-10 15:03:27 +00:00
endolf d6368e8dc5 Don't put the examples in the main jar 2007-06-10 11:31:30 +00:00
endolf 4c295d9219 Added commented examples 2007-06-10 10:51:31 +00:00
endolf 795f0d1a3f Issue number:
Obtained from:
Submitted by:
Reviewed by:
2007-06-06 19:34:19 +00:00
endolf bd39ae8aef Another formatting shuffle 2007-04-19 18:59:10 +00:00
endolf 6cbebb1061 Added a not to contact us in the forums if you want to get involved 2007-04-19 18:57:03 +00:00
endolf 4a55c75a5e Needed a starting break 2007-04-19 18:34:26 +00:00
endolf ffbec4163d Tried to update the main page a bit, including removing that horrid banner and reflecting the new win32 plugin information 2007-04-19 18:32:54 +00:00
elias 1bfb2dc3c0 Made polling of absolute Components lazy to avoid performance problems with keyboards on mac os x 2007-04-19 11:59:23 +00:00
elias 7716494aee Linux: Added more paths to the jni header search path 2007-04-19 11:40:03 +00:00
elias d71de8a642 Mac OS X: Don't fail the entire device enumeration when one device fails to open 2007-02-25 20:40:02 +00:00
elias 7bf9a5d428 Linux: Bounds check fixes (again) 2006-12-26 09:18:46 +00:00
elias 02196352eb Linux ~: More bounds checks 2006-12-25 09:31:34 +00:00
elias 9d211951c1 Linux: Fix an IndexOutOfBoundsException for unknown controller types 2006-12-23 07:51:58 +00:00
elias 43b4dab801 Mac OS X: Added support for mouse scroll wheel 2006-11-12 18:36:17 +00:00
endolf 58a0518a42 Issue number: 33
Obtained from: vacaro
Submitted by:  vacaro
Reviewed by:  endolf
2006-11-08 13:25:39 +00:00
endolf f107ea2558 Make the default state connected to the cursor 2006-10-31 20:46:46 +00:00
endolf 2a7557fcfb jnlp files for webstart 2006-10-29 20:27:39 +00:00
endolf 8af1163d0c Updates for webstart scripts 2006-10-29 20:10:15 +00:00
endolf e2d5fc8e24 Updates to build system for wintab plugin 2006-10-29 17:47:35 +00:00
endolf 1ef6081c1f First commit of the wintab plugin 2006-10-29 15:57:42 +00:00
elias f201cc526b Linux: Changed uname -i to uname -m to improve 64 bit detection in build scripts 2006-09-08 10:06:51 +00:00
elias 9cc64dd560 DirectInput: Only choose DIDF_RELAXIS id the device has at least one axis, and all axes are relative 2006-08-23 08:04:50 +00:00
elias b251b846f2 DirectInput: Don't fail entire enumeration because of one device failure 2006-08-23 07:53:04 +00:00
elias e48f275cfc DirectInput: Fix an issue with mice devices and DIDF_ABSAXIS axis mode. Now DIDF_RELAXIS is chosen if all device axes are relative. 2006-08-22 21:20:35 +00:00
elias 924d55e7d3 DirectInput: Use Controller.Type.UNKNOWN for the catch-all device type 2006-08-22 09:22:51 +00:00
elias b1892fe307 Linux: Ignore rumblers when device is read only 2006-08-11 08:44:12 +00:00
elias 3d2ce651e8 DirectInput: Ignore unmapped components 2006-08-10 08:05:14 +00:00
elias 027fa2a7a0 Check for NULL malloc result 2006-08-09 08:38:58 +00:00
elias c31a7d8818 Windows: More MinGW compile fixes 2006-07-20 10:45:00 +00:00
elias 13a7aaef3c Windows: Fix more mingw compile warnings 2006-07-17 11:32:38 +00:00
elias 0a481c9adb Windows: More mingw fixes 2006-07-17 11:29:02 +00:00
elias 0fb2152bde Windows: MinGW path fixes 2006-07-15 23:09:40 +00:00
elias e5b009c563 Windows: Added build.xml.mingw for building with mingw compiler. Doesn't work yet since the RawInput API is not supported through mingw yet. 2006-07-15 22:39:32 +00:00
elias f0737680fa Made the core classes and the linux plugin applet compatible. Removed dead code in DefaultControllerEnvironment 2006-07-14 08:31:27 +00:00
elias c9b1dd2ba1 Windows: Handle polled devices in setDataFormat 2006-07-13 18:37:27 +00:00
elias c97630f17d Linux: build fixes for 64 bit 2006-07-11 21:07:38 +00:00
elias 06ecaad638 Changed a System.out.println to use logging 2006-07-11 21:04:54 +00:00
elias 6eb27144d9 Linux: Implemented support for libjinput-linux64.so 64 bit library 2006-07-11 21:02:46 +00:00
elias 8f13bb8862 Windows: Use pre-defined environment variables for the native include and lib paths 2006-07-10 22:20:03 +00:00
elias e1e1d4f564 Windows Raw Plugin: Make sure DefWindowProc is called to clean up resources. Use MSG.time field instead of GetMessageTime. 2006-07-05 08:51:36 +00:00
elias 4931654f9c Windows: Fix RawMouse event bug where all mouse clicks would end up being reported on the left (primary) mouse button 2006-07-04 21:25:51 +00:00
elias 4306f119c2 added DefaultControllerEnvironment.loadLibrary convenience method for plugins. It will also respect the new net.java.games.input.librarypath property for locating natives (useful for applets). Removed the mac os x jinput-osx-legacy library loading, as it is not necessary anymore with the combined 10.3/10.4 library 2006-07-03 11:59:10 +00:00
elias d5ea04d3af Added seal to security sensitive jars 2006-07-03 11:48:11 +00:00
elias 603d4c6ce6 Added ControllerEventTest for testing event queueing 2006-06-23 10:48:04 +00:00
elias 55335e976d Windows: Fixed warning about unsafe _vsnprintf 2006-06-22 14:08:08 +00:00
endolf 99e28a3d9d Add an axis identifier for unknown axis types and get directx to use it
if it doesn't recognise an axis on construction.
2006-05-25 12:40:27 +00:00
endolf 1dc8f9ea11 Merge revision 12 of oddlabs svn repo.
Mac OS X: build.xml fix
Windows: Fixed crash when Raw plugin fails to load
Mac OS X: Tweak native libraries so only one library, libjinput-osx.jnilib contains both gcc 3 ppc code and gcc 4 i386 code. That way, we'll cover all releases and architectures with one native library instead of two
2006-05-14 09:14:52 +00:00
endolf 559c008a02 Make version 2 the main jinput version 2006-04-29 22:29:27 +00:00
endolf 4c91a4eb44 Trying to sort out some of the crashes and failed exits 2006-01-12 22:16:10 +00:00
endolf 552fdad56d Fixed a sigsegv, once we've found a match for an event device and
joystick, don't look at that stick again, especially having nulled the
pointer.
2005-12-04 22:14:35 +00:00
endolf c47f72208e First bodge at pursuading windows to use some of the same button ID's as linux. I dunno which is right, I suspect that both are as there is no standard that both admit to. So for now, lets do that good old nasty hack of string searching. 2005-12-04 16:39:13 +00:00
endolf fb1b49b5a9 Updated button ID's. Trouble is, windows and linux id the buttons differently. 2005-12-02 22:43:14 +00:00
endolf 819e59f33c Don't poll if we are shutting down 2005-11-11 20:05:06 +00:00
endolf db744e1d41 Let me just say ....
Ooops

was forgetting to increment a counter
2005-11-11 19:22:55 +00:00
endolf dc39383a67 Handle cases where there are no event devices, only js ones. 2005-11-07 07:46:34 +00:00
endolf 9a920ade6d Fixes for js devices that are read only 2005-11-03 22:00:11 +00:00
endolf f95cb1ce41 3 Changes
When there are no device files found, jinput won't try to read the 0th
one.

When no js* devices are found in /dev/input it will look in /dev

Try to free some of the memory created in the init process
2005-10-30 21:56:14 +00:00
endolf 3b9688b972 Fixed my debug 2005-09-01 20:37:01 +00:00
endolf 67bcd5f43e Trying to handle more than 2 force feedback axis. Untested. 2005-09-01 20:34:01 +00:00
endolf 2ae95adfcc Added debug for an array out of bounds error that is being seen 2005-09-01 20:02:57 +00:00
endolf 95cf7ab8e7 It helps if you add the files the new changes depend on.
Ooops

(force feedback changes I committed yesterday that is)
2005-08-31 06:43:02 +00:00
endolf b6f7e35321 It appears as though linux can't cope with scaling the effect, it's on
or off. So i'm having to play with the strong/weak rumble settings.
2005-08-30 19:54:25 +00:00
endolf daba6d24cc Unless cleanup is called from the same thread as init, the cleanup
doesn't happen properly and events are left of the ff device meaning we
run out of device space. Added a thread that init and cleanup are called
from via methods on the interface.

Then it became apparent that rumble would only work from the same thread
as the others too, so thats added in there.

Nastyness all round.
2005-08-30 19:37:53 +00:00
endolf ab247c91ad Updated build file to build 1.4 byte code 2005-08-28 21:23:54 +00:00
endolf ae942dd3cc Updated build scripts to build java 1.4 byte code 2005-08-28 20:52:26 +00:00
endolf c15d74238d More rumbler debug 2005-08-28 09:23:00 +00:00
endolf def8e4976b Extra debug for rumblers 2005-08-27 09:22:16 +00:00
endolf be7b59d328 Re added the fade test 2005-08-27 09:21:48 +00:00
endolf f48ee8f6f4 Start of some work to print more debug if force feedback effect creation fails 2005-08-27 08:22:19 +00:00
endolf cebedc9479 Added shutdown hooks to stop rumblers before quitting. 2005-08-27 08:21:42 +00:00
jeffpk 98ab1d6fe4 Added handlign for unknown windows versions 2005-08-23 20:59:32 +00:00
endolf 04e3538e83 Added cleanup stuff for rumblers, it doesn't fix the code, but is nice 2005-07-16 15:09:04 +00:00
endolf d4c72ba15c Couple if inux rumbler differences, including including the added file 2005-07-16 13:07:45 +00:00
endolf df432c29ae Linux rumbler support
IT DOES NOT WORK YET though.

I'm in contact with the kernel module developers as I think it's a kernel bug
2005-07-03 20:05:34 +00:00
endolf 38d108b857 Changed the binary library name 2005-06-19 17:41:40 +00:00
endolf d222fad271 Updated the name of the linux native library 2005-06-19 15:33:12 +00:00
endolf c2bbf1d876 Extra debug info 2005-06-19 15:32:44 +00:00
endolf decd93d226 If the default plugin is not in the classpath, an exception gets thrown.
This should only happen if it's also not in the plugins directory.
2005-06-16 16:32:59 +00:00
endolf 9f9ac8834c Opps 2005-06-16 13:43:04 +00:00
endolf 8fb52e9ea4 Added the simple_dist task and subtasks to build the single
distributable zip/tgz for each platform that includes the core classes,
the default plugins classes, the jutils classes, and the binary library
for that platform.
2005-06-16 13:38:16 +00:00
endolf 4a07a72323 Unless otherwise specified (using the property), the plugin loader will
now automatically try and load the plugin specific to that platform. The
plugins path will be scanned first, and if found, the plugin will not be
reloaded.
2005-06-15 12:26:14 +00:00
endolf e6c082f399 The changes of Axis.Identifier to Component.Identifier was obviously not checked under windows. My fault. Fixed (I hope) 2005-06-15 09:20:16 +00:00
endolf 9dd954a4f4 Guess who found the device that pops the buffer size?, was getting an array out of bounds. 2005-06-15 09:09:09 +00:00
endolf b5bea30cc2 For some reason, my ubunto boxes with jdk 1.5.0_02 all seem to have
java.home set to the jre dir, even though a 'which java' reveals it's
using the jdk one, not the jre one. This causes the include dir not to
be found and causes the build to fail. Made it so that the build file
looks for includes relative to the jre dir and the jdk dir, so all
systems should work (yeah, right)
2005-06-14 11:19:55 +00:00
cjcdoomed 0d155c818c Issue number: Implemented OSXJoystick functionality
Submitted by:  Chris Cooper cjcdoomed@gmail.com
2005-05-20 14:25:24 +00:00
endolf ab7bba58d6 Will try to open the device for read/write first, if that fails, trys
read only and displays a message about not being enabled for force
feedback
2005-05-08 09:58:31 +00:00
cjcdoomed eac5380da4 Issue: OS X Nightly build not compiling
Obtained from:
Submitted by:  Chris Cooper
Reviewed by:
2005-05-06 05:00:46 +00:00
endolf fc587842d0 Handle missing absolute axis ID's 2005-05-05 08:07:51 +00:00
endolf e48688ce73 Regenerated from 2.6.10 headers 2005-05-04 18:16:23 +00:00
endolf fa0b606105 Event devices now opened read only 2005-05-04 18:15:08 +00:00
jeffpk 4be7c6e38b Updated EventDevice.cpp to handle EV_SYN properly 2005-05-01 23:25:38 +00:00
jeffpk 3a67a298a8 Updated linux plugin to build under Linux 2.6.5-7.151
Note, these are hacky fixes that may break it under earlier versions of Linux. Sorry.
2005-04-28 05:19:22 +00:00
endolf fa132b2126 Changes for Axis.Identifier changes. This includes renaming Axis to Component, and creating the Identifier objects for Key Axis and Button. 2004-08-29 21:23:06 +00:00
endolf e312d8dd34 Initial checkin 2004-08-29 20:17:39 +00:00
endolf 9741fccdfa Updates so that for now keyboards are just created as normal devices, this means the Axis.Identifiers are not the standard ones, but the correct things are now show and no excpetions are seen on the Logitech Elite keyboard (or any that has axis as well) 2004-07-07 23:16:03 +00:00
endolf 5fb795d2fd If a joystick hat isn't configured properly, or if it's digital, then the axis data is not -32676, 0 or 32767 it is -1, 0 or 1. Updated the hat object to reflect this. 2004-07-07 23:09:41 +00:00
endolf bbb5c4e0af Issue number: 18 2004-06-21 21:48:44 +00:00
endolf cd663ae444 Possible fix for sigfault on linux, need to test more 2004-06-21 21:44:16 +00:00
188 changed files with 20997 additions and 4714 deletions

13
.gitignore vendored Normal file
View file

@ -0,0 +1,13 @@
.classpath
.project
.settings/
build/
target/
apidocs/
bin/
classes/
dist/
eclipse_bin/
*.iml
.idea/
dependency-reduced-pom.xml

144
Jenkinsfile vendored Normal file
View file

@ -0,0 +1,144 @@
pipeline {
agent none
triggers { pollSCM('H/15 * * * *') }
tools {
maven 'Maven 3.5.3'
jdk 'OpenJDK 9'
}
options { buildDiscarder(logRotator(numToKeepStr: '5')) }
parameters {
booleanParam(defaultValue: false, description: 'Perform Release', name: 'release')
}
stages {
stage('Build core') {
agent {
label "osx"
}
steps {
sh 'mvn -B -Dmaven.antrun.skip -Dmaven.source.skip -Dmaven.test.skip -DskipTests -DskipITs -pl coreAPI/ package'
}
post {
success {
archiveArtifacts artifacts: 'coreAPI/target/apidocs/**/*', fingerprint: true
}
}
}
stage('Build natives') {
parallel {
stage('Build Windows natives') {
agent {
label "windows"
}
steps {
bat 'mvn -B -am -pl plugins/windows/,plugins/wintab/ clean compile'
}
post {
success {
stash includes: 'plugins/**/target/natives/*.dll', name: 'windows-natives'
}
}
}
stage('Build Linux natives') {
agent {
label "linux"
}
steps {
sh 'mvn -B -am -pl plugins/linux/ clean compile'
}
post {
success {
stash includes: 'plugins/**/target/natives/*.so*', name: 'linux-natives'
}
}
}
stage('Build OSX natives') {
agent {
label "osx"
}
steps {
sh 'mvn -B -am -pl plugins/OSX/ clean compile'
}
post {
success {
stash includes: '**/target/natives/*.jnilib', name: 'osx-natives'
}
}
}
}
}
stage('Build') {
agent {
label "linux"
}
steps {
unstash 'windows-natives'
unstash 'osx-natives'
unstash 'linux-natives'
sh 'mvn -B -P windows,linux,osx,wintab -Dmaven.antrun.skip -Dmaven.javadoc.skip -Dmaven.source.skip -Dmaven.test.skip -DskipTests -DskipITs package'
}
post {
success {
stash includes: '**/target/*.jar', name: 'all-java-jars'
archiveArtifacts artifacts: '**/target/*.jar*', fingerprint: true
}
}
}
stage('Deploy') {
agent {
label "linux"
}
when { branch 'master' }
steps {
milestone(1)
unstash 'windows-natives'
unstash 'osx-natives'
unstash 'linux-natives'
sh 'echo $GPG_SECRET_KEYS | base64 --decode | gpg --batch --import'
sh 'echo $GPG_OWNERTRUST | base64 --decode | gpg --import-ownertrust'
withMaven(
maven: 'Maven 3.5.3',
jdk: 'OpenJDK 9',
globalMavenSettingsConfig: 'global-maven-settings-ossrh',
mavenOpts: '-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts' //Work around for JDK9 missing cacerts
) {
sh "mvn -P windows,linux,osx,wintab -Dmaven.antrun.skip -Dmaven.test.skip -DskipTests -DskipITs deploy"
}
}
}
stage('Release') {
agent {
label "linux"
}
when {
expression {
return params.release
}
}
steps {
milestone(3)
unstash 'windows-natives'
unstash 'osx-natives'
unstash 'linux-natives'
sh 'echo $GPG_SECRET_KEYS | base64 --decode | gpg --batch --import'
sh 'echo $GPG_OWNERTRUST | base64 --decode | gpg --import-ownertrust'
withMaven(
maven: 'Maven 3.5.3',
jdk: 'OpenJDK 9',
globalMavenSettingsConfig: 'global-maven-settings-ossrh',
mavenOpts: '-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts' //Work around for JDK9 missing cacerts
) {
sh "mvn -P windows,linux,osx,wintab versions:set -DremoveSnapshot"
script {
VERSION_TAG = sh(script: "mvn -Dexpression=project.version help:evaluate | grep -e '^[[:digit:]]'", returnStdout: true).trim()
}
sh "git tag -a ${VERSION_TAG} -m 'Release tag ${VERSION_TAG}'"
sh "mvn -P windows,linux,osx,wintab,release -Dmaven.antrun.skip -Dmaven.test.skip -DskipTests -DskipITs deploy"
sh "mvn -P windows,linux,osx,wintab versions:revert"
sh "mvn -P windows,linux,osx,wintab versions:set -DnextSnapshot"
sh "git commit -m 'Next development release' ."
sh "git push origin HEAD:master --follow-tags"
}
}
}
}
}

9
README.md Normal file
View file

@ -0,0 +1,9 @@
# JInput
[![Maven Central](https://img.shields.io/maven-central/v/net.java.jinput/coreapi.svg)](https://maven-badges.herokuapp.com/maven-central/net.java.jinput/coreapi)
[![Javadocs](http://www.javadoc.io/badge/net.java.jinput/coreapi.svg)](http://www.javadoc.io/doc/net.java.jinput/coreapi)
Library for access to input devices.
## License
Licensed under [BSD License](https://opensource.org/licenses/BSD-3-Clause), copyright is attributed in each source file committed.

18
applet/jinput-event.html Normal file
View file

@ -0,0 +1,18 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="content-language" content="en">
<title>JInput Applet Test</title>
<script src="http://java.com/js/deployJava.js"></script>
</head>
<body>
<script>
deployJava.setInstallerType('kernel');
// include any required packages as shown below
deployJava.setAdditionalPackages('javax.swing, javax.xml');
deployJava.runApplet({codebase:".",
archive:"jinput.jar,jinput-test.jar,jinput-applet-test.jar", code:"net.java.games.input.applet.test.ControllerEventTestApplet",
width:"320", Height:"400"}, null, "1.4.2");
</script>
</body>
</html>

18
applet/jinput.html Normal file
View file

@ -0,0 +1,18 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="content-language" content="en">
<title>JInput Applet Test</title>
<script src="http://java.com/js/deployJava.js"></script>
</head>
<body>
<script>
deployJava.setInstallerType('kernel');
// include any required packages as shown below
deployJava.setAdditionalPackages('javax.swing, javax.xml');
deployJava.runApplet({codebase:".",
archive:"jinput.jar,jinput-test.jar,jinput-applet-test.jar", code:"net.java.games.input.applet.test.ControllerReadTestApplet",
width:"320", Height:"400"}, null, "1.4.2");
</script>
</body>
</html>

27
applet/pom.xml Normal file
View file

@ -0,0 +1,27 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<artifactId>applet</artifactId>
<packaging>jar</packaging>
<name>JInput - applet</name>
<parent>
<groupId>net.java.jinput</groupId>
<artifactId>jinput-parent</artifactId>
<version>2.0.10-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View file

@ -0,0 +1,213 @@
/**
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input.applet;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.logging.Logger;
public class JInputAppletResourceLoader {
private static final Logger diagnosticLog = Logger.getLogger(JInputAppletResourceLoader.class.getName());
private int percentageDone = 0;
private String getPrivilegedProperty(final String property) {
return AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty(property));
}
private String setPrivilegedProperty(final String property, final String value) {
return AccessController.doPrivileged((PrivilegedAction<String>) () -> System.setProperty(property, value));
}
public void loadResources(URL codeBase) throws IOException {
downloadNativesJar(codeBase);
extractNativesJar(codeBase);
setJInputClasspath(codeBase);
}
public int getPercentageDone() {
return percentageDone;
}
private void setJInputClasspath(URL codeBase) {
setPrivilegedProperty("net.java.games.input.librarypath", getTempDir(codeBase) + File.separator + "natives" + File.separator);
}
private void extractNativesJar(URL codeBase) throws IOException {
File tempDir = new File(getTempDir(codeBase));
String osName = getPrivilegedProperty("os.name");
String nativeJar = null;
if (osName.startsWith("Win")) {
nativeJar = "jinput-windows-native.jar";
} else if (osName.startsWith("Linux") || osName.startsWith("FreeBSD")) {
nativeJar = "jinput-linux-native.jar";
} else if (osName.startsWith("Mac")) {
nativeJar = "jinput-osx-native.jar";
} else {
}
JarFile localJarFile = new JarFile(new File(tempDir, nativeJar), true);
Enumeration<JarEntry> jarEntries = localJarFile.entries();
int totalUncompressedBytes = 0;
int totalUncompressedBytesWritten = 0;
List<JarEntry> entriesToUse = new ArrayList<>();
while(jarEntries.hasMoreElements()) {
JarEntry jarEntry = jarEntries.nextElement();
String entryName = jarEntry.getName();
if(!entryName.startsWith("META-INF")) {
totalUncompressedBytes+=jarEntry.getSize();
entriesToUse.add(jarEntry);
diagnosticLog.log(Level.INFO, "Got entry " + entryName + " " + jarEntry.getSize() + " big, total of " + totalUncompressedBytes);
}
}
File tempNativesDir = new File(tempDir, "natives");
if(!tempNativesDir.exists()) {
tempNativesDir.mkdirs();
tempNativesDir.deleteOnExit();
}
for(int i=0;i<entriesToUse.size();i++) {
JarEntry jarEntry = entriesToUse.get(i);
InputStream inStream = localJarFile.getInputStream(localJarFile.getEntry(jarEntry.getName()));
File nativeFile = new File(tempNativesDir, jarEntry.getName());
FileOutputStream fos = new FileOutputStream(nativeFile);
byte[] dataBuffer = new byte[65535];
int bytesRead = 0;
// Read the first block
bytesRead = inStream.read(dataBuffer, 0, dataBuffer.length);
while(bytesRead!=-1) {
fos.write(dataBuffer, 0, bytesRead);
totalUncompressedBytesWritten+=bytesRead;
int unpackingPercentageDone = (int)((((float)totalUncompressedBytesWritten)/totalUncompressedBytes)*100);
percentageDone = 50 + (unpackingPercentageDone/2); //Reading the file is only 1/2 the job
diagnosticLog.log(Level.INFO, "Written " + totalUncompressedBytesWritten + " out of " + totalUncompressedBytes + " " + unpackingPercentageDone + "%, (" + percentageDone + "% total)");
// Read the next block
bytesRead = inStream.read(dataBuffer, 0, dataBuffer.length);
}
long entryModifiedTime = jarEntry.getTime();
nativeFile.setLastModified(entryModifiedTime);
diagnosticLog.log(Level.INFO, "Setting native modified time to " + new Date(entryModifiedTime));
fos.close();
inStream.close();
}
}
private void downloadNativesJar(URL codeBase) throws IOException {
diagnosticLog.log(Level.INFO, "codebase: " + codeBase);
File tempDir = new File(getTempDir(codeBase));
if(!tempDir.exists()) {
tempDir.mkdirs();
tempDir.deleteOnExit();
}
String osName = getPrivilegedProperty("os.name");
String nativeJar = null;
if (osName.startsWith("Win")) {
nativeJar = "jinput-windows-native.jar";
} else if (osName.startsWith("Linux") || osName.startsWith("FreeBSD")) {
nativeJar = "jinput-linux-native.jar";
} else if (osName.startsWith("Mac")) {
nativeJar = "jinput-osx-native.jar";
} else {
}
File localJarFile = new File(tempDir, nativeJar);
localJarFile.deleteOnExit();
diagnosticLog.log(Level.INFO, "Using local file " + localJarFile.getCanonicalPath());
OutputStream outStream = new FileOutputStream(localJarFile);
outStream = new BufferedOutputStream(outStream);
URL remoteJarURL = new URL(codeBase, nativeJar);
diagnosticLog.log(Level.INFO, "Using remote file " + remoteJarURL);
URLConnection connection = remoteJarURL.openConnection();
connection.setUseCaches(false);
connection.setConnectTimeout(2000);
int contentLength = connection.getContentLength();
diagnosticLog.log(Level.INFO, "remote jar is " + contentLength + " bytes");
InputStream inStream = connection.getInputStream();
byte[] dataBuffer = new byte[65535];
int bytesRead = 0;
int totalRead = 0;
int totalWritten = 0;
// Read the first block
bytesRead = inStream.read(dataBuffer, 0, dataBuffer.length);
while(bytesRead!=-1) {
//Update total read
totalRead+=bytesRead;
outStream.write(dataBuffer, 0, bytesRead);
totalWritten+=bytesRead;
int thisFilePercent = (int)((((float)totalRead)/contentLength)*100);
percentageDone = thisFilePercent/2; //Reading the file is only 1/2 the job
diagnosticLog.log(Level.INFO, "Written " + totalRead + " out of " + contentLength + " " + thisFilePercent + "%, (" + percentageDone + "% total)");
// Read the next block
bytesRead = inStream.read(dataBuffer, 0, dataBuffer.length);
}
inStream.close();
outStream.close();
}
private String getTempDir(URL codeBase) {
return getPrivilegedProperty("java.io.tmpdir") + File.separator + codeBase.getHost() + File.separator + "jinput";
}
}

31
coreAPI/pom.xml Normal file
View file

@ -0,0 +1,31 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<artifactId>coreapi</artifactId>
<packaging>jar</packaging>
<name>JInput - core API</name>
<parent>
<groupId>net.java.jinput</groupId>
<artifactId>jinput-parent</artifactId>
<version>2.0.10-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>net.java.jutils</groupId>
<artifactId>jutils</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<!-- <plugin> -->
<!-- <artifactId>maven-javadoc-plugin</artifactId> -->
<!-- </plugin> -->
</plugins>
</build>
</project>

View file

@ -0,0 +1,145 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.io.IOException;
/**
* Skeleton implementation of a named axis.
*/
public abstract class AbstractComponent implements Component {
/**
* Human-readable name for this Axis
*/
private final String name;
private final Identifier id;
private boolean has_polled;
private float value;
private float event_value;
/**
* Protected constructor
* @param name A name for the axis
*/
protected AbstractComponent(String name, Identifier id) {
this.name = name;
this.id = id;
}
/**
* Returns the type or identifier of the axis.
*/
public Identifier getIdentifier() {
return id;
}
/**
* Returns whether or not the axis is analog, or false if it is digital.
* @return false by default, can be overridden
*/
public boolean isAnalog() {
return false;
}
/**
* Returns the suggested dead zone for this axis. Dead zone is the
* amount polled data can vary before considered a significant change
* in value. An application can safely ignore changes less than this
* value in the positive or negative direction.
* @return 0.0f by default, can be overridden
*/
public float getDeadZone() {
return 0.0f;
}
/**
* Returns the data from the last time the control has been polled.
* If this axis is a button, the value returned will be either 0.0f or 1.0f.
* If this axis is normalised, the value returned will be between -1.0f and
* 1.0f.
* @return The data from the last time the control has been polled.
*/
public final float getPollData() {
if (!has_polled && !isRelative()) {
has_polled = true;
try {
setPollData(poll());
} catch (IOException e) {
ControllerEnvironment.log("Failed to poll component: " + e);
}
}
return value;
}
final void resetHasPolled() {
has_polled = false;
}
final void setPollData(float value) {
this.value = value;
}
final float getEventValue() {
return event_value;
}
final void setEventValue(float event_value) {
this.event_value = event_value;
}
/**
* Returns a human-readable name for this axis.
*/
public String getName() {
return name;
}
/**
* Returns a non-localized string description of this axis.
*/
public String toString() {
return name;
}
protected abstract float poll() throws IOException;
} // AbstractAxis

View file

@ -0,0 +1,233 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*/
package net.java.games.input;
import java.util.Map;
import java.util.HashMap;
import java.io.IOException;
/**
* An AbstractController is a skeleton implementation of a controller that
* contains a fixed number of axes, controllers, and rumblers.
*/
public abstract class AbstractController implements Controller {
final static int EVENT_QUEUE_DEPTH = 32;
private final static Event event = new Event();
/**
* Human-readable name for this Controller
*/
private final String name;
/**
* Array of components
*/
private final Component[] components;
/**
* Array of child controllers
*/
private final Controller[] children;
/**
* Array of rumblers
*/
private final Rumbler[] rumblers;
/**
* Map from Component.Identifiers to Components
*/
private final Map<Component.Identifier, Component> id_to_components = new HashMap<>();
private EventQueue event_queue = new EventQueue(EVENT_QUEUE_DEPTH);
/**
* Protected constructor for a controller containing the specified
* axes, child controllers, and rumblers
* @param name name for the controller
* @param components components for the controller
* @param children child controllers for the controller
* @param rumblers rumblers for the controller
*/
protected AbstractController(String name, Component[] components, Controller[] children, Rumbler[] rumblers) {
this.name = name;
this.components = components;
this.children = children;
this.rumblers = rumblers;
// process from last to first to let earlier listed Components get higher priority
for (int i = components.length - 1; i >= 0; i--) {
id_to_components.put(components[i].getIdentifier(), components[i]);
}
}
/**
* Returns the controllers connected to make up this controller, or
* an empty array if this controller contains no child controllers.
* The objects in the array are returned in order of assignment priority
* (primary stick, secondary buttons, etc.).
*/
public final Controller[] getControllers() {
return children;
}
/**
* Returns the components on this controller, in order of assignment priority.
* For example, the button controller on a mouse returns an array containing
* the primary or leftmost mouse button, followed by the secondary or
* rightmost mouse button (if present), followed by the middle mouse button
* (if present).
* The array returned is an empty array if this controller contains no components
* (such as a logical grouping of child controllers).
*/
public final Component[] getComponents() {
return components;
}
/**
* Returns a single component based on its identifier, or null
* if no component with the specified type could be found.
*/
public final Component getComponent(Component.Identifier id) {
return id_to_components.get(id);
}
/**
* Returns the rumblers for sending feedback to this controller, or an
* empty array if there are no rumblers on this controller.
*/
public final Rumbler[] getRumblers() {
return rumblers;
}
/**
* Returns the port type for this Controller.
* @return PortType.UNKNOWN by default, can be overridden
*/
public PortType getPortType() {
return PortType.UNKNOWN;
}
/**
* Returns the zero-based port number for this Controller.
* @return 0 by default, can be overridden
*/
public int getPortNumber() {
return 0;
}
/**
* Returns a human-readable name for this Controller.
*/
public final String getName() {
return name;
}
/**
* Returns a non-localized string description of this controller.
*/
public String toString() {
return name;
}
/** Returns the type of the Controller.
*/
public Type getType() {
return Type.UNKNOWN;
}
/**
* Creates a new EventQueue. Events in old queue are lost.
*/
public final void setEventQueueSize(int size) {
try {
setDeviceEventQueueSize(size);
event_queue = new EventQueue(size);
} catch (IOException e) {
ControllerEnvironment.log("Failed to create new event queue of size " + size + ": " + e);
}
}
/**
* Plugins override this method to adjust their internal event queue size
*/
protected void setDeviceEventQueueSize(int size) throws IOException {
}
public final EventQueue getEventQueue() {
return event_queue;
}
protected abstract boolean getNextDeviceEvent(Event event) throws IOException;
protected void pollDevice() throws IOException {
}
/* poll() is synchronized to protect the static event */
public synchronized boolean poll() {
Component[] components = getComponents();
try {
pollDevice();
for (int i = 0; i < components.length; i++) {
AbstractComponent component = (AbstractComponent)components[i];
if (component.isRelative()) {
component.setPollData(0);
} else {
// Let the component poll itself lazily
component.resetHasPolled();
}
}
while (getNextDeviceEvent(event)) {
AbstractComponent component = (AbstractComponent)event.getComponent();
float value = event.getValue();
if (component.isRelative()) {
if (value == 0)
continue;
component.setPollData(component.getPollData() + value);
} else {
if (value == component.getEventValue())
continue;
component.setEventValue(value);
}
if (!event_queue.isFull())
event_queue.add(event);
}
return true;
} catch (IOException e) {
ControllerEnvironment.log("Failed to poll device: " + e.getMessage());
return false;
}
}
} // class AbstractController

View file

@ -0,0 +1,782 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
/**
* An axis is a single button, slider, or dial, which has a single range. An
* axis can hold information for motion (linear or rotational), velocity,
* force, or acceleration.
*/
public interface Component {
/**
* Returns the identifier of the axis.
*/
public abstract Identifier getIdentifier();
/**
* Returns <code>true</code> if data returned from <code>poll</code>
* is relative to the last call, or <code>false</code> if data
* is absolute.
*/
public abstract boolean isRelative();
/**
* Returns whether or not the axis is analog, or false if it is digital.
*/
public abstract boolean isAnalog();
/**
* Returns the suggested dead zone for this axis. Dead zone is the
* amount polled data can vary before considered a significant change
* in value. An application can safely ignore changes less than this
* value in the positive or negative direction.
* @see #getPollData
*/
public abstract float getDeadZone();
/**
* Returns the data from the last time the control has been polled.
* If this axis is a button, the value returned will be either 0.0f or 1.0f.
* If this axis is normalized, the value returned will be between -1.0f and
* 1.0f.
* @see Controller#poll
*/
public abstract float getPollData();
/**
* Returns a human-readable name for this axis.
*/
public abstract String getName();
/**
* Identifiers for different Axes.
*/
public static class Identifier {
/**
* Name of axis type
*/
private final String name;
/**
* Protected constructor
*/
protected Identifier(String name) {
this.name = name;
}
/**
* Returns a non-localized string description of this axis type.
*/
public String getName() {
return name;
}
/**
* Returns a non-localized string description of this axis type.
*/
public String toString() {
return name;
}
public static class Axis extends Identifier {
/**
* @param name
*/
protected Axis(String name) {
super(name);
}
/**
* An axis for specifying vertical data.
*/
public static final Axis X = new Axis("x");
/**
* An axis for specifying horizontal data.
*/
public static final Axis Y = new Axis("y");
/**
* An axis for specifying third dimensional up/down
* data, or linear data in any direction that is
* neither horizontal nor vertical.
*/
public static final Axis Z = new Axis("z");
/**
* An axis for specifying left-right rotational data.
*/
public static final Axis RX = new Axis("rx");
/**
* An axis for specifying forward-back rotational data.
*/
public static final Axis RY = new Axis("ry");
/**
* An axis for specifying up-down rotational data
* (rudder control).
*/
public static final Axis RZ = new Axis("rz");
/**
* An axis for a slider or mouse wheel.
*/
public static final Axis SLIDER = new Axis("slider");
/**
* An axis for slider or mouse wheel acceleration data.
*/
public static final Axis SLIDER_ACCELERATION = new Axis("slider-acceleration");
/**
* An axis for slider force data.
*/
public static final Axis SLIDER_FORCE = new Axis("slider-force");
/**
* An axis for slider or mouse wheel velocity data.
*/
public static final Axis SLIDER_VELOCITY = new Axis("slider-velocity");
/**
* An axis for specifying vertical acceleration data.
*/
public static final Axis X_ACCELERATION = new Axis("x-acceleration");
/**
* An axis for specifying vertical force data.
*/
public static final Axis X_FORCE = new Axis("x-force");
/**
* An axis for specifying vertical velocity data.
*/
public static final Axis X_VELOCITY = new Axis("x-velocity");
/**
* An axis for specifying horizontal acceleration data.
*/
public static final Axis Y_ACCELERATION = new Axis("y-acceleration");
/**
* An axis for specifying horizontal force data.
*/
public static final Axis Y_FORCE = new Axis("y-force");
/**
* An axis for specifying horizontal velocity data.
*/
public static final Axis Y_VELOCITY = new Axis("y-velocity");
/**
* An axis for specifying third dimensional up/down acceleration data.
*/
public static final Axis Z_ACCELERATION = new Axis("z-acceleration");
/**
* An axis for specifying third dimensional up/down force data.
*/
public static final Axis Z_FORCE = new Axis("z-force");
/**
* An axis for specifying third dimensional up/down velocity data.
*/
public static final Axis Z_VELOCITY = new Axis("z-velocity");
/**
* An axis for specifying left-right angular acceleration data.
*/
public static final Axis RX_ACCELERATION = new Axis("rx-acceleration");
/**
* An axis for specifying left-right angular force (torque) data.
*/
public static final Axis RX_FORCE = new Axis("rx-force");
/**
* An axis for specifying left-right angular velocity data.
*/
public static final Axis RX_VELOCITY = new Axis("rx-velocity");
/**
* An axis for specifying forward-back angular acceleration data.
*/
public static final Axis RY_ACCELERATION = new Axis("ry-acceleration");
/**
* An axis for specifying forward-back angular force (torque) data.
*/
public static final Axis RY_FORCE = new Axis("ry-force");
/**
* An axis for specifying forward-back angular velocity data.
*/
public static final Axis RY_VELOCITY = new Axis("ry-velocity");
/**
* An axis for specifying up-down angular acceleration data.
*/
public static final Axis RZ_ACCELERATION = new Axis("rz-acceleration");
/**
* An axis for specifying up-down angular force (torque) data.
*/
public static final Axis RZ_FORCE = new Axis("rz-force");
/**
* An axis for specifying up-down angular velocity data.
*/
public static final Axis RZ_VELOCITY = new Axis("rz-velocity");
/**
* An axis for a point-of-view control.
*/
public static final Axis POV = new Axis("pov");
/**
* An unknown axis.
*/
public static final Axis UNKNOWN = new Axis("unknown");
}
public static class Button extends Identifier {
public Button(String name) {
super(name);
}
/** First device button
*/
public static final Button _0 = new Button("0");
/** Second device button
*/
public static final Button _1 = new Button("1");
/** Thrid device button
*/
public static final Button _2 = new Button("2");
/** Fourth device button
*/
public static final Button _3 = new Button("3");
/** Fifth device button
*/
public static final Button _4 = new Button("4");
/** Sixth device button
*/
public static final Button _5 = new Button("5");
/** Seventh device button
*/
public static final Button _6 = new Button("6");
/** Eighth device button
*/
public static final Button _7 = new Button("7");
/** Ninth device button
*/
public static final Button _8 = new Button("8");
/** 10th device button
*/
public static final Button _9 = new Button("9");
public static final Button _10 = new Button("10");
public static final Button _11 = new Button("11");
public static final Button _12 = new Button("12");
public static final Button _13 = new Button("13");
public static final Button _14 = new Button("14");
public static final Button _15 = new Button("15");
public static final Button _16 = new Button("16");
public static final Button _17 = new Button("17");
public static final Button _18 = new Button("18");
public static final Button _19 = new Button("19");
public static final Button _20 = new Button("20");
public static final Button _21 = new Button("21");
public static final Button _22 = new Button("22");
public static final Button _23 = new Button("23");
public static final Button _24 = new Button("24");
public static final Button _25 = new Button("25");
public static final Button _26 = new Button("26");
public static final Button _27 = new Button("27");
public static final Button _28 = new Button("28");
public static final Button _29 = new Button("29");
public static final Button _30 = new Button("30");
public static final Button _31 = new Button("31");
/** Joystick trigger button
*/
public static final Button TRIGGER = new Button("Trigger");
/** Joystick thumb button
*/
public static final Button THUMB = new Button("Thumb");
/** Second joystick thumb button
*/
public static final Button THUMB2 = new Button("Thumb 2");
/** Joystick top button
*/
public static final Button TOP = new Button("Top");
/** Second joystick top button
*/
public static final Button TOP2 = new Button("Top 2");
/** The joystick button you play with with you little finger (Pinkie on *that* side
* of the pond :P)
*/
public static final Button PINKIE = new Button("Pinkie");
/** Joystick button on the base of the device
*/
public static final Button BASE = new Button("Base");
/** Second joystick button on the base of the device
*/
public static final Button BASE2 = new Button("Base 2");
/** Thrid joystick button on the base of the device
*/
public static final Button BASE3 = new Button("Base 3");
/** Fourth joystick button on the base of the device
*/
public static final Button BASE4 = new Button("Base 4");
/** Fifth joystick button on the base of the device
*/
public static final Button BASE5 = new Button("Base 5");
/** Sixth joystick button on the base of the device
*/
public static final Button BASE6 = new Button("Base 6");
/** erm, dunno, but it's in the defines so it might exist.
*/
public static final Button DEAD = new Button("Dead");
/** 'A' button on a gamepad
*/
public static final Button A = new Button("A");
/** 'B' button on a gamepad
*/
public static final Button B = new Button("B");
/** 'C' button on a gamepad
*/
public static final Button C = new Button("C");
/** 'X' button on a gamepad
*/
public static final Button X = new Button("X");
/** 'Y' button on a gamepad
*/
public static final Button Y = new Button("Y");
/** 'Z' button on a gamepad
*/
public static final Button Z = new Button("Z");
/** Left thumb button on a gamepad
*/
public static final Button LEFT_THUMB = new Button("Left Thumb");
/** Right thumb button on a gamepad
*/
public static final Button RIGHT_THUMB = new Button("Right Thumb");
/** Second left thumb button on a gamepad
*/
public static final Button LEFT_THUMB2 = new Button("Left Thumb 2");
/** Second right thumb button on a gamepad
*/
public static final Button RIGHT_THUMB2 = new Button("Right Thumb 2");
/** 'Select' button on a gamepad
*/
public static final Button SELECT = new Button("Select");
/** 'Start' button on a gamepad
*/
public static final Button START = new Button("Start");
/** 'Mode' button on a gamepad
*/
public static final Button MODE = new Button("Mode");
/** Another left thumb button on a gamepad (how many thumbs do you have??)
*/
public static final Button LEFT_THUMB3 = new Button("Left Thumb 3");
/** Another right thumb button on a gamepad
*/
public static final Button RIGHT_THUMB3 = new Button("Right Thumb 3");
/** Digitiser pen tool button
*/
public static final Button TOOL_PEN = new Button("Pen");
/** Digitiser rubber (eraser) tool button
*/
public static final Button TOOL_RUBBER = new Button("Rubber");
/** Digitiser brush tool button
*/
public static final Button TOOL_BRUSH = new Button("Brush");
/** Digitiser pencil tool button
*/
public static final Button TOOL_PENCIL = new Button("Pencil");
/** Digitiser airbrush tool button
*/
public static final Button TOOL_AIRBRUSH = new Button("Airbrush");
/** Digitiser finger tool button
*/
public static final Button TOOL_FINGER = new Button("Finger");
/** Digitiser mouse tool button
*/
public static final Button TOOL_MOUSE = new Button("Mouse");
/** Digitiser lens tool button
*/
public static final Button TOOL_LENS = new Button("Lens");
/** Digitiser touch button
*/
public static final Button TOUCH = new Button("Touch");
/** Digitiser stylus button
*/
public static final Button STYLUS = new Button("Stylus");
/** Second digitiser stylus button
*/
public static final Button STYLUS2 = new Button("Stylus 2");
/**
* An unknown button
*/
public static final Button UNKNOWN = new Button("Unknown");
/**
* Returns the back mouse button.
*/
public static final Button BACK = new Button("Back");
/**
* Returns the extra mouse button.
*/
public static final Button EXTRA = new Button("Extra");
/**
* Returns the forward mouse button.
*/
public static final Button FORWARD = new Button("Forward");
/**
* The primary or leftmost mouse button.
*/
public static final Button LEFT = new Button("Left");
/**
* Returns the middle mouse button, not present if the mouse has fewer than three buttons.
*/
public static final Button MIDDLE = new Button("Middle");
/**
* The secondary or rightmost mouse button, not present if the mouse is a single-button mouse.
*/
public static final Button RIGHT = new Button("Right");
/**
* Returns the side mouse button.
*/
public static final Button SIDE = new Button("Side");
/**
* Extra, unnamed, buttons
*/
public static final Button EXTRA_1 = new Button("Extra 1");
public static final Button EXTRA_2 = new Button("Extra 2");
public static final Button EXTRA_3 = new Button("Extra 3");
public static final Button EXTRA_4 = new Button("Extra 4");
public static final Button EXTRA_5 = new Button("Extra 5");
public static final Button EXTRA_6 = new Button("Extra 6");
public static final Button EXTRA_7 = new Button("Extra 7");
public static final Button EXTRA_8 = new Button("Extra 8");
public static final Button EXTRA_9 = new Button("Extra 9");
public static final Button EXTRA_10 = new Button("Extra 10");
public static final Button EXTRA_11 = new Button("Extra 11");
public static final Button EXTRA_12 = new Button("Extra 12");
public static final Button EXTRA_13 = new Button("Extra 13");
public static final Button EXTRA_14 = new Button("Extra 14");
public static final Button EXTRA_15 = new Button("Extra 15");
public static final Button EXTRA_16 = new Button("Extra 16");
public static final Button EXTRA_17 = new Button("Extra 17");
public static final Button EXTRA_18 = new Button("Extra 18");
public static final Button EXTRA_19 = new Button("Extra 19");
public static final Button EXTRA_20 = new Button("Extra 20");
public static final Button EXTRA_21 = new Button("Extra 21");
public static final Button EXTRA_22 = new Button("Extra 22");
public static final Button EXTRA_23 = new Button("Extra 23");
public static final Button EXTRA_24 = new Button("Extra 24");
public static final Button EXTRA_25 = new Button("Extra 25");
public static final Button EXTRA_26 = new Button("Extra 26");
public static final Button EXTRA_27 = new Button("Extra 27");
public static final Button EXTRA_28 = new Button("Extra 28");
public static final Button EXTRA_29 = new Button("Extra 29");
public static final Button EXTRA_30 = new Button("Extra 30");
public static final Button EXTRA_31 = new Button("Extra 31");
public static final Button EXTRA_32 = new Button("Extra 32");
public static final Button EXTRA_33 = new Button("Extra 33");
public static final Button EXTRA_34 = new Button("Extra 34");
public static final Button EXTRA_35 = new Button("Extra 35");
public static final Button EXTRA_36 = new Button("Extra 36");
public static final Button EXTRA_37 = new Button("Extra 37");
public static final Button EXTRA_38 = new Button("Extra 38");
public static final Button EXTRA_39 = new Button("Extra 39");
public static final Button EXTRA_40 = new Button("Extra 40");
}
/**
* KeyIDs for standard PC (LATIN-1) keyboards
*/
public static class Key extends Identifier {
/**
* Protected constructor
*/
protected Key(String name) {
super(name);
}
/**
* Standard keyboard (LATIN-1) keys
* UNIX X11 keysym values are listed to the right
*/
public static final Key VOID = new Key("Void"); // MS 0x00 UNIX 0xFFFFFF
public static final Key ESCAPE = new Key("Escape"); // MS 0x01 UNIX 0xFF1B
public static final Key _1 = new Key("1"); // MS 0x02 UNIX 0x031 EXCLAM 0x021
public static final Key _2 = new Key("2"); // MS 0x03 UNIX 0x032 AT 0x040
public static final Key _3 = new Key("3"); // MS 0x04 UNIX 0x033 NUMBERSIGN 0x023
public static final Key _4 = new Key("4"); // MS 0x05 UNIX 0x034 DOLLAR 0x024
public static final Key _5 = new Key("5"); // MS 0x06 UNIX 0x035 PERCENT 0x025
public static final Key _6 = new Key("6"); // MS 0x07 UNIX 0x036 CIRCUMFLEX 0x05e
public static final Key _7 = new Key("7"); // MS 0x08 UNIX 0x037 AMPERSAND 0x026
public static final Key _8 = new Key("8"); // MS 0x09 UNIX 0x038 ASTERISK 0x02a
public static final Key _9 = new Key("9"); // MS 0x0A UNIX 0x039 PARENLEFT 0x028
public static final Key _0 = new Key("0"); // MS 0x0B UNIX 0x030 PARENRIGHT 0x029
public static final Key MINUS = new Key("-"); // MS 0x0C UNIX 0x02d UNDERSCORE 0x05f
public static final Key EQUALS = new Key("="); // MS 0x0D UNIX 0x03d PLUS 0x02b
public static final Key BACK = new Key("Back"); // MS 0x0E UNIX 0xFF08
public static final Key TAB = new Key("Tab"); // MS 0x0F UNIX 0xFF09
public static final Key Q = new Key("Q"); // MS 0x10 UNIX 0x071 UPPER 0x051
public static final Key W = new Key("W"); // MS 0x11 UNIX 0x077 UPPER 0x057
public static final Key E = new Key("E"); // MS 0x12 UNIX 0x065 UPPER 0x045
public static final Key R = new Key("R"); // MS 0x13 UNIX 0x072 UPPER 0x052
public static final Key T = new Key("T"); // MS 0x14 UNIX 0x074 UPPER 0x054
public static final Key Y = new Key("Y"); // MS 0x15 UNIX 0x079 UPPER 0x059
public static final Key U = new Key("U"); // MS 0x16 UNIX 0x075 UPPER 0x055
public static final Key I = new Key("I"); // MS 0x17 UNIX 0x069 UPPER 0x049
public static final Key O = new Key("O"); // MS 0x18 UNIX 0x06F UPPER 0x04F
public static final Key P = new Key("P"); // MS 0x19 UNIX 0x070 UPPER 0x050
public static final Key LBRACKET = new Key("["); // MS 0x1A UNIX 0x05b BRACE 0x07b
public static final Key RBRACKET = new Key("]"); // MS 0x1B UNIX 0x05d BRACE 0x07d
public static final Key RETURN = new Key("Return"); // MS 0x1C UNIX 0xFF0D
public static final Key LCONTROL = new Key("Left Control"); // MS 0x1D UNIX 0xFFE3
public static final Key A = new Key("A"); // MS 0x1E UNIX 0x061 UPPER 0x041
public static final Key S = new Key("S"); // MS 0x1F UNIX 0x073 UPPER 0x053
public static final Key D = new Key("D"); // MS 0x20 UNIX 0x064 UPPER 0x044
public static final Key F = new Key("F"); // MS 0x21 UNIX 0x066 UPPER 0x046
public static final Key G = new Key("G"); // MS 0x22 UNIX 0x067 UPPER 0x047
public static final Key H = new Key("H"); // MS 0x23 UNIX 0x068 UPPER 0x048
public static final Key J = new Key("J"); // MS 0x24 UNIX 0x06A UPPER 0x04A
public static final Key K = new Key("K"); // MS 0x25 UNIX 0x06B UPPER 0x04B
public static final Key L = new Key("L"); // MS 0x26 UNIX 0x06C UPPER 0x04C
public static final Key SEMICOLON = new Key(";"); // MS 0x27 UNIX 0x03b COLON 0x03a
public static final Key APOSTROPHE = new Key("'"); // MS 0x28 UNIX 0x027 QUOTEDBL 0x022
public static final Key GRAVE = new Key("~"); // MS 0x29 UNIX 0x060 TILDE 0x07e
public static final Key LSHIFT = new Key("Left Shift"); // MS 0x2A UNIX 0xFFE1
public static final Key BACKSLASH = new Key("\\"); // MS 0x2B UNIX 0x05c BAR 0x07c
public static final Key Z = new Key("Z"); // MS 0x2C UNIX 0x07A UPPER 0x05A
public static final Key X = new Key("X"); // MS 0x2D UNIX 0x078 UPPER 0x058
public static final Key C = new Key("C"); // MS 0x2E UNIX 0x063 UPPER 0x043
public static final Key V = new Key("V"); // MS 0x2F UNIX 0x076 UPPER 0x056
public static final Key B = new Key("B"); // MS 0x30 UNIX 0x062 UPPER 0x042
public static final Key N = new Key("N"); // MS 0x31 UNIX 0x06E UPPER 0x04E
public static final Key M = new Key("M"); // MS 0x32 UNIX 0x06D UPPER 0x04D
public static final Key COMMA = new Key(","); // MS 0x33 UNIX 0x02c LESS 0x03c
public static final Key PERIOD = new Key("."); // MS 0x34 UNIX 0x02e GREATER 0x03e
public static final Key SLASH = new Key("/"); // MS 0x35 UNIX 0x02f QUESTION 0x03f
public static final Key RSHIFT = new Key("Right Shift"); // MS 0x36 UNIX 0xFFE2
public static final Key MULTIPLY = new Key("Multiply"); // MS 0x37 UNIX 0xFFAA
public static final Key LALT = new Key("Left Alt"); // MS 0x38 UNIX 0xFFE9
public static final Key SPACE = new Key(" "); // MS 0x39 UNIX 0x020
public static final Key CAPITAL = new Key("Caps Lock"); // MS 0x3A UNIX 0xFFE5 SHIFTLOCK 0xFFE6
public static final Key F1 = new Key("F1"); // MS 0x3B UNIX 0xFFBE
public static final Key F2 = new Key("F2"); // MS 0x3C UNIX 0xFFBF
public static final Key F3 = new Key("F3"); // MS 0x3D UNIX 0xFFC0
public static final Key F4 = new Key("F4"); // MS 0x3E UNIX 0xFFC1
public static final Key F5 = new Key("F5"); // MS 0x3F UNIX 0xFFC2
public static final Key F6 = new Key("F6"); // MS 0x40 UNIX 0xFFC3
public static final Key F7 = new Key("F7"); // MS 0x41 UNIX 0xFFC4
public static final Key F8 = new Key("F8"); // MS 0x42 UNIX 0xFFC5
public static final Key F9 = new Key("F9"); // MS 0x43 UNIX 0xFFC6
public static final Key F10 = new Key("F10"); // MS 0x44 UNIX 0xFFC7
public static final Key NUMLOCK = new Key("Num Lock"); // MS 0x45 UNIX 0xFF7F
public static final Key SCROLL = new Key("Scroll Lock"); // MS 0x46 UNIX 0xFF14
public static final Key NUMPAD7 = new Key("Num 7"); // MS 0x47 UNIX 0xFFB7 HOME 0xFF95
public static final Key NUMPAD8 = new Key("Num 8"); // MS 0x48 UNIX 0xFFB8 UP 0xFF97
public static final Key NUMPAD9 = new Key("Num 9"); // MS 0x49 UNIX 0xFFB9 PRIOR 0xFF9A
public static final Key SUBTRACT = new Key("Num -"); // MS 0x4A UNIX 0xFFAD
public static final Key NUMPAD4 = new Key("Num 4"); // MS 0x4B UNIX 0xFFB4 LEFT 0xFF96
public static final Key NUMPAD5 = new Key("Num 5"); // MS 0x4C UNIX 0xFFB5
public static final Key NUMPAD6 = new Key("Num 6"); // MS 0x4D UNIX 0xFFB6 RIGHT 0xFF98
public static final Key ADD = new Key("Num +"); // MS 0x4E UNIX 0xFFAB
public static final Key NUMPAD1 = new Key("Num 1"); // MS 0x4F UNIX 0xFFB1 END 0xFF9C
public static final Key NUMPAD2 = new Key("Num 2"); // MS 0x50 UNIX 0xFFB2 DOWN 0xFF99
public static final Key NUMPAD3 = new Key("Num 3"); // MS 0x51 UNIX 0xFFB3 NEXT 0xFF9B
public static final Key NUMPAD0 = new Key("Num 0"); // MS 0x52 UNIX 0xFFB0 INSERT 0xFF9E
public static final Key DECIMAL = new Key("Num ."); // MS 0x53 UNIX 0xFFAE DELETE 0xFF9F
public static final Key F11 = new Key("F11"); // MS 0x57 UNIX 0xFFC8
public static final Key F12 = new Key("F12"); // MS 0x58 UNIX 0xFFC9
public static final Key F13 = new Key("F13"); // MS 0x64 UNIX 0xFFCA
public static final Key F14 = new Key("F14"); // MS 0x65 UNIX 0xFFCB
public static final Key F15 = new Key("F15"); // MS 0x66 UNIX 0xFFCC
public static final Key KANA = new Key("Kana"); // MS 0x70 UNIX 0xFF2D
public static final Key CONVERT = new Key("Convert"); // MS 0x79 Japanese keyboard
public static final Key NOCONVERT = new Key("Noconvert"); // MS 0x7B Japanese keyboard
public static final Key YEN = new Key("Yen"); // MS 0x7D UNIX 0x0a5
public static final Key NUMPADEQUAL = new Key("Num ="); // MS 0x8D UNIX 0xFFBD
public static final Key CIRCUMFLEX = new Key("Circumflex"); // MS 0x90 Japanese keyboard
public static final Key AT = new Key("At"); // MS 0x91 UNIX 0x040
public static final Key COLON = new Key("Colon"); // MS 0x92 UNIX 0x03a
public static final Key UNDERLINE = new Key("Underline"); // MS 0x93 NEC PC98
public static final Key KANJI = new Key("Kanji"); // MS 0x94 UNIX 0xFF21
public static final Key STOP = new Key("Stop"); // MS 0x95 UNIX 0xFF69
public static final Key AX = new Key("Ax"); // MS 0x96 Japan AX
public static final Key UNLABELED = new Key("Unlabeled"); // MS 0x97 J3100
public static final Key NUMPADENTER = new Key("Num Enter"); // MS 0x9C UNIX 0xFF8D
public static final Key RCONTROL = new Key("Right Control"); // MS 0x9D UNIX 0xFFE4
public static final Key NUMPADCOMMA = new Key("Num ,"); // MS 0xB3 UNIX 0xFFAC
public static final Key DIVIDE = new Key("Num /"); // MS 0xB5 UNIX 0xFFAF
public static final Key SYSRQ = new Key("SysRq"); // MS 0xB7 UNIX 0xFF15 PRINT 0xFF61
public static final Key RALT = new Key("Right Alt"); // MS 0xB8 UNIX 0xFFEA
public static final Key PAUSE = new Key("Pause"); // MS 0xC5 UNIX 0xFF13 BREAK 0xFF6B
public static final Key HOME = new Key("Home"); // MS 0xC7 UNIX 0xFF50
public static final Key UP = new Key("Up"); // MS 0xC8 UNIX 0xFF52
public static final Key PAGEUP = new Key("Pg Up"); // MS 0xC9 UNIX 0xFF55
public static final Key LEFT = new Key("Left"); // MS 0xCB UNIX 0xFF51
public static final Key RIGHT = new Key("Right"); // MS 0xCD UNIX 0xFF53
public static final Key END = new Key("End"); // MS 0xCF UNIX 0xFF57
public static final Key DOWN = new Key("Down"); // MS 0xD0 UNIX 0xFF54
public static final Key PAGEDOWN = new Key("Pg Down"); // MS 0xD1 UNIX 0xFF56
public static final Key INSERT = new Key("Insert"); // MS 0xD2 UNIX 0xFF63
public static final Key DELETE = new Key("Delete"); // MS 0xD3 UNIX 0xFFFF
public static final Key LWIN = new Key("Left Windows"); // MS 0xDB UNIX META 0xFFE7 SUPER 0xFFEB HYPER 0xFFED
public static final Key RWIN = new Key("Right Windows"); // MS 0xDC UNIX META 0xFFE8 SUPER 0xFFEC HYPER 0xFFEE
public static final Key APPS = new Key("Apps"); // MS 0xDD UNIX 0xFF67
public static final Key POWER = new Key("Power"); // MS 0xDE Sun 0x1005FF76 SHIFT 0x1005FF7D
public static final Key SLEEP = new Key("Sleep"); // MS 0xDF No UNIX keysym
public static final Key UNKNOWN = new Key("Unknown");
} // class StandardKeyboard.KeyID
} // class Axis.Identifier
/**
* POV enum for different positions.
*/
public static class POV {
/**
* Standard value for center HAT position
*/
public static final float OFF = 0.0f;
/**
* Synonmous with OFF
*/
public static final float CENTER = OFF;
/**
* Standard value for up-left HAT position
*/
public static final float UP_LEFT = 0.125f;
/**
* Standard value for up HAT position
*/
public static final float UP = 0.25f;
/**
* Standard value for up-right HAT position
*/
public static final float UP_RIGHT = 0.375f;
/**
* Standard value for right HAT position
*/
public static final float RIGHT = 0.50f;
/**
* Standard value for down-right HAT position
*/
public static final float DOWN_RIGHT = 0.625f;
/**
* Standard value for down HAT position
*/
public static final float DOWN = 0.75f;
/**
* Standard value for down-left HAT position
*/
public static final float DOWN_LEFT = 0.875f;
/**
* Standard value for left HAT position
*/
public static final float LEFT = 1.0f;
} // class Axis.POV
} // interface Axis

View file

@ -0,0 +1,263 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
/**
* A Controller represents a physical device, such as a keyboard, mouse,
* or joystick, or a logical grouping of related controls, such as a button
* pad or mouse ball. A controller can be composed of multiple controllers.
* For example, the ball of a mouse and its buttons are two separate
* controllers.
*/
public interface Controller {
/**
* Returns the controllers connected to make up this controller, or
* an empty array if this controller contains no child controllers.
* The objects in the array are returned in order of assignment priority
* (primary stick, secondary buttons, etc.).
*/
public abstract Controller[] getControllers();
/**
* Returns the type of the Controller.
*/
public abstract Type getType();
/**
* Returns the components on this controller, in order of assignment priority.
* For example, the button controller on a mouse returns an array containing
* the primary or leftmost mouse button, followed by the secondary or
* rightmost mouse button (if present), followed by the middle mouse button
* (if present).
* The array returned is an empty array if this controller contains no components
* (such as a logical grouping of child controllers).
*/
public abstract Component[] getComponents();
/**
* Returns a single axis based on its type, or null
* if no axis with the specified type could be found.
*/
public abstract Component getComponent(Component.Identifier id);
/**
* Returns the rumblers for sending feedback to this controller, or an
* empty array if there are no rumblers on this controller.
*/
public abstract Rumbler[] getRumblers();
/**
* Polls axes for data. Returns false if the controller is no longer valid.
* Polling reflects the current state of the device when polled.
*/
public abstract boolean poll();
/**
* Initialized the controller event queue to a new size. Existing events
* in the queue are lost.
*/
public abstract void setEventQueueSize(int size);
/**
* Get the device event queue
*/
public abstract EventQueue getEventQueue();
/**
* Returns the port type for this Controller.
*/
public abstract PortType getPortType();
/**
* Returns the zero-based port number for this Controller.
*/
public abstract int getPortNumber();
/**
* Returns a human-readable name for this Controller.
*/
public abstract String getName();
/**
* Types of controller objects.
*/
public static class Type {
/**
* Name of controller type
*/
private final String name;
/**
* Protected constructor
*/
protected Type(String name) {
this.name = name;
}
/**
* Returns a non-localized string description of this controller type.
*/
public String toString() {
return name;
}
/**
* Unkown controller type.
*/
public static final Type UNKNOWN = new Type("Unknown");
/**
* Mouse controller.
*/
public static final Type MOUSE = new Type("Mouse");
/**
* A keyboard controller
*/
public static final Type KEYBOARD = new Type("Keyboard");
/**
* Fingerstick controller; note that this may be sometimes treated as a
* type of mouse or stick.
*/
public static final Type FINGERSTICK = new Type("Fingerstick");
/**
* Gamepad controller.
*/
public static final Type GAMEPAD = new Type("Gamepad");
/**
* Headtracker controller.
*/
public static final Type HEADTRACKER = new Type("Headtracker");
/**
* Rudder controller.
*/
public static final Type RUDDER = new Type("Rudder");
/**
* Stick controller, such as a joystick or flightstick.
*/
public static final Type STICK = new Type("Stick");
/**
* A trackball controller; note that this may sometimes be treated as a
* type of mouse.
*/
public static final Type TRACKBALL = new Type("Trackball");
/**
* A trackpad, such as a tablet, touchpad, or glidepad;
* note that this may sometimes be treated as a type of mouse.
*/
public static final Type TRACKPAD = new Type("Trackpad");
/**
* A wheel controller, such as a steering wheel (note
* that a mouse wheel is considered part of a mouse, not a
* wheel controller).
*/
public static final Type WHEEL = new Type("Wheel");
} // class Controller.Type
/**
* Common controller port types.
*/
public static final class PortType {
/**
* Name of port type
*/
private final String name;
/**
* Protected constructor
*/
protected PortType(String name) {
this.name = name;
}
/**
* Returns a non-localized string description of this port type.
*/
public String toString() {
return name;
}
/**
* Unknown port type
*/
public static final PortType UNKNOWN = new PortType("Unknown");
/**
* USB port
*/
public static final PortType USB = new PortType("USB port");
/**
* Standard game port
*/
public static final PortType GAME = new PortType("Game port");
/**
* Network port
*/
public static final PortType NETWORK = new PortType("Network port");
/**
* Serial port
*/
public static final PortType SERIAL = new PortType("Serial port");
/**
* i8042
*/
public static final PortType I8042 = new PortType("i8042 (PS/2)");
/**
* Parallel port
*/
public static final PortType PARALLEL = new PortType("Parallel port");
} // class Controller.PortType
} // interface Controller

View file

@ -0,0 +1,160 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.io.File;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* A ControllerEnvironment represents a collection of controllers that are
* physically or logically linked. By default, this corresponds to the
* environment for the local machine.
* <p>
* In this reference implementation, this class can also be used to register
* controllers with the default environment as "plug-ins". A plug-in is
* created by subclassing ControllerEnvironment with a class that has a public
* no-argument constructor, implements the net.java.games.util.plugins.Plugin
* interface and has a name ending in "Plugin".
* (See net.java.games.input.DirectInputEnvironmentPlugin in the DXplugin
* part of the source tree for an example.)
*
* When the DefaultControllerEnvrionment is instanced it uses the plugin library
* to look for Plugins in both [java.home]/lib/controller and
* [user.dir]/controller. This allows controller plugins to be installed either
* globally for the entire Java environment or locally for just one particular
* Java app.
*
* For more information on the organization of plugins within the controller
* root directories, see net.java.games.util.plugins.Plugins (Note the
* plural -- "Plugins" not "Plugin" which is just a marker interface.)
*
*/
public abstract class ControllerEnvironment {
static void log(String msg) {
Logger.getLogger(ControllerEnvironment.class.getName()).info(msg);
}
/**
* The default controller environment
*/
private static ControllerEnvironment defaultEnvironment =
new DefaultControllerEnvironment();
/**
* List of controller listeners
*/
protected final ArrayList<ControllerListener> controllerListeners = new ArrayList<>();
/**
* Protected constructor for subclassing.
*/
protected ControllerEnvironment() {
if(System.getProperty("jinput.loglevel") != null) {
String loggerName = ControllerEnvironment.class.getPackage().getName();
Level level = Level.parse(System.getProperty("jinput.loglevel"));
Logger.getLogger(loggerName).setLevel(level);
}
}
/**
* Returns a list of all controllers available to this environment,
* or an empty array if there are no controllers in this environment.
*/
public abstract Controller[] getControllers();
/**
* Adds a listener for controller state change events.
*/
public void addControllerListener(ControllerListener l) {
assert l != null;
controllerListeners.add(l);
}
/**
* Returns the isSupported status of this environment.
* What makes an environment supported or not is up to the
* particular plugin, but may include OS or available hardware.
*/
public abstract boolean isSupported();
/**
* Removes a listener for controller state change events.
*/
public void removeControllerListener(ControllerListener l) {
assert l != null;
controllerListeners.remove(l);
}
/**
* Creates and sends an event to the controller listeners that a controller
* has been added.
*/
protected void fireControllerAdded(Controller c) {
ControllerEvent ev = new ControllerEvent(c);
Iterator<ControllerListener> it = controllerListeners.iterator();
while (it.hasNext()) {
it.next().controllerAdded(ev);
}
}
/**
* Creates and sends an event to the controller listeners that a controller
* has been lost.
*/
protected void fireControllerRemoved(Controller c) {
ControllerEvent ev = new ControllerEvent(c);
Iterator<ControllerListener> it = controllerListeners.iterator();
while (it.hasNext()) {
it.next().controllerRemoved(ev);
}
}
/**
* Returns the default environment for input controllers.
* This usually corresponds to the environment for the local machine.
*/
public static ControllerEnvironment getDefaultEnvironment() {
return defaultEnvironment;
}
}

View file

@ -0,0 +1,61 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
/**
* An event that is fired when the state of a controller changes
*/
public class ControllerEvent {
private Controller controller;
/**
* Creates a controller event object.
*/
public ControllerEvent(Controller c) {
controller = c;
}
/**
* Returns the controller for this event.
*/
public Controller getController() {
return controller;
}
} // class ControllerEvent

View file

@ -0,0 +1,55 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
/**
* A listener for changes in the state of controllers
*/
public interface ControllerListener {
/**
* Invoked when a controller is lost.
*/
public abstract void controllerRemoved(ControllerEvent ev);
/**
* Invoked when a controller has been added.
*/
public abstract void controllerAdded(ControllerEvent ev);
} // interface ControllerListener

View file

@ -0,0 +1,214 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*/
package net.java.games.input;
import net.java.games.util.plugins.Plugins;
import java.io.File;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.logging.Logger;
/**
* The default controller environment.
*
* @version %I% %G%
* @author Michael Martak
*/
class DefaultControllerEnvironment extends ControllerEnvironment {
static String libPath;
private static Logger log = Logger.getLogger(DefaultControllerEnvironment.class.getName());
/**
* Static utility method for loading native libraries.
* It will try to load from either the path given by
* the net.java.games.input.librarypath property
* or through System.loadLibrary().
*
*/
static void loadLibrary(final String lib_name) {
AccessController.doPrivileged((PrivilegedAction<String>) () -> {
String lib_path = System.getProperty("net.java.games.input.librarypath");
if (lib_path != null)
System.load(lib_path + File.separator + System.mapLibraryName(lib_name));
else
System.loadLibrary(lib_name);
return null;
});
}
static String getPrivilegedProperty(final String property) {
return AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty(property));
}
static String getPrivilegedProperty(final String property, final String default_value) {
return AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty(property, default_value));
}
/**
* List of all controllers in this environment
*/
private ArrayList<Controller> controllers;
private Collection<String> loadedPluginNames = new ArrayList<>();
/**
* Public no-arg constructor.
*/
public DefaultControllerEnvironment() {
}
/**
* Returns a list of all controllers available to this environment,
* or an empty array if there are no controllers in this environment.
*/
public Controller[] getControllers() {
if (controllers == null) {
// Controller list has not been scanned.
controllers = new ArrayList<>();
AccessController.doPrivileged((PrivilegedAction<Void>) () -> scanControllers());
//Check the properties for specified controller classes
String pluginClasses = getPrivilegedProperty("jinput.plugins", "") + " " + getPrivilegedProperty("net.java.games.input.plugins", "");
if(!getPrivilegedProperty("jinput.useDefaultPlugin", "true").toLowerCase().trim().equals("false") && !getPrivilegedProperty("net.java.games.input.useDefaultPlugin", "true").toLowerCase().trim().equals("false")) {
String osName = getPrivilegedProperty("os.name", "").trim();
if(osName.equals("Linux")) {
pluginClasses = pluginClasses + " net.java.games.input.LinuxEnvironmentPlugin";
} else if(osName.equals("Mac OS X")) {
pluginClasses = pluginClasses + " net.java.games.input.OSXEnvironmentPlugin";
} else if(osName.equals("Windows XP") || osName.equals("Windows Vista") || osName.equals("Windows 7") || osName.equals("Windows 8") || osName.equals("Windows 8.1") || osName.equals("Windows 10")) {
pluginClasses = pluginClasses + " net.java.games.input.DirectAndRawInputEnvironmentPlugin";
} else if(osName.equals("Windows 98") || osName.equals("Windows 2000")) {
pluginClasses = pluginClasses + " net.java.games.input.DirectInputEnvironmentPlugin";
} else if (osName.startsWith("Windows")) {
log.warning("Found unknown Windows version: " + osName);
log.warning("Attempting to use default windows plug-in.");
pluginClasses = pluginClasses + " net.java.games.input.DirectAndRawInputEnvironmentPlugin";
} else {
log.warning("Trying to use default plugin, OS name " + osName +" not recognised");
}
}
StringTokenizer pluginClassTok = new StringTokenizer(pluginClasses, " \t\n\r\f,;:");
while(pluginClassTok.hasMoreTokens()) {
String className = pluginClassTok.nextToken();
try {
if(!loadedPluginNames.contains(className)) {
log.fine("Loading: " + className);
Class<?> ceClass = Class.forName(className);
ControllerEnvironment ce = (ControllerEnvironment) ceClass.getDeclaredConstructor().newInstance();
if(ce.isSupported()) {
addControllers(ce.getControllers());
loadedPluginNames.add(ce.getClass().getName());
} else {
log(ceClass.getName() + " is not supported");
}
}
} catch (Throwable e) {
e.printStackTrace();
}
}
}
Controller[] ret = new Controller[controllers.size()];
Iterator<Controller> it = controllers.iterator();
int i = 0;
while (it.hasNext()) {
ret[i] = it.next();
i++;
}
return ret;
}
/* This is jeff's new plugin code using Jeff's Plugin manager */
private Void scanControllers() {
String pluginPathName = getPrivilegedProperty("jinput.controllerPluginPath");
if(pluginPathName == null) {
pluginPathName = "controller";
}
scanControllersAt(getPrivilegedProperty("java.home") +
File.separator + "lib"+File.separator + pluginPathName);
scanControllersAt(getPrivilegedProperty("user.dir")+
File.separator + pluginPathName);
return null;
}
private void scanControllersAt(String path) {
File file = new File(path);
if (!file.exists()) {
return;
}
try {
Plugins plugins = new Plugins(file);
@SuppressWarnings("unchecked")
Class<ControllerEnvironment>[] envClasses = plugins.getExtends(ControllerEnvironment.class);
for(int i=0;i<envClasses.length;i++){
try {
ControllerEnvironment.log("ControllerEnvironment "+
envClasses[i].getName()
+" loaded by "+envClasses[i].getClassLoader());
ControllerEnvironment ce = envClasses[i].getDeclaredConstructor().newInstance();
if(ce.isSupported()) {
addControllers(ce.getControllers());
loadedPluginNames.add(ce.getClass().getName());
} else {
log(envClasses[i].getName() + " is not supported");
}
} catch (Throwable e) {
e.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Add the array of controllers to our list of controllers.
*/
private void addControllers(Controller[] c) {
for (int i = 0; i < c.length; i++) {
controllers.add(c[i]);
}
}
public boolean isSupported() {
return true;
}
}

View file

@ -0,0 +1,76 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
public final class Event {
private Component component;
private float value;
private long nanos;
public final void set(Event other) {
this.set(other.getComponent(), other.getValue(), other.getNanos());
}
public final void set(Component component, float value, long nanos) {
this.component = component;
this.value = value;
this.nanos = nanos;
}
public final Component getComponent() {
return component;
}
public final float getValue() {
return value;
}
/**
* Return the time the event happened, in nanoseconds.
* The time is relative and therefore can only be used
* to compare with other event times.
*/
public final long getNanos() {
return nanos;
}
public final String toString() {
return "Event: component = " + component + " | value = " + value;
}
}

View file

@ -0,0 +1,95 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
/**
* A FIFO queue for input events.
*/
public final class EventQueue {
private final Event[] queue;
private int head;
private int tail;
/**
* This is an internal method and should not be called by applications using the API
*/
public EventQueue(int size) {
queue = new Event[size + 1];
for (int i = 0; i < queue.length; i++)
queue[i] = new Event();
}
/**
* This is an internal method and should not be called by applications using the API
*/
final synchronized void add(Event event) {
queue[tail].set(event);
tail = increase(tail);
}
/**
* Check if the queue is full
* @return true if the queue is full
*/
final synchronized boolean isFull() {
return increase(tail) == head;
}
/**
* This is an internal method and should not be called by applications using the API
*/
private final int increase(int x) {
return (x + 1)%queue.length;
}
/**
* Populates the provided event with the details of the event on the head of the queue.
*
* @param event The event to populate
* @return false if there were no events left on the queue, otherwise true.
*/
public final synchronized boolean getNextEvent(Event event) {
if (head == tail)
return false;
event.set(queue[head]);
head = increase(head);
return true;
}
}

View file

@ -0,0 +1,69 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
/**
* A Keyboard is a type of controller consisting of a single controller,
* they keypad, which contains several axes (the keys). By default, all keys
* are set to receive polling data.
*/
public abstract class Keyboard extends AbstractController {
/**
* Protected constructor.
* Subclasses should initialize the array of axes to an array of keys.
* @param name The name of the keyboard
*/
protected Keyboard(String name, Component[] keys, Controller[] children, Rumbler[] rumblers) {
super(name, keys, children, rumblers);
}
/**
* Returns the type of the Controller.
*/
public Type getType() {
return Type.KEYBOARD;
}
public final boolean isKeyDown(Component.Identifier.Key key_id) {
Component key = getComponent(key_id);
if (key == null)
return false;
return key.getPollData() != 0;
}
} // class Keyboard

View file

@ -0,0 +1,186 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.util.List;
import java.util.ArrayList;
/**
* A Mouse is a type of controller consisting of two child controllers,
* a ball and a button pad. This includes devices such as touch pads,
* trackballs, and fingersticks.
*/
public abstract class Mouse extends AbstractController {
protected Mouse(String name, Component[] components, Controller[] children, Rumbler[] rumblers) {
super(name, components, children, rumblers);
}
/**
* Returns the type of the Controller.
*/
public Type getType() {
return Type.MOUSE;
}
/**
* Returns the x-axis for the mouse ball, never null.
*/
public Component getX() {
return getComponent(Component.Identifier.Axis.X);
}
/**
* Returns the y-axis for the mouse ball, never null.
*/
public Component getY() {
return getComponent(Component.Identifier.Axis.Y);
}
/**
* Returns the mouse wheel, or null if no mouse wheel is present.
*/
public Component getWheel() {
return getComponent(Component.Identifier.Axis.Z);
}
/**
* Returns the left or primary mouse button, never null.
*/
public Component getPrimaryButton() {
Component primaryButton = getComponent(Component.Identifier.Button.LEFT);
if(primaryButton==null) {
primaryButton = getComponent(Component.Identifier.Button._1);
}
return primaryButton;
}
/**
* Returns the right or secondary mouse button, null if the mouse is
* a single-button mouse.
*/
public Component getSecondaryButton() {
Component secondaryButton = getComponent(Component.Identifier.Button.RIGHT);
if(secondaryButton==null) {
secondaryButton = getComponent(Component.Identifier.Button._2);
}
return secondaryButton;
}
/**
* Returns the middle or tertiary mouse button, null if the mouse has
* fewer than three buttons.
*/
public Component getTertiaryButton() {
Component tertiaryButton = getComponent(Component.Identifier.Button.MIDDLE);
if(tertiaryButton==null) {
tertiaryButton = getComponent(Component.Identifier.Button._3);
}
return tertiaryButton;
}
/**
* Returns the left mouse button.
*/
public Component getLeft() {
return getComponent(Component.Identifier.Button.LEFT);
}
/**
* Returns the right, null if the mouse is a single-button mouse.
*/
public Component getRight() {
return getComponent(Component.Identifier.Button.RIGHT);
}
/**
* Returns the middle, null if the mouse has fewer than three buttons.
*/
public Component getMiddle() {
return getComponent(Component.Identifier.Button.MIDDLE);
}
/**
* Returns the side or 4th mouse button, null if the mouse has
* fewer than 4 buttons.
*/
public Component getSide() {
return getComponent(Component.Identifier.Button.SIDE);
}
/**
* Returns the extra or 5th mouse button, null if the mouse has
* fewer than 5 buttons.
*/
public Component getExtra() {
return getComponent(Component.Identifier.Button.EXTRA);
}
/**
* Returns the forward mouse button, null if the mouse hasn't
* got one.
*/
public Component getForward() {
return getComponent(Component.Identifier.Button.FORWARD);
}
/**
* Returns the back mouse button, null if the mouse hasn't
* got one.
*/
public Component getBack() {
return getComponent(Component.Identifier.Button.BACK);
}
/**
* Returns forth mouse button, null if the mouse hasn't
* got one.
*/
public Component getButton3() {
return getComponent(Component.Identifier.Button._3);
}
/**
* Returns fifth mouse button, null if the mouse hasn't
* got one.
*/
public Component getButton4() {
return getComponent(Component.Identifier.Button._4);
}
} // class Mouse

View file

@ -0,0 +1,169 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*/
package net.java.games.input;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.StringTokenizer;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
/**
* Loads all plugins.
*
* @version %I% %G%
* @author Michael Martak
*/
class PluginClassLoader extends ClassLoader {
/**
* Location of directory to look for plugins
*/
private static String pluginDirectory;
/**
* File filter for JAR files
*/
private static final FileFilter JAR_FILTER = new JarFileFilter();
/**
* Create a new class loader for loading plugins
*/
public PluginClassLoader() {
super(Thread.currentThread().getContextClassLoader());
}
/**
* Overrides findClass to first look in the parent class loader,
* then try loading the class from the plugin file system.
*/
protected Class<?> findClass(String name)
throws ClassNotFoundException {
// Try loading the class from the file system.
byte[] b = loadClassData(name);
return defineClass(name, b, 0, b.length);
}
/**
* Load the class data from the file system
*/
private byte[] loadClassData(String name)
throws ClassNotFoundException {
if (pluginDirectory == null) {
pluginDirectory = DefaultControllerEnvironment.libPath +
File.separator + "controller";
}
try {
return loadClassFromDirectory(name);
} catch (Exception e) {
try {
return loadClassFromJAR(name);
} catch (IOException e2) {
throw new ClassNotFoundException(name, e2);
}
}
}
/**
* Load the class data from the file system based on parsing
* the class name (packages).
*/
private byte[] loadClassFromDirectory(String name)
throws ClassNotFoundException, IOException {
// Parse the class name into package directories.
// Look for the class in the plugin directory.
StringTokenizer tokenizer = new StringTokenizer(name, ".");
StringBuffer path = new StringBuffer(pluginDirectory);
while (tokenizer.hasMoreTokens()) {
path.append(File.separator);
path.append(tokenizer.nextToken());
}
path.append(".class");
File file = new File(path.toString());
if (!file.exists()) {
throw new ClassNotFoundException(name);
}
try(FileInputStream fileInputStream = new FileInputStream(file)) {
assert file.length() <= Integer.MAX_VALUE;
int length = (int) file.length();
byte[] bytes = new byte[length];
int length2 = fileInputStream.read(bytes);
assert length == length2;
return bytes;
}
}
/**
* Scans through the plugin directory for JAR files and
* attempts to load the class data from each JAR file.
*/
private byte[] loadClassFromJAR(String name)
throws ClassNotFoundException, IOException {
File dir = new File(pluginDirectory);
File[] jarFiles = dir.listFiles(JAR_FILTER);
if (jarFiles == null) {
throw new ClassNotFoundException("Could not find class " + name);
}
for (int i = 0; i < jarFiles.length; i++) {
JarFile jarfile = new JarFile(jarFiles[i]);
JarEntry jarentry = jarfile.getJarEntry(name + ".class");
if (jarentry != null) {
try(InputStream jarInputStream = jarfile.getInputStream(jarentry)) {
assert jarentry.getSize() <= Integer.MAX_VALUE;
int length = (int) jarentry.getSize();
assert length >= 0;
byte[] bytes = new byte[length];
int length2 = jarInputStream.read(bytes);
assert length == length2;
return bytes;
}
}
}
throw new FileNotFoundException(name);
}
/**
* Filters out all non-JAR files, based on whether or not they
* end in ".JAR" (case-insensitive).
*/
private static class JarFileFilter implements FileFilter {
public boolean accept(File file) {
return file.getName().toUpperCase().endsWith(".JAR");
}
}
}

View file

@ -0,0 +1,67 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
/**
* A Rumbler is a controller's mechanism for delivering feedback
* to the user through the device.
*/
public interface Rumbler {
/**
* Rumble with the specified intensity.
*/
public abstract void rumble(float intensity);
/**
* Get the string name of the axis the rumbler is attached to
*
* @return The axis name
*/
public String getAxisName();
/**
* Get the axis identifier the rumbler is attached to
*
* @return The axis identifier
*/
public Component.Identifier getAxisIdentifier();
} // interface Rumbler

View file

@ -0,0 +1,102 @@
/*
* Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* -Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS
* LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A
* RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
* IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT
* OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS
* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for use in the
* design, construction, operation or maintenance of any nuclear facility.
*/
package net.java.games.input;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
* The version and build number of this implementation.
* Version numbers for a release are of the form: w.x.y, where:
* <ul>
* <li>
* w - the major version number of the release. This number should
* start at 1. Typically, a bump in the major version number
* signifies that the release breaks backwards compatibility
* with some older release.
* </li>
* <li>
* x - minor version number. This number starts at 0. A bump in
* the minor version number signifies a release that has significant
* new functionality.
* </li>
* <li>
* y - minor-minor version number number. This number starts at 0. A
* bump in the minor-minor version number signifies that new bug
* fixes have been added to the build.
* </li>
* </ul>
*
* For example, the following are all valid version strings:
* <ul>
* <li>1.1.2</li>
* <li>1.3.5-SNAPSHOT</li>
* <li>4.7.1-M2</li>
* </ul>
*
*/
public final class Version {
/**
* Private constructor - no need for user to create
* an instance of this class.
*/
private Version() {
}
/**
* Returns the verison string and build number of
* this implementation. See the class descritpion
* for the version string format.
*
* @return The version string of this implementation.
*/
public static String getVersion() {
String version = "Unversioned";
try {
Properties p = new Properties();
InputStream is = Version.class.getResourceAsStream("/META-INF/maven/net.java.jinput/coreapi/pom.properties");
if(is != null) {
p.load(is);
version = p.getProperty("version", "");
}
} catch(IOException e) {
// ignore
}
return version;
}
}

View file

@ -0,0 +1,14 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<body>
Top level package for JInput.
<h2>Package Specification</h2>
Use -Djinput.useDefaultPlugin=false (or net.java.games.input.useDefaultPlugin=false) to disable automatic loading of the default plugin for the platform.<BR/>
Use -Djinput.plugins (or net.java.games.input.plugins) and specifiy a list of class name to over ride the plugins system. This will force the classes passed to be loaded first, then plugins will be searched for in the default manner (./controller/*.jar)<BR/>
Use -Djinput.controllerPluginPath to change the path the plugins mechanism will use to search for plugin Jars.
Use -Djinput.loglevel to change the logging level using Java util logging level strings.
</body>
</html>

6
docs/_config.yml Normal file
View file

@ -0,0 +1,6 @@
title: JInput
description: Java library for access to input devices.
show_downloads: true
google_analytics:
theme: jekyll-theme-architect
jinput_version: 2.0.9

93
docs/index.md Normal file
View file

@ -0,0 +1,93 @@
---
layout: default
---
[![Maven Central](https://img.shields.io/maven-central/v/net.java.jinput/coreapi.svg)](https://maven-badges.herokuapp.com/maven-central/net.java.jinput/coreapi)
[![Javadocs](http://www.javadoc.io/badge/net.java.jinput/coreapi.svg)](http://www.javadoc.io/doc/net.java.jinput/coreapi)
# Welcome to the Java Input API Project!
<p>The JInput Project hosts an implementation of an API for game controller
discovery and polled input. It is part of a suite of open-source technologies
initiated by the Game Technology Group at Sun Microsystems with intention of
making the development of high performance games in Java a reality.</p>
<p>The API itself is pure Java and presents a platform-neutral
completely portable model of controller discovery and polling.
It can handle arbitrary controllers and returns both human and
machine understandable descriptions of the inputs available.</p>
<p>The implementation hosted here also includes plug-ins to allow
the API to adapt to various specific platforms. These plug-ins
often contain a native code portion to interface to the host system.
</p>
## Getting Started
### Maven
Include the dependency in your project:
```xml
<dependency>
<groupId>net.java.jinput</groupId>
<artifactId>jinput</artifactId>
<version>{{site.jinput_version}}</version>
</dependency>
<dependency>
<groupId>net.java.jinput</groupId>
<artifactId>jinput</artifactId>
<version>{{site.jinput_version}}</version>
<classifier>natives-all</classifier>
</dependency>
```
You'll also need to add the build plugin in your `build/plugins` section of your pom
```xml
<plugin>
<groupId>com.googlecode.mavennatives</groupId>
<artifactId>maven-nativedependencies-plugin</artifactId>
</plugin>
```
A full pom might look like [this one](https://github.com/jinput/jinput/blob/master/examples/example.pom.xml)
### Without maven
The jar file with the java code in should be in maven central, you'll need the [jinput.jar](http://repo1.maven.org/maven2/net/java/jinput/jinput/{{site.jinput_version}}/jinput-{{site.jinput_version}}.jar) and [jinput-natives-all.jar](http://repo1.maven.org/maven2/net/java/jinput/jinput/{{site.jinput_version}}/jinput-{{site.jinput_version}}-natives-all.jar) that contains the native binaries.
## Running
Add the jinput jar to your classpath, if you are using maven and have the native dependencies plugin working, it will have unpacked the native binaries to `target/natives`, you must specify the `java.library.path` property to point to this directy.
Example
```
java -cp ~/.m2/repository/net/java/jinput/jinput/{{site.jinput_version}}/jinput-{{site.jinput_version}}.jar:target/examples-pom-{{site.jinput_version}}.jar -Djava.library.path=target/natives net.java.games.input.example.ReadFirstMouse
```
More generally
```
java -cp <path to jinput.jar>:<your own jars> -Djava.library.path=<path to natives> <main class>
```
## Usage
```java
/* Create an event object for the underlying plugin to populate */
Event event = new Event();
/* Get the available controllers */
Controller[] controllers = ControllerEnvironment.getDefaultEnvironment().getControllers();
for (int i = 0; i < controllers.length; i++) {
/* Remember to poll each one */
controllers[i].poll();
/* Get the controllers event queue */
EventQueue queue = controllers[i].getEventQueue();
/* For each object in the queue */
while (queue.getNextEvent(event)) {
/* Get event component */
Component comp = event.getComponent();
/* Process event (your awesome code) */
...
}
}
```
[More examples here](https://github.com/jinput/jinput/tree/master/examples/src/main/java/net/java/games/input/example).

77
examples/example.pom.xml Normal file
View file

@ -0,0 +1,77 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>net.java.jinput</groupId>
<artifactId>examples-pom</artifactId>
<packaging>jar</packaging>
<name>JInput - example pom</name>
<version>2.0.9</version>
<repositories>
<repository>
<id>central-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>net.java.jinput</groupId>
<artifactId>jinput</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.java.jinput</groupId>
<artifactId>jinput</artifactId>
<version>${project.version}</version>
<classifier>natives-all</classifier>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.googlecode.mavennatives</groupId>
<artifactId>maven-nativedependencies-plugin</artifactId>
<version>0.0.7</version>
<executions>
<execution>
<id>unpacknatives</id>
<goals>
<goal>copy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>-Djava.library.path=${project.build.directory}/natives</argument>
<argument>-Djinput.loglevel=OFF</argument>
<argument>net.java.games.input.example.ReadAllEvents</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</project>

78
examples/pom.xml Normal file
View file

@ -0,0 +1,78 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<artifactId>examples</artifactId>
<packaging>jar</packaging>
<name>JInput - examples</name>
<parent>
<groupId>net.java.jinput</groupId>
<artifactId>jinput-parent</artifactId>
<version>2.0.10-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<repositories>
<repository>
<id>central-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jinput</artifactId>
<version>${project.version}</version>
<type>pom</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.googlecode.mavennatives</groupId>
<artifactId>maven-nativedependencies-plugin</artifactId>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>ReadAllEvents</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>-Djava.library.path=${project.build.directory}/natives</argument>
<argument>-Djinput.loglevel=OFF</argument>
<argument>net.java.games.input.example.ReadAllEvents</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View file

@ -0,0 +1,92 @@
package net.java.games.input.example;
import net.java.games.input.Component;
import net.java.games.input.Controller;
import net.java.games.input.ControllerEnvironment;
import net.java.games.input.Event;
import net.java.games.input.EventQueue;
/**
* This class shows how to use the event queue system in JInput. It will show
* how to get the controllers, how to get the event queue for a controller, and
* how to read and process events from the queue.
*
* @author Endolf
*/
public class ReadAllEvents {
public ReadAllEvents() {
while (true) {
/* Get the available controllers */
Controller[] controllers = ControllerEnvironment
.getDefaultEnvironment().getControllers();
if (controllers.length == 0) {
System.out.println("Found no controllers.");
System.exit(0);
}
for (int i = 0; i < controllers.length; i++) {
/* Remember to poll each one */
controllers[i].poll();
/* Get the controllers event queue */
EventQueue queue = controllers[i].getEventQueue();
/* Create an event object for the underlying plugin to populate */
Event event = new Event();
/* For each object in the queue */
while (queue.getNextEvent(event)) {
/*
* Create a string buffer and put in it, the controller name,
* the time stamp of the event, the name of the component
* that changed and the new value.
*
* Note that the timestamp is a relative thing, not
* absolute, we can tell what order events happened in
* across controllers this way. We can not use it to tell
* exactly *when* an event happened just the order.
*/
StringBuffer buffer = new StringBuffer(controllers[i]
.getName());
buffer.append(" at ");
buffer.append(event.getNanos()).append(", ");
Component comp = event.getComponent();
buffer.append(comp.getName()).append(" changed to ");
float value = event.getValue();
/*
* Check the type of the component and display an
* appropriate value
*/
if (comp.isAnalog()) {
buffer.append(value);
} else {
if (value == 1.0f) {
buffer.append("On");
} else {
buffer.append("Off");
}
}
System.out.println(buffer.toString());
}
}
/*
* Sleep for 20 milliseconds, in here only so the example doesn't
* thrash the system.
*/
try {
Thread.sleep(20);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public static void main(String[] args) {
new ReadAllEvents();
}
}

View file

@ -0,0 +1,85 @@
package net.java.games.input.example;
import net.java.games.input.Component;
import net.java.games.input.Controller;
import net.java.games.input.ControllerEnvironment;
/**
* This class shows how to read the values in a polling loop for the first mouse
* detected. It will show how to get the available controllers, how to check the
* type of the controller, how to read the components of the controller, and how
* to get the data from the component.
*
* @author Endolf
*/
public class ReadFirstMouse {
public ReadFirstMouse() {
/* Get the available controllers */
Controller[] controllers = ControllerEnvironment
.getDefaultEnvironment().getControllers();
/*
* Loop through the controllers, check the type of each one, and save
* the first mouse we find.
*/
Controller firstMouse = null;
for (int i = 0; i < controllers.length && firstMouse == null; i++) {
if (controllers[i].getType() == Controller.Type.MOUSE) {
// Found a mouse
firstMouse = controllers[i];
}
}
if (firstMouse == null) {
// Couldn't find a mouse
System.out.println("Found no mouse");
System.exit(0);
}
System.out.println("First mouse is: " + firstMouse.getName());
while (true) {
/* Poll the controller */
firstMouse.poll();
/* Get all the axis and buttons */
Component[] components = firstMouse.getComponents();
StringBuffer buffer = new StringBuffer();
/* For each component, get it's name, and it's current value */
for (int i = 0; i < components.length; i++) {
if (i > 0) {
buffer.append(", ");
}
buffer.append(components[i].getName());
buffer.append(": ");
if (components[i].isAnalog()) {
/* Get the value at the last poll of this component */
buffer.append(components[i].getPollData());
} else {
if (components[i].getPollData() == 1.0f) {
buffer.append("On");
} else {
buffer.append("Off");
}
}
}
System.out.println(buffer.toString());
/*
* Sleep for 20 millis, this is just so the example doesn't thrash
* the system.
*/
try {
Thread.sleep(20);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public static void main(String[] args) {
new ReadFirstMouse();
}
}

52
plugins/OSX/build.xml Normal file
View file

@ -0,0 +1,52 @@
<?xml version="1.0" ?>
<project name="OS X Plugin, Native code" basedir="." default="compileNativeJinputLib">
<description>OSX JInput Native Plugin</description>
<target name="init">
<mkdir dir="target/natives/arm64"/>
</target>
<target name="compile">
<apply dir="${dstdir}" executable="${compiler}" os="Mac OS X" skipemptyfilesets="true" failonerror="true" dest="${dstdir}">
<arg line="${cflags} -O2 -Wall -c -fPIC -I${sdkroot}/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers -I../../../../common/src/native -I../../generated-sources/natives/"/>
<mapper type="glob" from="*.c" to="*.o"/>
<fileset dir="src/main/native" includes="*.c"/>
<fileset dir="../common/src/native" includes="*.c"/>
</apply>
</target>
<target name="link">
<apply dir="${objdir}" parallel="true" executable="${linker}" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
<arg line="${linkerflags} -dynamiclib -o ${libname} -framework CoreFoundation -framework IOKit -framework CoreServices -L/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/lib"/>
<fileset dir="${objdir}" includes="*.o"/>
</apply>
<apply dir="${objdir}" executable="strip" os="Mac OS X" failonerror="true">
<arg line="-S -X"/>
<fileset dir="." includes="${libname}"/>
</apply>
</target>
<target name="compileNativeJinputLib" depends="init">
<property name="arm64_sdkroot" location="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"/>
<property name="arm64_flags" value="-isysroot ${arm64_sdkroot} -arch arm64 -mmacosx-version-min=10.5 -I/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/include/ -I/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/include/darwin/"/>
<antcall target="compile">
<param name="dstdir" location="target/natives/arm64"/>
<param name="compiler" value="gcc"/>
<param name="sdkroot" location="${arm64_sdkroot}"/>
<param name="cflags" value="${arm64_flags}"/>
</antcall>
<antcall target="link">
<param name="objdir" location="target/natives/arm64"/>
<param name="libname" value="libjinput-osx-arm64.jnilib"/>
<param name="linker" value="gcc"/>
<param name="linkerflags" value="${arm64_flags}"/>
</antcall>
<apply dir="target/natives" parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true" >
<arg value="-create"/>
<srcfile/>
<arg value="-output"/>
<arg path="target/natives/libjinput-osx.jnilib"/>
<fileset file="target/natives/arm64/libjinput-osx-arm64.jnilib"/>
</apply>
</target>
</project>

69
plugins/OSX/pom.xml Normal file
View file

@ -0,0 +1,69 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<artifactId>osx-plugin</artifactId>
<packaging>jar</packaging>
<name>JInput - OSX Plugin</name>
<parent>
<groupId>net.java.jinput</groupId>
<artifactId>plugins</artifactId>
<version>2.0.10-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>net.java.jinput</groupId>
<artifactId>coreapi</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<!-- <plugin> -->
<!-- <artifactId>maven-javadoc-plugin</artifactId> -->
<!-- </plugin> -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<target>
<ant dir="." target="compileNativeJinputLib"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classesDirectory>${project.build.directory}/natives</classesDirectory>
<classifier>natives-osx</classifier>
<includes>
<include>*.jnilib</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View file

@ -0,0 +1,135 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*/
package net.java.games.input;
import java.util.Map;
import java.util.HashMap;
/** Button Usages
* @author elias
* @version 1.0
*/
final class ButtonUsage implements Usage {
private final static Map<Integer, ButtonUsage> map = new HashMap<>();
private final int button_id;
public final static ButtonUsage map(int button_id) {
Integer button_id_obj = button_id;
ButtonUsage existing = map.get(button_id_obj);
if (existing != null)
return existing;
ButtonUsage new_button = new ButtonUsage(button_id);
map.put(button_id_obj, new_button);
return new_button;
}
private ButtonUsage(int button_id) {
this.button_id = button_id;
}
public final Component.Identifier.Button getIdentifier() {
switch (button_id) {
case 1:
return Component.Identifier.Button._0;
case 2:
return Component.Identifier.Button._1;
case 3:
return Component.Identifier.Button._2;
case 4:
return Component.Identifier.Button._3;
case 5:
return Component.Identifier.Button._4;
case 6:
return Component.Identifier.Button._5;
case 7:
return Component.Identifier.Button._6;
case 8:
return Component.Identifier.Button._7;
case 9:
return Component.Identifier.Button._8;
case 10:
return Component.Identifier.Button._9;
case 11:
return Component.Identifier.Button._10;
case 12:
return Component.Identifier.Button._11;
case 13:
return Component.Identifier.Button._12;
case 14:
return Component.Identifier.Button._13;
case 15:
return Component.Identifier.Button._14;
case 16:
return Component.Identifier.Button._15;
case 17:
return Component.Identifier.Button._16;
case 18:
return Component.Identifier.Button._17;
case 19:
return Component.Identifier.Button._18;
case 20:
return Component.Identifier.Button._19;
case 21:
return Component.Identifier.Button._20;
case 22:
return Component.Identifier.Button._21;
case 23:
return Component.Identifier.Button._22;
case 24:
return Component.Identifier.Button._23;
case 25:
return Component.Identifier.Button._24;
case 26:
return Component.Identifier.Button._25;
case 27:
return Component.Identifier.Button._26;
case 28:
return Component.Identifier.Button._27;
case 29:
return Component.Identifier.Button._28;
case 30:
return Component.Identifier.Button._29;
case 31:
return Component.Identifier.Button._30;
case 32:
return Component.Identifier.Button._31;
default:
return null;
}
}
public final String toString() {
return "ButtonUsage (" + button_id + ")";
}
}

View file

@ -0,0 +1,74 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.lang.reflect.Method;
/** HID Element types
* @author elias
* @version 1.0
*/
final class ElementType {
private final static ElementType[] map = new ElementType[514];
public final static ElementType INPUT_MISC = new ElementType(1);
public final static ElementType INPUT_BUTTON = new ElementType(2);
public final static ElementType INPUT_AXIS = new ElementType(3);
public final static ElementType INPUT_SCANCODES = new ElementType(4);
public final static ElementType OUTPUT = new ElementType(129);
public final static ElementType FEATURE = new ElementType(257);
public final static ElementType COLLECTION = new ElementType(513);
private final int type_id;
public final static ElementType map(int type_id) {
if (type_id < 0 || type_id >= map.length)
return null;
return map[type_id];
}
private ElementType(int type_id) {
map[type_id] = this;
this.type_id = type_id;
}
public final String toString() {
return "ElementType (0x" + Integer.toHexString(type_id) + ")";
}
}

View file

@ -0,0 +1,136 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*/
package net.java.games.input;
/** Generic Desktop Usages
* @author elias
* @version 1.0
*/
final class GenericDesktopUsage implements Usage {
private final static GenericDesktopUsage[] map = new GenericDesktopUsage[0xFF];
public final static GenericDesktopUsage POINTER = new GenericDesktopUsage(0x01); /* Physical Collection */
public final static GenericDesktopUsage MOUSE = new GenericDesktopUsage(0x02); /* Application Collection */
/* 0x03 Reserved */
public final static GenericDesktopUsage JOYSTICK = new GenericDesktopUsage(0x04); /* Application Collection */
public final static GenericDesktopUsage GAME_PAD = new GenericDesktopUsage(0x05); /* Application Collection */
public final static GenericDesktopUsage KEYBOARD = new GenericDesktopUsage(0x06); /* Application Collection */
public final static GenericDesktopUsage KEYPAD = new GenericDesktopUsage(0x07); /* Application Collection */
public final static GenericDesktopUsage MULTI_AXIS_CONTROLLER = new GenericDesktopUsage(0x08); /* Application Collection */
/* 0x09 - 0x2F Reserved */
public final static GenericDesktopUsage X = new GenericDesktopUsage(0x30); /* Dynamic Value */
public final static GenericDesktopUsage Y = new GenericDesktopUsage(0x31); /* Dynamic Value */
public final static GenericDesktopUsage Z = new GenericDesktopUsage(0x32); /* Dynamic Value */
public final static GenericDesktopUsage RX = new GenericDesktopUsage(0x33); /* Dynamic Value */
public final static GenericDesktopUsage RY = new GenericDesktopUsage(0x34); /* Dynamic Value */
public final static GenericDesktopUsage RZ = new GenericDesktopUsage(0x35); /* Dynamic Value */
public final static GenericDesktopUsage SLIDER = new GenericDesktopUsage(0x36); /* Dynamic Value */
public final static GenericDesktopUsage DIAL = new GenericDesktopUsage(0x37); /* Dynamic Value */
public final static GenericDesktopUsage WHEEL = new GenericDesktopUsage(0x38); /* Dynamic Value */
public final static GenericDesktopUsage HATSWITCH = new GenericDesktopUsage(0x39); /* Dynamic Value */
public final static GenericDesktopUsage COUNTED_BUFFER = new GenericDesktopUsage(0x3A); /* Logical Collection */
public final static GenericDesktopUsage BYTE_COUNT = new GenericDesktopUsage(0x3B); /* Dynamic Value */
public final static GenericDesktopUsage MOTION_WAKEUP = new GenericDesktopUsage(0x3C); /* One-Shot Control */
public final static GenericDesktopUsage START = new GenericDesktopUsage(0x3D); /* On/Off Control */
public final static GenericDesktopUsage SELECT = new GenericDesktopUsage(0x3E); /* On/Off Control */
/* 0x3F Reserved */
public final static GenericDesktopUsage VX = new GenericDesktopUsage(0x40); /* Dynamic Value */
public final static GenericDesktopUsage VY = new GenericDesktopUsage(0x41); /* Dynamic Value */
public final static GenericDesktopUsage VZ = new GenericDesktopUsage(0x42); /* Dynamic Value */
public final static GenericDesktopUsage VBRX = new GenericDesktopUsage(0x43); /* Dynamic Value */
public final static GenericDesktopUsage VBRY = new GenericDesktopUsage(0x44); /* Dynamic Value */
public final static GenericDesktopUsage VBRZ = new GenericDesktopUsage(0x45); /* Dynamic Value */
public final static GenericDesktopUsage VNO = new GenericDesktopUsage(0x46); /* Dynamic Value */
/* 0x47 - 0x7F Reserved */
public final static GenericDesktopUsage SYSTEM_CONTROL = new GenericDesktopUsage(0x80); /* Application Collection */
public final static GenericDesktopUsage SYSTEM_POWER_DOWN = new GenericDesktopUsage(0x81); /* One-Shot Control */
public final static GenericDesktopUsage SYSTEM_SLEEP = new GenericDesktopUsage(0x82); /* One-Shot Control */
public final static GenericDesktopUsage SYSTEM_WAKE_UP = new GenericDesktopUsage(0x83); /* One-Shot Control */
public final static GenericDesktopUsage SYSTEM_CONTEXT_MENU = new GenericDesktopUsage(0x84); /* One-Shot Control */
public final static GenericDesktopUsage SYSTEM_MAIN_MENU = new GenericDesktopUsage(0x85); /* One-Shot Control */
public final static GenericDesktopUsage SYSTEM_APP_MENU = new GenericDesktopUsage(0x86); /* One-Shot Control */
public final static GenericDesktopUsage SYSTEM_MENU_HELP = new GenericDesktopUsage(0x87); /* One-Shot Control */
public final static GenericDesktopUsage SYSTEM_MENU_EXIT = new GenericDesktopUsage(0x88); /* One-Shot Control */
public final static GenericDesktopUsage SYSTEM_MENU = new GenericDesktopUsage(0x89); /* Selector */
public final static GenericDesktopUsage SYSTEM_MENU_RIGHT = new GenericDesktopUsage(0x8A); /* Re-Trigger Control */
public final static GenericDesktopUsage SYSTEM_MENU_LEFT = new GenericDesktopUsage(0x8B); /* Re-Trigger Control */
public final static GenericDesktopUsage SYSTEM_MENU_UP = new GenericDesktopUsage(0x8C); /* Re-Trigger Control */
public final static GenericDesktopUsage SYSTEM_MENU_DOWN = new GenericDesktopUsage(0x8D); /* Re-Trigger Control */
/* 0x8E - 0x8F Reserved */
public final static GenericDesktopUsage DPAD_UP = new GenericDesktopUsage(0x90); /* On/Off Control */
public final static GenericDesktopUsage DPAD_DOWN = new GenericDesktopUsage(0x91); /* On/Off Control */
public final static GenericDesktopUsage DPAD_RIGHT = new GenericDesktopUsage(0x92); /* On/Off Control */
public final static GenericDesktopUsage DPAD_LEFT = new GenericDesktopUsage(0x93); /* On/Off Control */
/* 0x94 - 0xFFFF Reserved */
private final int usage_id;
public final static GenericDesktopUsage map(int usage_id) {
if (usage_id < 0 || usage_id >= map.length)
return null;
return map[usage_id];
}
private GenericDesktopUsage(int usage_id) {
map[usage_id] = this;
this.usage_id = usage_id;
}
public final String toString() {
return "GenericDesktopUsage (0x" + Integer.toHexString(usage_id) + ")";
}
public final Component.Identifier getIdentifier() {
if (this == GenericDesktopUsage.X) {
return Component.Identifier.Axis.X;
} else if (this == GenericDesktopUsage.Y) {
return Component.Identifier.Axis.Y;
} else if (this == GenericDesktopUsage.Z || this == GenericDesktopUsage.WHEEL) {
return Component.Identifier.Axis.Z;
} else if (this == GenericDesktopUsage.RX) {
return Component.Identifier.Axis.RX;
} else if (this == GenericDesktopUsage.RY) {
return Component.Identifier.Axis.RY;
} else if (this == GenericDesktopUsage.RZ) {
return Component.Identifier.Axis.RZ;
} else if (this == GenericDesktopUsage.SLIDER) {
return Component.Identifier.Axis.SLIDER;
} else if (this == GenericDesktopUsage.HATSWITCH) {
return Component.Identifier.Axis.POV;
} else if (this == GenericDesktopUsage.SELECT) {
return Component.Identifier.Button.SELECT;
} else
return null;
}
}

View file

@ -0,0 +1,242 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*/
package net.java.games.input;
/** Mapping from Keyboard HID usages to Component.Identifier.Key
* @author elias
* @version 1.0
*/
final class KeyboardUsage implements Usage {
private final static KeyboardUsage[] map = new KeyboardUsage[0xFF];
public static final KeyboardUsage ERRORROLLOVER = new KeyboardUsage(0x01); /* ErrorRollOver */
public static final KeyboardUsage POSTFAIL = new KeyboardUsage(0x02); /* POSTFail */
public static final KeyboardUsage ERRORUNDEFINED = new KeyboardUsage(0x03); /* ErrorUndefined */
public static final KeyboardUsage A = new KeyboardUsage(Component.Identifier.Key.A, 0x04); /* a or A */
public static final KeyboardUsage B = new KeyboardUsage(Component.Identifier.Key.B, 0x05); /* b or B */
public static final KeyboardUsage C = new KeyboardUsage(Component.Identifier.Key.C, 0x06); /* c or C */
public static final KeyboardUsage D = new KeyboardUsage(Component.Identifier.Key.D, 0x07); /* d or D */
public static final KeyboardUsage E = new KeyboardUsage(Component.Identifier.Key.E, 0x08); /* e or E */
public static final KeyboardUsage F = new KeyboardUsage(Component.Identifier.Key.F, 0x09); /* f or F */
public static final KeyboardUsage G = new KeyboardUsage(Component.Identifier.Key.G, 0x0A); /* g or G */
public static final KeyboardUsage H = new KeyboardUsage(Component.Identifier.Key.H, 0x0B); /* h or H */
public static final KeyboardUsage I = new KeyboardUsage(Component.Identifier.Key.I, 0x0C); /* i or I */
public static final KeyboardUsage J = new KeyboardUsage(Component.Identifier.Key.J, 0x0D); /* j or J */
public static final KeyboardUsage K = new KeyboardUsage(Component.Identifier.Key.K, 0x0E); /* k or K */
public static final KeyboardUsage L = new KeyboardUsage(Component.Identifier.Key.L, 0x0F); /* l or L */
public static final KeyboardUsage M = new KeyboardUsage(Component.Identifier.Key.M, 0x10); /* m or M */
public static final KeyboardUsage N = new KeyboardUsage(Component.Identifier.Key.N, 0x11); /* n or N */
public static final KeyboardUsage O = new KeyboardUsage(Component.Identifier.Key.O, 0x12); /* o or O */
public static final KeyboardUsage P = new KeyboardUsage(Component.Identifier.Key.P, 0x13); /* p or P */
public static final KeyboardUsage Q = new KeyboardUsage(Component.Identifier.Key.Q, 0x14); /* q or Q */
public static final KeyboardUsage R = new KeyboardUsage(Component.Identifier.Key.R, 0x15); /* r or R */
public static final KeyboardUsage S = new KeyboardUsage(Component.Identifier.Key.S, 0x16); /* s or S */
public static final KeyboardUsage T = new KeyboardUsage(Component.Identifier.Key.T, 0x17); /* t or T */
public static final KeyboardUsage U = new KeyboardUsage(Component.Identifier.Key.U, 0x18); /* u or U */
public static final KeyboardUsage V = new KeyboardUsage(Component.Identifier.Key.V, 0x19); /* v or V */
public static final KeyboardUsage W = new KeyboardUsage(Component.Identifier.Key.W, 0x1A); /* w or W */
public static final KeyboardUsage X = new KeyboardUsage(Component.Identifier.Key.X, 0x1B); /* x or X */
public static final KeyboardUsage Y = new KeyboardUsage(Component.Identifier.Key.Y, 0x1C); /* y or Y */
public static final KeyboardUsage Z = new KeyboardUsage(Component.Identifier.Key.Z, 0x1D); /* z or Z */
public static final KeyboardUsage _1 = new KeyboardUsage(Component.Identifier.Key._1, 0x1E); /* 1 or ! */
public static final KeyboardUsage _2 = new KeyboardUsage(Component.Identifier.Key._2, 0x1F); /* 2 or @ */
public static final KeyboardUsage _3 = new KeyboardUsage(Component.Identifier.Key._3, 0x20); /* 3 or # */
public static final KeyboardUsage _4 = new KeyboardUsage(Component.Identifier.Key._4, 0x21); /* 4 or $ */
public static final KeyboardUsage _5 = new KeyboardUsage(Component.Identifier.Key._5, 0x22); /* 5 or % */
public static final KeyboardUsage _6 = new KeyboardUsage(Component.Identifier.Key._6, 0x23); /* 6 or ^ */
public static final KeyboardUsage _7 = new KeyboardUsage(Component.Identifier.Key._7, 0x24); /* 7 or & */
public static final KeyboardUsage _8 = new KeyboardUsage(Component.Identifier.Key._8, 0x25); /* 8 or * */
public static final KeyboardUsage _9 = new KeyboardUsage(Component.Identifier.Key._9, 0x26); /* 9 or ( */
public static final KeyboardUsage _0 = new KeyboardUsage(Component.Identifier.Key._0, 0x27); /* 0 or ) */
public static final KeyboardUsage ENTER = new KeyboardUsage(Component.Identifier.Key.RETURN, 0x28); /* Return (Enter) */
public static final KeyboardUsage ESCAPE = new KeyboardUsage(Component.Identifier.Key.ESCAPE, 0x29); /* Escape */
public static final KeyboardUsage BACKSPACE = new KeyboardUsage(Component.Identifier.Key.BACK, 0x2A); /* Delete (Backspace) */
public static final KeyboardUsage TAB = new KeyboardUsage(Component.Identifier.Key.TAB, 0x2B); /* Tab */
public static final KeyboardUsage SPACEBAR = new KeyboardUsage(Component.Identifier.Key.SPACE, 0x2C); /* Spacebar */
public static final KeyboardUsage HYPHEN = new KeyboardUsage(Component.Identifier.Key.MINUS, 0x2D); /* - or _ */
public static final KeyboardUsage EQUALSIGN = new KeyboardUsage(Component.Identifier.Key.EQUALS, 0x2E); /* = or + */
public static final KeyboardUsage OPENBRACKET = new KeyboardUsage(Component.Identifier.Key.LBRACKET, 0x2F); /* [ or { */
public static final KeyboardUsage CLOSEBRACKET = new KeyboardUsage(Component.Identifier.Key.RBRACKET, 0x30); /* ] or } */
public static final KeyboardUsage BACKSLASH = new KeyboardUsage(Component.Identifier.Key.BACKSLASH, 0x31); /* \ or | */
public static final KeyboardUsage NONUSPOUNT = new KeyboardUsage(Component.Identifier.Key.PERIOD, 0x32); /* Non-US # or _ */
public static final KeyboardUsage SEMICOLON = new KeyboardUsage(Component.Identifier.Key.SEMICOLON, 0x33); /* ; or : */
public static final KeyboardUsage QUOTE = new KeyboardUsage(Component.Identifier.Key.APOSTROPHE, 0x34); /* ' or " */
public static final KeyboardUsage TILDE = new KeyboardUsage(Component.Identifier.Key.GRAVE, 0x35); /* Grave Accent and Tilde */
public static final KeyboardUsage COMMA = new KeyboardUsage(Component.Identifier.Key.COMMA, 0x36); /* , or < */
public static final KeyboardUsage PERIOD = new KeyboardUsage(Component.Identifier.Key.PERIOD, 0x37); /* . or > */
public static final KeyboardUsage SLASH = new KeyboardUsage(Component.Identifier.Key.SLASH, 0x38); /* / or ? */
public static final KeyboardUsage CAPSLOCK = new KeyboardUsage(Component.Identifier.Key.CAPITAL, 0x39); /* Caps Lock */
public static final KeyboardUsage F1 = new KeyboardUsage(Component.Identifier.Key.F1, 0x3A); /* F1 */
public static final KeyboardUsage F2 = new KeyboardUsage(Component.Identifier.Key.F2, 0x3B); /* F2 */
public static final KeyboardUsage F3 = new KeyboardUsage(Component.Identifier.Key.F3, 0x3C); /* F3 */
public static final KeyboardUsage F4 = new KeyboardUsage(Component.Identifier.Key.F4, 0x3D); /* F4 */
public static final KeyboardUsage F5 = new KeyboardUsage(Component.Identifier.Key.F5, 0x3E); /* F5 */
public static final KeyboardUsage F6 = new KeyboardUsage(Component.Identifier.Key.F6, 0x3F); /* F6 */
public static final KeyboardUsage F7 = new KeyboardUsage(Component.Identifier.Key.F7, 0x40); /* F7 */
public static final KeyboardUsage F8 = new KeyboardUsage(Component.Identifier.Key.F8, 0x41); /* F8 */
public static final KeyboardUsage F9 = new KeyboardUsage(Component.Identifier.Key.F9, 0x42); /* F9 */
public static final KeyboardUsage F10 = new KeyboardUsage(Component.Identifier.Key.F10, 0x43); /* F10 */
public static final KeyboardUsage F11 = new KeyboardUsage(Component.Identifier.Key.F11, 0x44); /* F11 */
public static final KeyboardUsage F12 = new KeyboardUsage(Component.Identifier.Key.F12, 0x45); /* F12 */
public static final KeyboardUsage PRINTSCREEN = new KeyboardUsage(Component.Identifier.Key.SYSRQ, 0x46); /* PrintScreen */
public static final KeyboardUsage SCROLLLOCK = new KeyboardUsage(Component.Identifier.Key.SCROLL, 0x47); /* Scroll Lock */
public static final KeyboardUsage PAUSE = new KeyboardUsage(Component.Identifier.Key.PAUSE, 0x48); /* Pause */
public static final KeyboardUsage INSERT = new KeyboardUsage(Component.Identifier.Key.INSERT, 0x49); /* Insert */
public static final KeyboardUsage HOME = new KeyboardUsage(Component.Identifier.Key.HOME, 0x4A); /* Home */
public static final KeyboardUsage PAGEUP = new KeyboardUsage(Component.Identifier.Key.PAGEUP, 0x4B); /* Page Up */
public static final KeyboardUsage DELETE = new KeyboardUsage(Component.Identifier.Key.DELETE, 0x4C); /* Delete Forward */
public static final KeyboardUsage END = new KeyboardUsage(Component.Identifier.Key.END, 0x4D); /* End */
public static final KeyboardUsage PAGEDOWN = new KeyboardUsage(Component.Identifier.Key.PAGEDOWN, 0x4E); /* Page Down */
public static final KeyboardUsage RIGHTARROW = new KeyboardUsage(Component.Identifier.Key.RIGHT, 0x4F); /* Right Arrow */
public static final KeyboardUsage LEFTARROW = new KeyboardUsage(Component.Identifier.Key.LEFT, 0x50); /* Left Arrow */
public static final KeyboardUsage DOWNARROW = new KeyboardUsage(Component.Identifier.Key.DOWN, 0x51); /* Down Arrow */
public static final KeyboardUsage UPARROW = new KeyboardUsage(Component.Identifier.Key.UP, 0x52); /* Up Arrow */
public static final KeyboardUsage KEYPAD_NUMLOCK = new KeyboardUsage(Component.Identifier.Key.NUMLOCK, 0x53); /* Keypad NumLock or Clear */
public static final KeyboardUsage KEYPAD_SLASH = new KeyboardUsage(Component.Identifier.Key.DIVIDE, 0x54); /* Keypad / */
public static final KeyboardUsage KEYPAD_ASTERICK = new KeyboardUsage(0x55); /* Keypad * */
public static final KeyboardUsage KEYPAD_HYPHEN = new KeyboardUsage(Component.Identifier.Key.SUBTRACT, 0x56); /* Keypad - */
public static final KeyboardUsage KEYPAD_PLUS = new KeyboardUsage(Component.Identifier.Key.ADD, 0x57); /* Keypad + */
public static final KeyboardUsage KEYPAD_ENTER = new KeyboardUsage(Component.Identifier.Key.NUMPADENTER, 0x58); /* Keypad Enter */
public static final KeyboardUsage KEYPAD_1 = new KeyboardUsage(Component.Identifier.Key.NUMPAD1, 0x59); /* Keypad 1 or End */
public static final KeyboardUsage KEYPAD_2 = new KeyboardUsage(Component.Identifier.Key.NUMPAD2, 0x5A); /* Keypad 2 or Down Arrow */
public static final KeyboardUsage KEYPAD_3 = new KeyboardUsage(Component.Identifier.Key.NUMPAD3, 0x5B); /* Keypad 3 or Page Down */
public static final KeyboardUsage KEYPAD_4 = new KeyboardUsage(Component.Identifier.Key.NUMPAD4, 0x5C); /* Keypad 4 or Left Arrow */
public static final KeyboardUsage KEYPAD_5 = new KeyboardUsage(Component.Identifier.Key.NUMPAD5, 0x5D); /* Keypad 5 */
public static final KeyboardUsage KEYPAD_6 = new KeyboardUsage(Component.Identifier.Key.NUMPAD6, 0x5E); /* Keypad 6 or Right Arrow */
public static final KeyboardUsage KEYPAD_7 = new KeyboardUsage(Component.Identifier.Key.NUMPAD7, 0x5F); /* Keypad 7 or Home */
public static final KeyboardUsage KEYPAD_8 = new KeyboardUsage(Component.Identifier.Key.NUMPAD8, 0x60); /* Keypad 8 or Up Arrow */
public static final KeyboardUsage KEYPAD_9 = new KeyboardUsage(Component.Identifier.Key.NUMPAD9, 0x61); /* Keypad 9 or Page Up */
public static final KeyboardUsage KEYPAD_0 = new KeyboardUsage(Component.Identifier.Key.NUMPAD0, 0x62); /* Keypad 0 or Insert */
public static final KeyboardUsage KEYPAD_PERIOD = new KeyboardUsage(Component.Identifier.Key.DECIMAL, 0x63); /* Keypad . or Delete */
public static final KeyboardUsage NONUSBACKSLASH = new KeyboardUsage(Component.Identifier.Key.BACKSLASH, 0x64); /* Non-US \ or | */
public static final KeyboardUsage APPLICATION = new KeyboardUsage(Component.Identifier.Key.APPS, 0x65); /* Application */
public static final KeyboardUsage POWER = new KeyboardUsage(Component.Identifier.Key.POWER, 0x66); /* Power */
public static final KeyboardUsage KEYPAD_EQUALSIGN = new KeyboardUsage(Component.Identifier.Key.NUMPADEQUAL, 0x67); /* Keypad = */
public static final KeyboardUsage F13 = new KeyboardUsage(Component.Identifier.Key.F13, 0x68); /* F13 */
public static final KeyboardUsage F14 = new KeyboardUsage(Component.Identifier.Key.F14, 0x69); /* F14 */
public static final KeyboardUsage F15 = new KeyboardUsage(Component.Identifier.Key.F15, 0x6A); /* F15 */
public static final KeyboardUsage F16 = new KeyboardUsage(0x6B); /* F16 */
public static final KeyboardUsage F17 = new KeyboardUsage(0x6C); /* F17 */
public static final KeyboardUsage F18 = new KeyboardUsage(0x6D); /* F18 */
public static final KeyboardUsage F19 = new KeyboardUsage(0x6E); /* F19 */
public static final KeyboardUsage F20 = new KeyboardUsage(0x6F); /* F20 */
public static final KeyboardUsage F21 = new KeyboardUsage(0x70); /* F21 */
public static final KeyboardUsage F22 = new KeyboardUsage(0x71); /* F22 */
public static final KeyboardUsage F23 = new KeyboardUsage(0x72); /* F23 */
public static final KeyboardUsage F24 = new KeyboardUsage(0x73); /* F24 */
public static final KeyboardUsage EXECUTE = new KeyboardUsage(0x74); /* Execute */
public static final KeyboardUsage HELP = new KeyboardUsage(0x75); /* Help */
public static final KeyboardUsage MENU = new KeyboardUsage(0x76); /* Menu */
public static final KeyboardUsage SELECT = new KeyboardUsage(0x77); /* Select */
public static final KeyboardUsage STOP = new KeyboardUsage(Component.Identifier.Key.STOP, 0x78); /* Stop */
public static final KeyboardUsage AGAIN = new KeyboardUsage(0x79); /* Again */
public static final KeyboardUsage UNDO = new KeyboardUsage(0x7A); /* Undo */
public static final KeyboardUsage CUT = new KeyboardUsage(0x7B); /* Cut */
public static final KeyboardUsage COPY = new KeyboardUsage(0x7C); /* Copy */
public static final KeyboardUsage PASTE = new KeyboardUsage(0x7D); /* Paste */
public static final KeyboardUsage FIND = new KeyboardUsage(0x7E); /* Find */
public static final KeyboardUsage MUTE = new KeyboardUsage(0x7F); /* Mute */
public static final KeyboardUsage VOLUMEUP = new KeyboardUsage(0x80); /* Volume Up */
public static final KeyboardUsage VOLUMEDOWN = new KeyboardUsage(0x81); /* Volume Down */
public static final KeyboardUsage LOCKINGCAPSLOCK = new KeyboardUsage(Component.Identifier.Key.CAPITAL, 0x82); /* Locking Caps Lock */
public static final KeyboardUsage LOCKINGNUMLOCK = new KeyboardUsage(Component.Identifier.Key.NUMLOCK, 0x83); /* Locking Num Lock */
public static final KeyboardUsage LOCKINGSCROLLLOCK = new KeyboardUsage(Component.Identifier.Key.SCROLL, 0x84); /* Locking Scroll Lock */
public static final KeyboardUsage KEYPAD_COMMA = new KeyboardUsage(Component.Identifier.Key.COMMA, 0x85); /* Keypad Comma */
public static final KeyboardUsage KEYPAD_EQUALSSIGNAS400 = new KeyboardUsage(0x86); /* Keypad Equal Sign for AS/400 */
public static final KeyboardUsage INTERNATIONAL1 = new KeyboardUsage(0x87); /* International1 */
public static final KeyboardUsage INTERNATIONAL2 = new KeyboardUsage(0x88); /* International2 */
public static final KeyboardUsage INTERNATIONAL3 = new KeyboardUsage(0x89); /* International3 */
public static final KeyboardUsage INTERNATIONAL4 = new KeyboardUsage(0x8A); /* International4 */
public static final KeyboardUsage INTERNATIONAL5 = new KeyboardUsage(0x8B); /* International5 */
public static final KeyboardUsage INTERNATIONAL6 = new KeyboardUsage(0x8C); /* International6 */
public static final KeyboardUsage INTERNATIONAL7 = new KeyboardUsage(0x8D); /* International7 */
public static final KeyboardUsage INTERNATIONAL8 = new KeyboardUsage(0x8E); /* International8 */
public static final KeyboardUsage INTERNATIONAL9 = new KeyboardUsage(0x8F); /* International9 */
public static final KeyboardUsage LANG1 = new KeyboardUsage(0x90); /* LANG1 */
public static final KeyboardUsage LANG2 = new KeyboardUsage(0x91); /* LANG2 */
public static final KeyboardUsage LANG3 = new KeyboardUsage(0x92); /* LANG3 */
public static final KeyboardUsage LANG4 = new KeyboardUsage(0x93); /* LANG4 */
public static final KeyboardUsage LANG5 = new KeyboardUsage(0x94); /* LANG5 */
public static final KeyboardUsage LANG6 = new KeyboardUsage(0x95); /* LANG6 */
public static final KeyboardUsage LANG7 = new KeyboardUsage(0x96); /* LANG7 */
public static final KeyboardUsage LANG8 = new KeyboardUsage(0x97); /* LANG8 */
public static final KeyboardUsage LANG9 = new KeyboardUsage(0x98); /* LANG9 */
public static final KeyboardUsage ALTERNATEERASE = new KeyboardUsage(0x99); /* AlternateErase */
public static final KeyboardUsage SYSREQORATTENTION = new KeyboardUsage(Component.Identifier.Key.SYSRQ, 0x9A); /* SysReq/Attention */
public static final KeyboardUsage CANCEL = new KeyboardUsage(0x9B); /* Cancel */
public static final KeyboardUsage CLEAR = new KeyboardUsage(0x9C); /* Clear */
public static final KeyboardUsage PRIOR = new KeyboardUsage(Component.Identifier.Key.PAGEUP, 0x9D); /* Prior */
public static final KeyboardUsage RETURN = new KeyboardUsage(Component.Identifier.Key.RETURN, 0x9E); /* Return */
public static final KeyboardUsage SEPARATOR = new KeyboardUsage(0x9F); /* Separator */
public static final KeyboardUsage OUT = new KeyboardUsage(0xA0); /* Out */
public static final KeyboardUsage OPER = new KeyboardUsage(0xA1); /* Oper */
public static final KeyboardUsage CLEARORAGAIN = new KeyboardUsage(0xA2); /* Clear/Again */
public static final KeyboardUsage CRSELORPROPS = new KeyboardUsage(0xA3); /* CrSel/Props */
public static final KeyboardUsage EXSEL = new KeyboardUsage(0xA4); /* ExSel */
/* 0xA5-0xDF Reserved */
public static final KeyboardUsage LEFTCONTROL = new KeyboardUsage(Component.Identifier.Key.LCONTROL, 0xE0); /* Left Control */
public static final KeyboardUsage LEFTSHIFT = new KeyboardUsage(Component.Identifier.Key.LSHIFT, 0xE1); /* Left Shift */
public static final KeyboardUsage LEFTALT = new KeyboardUsage(Component.Identifier.Key.LALT, 0xE2); /* Left Alt */
public static final KeyboardUsage LEFTGUI = new KeyboardUsage(Component.Identifier.Key.LWIN, 0xE3); /* Left GUI */
public static final KeyboardUsage RIGHTCONTROL = new KeyboardUsage(Component.Identifier.Key.RCONTROL, 0xE4); /* Right Control */
public static final KeyboardUsage RIGHTSHIFT = new KeyboardUsage(Component.Identifier.Key.RSHIFT, 0xE5); /* Right Shift */
public static final KeyboardUsage RIGHTALT = new KeyboardUsage(Component.Identifier.Key.RALT, 0xE6); /* Right Alt */
public static final KeyboardUsage RIGHTGUI = new KeyboardUsage(Component.Identifier.Key.RWIN, 0xE7); /* Right GUI */
private final int usage;
private final Component.Identifier.Key identifier;
public final Component.Identifier.Key getIdentifier() {
return identifier;
}
public final static KeyboardUsage map(int usage) {
if (usage < 0 || usage >= map.length)
return null;
return map[usage];
}
private KeyboardUsage(int usage) {
this(Component.Identifier.Key.UNKNOWN, usage);
}
private KeyboardUsage(Component.Identifier.Key id, int usage) {
this.identifier = id;
this.usage = usage;
map[usage] = this;
}
public final String toString() {
return "KeyboardUsage (0x" + Integer.toHexString(usage) + ")";
}
}

View file

@ -0,0 +1,74 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.io.IOException;
/** Represents an OSX AbstractController
* @author elias
* @version 1.0
*/
final class OSXAbstractController extends AbstractController {
private final PortType port;
private final OSXHIDQueue queue;
private final Type type;
protected OSXAbstractController(OSXHIDDevice device, OSXHIDQueue queue, Component[] components, Controller[] children, Rumbler[] rumblers, Type type) {
super(device.getProductName(), components, children, rumblers);
this.queue = queue;
this.type = type;
this.port = device.getPortType();
}
protected final boolean getNextDeviceEvent(Event event) throws IOException {
return OSXControllers.getNextDeviceEvent(event, queue);
}
protected final void setDeviceEventQueueSize(int size) throws IOException {
queue.setQueueDepth(size);
}
public Type getType() {
return type;
}
public final PortType getPortType() {
return port;
}
}

View file

@ -0,0 +1,70 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.io.IOException;
/** Represents an OSX Component
* @author elias
* @version 1.0
*/
class OSXComponent extends AbstractComponent {
private final OSXHIDElement element;
public OSXComponent(Component.Identifier id, OSXHIDElement element) {
super(id.getName(), id);
this.element = element;
}
public final boolean isRelative() {
return element.isRelative();
}
public boolean isAnalog() {
return element.isAnalog();
}
public final OSXHIDElement getElement() {
return element;
}
protected float poll() throws IOException {
return OSXControllers.poll(element);
}
}

View file

@ -0,0 +1,64 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.io.IOException;
/** helper methods for OSX specific Controllers
* @author elias
* @version 1.0
*/
final class OSXControllers {
private final static OSXEvent osx_event = new OSXEvent();
public final static synchronized float poll(OSXHIDElement element) throws IOException {
element.getElementValue(osx_event);
return element.convertValue(osx_event.getValue());
}
/* synchronized to protect osx_event */
public final static synchronized boolean getNextDeviceEvent(Event event, OSXHIDQueue queue) throws IOException {
if (queue.getNextEvent(osx_event)) {
OSXComponent component = queue.mapEvent(osx_event);
event.set(component, component.getElement().convertValue(osx_event.getValue()), osx_event.getNanos());
return true;
} else
return false;
}
}

View file

@ -0,0 +1,261 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*/
package net.java.games.input;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.StringTokenizer;
import net.java.games.util.plugins.Plugin;
import java.security.AccessController;
import java.security.PrivilegedAction;
/** OSX HIDManager implementation
* @author elias
* @author gregorypierce
* @version 1.0
*/
public final class OSXEnvironmentPlugin extends ControllerEnvironment implements Plugin {
private static boolean supported = false;
/**
* Static utility method for loading native libraries.
* It will try to load from either the path given by
* the net.java.games.input.librarypath property
* or through System.loadLibrary().
*
*/
static void loadLibrary(final String lib_name) {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
try {
String lib_path = System.getProperty("net.java.games.input.librarypath");
if (lib_path != null)
System.load(lib_path + File.separator + System.mapLibraryName(lib_name));
else
System.loadLibrary(lib_name);
} catch (UnsatisfiedLinkError e) {
e.printStackTrace();
supported = false;
}
return null;
});
}
static String getPrivilegedProperty(final String property) {
return AccessController.doPrivileged((PrivilegedAction<String>)() -> System.getProperty(property));
}
static String getPrivilegedProperty(final String property, final String default_value) {
return AccessController.doPrivileged((PrivilegedAction<String>)() -> System.getProperty(property, default_value));
}
static {
String osName = getPrivilegedProperty("os.name", "").trim();
if(osName.equals("Mac OS X")) {
// Could check isMacOSXEqualsOrBetterThan in here too.
supported = true;
loadLibrary("jinput-osx");
}
}
private final static boolean isMacOSXEqualsOrBetterThan(int major_required, int minor_required) {
String os_version = System.getProperty("os.version");
StringTokenizer version_tokenizer = new StringTokenizer(os_version, ".");
int major;
int minor;
try {
String major_str = version_tokenizer.nextToken();
String minor_str = version_tokenizer.nextToken();
major = Integer.parseInt(major_str);
minor = Integer.parseInt(minor_str);
} catch (Exception e) {
log("Exception occurred while trying to determine OS version: " + e);
// Best guess, no
return false;
}
return major > major_required || (major == major_required && minor >= minor_required);
}
private final Controller[] controllers;
public OSXEnvironmentPlugin() {
if(isSupported()) {
this.controllers = enumerateControllers();
} else {
this.controllers = new Controller[0];
}
}
public final Controller[] getControllers() {
return controllers;
}
public boolean isSupported() {
return supported;
}
private final static void addElements(OSXHIDQueue queue, List<OSXHIDElement> elements, List<OSXComponent> components, boolean map_mouse_buttons) throws IOException {
Iterator<OSXHIDElement> it = elements.iterator();
while (it.hasNext()) {
OSXHIDElement element = it.next();
Component.Identifier id = element.getIdentifier();
if (id == null)
continue;
if (map_mouse_buttons) {
if (id == Component.Identifier.Button._0) {
id = Component.Identifier.Button.LEFT;
} else if (id == Component.Identifier.Button._1) {
id = Component.Identifier.Button.RIGHT;
} else if (id == Component.Identifier.Button._2) {
id = Component.Identifier.Button.MIDDLE;
}
}
OSXComponent component = new OSXComponent(id, element);
components.add(component);
queue.addElement(element, component);
}
}
private final static Keyboard createKeyboardFromDevice(OSXHIDDevice device, List<OSXHIDElement> elements) throws IOException {
List<OSXComponent> components = new ArrayList<>();
OSXHIDQueue queue = device.createQueue(AbstractController.EVENT_QUEUE_DEPTH);
try {
addElements(queue, elements, components, false);
} catch (IOException e) {
queue.release();
throw e;
}
Component[] components_array = new Component[components.size()];
components.toArray(components_array);
return new OSXKeyboard(device, queue, components_array, new Controller[]{}, new Rumbler[]{});
}
private final static Mouse createMouseFromDevice(OSXHIDDevice device, List<OSXHIDElement> elements) throws IOException {
List<OSXComponent> components = new ArrayList<>();
OSXHIDQueue queue = device.createQueue(AbstractController.EVENT_QUEUE_DEPTH);
try {
addElements(queue, elements, components, true);
} catch (IOException e) {
queue.release();
throw e;
}
Component[] components_array = new Component[components.size()];
components.toArray(components_array);
Mouse mouse = new OSXMouse(device, queue, components_array, new Controller[]{}, new Rumbler[]{});
if (mouse.getPrimaryButton() != null && mouse.getX() != null && mouse.getY() != null) {
return mouse;
} else {
queue.release();
return null;
}
}
private final static AbstractController createControllerFromDevice(OSXHIDDevice device, List<OSXHIDElement> elements, Controller.Type type) throws IOException {
List<OSXComponent> components = new ArrayList<>();
OSXHIDQueue queue = device.createQueue(AbstractController.EVENT_QUEUE_DEPTH);
try {
addElements(queue, elements, components, false);
} catch (IOException e) {
queue.release();
throw e;
}
Component[] components_array = new Component[components.size()];
components.toArray(components_array);
return new OSXAbstractController(device, queue, components_array, new Controller[]{}, new Rumbler[]{}, type);
}
private final static void createControllersFromDevice(OSXHIDDevice device, List<Controller> controllers) throws IOException {
UsagePair usage_pair = device.getUsagePair();
if (usage_pair == null)
return;
List<OSXHIDElement> elements = device.getElements();
if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && (usage_pair.getUsage() == GenericDesktopUsage.MOUSE ||
usage_pair.getUsage() == GenericDesktopUsage.POINTER)) {
Controller mouse = createMouseFromDevice(device, elements);
if (mouse != null)
controllers.add(mouse);
} else if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && (usage_pair.getUsage() == GenericDesktopUsage.KEYBOARD ||
usage_pair.getUsage() == GenericDesktopUsage.KEYPAD)) {
controllers.add(createKeyboardFromDevice(device, elements));
} else if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && usage_pair.getUsage() == GenericDesktopUsage.JOYSTICK) {
controllers.add(createControllerFromDevice(device, elements, Controller.Type.STICK));
} else if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && usage_pair.getUsage() == GenericDesktopUsage.MULTI_AXIS_CONTROLLER) {
controllers.add(createControllerFromDevice(device, elements, Controller.Type.STICK));
} else if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP && usage_pair.getUsage() == GenericDesktopUsage.GAME_PAD) {
controllers.add(createControllerFromDevice(device, elements, Controller.Type.GAMEPAD));
}
}
private final static Controller[] enumerateControllers() {
List<Controller> controllers = new ArrayList<>();
try {
OSXHIDDeviceIterator it = new OSXHIDDeviceIterator();
try {
while (true) {
OSXHIDDevice device;
try {
device = it.next();
if (device == null)
break;
boolean device_used = false;
try {
int old_size = controllers.size();
createControllersFromDevice(device, controllers);
device_used = old_size != controllers.size();
} catch (IOException e) {
log("Failed to create controllers from device: " + device.getProductName());
}
if (!device_used)
device.release();
} catch (IOException e) {
log("Failed to enumerate device: " + e.getMessage());
}
}
} finally {
it.close();
}
} catch (IOException e) {
log("Failed to enumerate devices: " + e.getMessage());
return new Controller[]{};
}
Controller[] controllers_array = new Controller[controllers.size()];
controllers.toArray(controllers_array);
return controllers_array;
}
}

View file

@ -0,0 +1,73 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
/** OSX Event structure corresponding to IOHIDEventStruct
* @author elias
* @version 1.0
*/
class OSXEvent {
private long type;
private long cookie;
private int value;
private long nanos;
public void set(long type, long cookie, int value, long nanos) {
this.type = type;
this.cookie = cookie;
this.value = value;
this.nanos = nanos;
}
public long getType() {
return type;
}
public long getCookie() {
return cookie;
}
public int getValue() {
return value;
}
public long getNanos() {
return nanos;
}
}

View file

@ -0,0 +1,294 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*/
package net.java.games.input;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.Iterator;
import java.util.logging.Logger;
/** OSX HIDManager implementation
* @author elias
* @author gregorypierce
* @version 1.0
*/
final class OSXHIDDevice {
private final static Logger log = Logger.getLogger(OSXHIDDevice.class.getName());
private final static int AXIS_DEFAULT_MIN_VALUE = 0;
private final static int AXIS_DEFAULT_MAX_VALUE = 64*1024;
private final static String kIOHIDTransportKey = "Transport";
private final static String kIOHIDVendorIDKey = "VendorID";
private final static String kIOHIDVendorIDSourceKey = "VendorIDSource";
private final static String kIOHIDProductIDKey = "ProductID";
private final static String kIOHIDVersionNumberKey = "VersionNumber";
private final static String kIOHIDManufacturerKey = "Manufacturer";
private final static String kIOHIDProductKey = "Product";
private final static String kIOHIDSerialNumberKey = "SerialNumber";
private final static String kIOHIDCountryCodeKey = "CountryCode";
private final static String kIOHIDLocationIDKey = "LocationID";
private final static String kIOHIDDeviceUsageKey = "DeviceUsage";
private final static String kIOHIDDeviceUsagePageKey = "DeviceUsagePage";
private final static String kIOHIDDeviceUsagePairsKey = "DeviceUsagePairs";
private final static String kIOHIDPrimaryUsageKey = "PrimaryUsage";
private final static String kIOHIDPrimaryUsagePageKey = "PrimaryUsagePage";
private final static String kIOHIDMaxInputReportSizeKey = "MaxInputReportSize";
private final static String kIOHIDMaxOutputReportSizeKey = "MaxOutputReportSize";
private final static String kIOHIDMaxFeatureReportSizeKey = "MaxFeatureReportSize";
private final static String kIOHIDElementKey = "Elements";
private final static String kIOHIDElementCookieKey = "ElementCookie";
private final static String kIOHIDElementTypeKey = "Type";
private final static String kIOHIDElementCollectionTypeKey = "CollectionType";
private final static String kIOHIDElementUsageKey = "Usage";
private final static String kIOHIDElementUsagePageKey = "UsagePage";
private final static String kIOHIDElementMinKey = "Min";
private final static String kIOHIDElementMaxKey = "Max";
private final static String kIOHIDElementScaledMinKey = "ScaledMin";
private final static String kIOHIDElementScaledMaxKey = "ScaledMax";
private final static String kIOHIDElementSizeKey = "Size";
private final static String kIOHIDElementReportSizeKey = "ReportSize";
private final static String kIOHIDElementReportCountKey = "ReportCount";
private final static String kIOHIDElementReportIDKey = "ReportID";
private final static String kIOHIDElementIsArrayKey = "IsArray";
private final static String kIOHIDElementIsRelativeKey = "IsRelative";
private final static String kIOHIDElementIsWrappingKey = "IsWrapping";
private final static String kIOHIDElementIsNonLinearKey = "IsNonLinear";
private final static String kIOHIDElementHasPreferredStateKey = "HasPreferredState";
private final static String kIOHIDElementHasNullStateKey = "HasNullState";
private final static String kIOHIDElementUnitKey = "Unit";
private final static String kIOHIDElementUnitExponentKey = "UnitExponent";
private final static String kIOHIDElementNameKey = "Name";
private final static String kIOHIDElementValueLocationKey = "ValueLocation";
private final static String kIOHIDElementDuplicateIndexKey = "DuplicateIndex";
private final static String kIOHIDElementParentCollectionKey = "ParentCollection";
private final long device_address;
private final long device_interface_address;
private final Map<String,?> properties;
private boolean released;
public OSXHIDDevice(long device_address, long device_interface_address) throws IOException {
this.device_address = device_address;
this.device_interface_address = device_interface_address;
this.properties = getDeviceProperties();
open();
}
public final Controller.PortType getPortType() {
String transport = (String)properties.get(kIOHIDTransportKey);
if (transport == null)
return Controller.PortType.UNKNOWN;
if (transport.equals("USB")) {
return Controller.PortType.USB;
} else {
return Controller.PortType.UNKNOWN;
}
}
public final String getProductName() {
return (String)properties.get(kIOHIDProductKey);
}
private final OSXHIDElement createElementFromElementProperties(Map<String,?> element_properties) {
/* long size = getLongFromProperties(element_properties, kIOHIDElementSizeKey);
// ignore elements that can't fit into the 32 bit value field of a hid event
if (size > 32)
return null;*/
long element_cookie = getLongFromProperties(element_properties, kIOHIDElementCookieKey);
int element_type_id = getIntFromProperties(element_properties, kIOHIDElementTypeKey);
ElementType element_type = ElementType.map(element_type_id);
int min = (int)getLongFromProperties(element_properties, kIOHIDElementMinKey, AXIS_DEFAULT_MIN_VALUE);
int max = (int)getLongFromProperties(element_properties, kIOHIDElementMaxKey, AXIS_DEFAULT_MAX_VALUE);
/* long scaled_min = getLongFromProperties(element_properties, kIOHIDElementScaledMinKey, Long.MIN_VALUE);
long scaled_max = getLongFromProperties(element_properties, kIOHIDElementScaledMaxKey, Long.MAX_VALUE);*/
UsagePair device_usage_pair = getUsagePair();
boolean default_relative = device_usage_pair != null && (device_usage_pair.getUsage() == GenericDesktopUsage.POINTER || device_usage_pair.getUsage() == GenericDesktopUsage.MOUSE);
boolean is_relative = getBooleanFromProperties(element_properties, kIOHIDElementIsRelativeKey, default_relative);
/* boolean is_wrapping = getBooleanFromProperties(element_properties, kIOHIDElementIsWrappingKey);
boolean is_non_linear = getBooleanFromProperties(element_properties, kIOHIDElementIsNonLinearKey);
boolean has_preferred_state = getBooleanFromProperties(element_properties, kIOHIDElementHasPreferredStateKey);
boolean has_null_state = getBooleanFromProperties(element_properties, kIOHIDElementHasNullStateKey);*/
int usage = getIntFromProperties(element_properties, kIOHIDElementUsageKey);
int usage_page = getIntFromProperties(element_properties, kIOHIDElementUsagePageKey);
UsagePair usage_pair = createUsagePair(usage_page, usage);
if (usage_pair == null || (element_type != ElementType.INPUT_MISC && element_type != ElementType.INPUT_BUTTON && element_type != ElementType.INPUT_AXIS)) {
//log.info("element_type = 0x" + element_type + " | usage = " + usage + " | usage_page = " + usage_page);
return null;
} else {
return new OSXHIDElement(this, usage_pair, element_cookie, element_type, min, max, is_relative);
}
}
@SuppressWarnings("unchecked")
private final void addElements(List<OSXHIDElement> elements, Map<String,?> properties) {
Object[] elements_properties = (Object[])properties.get(kIOHIDElementKey);
if (elements_properties == null)
return;
for (int i = 0; i < elements_properties.length; i++) {
Map<String,?> element_properties = (Map<String,?>)elements_properties[i];
OSXHIDElement element = createElementFromElementProperties(element_properties);
if (element != null) {
elements.add(element);
}
addElements(elements, element_properties);
}
}
public final List<OSXHIDElement> getElements() {
List<OSXHIDElement> elements = new ArrayList<>();
addElements(elements, properties);
return elements;
}
private final static long getLongFromProperties(Map<String,?> properties, String key, long default_value) {
Long long_obj = (Long)properties.get(key);
if (long_obj == null)
return default_value;
return long_obj.longValue();
}
private final static boolean getBooleanFromProperties(Map<String,?> properties, String key, boolean default_value) {
return getLongFromProperties(properties, key, default_value ? 1 : 0) != 0;
}
private final static int getIntFromProperties(Map<String,?> properties, String key) {
return (int)getLongFromProperties(properties, key);
}
private final static long getLongFromProperties(Map<String,?> properties, String key) {
Long long_obj = (Long)properties.get(key);
return long_obj.longValue();
}
private final static UsagePair createUsagePair(int usage_page_id, int usage_id) {
UsagePage usage_page = UsagePage.map(usage_page_id);
if (usage_page != null) {
Usage usage = usage_page.mapUsage(usage_id);
if (usage != null)
return new UsagePair(usage_page, usage);
}
return null;
}
public final UsagePair getUsagePair() {
int usage_page_id = getIntFromProperties(properties, kIOHIDPrimaryUsagePageKey);
int usage_id = getIntFromProperties(properties, kIOHIDPrimaryUsageKey);
return createUsagePair(usage_page_id, usage_id);
}
private final void dumpProperties() {
log.info(toString());
dumpMap("", properties);
}
private final static void dumpArray(String prefix, Object[] array) {
log.info(prefix + "{");
for (int i = 0; i < array.length; i++) {
dumpObject(prefix + "\t", array[i]);
log.info(prefix + ",");
}
log.info(prefix + "}");
}
private final static void dumpMap(String prefix, Map<String,?> map) {
Iterator<String> keys = map.keySet().iterator();
while (keys.hasNext()) {
Object key = keys.next();
Object value = map.get(key);
dumpObject(prefix, key);
dumpObject(prefix + "\t", value);
}
}
@SuppressWarnings("unchecked")
private final static void dumpObject(String prefix, Object obj) {
if (obj instanceof Long) {
Long l = (Long)obj;
log.info(prefix + "0x" + Long.toHexString(l.longValue()));
} else if (obj instanceof Map)
dumpMap(prefix, (Map<String,?>)obj);
else if (obj.getClass().isArray())
dumpArray(prefix, (Object[])obj);
else
log.info(prefix + obj);
}
private final Map<String,?> getDeviceProperties() throws IOException {
return nGetDeviceProperties(device_address);
}
private final static native Map<String,?> nGetDeviceProperties(long device_address) throws IOException;
public final synchronized void release() throws IOException {
try {
close();
} finally {
released = true;
nReleaseDevice(device_address, device_interface_address);
}
}
private final static native void nReleaseDevice(long device_address, long device_interface_address);
public final synchronized void getElementValue(long element_cookie, OSXEvent event) throws IOException {
checkReleased();
nGetElementValue(device_interface_address, element_cookie, event);
}
private final static native void nGetElementValue(long device_interface_address, long element_cookie, OSXEvent event) throws IOException;
public final synchronized OSXHIDQueue createQueue(int queue_depth) throws IOException {
checkReleased();
long queue_address = nCreateQueue(device_interface_address);
return new OSXHIDQueue(queue_address, queue_depth);
}
private final static native long nCreateQueue(long device_interface_address) throws IOException;
private final void open() throws IOException {
nOpen(device_interface_address);
}
private final static native void nOpen(long device_interface_address) throws IOException;
private final void close() throws IOException {
nClose(device_interface_address);
}
private final static native void nClose(long device_interface_address) throws IOException;
private final void checkReleased() throws IOException {
if (released)
throw new IOException();
}
}

View file

@ -0,0 +1,65 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.io.IOException;
/** OSX HIDManager implementation
* @author elias
* @author gregorypierce
* @version 1.0
*/
final class OSXHIDDeviceIterator {
private final long iterator_address;
public OSXHIDDeviceIterator() throws IOException {
this.iterator_address = nCreateIterator();
}
private final static native long nCreateIterator();
public final void close(){
nReleaseIterator(iterator_address);
}
private final static native void nReleaseIterator(long iterator_address);
public final OSXHIDDevice next() throws IOException {
return nNext(iterator_address);
}
private final static native OSXHIDDevice nNext(long iterator_address) throws IOException;
}

View file

@ -0,0 +1,143 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.io.IOException;
/** Represents an OSX HID Element
* @author elias
* @author gregorypierce
* @version 1.0
*/
final class OSXHIDElement {
private final OSXHIDDevice device;
private final UsagePair usage_pair;
private final long element_cookie;
private final ElementType element_type;
private final int min;
private final int max;
private final Component.Identifier identifier;
private final boolean is_relative;
public OSXHIDElement(OSXHIDDevice device, UsagePair usage_pair, long element_cookie, ElementType element_type, int min, int max, boolean is_relative) {
this.device = device;
this.usage_pair = usage_pair;
this.element_cookie = element_cookie;
this.element_type = element_type;
this.min = min;
this.max = max;
this.identifier = computeIdentifier();
this.is_relative = is_relative;
}
private final Component.Identifier computeIdentifier() {
if (usage_pair.getUsagePage() == UsagePage.GENERIC_DESKTOP) {
return ((GenericDesktopUsage)usage_pair.getUsage()).getIdentifier();
} else if (usage_pair.getUsagePage() == UsagePage.BUTTON) {
return ((ButtonUsage)usage_pair.getUsage()).getIdentifier();
} else if (usage_pair.getUsagePage() == UsagePage.KEYBOARD_OR_KEYPAD) {
return ((KeyboardUsage)usage_pair.getUsage()).getIdentifier();
} else
return null;
}
final Component.Identifier getIdentifier() {
return identifier;
}
final long getCookie() {
return element_cookie;
}
final ElementType getType() {
return element_type;
}
final boolean isRelative() {
return is_relative && identifier instanceof Component.Identifier.Axis;
}
final boolean isAnalog() {
return identifier instanceof Component.Identifier.Axis && identifier != Component.Identifier.Axis.POV;
}
private UsagePair getUsagePair() {
return usage_pair;
}
final void getElementValue(OSXEvent event) throws IOException {
device.getElementValue(element_cookie, event);
}
final float convertValue(float value) {
if (identifier == Component.Identifier.Axis.POV) {
switch ((int)value) {
case 0:
return Component.POV.UP;
case 1:
return Component.POV.UP_RIGHT;
case 2:
return Component.POV.RIGHT;
case 3:
return Component.POV.DOWN_RIGHT;
case 4:
return Component.POV.DOWN;
case 5:
return Component.POV.DOWN_LEFT;
case 6:
return Component.POV.LEFT;
case 7:
return Component.POV.UP_LEFT;
case 8:
return Component.POV.OFF;
default:
return Component.POV.OFF;
}
} else if (identifier instanceof Component.Identifier.Axis && !is_relative) {
if (min == max)
return 0;
else if (value > max)
value = max;
else if (value < min)
value = min;
return 2*(value - min)/(max - min) - 1;
} else
return value;
}
}

View file

@ -0,0 +1,135 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*/
package net.java.games.input;
import java.io.IOException;
import java.util.Map;
import java.util.HashMap;
/**
* @author elias
* @version 1.0
*/
final class OSXHIDQueue {
private final Map<Long,OSXComponent> map = new HashMap<>();
private final long queue_address;
private boolean released;
public OSXHIDQueue(long address, int queue_depth) throws IOException {
this.queue_address = address;
try {
createQueue(queue_depth);
} catch (IOException e) {
release();
throw e;
}
}
public final synchronized void setQueueDepth(int queue_depth) throws IOException {
checkReleased();
stop();
close();
createQueue(queue_depth);
}
private final void createQueue(int queue_depth) throws IOException {
open(queue_depth);
try {
start();
} catch (IOException e) {
close();
throw e;
}
}
public final OSXComponent mapEvent(OSXEvent event) {
return map.get(event.getCookie());
}
private final void open(int queue_depth) throws IOException {
nOpen(queue_address, queue_depth);
}
private final static native void nOpen(long queue_address, int queue_depth) throws IOException;
private final void close() throws IOException {
nClose(queue_address);
}
private final static native void nClose(long queue_address) throws IOException;
private final void start() throws IOException {
nStart(queue_address);
}
private final static native void nStart(long queue_address) throws IOException;
private final void stop() throws IOException {
nStop(queue_address);
}
private final static native void nStop(long queue_address) throws IOException;
public final synchronized void release() throws IOException {
if (!released) {
released = true;
try {
stop();
close();
} finally {
nReleaseQueue(queue_address);
}
}
}
private final static native void nReleaseQueue(long queue_address) throws IOException;
public final void addElement(OSXHIDElement element, OSXComponent component) throws IOException {
nAddElement(queue_address, element.getCookie());
map.put(element.getCookie(), component);
}
private final static native void nAddElement(long queue_address, long cookie) throws IOException;
public final void removeElement(OSXHIDElement element) throws IOException {
nRemoveElement(queue_address, element.getCookie());
map.remove(element.getCookie());
}
private final static native void nRemoveElement(long queue_address, long cookie) throws IOException;
public final synchronized boolean getNextEvent(OSXEvent event) throws IOException {
checkReleased();
return nGetNextEvent(queue_address, event);
}
private final static native boolean nGetNextEvent(long queue_address, OSXEvent event) throws IOException;
private final void checkReleased() throws IOException {
if (released)
throw new IOException("Queue is released");
}
}

View file

@ -0,0 +1,68 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.io.IOException;
/** Represents an OSX Keyboard
* @author elias
* @version 1.0
*/
final class OSXKeyboard extends Keyboard {
private final PortType port;
private final OSXHIDQueue queue;
protected OSXKeyboard(OSXHIDDevice device, OSXHIDQueue queue, Component[] components, Controller[] children, Rumbler[] rumblers) {
super(device.getProductName(), components, children, rumblers);
this.queue = queue;
this.port = device.getPortType();
}
protected final boolean getNextDeviceEvent(Event event) throws IOException {
return OSXControllers.getNextDeviceEvent(event, queue);
}
protected final void setDeviceEventQueueSize(int size) throws IOException {
queue.setQueueDepth(size);
}
public final PortType getPortType() {
return port;
}
}

View file

@ -0,0 +1,68 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.io.IOException;
/** Represents an OSX Mouse
* @author elias
* @version 1.0
*/
final class OSXMouse extends Mouse {
private final PortType port;
private final OSXHIDQueue queue;
protected OSXMouse(OSXHIDDevice device, OSXHIDQueue queue, Component[] components, Controller[] children, Rumbler[] rumblers) {
super(device.getProductName(), components, children, rumblers);
this.queue = queue;
this.port = device.getPortType();
}
protected final boolean getNextDeviceEvent(Event event) throws IOException {
return OSXControllers.getNextDeviceEvent(event, queue);
}
protected final void setDeviceEventQueueSize(int size) throws IOException {
queue.setQueueDepth(size);
}
public final PortType getPortType() {
return port;
}
}

View file

@ -0,0 +1,40 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*/
package net.java.games.input;
/** Generic Desktop Usages
* @author elias
* @version 1.0
*/
public interface Usage {
}

View file

@ -0,0 +1,108 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*/
package net.java.games.input;
import java.lang.reflect.Method;
/** HID Usage pages
* @author elias
* @version 1.0
*/
final class UsagePage {
private final static UsagePage[] map = new UsagePage[0xFF];
public final static UsagePage UNDEFINED = new UsagePage(0x00);
public final static UsagePage GENERIC_DESKTOP = new UsagePage(0x01, GenericDesktopUsage.class);
public final static UsagePage SIMULATION = new UsagePage(0x02);
public final static UsagePage VR = new UsagePage(0x03);
public final static UsagePage SPORT = new UsagePage(0x04);
public final static UsagePage GAME = new UsagePage(0x05);
/* Reserved 0x06 */
public final static UsagePage KEYBOARD_OR_KEYPAD = new UsagePage(0x07, KeyboardUsage.class); /* USB Device Class Definition for Human Interface Devices (HID). Note: the usage type for all key codes is Selector (Sel). */
public final static UsagePage LEDS = new UsagePage(0x08);
public final static UsagePage BUTTON = new UsagePage(0x09, ButtonUsage.class);
public final static UsagePage ORDINAL = new UsagePage(0x0A);
public final static UsagePage TELEPHONY = new UsagePage(0x0B);
public final static UsagePage CONSUMER = new UsagePage(0x0C);
public final static UsagePage DIGITIZER = new UsagePage(0x0D);
/* Reserved 0x0E */
public final static UsagePage PID = new UsagePage(0x0F); /* USB Physical Interface Device definitions for force feedback and related devices. */
public final static UsagePage UNICODE = new UsagePage(0x10);
/* Reserved 0x11 - 0x13 */
public final static UsagePage ALPHANUMERIC_DISPLAY = new UsagePage(0x14);
/* Reserved 0x15 - 0x7F */
/* Monitor 0x80 - 0x83 USB Device Class Definition for Monitor Devices */
/* Power 0x84 - 0x87 USB Device Class Definition for Power Devices */
public final static UsagePage POWER_DEVICE = new UsagePage(0x84); /* Power Device Page */
public final static UsagePage BATTERY_SYSTEM = new UsagePage(0x85); /* Battery System Page */
/* Reserved 0x88 - 0x8B */
public final static UsagePage BAR_CODE_SCANNER = new UsagePage(0x8C); /* (Point of Sale) USB Device Class Definition for Bar Code Scanner Devices */
public final static UsagePage SCALE = new UsagePage(0x8D); /* (Point of Sale) USB Device Class Definition for Scale Devices */
/* ReservedPointofSalepages 0x8E - 0X8F */
public final static UsagePage CAMERACONTROL= new UsagePage(0x90); /* USB Device Class Definition for Image Class Devices */
public final static UsagePage ARCADE = new UsagePage(0x91); /* OAAF Definitions for arcade and coinop related Devices */
private final Class<? extends Usage> usage_class;
private final int usage_page_id;
public final static UsagePage map(int page_id) {
if (page_id < 0 || page_id >= map.length)
return null;
return map[page_id];
}
private UsagePage(int page_id, Class<? extends Usage> usage_class) {
map[page_id] = this;
this.usage_class = usage_class;
this.usage_page_id = page_id;
}
private UsagePage(int page_id) {
this(page_id, null);
}
public final String toString() {
return "UsagePage (0x" + Integer.toHexString(usage_page_id) + ")";
}
public final Usage mapUsage(int usage_id) {
if (usage_class == null)
return null;
try {
Method map_method = usage_class.getMethod("map", int.class);
Object result = map_method.invoke(null, usage_id);
return (Usage)result;
} catch (Exception e) {
throw new Error(e);
}
}
}

View file

@ -0,0 +1,76 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
/** Usage/Page pair
* @author elias
* @version 1.0
*/
class UsagePair {
private final UsagePage usage_page;
private final Usage usage;
public UsagePair(UsagePage usage_page, Usage usage) {
this.usage_page = usage_page;
this.usage = usage;
}
public final UsagePage getUsagePage() {
return usage_page;
}
public final Usage getUsage() {
return usage;
}
public final int hashCode() {
return usage.hashCode() ^ usage_page.hashCode();
}
public final boolean equals(Object other) {
if (!(other instanceof UsagePair))
return false;
UsagePair other_pair = (UsagePair)other;
return other_pair.usage.equals(usage) && other_pair.usage_page.equals(usage_page);
}
public final String toString() {
return "UsagePair: (page = " + usage_page + ", usage = " + usage + ")";
}
}

View file

@ -0,0 +1,197 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
#include <CoreServices/CoreServices.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <jni.h>
#include "util.h"
#include "macosxutil.h"
typedef struct {
JNIEnv *env;
jobject map;
} dict_context_t;
typedef struct {
JNIEnv *env;
jobjectArray array;
jsize index;
} array_context_t;
static jobject createObjectFromCFObject(JNIEnv *env, CFTypeRef cfobject);
static jstring createStringFromCFString(JNIEnv *env, CFStringRef cfstring) {
CFIndex unicode_length = CFStringGetLength(cfstring);
CFIndex utf8_length = CFStringGetMaximumSizeForEncoding(unicode_length, kCFStringEncodingUTF8);
// Allocate buffer large enough, plus \0 terminator
char *buffer = (char *)malloc(utf8_length + 1);
if (buffer == NULL)
return NULL;
Boolean result = CFStringGetCString(cfstring, buffer, utf8_length + 1, kCFStringEncodingUTF8);
if (!result) {
free(buffer);
return NULL;
}
jstring str = (*env)->NewStringUTF(env, buffer);
free(buffer);
return str;
}
static jobject createDoubleObjectFromCFNumber(JNIEnv *env, CFNumberRef cfnumber) {
double value;
Boolean result = CFNumberGetValue(cfnumber, kCFNumberDoubleType, &value);
if (!result)
return NULL;
return newJObject(env, "java/lang/Double", "(D)V", (jdouble)value);
}
static jobject createLongObjectFromCFNumber(JNIEnv *env, CFNumberRef cfnumber) {
SInt64 value;
Boolean result = CFNumberGetValue(cfnumber, kCFNumberSInt64Type, &value);
if (!result)
return NULL;
return newJObject(env, "java/lang/Long", "(J)V", (jlong)value);
}
static jobject createNumberFromCFNumber(JNIEnv *env, CFNumberRef cfnumber) {
CFNumberType number_type = CFNumberGetType(cfnumber);
switch (number_type) {
case kCFNumberSInt8Type:
case kCFNumberSInt16Type:
case kCFNumberSInt32Type:
case kCFNumberSInt64Type:
case kCFNumberCharType:
case kCFNumberShortType:
case kCFNumberIntType:
case kCFNumberLongType:
case kCFNumberLongLongType:
case kCFNumberCFIndexType:
return createLongObjectFromCFNumber(env, cfnumber);
case kCFNumberFloat32Type:
case kCFNumberFloat64Type:
case kCFNumberFloatType:
case kCFNumberDoubleType:
return createDoubleObjectFromCFNumber(env, cfnumber);
default:
return NULL;
}
}
static void createArrayEntries(const void *value, void *context) {
array_context_t *array_context = (array_context_t *)context;
jobject jval = createObjectFromCFObject(array_context->env, value);
(*array_context->env)->SetObjectArrayElement(array_context->env, array_context->array, array_context->index++, jval);
(*array_context->env)->DeleteLocalRef(array_context->env, jval);
}
static jobject createArrayFromCFArray(JNIEnv *env, CFArrayRef cfarray) {
jclass Object_class = (*env)->FindClass(env, "java/lang/Object");
if (Object_class == NULL)
return NULL;
CFIndex size = CFArrayGetCount(cfarray);
CFRange range = {0, size};
jobjectArray array = (*env)->NewObjectArray(env, size, Object_class, NULL);
array_context_t array_context;
array_context.env = env;
array_context.array = array;
array_context.index = 0;
CFArrayApplyFunction(cfarray, range, createArrayEntries, &array_context);
return array;
}
static jobject createObjectFromCFObject(JNIEnv *env, CFTypeRef cfobject) {
CFTypeID type_id = CFGetTypeID(cfobject);
if (type_id == CFDictionaryGetTypeID()) {
return createMapFromCFDictionary(env, cfobject);
} else if (type_id == CFArrayGetTypeID()) {
return createArrayFromCFArray(env, cfobject);
} else if (type_id == CFStringGetTypeID()) {
return createStringFromCFString(env, cfobject);
} else if (type_id == CFNumberGetTypeID()) {
return createNumberFromCFNumber(env, cfobject);
} else {
return NULL;
}
}
static void createMapKeys(const void *key, const void *value, void *context) {
dict_context_t *dict_context = (dict_context_t *)context;
jclass Map_class = (*dict_context->env)->GetObjectClass(dict_context->env, dict_context->map);
if (Map_class == NULL)
return;
jmethodID map_put = (*dict_context->env)->GetMethodID(dict_context->env, Map_class, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
if (map_put == NULL)
return;
jobject jkey = createObjectFromCFObject(dict_context->env, key);
jobject jvalue = createObjectFromCFObject(dict_context->env, value);
if (jkey == NULL || jvalue == NULL)
return;
(*dict_context->env)->CallObjectMethod(dict_context->env, dict_context->map, map_put, jkey, jvalue);
(*dict_context->env)->DeleteLocalRef(dict_context->env, jkey);
(*dict_context->env)->DeleteLocalRef(dict_context->env, jvalue);
}
jobject createMapFromCFDictionary(JNIEnv *env, CFDictionaryRef dict) {
jobject map = newJObject(env, "java/util/HashMap", "()V");
if (map == NULL)
return NULL;
dict_context_t dict_context;
dict_context.env = env;
dict_context.map = map;
CFDictionaryApplyFunction(dict, createMapKeys, &dict_context);
return map;
}
void copyEvent(JNIEnv *env, IOHIDEventStruct *event, jobject event_return) {
jclass OSXEvent_class = (*env)->GetObjectClass(env, event_return);
if (OSXEvent_class == NULL) {
return;
}
jmethodID OSXEvent_set = (*env)->GetMethodID(env, OSXEvent_class, "set", "(JJIJ)V");
if (OSXEvent_set == NULL) {
return;
}
Nanoseconds nanos = AbsoluteToNanoseconds(event->timestamp);
uint64_t nanos64= *((uint64_t *)&nanos);
(*env)->CallVoidMethod(env, event_return, OSXEvent_set, (jlong)event->type, (jlong)(intptr_t)event->elementCookie, (jint)event->value, (jlong)nanos64);
}

View file

@ -0,0 +1,48 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <jni.h>
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/hid/IOHIDLib.h>
extern jobject createMapFromCFDictionary(JNIEnv *env, CFDictionaryRef dict);
extern void copyEvent(JNIEnv *env, IOHIDEventStruct *event, jobject event_return);

View file

@ -0,0 +1,118 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
#include <IOKit/IOTypes.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/hid/IOHIDLib.h>
#include <IOKit/hid/IOHIDKeys.h>
#include <CoreFoundation/CoreFoundation.h>
#include "net_java_games_input_OSXHIDDevice.h"
#include "util.h"
#include "macosxutil.h"
JNIEXPORT void JNICALL Java_net_java_games_input_OSXHIDDevice_nReleaseDevice(JNIEnv *env, jclass unused, jlong device_address, jlong interface_address) {
io_object_t hidDevice = (io_object_t)device_address;
IOHIDDeviceInterface **device_interface = (IOHIDDeviceInterface **)(intptr_t)interface_address;;
(*device_interface)->Release(device_interface);
IOObjectRelease(hidDevice);
}
JNIEXPORT jobject JNICALL Java_net_java_games_input_OSXHIDDevice_nGetDeviceProperties(JNIEnv *env, jclass unused, jlong device_address) {
io_object_t hidDevice = (io_object_t)device_address;
CFMutableDictionaryRef properties;
kern_return_t result = IORegistryEntryCreateCFProperties(hidDevice,
&properties,
kCFAllocatorDefault,
kNilOptions);
if (result != KERN_SUCCESS) {
throwIOException(env, "Failed to create properties for device (%ld)", result);
return NULL;
}
jobject map = createMapFromCFDictionary(env, properties);
CFRelease(properties);
return map;
}
JNIEXPORT void JNICALL Java_net_java_games_input_OSXHIDDevice_nOpen
(JNIEnv * env, jclass unused, jlong lpDevice) {
IOHIDDeviceInterface **hidDeviceInterface = (IOHIDDeviceInterface **)(intptr_t)lpDevice;
IOReturn ioReturnValue = (*hidDeviceInterface)->open(hidDeviceInterface, 0);
if (ioReturnValue != kIOReturnSuccess) {
throwIOException(env, "Device open failed: %d", ioReturnValue);
}
}
JNIEXPORT void JNICALL Java_net_java_games_input_OSXHIDDevice_nClose
(JNIEnv * env, jclass unused, jlong lpDevice) {
IOHIDDeviceInterface **hidDeviceInterface = (IOHIDDeviceInterface **)(intptr_t)lpDevice;
IOReturn ioReturnValue = (*hidDeviceInterface)->close(hidDeviceInterface);
if (ioReturnValue != kIOReturnSuccess) {
throwIOException(env, "Device close failed: %d", ioReturnValue);
}
}
JNIEXPORT void JNICALL Java_net_java_games_input_OSXHIDDevice_nGetElementValue
(JNIEnv * env, jclass unused, jlong lpDevice, jlong hidCookie, jobject event_return) {
IOHIDDeviceInterface **hidDeviceInterface = (IOHIDDeviceInterface **)(intptr_t)lpDevice;
IOHIDElementCookie cookie = (IOHIDElementCookie)(intptr_t)hidCookie;
IOHIDEventStruct event;
IOReturn ioReturnValue = (*hidDeviceInterface)->getElementValue(hidDeviceInterface, cookie, &event);
if (ioReturnValue != kIOReturnSuccess) {
throwIOException(env, "Device getElementValue failed: %d", ioReturnValue);
return;
}
copyEvent(env, &event, event_return);
if (event.longValue != NULL) {
free(event.longValue);
}
}
JNIEXPORT jlong JNICALL Java_net_java_games_input_OSXHIDDevice_nCreateQueue(JNIEnv *env, jclass unused, jlong device_address) {
IOHIDDeviceInterface **hidDeviceInterface = (IOHIDDeviceInterface **)(intptr_t)device_address;
IOHIDQueueInterface **queue = (*hidDeviceInterface)->allocQueue(hidDeviceInterface);
if (queue == NULL) {
throwIOException(env, "Could not allocate queue");
return 0;
}
return (jlong)(intptr_t)queue;
}

View file

@ -0,0 +1,143 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
#include <IOKit/IOTypes.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/hid/IOHIDLib.h>
#include <IOKit/hid/IOHIDKeys.h>
#include <CoreFoundation/CoreFoundation.h>
#include "net_java_games_input_OSXHIDDeviceIterator.h"
#include "util.h"
JNIEXPORT jlong JNICALL Java_net_java_games_input_OSXHIDDeviceIterator_nCreateIterator(JNIEnv *env, jclass unused) {
io_iterator_t hidObjectIterator;
// Set up a matching dictionary to search the I/O Registry by class
// name for all HID class devices
//
CFMutableDictionaryRef hidMatchDictionary = IOServiceMatching(kIOHIDDeviceKey);
// Now search I/O Registry for matching devices.
// IOServiceGetMatchingServices consumes a reference to the dictionary so we don't have to release it
IOReturn ioReturnValue = IOServiceGetMatchingServices(kIOMasterPortDefault, hidMatchDictionary, &hidObjectIterator);
if (ioReturnValue != kIOReturnSuccess) {
throwIOException(env, "Failed to create iterator (%ld)\n", ioReturnValue);
return 0;
}
if (hidObjectIterator == IO_OBJECT_NULL) {
throwIOException(env, "Failed to create iterator\n");
return 0;
}
return (jlong)hidObjectIterator;
}
JNIEXPORT void JNICALL Java_net_java_games_input_OSXHIDDeviceIterator_nReleaseIterator(JNIEnv *env, jclass unused, jlong address) {
io_iterator_t iterator = (io_iterator_t)address;
IOObjectRelease(iterator);
}
static IOHIDDeviceInterface **createHIDDevice(JNIEnv *env, io_object_t hidDevice) {
// io_name_t className;
IOHIDDeviceInterface **hidDeviceInterface;
IOCFPlugInInterface **plugInInterface;
SInt32 score;
/* ioReturnValue = IOObjectGetClass(hidDevice, className);
if (ioReturnValue != kIOReturnSuccess) {
printfJava(env, "Failed to get IOObject class name.");
}
printfJava(env, "Found device type [%s]\n", className);
*/
IOReturn ioReturnValue = IOCreatePlugInInterfaceForService(hidDevice,
kIOHIDDeviceUserClientTypeID,
kIOCFPlugInInterfaceID,
&plugInInterface,
&score);
if (ioReturnValue != kIOReturnSuccess) {
throwIOException(env, "Couldn't create plugin for device interface (%ld)\n", ioReturnValue);
return NULL;
}
//Call a method of the intermediate plug-in to create the device
//interface
//
HRESULT plugInResult = (*plugInInterface)->QueryInterface(plugInInterface,
CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID),
(LPVOID)&hidDeviceInterface);
(*plugInInterface)->Release(plugInInterface);
if (plugInResult != S_OK) {
throwIOException(env, "Couldn't create HID class device interface (%ld)\n", plugInResult);
return NULL;
}
return hidDeviceInterface;
}
JNIEXPORT jobject JNICALL Java_net_java_games_input_OSXHIDDeviceIterator_nNext(JNIEnv *env, jclass unused, jlong address) {
io_iterator_t iterator = (io_iterator_t)address;
io_object_t hidDevice;
// io_string_t path;
// kern_return_t result;
hidDevice = IOIteratorNext(iterator);
if (hidDevice == MACH_PORT_NULL)
return NULL;
/* IOResult result = IORegistryEntryGetPath(hidDevice, kIOServicePlane, path);
if (result != KERN_SUCCESS) {
IOObjectRelease(hidDevice);
throwIOException("Failed to get device path (%ld)\n", result);
return NULL;
}
*/
IOHIDDeviceInterface **device_interface = createHIDDevice(env, hidDevice);
if (device_interface == NULL) {
IOObjectRelease(hidDevice);
return NULL;
}
jobject device_object = newJObject(env, "net/java/games/input/OSXHIDDevice", "(JJ)V", (jlong)hidDevice, (jlong)(intptr_t)device_interface);
if (device_object == NULL) {
(*device_interface)->Release(device_interface);
IOObjectRelease(hidDevice);
return NULL;
}
return device_object;
}

View file

@ -0,0 +1,135 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
#include <IOKit/IOTypes.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/hid/IOHIDLib.h>
#include <IOKit/hid/IOHIDKeys.h>
#include <CoreFoundation/CoreFoundation.h>
#include "net_java_games_input_OSXHIDQueue.h"
#include "util.h"
#include "macosxutil.h"
JNIEXPORT void JNICALL Java_net_java_games_input_OSXHIDQueue_nOpen(JNIEnv *env, jclass unused, jlong address, jint queue_depth) {
IOHIDQueueInterface **queue = (IOHIDQueueInterface **)(intptr_t)address;
IOReturn ioReturnValue = (*queue)->create(queue, 0, queue_depth);
if (ioReturnValue != kIOReturnSuccess) {
throwIOException(env, "Queue open failed: %d\n", ioReturnValue);
return;
}
}
JNIEXPORT void JNICALL Java_net_java_games_input_OSXHIDQueue_nStart(JNIEnv *env, jclass unused, jlong address) {
IOHIDQueueInterface **queue = (IOHIDQueueInterface **)(intptr_t)address;
IOReturn ioReturnValue = (*queue)->start(queue);
if (ioReturnValue != kIOReturnSuccess) {
throwIOException(env, "Queue start failed: %d\n", ioReturnValue);
return;
}
}
JNIEXPORT void JNICALL Java_net_java_games_input_OSXHIDQueue_nStop(JNIEnv *env, jclass unused, jlong address) {
IOHIDQueueInterface **queue = (IOHIDQueueInterface **)(intptr_t)address;
IOReturn ioReturnValue = (*queue)->stop(queue);
if (ioReturnValue != kIOReturnSuccess) {
throwIOException(env, "Queue stop failed: %d\n", ioReturnValue);
return;
}
}
JNIEXPORT void JNICALL Java_net_java_games_input_OSXHIDQueue_nClose(JNIEnv *env, jclass unused, jlong address) {
IOHIDQueueInterface **queue = (IOHIDQueueInterface **)(intptr_t)address;
IOReturn ioReturnValue = (*queue)->dispose(queue);
if (ioReturnValue != kIOReturnSuccess) {
throwIOException(env, "Queue dispose failed: %d\n", ioReturnValue);
return;
}
}
JNIEXPORT void JNICALL Java_net_java_games_input_OSXHIDQueue_nReleaseQueue(JNIEnv *env, jclass unused, jlong address) {
IOHIDQueueInterface **queue = (IOHIDQueueInterface **)(intptr_t)address;
IOReturn ioReturnValue = (*queue)->Release(queue);
if (ioReturnValue != kIOReturnSuccess) {
throwIOException(env, "Queue Release failed: %d\n", ioReturnValue);
return;
}
}
JNIEXPORT void JNICALL Java_net_java_games_input_OSXHIDQueue_nAddElement(JNIEnv *env, jclass unused, jlong address, jlong cookie_address) {
IOHIDQueueInterface **queue = (IOHIDQueueInterface **)(intptr_t)address;
IOHIDElementCookie cookie = (IOHIDElementCookie)(intptr_t)cookie_address;
IOReturn ioReturnValue = (*queue)->addElement(queue, cookie, 0);
if (ioReturnValue != kIOReturnSuccess) {
throwIOException(env, "Queue addElement failed: %d\n", ioReturnValue);
return;
}
}
JNIEXPORT void JNICALL Java_net_java_games_input_OSXHIDQueue_nRemoveElement(JNIEnv *env, jclass unused, jlong address, jlong cookie_address) {
IOHIDQueueInterface **queue = (IOHIDQueueInterface **)(intptr_t)address;
IOHIDElementCookie cookie = (IOHIDElementCookie)(intptr_t)cookie_address;
IOReturn ioReturnValue = (*queue)->removeElement(queue, cookie);
if (ioReturnValue != kIOReturnSuccess) {
throwIOException(env, "Queue removeElement failed: %d\n", ioReturnValue);
return;
}
}
JNIEXPORT jboolean JNICALL Java_net_java_games_input_OSXHIDQueue_nGetNextEvent(JNIEnv *env, jclass unused, jlong address, jobject event_return) {
IOHIDQueueInterface **queue = (IOHIDQueueInterface **)(intptr_t)address;
IOHIDEventStruct event;
AbsoluteTime zeroTime = {0, 0};
IOReturn ioReturnValue = (*queue)->getNextEvent(queue, &event, zeroTime, 0);
if (ioReturnValue == kIOReturnUnderrun) {
return JNI_FALSE;
} else if (ioReturnValue != kIOReturnSuccess) {
throwIOException(env, "Queue getNextEvent failed: %d\n", ioReturnValue);
return JNI_FALSE;
}
copyEvent(env, &event, event_return);
if (event.longValue != NULL) {
free(event.longValue);
}
return JNI_TRUE;
}

51
plugins/awt/build.xml Normal file
View file

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="all" name="AWT Plugin">
<target name="init">
<mkdir dir="classes"/>
<mkdir dir="bin"/>
</target>
<target depends="init" name="compile">
<javac debug="true" deprecation="true" destdir="classes" source="1.4" target="1.4" srcdir="src">
<classpath>
<pathelement location="../../coreAPI/bin/jinput-core.jar"/>
<pathelement location="../../lib/jutils.jar"/>
</classpath>
</javac>
</target>
<target depends="init,compile" name="jar">
<jar jarfile="bin/awtinput.jar" compress="true" basedir="classes">
<include name="**/*.class"/>
</jar>
</target>
<target depends="jar" description="Build everything." name="all">
</target>
<target name="javadoc" depends="init" description="Javadoc for AWT plugin for JInput.">
<mkdir dir="apidocs"/>
<javadoc packagenames="net.java.games.input.*"
destdir="apidocs"
additionalparam="-source 1.4"
link="../../../coreAPI/apidocs">
<sourcepath>
<pathelement location="src"/>
</sourcepath>
<classpath>
<pathelement location="../../coreAPI/bin/jinput-core.jar"/>
<pathelement location="../../lib/jutils.jar"/>
</classpath>
</javadoc>
</target>
<target description="Clean all build products." name="clean">
<delete failonerror="no">
<fileset dir="classes"/>
</delete>
<delete dir="bin/awtinput.jar" failonerror="no"/>
<delete dir="apidoc" failonerror="no"/>
</target>
</project>

32
plugins/awt/pom.xml Normal file
View file

@ -0,0 +1,32 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<artifactId>awt-plugin</artifactId>
<packaging>jar</packaging>
<name>JInput - AWT Plugin</name>
<parent>
<groupId>net.java.jinput</groupId>
<artifactId>plugins</artifactId>
<version>2.0.10-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>net.java.jinput</groupId>
<artifactId>coreapi</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<!-- <plugin> -->
<!-- <artifactId>maven-javadoc-plugin</artifactId> -->
<!-- </plugin> -->
</plugins>
</build>
</project>

View file

@ -0,0 +1,51 @@
/**
* Copyright (C) 2004 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
import net.java.games.input.Controller;
import net.java.games.input.ControllerEnvironment;
import net.java.games.util.plugins.Plugin;
/**
* @author Jeremy
* @author elias
*/
public class AWTEnvironmentPlugin extends ControllerEnvironment implements Plugin {
private final Controller[] controllers;
public AWTEnvironmentPlugin() {
this.controllers = new Controller[]{new AWTKeyboard(), new AWTMouse()};
}
public Controller[] getControllers() {
return controllers;
}
public boolean isSupported() {
return true;
}
}

View file

@ -0,0 +1,289 @@
/**
* Copyright (C) 2004 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
import java.awt.event.KeyEvent;
/**
* @author Jeremy
* @author elias
*/
final class AWTKeyMap {
public final static Component.Identifier.Key mapKeyCode(int key_code) {
switch (key_code) {
case KeyEvent.VK_0:
return Component.Identifier.Key._0;
case KeyEvent.VK_1:
return Component.Identifier.Key._1;
case KeyEvent.VK_2:
return Component.Identifier.Key._2;
case KeyEvent.VK_3:
return Component.Identifier.Key._3;
case KeyEvent.VK_4:
return Component.Identifier.Key._4;
case KeyEvent.VK_5:
return Component.Identifier.Key._5;
case KeyEvent.VK_6:
return Component.Identifier.Key._6;
case KeyEvent.VK_7:
return Component.Identifier.Key._7;
case KeyEvent.VK_8:
return Component.Identifier.Key._8;
case KeyEvent.VK_9:
return Component.Identifier.Key._9;
case KeyEvent.VK_Q:
return Component.Identifier.Key.Q;
case KeyEvent.VK_W:
return Component.Identifier.Key.W;
case KeyEvent.VK_E:
return Component.Identifier.Key.E;
case KeyEvent.VK_R:
return Component.Identifier.Key.R;
case KeyEvent.VK_T:
return Component.Identifier.Key.T;
case KeyEvent.VK_Y:
return Component.Identifier.Key.Y;
case KeyEvent.VK_U:
return Component.Identifier.Key.U;
case KeyEvent.VK_I:
return Component.Identifier.Key.I;
case KeyEvent.VK_O:
return Component.Identifier.Key.O;
case KeyEvent.VK_P:
return Component.Identifier.Key.P;
case KeyEvent.VK_A:
return Component.Identifier.Key.A;
case KeyEvent.VK_S:
return Component.Identifier.Key.S;
case KeyEvent.VK_D:
return Component.Identifier.Key.D;
case KeyEvent.VK_F:
return Component.Identifier.Key.F;
case KeyEvent.VK_G:
return Component.Identifier.Key.G;
case KeyEvent.VK_H:
return Component.Identifier.Key.H;
case KeyEvent.VK_J:
return Component.Identifier.Key.J;
case KeyEvent.VK_K:
return Component.Identifier.Key.K;
case KeyEvent.VK_L:
return Component.Identifier.Key.L;
case KeyEvent.VK_Z:
return Component.Identifier.Key.Z;
case KeyEvent.VK_X:
return Component.Identifier.Key.X;
case KeyEvent.VK_C:
return Component.Identifier.Key.C;
case KeyEvent.VK_V:
return Component.Identifier.Key.V;
case KeyEvent.VK_B:
return Component.Identifier.Key.B;
case KeyEvent.VK_N:
return Component.Identifier.Key.N;
case KeyEvent.VK_M:
return Component.Identifier.Key.M;
case KeyEvent.VK_F1:
return Component.Identifier.Key.F1;
case KeyEvent.VK_F2:
return Component.Identifier.Key.F2;
case KeyEvent.VK_F3:
return Component.Identifier.Key.F3;
case KeyEvent.VK_F4:
return Component.Identifier.Key.F4;
case KeyEvent.VK_F5:
return Component.Identifier.Key.F5;
case KeyEvent.VK_F6:
return Component.Identifier.Key.F6;
case KeyEvent.VK_F7:
return Component.Identifier.Key.F7;
case KeyEvent.VK_F8:
return Component.Identifier.Key.F8;
case KeyEvent.VK_F9:
return Component.Identifier.Key.F9;
case KeyEvent.VK_F10:
return Component.Identifier.Key.F10;
case KeyEvent.VK_F11:
return Component.Identifier.Key.F11;
case KeyEvent.VK_F12:
return Component.Identifier.Key.F12;
case KeyEvent.VK_ESCAPE:
return Component.Identifier.Key.ESCAPE;
case KeyEvent.VK_MINUS:
return Component.Identifier.Key.MINUS;
case KeyEvent.VK_EQUALS:
return Component.Identifier.Key.EQUALS;
case KeyEvent.VK_BACK_SPACE:
return Component.Identifier.Key.BACKSLASH;
case KeyEvent.VK_TAB:
return Component.Identifier.Key.TAB;
case KeyEvent.VK_OPEN_BRACKET:
return Component.Identifier.Key.LBRACKET;
case KeyEvent.VK_CLOSE_BRACKET:
return Component.Identifier.Key.RBRACKET;
case KeyEvent.VK_SEMICOLON:
return Component.Identifier.Key.SEMICOLON;
case KeyEvent.VK_QUOTE:
return Component.Identifier.Key.APOSTROPHE;
case KeyEvent.VK_NUMBER_SIGN:
return Component.Identifier.Key.GRAVE;
case KeyEvent.VK_BACK_SLASH:
return Component.Identifier.Key.BACKSLASH;
case KeyEvent.VK_PERIOD:
return Component.Identifier.Key.PERIOD;
case KeyEvent.VK_SLASH:
return Component.Identifier.Key.SLASH;
case KeyEvent.VK_MULTIPLY:
return Component.Identifier.Key.MULTIPLY;
case KeyEvent.VK_SPACE:
return Component.Identifier.Key.SPACE;
case KeyEvent.VK_CAPS_LOCK:
return Component.Identifier.Key.CAPITAL;
case KeyEvent.VK_NUM_LOCK:
return Component.Identifier.Key.NUMLOCK;
case KeyEvent.VK_SCROLL_LOCK:
return Component.Identifier.Key.SCROLL;
case KeyEvent.VK_NUMPAD7:
return Component.Identifier.Key.NUMPAD7;
case KeyEvent.VK_NUMPAD8:
return Component.Identifier.Key.NUMPAD8;
case KeyEvent.VK_NUMPAD9:
return Component.Identifier.Key.NUMPAD9;
case KeyEvent.VK_SUBTRACT:
return Component.Identifier.Key.SUBTRACT;
case KeyEvent.VK_NUMPAD4:
return Component.Identifier.Key.NUMPAD4;
case KeyEvent.VK_NUMPAD5:
return Component.Identifier.Key.NUMPAD5;
case KeyEvent.VK_NUMPAD6:
return Component.Identifier.Key.NUMPAD6;
case KeyEvent.VK_ADD:
return Component.Identifier.Key.ADD;
case KeyEvent.VK_NUMPAD1:
return Component.Identifier.Key.NUMPAD1;
case KeyEvent.VK_NUMPAD2:
return Component.Identifier.Key.NUMPAD2;
case KeyEvent.VK_NUMPAD3:
return Component.Identifier.Key.NUMPAD3;
case KeyEvent.VK_NUMPAD0:
return Component.Identifier.Key.NUMPAD0;
case KeyEvent.VK_DECIMAL:
return Component.Identifier.Key.DECIMAL;
case KeyEvent.VK_KANA:
return Component.Identifier.Key.KANA;
case KeyEvent.VK_CONVERT:
return Component.Identifier.Key.CONVERT;
case KeyEvent.VK_NONCONVERT:
return Component.Identifier.Key.NOCONVERT;
case KeyEvent.VK_CIRCUMFLEX:
return Component.Identifier.Key.CIRCUMFLEX;
case KeyEvent.VK_AT:
return Component.Identifier.Key.AT;
case KeyEvent.VK_COLON:
return Component.Identifier.Key.COLON;
case KeyEvent.VK_UNDERSCORE:
return Component.Identifier.Key.UNDERLINE;
case KeyEvent.VK_KANJI:
return Component.Identifier.Key.KANJI;
case KeyEvent.VK_STOP:
return Component.Identifier.Key.STOP;
case KeyEvent.VK_DIVIDE:
return Component.Identifier.Key.DIVIDE;
case KeyEvent.VK_PAUSE:
return Component.Identifier.Key.PAUSE;
case KeyEvent.VK_HOME:
return Component.Identifier.Key.HOME;
case KeyEvent.VK_UP:
return Component.Identifier.Key.UP;
case KeyEvent.VK_PAGE_UP:
return Component.Identifier.Key.PAGEUP;
case KeyEvent.VK_LEFT:
return Component.Identifier.Key.LEFT;
case KeyEvent.VK_RIGHT:
return Component.Identifier.Key.RIGHT;
case KeyEvent.VK_END:
return Component.Identifier.Key.END;
case KeyEvent.VK_DOWN:
return Component.Identifier.Key.DOWN;
case KeyEvent.VK_PAGE_DOWN:
return Component.Identifier.Key.PAGEDOWN;
case KeyEvent.VK_INSERT:
return Component.Identifier.Key.INSERT;
case KeyEvent.VK_DELETE:
return Component.Identifier.Key.DELETE;
default:
return Component.Identifier.Key.UNKNOWN;
}
}
public final static Component.Identifier.Key map(KeyEvent event) {
int key_code = event.getKeyCode();
int key_location = event.getKeyLocation();
switch (key_code) {
case KeyEvent.VK_CONTROL:
if (key_location == KeyEvent.KEY_LOCATION_RIGHT)
return Component.Identifier.Key.RCONTROL;
else
return Component.Identifier.Key.LCONTROL;
case KeyEvent.VK_SHIFT:
if (key_location == KeyEvent.KEY_LOCATION_RIGHT)
return Component.Identifier.Key.RSHIFT;
else
return Component.Identifier.Key.LSHIFT;
case KeyEvent.VK_ALT:
if (key_location == KeyEvent.KEY_LOCATION_RIGHT)
return Component.Identifier.Key.RALT;
else
return Component.Identifier.Key.LALT;
//this is 1.5 only
/* case KeyEvent.VK_WINDOWS:
if (key_location == KeyEvent.KEY_LOCATION_RIGHT)
return Component.Identifier.Key.RWIN;
else
return Component.Identifier.Key.LWIN;*/
case KeyEvent.VK_ENTER:
if (key_location == KeyEvent.KEY_LOCATION_NUMPAD)
return Component.Identifier.Key.NUMPADENTER;
else
return Component.Identifier.Key.RETURN;
case KeyEvent.VK_COMMA:
if (key_location == KeyEvent.KEY_LOCATION_NUMPAD)
return Component.Identifier.Key.NUMPADCOMMA;
else
return Component.Identifier.Key.COMMA;
default:
return mapKeyCode(key_code);
}
}
}

View file

@ -0,0 +1,170 @@
/*
* Copyright (C) 2004 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
import java.awt.AWTEvent;
import java.awt.Toolkit;
import java.awt.event.AWTEventListener;
import java.awt.event.KeyEvent;
import java.util.List;
import java.util.ArrayList;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
/**
* @author Jeremy
* @author elias
*/
final class AWTKeyboard extends Keyboard implements AWTEventListener {
private final List<KeyEvent> awt_events = new ArrayList<>();
private Event[] processed_events;
private int processed_events_index;
protected AWTKeyboard() {
super("AWTKeyboard", createComponents(), new Controller[]{}, new Rumbler[]{});
Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK);
resizeEventQueue(EVENT_QUEUE_DEPTH);
}
private final static Component[] createComponents() {
List<Component> components = new ArrayList<>();
Field[] vkey_fields = KeyEvent.class.getFields();
for (int i = 0; i < vkey_fields.length; i++) {
Field vkey_field = vkey_fields[i];
try {
if (Modifier.isStatic(vkey_field.getModifiers()) && vkey_field.getType() == int.class &&
vkey_field.getName().startsWith("VK_")) {
int vkey_code = vkey_field.getInt(null);
Component.Identifier.Key key_id = AWTKeyMap.mapKeyCode(vkey_code);
if (key_id != Component.Identifier.Key.UNKNOWN)
components.add(new Key(key_id));
}
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
components.add(new Key(Component.Identifier.Key.RCONTROL));
components.add(new Key(Component.Identifier.Key.LCONTROL));
components.add(new Key(Component.Identifier.Key.RSHIFT));
components.add(new Key(Component.Identifier.Key.LSHIFT));
components.add(new Key(Component.Identifier.Key.RALT));
components.add(new Key(Component.Identifier.Key.LALT));
components.add(new Key(Component.Identifier.Key.NUMPADENTER));
components.add(new Key(Component.Identifier.Key.RETURN));
components.add(new Key(Component.Identifier.Key.NUMPADCOMMA));
components.add(new Key(Component.Identifier.Key.COMMA));
return components.toArray(new Component[]{});
}
private final void resizeEventQueue(int size) {
processed_events = new Event[size];
for (int i = 0; i < processed_events.length; i++)
processed_events[i] = new Event();
processed_events_index = 0;
}
protected final void setDeviceEventQueueSize(int size) throws IOException {
resizeEventQueue(size);
}
public final synchronized void eventDispatched(AWTEvent event) {
if (event instanceof KeyEvent)
awt_events.add((KeyEvent)event);
}
public final synchronized void pollDevice() throws IOException {
for (int i = 0; i < awt_events.size(); i++) {
processEvent(awt_events.get(i));
}
awt_events.clear();
}
private final void processEvent(KeyEvent event) {
Component.Identifier.Key key_id = AWTKeyMap.map(event);
if (key_id == null)
return;
Key key = (Key)getComponent(key_id);
if (key == null)
return;
long nanos = event.getWhen()*1000000L;
if (event.getID() == KeyEvent.KEY_PRESSED) {
//the key was pressed
addEvent(key, 1, nanos);
} else if (event.getID() == KeyEvent.KEY_RELEASED) {
KeyEvent nextPress = (KeyEvent)Toolkit.getDefaultToolkit().getSystemEventQueue().peekEvent(KeyEvent.KEY_PRESSED);
if ((nextPress == null) || (nextPress.getWhen() != event.getWhen())) {
//the key came really came up
addEvent(key, 0, nanos);
}
}
}
private final void addEvent(Key key, float value, long nanos) {
key.setValue(value);
if (processed_events_index < processed_events.length)
processed_events[processed_events_index++].set(key, value, nanos);
}
protected final synchronized boolean getNextDeviceEvent(Event event) throws IOException {
if (processed_events_index == 0)
return false;
processed_events_index--;
event.set(processed_events[0]);
Event tmp = processed_events[0];
processed_events[0] = processed_events[processed_events_index];
processed_events[processed_events_index] = tmp;
return true;
}
private final static class Key extends AbstractComponent {
private float value;
public Key(Component.Identifier.Key key_id) {
super(key_id.getName(), key_id);
}
public final void setValue(float value) {
this.value = value;
}
protected final float poll() {
return value;
}
public final boolean isAnalog() {
return false;
}
public final boolean isRelative() {
return false;
}
}
}

View file

@ -0,0 +1,221 @@
/*
* Copyright (C) 2004 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
import java.awt.AWTEvent;
import java.awt.Toolkit;
import java.awt.event.AWTEventListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.util.List;
import java.util.ArrayList;
import java.io.IOException;
/**
* @author Jeremy
* @author elias
*/
final class AWTMouse extends Mouse implements AWTEventListener {
private final static int EVENT_X = 1;
private final static int EVENT_Y = 2;
private final static int EVENT_BUTTON = 4;
private final List<AWTEvent> awt_events = new ArrayList<>();
private final List<AWTEvent> processed_awt_events = new ArrayList<>();
private int event_state = EVENT_X;
protected AWTMouse() {
super("AWTMouse", createComponents(), new Controller[]{}, new Rumbler[]{});
Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK);
}
private final static Component[] createComponents() {
return new Component[]{new Axis(Component.Identifier.Axis.X),
new Axis(Component.Identifier.Axis.Y),
new Axis(Component.Identifier.Axis.Z),
new Button(Component.Identifier.Button.LEFT),
new Button(Component.Identifier.Button.MIDDLE),
new Button(Component.Identifier.Button.RIGHT)};
}
private final void processButtons(int button_enum, float value) {
Button button = getButton(button_enum);
if (button != null)
button.setValue(value);
}
private final Button getButton(int button_enum) {
switch (button_enum) {
case MouseEvent.BUTTON1:
return (Button)getLeft();
case MouseEvent.BUTTON2:
return (Button)getMiddle();
case MouseEvent.BUTTON3:
return (Button)getRight();
case MouseEvent.NOBUTTON:
default:
// Unknown button
return null;
}
}
private final void processEvent(AWTEvent event) throws IOException {
if (event instanceof MouseWheelEvent) {
MouseWheelEvent mwe = (MouseWheelEvent)event;
Axis wheel = (Axis)getWheel();
wheel.setValue(wheel.poll() + mwe.getWheelRotation());
} else if (event instanceof MouseEvent) {
MouseEvent me = (MouseEvent)event;
Axis x = (Axis)getX();
Axis y = (Axis)getY();
x.setValue(me.getX());
y.setValue(me.getY());
switch (me.getID()) {
case MouseEvent.MOUSE_PRESSED:
processButtons(me.getButton(), 1f);
break;
case MouseEvent.MOUSE_RELEASED:
processButtons(me.getButton(), 0f);
break;
default:
break;
}
}
}
public final synchronized void pollDevice() throws IOException {
Axis wheel = (Axis)getWheel();
wheel.setValue(0);
for (int i = 0; i < awt_events.size(); i++) {
AWTEvent event = awt_events.get(i);
processEvent(event);
processed_awt_events.add(event);
}
awt_events.clear();
}
protected final synchronized boolean getNextDeviceEvent(Event event) throws IOException {
while (true) {
if (processed_awt_events.isEmpty())
return false;
AWTEvent awt_event = processed_awt_events.get(0);
if (awt_event instanceof MouseWheelEvent) {
MouseWheelEvent awt_wheel_event = (MouseWheelEvent)awt_event;
long nanos = awt_wheel_event.getWhen()*1000000L;
event.set(getWheel(), awt_wheel_event.getWheelRotation(), nanos);
processed_awt_events.remove(0);
} else if (awt_event instanceof MouseEvent) {
MouseEvent mouse_event = (MouseEvent)awt_event;
long nanos = mouse_event.getWhen()*1000000L;
switch (event_state) {
case EVENT_X:
event_state = EVENT_Y;
event.set(getX(), mouse_event.getX(), nanos);
return true;
case EVENT_Y:
event_state = EVENT_BUTTON;
event.set(getY(), mouse_event.getY(), nanos);
return true;
case EVENT_BUTTON:
processed_awt_events.remove(0);
event_state = EVENT_X;
Button button = getButton(mouse_event.getButton());
if (button != null) {
switch (mouse_event.getID()) {
case MouseEvent.MOUSE_PRESSED:
event.set(button, 1f, nanos);
return true;
case MouseEvent.MOUSE_RELEASED:
event.set(button, 0f, nanos);
return true;
default:
break;
}
}
break;
default:
throw new RuntimeException("Unknown event state: " + event_state);
}
}
}
}
public final synchronized void eventDispatched(AWTEvent event) {
awt_events.add(event);
}
final static class Axis extends AbstractComponent {
private float value;
public Axis(Component.Identifier.Axis axis_id) {
super(axis_id.getName(), axis_id);
}
public final boolean isRelative() {
return false;
}
public final boolean isAnalog() {
return true;
}
protected final void setValue(float value) {
this.value = value;
}
protected final float poll() throws IOException {
return value;
}
}
final static class Button extends AbstractComponent {
private float value;
public Button(Component.Identifier.Button button_id) {
super(button_id.getName(), button_id);
}
protected final void setValue(float value) {
this.value = value;
}
protected final float poll() throws IOException {
return value;
}
public final boolean isAnalog() {
return false;
}
public final boolean isRelative() {
return false;
}
}
}

View file

@ -0,0 +1,118 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#include "util.h"
static jstring sprintfJavaString(JNIEnv *env, const char *format, va_list ap) {
#define BUFFER_SIZE 4000
char buffer[BUFFER_SIZE];
jstring str;
#ifdef _MSC_VER
vsnprintf_s(buffer, BUFFER_SIZE, _TRUNCATE, format, ap);
#else
vsnprintf(buffer, BUFFER_SIZE, format, ap);
#endif
buffer[BUFFER_SIZE - 1] = '\0';
str = (*env)->NewStringUTF(env, buffer);
return str;
}
void printfJava(JNIEnv *env, const char *format, ...) {
jstring str;
jclass org_lwjgl_LWJGLUtil_class;
jmethodID log_method;
va_list ap;
va_start(ap, format);
str = sprintfJavaString(env, format, ap);
va_end(ap);
org_lwjgl_LWJGLUtil_class = (*env)->FindClass(env, "net/java/games/input/ControllerEnvironment");
if (org_lwjgl_LWJGLUtil_class == NULL)
return;
log_method = (*env)->GetStaticMethodID(env, org_lwjgl_LWJGLUtil_class, "log", "(Ljava/lang/String;)V");
if (log_method == NULL)
return;
(*env)->CallStaticVoidMethod(env, org_lwjgl_LWJGLUtil_class, log_method, str);
}
static void throwException(JNIEnv * env, const char *exception_name, const char *format, va_list ap) {
jstring str;
jobject exception;
if ((*env)->ExceptionCheck(env) == JNI_TRUE)
return; // The JVM crashes if we try to throw two exceptions from one native call
str = sprintfJavaString(env, format, ap);
exception = newJObject(env, exception_name, "(Ljava/lang/String;)V", str);
(*env)->Throw(env, exception);
}
void throwRuntimeException(JNIEnv * env, const char *format, ...) {
va_list ap;
va_start(ap, format);
throwException(env, "java/lang/RuntimeException", format, ap);
va_end(ap);
}
void throwIOException(JNIEnv * env, const char *format, ...) {
va_list ap;
va_start(ap, format);
throwException(env, "java/io/IOException", format, ap);
va_end(ap);
}
jobject newJObject(JNIEnv * env, const char *class_name, const char *constructor_signature, ...) {
va_list ap;
jclass clazz;
jmethodID constructor;
jobject obj;
clazz = (*env)->FindClass(env, class_name);
if (clazz == NULL)
return NULL;
constructor = (*env)->GetMethodID(env, clazz, "<init>", constructor_signature);
if (constructor == NULL)
return NULL;
va_start(ap, constructor_signature);
obj = (*env)->NewObjectV(env, clazz, constructor, ap);
va_end(ap);
return obj;
}

View file

@ -0,0 +1,53 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <jni.h>
#ifdef _MSC_VER
#include <Basetsd.h>
#else
#include <inttypes.h>
#endif
extern void printfJava(JNIEnv *env, const char *format, ...);
extern void throwRuntimeException(JNIEnv * env, const char *format, ...);
extern void throwIOException(JNIEnv * env, const char *format, ...);
extern jobject newJObject(JNIEnv * env, const char *class_name, const char *constructor_signature, ...);

View file

@ -1,83 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="all" name="Linux Plugin"> <project basedir="." default="compileNativeJinputLib" name="Linux Plugin">
<property name="libname64" value="libjinput-linux64.so"/>
<property name="libname32" value="libjinput-linux.so"/>
<target name="init"> <target name="init">
<property name="hello" value="world"/> <mkdir dir="target/natives"/>
<mkdir dir="classes"/>
<mkdir dir="bin"/>
</target> </target>
<target depends="init" name="compile"> <target name="createNativeDefinitions.java">
<javac debug="true" deprecation="true" destdir="classes" source="1.4" srcdir="src/java"> <exec dir="src/main/native" executable="gawk" os="Linux" output="../java/net/java/games/input/NativeDefinitions.java">
<classpath> <arg line="-f"/>
<pathelement location="../../coreAPI/bin/jinput.jar"/> <arg line="getDefinitions"/>
<pathelement location="../../coreAPI/lib/jutils.jar"/>
</classpath>
</javac>
</target>
<target depends="init,compile" name="jar">
<jar jarfile="bin/linux.jar" compress="true" basedir="classes">
<exclude name="**/*.java"/>
<exclude name="linux.jar"/>
<exclude name="apidoc"/>
</jar>
<copy file="bin/linux.jar" todir="../../coreAPI/src/tests/controller" />
</target>
<target depends="compileNativeJinputLib,jar" description="Build everything." name="all">
<echo message="Application built. Hello ${hello}!"/>
</target>
<target name="javadoc" depends="init" description="Javadoc for Linux plugin for JInput.">
<mkdir dir="apidocs"/>
<javadoc packagenames="net.java.games.input.*"
destdir="apidocs"
additionalparam="-source 1.4"
link="../../../coreAPI/apidocs">
<sourcepath>
<pathelement location="src/java"/>
</sourcepath>
<classpath>
<pathelement location="../../coreAPI/bin/jinput.jar"/>
<pathelement location="../../coreAPI/lib/jutils.jar"/>
</classpath>
</javadoc>
</target>
<target description="Clean all build products." name="clean">
<delete failonerror="no">
<fileset dir="classes">
<include name="**/*.class"/>
</fileset>
</delete>
<delete file="bin/linux.jar" failonerror="no"/>
<delete file="src/native/libjinput.so" failonerror="no"/>
<delete file="../../coreAPI/src/tests/controller/linux.jar" failonerror="no" />
<delete file="../../coreAPI/src/tests/controller/libjinput.so" failonerror="no"/>
<delete file="apidoc" failonerror="no"/>
</target>
<target depends="init,compile" name="createJNIHeaders">
<javah>
<classpath>
<pathelement path="src/java"/>
<pathelement location="jinput.jar"/>
</classpath>
<class name="net.java.games.input.LinuxDevice"/>
<class name="net.java.games.input.LinuxEnvironmentPlugin"/>
<class name="net.java.games.input.LinuxKeyboard"/>
</javah>
</target>
<target depends="init" name="createNativeDefinitions.java">
<exec dir="." executable="./getDefinitions" os="linux" output="src/java/net/java/games/input/NativeDefinitions.java">
<arg line="/usr/include/linux/input.h"/> <arg line="/usr/include/linux/input.h"/>
</exec> </exec>
</target> </target>
<target depends="init" name="compileNativeJinputLib"> <target depends="init" name="compileNativeJinputLib">
<ant dir="src/native" target="compileNativeJinputLib"/> <exec executable="uname" outputproperty="hwplatform">
<copy file="src/native/libjinput.so" todir="../../coreAPI/src/tests/controller" /> <arg value="-m"/>
</exec>
<condition property="libname" value="${libname64}" else="${libname32}">
<equals arg1="${hwplatform}" arg2="x86_64"/>
</condition>
<apply dir="target/natives" executable="cc" os="Linux" dest="target/natives" skipemptyfilesets="true" failonerror="true">
<arg line="-O2 -Wall -c -fPIC"/>
<arg value="-I${java.home}/include"/>
<arg value="-I${java.home}/include/linux"/>
<arg value="-I${java.home}/../include"/>
<arg value="-I${java.home}/../include/linux"/>
<arg value="-I../../../common/src/native"/>
<arg value="-I../generated-sources/natives"/>
<mapper type="glob" from="*.c" to="*.o"/>
<fileset dir="src/main/native" includes="*.c"/>
<fileset dir="../common/src/native" includes="*.c"/>
</apply>
<apply dir="target/natives" parallel="true" executable="cc" os="Linux" failonerror="true">
<arg line="-shared -O2 -Wall -o ${libname}"/>
<fileset dir="target/natives" includes="*.o"/>
</apply>
<apply dir="target/natives" parallel="true" executable="strip" os="Linux" failonerror="true">
<fileset file="target/natives/${libname}"/>
</apply>
</target> </target>
</project> </project>

69
plugins/linux/pom.xml Normal file
View file

@ -0,0 +1,69 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<artifactId>linux-plugin</artifactId>
<packaging>jar</packaging>
<name>JInput - Linux Plugin</name>
<parent>
<groupId>net.java.jinput</groupId>
<artifactId>plugins</artifactId>
<version>2.0.10-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>net.java.jinput</groupId>
<artifactId>coreapi</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<target>
<ant dir="." target="compileNativeJinputLib"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classesDirectory>${project.build.directory}/natives</classesDirectory>
<classifier>natives-linux</classifier>
<includes>
<include>*.so</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View file

@ -1,192 +0,0 @@
/**
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
import net.java.games.input.AbstractAxis;
import net.java.games.input.LinuxDevice;
/** Represents an Axis absolute or relative
*
* @author Jeremy Booth (jeremy@newdawnsoftware.com)
*/
public class LinuxAxis extends AbstractAxis {
/** The controller this axis is part of */
private LinuxDevice controller;
/** The native ID of this axis */
private int axisID;
/** The null zone, defaulted to 0 */
private float nullZone = 0.0f;
/** Is this axis analog */
private boolean isAnalog = true;
/** Are the values returned by getPollData normalised */
private boolean isNormalized = false;
/** Is this a relative axis */
private boolean isRelative = false;
/** Should we normalise the value before returning it in getPollData */
private boolean needsNormalising = false;
/** The minimum possible axis value (not always used) */
private float minAxisValue;
/** The maximum possibe axis value (not always used */
private float maxAxisValue;
/** The current value of the axis */
private float value = 0.0f;
/**
* Creates a new instance of LinuxAxis
* @param controller The parent Controller
* @param axisID The native ID of this axis
* @param name The name of this axis
* @param id The Axis.Identifier of this axis
* @param deadzone The deadzone (null zone) of this axis
* @param isAnalog Is this axis analog
* @param isNormalized Is this axis normalised
* @param isRelative Is this axis relative
*/
public LinuxAxis(LinuxDevice controller, int axisID, String name, Identifier id, float deadzone, boolean isAnalog, boolean isNormalized, boolean isRelative) {
super(name, id);
this.controller = controller;
this.axisID = axisID;
this.nullZone = deadzone;
this.isAnalog = isAnalog;
this.isNormalized = isNormalized;
this.isRelative = isRelative;
}
/** Creates a new instance of LinuxAxis, it will auto normalise the data based on
* the minimum and maximum values provided
* @param controller The parent Controller
* @param axisID The native ID of this axis
* @param name The name of this axis
* @param id The Axis.Identifier of this axis
* @param deadzone The deadzone (null zone) of this axis
* @param isAnalog Is this axis analog
* @param isRelative Is this axis relative
* @param minAxisValue Minimum value that the native library will return for this axis
* @param maxAxisValue Maximum value that the native library will return for this axis
*/
public LinuxAxis(LinuxDevice controller, int axisID, String name, Identifier id, float deadzone, boolean isAnalog, boolean isRelative, float minAxisValue, float maxAxisValue) {
super(name, id);
this.controller = controller;
this.axisID = axisID;
this.nullZone = deadzone;
this.isAnalog = isAnalog;
this.isNormalized = false;
this.isRelative = isRelative;
this.needsNormalising = true;
this.minAxisValue = minAxisValue;
this.maxAxisValue = maxAxisValue;
}
/** Returns <code>true</code> if data returned from <code>poll</code>
* is relative to the last call, or <code>false</code> if data
* is absolute.
* @return Returns <code>true</code> if data returned from <code>poll</code>
* is relative to the last call, or <code>false</code> if data
* is absolute.
*/
public boolean isRelative() {
return isRelative;
}
/** Returns the suggested dead zone for this axis. Dead zone is the
* amount polled data can vary before considered a significant change
* in value. An application can safely ignore changes less than this
* value in the positive or negative direction.
* @return 0.0f by default, can be overridden
*/
public float getDeadZone() {
return nullZone;
}
/** Returns whether or not the axis is analog, or false if it is digital.
* @return false by default, can be overridden
*/
public boolean isAnalog() {
return isAnalog;
}
/** Returns the data from the last time the control has been polled.
* If this axis is a button, the value returned will be either 0.0f or 1.0f.
* If this axis is normalized, the value returned will be between -1.0f and
* 1.0f.
* @return 0.0f by default, can be overridden
*/
public float getPollData() {
if(isPolling()) {
updateValue();
}
return value;
}
/** Update this axis data from the latest native poll value
*/
private void updateValue() {
if(isAnalog) {
float tempVal;
if(isRelative) {
tempVal = (float)controller.getRelAxisValue(axisID);
} else {
tempVal = (float)controller.getAbsAxisValue(axisID);
}
if(needsNormalising) {
if(isRelative) {
if(tempVal>1) {
tempVal = 1;
} else if(tempVal<-1) {
tempVal = -1;
}
value = tempVal;
} else {
//float center = (minAxisValue + maxAxisValue) / 2;
//value = (tempVal - center) / center;
float center = ((maxAxisValue - minAxisValue)/2);
value = (((tempVal - minAxisValue) - center) / center);
//System.out.println("tempVal: " + tempVal + " minAxisValue: " + minAxisValue + " maxAxisValue: " + maxAxisValue + " center: " + center + " value: " + value);
//System.out.flush();
}
} else {
value = tempVal;
}
} else {
value = (float)controller.getButtonValue(axisID);
}
}
/** Returns whether or not data polled from this axis is normalized
* between the values of -1.0f and 1.0f.
* @return true by default, can be overridden
*/
public boolean isNormalized() {
return (isNormalized || needsNormalising);
}
}

View file

@ -1,925 +0,0 @@
/**
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
import java.util.ArrayList;
/**
* Represents a device that is not a keyboard or mouse.
* @author Jeremy Booth (jeremy@newdawnsoftware.com)
*/
public class LinuxDevice extends AbstractController {
/** The name of the device
*/
private String name;
/** The native ID of the device
*/
private int nativeID;
/** The port type the device is attached to.
*/
private PortType portType;
/** List of buttons the device has
*/
private LinuxAxis[] buttons;
/** List of relative axes the device has
*/
private LinuxAxis[] relAxes;
/** List of absolute axes the device has
*/
private LinuxAxis[] absAxes;
/** List of coolie hats the device has
*/
private LinuxHat[] hats;
/** The id's of the coolie hat axes
*/
private int hatAxisIDs[] = new int[8];
/** The number of buttons the device has
*/
private int numButtons;
/** The number of relative axes the device has
*/
private int numRelAxes;
/** The number of absolute axes the device has
*/
private int numAbsAxes;
/** The number of coolie hats the device has
*/
private int numHats=0;
/** The native button values.
*/
private int[] buttonData;
/** The native relative axes values
*/
private int[] relAxesData;
/** The native absolute axis values
*/
private int[] absAxesData;
/** A guess at the device type.
*/
private Type typeGuess = Type.UNKNOWN;
/** An array of the list of axes this device has
*/
private ArrayList axesArray = new ArrayList();
/** Creates a new instance of LinuxDevice
* @param nativeID The native ID of this device
* @param name The name of this device
* @param numButtons The number of buttons the devices has
* @param numRelAxes The number of raltive axes this device has
* @param numAbsAxes The number of absolute axes this device has
*/
public LinuxDevice(int nativeID, String name, int numButtons, int numRelAxes, int numAbsAxes) {
super(name);
children = NO_CONTROLLERS;
rumblers = NO_RUMBLERS;
this.nativeID = nativeID;
portType = LinuxNativeTypesMap.getPortType(getNativePortType(nativeID));
for(int i=0;i<8;i++) {
hatAxisIDs[i] = -1;
}
this.numButtons = numButtons;
this.numRelAxes = numRelAxes;
this.numAbsAxes = numAbsAxes;
this.numHats = 0;
buttonData = new int[numButtons];
relAxesData = new int[numRelAxes];
absAxesData = new int[numAbsAxes];
createButtons(numButtons);
createRelAxes(numRelAxes);
createAbsAxes(numAbsAxes);
createHats();
/*ArrayList tempAxes = new ArrayList();
for(int i=0;i<numButtons;i++) {
Axis tempAxis = buttons[i];
if(tempAxis!=null) {
tempAxes.add(tempAxis);
}
}
for(int i=0;i<numRelAxes;i++) {
Axis tempAxis = relAxes[i];
if(tempAxis!=null) {
tempAxes.add(tempAxis);
}
}
for(int i=0;i<numAbsAxes;i++) {
Axis tempAxis = absAxes[i];
if(tempAxis!=null) {
tempAxes.add(tempAxis);
}
}
axes = (Axis[]) tempAxes.toArray(axes);*/
for(int i=0;i<numAbsAxes;i++) {
if(absAxes[i]!=null) {
axesArray.add(absAxes[i]);
}
}
for(int i=0;i<numRelAxes;i++) {
if(relAxes[i]!=null) {
axesArray.add(relAxes[i]);
}
}
for(int i=0;i<numHats;i++) {
if(hats[i]!=null) {
axesArray.add(hats[i]);
}
}
for(int i=0;i<numButtons;i++) {
if(buttons[i]!=null) {
axesArray.add(buttons[i]);
}
}
axes = (Axis[]) axesArray.toArray(axes);
guessType();
}
/*public Axis[] getAxes(){
Axis retval[] = new Axis[0];
retval = (Axis []) axesArray.toArray(retval);
return retval;
}*/
/**
* Returns the port type that this device is connected to.
* @return The port type
*/
public PortType getPortType() {
return portType;
}
/**
* Returns the type of the Controller.
* @return The controller type.
*/
public Type getType() {
return typeGuess;
}
/** Create the buttons for the device
* @param numButtons The number of buttons the device has
*/
private void createButtons(int numButtons) {
int supportedButtons[] = new int[numButtons];
buttons = new LinuxAxis[numButtons];
if(numButtons>0) {
getSupportedButtons(supportedButtons);
for(int i=0;i<numButtons;i++) {
buttons[i] = createButton(i, supportedButtons[i]);
//axesArray.add(buttons[i]);
}
}
}
/** Create the relative axes for the device
* @param numRelAxes The number of relative axes the device has
*/
private void createRelAxes(int numRelAxes) {
int supportedRelAxes[] = new int[numRelAxes];
getSupportedRelAxes(supportedRelAxes);
relAxes = new LinuxAxis[numRelAxes];
for(int i=0;i<numRelAxes;i++) {
relAxes[i] = createRelAxis(i, supportedRelAxes[i]);
//axesArray.add(relAxes[i]);
}
}
/** Create the absolute axes for the device
* @param numAbsAxes The number of absolute axes the device has
*/
private void createAbsAxes(int numAbsAxes) {
int supportedAbsAxes[] = new int[numAbsAxes];
getSupportedAbsAxes(supportedAbsAxes);
absAxes = new LinuxAxis[numAbsAxes];
for(int i=0;i<numAbsAxes;i++) {
// Nasy code here
// Hats underlinux are 2 axis, combine them
if(supportedAbsAxes[i] == NativeDefinitions.ABS_HAT0X) {
hatAxisIDs[0] = i;
} else if(supportedAbsAxes[i] == NativeDefinitions.ABS_HAT0Y) {
hatAxisIDs[1] = i;
} else if(supportedAbsAxes[i] == NativeDefinitions.ABS_HAT1X) {
hatAxisIDs[2] = i;
} else if(supportedAbsAxes[i] == NativeDefinitions.ABS_HAT1Y) {
hatAxisIDs[3] = i;
} else if(supportedAbsAxes[i] == NativeDefinitions.ABS_HAT2X) {
hatAxisIDs[4] = i;
} else if(supportedAbsAxes[i] == NativeDefinitions.ABS_HAT2Y) {
hatAxisIDs[5] = i;
} else if(supportedAbsAxes[i] == NativeDefinitions.ABS_HAT3X) {
hatAxisIDs[6] = i;
} else if(supportedAbsAxes[i] == NativeDefinitions.ABS_HAT3Y) {
hatAxisIDs[7] = i;
} else {
absAxes[i] = createAbsAxis(i, supportedAbsAxes[i]);
//axesArray.add(absAxes[i]);
}
}
}
/** Create the coolie hats for the device
*/
private void createHats() {
LinuxHat tempHats[] = new LinuxHat[4];
for(int i=0;i<4;i++) {
int x = i*2;
int y= x+1;
//Check we have at least one hat axis (can hats have just one axis?
if((hatAxisIDs[x]!=-1) || (hatAxisIDs[y]!=-1)) {
String hatName = "Hat " + i;
tempHats[numHats] = createHat(hatName, hatAxisIDs[x], hatAxisIDs[y]);
numHats++;
}
}
hats = new LinuxHat[numHats];
for(int i=0;i<numHats;i++) {
hats[i] = tempHats[i];
//axesArray.add(hats[i]);
}
}
/** Take a guess at the device type.
*/
private void guessType() {
int joystickCharacteristic=0;
int digitiserCharacteristic=0;
int gamepadCharacteristic=0;
int miscCharacteristic=0;
int mouseCharacteristic=0;
int supportedButtons[] = new int[numButtons];
getSupportedButtons(supportedButtons);
for(int i=0;i<numButtons;i++) {
switch (supportedButtons[i]) {
case NativeDefinitions.BTN_TRIGGER :
case NativeDefinitions.BTN_THUMB :
case NativeDefinitions.BTN_THUMB2 :
case NativeDefinitions.BTN_TOP :
case NativeDefinitions.BTN_TOP2 :
case NativeDefinitions.BTN_PINKIE :
case NativeDefinitions.BTN_BASE :
case NativeDefinitions.BTN_BASE2 :
case NativeDefinitions.BTN_BASE3 :
case NativeDefinitions.BTN_BASE4 :
case NativeDefinitions.BTN_BASE5 :
case NativeDefinitions.BTN_BASE6 :
case NativeDefinitions.BTN_DEAD :
joystickCharacteristic++;
break;
case NativeDefinitions.BTN_A :
case NativeDefinitions.BTN_B :
case NativeDefinitions.BTN_C :
case NativeDefinitions.BTN_X :
case NativeDefinitions.BTN_Y :
case NativeDefinitions.BTN_Z :
case NativeDefinitions.BTN_TL :
case NativeDefinitions.BTN_TR :
case NativeDefinitions.BTN_TL2 :
case NativeDefinitions.BTN_TR2 :
case NativeDefinitions.BTN_SELECT :
case NativeDefinitions.BTN_MODE :
case NativeDefinitions.BTN_THUMBL :
case NativeDefinitions.BTN_THUMBR :
gamepadCharacteristic++;
break;
case NativeDefinitions.BTN_0 :
case NativeDefinitions.BTN_1 :
case NativeDefinitions.BTN_2 :
case NativeDefinitions.BTN_3 :
case NativeDefinitions.BTN_4 :
case NativeDefinitions.BTN_5 :
case NativeDefinitions.BTN_6 :
case NativeDefinitions.BTN_7 :
case NativeDefinitions.BTN_8 :
case NativeDefinitions.BTN_9 :
miscCharacteristic++;
break;
case NativeDefinitions.BTN_LEFT :
case NativeDefinitions.BTN_RIGHT :
case NativeDefinitions.BTN_MIDDLE :
case NativeDefinitions.BTN_SIDE :
case NativeDefinitions.BTN_EXTRA :
case NativeDefinitions.BTN_FORWARD :
case NativeDefinitions.BTN_BACK :
mouseCharacteristic++;
break;
case NativeDefinitions.BTN_TOOL_PEN :
case NativeDefinitions.BTN_TOOL_RUBBER :
case NativeDefinitions.BTN_TOOL_BRUSH :
case NativeDefinitions.BTN_TOOL_PENCIL :
case NativeDefinitions.BTN_TOOL_AIRBRUSH :
case NativeDefinitions.BTN_TOOL_FINGER :
case NativeDefinitions.BTN_TOOL_MOUSE :
case NativeDefinitions.BTN_TOOL_LENS :
case NativeDefinitions.BTN_TOUCH :
case NativeDefinitions.BTN_STYLUS :
case NativeDefinitions.BTN_STYLUS2 :
digitiserCharacteristic++;
break;
default:
// no sweat, it's non of the above, erg
}
}
if((joystickCharacteristic > 0) &&
(joystickCharacteristic >= digitiserCharacteristic) &&
(joystickCharacteristic >= gamepadCharacteristic) &&
(joystickCharacteristic >= miscCharacteristic) &&
(joystickCharacteristic >= mouseCharacteristic)) {
typeGuess = Type.STICK;
} else if((gamepadCharacteristic > 0) &&
(gamepadCharacteristic >= digitiserCharacteristic) &&
(gamepadCharacteristic >= joystickCharacteristic) &&
(gamepadCharacteristic >= miscCharacteristic) &&
(gamepadCharacteristic >= mouseCharacteristic)) {
typeGuess = Type.GAMEPAD;
} else if((digitiserCharacteristic > 0) &&
(digitiserCharacteristic >= gamepadCharacteristic) &&
(digitiserCharacteristic >= joystickCharacteristic) &&
(digitiserCharacteristic >= miscCharacteristic) &&
(digitiserCharacteristic >= mouseCharacteristic)) {
typeGuess = Type.TRACKPAD;
} else if((miscCharacteristic > 0) &&
(miscCharacteristic >= gamepadCharacteristic) &&
(miscCharacteristic >= joystickCharacteristic) &&
(miscCharacteristic >= miscCharacteristic) &&
(miscCharacteristic >= mouseCharacteristic)) {
// I'm not sure what one of these would be, but it has axis other
// wise a LinuxKeyboard would have been constructed, so assume its
// some kind of stick;
typeGuess = Type.STICK;
} else if((mouseCharacteristic > 0) &&
(mouseCharacteristic >= digitiserCharacteristic) &&
(mouseCharacteristic >= joystickCharacteristic) &&
(mouseCharacteristic >= miscCharacteristic) &&
(mouseCharacteristic >= gamepadCharacteristic)) {
// We shouldn't ever get here, as a mouse should have constructed
// a LinuxMouse object, but you never know
typeGuess = Type.MOUSE;
}
if(typeGuess == Type.STICK) {
String tempName = getName().toLowerCase();
if((tempName.indexOf("gamepad") > -1) || (tempName.indexOf("game pad") > -1)) {
typeGuess = Type.GAMEPAD;
}
}
}
/** Create an button for the device
* @param buttonNumber The button number
* @param nativeButtonType The type of button
* @return The new button
*/
private LinuxAxis createButton(int buttonNumber, int nativeButtonType) {
Axis.Identifier id = LinuxNativeTypesMap.getButtonID(nativeButtonType);
String name = LinuxNativeTypesMap.getButtonName(nativeButtonType);
if(name == null) {
name = "Uknown button";
id = new ButtonID(name);
}
return new LinuxAxis(this, buttonNumber, name, id, 0, false, true, false);
}
/** Create a relative axis for the device
* @param axisNumber The native axis id
* @param nativeType The native type
* @return The new axis
*/
private LinuxAxis createRelAxis(int axisNumber, int nativeType) {
Axis.Identifier id = LinuxNativeTypesMap.getRelAxisID(nativeType);
String name = LinuxNativeTypesMap.getRelAxisName(nativeType);
// This is done to be like the windows version
// return new LinuxAxis(this, axisNumber, name, id, 0, true, true, 0, 0);
// this is what should be done
return new LinuxAxis(this, axisNumber, name, id, 0, true, false, true);
}
/** Create an absolute axis for the device
* @param axisNumber The native axis number
* @param nativeType The native tpye
* @return The new axis
*/
private LinuxAxis createAbsAxis(int axisNumber, int nativeType) {
Axis.Identifier id = LinuxNativeTypesMap.getAbsAxisID(nativeType);
String name = LinuxNativeTypesMap.getAbsAxisName(nativeType);
// Work around for a kernel level (I think) bug that incorrectly reports
// the third axis as a rudder not a throttle on analog (gameport) 3 axis
// 4 button sticks
if((getName().equals("Analog 3-axis 4-button joystick")) && (portType == Controller.PortType.GAME)) {
if((id == Axis.Identifier.RZ) && (name.equals("Rudder"))) {
id = Axis.Identifier.SLIDER;
name = "Throttle";
}
}
return new LinuxAxis(this, axisNumber, name, id, getAbsAxisFuzz(axisNumber), true, false, getAbsAxisMinimum(axisNumber), getAbsAxisMaximum(axisNumber));
//return new LinuxAxis(this, axisNumber, name, id, getAbsAxisFuzz(axisNumber), true, false, false);
}
/** Create a hat for the device
* @param name The name of the hat to create
* @param xAxisID The axis that is the hats X axis
* @param yAxisID The axis that is the hats Y axis
* @return The new hat
*/
private LinuxHat createHat(String name, int xAxisID, int yAxisID) {
return new LinuxHat(this, name, xAxisID, yAxisID);
}
/** Polls axes for data. Returns false if the controller is no longer valid.
* Polling reflects the current state of the device when polled.
* @return false if the controller is no longer valid.
*/
public boolean poll() {
int retval = nativePoll(nativeID, buttonData, relAxesData, absAxesData);
if(retval>=0) return true;
return false;
}
/**
* Retursn the value of a particular button or key
* @param buttonID The button/key to check
* @return The value fo the button/key
*/
public float getButtonValue(int buttonID) {
if(buttonData[buttonID]>0) return 1.0f;
return 0.0f;
}
/**
* Returns the value of a particular absolute axis
* @param axisID The axis id
* @return The axis value
*/
public float getAbsAxisValue(int axisID) {
return (float) absAxesData[axisID];
}
/**
* Returns the value of the requested relative axis.
* @param axisID The native axis ID.
* @return The value of the axis
*/
public float getRelAxisValue(int axisID) {
return (float) relAxesData[axisID];
}
/**
* Gets the axis fuzz, used for nullzone information
* @param axisID The axis to get the fuzz for
* @return The axis fuzz.
*/
public float getAbsAxisFuzz(int axisID) {
return (float) getNativeAbsAxisFuzz(nativeID, axisID);
}
/**
* Returns the maximum value for the requested axis
* @param axisID The native ID of the axis to check
* @return The maximum value
*/
public float getAbsAxisMaximum(int axisID) {
return (float) getNativeAbsAxisMaximum(nativeID, axisID);
}
/**
* The minimum value the requested axis can have
* @param axisID The native axis ID
* @return The minimum axis value
*/
public float getAbsAxisMinimum(int axisID) {
return (float) getNativeAbsAxisMinimum(nativeID, axisID);
}
/** Return the enumeration of supported button types for this device
* @param supportedButtons Array to populate
*/
private void getSupportedButtons(int supportedButtons[]) {
if(supportedButtons.length==0) {
return;
}
getNativeSupportedButtons(nativeID, supportedButtons);
}
/** Return the enumeration of supported absolute axis types for this device
* @param suportedAbsAxes The array to populate
*/
private void getSupportedAbsAxes(int suportedAbsAxes[]) {
getNativeSupportedAbsAxes(nativeID, suportedAbsAxes);
}
/** Return the enumeration of supported relative axis types for this device
* @param supportedRelAxes The array to populate
*/
private void getSupportedRelAxes(int supportedRelAxes[]) {
getNativeSupportedRelAxes(nativeID, supportedRelAxes);
}
/** Native call to get the supported absolute axes for a device
* @param deviceID The native device number
* @param supportedAbsAxes aray to populate
*/
private native void getNativeSupportedAbsAxes(int deviceID, int supportedAbsAxes[]);
/** Native call to get the supported relative axes for a device
* @param deviceID The native device ID
* @param supportedRelAxes the array to populate
*/
private native void getNativeSupportedRelAxes(int deviceID, int supportedRelAxes[]);
/** Native call to get the supported buttons for a device
* @param deviceID The native device ID
* @param supportedButtons The array to populate
*/
private native void getNativeSupportedButtons(int deviceID, int supportedButtons[]);
/** Call to poll the device at the native library
* @param deviceID The native device ID
* @param buttonData Array to populate with button values
* @param relAxesData Array to populate with relative axes values
* @param absAxesData Array to populate with absolute axes values
* @return the number of events read
*/
private native int nativePoll(int deviceID, int buttonData[], int relAxesData[], int absAxesData[]);
/** Returns the fuzz of an axis fro mthe native lib
* @param deviceID The native device id
* @param axisID The native axis ID
* @return The fuzz
*/
private native int getNativeAbsAxisFuzz(int deviceID, int axisID);
/** Gets the maximum value for an absloute axis fr omthe native library
* @param deviceID The native device ID
* @param axisID The native axis ID
* @return The Max value
*/
private native int getNativeAbsAxisMaximum(int deviceID, int axisID);
/** Gets the minimum value for an absloute axis from the native library
* @param deviceID The native device ID
* @param axisID The native axis number
* @return The min value
*/
private native int getNativeAbsAxisMinimum(int deviceID, int axisID);
/** Gets the port type from the native lib
* @param deviceID The device to get the port type for
* @return The port type
*/
private native int getNativePortType(int deviceID);
/**
* A device that represents a joystick coolie hat.
* @author Jeremy Booth (jeremy@newdawnsoftware.com)
*/
public static class LinuxHat extends AbstractAxis {
/** The parent controller
*/
private LinuxDevice controller;
/** The xAxis for this hat
*/
private int xAxisID;
/** The y axis for this hat
*/
private int yAxisID;
/** The last polled value of this hat
*/
private float value;
/**
* Creates a new instance of LinuxHat, coolie hats under linux are reported as
* two independant axis, this class is responsible for combining the axis values
* and returning a value appropriate for a coolie hat.
* @param controller The parent controller
* @param name The name of this hat
* @param xAxisID The X axis native axis ID
* @param yAxisID The Y axis native axis ID
*/
public LinuxHat(LinuxDevice controller, String name, int xAxisID, int yAxisID) {
super(name, Axis.Identifier.POV);
this.controller = controller;
this.xAxisID = xAxisID;
this.yAxisID = yAxisID;
//System.err.println("New hat: " + name + " created");
//System.err.flush();
}
/** Returns <code>true</code> if data returned from <code>poll</code>
* is relative to the last call, or <code>false</code> if data
* is absolute.
* @return Returns <code>true</code> if data returned from <code>poll</code>
* is relative to the last call, or <code>false</code> if data
* is absolute.
*/
public boolean isRelative() {
return false;
}
/** Returns true if this axis is analog
* @return Always retursn true as coolie hats are analog under linux
*/
public boolean isAnalog() {
return false;
}
/**
* Retursn true if this axis is normalised
* @return Always returns true as linux hats are normalised
*/
public boolean isNormalised() {
return true;
}
/**
* Returns the current value of this axis
* @return The current axis value
*/
public float getPollData() {
//System.err.println("getPollData called, isPolling: " + isPolling());
//System.err.flush();
if(isPolling()) { updateData(); };
return value;
}
/** Gets the data fro mthe native level and combines it to the hats value
*/
private void updateData() {
//System.err.println("updateData called");
//System.err.flush();
int newXAxisValue = (int)controller.getAbsAxisValue(xAxisID);
int newYAxisValue = (int)controller.getAbsAxisValue(yAxisID);
//System.err.println("newXAxisValue: " + newXAxisValue + " newYAxisValue: " + newYAxisValue);
if((newXAxisValue == 0) && (newYAxisValue == 0)) {
value = POV.OFF;
} else if((newXAxisValue == 32767) && (newYAxisValue == 32767)) {
value = POV.UP_RIGHT;
} else if((newXAxisValue == 32767) && (newYAxisValue == 0)) {
value = POV.RIGHT;
} else if((newXAxisValue == 32767) && (newYAxisValue == -32767)) {
value = POV.DOWN_RIGHT;
} else if((newXAxisValue == 0) && (newYAxisValue == -32767)) {
value = POV.DOWN;
} else if((newXAxisValue == -32767) && (newYAxisValue == -32767)) {
value = POV.DOWN_LEFT;
} else if((newXAxisValue == -32767) && (newYAxisValue == 0)) {
value = POV.LEFT;
} else if((newXAxisValue == -32767) && (newYAxisValue == 32767)) {
value = POV.UP_LEFT;
} else if((newXAxisValue == 0) && (newYAxisValue == 32767)) {
value = POV.UP;
}
//System.err.println("new value: " + value);
//System.err.flush();
}
}
/** Some button ID's specific to linux devices
* @author Jeremy Booth (jeremy@computerbooth.com)
*/
public static class ButtonID extends Axis.Identifier {
/** First device button
*/
public static final ButtonID BTN_0 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_0));
/** Second device button
*/
public static final ButtonID BTN_1 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_1));
/** Thrid device button
*/
public static final ButtonID BTN_2 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_2));
/** Fourth device button
*/
public static final ButtonID BTN_3 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_3));
/** Fifth device button
*/
public static final ButtonID BTN_4 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_4));
/** Sixth device button
*/
public static final ButtonID BTN_5 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_5));
/** Seventh device button
*/
public static final ButtonID BTN_6 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_6));
/** Eighth (had to check that spelling on dictionary.com) device button
*/
public static final ButtonID BTN_7 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_7));
/** Ninth device button
*/
public static final ButtonID BTN_8 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_8));
/** 10th device button
*/
public static final ButtonID BTN_9 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_9));
/** Joystick trigger button
*/
public static final ButtonID BTN_TRIGGER = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_TRIGGER));
/** Joystick thumb button
*/
public static final ButtonID BTN_THUMB = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_THUMB));
/** Second joystick thumb button
*/
public static final ButtonID BTN_THUMB2 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_THUMB2));
/** Joystick top button
*/
public static final ButtonID BTN_TOP = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_TOP));
/** Second joystick top button
*/
public static final ButtonID BTN_TOP2 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_TOP2));
/** The joystick button you play with with you little finger (Pinkie on *that* side
* of the pond :P)
*/
public static final ButtonID BTN_PINKIE = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_PINKIE));
/** Joystick button on the base of the device
*/
public static final ButtonID BTN_BASE = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_BASE));
/** Second joystick button on the base of the device
*/
public static final ButtonID BTN_BASE2 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_BASE2));
/** Thrid joystick button on the base of the device
*/
public static final ButtonID BTN_BASE3 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_BASE3));
/** Fourth joystick button on the base of the device
*/
public static final ButtonID BTN_BASE4 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_BASE4));
/** Fifth joystick button on the base of the device
*/
public static final ButtonID BTN_BASE5 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_BASE5));
/** Sixth joystick button on the base of the device
*/
public static final ButtonID BTN_BASE6 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_BASE6));
/** erm, dunno, but it's in the defines so it might exist.
*/
public static final ButtonID BTN_DEAD = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_DEAD));
/** 'A' button on a gamepad
*/
public static final ButtonID BTN_A = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_A));
/** 'B' button on a gamepad
*/
public static final ButtonID BTN_B = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_B));
/** 'C' button on a gamepad
*/
public static final ButtonID BTN_C = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_C));
/** 'X' button on a gamepad
*/
public static final ButtonID BTN_X = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_X));
/** 'Y' button on a gamepad
*/
public static final ButtonID BTN_Y = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_Y));
/** 'Z' button on a gamepad
*/
public static final ButtonID BTN_Z = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_Z));
/** Left thumb button on a gamepad
*/
public static final ButtonID BTN_TL = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_TL));
/** Right thumb button on a gamepad
*/
public static final ButtonID BTN_TR = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_TR));
/** Second left thumb button on a gamepad
*/
public static final ButtonID BTN_TL2 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_TL2));
/** Second right thumb button on a gamepad
*/
public static final ButtonID BTN_TR2 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_TR2));
/** 'Select' button on a gamepad
*/
public static final ButtonID BTN_SELECT = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_SELECT));
/** 'Mode' button on a gamepad
*/
public static final ButtonID BTN_MODE = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_MODE));
/** Another left thumb button on a gamepad (how many thumbs do you have??)
*/
public static final ButtonID BTN_THUMBL = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_THUMBL));
/** Another right thumb button on a gamepad
*/
public static final ButtonID BTN_THUMBR = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_THUMBR));
/** Digitiser pen tool button
*/
public static final ButtonID BTN_TOOL_PEN = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_TOOL_PEN));
/** Digitiser rubber (eraser) tool button
*/
public static final ButtonID BTN_TOOL_RUBBER = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_TOOL_RUBBER));
/** Digitiser brush tool button
*/
public static final ButtonID BTN_TOOL_BRUSH = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_TOOL_BRUSH));
/** Digitiser pencil tool button
*/
public static final ButtonID BTN_TOOL_PENCIL = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_TOOL_PENCIL));
/** Digitiser airbrush tool button
*/
public static final ButtonID BTN_TOOL_AIRBRUSH = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_TOOL_AIRBRUSH));
/** Digitiser finger tool button
*/
public static final ButtonID BTN_TOOL_FINGER = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_TOOL_FINGER));
/** Digitiser mouse tool button
*/
public static final ButtonID BTN_TOOL_MOUSE = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_TOOL_MOUSE));
/** Digitiser lens tool button
*/
public static final ButtonID BTN_TOOL_LENS = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_TOOL_LENS));
/** Digitiser touch button
*/
public static final ButtonID BTN_TOUCH = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_TOUCH));
/** Digitiser stylus button
*/
public static final ButtonID BTN_STYLUS = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_STYLUS));
/** Second digitiser stylus button
*/
public static final ButtonID BTN_STYLUS2 = new ButtonID(LinuxNativeTypesMap.getButtonName(NativeDefinitions.BTN_STYLUS2));
/** Create a new Button.Identidier with the passed name
* @param name The name for the new identifier
*/
private ButtonID(String name) {
super(name);
}
}
}

View file

@ -1,155 +0,0 @@
/**
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
import net.java.games.util.plugins.Plugin;
/** Environment plugin for linux
* @author Jeremy Booth (jeremy@newdawnsoftware.com)
*/
public class LinuxEnvironmentPlugin extends ControllerEnvironment implements Plugin {
static {
System.loadLibrary("jinput");
}
/** List of controllers
*/
private Controller[] controllers;
/** Creates a new instance of LinuxEnvironmentPlugin */
public LinuxEnvironmentPlugin() {
LinuxNativeTypesMap.init();
init();
createControllers();
}
/** Returns a list of all controllers available to this environment,
* or an empty array if there are no controllers in this environment.
* @return Returns a list of all controllers available to this environment,
* or an empty array if there are no controllers in this environment.
*/
public Controller[] getControllers() {
return controllers;
}
/** Create the controllers
*/
private void createControllers() {
int numDevices = getNumberOfDevices();
controllers = new Controller[numDevices];
for(int i=0;i<numDevices;i++) {
controllers[i] = createDevice(i);
}
}
/** Create a particular device
* @param deviceNumber The device ID
* @return The new device
*/
private Controller createDevice(int deviceNumber) {
String name = getDeviceName(deviceNumber);
int numAbsAxes = getNumAbsAxes(deviceNumber);
int numRelAxes = getNumRelAxes(deviceNumber);
int numButtons = getNumButtons(deviceNumber);
Controller device = null;
int mouseCharacteristic = 0;
int keyboardCharacteristic = 0;
int joystickCharacteristic = 0;
// we are going to try and guess what type of controller it is now
if(name.toLowerCase().indexOf("mouse")>=0) {
mouseCharacteristic++;
}
if(name.toLowerCase().indexOf("keyboard")>=0) {
keyboardCharacteristic++;
}
if(name.toLowerCase().indexOf("joystick")>=0) {
joystickCharacteristic++;
}
if(numRelAxes>=2) {
mouseCharacteristic++;
} else {
mouseCharacteristic--;
}
if(numAbsAxes>=2) {
joystickCharacteristic++;
} else {
joystickCharacteristic--;
}
if(numButtons>64) {
keyboardCharacteristic++;
} else {
keyboardCharacteristic--;
}
if((mouseCharacteristic > keyboardCharacteristic) && (mouseCharacteristic > joystickCharacteristic)) {
device = new LinuxMouse(new LinuxDevice(deviceNumber, name, numButtons, numRelAxes, numAbsAxes));
} else if((keyboardCharacteristic > mouseCharacteristic) && (keyboardCharacteristic > joystickCharacteristic)) {
device = new LinuxKeyboard(deviceNumber, name, numButtons, numRelAxes, numAbsAxes);
} else if((joystickCharacteristic > keyboardCharacteristic) && (joystickCharacteristic > mouseCharacteristic)) {
device = new LinuxDevice(deviceNumber, name, numButtons, numRelAxes, numAbsAxes);
} else {
//Dunno what this is, but try it anyway
device = new LinuxDevice(deviceNumber, name, numButtons, numRelAxes, numAbsAxes);
}
return device;
}
/** Get the name of a device from the native library
* @param deviceID The device id
* @return The devices name
*/
private native String getDeviceName(int deviceID);
/** Get the number of absolute axes for the requested device
* @param deviceID The device ID
* @return The number of abs axes
*/
private native int getNumAbsAxes(int deviceID);
/** Get the nmber or relative axes from the native library
* @param deviceID The native device ID
* @return The number of raltive axes for the device
*/
private native int getNumRelAxes(int deviceID);
/** Gets the number of buttons for the requested devce from the native library
* @param deviceID The device ID
* @return The number of buttons
*/
private native int getNumButtons(int deviceID);
/** Initialises the native library
* @return <0 if something went wrong
*/
private native int init();
/** Gets the number of devices the native library found
* @return Th number of devices
*/
private native int getNumberOfDevices();
}

View file

@ -1,232 +0,0 @@
/**
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
/** Class that represents a keyboard under linux
* @author Jeremy Booth (jeremy@newdawnsoftware.com)
*/
public class LinuxKeyboard extends StandardKeyboard {
/** Values for the keys
*/
private int keyData[];
/** Needed for the polling methods
*/
private int dummyRelAxesData[];
/** Needed for the polling methods
*/
private int dummyAbsAxesData[];
/** Map of native key numbers from jinput key id key indexes.
*/
private int keyMap[];
/** List of keys this keyboard supports
*/
private int supportedKeys[];
/** Number of keys this keyboard has
*/
private int numKeys;
/** Port type that this keyboard is connected to.
*/
private PortType portType;
/** The native device id
*/
private int nativeID;
/** Creates a new instance of LinuxKeyboard
* @param nativeID Native device id
* @param name Name of this keybaord
* @param numButtons Number of keys
* @param numRelAxes Number of relative axes (you never know)
* @param numAbsAxes Number of absolute axes (you never know)
*/
public LinuxKeyboard(int nativeID, String name, int numButtons, int numRelAxes, int numAbsAxes) {
super(name);
children = NO_CONTROLLERS;
rumblers = NO_RUMBLERS;
if((numRelAxes > 0) || (numAbsAxes > 0)) {
children = new Controller[1];
children[0] = new LinuxDevice(nativeID, name + " axis", 0, numRelAxes, numAbsAxes);
}
this.nativeID = nativeID;
portType = LinuxNativeTypesMap.getPortType(getNativePortType(nativeID));
dummyRelAxesData = new int[numRelAxes];
dummyAbsAxesData = new int[numAbsAxes];
this.numKeys = numButtons;
keyData = new int[numButtons+1];
supportedKeys = new int[numButtons+1];
keyMap = new int[KeyID.LAST.getKeyIndex()];
getSupportedButtons(supportedKeys);
supportedKeys[numKeys] = NativeDefinitions.KEY_UNKNOWN;
setupKeyMap();
renameKeys();
}
/** Returns whether or not the given key has been pressed since the last
* call to poll. This is called from a key's getPollData method.
* @param key The key to check
* @return the value fo the key
*/
protected boolean isKeyPressed(Key key) {
/*if(((Keyboard.KeyID) key.getIdentifier()).getKeyIndex() == StandardKeyboard.KeyID.ESCAPE.getKeyIndex()) {
System.out.println("Asked if key " + key + " was pressed");
System.out.println("key id " + key.getIdentifier());
System.out.println("keyIndex " + ((Keyboard.KeyID) key.getIdentifier()).getKeyIndex());
System.out.println("keyMap for index is " + keyMap[((Keyboard.KeyID) key.getIdentifier()).getKeyIndex()]);
System.out.println("name for supportedKeys index is " + LinuxNativeTypesMap.getButtonName(supportedKeys[keyMap[((Keyboard.KeyID) key.getIdentifier()).getKeyIndex()]]));
System.out.println("id for supportedKeys index is " + LinuxNativeTypesMap.getButtonID(supportedKeys[keyMap[((Keyboard.KeyID) key.getIdentifier()).getKeyIndex()]]));
System.out.flush();
}*/
if(keyData[keyMap[((Keyboard.KeyID) key.getIdentifier()).getKeyIndex()]] > 0) {
return true;
}
return false;
}
/** Polls axes for data. Returns false if the controller is no longer valid.
* Polling reflects the current state of the device when polled.
* @return False if this device is invalid.
*/
public boolean poll() {
int retval = nativePoll(nativeID, keyData, dummyRelAxesData, dummyAbsAxesData);
if(retval>=0) return true;
return false;
}
/** Goes through every key to initialise the key map
*/
private void setupKeyMap() {
for(int i=0;i<KeyID.LAST.getKeyIndex();i++) {
keyMap[i] = numKeys;
}
for(int i=0;i<numKeys;i++) {
int tempNativeID = supportedKeys[i];
Keyboard.KeyID tempKeyID = StandardKeyboard.KeyID.VOID;
try {
tempKeyID = (Keyboard.KeyID)LinuxNativeTypesMap.getButtonID(tempNativeID);
} catch (ClassCastException e) {
System.out.println("LinuxNativeTypesMap.getButtonID() returned " + LinuxNativeTypesMap.getButtonID(tempNativeID).getClass().toString());
}
if(tempKeyID.getKeyIndex() < keyMap.length) {
keyMap[tempKeyID.getKeyIndex()] = i;
//System.out.println("keyMap[" + (tempKeyID.getKeyIndex()) + "] (" + tempKeyID + ") set to index " + i + " (" + LinuxNativeTypesMap.getButtonName(supportedKeys[i]) + ")");
} else {
//System.out.println("Linux key " + LinuxNativeTypesMap.getButtonName(tempNativeID) + " isn't supported by jinput");
}
}
}
/** Renames all the keys based on what information we have about them (number/name)
*/
private void renameKeys() {
Axis tempAxes[] = getAxes();
// Do this one by hand as it's a special case
//((AbstractAxis)tempAxes[0]).setName("Unknown");
for(int i=0;i<tempAxes.length;i++) {
Axis tempAxis = tempAxes[i];
int nativeKeyID = supportedKeys[keyMap[((Keyboard.KeyID) tempAxis.getIdentifier()).getKeyIndex()]];
//System.out.println("key " + tempAxis + " map: " + nativeKeyID);
if(nativeKeyID != NativeDefinitions.KEY_UNKNOWN) {
String tempName = LinuxNativeTypesMap.getButtonName(nativeKeyID);
((AbstractAxis)tempAxis).setName(tempName);
/*System.out.println("axis id is " + (Keyboard.KeyID) tempAxis.getIdentifier());
System.out.println("keyMap[id] is " + keyMap[((Keyboard.KeyID) tempAxis.getIdentifier()).getKeyIndex()]);
System.out.println("nativeKeyID is: " + nativeKeyID);
System.out.println("Set name of key " + ((Keyboard.KeyID) tempAxis.getIdentifier()).getKeyIndex() + " to " + tempName);*/
}
}
}
/** Gets all the supported keys for this device
* @param supportedButtons The array if key types to populate
*/
private void getSupportedButtons(int supportedButtons[]) {
getNativeSupportedButtons(nativeID, supportedButtons);
}
/** Gets the supported key types for a particular native device
* @param deviceID The device ID
* @param supportedButtons The array to populate with teh supported key ids
*/
private native void getNativeSupportedButtons(int deviceID, int supportedButtons[]);
/** Calls the native library to poll the device
* @param deviceID The device ID
* @param buttonData Aray to populate with button values
* @param relAxesData Array to populate with relative axis values
* @param absAxesData Array to populate with absolute axes values
* @return <0 if soething went wrong
*/
private native int nativePoll(int deviceID, int buttonData[], int relAxesData[], int absAxesData[]);
/** Gets the port type from the native library for a particular keyboard
* @param deviceID The keybaord id
* @return native port ype
*/
private native int getNativePortType(int deviceID);
/** Linux specific key ID's
* @author Jeremy Booth (jeremy@newdawnsoftware.com)
*/
public static class KeyID extends StandardKeyboard.KeyID {
/** The Page up key id
*/
public static final KeyID PAGEUP = new KeyID(StandardKeyboard.KeyID.LAST.getKeyIndex()+1, "Page up");
/** Page down key id
*/
public static final KeyID PAGEDOWN = new KeyID(StandardKeyboard.KeyID.LAST.getKeyIndex()+1, "Page down");
/** The last defined key ID
*/
protected static final KeyID LAST = PAGEDOWN;
/** The name of this key ID
*/
String name;
/** Construct a new key ID from the passed arguments
* @param keyid The native ID of the key
* @param name The name fo the key
*/
public KeyID(int keyid, String name) {
super(keyid);
this.name = name;
}
/** Returns a string representing this key ID
* @return String representing this key id
*/
public String toString() {
return super.toString() + " (" + name + ")";
}
}
}

View file

@ -1,168 +0,0 @@
/**
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
/** Class that represents a mouse under linux.
*
* @author Jeremy Booth (jeremy@newdawnsoftware.com)
*/
public class LinuxMouse extends Mouse {
/** The parent linux device
*/
private LinuxDevice device;
/** Creates a new instance of LinuxMouse
* @param device The parent device
*/
public LinuxMouse(LinuxDevice device) {
super(device.getName());
this.device = device;
Axis[] axes = device.getAxes();
Axis x = null;
Axis y = null;
Axis wheel = null;
Button left = null;
Button right = null;
Button middle = null;
Button side = null;
Button extra = null;
Button forward = null;
Button back = null;
// start from the back, that way the first one is it
for(int i = (axes.length -1);i>=0;i--) {
Axis tempAxis = axes[i];
if(tempAxis.isRelative()) {
if(tempAxis.getIdentifier() == Axis.Identifier.X) {
x = tempAxis;
} else if(tempAxis.getIdentifier() == Axis.Identifier.Y) {
y = tempAxis;
} else if(tempAxis.getIdentifier() == Axis.Identifier.SLIDER) {
wheel = tempAxis;
}
} else if(!(tempAxis.isAnalog())) {
if(tempAxis.getIdentifier() == Mouse.ButtonID.LEFT) {
left = new LinuxMouseButton(tempAxis);
} else if(tempAxis.getIdentifier() == Mouse.ButtonID.RIGHT) {
right = new LinuxMouseButton(tempAxis);
} else if(tempAxis.getIdentifier() == Mouse.ButtonID.MIDDLE) {
middle = new LinuxMouseButton(tempAxis);
} else if(tempAxis.getIdentifier() == Mouse.ButtonID.SIDE) {
side = new LinuxMouseButton(tempAxis);
} else if(tempAxis.getIdentifier() == Mouse.ButtonID.EXTRA) {
extra = new LinuxMouseButton(tempAxis);
} else if(tempAxis.getIdentifier() == Mouse.ButtonID.FORWARD) {
forward = new LinuxMouseButton(tempAxis);
} else if(tempAxis.getIdentifier() == Mouse.ButtonID.BACK) {
back = new LinuxMouseButton(tempAxis);
}
}
}
ball = new LinuxMouseBall(x,y,wheel);
buttons = new LinuxMouseButtons(left, right, middle, side, extra, forward, back);
}
/** Polls axes for data. Returns false if the controller is no longer valid.
* Polling reflects the current state of the device when polled.
* @return Returns false if the controller is no longer valid.
*/
public boolean poll() {
return device.poll();
}
/** Mouse ball under linux
*/
private class LinuxMouseBall extends Ball {
/** Constructs the new mouse ball
* @param x The x axis
* @param y The y axis
* @param wheel The mouse wheel axis
*/
public LinuxMouseBall(Axis x, Axis y, Axis wheel) {
super(LinuxMouse.this.getName() + " ball");
this.x = x;
this.y = y;
this.wheel = wheel;
}
}
/** Mouse buttons under linux
*/
private class LinuxMouseButtons extends Buttons {
/** Creates the new mouse's buttons
* @param left Left mouse button
* @param right Right mouse button
* @param middle Middle mouse button
* @param side Side mouse button
* @param extra Extra mouse button
* @param forward Forward mouse button
* @param back Back mouse button
*/
public LinuxMouseButtons(Button left, Button right, Button middle, Button side, Button extra, Button forward, Button back) {
super(LinuxMouse.this.getName() + " buttons");
this.left = left;
this.right = right;
this.middle = middle;
this.side = side;
this.extra = extra;
this.forward = forward;
this.back = back;
}
}
/** Linux specific mouse buttons
*/
private class LinuxMouseButton extends Mouse.Button {
/** The real Axis
*/
private Axis realAxis;
/** Construct a linux mouse button fro mthe given axis
* @param axis The axis that holds the data
*/
public LinuxMouseButton(Axis axis) {
super(axis.getName(), (Mouse.ButtonID)axis.getIdentifier());
this.realAxis = axis;
}
/** Returns true f this axis is relative
* @return Always returns false for a mouse button
*/
public boolean isRelative() {
return false;
}
/** Returns the data for this mouse button
* @return Retursn this mouse buttons value
*/
public float getPollData(){
return realAxis.getPollData();
}
}
}

View file

@ -1,792 +0,0 @@
/**
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
/**
* Mapping utility class between native type ints and string names or
* Key.Identifiers
* @author Jeremy Booth (jeremy@newdawnsoftware.com)
*/
public class LinuxNativeTypesMap {
/** Instance of they key map
*/
private static LinuxNativeTypesMap INSTANCE = new LinuxNativeTypesMap();
/** Indexed array of key names
*/
private String keyNames[];
/** Inexed array of relative axes names
*/
private String relAxesNames[];
/** Indexed array of absolute axis names
*/
private String absAxesNames[];
/** Indexed array of relative axis ID's
*/
private Axis.Identifier relAxesIDs[];
/** Indexed array of absoulte axis ID's
*/
private Axis.Identifier absAxesIDs[];
/** Indexed array of button axis ID's
*/
private Axis.Identifier buttonIDs[];
/** create an empty, uninitialsed map
*/
private LinuxNativeTypesMap() {
keyNames = new String[NativeDefinitions.KEY_MAX];
}
/** Initialise the map, has to be done like this because the map references staic
* classes, as this would otherwise be done in a static class initialiser the whole
* thing blew up as the static classes this class references refer to this class
* this meant that the other classes could not be initialsed until this one was,
* but this class couldn't be loaded until the others were, all went horibly wrong
* and INSTANCE was null whilst initialising the class, ouch.
*/
public static void init() {
INSTANCE.reInit();
}
/** Do the work.
*/
private void reInit() {
keyNames[NativeDefinitions.KEY_ESC] = "Escape";
keyNames[NativeDefinitions.KEY_1] = "1";
keyNames[NativeDefinitions.KEY_2] = "2";
keyNames[NativeDefinitions.KEY_3] = "3";
keyNames[NativeDefinitions.KEY_4] = "4";
keyNames[NativeDefinitions.KEY_5] = "5";
keyNames[NativeDefinitions.KEY_6] = "6";
keyNames[NativeDefinitions.KEY_7] = "7";
keyNames[NativeDefinitions.KEY_8] = "8";
keyNames[NativeDefinitions.KEY_9] = "9";
keyNames[NativeDefinitions.KEY_0] = "0";
keyNames[NativeDefinitions.KEY_MINUS] = "-";
keyNames[NativeDefinitions.KEY_EQUAL] = "=";
keyNames[NativeDefinitions.KEY_BACKSPACE] = "Backspace";
keyNames[NativeDefinitions.KEY_TAB] = "Tab";
keyNames[NativeDefinitions.KEY_Q] = "Q";
keyNames[NativeDefinitions.KEY_W] = "W";
keyNames[NativeDefinitions.KEY_E] = "E";
keyNames[NativeDefinitions.KEY_R] = "R";
keyNames[NativeDefinitions.KEY_T] = "T";
keyNames[NativeDefinitions.KEY_Y] = "Y";
keyNames[NativeDefinitions.KEY_U] = "U";
keyNames[NativeDefinitions.KEY_I] = "I";
keyNames[NativeDefinitions.KEY_O] = "O";
keyNames[NativeDefinitions.KEY_P] = "P";
keyNames[NativeDefinitions.KEY_LEFTBRACE] = "[";
keyNames[NativeDefinitions.KEY_RIGHTBRACE] = "]";
keyNames[NativeDefinitions.KEY_ENTER] = "Enter";
keyNames[NativeDefinitions.KEY_LEFTCTRL] = "LH Control";
keyNames[NativeDefinitions.KEY_A] = "A";
keyNames[NativeDefinitions.KEY_S] = "S";
keyNames[NativeDefinitions.KEY_D] = "D";
keyNames[NativeDefinitions.KEY_F] = "F";
keyNames[NativeDefinitions.KEY_G] = "G";
keyNames[NativeDefinitions.KEY_H] = "H";
keyNames[NativeDefinitions.KEY_J] = "J";
keyNames[NativeDefinitions.KEY_K] = "K";
keyNames[NativeDefinitions.KEY_L] = "L";
keyNames[NativeDefinitions.KEY_SEMICOLON] = ";";
keyNames[NativeDefinitions.KEY_APOSTROPHE] = "'";
keyNames[NativeDefinitions.KEY_GRAVE] = "`";
keyNames[NativeDefinitions.KEY_LEFTSHIFT] = "LH Shift";
keyNames[NativeDefinitions.KEY_BACKSLASH] = "\\";
keyNames[NativeDefinitions.KEY_Z] = "Z";
keyNames[NativeDefinitions.KEY_X] = "X";
keyNames[NativeDefinitions.KEY_C] = "C";
keyNames[NativeDefinitions.KEY_V] = "V";
keyNames[NativeDefinitions.KEY_B] = "B";
keyNames[NativeDefinitions.KEY_N] = "N";
keyNames[NativeDefinitions.KEY_M] = "M";
keyNames[NativeDefinitions.KEY_COMMA] = ",";
keyNames[NativeDefinitions.KEY_DOT] = ".";
keyNames[NativeDefinitions.KEY_SLASH] = "/";
keyNames[NativeDefinitions.KEY_RIGHTSHIFT] = "RH Shift";
keyNames[NativeDefinitions.KEY_KPASTERISK] = "*";
keyNames[NativeDefinitions.KEY_LEFTALT] = "LH Alt";
keyNames[NativeDefinitions.KEY_SPACE] = "Space";
keyNames[NativeDefinitions.KEY_CAPSLOCK] = "CapsLock";
keyNames[NativeDefinitions.KEY_F1] = "F1";
keyNames[NativeDefinitions.KEY_F2] = "F2";
keyNames[NativeDefinitions.KEY_F3] = "F3";
keyNames[NativeDefinitions.KEY_F4] = "F4";
keyNames[NativeDefinitions.KEY_F5] = "F5";
keyNames[NativeDefinitions.KEY_F6] = "F6";
keyNames[NativeDefinitions.KEY_F7] = "F7";
keyNames[NativeDefinitions.KEY_F8] = "F8";
keyNames[NativeDefinitions.KEY_F9] = "F9";
keyNames[NativeDefinitions.KEY_F10] = "F10";
keyNames[NativeDefinitions.KEY_NUMLOCK] = "NumLock";
keyNames[NativeDefinitions.KEY_SCROLLLOCK] = "ScrollLock";
keyNames[NativeDefinitions.KEY_KP7] = "KeyPad 7";
keyNames[NativeDefinitions.KEY_KP8] = "KeyPad 8";
keyNames[NativeDefinitions.KEY_KP9] = "Keypad 9";
keyNames[NativeDefinitions.KEY_KPMINUS] = "KeyPad Minus";
keyNames[NativeDefinitions.KEY_KP4] = "KeyPad 4";
keyNames[NativeDefinitions.KEY_KP5] = "KeyPad 5";
keyNames[NativeDefinitions.KEY_KP6] = "KeyPad 6";
keyNames[NativeDefinitions.KEY_KPPLUS] = "KeyPad Plus";
keyNames[NativeDefinitions.KEY_KP1] = "KeyPad 1";
keyNames[NativeDefinitions.KEY_KP2] = "KeyPad 2";
keyNames[NativeDefinitions.KEY_KP3] = "KeyPad 3";
keyNames[NativeDefinitions.KEY_KP0] = "KeyPad 0";
keyNames[NativeDefinitions.KEY_KPDOT] = "KeyPad decimal point";
keyNames[NativeDefinitions.KEY_103RD] = "Huh?";
keyNames[NativeDefinitions.KEY_F13] = "F13";
keyNames[NativeDefinitions.KEY_102ND] = "Beats me...";
keyNames[NativeDefinitions.KEY_F11] = "F11";
keyNames[NativeDefinitions.KEY_F12] = "F12";
keyNames[NativeDefinitions.KEY_F14] = "F14";
keyNames[NativeDefinitions.KEY_F15] = "F15";
keyNames[NativeDefinitions.KEY_F16] = "F16";
keyNames[NativeDefinitions.KEY_F17] = "F17";
keyNames[NativeDefinitions.KEY_F18] = "F18";
keyNames[NativeDefinitions.KEY_F19] = "F19";
keyNames[NativeDefinitions.KEY_F20] = "F20";
keyNames[NativeDefinitions.KEY_KPENTER] = "Keypad Enter";
keyNames[NativeDefinitions.KEY_RIGHTCTRL] = "RH Control";
keyNames[NativeDefinitions.KEY_KPSLASH] = "KeyPad Forward Slash";
keyNames[NativeDefinitions.KEY_SYSRQ] = "System Request";
keyNames[NativeDefinitions.KEY_RIGHTALT] = "RH Alternate";
keyNames[NativeDefinitions.KEY_LINEFEED] = "Line Feed";
keyNames[NativeDefinitions.KEY_HOME] = "Home";
keyNames[NativeDefinitions.KEY_UP] = "Up";
keyNames[NativeDefinitions.KEY_PAGEUP] = "Page Up";
keyNames[NativeDefinitions.KEY_LEFT] = "Left";
keyNames[NativeDefinitions.KEY_RIGHT] = "Right";
keyNames[NativeDefinitions.KEY_END] = "End";
keyNames[NativeDefinitions.KEY_DOWN] = "Down";
keyNames[NativeDefinitions.KEY_PAGEDOWN] = "Page Down";
keyNames[NativeDefinitions.KEY_INSERT] = "Insert";
keyNames[NativeDefinitions.KEY_DELETE] = "Delete";
keyNames[NativeDefinitions.KEY_MACRO] = "Macro";
keyNames[NativeDefinitions.KEY_MUTE] = "Mute";
keyNames[NativeDefinitions.KEY_VOLUMEDOWN] = "Volume Down";
keyNames[NativeDefinitions.KEY_VOLUMEUP] = "Volume Up";
keyNames[NativeDefinitions.KEY_POWER] = "Power";
keyNames[NativeDefinitions.KEY_KPEQUAL] = "KeyPad Equal";
keyNames[NativeDefinitions.KEY_KPPLUSMINUS] = "KeyPad +/-";
keyNames[NativeDefinitions.KEY_PAUSE] = "Pause";
keyNames[NativeDefinitions.KEY_F21] = "F21";
keyNames[NativeDefinitions.KEY_F22] = "F22";
keyNames[NativeDefinitions.KEY_F23] = "F23";
keyNames[NativeDefinitions.KEY_F24] = "F24";
keyNames[NativeDefinitions.KEY_KPCOMMA] = "KeyPad comma";
keyNames[NativeDefinitions.KEY_LEFTMETA] = "LH Meta";
keyNames[NativeDefinitions.KEY_RIGHTMETA] = "RH Meta";
keyNames[NativeDefinitions.KEY_COMPOSE] = "Compose";
keyNames[NativeDefinitions.KEY_STOP] = "Stop";
keyNames[NativeDefinitions.KEY_AGAIN] = "Again";
keyNames[NativeDefinitions.KEY_PROPS] = "Properties";
keyNames[NativeDefinitions.KEY_UNDO] = "Undo";
keyNames[NativeDefinitions.KEY_FRONT] = "Front";
keyNames[NativeDefinitions.KEY_COPY] = "Copy";
keyNames[NativeDefinitions.KEY_OPEN] = "Open";
keyNames[NativeDefinitions.KEY_PASTE] = "Paste";
keyNames[NativeDefinitions.KEY_FIND] = "Find";
keyNames[NativeDefinitions.KEY_CUT] = "Cut";
keyNames[NativeDefinitions.KEY_HELP] = "Help";
keyNames[NativeDefinitions.KEY_MENU] = "Menu";
keyNames[NativeDefinitions.KEY_CALC] = "Calculator";
keyNames[NativeDefinitions.KEY_SETUP] = "Setup";
keyNames[NativeDefinitions.KEY_SLEEP] = "Sleep";
keyNames[NativeDefinitions.KEY_WAKEUP] = "Wakeup";
keyNames[NativeDefinitions.KEY_FILE] = "File";
keyNames[NativeDefinitions.KEY_SENDFILE] = "Send File";
keyNames[NativeDefinitions.KEY_DELETEFILE] = "Delete File";
keyNames[NativeDefinitions.KEY_XFER] = "Transfer";
keyNames[NativeDefinitions.KEY_PROG1] = "Program 1";
keyNames[NativeDefinitions.KEY_PROG2] = "Program 2";
keyNames[NativeDefinitions.KEY_WWW] = "Web Browser";
keyNames[NativeDefinitions.KEY_MSDOS] = "DOS mode";
keyNames[NativeDefinitions.KEY_COFFEE] = "Coffee";
keyNames[NativeDefinitions.KEY_DIRECTION] = "Direction";
keyNames[NativeDefinitions.KEY_CYCLEWINDOWS] = "Window cycle";
keyNames[NativeDefinitions.KEY_MAIL] = "Mail";
keyNames[NativeDefinitions.KEY_BOOKMARKS] = "Book Marks";
keyNames[NativeDefinitions.KEY_COMPUTER] = "Computer";
keyNames[NativeDefinitions.KEY_BACK] = "Back";
keyNames[NativeDefinitions.KEY_FORWARD] = "Forward";
keyNames[NativeDefinitions.KEY_CLOSECD] = "Close CD";
keyNames[NativeDefinitions.KEY_EJECTCD] = "Eject CD";
keyNames[NativeDefinitions.KEY_EJECTCLOSECD] = "Eject / Close CD";
keyNames[NativeDefinitions.KEY_NEXTSONG] = "Next Song";
keyNames[NativeDefinitions.KEY_PLAYPAUSE] = "Play and Pause";
keyNames[NativeDefinitions.KEY_PREVIOUSSONG] = "Previous Song";
keyNames[NativeDefinitions.KEY_STOPCD] = "Stop CD";
keyNames[NativeDefinitions.KEY_RECORD] = "Record";
keyNames[NativeDefinitions.KEY_REWIND] = "Rewind";
keyNames[NativeDefinitions.KEY_PHONE] = "Phone";
keyNames[NativeDefinitions.KEY_ISO] = "ISO";
keyNames[NativeDefinitions.KEY_CONFIG] = "Config";
keyNames[NativeDefinitions.KEY_HOMEPAGE] = "Home";
keyNames[NativeDefinitions.KEY_REFRESH] = "Refresh";
keyNames[NativeDefinitions.KEY_EXIT] = "Exit";
keyNames[NativeDefinitions.KEY_MOVE] = "Move";
keyNames[NativeDefinitions.KEY_EDIT] = "Edit";
keyNames[NativeDefinitions.KEY_SCROLLUP] = "Scroll Up";
keyNames[NativeDefinitions.KEY_SCROLLDOWN] = "Scroll Down";
keyNames[NativeDefinitions.KEY_KPLEFTPAREN] = "KeyPad LH parenthesis";
keyNames[NativeDefinitions.KEY_KPRIGHTPAREN] = "KeyPad RH parenthesis";
keyNames[NativeDefinitions.KEY_INTL1] = "Intl 1";
keyNames[NativeDefinitions.KEY_INTL2] = "Intl 2";
keyNames[NativeDefinitions.KEY_INTL3] = "Intl 3";
keyNames[NativeDefinitions.KEY_INTL4] = "Intl 4";
keyNames[NativeDefinitions.KEY_INTL5] = "Intl 5";
keyNames[NativeDefinitions.KEY_INTL6] = "Intl 6";
keyNames[NativeDefinitions.KEY_INTL7] = "Intl 7";
keyNames[NativeDefinitions.KEY_INTL8] = "Intl 8";
keyNames[NativeDefinitions.KEY_INTL9] = "Intl 9";
keyNames[NativeDefinitions.KEY_LANG1] = "Language 1";
keyNames[NativeDefinitions.KEY_LANG2] = "Language 2";
keyNames[NativeDefinitions.KEY_LANG3] = "Language 3";
keyNames[NativeDefinitions.KEY_LANG4] = "Language 4";
keyNames[NativeDefinitions.KEY_LANG5] = "Language 5";
keyNames[NativeDefinitions.KEY_LANG6] = "Language 6";
keyNames[NativeDefinitions.KEY_LANG7] = "Language 7";
keyNames[NativeDefinitions.KEY_LANG8] = "Language 8";
keyNames[NativeDefinitions.KEY_LANG9] = "Language 9";
keyNames[NativeDefinitions.KEY_PLAYCD] = "Play CD";
keyNames[NativeDefinitions.KEY_PAUSECD] = "Pause CD";
keyNames[NativeDefinitions.KEY_PROG3] = "Program 3";
keyNames[NativeDefinitions.KEY_PROG4] = "Program 4";
keyNames[NativeDefinitions.KEY_SUSPEND] = "Suspend";
keyNames[NativeDefinitions.KEY_CLOSE] = "Close";
keyNames[NativeDefinitions.KEY_UNKNOWN] = "Specifically unknown";
keyNames[NativeDefinitions.KEY_BRIGHTNESSDOWN] = "Brightness Down";
keyNames[NativeDefinitions.KEY_BRIGHTNESSUP] = "Brightness Up";
keyNames[NativeDefinitions.BTN_0] = "Button 0";
keyNames[NativeDefinitions.BTN_1] = "Button 1";
keyNames[NativeDefinitions.BTN_2] = "Button 2";
keyNames[NativeDefinitions.BTN_3] = "Button 3";
keyNames[NativeDefinitions.BTN_4] = "Button 4";
keyNames[NativeDefinitions.BTN_5] = "Button 5";
keyNames[NativeDefinitions.BTN_6] = "Button 6";
keyNames[NativeDefinitions.BTN_7] = "Button 7";
keyNames[NativeDefinitions.BTN_8] = "Button 8";
keyNames[NativeDefinitions.BTN_9] = "Button 9";
keyNames[NativeDefinitions.BTN_LEFT] = "Left Button";
keyNames[NativeDefinitions.BTN_RIGHT] = "Right Button";
keyNames[NativeDefinitions.BTN_MIDDLE] = "Middle Button";
keyNames[NativeDefinitions.BTN_SIDE] = "Side Button";
keyNames[NativeDefinitions.BTN_EXTRA] = "Extra Button";
keyNames[NativeDefinitions.BTN_FORWARD] = "Forward Button";
keyNames[NativeDefinitions.BTN_BACK] = "Back Button";
keyNames[NativeDefinitions.BTN_TRIGGER] = "Trigger Button";
keyNames[NativeDefinitions.BTN_THUMB] = "Thumb Button";
keyNames[NativeDefinitions.BTN_THUMB2] = "Second Thumb Button";
keyNames[NativeDefinitions.BTN_TOP] = "Top Button";
keyNames[NativeDefinitions.BTN_TOP2] = "Second Top Button";
keyNames[NativeDefinitions.BTN_PINKIE] = "Pinkie Button";
keyNames[NativeDefinitions.BTN_BASE] = "Base Button";
keyNames[NativeDefinitions.BTN_BASE2] = "Second Base Button";
keyNames[NativeDefinitions.BTN_BASE3] = "Third Base Button";
keyNames[NativeDefinitions.BTN_BASE4] = "Fourth Base Button";
keyNames[NativeDefinitions.BTN_BASE5] = "Fifth Base Button";
keyNames[NativeDefinitions.BTN_BASE6] = "Sixth Base Button";
keyNames[NativeDefinitions.BTN_DEAD] = "Dead Button";
keyNames[NativeDefinitions.BTN_A] = "Button A";
keyNames[NativeDefinitions.BTN_B] = "Button B";
keyNames[NativeDefinitions.BTN_C] = "Button C";
keyNames[NativeDefinitions.BTN_X] = "Button X";
keyNames[NativeDefinitions.BTN_Y] = "Button Y";
keyNames[NativeDefinitions.BTN_Z] = "Button Z";
keyNames[NativeDefinitions.BTN_TL] = "Thumb Left Button";
keyNames[NativeDefinitions.BTN_TR] = "Thumb Right Button ";
keyNames[NativeDefinitions.BTN_TL2] = "Second Thumb Left Button";
keyNames[NativeDefinitions.BTN_TR2] = "Second Thumb Right Button ";
keyNames[NativeDefinitions.BTN_SELECT] = "Select Button";
keyNames[NativeDefinitions.BTN_MODE] = "Mode Button";
keyNames[NativeDefinitions.BTN_THUMBL] = "Another Left Thumb Button ";
keyNames[NativeDefinitions.BTN_THUMBR] = "Another Right Thumb Button ";
keyNames[NativeDefinitions.BTN_TOOL_PEN] = "Digitiser Pen Tool";
keyNames[NativeDefinitions.BTN_TOOL_RUBBER] = "Digitiser Rubber Tool";
keyNames[NativeDefinitions.BTN_TOOL_BRUSH] = "Digitiser Brush Tool";
keyNames[NativeDefinitions.BTN_TOOL_PENCIL] = "Digitiser Pencil Tool";
keyNames[NativeDefinitions.BTN_TOOL_AIRBRUSH] = "Digitiser Airbrush Tool";
keyNames[NativeDefinitions.BTN_TOOL_FINGER] = "Digitiser Finger Tool";
keyNames[NativeDefinitions.BTN_TOOL_MOUSE] = "Digitiser Mouse Tool";
keyNames[NativeDefinitions.BTN_TOOL_LENS] = "Digitiser Lens Tool";
keyNames[NativeDefinitions.BTN_TOUCH] = "Digitiser Touch Button ";
keyNames[NativeDefinitions.BTN_STYLUS] = "Digitiser Stylus Button ";
keyNames[NativeDefinitions.BTN_STYLUS2] = "Second Digitiser Stylus Button ";
buttonIDs = new Axis.Identifier[NativeDefinitions.KEY_MAX];
buttonIDs[NativeDefinitions.KEY_ESC] = StandardKeyboard.KeyID.ESCAPE;
buttonIDs[NativeDefinitions.KEY_1] = StandardKeyboard.KeyID._1;
buttonIDs[NativeDefinitions.KEY_2] = StandardKeyboard.KeyID._2;
buttonIDs[NativeDefinitions.KEY_3] = StandardKeyboard.KeyID._3;
buttonIDs[NativeDefinitions.KEY_4] = StandardKeyboard.KeyID._4;
buttonIDs[NativeDefinitions.KEY_5] = StandardKeyboard.KeyID._5;
buttonIDs[NativeDefinitions.KEY_6] = StandardKeyboard.KeyID._6;
buttonIDs[NativeDefinitions.KEY_7] = StandardKeyboard.KeyID._7;
buttonIDs[NativeDefinitions.KEY_8] = StandardKeyboard.KeyID._8;
buttonIDs[NativeDefinitions.KEY_9] = StandardKeyboard.KeyID._9;
buttonIDs[NativeDefinitions.KEY_0] = StandardKeyboard.KeyID._0;
buttonIDs[NativeDefinitions.KEY_MINUS] = StandardKeyboard.KeyID.MINUS;
buttonIDs[NativeDefinitions.KEY_EQUAL] = StandardKeyboard.KeyID.EQUALS;
buttonIDs[NativeDefinitions.KEY_BACKSPACE] = StandardKeyboard.KeyID.BACK;
buttonIDs[NativeDefinitions.KEY_TAB] = StandardKeyboard.KeyID.TAB;
buttonIDs[NativeDefinitions.KEY_Q] = StandardKeyboard.KeyID.Q;
buttonIDs[NativeDefinitions.KEY_W] = StandardKeyboard.KeyID.W;
buttonIDs[NativeDefinitions.KEY_E] = StandardKeyboard.KeyID.E;
buttonIDs[NativeDefinitions.KEY_R] = StandardKeyboard.KeyID.R;
buttonIDs[NativeDefinitions.KEY_T] = StandardKeyboard.KeyID.T;
buttonIDs[NativeDefinitions.KEY_Y] = StandardKeyboard.KeyID.Y;
buttonIDs[NativeDefinitions.KEY_U] = StandardKeyboard.KeyID.U;
buttonIDs[NativeDefinitions.KEY_I] = StandardKeyboard.KeyID.I;
buttonIDs[NativeDefinitions.KEY_O] = StandardKeyboard.KeyID.O;
buttonIDs[NativeDefinitions.KEY_P] = StandardKeyboard.KeyID.P;
buttonIDs[NativeDefinitions.KEY_LEFTBRACE] = StandardKeyboard.KeyID.LBRACKET;
buttonIDs[NativeDefinitions.KEY_RIGHTBRACE] = StandardKeyboard.KeyID.RBRACKET;
buttonIDs[NativeDefinitions.KEY_ENTER] = StandardKeyboard.KeyID.RETURN;
buttonIDs[NativeDefinitions.KEY_LEFTCTRL] = StandardKeyboard.KeyID.LCONTROL;
buttonIDs[NativeDefinitions.KEY_A] = StandardKeyboard.KeyID.A;
buttonIDs[NativeDefinitions.KEY_S] = StandardKeyboard.KeyID.S;
buttonIDs[NativeDefinitions.KEY_D] = StandardKeyboard.KeyID.D;
buttonIDs[NativeDefinitions.KEY_F] = StandardKeyboard.KeyID.F;
buttonIDs[NativeDefinitions.KEY_G] = StandardKeyboard.KeyID.G;
buttonIDs[NativeDefinitions.KEY_H] = StandardKeyboard.KeyID.H;
buttonIDs[NativeDefinitions.KEY_J] = StandardKeyboard.KeyID.J;
buttonIDs[NativeDefinitions.KEY_K] = StandardKeyboard.KeyID.K;
buttonIDs[NativeDefinitions.KEY_L] = StandardKeyboard.KeyID.L;
buttonIDs[NativeDefinitions.KEY_SEMICOLON] = StandardKeyboard.KeyID.SEMICOLON;
buttonIDs[NativeDefinitions.KEY_APOSTROPHE] = StandardKeyboard.KeyID.APOSTROPHE;
buttonIDs[NativeDefinitions.KEY_GRAVE] = StandardKeyboard.KeyID.GRAVE;
buttonIDs[NativeDefinitions.KEY_LEFTSHIFT] = StandardKeyboard.KeyID.LSHIFT;
buttonIDs[NativeDefinitions.KEY_BACKSLASH] = StandardKeyboard.KeyID.BACKSLASH;
buttonIDs[NativeDefinitions.KEY_Z] = StandardKeyboard.KeyID.Z;
buttonIDs[NativeDefinitions.KEY_X] = StandardKeyboard.KeyID.X;
buttonIDs[NativeDefinitions.KEY_C] = StandardKeyboard.KeyID.C;
buttonIDs[NativeDefinitions.KEY_V] = StandardKeyboard.KeyID.V;
buttonIDs[NativeDefinitions.KEY_B] = StandardKeyboard.KeyID.B;
buttonIDs[NativeDefinitions.KEY_N] = StandardKeyboard.KeyID.N;
buttonIDs[NativeDefinitions.KEY_M] = StandardKeyboard.KeyID.M;
buttonIDs[NativeDefinitions.KEY_COMMA] = StandardKeyboard.KeyID.COMMA;
buttonIDs[NativeDefinitions.KEY_DOT] = StandardKeyboard.KeyID.PERIOD;
buttonIDs[NativeDefinitions.KEY_SLASH] = StandardKeyboard.KeyID.SLASH;
buttonIDs[NativeDefinitions.KEY_RIGHTSHIFT] = StandardKeyboard.KeyID.RSHIFT;
buttonIDs[NativeDefinitions.KEY_KPASTERISK] = StandardKeyboard.KeyID.MULTIPLY;
buttonIDs[NativeDefinitions.KEY_LEFTALT] = StandardKeyboard.KeyID.LALT;
buttonIDs[NativeDefinitions.KEY_SPACE] = StandardKeyboard.KeyID.SPACE;
buttonIDs[NativeDefinitions.KEY_CAPSLOCK] = StandardKeyboard.KeyID.CAPITAL;
buttonIDs[NativeDefinitions.KEY_F1] = StandardKeyboard.KeyID.F1;
buttonIDs[NativeDefinitions.KEY_F2] = StandardKeyboard.KeyID.F2;
buttonIDs[NativeDefinitions.KEY_F3] = StandardKeyboard.KeyID.F3;
buttonIDs[NativeDefinitions.KEY_F4] = StandardKeyboard.KeyID.F4;
buttonIDs[NativeDefinitions.KEY_F5] = StandardKeyboard.KeyID.F5;
buttonIDs[NativeDefinitions.KEY_F6] = StandardKeyboard.KeyID.F6;
buttonIDs[NativeDefinitions.KEY_F7] = StandardKeyboard.KeyID.F7;
buttonIDs[NativeDefinitions.KEY_F8] = StandardKeyboard.KeyID.F8;
buttonIDs[NativeDefinitions.KEY_F9] = StandardKeyboard.KeyID.F9;
buttonIDs[NativeDefinitions.KEY_F10] = StandardKeyboard.KeyID.F10;
buttonIDs[NativeDefinitions.KEY_NUMLOCK] = StandardKeyboard.KeyID.NUMLOCK;
buttonIDs[NativeDefinitions.KEY_SCROLLLOCK] = StandardKeyboard.KeyID.SCROLL;
buttonIDs[NativeDefinitions.KEY_KP7] = StandardKeyboard.KeyID.NUMPAD7;
buttonIDs[NativeDefinitions.KEY_KP8] = StandardKeyboard.KeyID.NUMPAD8;
buttonIDs[NativeDefinitions.KEY_KP9] = StandardKeyboard.KeyID.NUMPAD9;
buttonIDs[NativeDefinitions.KEY_KPMINUS] = StandardKeyboard.KeyID.SUBTRACT;
buttonIDs[NativeDefinitions.KEY_KP4] = StandardKeyboard.KeyID.NUMPAD4;
buttonIDs[NativeDefinitions.KEY_KP5] = StandardKeyboard.KeyID.NUMPAD5;
buttonIDs[NativeDefinitions.KEY_KP6] = StandardKeyboard.KeyID.NUMPAD6;
buttonIDs[NativeDefinitions.KEY_KPPLUS] = StandardKeyboard.KeyID.ADD;
buttonIDs[NativeDefinitions.KEY_KP1] = StandardKeyboard.KeyID.NUMPAD1;
buttonIDs[NativeDefinitions.KEY_KP2] = StandardKeyboard.KeyID.NUMPAD2;
buttonIDs[NativeDefinitions.KEY_KP3] = StandardKeyboard.KeyID.NUMPAD3;
buttonIDs[NativeDefinitions.KEY_KP0] = StandardKeyboard.KeyID.NUMPAD0;
buttonIDs[NativeDefinitions.KEY_KPDOT] = StandardKeyboard.KeyID.DECIMAL;
buttonIDs[NativeDefinitions.KEY_103RD] = null;
buttonIDs[NativeDefinitions.KEY_F13] = StandardKeyboard.KeyID.F13;
buttonIDs[NativeDefinitions.KEY_102ND] = null;
buttonIDs[NativeDefinitions.KEY_F11] = StandardKeyboard.KeyID.F11;
buttonIDs[NativeDefinitions.KEY_F12] = StandardKeyboard.KeyID.F12;
buttonIDs[NativeDefinitions.KEY_F14] = StandardKeyboard.KeyID.F14;
buttonIDs[NativeDefinitions.KEY_F15] = StandardKeyboard.KeyID.F15;
buttonIDs[NativeDefinitions.KEY_F16] = null;
buttonIDs[NativeDefinitions.KEY_F17] = null;
buttonIDs[NativeDefinitions.KEY_F18] = null;
buttonIDs[NativeDefinitions.KEY_F19] = null;
buttonIDs[NativeDefinitions.KEY_F20] = null;
buttonIDs[NativeDefinitions.KEY_KPENTER] = StandardKeyboard.KeyID.NUMPADENTER;
buttonIDs[NativeDefinitions.KEY_RIGHTCTRL] = StandardKeyboard.KeyID.RCONTROL;
buttonIDs[NativeDefinitions.KEY_KPSLASH] = StandardKeyboard.KeyID.DIVIDE;
buttonIDs[NativeDefinitions.KEY_SYSRQ] = StandardKeyboard.KeyID.SYSRQ;
buttonIDs[NativeDefinitions.KEY_RIGHTALT] = StandardKeyboard.KeyID.RALT;
buttonIDs[NativeDefinitions.KEY_LINEFEED] = null;
buttonIDs[NativeDefinitions.KEY_HOME] = StandardKeyboard.KeyID.HOME;
buttonIDs[NativeDefinitions.KEY_UP] = StandardKeyboard.KeyID.UP;
buttonIDs[NativeDefinitions.KEY_PAGEUP] = LinuxKeyboard.KeyID.PAGEUP;
buttonIDs[NativeDefinitions.KEY_LEFT] = StandardKeyboard.KeyID.LEFT;
buttonIDs[NativeDefinitions.KEY_RIGHT] = StandardKeyboard.KeyID.RIGHT;
buttonIDs[NativeDefinitions.KEY_END] = StandardKeyboard.KeyID.END;
buttonIDs[NativeDefinitions.KEY_DOWN] = StandardKeyboard.KeyID.DOWN;
buttonIDs[NativeDefinitions.KEY_PAGEDOWN] = LinuxKeyboard.KeyID.PAGEDOWN;
buttonIDs[NativeDefinitions.KEY_INSERT] = StandardKeyboard.KeyID.INSERT;
buttonIDs[NativeDefinitions.KEY_DELETE] = StandardKeyboard.KeyID.DELETE;
buttonIDs[NativeDefinitions.KEY_PAUSE] = StandardKeyboard.KeyID.PAUSE;
/* buttonIDs[NativeDefinitions.KEY_MACRO] = "Macro";
buttonIDs[NativeDefinitions.KEY_MUTE] = "Mute";
buttonIDs[NativeDefinitions.KEY_VOLUMEDOWN] = "Volume Down";
buttonIDs[NativeDefinitions.KEY_VOLUMEUP] = "Volume Up";
buttonIDs[NativeDefinitions.KEY_POWER] = "Power";*/
buttonIDs[NativeDefinitions.KEY_KPEQUAL] = StandardKeyboard.KeyID.NUMPADEQUAL;
//buttonIDs[NativeDefinitions.KEY_KPPLUSMINUS] = "KeyPad +/-";
/* buttonIDs[NativeDefinitions.KEY_F21] = "F21";
buttonIDs[NativeDefinitions.KEY_F22] = "F22";
buttonIDs[NativeDefinitions.KEY_F23] = "F23";
buttonIDs[NativeDefinitions.KEY_F24] = "F24";
buttonIDs[NativeDefinitions.KEY_KPCOMMA] = "KeyPad comma";
buttonIDs[NativeDefinitions.KEY_LEFTMETA] = "LH Meta";
buttonIDs[NativeDefinitions.KEY_RIGHTMETA] = "RH Meta";
buttonIDs[NativeDefinitions.KEY_COMPOSE] = "Compose";
buttonIDs[NativeDefinitions.KEY_STOP] = "Stop";
buttonIDs[NativeDefinitions.KEY_AGAIN] = "Again";
buttonIDs[NativeDefinitions.KEY_PROPS] = "Properties";
buttonIDs[NativeDefinitions.KEY_UNDO] = "Undo";
buttonIDs[NativeDefinitions.KEY_FRONT] = "Front";
buttonIDs[NativeDefinitions.KEY_COPY] = "Copy";
buttonIDs[NativeDefinitions.KEY_OPEN] = "Open";
buttonIDs[NativeDefinitions.KEY_PASTE] = "Paste";
buttonIDs[NativeDefinitions.KEY_FIND] = "Find";
buttonIDs[NativeDefinitions.KEY_CUT] = "Cut";
buttonIDs[NativeDefinitions.KEY_HELP] = "Help";
buttonIDs[NativeDefinitions.KEY_MENU] = "Menu";
buttonIDs[NativeDefinitions.KEY_CALC] = "Calculator";
buttonIDs[NativeDefinitions.KEY_SETUP] = "Setup";*/
buttonIDs[NativeDefinitions.KEY_SLEEP] = StandardKeyboard.KeyID.SLEEP;
/*buttonIDs[NativeDefinitions.KEY_WAKEUP] = "Wakeup";
buttonIDs[NativeDefinitions.KEY_FILE] = "File";
buttonIDs[NativeDefinitions.KEY_SENDFILE] = "Send File";
buttonIDs[NativeDefinitions.KEY_DELETEFILE] = "Delete File";
buttonIDs[NativeDefinitions.KEY_XFER] = "Transfer";
buttonIDs[NativeDefinitions.KEY_PROG1] = "Program 1";
buttonIDs[NativeDefinitions.KEY_PROG2] = "Program 2";
buttonIDs[NativeDefinitions.KEY_WWW] = "Web Browser";
buttonIDs[NativeDefinitions.KEY_MSDOS] = "DOS mode";
buttonIDs[NativeDefinitions.KEY_COFFEE] = "Coffee";
buttonIDs[NativeDefinitions.KEY_DIRECTION] = "Direction";
buttonIDs[NativeDefinitions.KEY_CYCLEWINDOWS] = "Window cycle";
buttonIDs[NativeDefinitions.KEY_MAIL] = "Mail";
buttonIDs[NativeDefinitions.KEY_BOOKMARKS] = "Book Marks";
buttonIDs[NativeDefinitions.KEY_COMPUTER] = "Computer";
buttonIDs[NativeDefinitions.KEY_BACK] = "Back";
buttonIDs[NativeDefinitions.KEY_FORWARD] = "Forward";
buttonIDs[NativeDefinitions.KEY_CLOSECD] = "Close CD";
buttonIDs[NativeDefinitions.KEY_EJECTCD] = "Eject CD";
buttonIDs[NativeDefinitions.KEY_EJECTCLOSECD] = "Eject / Close CD";
buttonIDs[NativeDefinitions.KEY_NEXTSONG] = "Next Song";
buttonIDs[NativeDefinitions.KEY_PLAYPAUSE] = "Play and Pause";
buttonIDs[NativeDefinitions.KEY_PREVIOUSSONG] = "Previous Song";
buttonIDs[NativeDefinitions.KEY_STOPCD] = "Stop CD";
buttonIDs[NativeDefinitions.KEY_RECORD] = "Record";
buttonIDs[NativeDefinitions.KEY_REWIND] = "Rewind";
buttonIDs[NativeDefinitions.KEY_PHONE] = "Phone";
buttonIDs[NativeDefinitions.KEY_ISO] = "ISO";
buttonIDs[NativeDefinitions.KEY_CONFIG] = "Config";
buttonIDs[NativeDefinitions.KEY_HOMEPAGE] = "Home";
buttonIDs[NativeDefinitions.KEY_REFRESH] = "Refresh";
buttonIDs[NativeDefinitions.KEY_EXIT] = "Exit";
buttonIDs[NativeDefinitions.KEY_MOVE] = "Move";
buttonIDs[NativeDefinitions.KEY_EDIT] = "Edit";
buttonIDs[NativeDefinitions.KEY_SCROLLUP] = "Scroll Up";
buttonIDs[NativeDefinitions.KEY_SCROLLDOWN] = "Scroll Down";
buttonIDs[NativeDefinitions.KEY_KPLEFTPAREN] = "KeyPad LH parenthesis";
buttonIDs[NativeDefinitions.KEY_KPRIGHTPAREN] = "KeyPad RH parenthesis";
buttonIDs[NativeDefinitions.KEY_INTL1] = "Intl 1";
buttonIDs[NativeDefinitions.KEY_INTL2] = "Intl 2";
buttonIDs[NativeDefinitions.KEY_INTL3] = "Intl 3";
buttonIDs[NativeDefinitions.KEY_INTL4] = "Intl 4";
buttonIDs[NativeDefinitions.KEY_INTL5] = "Intl 5";
buttonIDs[NativeDefinitions.KEY_INTL6] = "Intl 6";
buttonIDs[NativeDefinitions.KEY_INTL7] = "Intl 7";
buttonIDs[NativeDefinitions.KEY_INTL8] = "Intl 8";
buttonIDs[NativeDefinitions.KEY_INTL9] = "Intl 9";
buttonIDs[NativeDefinitions.KEY_LANG1] = "Language 1";
buttonIDs[NativeDefinitions.KEY_LANG2] = "Language 2";
buttonIDs[NativeDefinitions.KEY_LANG3] = "Language 3";
buttonIDs[NativeDefinitions.KEY_LANG4] = "Language 4";
buttonIDs[NativeDefinitions.KEY_LANG5] = "Language 5";
buttonIDs[NativeDefinitions.KEY_LANG6] = "Language 6";
buttonIDs[NativeDefinitions.KEY_LANG7] = "Language 7";
buttonIDs[NativeDefinitions.KEY_LANG8] = "Language 8";
buttonIDs[NativeDefinitions.KEY_LANG9] = "Language 9";
buttonIDs[NativeDefinitions.KEY_PLAYCD] = "Play CD";
buttonIDs[NativeDefinitions.KEY_PAUSECD] = "Pause CD";
buttonIDs[NativeDefinitions.KEY_PROG3] = "Program 3";
buttonIDs[NativeDefinitions.KEY_PROG4] = "Program 4";
buttonIDs[NativeDefinitions.KEY_SUSPEND] = "Suspend";
buttonIDs[NativeDefinitions.KEY_CLOSE] = "Close";*/
buttonIDs[NativeDefinitions.KEY_UNKNOWN] = StandardKeyboard.KeyID.UNLABELED;
/*buttonIDs[NativeDefinitions.KEY_BRIGHTNESSDOWN] = "Brightness Down";
buttonIDs[NativeDefinitions.KEY_BRIGHTNESSUP] = "Brightness Up";*/
//Msic keys
buttonIDs[NativeDefinitions.BTN_0] = LinuxDevice.ButtonID.BTN_0;
buttonIDs[NativeDefinitions.BTN_1] = LinuxDevice.ButtonID.BTN_1;
buttonIDs[NativeDefinitions.BTN_2] = LinuxDevice.ButtonID.BTN_2;
buttonIDs[NativeDefinitions.BTN_3] = LinuxDevice.ButtonID.BTN_3;
buttonIDs[NativeDefinitions.BTN_4] = LinuxDevice.ButtonID.BTN_4;
buttonIDs[NativeDefinitions.BTN_5] = LinuxDevice.ButtonID.BTN_5;
buttonIDs[NativeDefinitions.BTN_6] = LinuxDevice.ButtonID.BTN_6;
buttonIDs[NativeDefinitions.BTN_7] = LinuxDevice.ButtonID.BTN_7;
buttonIDs[NativeDefinitions.BTN_8] = LinuxDevice.ButtonID.BTN_8;
buttonIDs[NativeDefinitions.BTN_9] = LinuxDevice.ButtonID.BTN_9;
// Mouse
buttonIDs[NativeDefinitions.BTN_LEFT] = Mouse.ButtonID.LEFT;
buttonIDs[NativeDefinitions.BTN_RIGHT] = Mouse.ButtonID.RIGHT;
buttonIDs[NativeDefinitions.BTN_MIDDLE] = Mouse.ButtonID.MIDDLE;
buttonIDs[NativeDefinitions.BTN_SIDE] = Mouse.ButtonID.SIDE;
buttonIDs[NativeDefinitions.BTN_EXTRA] = Mouse.ButtonID.EXTRA;
buttonIDs[NativeDefinitions.BTN_FORWARD] = Mouse.ButtonID.FORWARD;
buttonIDs[NativeDefinitions.BTN_BACK] = Mouse.ButtonID.BACK;
// Joystick
buttonIDs[NativeDefinitions.BTN_TRIGGER] = LinuxDevice.ButtonID.BTN_TRIGGER;
buttonIDs[NativeDefinitions.BTN_THUMB] = LinuxDevice.ButtonID.BTN_THUMB;
buttonIDs[NativeDefinitions.BTN_THUMB2] = LinuxDevice.ButtonID.BTN_THUMB2;
buttonIDs[NativeDefinitions.BTN_TOP] = LinuxDevice.ButtonID.BTN_TOP;
buttonIDs[NativeDefinitions.BTN_TOP2] = LinuxDevice.ButtonID.BTN_TOP2;
buttonIDs[NativeDefinitions.BTN_PINKIE] = LinuxDevice.ButtonID.BTN_PINKIE;
buttonIDs[NativeDefinitions.BTN_BASE] = LinuxDevice.ButtonID.BTN_BASE;
buttonIDs[NativeDefinitions.BTN_BASE2] = LinuxDevice.ButtonID.BTN_BASE2;
buttonIDs[NativeDefinitions.BTN_BASE3] = LinuxDevice.ButtonID.BTN_BASE3;
buttonIDs[NativeDefinitions.BTN_BASE4] = LinuxDevice.ButtonID.BTN_BASE4;
buttonIDs[NativeDefinitions.BTN_BASE5] = LinuxDevice.ButtonID.BTN_BASE5;
buttonIDs[NativeDefinitions.BTN_BASE6] = LinuxDevice.ButtonID.BTN_BASE6;
buttonIDs[NativeDefinitions.BTN_DEAD] = LinuxDevice.ButtonID.BTN_DEAD;
// Gamepad
buttonIDs[NativeDefinitions.BTN_A] = LinuxDevice.ButtonID.BTN_A;
buttonIDs[NativeDefinitions.BTN_B] = LinuxDevice.ButtonID.BTN_B;
buttonIDs[NativeDefinitions.BTN_C] = LinuxDevice.ButtonID.BTN_C;
buttonIDs[NativeDefinitions.BTN_X] = LinuxDevice.ButtonID.BTN_X;
buttonIDs[NativeDefinitions.BTN_Y] = LinuxDevice.ButtonID.BTN_Y;
buttonIDs[NativeDefinitions.BTN_Z] = LinuxDevice.ButtonID.BTN_Z;
buttonIDs[NativeDefinitions.BTN_TL] = LinuxDevice.ButtonID.BTN_TL;
buttonIDs[NativeDefinitions.BTN_TR] = LinuxDevice.ButtonID.BTN_TR;
buttonIDs[NativeDefinitions.BTN_TL2] = LinuxDevice.ButtonID.BTN_TL2;
buttonIDs[NativeDefinitions.BTN_TR2] = LinuxDevice.ButtonID.BTN_TR2;
buttonIDs[NativeDefinitions.BTN_SELECT] = LinuxDevice.ButtonID.BTN_SELECT;
buttonIDs[NativeDefinitions.BTN_MODE] = LinuxDevice.ButtonID.BTN_MODE;
buttonIDs[NativeDefinitions.BTN_THUMBL] = LinuxDevice.ButtonID.BTN_THUMBL;
buttonIDs[NativeDefinitions.BTN_THUMBR] = LinuxDevice.ButtonID.BTN_THUMBR;
// Digitiser
buttonIDs[NativeDefinitions.BTN_TOOL_PEN] = LinuxDevice.ButtonID.BTN_TOOL_PEN;
buttonIDs[NativeDefinitions.BTN_TOOL_RUBBER] = LinuxDevice.ButtonID.BTN_TOOL_RUBBER;
buttonIDs[NativeDefinitions.BTN_TOOL_BRUSH] = LinuxDevice.ButtonID.BTN_TOOL_BRUSH;
buttonIDs[NativeDefinitions.BTN_TOOL_PENCIL] = LinuxDevice.ButtonID.BTN_TOOL_PENCIL;
buttonIDs[NativeDefinitions.BTN_TOOL_AIRBRUSH] = LinuxDevice.ButtonID.BTN_TOOL_AIRBRUSH;
buttonIDs[NativeDefinitions.BTN_TOOL_FINGER] = LinuxDevice.ButtonID.BTN_TOOL_FINGER;
buttonIDs[NativeDefinitions.BTN_TOOL_MOUSE] = LinuxDevice.ButtonID.BTN_TOOL_MOUSE;
buttonIDs[NativeDefinitions.BTN_TOOL_LENS] = LinuxDevice.ButtonID.BTN_TOOL_LENS;
buttonIDs[NativeDefinitions.BTN_TOUCH] = LinuxDevice.ButtonID.BTN_TOUCH;
buttonIDs[NativeDefinitions.BTN_STYLUS] = LinuxDevice.ButtonID.BTN_STYLUS;
buttonIDs[NativeDefinitions.BTN_STYLUS2] = LinuxDevice.ButtonID.BTN_STYLUS2;
relAxesNames = new String[NativeDefinitions.REL_MAX];
relAxesNames[NativeDefinitions.REL_X] = "X axis";
relAxesNames[NativeDefinitions.REL_Y] = "Y axis";
relAxesNames[NativeDefinitions.REL_Z] = "Z axis";
relAxesNames[NativeDefinitions.REL_HWHEEL] ="Horizontal wheel";
relAxesNames[NativeDefinitions.REL_DIAL] = "Dial";
relAxesNames[NativeDefinitions.REL_WHEEL] = "Vertical wheel";
relAxesNames[NativeDefinitions.REL_MISC] = "Miscellaneous";
relAxesIDs = new Axis.Identifier[NativeDefinitions.REL_MAX];
relAxesIDs[NativeDefinitions.REL_X] = Axis.Identifier.X;
relAxesIDs[NativeDefinitions.REL_Y] = Axis.Identifier.Y;
relAxesIDs[NativeDefinitions.REL_Z] = Axis.Identifier.Z;
relAxesIDs[NativeDefinitions.REL_WHEEL] = Axis.Identifier.SLIDER;
// There are guesses as I have no idea what they would be used for
relAxesIDs[NativeDefinitions.REL_HWHEEL] = Axis.Identifier.SLIDER;
relAxesIDs[NativeDefinitions.REL_DIAL] = Axis.Identifier.SLIDER;
relAxesIDs[NativeDefinitions.REL_MISC] = Axis.Identifier.SLIDER;
absAxesNames = new String[NativeDefinitions.ABS_MAX];
absAxesNames[NativeDefinitions.ABS_X] = "X axis";
absAxesNames[NativeDefinitions.ABS_Y] = "Y axis";
absAxesNames[NativeDefinitions.ABS_Z] = "Z axis";
absAxesNames[NativeDefinitions.ABS_RX] = "X rate axis";
absAxesNames[NativeDefinitions.ABS_RY] = "Y rate axis";
absAxesNames[NativeDefinitions.ABS_RZ] = "Z rate axis";
absAxesNames[NativeDefinitions.ABS_THROTTLE] = "Throttle";
absAxesNames[NativeDefinitions.ABS_RUDDER] = "Rudder";
absAxesNames[NativeDefinitions.ABS_WHEEL] = "Wheel";
absAxesNames[NativeDefinitions.ABS_GAS] = "Accelerator";
absAxesNames[NativeDefinitions.ABS_BRAKE] = "Brake";
// Hats are done this way as they are mapped from two axis down to one
absAxesNames[NativeDefinitions.ABS_HAT0X] = "Hat 1";
absAxesNames[NativeDefinitions.ABS_HAT0Y] = "Hat 1";
absAxesNames[NativeDefinitions.ABS_HAT1X] = "Hat 2";
absAxesNames[NativeDefinitions.ABS_HAT1Y] = "Hat 2";
absAxesNames[NativeDefinitions.ABS_HAT2X] = "Hat 3";
absAxesNames[NativeDefinitions.ABS_HAT2Y] = "Hat 3";
absAxesNames[NativeDefinitions.ABS_HAT3X] = "Hat 4";
absAxesNames[NativeDefinitions.ABS_HAT3Y] = "Hat 4";
absAxesNames[NativeDefinitions.ABS_PRESSURE] = "Pressure";
absAxesNames[NativeDefinitions.ABS_DISTANCE] = "Distance";
absAxesNames[NativeDefinitions.ABS_TILT_X] = "X axis tilt";
absAxesNames[NativeDefinitions.ABS_TILT_Y] = "Y axis tilt";
absAxesNames[NativeDefinitions.ABS_MISC] = "Miscellaneous";
absAxesIDs = new Axis.Identifier[NativeDefinitions.ABS_MAX];
absAxesIDs[NativeDefinitions.ABS_X] = Axis.Identifier.X;
absAxesIDs[NativeDefinitions.ABS_Y] = Axis.Identifier.Y;
absAxesIDs[NativeDefinitions.ABS_Z] = Axis.Identifier.Z;
absAxesIDs[NativeDefinitions.ABS_RX] = Axis.Identifier.RX;
absAxesIDs[NativeDefinitions.ABS_RY] = Axis.Identifier.RY;
absAxesIDs[NativeDefinitions.ABS_RZ] = Axis.Identifier.RZ;
absAxesIDs[NativeDefinitions.ABS_THROTTLE] = Axis.Identifier.SLIDER;
absAxesIDs[NativeDefinitions.ABS_RUDDER] = Axis.Identifier.RZ;
absAxesIDs[NativeDefinitions.ABS_WHEEL] = Axis.Identifier.Y;
absAxesIDs[NativeDefinitions.ABS_GAS] = Axis.Identifier.SLIDER;
absAxesIDs[NativeDefinitions.ABS_BRAKE] = Axis.Identifier.SLIDER;
// Hats are done this way as they are mapped from two axis down to one
absAxesIDs[NativeDefinitions.ABS_HAT0X] = Axis.Identifier.POV;
absAxesIDs[NativeDefinitions.ABS_HAT0Y] = Axis.Identifier.POV;
absAxesIDs[NativeDefinitions.ABS_HAT1X] = Axis.Identifier.POV;
absAxesIDs[NativeDefinitions.ABS_HAT1Y] = Axis.Identifier.POV;
absAxesIDs[NativeDefinitions.ABS_HAT2X] = Axis.Identifier.POV;
absAxesIDs[NativeDefinitions.ABS_HAT2Y] = Axis.Identifier.POV;
absAxesIDs[NativeDefinitions.ABS_HAT3X] = Axis.Identifier.POV;
absAxesIDs[NativeDefinitions.ABS_HAT3Y] = Axis.Identifier.POV;
// erm, yeah
absAxesIDs[NativeDefinitions.ABS_PRESSURE] = null;
absAxesIDs[NativeDefinitions.ABS_DISTANCE] = null;
absAxesIDs[NativeDefinitions.ABS_TILT_X] = null;
absAxesIDs[NativeDefinitions.ABS_TILT_Y] = null;
absAxesIDs[NativeDefinitions.ABS_MISC] = null;
}
/** Return port type from a native port type int id
* @param nativeid The native port type
* @return The jinput port type
*/
public static Controller.PortType getPortType(int nativeid) {
// Have to do this one this way as there is no BUS_MAX
switch (nativeid) {
case NativeDefinitions.BUS_GAMEPORT :
return Controller.PortType.GAME;
case NativeDefinitions.BUS_I8042 :
return Controller.PortType.I8042;
case NativeDefinitions.BUS_PARPORT :
return Controller.PortType.PARALLEL;
case NativeDefinitions.BUS_RS232 :
return Controller.PortType.SERIAL;
case NativeDefinitions.BUS_USB :
return Controller.PortType.USB;
default:
return Controller.PortType.UNKNOWN;
}
}
/** Returns the name of a native button
* @param nativeID The native button type id
* @return The button name
*/
public static String getButtonName(int nativeID) {
String retval = INSTANCE.keyNames[nativeID];
//if(retval == null){
// retval = "Unknown button id";
// INSTANCE.keyNames[nativeID] = retval;
//}
return retval;
}
/** Retursn the name of the native relative axis
* @param nativeID The axis type ID
* @return The axis name
*/
public static String getRelAxisName(int nativeID) {
String retval = INSTANCE.relAxesNames[nativeID];
if(retval == null) {
retval = "Unknown relative axis id";
INSTANCE.relAxesNames[nativeID] = retval;
}
return retval;
}
/** Retursn the name of the native absolute axis
* @param nativeID The native axis type ID
* @return The name of the axis
*/
public static String getAbsAxisName(int nativeID) {
String retval = INSTANCE.absAxesNames[nativeID];
if(retval == null) {
retval = "Unknown absolute axis id";
INSTANCE.absAxesNames[nativeID] = retval;
}
return retval;
}
/** Gets the identifier for a relative axis
* @param nativeID The axis type ID
* @return The jinput id
*/
public static Axis.Identifier getRelAxisID(int nativeID) {
Axis.Identifier retval = INSTANCE.relAxesIDs[nativeID];
if(retval == null) {
retval = Axis.Identifier.SLIDER_VELOCITY;
INSTANCE.relAxesIDs[nativeID] = retval;
}
return retval;
}
/** Gets the identifier for a absolute axis
* @param nativeID The native axis type id
* @return The jinput id
*/
public static Axis.Identifier getAbsAxisID(int nativeID) {
Axis.Identifier retval = INSTANCE.absAxesIDs[nativeID];
if(retval == null) {
retval = Axis.Identifier.SLIDER;
INSTANCE.absAxesIDs[nativeID] = retval;
}
return retval;
}
/** Gets the identifier for a button
* @param nativeID The native button type id
* @return The jinput id
*/
public static Axis.Identifier getButtonID(int nativeID) {
Axis.Identifier retval = INSTANCE.buttonIDs[nativeID];
if(retval == null) {
//System.out.println("Creating new KeyID for nativeID " + nativeID);
retval = new LinuxKeyboard.KeyID(nativeID, getButtonName(nativeID));
INSTANCE.buttonIDs[nativeID] = retval;
}
return retval;
}
}

View file

@ -1,323 +0,0 @@
package net.java.games.input;
/**
* This file is generated from /usr/include/linux/input.h please do not edit
*/
public class NativeDefinitions {
public static final int KEY_RESERVED = 0;
public static final int KEY_ESC = 1;
public static final int KEY_1 = 2;
public static final int KEY_2 = 3;
public static final int KEY_3 = 4;
public static final int KEY_4 = 5;
public static final int KEY_5 = 6;
public static final int KEY_6 = 7;
public static final int KEY_7 = 8;
public static final int KEY_8 = 9;
public static final int KEY_9 = 10;
public static final int KEY_0 = 11;
public static final int KEY_MINUS = 12;
public static final int KEY_EQUAL = 13;
public static final int KEY_BACKSPACE = 14;
public static final int KEY_TAB = 15;
public static final int KEY_Q = 16;
public static final int KEY_W = 17;
public static final int KEY_E = 18;
public static final int KEY_R = 19;
public static final int KEY_T = 20;
public static final int KEY_Y = 21;
public static final int KEY_U = 22;
public static final int KEY_I = 23;
public static final int KEY_O = 24;
public static final int KEY_P = 25;
public static final int KEY_LEFTBRACE = 26;
public static final int KEY_RIGHTBRACE = 27;
public static final int KEY_ENTER = 28;
public static final int KEY_LEFTCTRL = 29;
public static final int KEY_A = 30;
public static final int KEY_S = 31;
public static final int KEY_D = 32;
public static final int KEY_F = 33;
public static final int KEY_G = 34;
public static final int KEY_H = 35;
public static final int KEY_J = 36;
public static final int KEY_K = 37;
public static final int KEY_L = 38;
public static final int KEY_SEMICOLON = 39;
public static final int KEY_APOSTROPHE = 40;
public static final int KEY_GRAVE = 41;
public static final int KEY_LEFTSHIFT = 42;
public static final int KEY_BACKSLASH = 43;
public static final int KEY_Z = 44;
public static final int KEY_X = 45;
public static final int KEY_C = 46;
public static final int KEY_V = 47;
public static final int KEY_B = 48;
public static final int KEY_N = 49;
public static final int KEY_M = 50;
public static final int KEY_COMMA = 51;
public static final int KEY_DOT = 52;
public static final int KEY_SLASH = 53;
public static final int KEY_RIGHTSHIFT = 54;
public static final int KEY_KPASTERISK = 55;
public static final int KEY_LEFTALT = 56;
public static final int KEY_SPACE = 57;
public static final int KEY_CAPSLOCK = 58;
public static final int KEY_F1 = 59;
public static final int KEY_F2 = 60;
public static final int KEY_F3 = 61;
public static final int KEY_F4 = 62;
public static final int KEY_F5 = 63;
public static final int KEY_F6 = 64;
public static final int KEY_F7 = 65;
public static final int KEY_F8 = 66;
public static final int KEY_F9 = 67;
public static final int KEY_F10 = 68;
public static final int KEY_NUMLOCK = 69;
public static final int KEY_SCROLLLOCK = 70;
public static final int KEY_KP7 = 71;
public static final int KEY_KP8 = 72;
public static final int KEY_KP9 = 73;
public static final int KEY_KPMINUS = 74;
public static final int KEY_KP4 = 75;
public static final int KEY_KP5 = 76;
public static final int KEY_KP6 = 77;
public static final int KEY_KPPLUS = 78;
public static final int KEY_KP1 = 79;
public static final int KEY_KP2 = 80;
public static final int KEY_KP3 = 81;
public static final int KEY_KP0 = 82;
public static final int KEY_KPDOT = 83;
public static final int KEY_103RD = 84;
public static final int KEY_F13 = 85;
public static final int KEY_102ND = 86;
public static final int KEY_F11 = 87;
public static final int KEY_F12 = 88;
public static final int KEY_F14 = 89;
public static final int KEY_F15 = 90;
public static final int KEY_F16 = 91;
public static final int KEY_F17 = 92;
public static final int KEY_F18 = 93;
public static final int KEY_F19 = 94;
public static final int KEY_F20 = 95;
public static final int KEY_KPENTER = 96;
public static final int KEY_RIGHTCTRL = 97;
public static final int KEY_KPSLASH = 98;
public static final int KEY_SYSRQ = 99;
public static final int KEY_RIGHTALT = 100;
public static final int KEY_LINEFEED = 101;
public static final int KEY_HOME = 102;
public static final int KEY_UP = 103;
public static final int KEY_PAGEUP = 104;
public static final int KEY_LEFT = 105;
public static final int KEY_RIGHT = 106;
public static final int KEY_END = 107;
public static final int KEY_DOWN = 108;
public static final int KEY_PAGEDOWN = 109;
public static final int KEY_INSERT = 110;
public static final int KEY_DELETE = 111;
public static final int KEY_MACRO = 112;
public static final int KEY_MUTE = 113;
public static final int KEY_VOLUMEDOWN = 114;
public static final int KEY_VOLUMEUP = 115;
public static final int KEY_POWER = 116;
public static final int KEY_KPEQUAL = 117;
public static final int KEY_KPPLUSMINUS = 118;
public static final int KEY_PAUSE = 119;
public static final int KEY_F21 = 120;
public static final int KEY_F22 = 121;
public static final int KEY_F23 = 122;
public static final int KEY_F24 = 123;
public static final int KEY_KPCOMMA = 124;
public static final int KEY_LEFTMETA = 125;
public static final int KEY_RIGHTMETA = 126;
public static final int KEY_COMPOSE = 127;
public static final int KEY_STOP = 128;
public static final int KEY_AGAIN = 129;
public static final int KEY_PROPS = 130;
public static final int KEY_UNDO = 131;
public static final int KEY_FRONT = 132;
public static final int KEY_COPY = 133;
public static final int KEY_OPEN = 134;
public static final int KEY_PASTE = 135;
public static final int KEY_FIND = 136;
public static final int KEY_CUT = 137;
public static final int KEY_HELP = 138;
public static final int KEY_MENU = 139;
public static final int KEY_CALC = 140;
public static final int KEY_SETUP = 141;
public static final int KEY_SLEEP = 142;
public static final int KEY_WAKEUP = 143;
public static final int KEY_FILE = 144;
public static final int KEY_SENDFILE = 145;
public static final int KEY_DELETEFILE = 146;
public static final int KEY_XFER = 147;
public static final int KEY_PROG1 = 148;
public static final int KEY_PROG2 = 149;
public static final int KEY_WWW = 150;
public static final int KEY_MSDOS = 151;
public static final int KEY_COFFEE = 152;
public static final int KEY_DIRECTION = 153;
public static final int KEY_CYCLEWINDOWS = 154;
public static final int KEY_MAIL = 155;
public static final int KEY_BOOKMARKS = 156;
public static final int KEY_COMPUTER = 157;
public static final int KEY_BACK = 158;
public static final int KEY_FORWARD = 159;
public static final int KEY_CLOSECD = 160;
public static final int KEY_EJECTCD = 161;
public static final int KEY_EJECTCLOSECD = 162;
public static final int KEY_NEXTSONG = 163;
public static final int KEY_PLAYPAUSE = 164;
public static final int KEY_PREVIOUSSONG = 165;
public static final int KEY_STOPCD = 166;
public static final int KEY_RECORD = 167;
public static final int KEY_REWIND = 168;
public static final int KEY_PHONE = 169;
public static final int KEY_ISO = 170;
public static final int KEY_CONFIG = 171;
public static final int KEY_HOMEPAGE = 172;
public static final int KEY_REFRESH = 173;
public static final int KEY_EXIT = 174;
public static final int KEY_MOVE = 175;
public static final int KEY_EDIT = 176;
public static final int KEY_SCROLLUP = 177;
public static final int KEY_SCROLLDOWN = 178;
public static final int KEY_KPLEFTPAREN = 179;
public static final int KEY_KPRIGHTPAREN = 180;
public static final int KEY_INTL1 = 181;
public static final int KEY_INTL2 = 182;
public static final int KEY_INTL3 = 183;
public static final int KEY_INTL4 = 184;
public static final int KEY_INTL5 = 185;
public static final int KEY_INTL6 = 186;
public static final int KEY_INTL7 = 187;
public static final int KEY_INTL8 = 188;
public static final int KEY_INTL9 = 189;
public static final int KEY_LANG1 = 190;
public static final int KEY_LANG2 = 191;
public static final int KEY_LANG3 = 192;
public static final int KEY_LANG4 = 193;
public static final int KEY_LANG5 = 194;
public static final int KEY_LANG6 = 195;
public static final int KEY_LANG7 = 196;
public static final int KEY_LANG8 = 197;
public static final int KEY_LANG9 = 198;
public static final int KEY_PLAYCD = 200;
public static final int KEY_PAUSECD = 201;
public static final int KEY_PROG3 = 202;
public static final int KEY_PROG4 = 203;
public static final int KEY_SUSPEND = 205;
public static final int KEY_CLOSE = 206;
public static final int KEY_UNKNOWN = 220;
public static final int KEY_BRIGHTNESSDOWN = 224;
public static final int KEY_BRIGHTNESSUP = 225;
public static final int BTN_MISC = 0x100;
public static final int BTN_0 = 0x100;
public static final int BTN_1 = 0x101;
public static final int BTN_2 = 0x102;
public static final int BTN_3 = 0x103;
public static final int BTN_4 = 0x104;
public static final int BTN_5 = 0x105;
public static final int BTN_6 = 0x106;
public static final int BTN_7 = 0x107;
public static final int BTN_8 = 0x108;
public static final int BTN_9 = 0x109;
public static final int BTN_MOUSE = 0x110;
public static final int BTN_LEFT = 0x110;
public static final int BTN_RIGHT = 0x111;
public static final int BTN_MIDDLE = 0x112;
public static final int BTN_SIDE = 0x113;
public static final int BTN_EXTRA = 0x114;
public static final int BTN_FORWARD = 0x115;
public static final int BTN_BACK = 0x116;
public static final int BTN_JOYSTICK = 0x120;
public static final int BTN_TRIGGER = 0x120;
public static final int BTN_THUMB = 0x121;
public static final int BTN_THUMB2 = 0x122;
public static final int BTN_TOP = 0x123;
public static final int BTN_TOP2 = 0x124;
public static final int BTN_PINKIE = 0x125;
public static final int BTN_BASE = 0x126;
public static final int BTN_BASE2 = 0x127;
public static final int BTN_BASE3 = 0x128;
public static final int BTN_BASE4 = 0x129;
public static final int BTN_BASE5 = 0x12a;
public static final int BTN_BASE6 = 0x12b;
public static final int BTN_DEAD = 0x12f;
public static final int BTN_GAMEPAD = 0x130;
public static final int BTN_A = 0x130;
public static final int BTN_B = 0x131;
public static final int BTN_C = 0x132;
public static final int BTN_X = 0x133;
public static final int BTN_Y = 0x134;
public static final int BTN_Z = 0x135;
public static final int BTN_TL = 0x136;
public static final int BTN_TR = 0x137;
public static final int BTN_TL2 = 0x138;
public static final int BTN_TR2 = 0x139;
public static final int BTN_SELECT = 0x13a;
public static final int BTN_START = 0x13b;
public static final int BTN_MODE = 0x13c;
public static final int BTN_THUMBL = 0x13d;
public static final int BTN_THUMBR = 0x13e;
public static final int BTN_DIGI = 0x140;
public static final int BTN_TOOL_PEN = 0x140;
public static final int BTN_TOOL_RUBBER = 0x141;
public static final int BTN_TOOL_BRUSH = 0x142;
public static final int BTN_TOOL_PENCIL = 0x143;
public static final int BTN_TOOL_AIRBRUSH = 0x144;
public static final int BTN_TOOL_FINGER = 0x145;
public static final int BTN_TOOL_MOUSE = 0x146;
public static final int BTN_TOOL_LENS = 0x147;
public static final int BTN_TOUCH = 0x14a;
public static final int BTN_STYLUS = 0x14b;
public static final int BTN_STYLUS2 = 0x14c;
public static final int KEY_MAX = 0x1ff;
public static final int REL_X = 0x00;
public static final int REL_Y = 0x01;
public static final int REL_Z = 0x02;
public static final int REL_HWHEEL = 0x06;
public static final int REL_DIAL = 0x07;
public static final int REL_WHEEL = 0x08;
public static final int REL_MISC = 0x09;
public static final int REL_MAX = 0x0f;
public static final int ABS_X = 0x00;
public static final int ABS_Y = 0x01;
public static final int ABS_Z = 0x02;
public static final int ABS_RX = 0x03;
public static final int ABS_RY = 0x04;
public static final int ABS_RZ = 0x05;
public static final int ABS_THROTTLE = 0x06;
public static final int ABS_RUDDER = 0x07;
public static final int ABS_WHEEL = 0x08;
public static final int ABS_GAS = 0x09;
public static final int ABS_BRAKE = 0x0a;
public static final int ABS_HAT0X = 0x10;
public static final int ABS_HAT0Y = 0x11;
public static final int ABS_HAT1X = 0x12;
public static final int ABS_HAT1Y = 0x13;
public static final int ABS_HAT2X = 0x14;
public static final int ABS_HAT2Y = 0x15;
public static final int ABS_HAT3X = 0x16;
public static final int ABS_HAT3Y = 0x17;
public static final int ABS_PRESSURE = 0x18;
public static final int ABS_DISTANCE = 0x19;
public static final int ABS_TILT_X = 0x1a;
public static final int ABS_TILT_Y = 0x1b;
public static final int ABS_MISC = 0x1c;
public static final int ABS_MAX = 0x1f;
public static final int BUS_PCI = 0x01;
public static final int BUS_ISAPNP = 0x02;
public static final int BUS_USB = 0x03;
public static final int BUS_ISA = 0x10;
public static final int BUS_I8042 = 0x11;
public static final int BUS_XTKBD = 0x12;
public static final int BUS_RS232 = 0x13;
public static final int BUS_GAMEPORT = 0x14;
public static final int BUS_PARPORT = 0x15;
public static final int BUS_AMIGA = 0x16;
public static final int BUS_ADB = 0x17;
public static final int BUS_I2C = 0x18;
}

View file

@ -23,46 +23,47 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/ */
package net.java.games.input;
#ifndef JoystickDevice_h /**
#define JoystickDevice_h * @author elias
*/
final class LinuxAbsInfo {
private int value;
private int minimum;
private int maximum;
private int fuzz;
private int flat;
#include <stdint.h> public final void set(int value, int min, int max, int fuzz, int flat) {
#include <linux/input.h> this.value = value;
#include "eventInterfaceTypes.h" this.minimum = min;
#include "Device.h" this.maximum = max;
this.fuzz = fuzz;
this.flat = flat;
}
class JoystickDevice : public Device { public final String toString() {
return "AbsInfo: value = " + value + " | min = " + minimum + " | max = " + maximum + " | fuzz = " + fuzz + " | flat = " + flat;
}
private: public final int getValue() {
int fd; return value;
int inited; }
char *name;
int numButtons;
int *absAxesData;
uint8_t *buttonData;
int numAbsAxes;
public: final int getMax() {
JoystickDevice(char *deviceFilename); return maximum;
int getNumberRelAxes(); }
int getNumberAbsAxes();
int getNumberButtons();
const char *getName();
int getBusType();
int getVendorID();
int getProductID();
int getVersion();
void getSupportedRelAxes(int supportedAxis[]);
void getSupportedAbsAxes(int supportedAxis[]);
void getSupportedButtons(int supportedButtons[]);
int poll();
void getPolledData(int relAxesData[], int absAxesData[], int buttonData[]);
int getAbsAxisMinimum(int axisNumber);
int getAbsAxisMaximum(int axisNumber);
int getAbsAxisFuzz(int axisNumber);
int isValidDevice();
}; final int getMin() {
return minimum;
}
final int getFlat() {
return flat;
}
#endif //eventInterface_eventDevice_h final int getFuzz() {
return fuzz;
}
}

View file

@ -0,0 +1,74 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.io.IOException;
/** Represents a Linux controller
* @author elias
* @version 1.0
*/
final class LinuxAbstractController extends AbstractController {
private final PortType port;
private final LinuxEventDevice device;
private final Type type;
protected LinuxAbstractController(LinuxEventDevice device, Component[] components, Controller[] children, Rumbler[] rumblers, Type type) throws IOException {
super(device.getName(), components, children, rumblers);
this.device = device;
this.port = device.getPortType();
this.type = type;
}
public final PortType getPortType() {
return port;
}
public final void pollDevice() throws IOException {
device.pollKeyStates();
}
protected final boolean getNextDeviceEvent(Event event) throws IOException {
return LinuxControllers.getNextDeviceEvent(event, device);
}
public Type getType() {
return type;
}
}

View file

@ -23,46 +23,40 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/ */
package net.java.games.input;
#ifndef MixedDevice_h /**
#define MixedDevice_h * @author elias
*/
final class LinuxAxisDescriptor {
private int type;
private int code;
#include <stdint.h> public final void set(int type, int code) {
#include <linux/input.h> this.type = type;
#include "eventInterfaceTypes.h" this.code = code;
#include "Device.h" }
#include "EventDevice.h"
#include "JoystickDevice.h"
#include "MixedDevice.h"
class MixedDevice : public Device { public final int getType() {
return type;
}
private: public final int getCode() {
JoystickDevice *joystickDevice; return code;
EventDevice *eventDevice; }
public: public final int hashCode() {
MixedDevice(JoystickDevice *joystickDevice, EventDevice *eventDevice); return type ^ code;
int getNumberRelAxes(); }
int getNumberAbsAxes();
int getNumberButtons();
const char *getName();
int getBusType();
int getVendorID();
int getProductID();
int getVersion();
void getSupportedRelAxes(int supportedAxis[]);
void getSupportedAbsAxes(int supportedAxis[]);
void getSupportedButtons(int supportedButtons[]);
void getSupportedRelAxes(short supportedAxis[]);
void getSupportedAbsAxes(short supportedAxis[]);
void getSupportedButtons(short supportedButtons[]);
int poll();
void getPolledData(int relAxesData[], int absAxesData[], int buttonData[]);
int getAbsAxisMinimum(int axisNumber);
int getAbsAxisMaximum(int axisNumber);
int getAbsAxisFuzz(int axisNumber);
}; public final boolean equals(Object other) {
if (!(other instanceof LinuxAxisDescriptor))
return false;
LinuxAxisDescriptor descriptor = (LinuxAxisDescriptor)other;
return descriptor.type == type && descriptor.code == code;
}
#endif //eventInterface_eventDevice_h public final String toString() {
return "LinuxAxis: type = 0x" + Integer.toHexString(type) + ", code = 0x" + Integer.toHexString(code);
}
}

View file

@ -0,0 +1,32 @@
package net.java.games.input;
import java.io.IOException;
public class LinuxCombinedController extends AbstractController {
private LinuxAbstractController eventController;
private LinuxJoystickAbstractController joystickController;
LinuxCombinedController(LinuxAbstractController eventController, LinuxJoystickAbstractController joystickController) {
super(eventController.getName(), joystickController.getComponents(), eventController.getControllers(), eventController.getRumblers());
this.eventController = eventController;
this.joystickController = joystickController;
}
protected boolean getNextDeviceEvent(Event event) throws IOException {
return joystickController.getNextDeviceEvent(event);
}
public final PortType getPortType() {
return eventController.getPortType();
}
public final void pollDevice() throws IOException {
eventController.pollDevice();
joystickController.pollDevice();
}
public Type getType() {
return eventController.getType();
}
}

View file

@ -0,0 +1,78 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.io.IOException;
/** Represents a linux Axis
* @author elias
* @version 1.0
*/
class LinuxComponent extends AbstractComponent {
private final LinuxEventComponent component;
public LinuxComponent(LinuxEventComponent component) {
super(component.getIdentifier().getName(), component.getIdentifier());
this.component = component;
}
public final boolean isRelative() {
return component.isRelative();
}
public final boolean isAnalog() {
return component.isAnalog();
}
protected float poll() throws IOException {
return convertValue(LinuxControllers.poll(component), component.getDescriptor());
}
float convertValue(float value, LinuxAxisDescriptor descriptor) {
return getComponent().convertValue(value);
}
public final float getDeadZone() {
return component.getDeadZone();
}
public final LinuxEventComponent getComponent() {
return component;
}
}

View file

@ -0,0 +1,42 @@
/**
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
import java.io.IOException;
/**
* @author elias
*/
final class LinuxConstantFF extends LinuxForceFeedbackEffect {
public LinuxConstantFF(LinuxEventDevice device) throws IOException {
super(device);
}
protected final int upload(int id, float intensity) throws IOException {
int scaled_intensity = Math.round(intensity*0x7fff);
return getDevice().uploadConstantEffect(id, 0, 0, 0, 0, 0, scaled_intensity, 0, 0, 0, 0);
}
}

View file

@ -0,0 +1,81 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.io.IOException;
/** helper methods for Linux specific Controllers
* @author elias
* @version 1.0
*/
final class LinuxControllers {
private final static LinuxEvent linux_event = new LinuxEvent();
/* Declared synchronized to protect linux_event */
public final static synchronized boolean getNextDeviceEvent(Event event, LinuxEventDevice device) throws IOException {
while (device.getNextEvent(linux_event)) {
LinuxAxisDescriptor descriptor = linux_event.getDescriptor();
LinuxComponent component = device.mapDescriptor(descriptor);
if (component != null) {
float value = component.convertValue(linux_event.getValue(), descriptor);
event.set(component, value, linux_event.getNanos());
return true;
}
}
return false;
}
private final static LinuxAbsInfo abs_info = new LinuxAbsInfo();
/* Declared synchronized to protect abs_info */
public final static synchronized float poll(LinuxEventComponent event_component) throws IOException {
int native_type = event_component.getDescriptor().getType();
switch (native_type) {
case NativeDefinitions.EV_KEY:
int native_code = event_component.getDescriptor().getCode();
float state = event_component.getDevice().isKeySet(native_code) ? 1f : 0f;
return state;
case NativeDefinitions.EV_ABS:
event_component.getAbsInfo(abs_info);
return abs_info.getValue();
default:
throw new RuntimeException("Unkown native_type: " + native_type);
}
}
}

View file

@ -23,15 +23,17 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/ */
package net.java.games.input;
#if !defined(joystickInterface_h) import java.io.IOException;
#define joystickInterface_h import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
#include "Device.h" /**
* @author elias
int jsGetJoystickInterfaceVersionNumber(); */
int jsInit(); interface LinuxDevice {
int jsGetNumberDevices(); void close() throws IOException;
void jsGetDevices(Device **deviceList); }
#endif //joystickInterface_h

View file

@ -0,0 +1,62 @@
/**
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
import java.io.IOException;
abstract class LinuxDeviceTask {
public final static int INPROGRESS = 1;
public final static int COMPLETED = 2;
public final static int FAILED = 3;
private Object result;
private IOException exception;
private int state = INPROGRESS;
public final void doExecute() {
try {
result = execute();
state = COMPLETED;
} catch (IOException e) {
exception = e;
state = FAILED;
}
}
public final IOException getException() {
return exception;
}
public final Object getResult() {
return result;
}
public final int getState() {
return state;
}
protected abstract Object execute() throws IOException;
}

View file

@ -0,0 +1,91 @@
/**
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
/**
* Linux doesn't have proper support for force feedback
* from different threads since it relies on PIDs
* to determine ownership of a particular effect slot.
* Therefore we have to hack around this by
* making sure everything related to FF
* (including the final device close that performs
* and implicit deletion of all the process' effects)
* is run on a single thread.
*/
final class LinuxDeviceThread extends Thread {
private final List<LinuxDeviceTask> tasks = new ArrayList<>();
public LinuxDeviceThread() {
setDaemon(true);
start();
}
public synchronized final void run() {
while (true) {
if (!tasks.isEmpty()) {
LinuxDeviceTask task = tasks.remove(0);
task.doExecute();
synchronized (task) {
task.notify();
}
} else {
try {
wait();
} catch (InterruptedException e) {
// ignore
}
}
}
}
public final Object execute(LinuxDeviceTask task) throws IOException {
synchronized (this) {
tasks.add(task);
notify();
}
synchronized (task) {
while (task.getState() == LinuxDeviceTask.INPROGRESS) {
try {
task.wait();
} catch (InterruptedException e) {
// ignore
}
}
}
switch (task.getState()) {
case LinuxDeviceTask.COMPLETED:
return task.getResult();
case LinuxDeviceTask.FAILED:
throw task.getException();
default:
throw new RuntimeException("Invalid task state: " + task.getState());
}
}
}

View file

@ -0,0 +1,477 @@
/*
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
import net.java.games.util.plugins.Plugin;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.ArrayList;
import java.io.IOException;
import java.io.File;
import java.io.FilenameFilter;
import java.security.AccessController;
import java.security.PrivilegedAction;
/** Environment plugin for linux
* @author elias
* @author Jeremy Booth (jeremy@newdawnsoftware.com)
*/
public final class LinuxEnvironmentPlugin extends ControllerEnvironment implements Plugin {
private final static String LIBNAME = "jinput-linux";
private final static String POSTFIX64BIT = "64";
private static boolean supported = false;
private final Controller[] controllers;
private final List<LinuxDevice> devices = new ArrayList<LinuxDevice>();
private final static LinuxDeviceThread device_thread = new LinuxDeviceThread();
/**
* Static utility method for loading native libraries.
* It will try to load from either the path given by
* the net.java.games.input.librarypath property
* or through System.loadLibrary().
*
*/
static void loadLibrary(final String lib_name) {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
String lib_path = System.getProperty("net.java.games.input.librarypath");
try {
if(lib_path != null)
System.load(lib_path + File.separator + System.mapLibraryName(lib_name));
else
System.loadLibrary(lib_name);
} catch(UnsatisfiedLinkError e) {
log("Failed to load library: " + e.getMessage());
e.printStackTrace();
supported = false;
}
return null;
});
}
static String getPrivilegedProperty(final String property) {
return AccessController.doPrivileged((PrivilegedAction<String>)() -> System.getProperty(property));
}
static String getPrivilegedProperty(final String property, final String default_value) {
return AccessController.doPrivileged((PrivilegedAction<String>)() -> System.getProperty(property, default_value));
}
static {
String osName = getPrivilegedProperty("os.name", "").trim();
if(osName.equals("Linux")) {
supported = true;
if("i386".equals(getPrivilegedProperty("os.arch"))) {
loadLibrary(LIBNAME);
} else {
loadLibrary(LIBNAME + POSTFIX64BIT);
}
}
}
public final static Object execute(LinuxDeviceTask task) throws IOException {
return device_thread.execute(task);
}
public LinuxEnvironmentPlugin() {
if(isSupported()) {
this.controllers = enumerateControllers();
log("Linux plugin claims to have found " + controllers.length + " controllers");
AccessController.doPrivileged((PrivilegedAction<Void>)() -> {
Runtime.getRuntime().addShutdownHook(new ShutdownHook());
return null;
});
} else {
controllers = new Controller[0];
}
}
/** Returns a list of all controllers available to this environment,
* or an empty array if there are no controllers in this environment.
* @return Returns a list of all controllers available to this environment,
* or an empty array if there are no controllers in this environment.
*/
public final Controller[] getControllers() {
return controllers;
}
private final static Component[] createComponents(List<LinuxEventComponent> event_components, LinuxEventDevice device) {
LinuxEventComponent[][] povs = new LinuxEventComponent[4][2];
List<LinuxComponent> components = new ArrayList<>();
for(int i = 0; i < event_components.size(); i++) {
LinuxEventComponent event_component = event_components.get(i);
Component.Identifier identifier = event_component.getIdentifier();
if(identifier == Component.Identifier.Axis.POV) {
int native_code = event_component.getDescriptor().getCode();
switch(native_code) {
case NativeDefinitions.ABS_HAT0X:
povs[0][0] = event_component;
break;
case NativeDefinitions.ABS_HAT0Y:
povs[0][1] = event_component;
break;
case NativeDefinitions.ABS_HAT1X:
povs[1][0] = event_component;
break;
case NativeDefinitions.ABS_HAT1Y:
povs[1][1] = event_component;
break;
case NativeDefinitions.ABS_HAT2X:
povs[2][0] = event_component;
break;
case NativeDefinitions.ABS_HAT2Y:
povs[2][1] = event_component;
break;
case NativeDefinitions.ABS_HAT3X:
povs[3][0] = event_component;
break;
case NativeDefinitions.ABS_HAT3Y:
povs[3][1] = event_component;
break;
default:
log("Unknown POV instance: " + native_code);
break;
}
} else if(identifier != null) {
LinuxComponent component = new LinuxComponent(event_component);
components.add(component);
device.registerComponent(event_component.getDescriptor(), component);
}
}
for(int i = 0; i < povs.length; i++) {
LinuxEventComponent x = povs[i][0];
LinuxEventComponent y = povs[i][1];
if(x != null && y != null) {
LinuxComponent controller_component = new LinuxPOV(x, y);
components.add(controller_component);
device.registerComponent(x.getDescriptor(), controller_component);
device.registerComponent(y.getDescriptor(), controller_component);
}
}
Component[] components_array = new Component[components.size()];
components.toArray(components_array);
return components_array;
}
private final static Mouse createMouseFromDevice(LinuxEventDevice device, Component[] components) throws IOException {
Mouse mouse = new LinuxMouse(device, components, new Controller[]{}, device.getRumblers());
if(mouse.getX() != null && mouse.getY() != null && mouse.getPrimaryButton() != null)
return mouse;
else
return null;
}
private final static Keyboard createKeyboardFromDevice(LinuxEventDevice device, Component[] components) throws IOException {
Keyboard keyboard = new LinuxKeyboard(device, components, new Controller[]{}, device.getRumblers());
return keyboard;
}
private final static Controller createJoystickFromDevice(LinuxEventDevice device, Component[] components, Controller.Type type) throws IOException {
Controller joystick = new LinuxAbstractController(device, components, new Controller[]{}, device.getRumblers(), type);
return joystick;
}
private final static Controller createControllerFromDevice(LinuxEventDevice device) throws IOException {
List<LinuxEventComponent> event_components = device.getComponents();
Component[] components = createComponents(event_components, device);
Controller.Type type = device.getType();
if(type == Controller.Type.MOUSE) {
return createMouseFromDevice(device, components);
} else if(type == Controller.Type.KEYBOARD) {
return createKeyboardFromDevice(device, components);
} else if(type == Controller.Type.STICK || type == Controller.Type.GAMEPAD) {
return createJoystickFromDevice(device, components, type);
} else
return null;
}
private final Controller[] enumerateControllers() {
List<Controller> controllers = new ArrayList<>();
List<Controller> eventControllers = new ArrayList<>();
List<Controller> jsControllers = new ArrayList<>();
enumerateEventControllers(eventControllers);
enumerateJoystickControllers(jsControllers);
for(int i = 0; i < eventControllers.size(); i++) {
for(int j = 0; j < jsControllers.size(); j++) {
Controller evController = eventControllers.get(i);
Controller jsController = jsControllers.get(j);
// compare
// Check if the nodes have the same name
if(evController.getName().equals(jsController.getName())) {
// Check they have the same component count
Component[] evComponents = evController.getComponents();
Component[] jsComponents = jsController.getComponents();
if(evComponents.length == jsComponents.length) {
boolean foundADifference = false;
// check the component pairs are of the same type
for(int k = 0; k < evComponents.length; k++) {
// Check the type of the component is the same
if(!(evComponents[k].getIdentifier() == jsComponents[k].getIdentifier())) {
foundADifference = true;
}
}
if(!foundADifference) {
controllers.add(new LinuxCombinedController((LinuxAbstractController) eventControllers.remove(i), (LinuxJoystickAbstractController) jsControllers.remove(j)));
i--;
j--;
break;
}
}
}
}
}
controllers.addAll(eventControllers);
controllers.addAll(jsControllers);
Controller[] controllers_array = new Controller[controllers.size()];
controllers.toArray(controllers_array);
return controllers_array;
}
private final static Component.Identifier.Button getButtonIdentifier(int index) {
switch(index) {
case 0:
return Component.Identifier.Button._0;
case 1:
return Component.Identifier.Button._1;
case 2:
return Component.Identifier.Button._2;
case 3:
return Component.Identifier.Button._3;
case 4:
return Component.Identifier.Button._4;
case 5:
return Component.Identifier.Button._5;
case 6:
return Component.Identifier.Button._6;
case 7:
return Component.Identifier.Button._7;
case 8:
return Component.Identifier.Button._8;
case 9:
return Component.Identifier.Button._9;
case 10:
return Component.Identifier.Button._10;
case 11:
return Component.Identifier.Button._11;
case 12:
return Component.Identifier.Button._12;
case 13:
return Component.Identifier.Button._13;
case 14:
return Component.Identifier.Button._14;
case 15:
return Component.Identifier.Button._15;
case 16:
return Component.Identifier.Button._16;
case 17:
return Component.Identifier.Button._17;
case 18:
return Component.Identifier.Button._18;
case 19:
return Component.Identifier.Button._19;
case 20:
return Component.Identifier.Button._20;
case 21:
return Component.Identifier.Button._21;
case 22:
return Component.Identifier.Button._22;
case 23:
return Component.Identifier.Button._23;
case 24:
return Component.Identifier.Button._24;
case 25:
return Component.Identifier.Button._25;
case 26:
return Component.Identifier.Button._26;
case 27:
return Component.Identifier.Button._27;
case 28:
return Component.Identifier.Button._28;
case 29:
return Component.Identifier.Button._29;
case 30:
return Component.Identifier.Button._30;
case 31:
return Component.Identifier.Button._31;
default:
return null;
}
}
private final static Controller createJoystickFromJoystickDevice(LinuxJoystickDevice device) {
List<AbstractComponent> components = new ArrayList<>();
byte[] axisMap = device.getAxisMap();
char[] buttonMap = device.getButtonMap();
LinuxJoystickAxis[] hatBits = new LinuxJoystickAxis[6];
for(int i = 0; i < device.getNumButtons(); i++) {
Component.Identifier button_id = LinuxNativeTypesMap.getButtonID(buttonMap[i]);
if(button_id != null) {
LinuxJoystickButton button = new LinuxJoystickButton(button_id);
device.registerButton(i, button);
components.add(button);
}
}
for(int i = 0; i < device.getNumAxes(); i++) {
Component.Identifier.Axis axis_id;
axis_id = (Component.Identifier.Axis) LinuxNativeTypesMap.getAbsAxisID(axisMap[i]);
LinuxJoystickAxis axis = new LinuxJoystickAxis(axis_id);
device.registerAxis(i, axis);
if(axisMap[i] == NativeDefinitions.ABS_HAT0X) {
hatBits[0] = axis;
} else if(axisMap[i] == NativeDefinitions.ABS_HAT0Y) {
hatBits[1] = axis;
axis = new LinuxJoystickPOV(Component.Identifier.Axis.POV, hatBits[0], hatBits[1]);
device.registerPOV((LinuxJoystickPOV) axis);
components.add(axis);
} else if(axisMap[i] == NativeDefinitions.ABS_HAT1X) {
hatBits[2] = axis;
} else if(axisMap[i] == NativeDefinitions.ABS_HAT1Y) {
hatBits[3] = axis;
axis = new LinuxJoystickPOV(Component.Identifier.Axis.POV, hatBits[2], hatBits[3]);
device.registerPOV((LinuxJoystickPOV) axis);
components.add(axis);
} else if(axisMap[i] == NativeDefinitions.ABS_HAT2X) {
hatBits[4] = axis;
} else if(axisMap[i] == NativeDefinitions.ABS_HAT2Y) {
hatBits[5] = axis;
axis = new LinuxJoystickPOV(Component.Identifier.Axis.POV, hatBits[4], hatBits[5]);
device.registerPOV((LinuxJoystickPOV) axis);
components.add(axis);
} else {
components.add(axis);
}
}
return new LinuxJoystickAbstractController(device, components.toArray(new Component[]{}), new Controller[]{}, new Rumbler[]{});
}
private final void enumerateJoystickControllers(List<Controller> controllers) {
File[] joystick_device_files = enumerateJoystickDeviceFiles("/dev/input");
if(joystick_device_files == null || joystick_device_files.length == 0) {
joystick_device_files = enumerateJoystickDeviceFiles("/dev");
if(joystick_device_files == null)
return;
}
for(int i = 0; i < joystick_device_files.length; i++) {
File event_file = joystick_device_files[i];
try {
String path = getAbsolutePathPrivileged(event_file);
LinuxJoystickDevice device = new LinuxJoystickDevice(path);
Controller controller = createJoystickFromJoystickDevice(device);
if(controller != null) {
controllers.add(controller);
devices.add(device);
} else
device.close();
} catch(IOException e) {
log("Failed to open device (" + event_file + "): " + e.getMessage());
}
}
}
private final static File[] enumerateJoystickDeviceFiles(final String dev_path) {
final File dev = new File(dev_path);
return listFilesPrivileged(dev, new FilenameFilter() {
public final boolean accept(File dir, String name) {
return name.startsWith("js");
}
});
}
private static String getAbsolutePathPrivileged(final File file) {
return AccessController.doPrivileged((PrivilegedAction<String>) () -> file.getAbsolutePath());
}
private static File[] listFilesPrivileged(final File dir, final FilenameFilter filter) {
return AccessController.doPrivileged((PrivilegedAction<File[]>) () -> {
File[] files = dir.listFiles(filter);
if(files == null) {
log("dir " + dir.getName() + " exists: " + dir.exists() + ", is writable: " + dir.isDirectory());
files = new File[]{};
} else {
Arrays.sort(files, Comparator.comparing(File::getName));
}
return files;
});
}
private final void enumerateEventControllers(List<Controller> controllers) {
final File dev = new File("/dev/input");
File[] event_device_files = listFilesPrivileged(dev, (File dir, String name) -> name.startsWith("event"));
if(event_device_files == null)
return;
for(int i = 0; i < event_device_files.length; i++) {
File event_file = event_device_files[i];
try {
String path = getAbsolutePathPrivileged(event_file);
LinuxEventDevice device = new LinuxEventDevice(path);
try {
Controller controller = createControllerFromDevice(device);
if(controller != null) {
controllers.add(controller);
devices.add(device);
} else
device.close();
} catch(IOException e) {
log("Failed to create Controller: " + e.getMessage());
device.close();
}
} catch(IOException e) {
log("Failed to open device (" + event_file + "): " + e.getMessage());
}
}
}
private final class ShutdownHook extends Thread {
public final void run() {
for(int i = 0; i < devices.size(); i++) {
try {
LinuxDevice device = devices.get(i);
device.close();
} catch(IOException e) {
log("Failed to close device: " + e.getMessage());
}
}
}
}
public boolean isSupported() {
return supported;
}
}

View file

@ -0,0 +1,53 @@
/**
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
/**
* @author elias
*/
final class LinuxEvent {
private long nanos;
private final LinuxAxisDescriptor descriptor = new LinuxAxisDescriptor();
private int value;
public final void set(long seconds, long microseconds, int type, int code, int value) {
this.nanos = (seconds*1000000 + microseconds)*1000;
this.descriptor.set(type, code);
this.value = value;
}
public final int getValue() {
return value;
}
public final LinuxAxisDescriptor getDescriptor() {
return descriptor;
}
public final long getNanos() {
return nanos;
}
}

View file

@ -0,0 +1,115 @@
/**
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
import java.io.IOException;
/**
* @author elias
* @author Jeremy Booth (jeremy@newdawnsoftware.com)
*/
final class LinuxEventComponent {
private final LinuxEventDevice device;
private final Component.Identifier identifier;
private final Controller.Type button_trait;
private final boolean is_relative;
private final LinuxAxisDescriptor descriptor;
private final int min;
private final int max;
private final int flat;
public LinuxEventComponent(LinuxEventDevice device, Component.Identifier identifier, boolean is_relative, int native_type, int native_code) throws IOException {
this.device = device;
this.identifier = identifier;
if (native_type == NativeDefinitions.EV_KEY)
this.button_trait = LinuxNativeTypesMap.guessButtonTrait(native_code);
else
this.button_trait = Controller.Type.UNKNOWN;
this.is_relative = is_relative;
this.descriptor = new LinuxAxisDescriptor();
descriptor.set(native_type, native_code);
if (native_type == NativeDefinitions.EV_ABS) {
LinuxAbsInfo abs_info = new LinuxAbsInfo();
getAbsInfo(abs_info);
this.min = abs_info.getMin();
this.max = abs_info.getMax();
this.flat = abs_info.getFlat();
} else {
this.min = Integer.MIN_VALUE;
this.max = Integer.MAX_VALUE;
this.flat = 0;
}
}
public final LinuxEventDevice getDevice() {
return device;
}
public final void getAbsInfo(LinuxAbsInfo abs_info) throws IOException {
assert descriptor.getType() == NativeDefinitions.EV_ABS;
device.getAbsInfo(descriptor.getCode(), abs_info);
}
public final Controller.Type getButtonTrait() {
return button_trait;
}
public final Component.Identifier getIdentifier() {
return identifier;
}
public final LinuxAxisDescriptor getDescriptor() {
return descriptor;
}
public final boolean isRelative() {
return is_relative;
}
public final boolean isAnalog() {
return identifier instanceof Component.Identifier.Axis && identifier != Component.Identifier.Axis.POV;
}
final float convertValue(float value) {
if (identifier instanceof Component.Identifier.Axis && !is_relative) {
// Some axes have min = max = 0
if (min == max)
return 0;
if (value > max)
value = max;
else if (value < min)
value = min;
return 2*(value - min)/(max - min) - 1;
} else {
return value;
}
}
final float getDeadZone() {
return flat/(2f*(max - min));
}
}

View file

@ -0,0 +1,367 @@
/*
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
import java.io.IOException;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
/**
* @author elias
*/
final class LinuxEventDevice implements LinuxDevice {
private final Map<LinuxAxisDescriptor, LinuxComponent> component_map = new HashMap<>();
private final Rumbler[] rumblers;
private final long fd;
private final String name;
private final LinuxInputID input_id;
private final List<LinuxEventComponent> components;
private final Controller.Type type;
/* Closed state variable that protects the validity of the file descriptor.
* Access to the closed state must be synchronized
*/
private boolean closed;
/* Access to the key_states array could be synchronized, but
* it doesn't hurt to have multiple threads read/write from/to it
*/
private final byte[] key_states = new byte[NativeDefinitions.KEY_MAX/8 + 1];
public LinuxEventDevice(String filename) throws IOException {
long fd;
boolean detect_rumblers = true;
try {
fd = nOpen(filename, true);
} catch (IOException e) {
fd = nOpen(filename, false);
detect_rumblers = false;
}
this.fd = fd;
try {
this.name = getDeviceName();
this.input_id = getDeviceInputID();
this.components = getDeviceComponents();
if (detect_rumblers)
this.rumblers = enumerateRumblers();
else
this.rumblers = new Rumbler[]{};
this.type = guessType();
} catch (IOException e) {
close();
throw e;
}
}
private final static native long nOpen(String filename, boolean rw) throws IOException;
public final Controller.Type getType() {
return type;
}
private final static int countComponents(List<LinuxEventComponent> components, Class<?> id_type, boolean relative) {
int count = 0;
for (int i = 0; i < components.size(); i++) {
LinuxEventComponent component = components.get(i);
if (id_type.isInstance(component.getIdentifier()) && relative == component.isRelative())
count++;
}
return count;
}
private final Controller.Type guessType() throws IOException {
List<LinuxEventComponent> components = getComponents();
if (components.size() == 0)
return Controller.Type.UNKNOWN;
int num_rel_axes = countComponents(components, Component.Identifier.Axis.class, true);
int num_abs_axes = countComponents(components, Component.Identifier.Axis.class, false);
int num_keys = countComponents(components, Component.Identifier.Key.class, false);
int mouse_traits = 0;
int keyboard_traits = 0;
int joystick_traits = 0;
int gamepad_traits = 0;
if (name.toLowerCase().indexOf("mouse") != -1)
mouse_traits++;
if (name.toLowerCase().indexOf("keyboard") != -1)
keyboard_traits++;
if (name.toLowerCase().indexOf("joystick") != -1)
joystick_traits++;
if (name.toLowerCase().indexOf("gamepad") != -1)
gamepad_traits++;
int num_keyboard_button_traits = 0;
int num_mouse_button_traits = 0;
int num_joystick_button_traits = 0;
int num_gamepad_button_traits = 0;
// count button traits
for (int i = 0; i < components.size(); i++) {
LinuxEventComponent component = components.get(i);
if (component.getButtonTrait() == Controller.Type.MOUSE)
num_mouse_button_traits++;
else if (component.getButtonTrait() == Controller.Type.KEYBOARD)
num_keyboard_button_traits++;
else if (component.getButtonTrait() == Controller.Type.GAMEPAD)
num_gamepad_button_traits++;
else if (component.getButtonTrait() == Controller.Type.STICK)
num_joystick_button_traits++;
}
if ((num_mouse_button_traits >= num_keyboard_button_traits) && (num_mouse_button_traits >= num_joystick_button_traits) && (num_mouse_button_traits >= num_gamepad_button_traits)) {
mouse_traits++;
} else if ((num_keyboard_button_traits >= num_mouse_button_traits) && (num_keyboard_button_traits >= num_joystick_button_traits) && (num_keyboard_button_traits >= num_gamepad_button_traits)) {
keyboard_traits++;
} else if ((num_joystick_button_traits >= num_keyboard_button_traits) && (num_joystick_button_traits >= num_mouse_button_traits) && (num_joystick_button_traits >= num_gamepad_button_traits)) {
joystick_traits++;
} else if ((num_gamepad_button_traits >= num_keyboard_button_traits) && (num_gamepad_button_traits >= num_mouse_button_traits) && (num_gamepad_button_traits >= num_joystick_button_traits)) {
gamepad_traits++;
}
if (num_rel_axes >= 2) {
mouse_traits++;
}
if (num_abs_axes >= 2) {
joystick_traits++;
gamepad_traits++;
}
if ((mouse_traits >= keyboard_traits) && (mouse_traits >= joystick_traits) && (mouse_traits >= gamepad_traits)) {
return Controller.Type.MOUSE;
} else if ((keyboard_traits >= mouse_traits) && (keyboard_traits >= joystick_traits) && (keyboard_traits >= gamepad_traits)) {
return Controller.Type.KEYBOARD;
} else if ((joystick_traits >= mouse_traits) && (joystick_traits >= keyboard_traits) && (joystick_traits >= gamepad_traits)) {
return Controller.Type.STICK;
} else if ((gamepad_traits >= mouse_traits) && (gamepad_traits >= keyboard_traits) && (gamepad_traits >= joystick_traits)) {
return Controller.Type.GAMEPAD;
} else
return null;
}
private final Rumbler[] enumerateRumblers() {
List<Rumbler> rumblers = new ArrayList<>();
try {
int num_effects = getNumEffects();
if (num_effects <= 0)
return rumblers.toArray(new Rumbler[]{});
byte[] ff_bits = getForceFeedbackBits();
if (isBitSet(ff_bits, NativeDefinitions.FF_RUMBLE) && num_effects > rumblers.size()) {
rumblers.add(new LinuxRumbleFF(this));
}
} catch (IOException e) {
LinuxEnvironmentPlugin.log("Failed to enumerate rumblers: " + e.getMessage());
}
return rumblers.toArray(new Rumbler[]{});
}
public final Rumbler[] getRumblers() {
return rumblers;
}
public final synchronized int uploadRumbleEffect(int id, int trigger_button, int direction, int trigger_interval, int replay_length, int replay_delay, int strong_magnitude, int weak_magnitude) throws IOException {
checkClosed();
return nUploadRumbleEffect(fd, id, direction, trigger_button, trigger_interval, replay_length, replay_delay, strong_magnitude, weak_magnitude);
}
private final static native int nUploadRumbleEffect(long fd, int id, int direction, int trigger_button, int trigger_interval, int replay_length, int replay_delay, int strong_magnitude, int weak_magnitude) throws IOException;
public final synchronized int uploadConstantEffect(int id, int trigger_button, int direction, int trigger_interval, int replay_length, int replay_delay, int constant_level, int constant_env_attack_length, int constant_env_attack_level, int constant_env_fade_length, int constant_env_fade_level) throws IOException {
checkClosed();
return nUploadConstantEffect(fd, id, direction, trigger_button, trigger_interval, replay_length, replay_delay, constant_level, constant_env_attack_length, constant_env_attack_level, constant_env_fade_length, constant_env_fade_level);
}
private final static native int nUploadConstantEffect(long fd, int id, int direction, int trigger_button, int trigger_interval, int replay_length, int replay_delay, int constant_level, int constant_env_attack_length, int constant_env_attack_level, int constant_env_fade_length, int constant_env_fade_level) throws IOException;
final void eraseEffect(int id) throws IOException {
nEraseEffect(fd, id);
}
private final static native void nEraseEffect(long fd, int ff_id) throws IOException;
public final synchronized void writeEvent(int type, int code, int value) throws IOException {
checkClosed();
nWriteEvent(fd, type, code, value);
}
private final static native void nWriteEvent(long fd, int type, int code, int value) throws IOException;
public final void registerComponent(LinuxAxisDescriptor desc, LinuxComponent component) {
component_map.put(desc, component);
}
public final LinuxComponent mapDescriptor(LinuxAxisDescriptor desc) {
return component_map.get(desc);
}
public final Controller.PortType getPortType() throws IOException {
return input_id.getPortType();
}
public final LinuxInputID getInputID() {
return input_id;
}
private final LinuxInputID getDeviceInputID() throws IOException {
return nGetInputID(fd);
}
private final static native LinuxInputID nGetInputID(long fd) throws IOException;
public final int getNumEffects() throws IOException {
return nGetNumEffects(fd);
}
private final static native int nGetNumEffects(long fd) throws IOException;
private final int getVersion() throws IOException {
return nGetVersion(fd);
}
private final static native int nGetVersion(long fd) throws IOException;
public final synchronized boolean getNextEvent(LinuxEvent linux_event) throws IOException {
checkClosed();
return nGetNextEvent(fd, linux_event);
}
private final static native boolean nGetNextEvent(long fd, LinuxEvent linux_event) throws IOException;
public final synchronized void getAbsInfo(int abs_axis, LinuxAbsInfo abs_info) throws IOException {
checkClosed();
nGetAbsInfo(fd, abs_axis, abs_info);
}
private final static native void nGetAbsInfo(long fd, int abs_axis, LinuxAbsInfo abs_info) throws IOException;
private final void addKeys(List<LinuxEventComponent> components) throws IOException {
byte[] bits = getKeysBits();
for (int i = 0; i < bits.length*8; i++) {
if (isBitSet(bits, i)) {
Component.Identifier id = LinuxNativeTypesMap.getButtonID(i);
components.add(new LinuxEventComponent(this, id, false, NativeDefinitions.EV_KEY, i));
}
}
}
private final void addAbsoluteAxes(List<LinuxEventComponent> components) throws IOException {
byte[] bits = getAbsoluteAxesBits();
for (int i = 0; i < bits.length*8; i++) {
if (isBitSet(bits, i)) {
Component.Identifier id = LinuxNativeTypesMap.getAbsAxisID(i);
components.add(new LinuxEventComponent(this, id, false, NativeDefinitions.EV_ABS, i));
}
}
}
private final void addRelativeAxes(List<LinuxEventComponent> components) throws IOException {
byte[] bits = getRelativeAxesBits();
for (int i = 0; i < bits.length*8; i++) {
if (isBitSet(bits, i)) {
Component.Identifier id = LinuxNativeTypesMap.getRelAxisID(i);
components.add(new LinuxEventComponent(this, id, true, NativeDefinitions.EV_REL, i));
}
}
}
public final List<LinuxEventComponent> getComponents() {
return components;
}
private final List<LinuxEventComponent> getDeviceComponents() throws IOException {
List<LinuxEventComponent> components = new ArrayList<>();
byte[] evtype_bits = getEventTypeBits();
if (isBitSet(evtype_bits, NativeDefinitions.EV_KEY))
addKeys(components);
if (isBitSet(evtype_bits, NativeDefinitions.EV_ABS))
addAbsoluteAxes(components);
if (isBitSet(evtype_bits, NativeDefinitions.EV_REL))
addRelativeAxes(components);
return components;
}
private final byte[] getForceFeedbackBits() throws IOException {
byte[] bits = new byte[NativeDefinitions.FF_MAX/8 + 1];
nGetBits(fd, NativeDefinitions.EV_FF, bits);
return bits;
}
private final byte[] getKeysBits() throws IOException {
byte[] bits = new byte[NativeDefinitions.KEY_MAX/8 + 1];
nGetBits(fd, NativeDefinitions.EV_KEY, bits);
return bits;
}
private final byte[] getAbsoluteAxesBits() throws IOException {
byte[] bits = new byte[NativeDefinitions.ABS_MAX/8 + 1];
nGetBits(fd, NativeDefinitions.EV_ABS, bits);
return bits;
}
private final byte[] getRelativeAxesBits() throws IOException {
byte[] bits = new byte[NativeDefinitions.REL_MAX/8 + 1];
nGetBits(fd, NativeDefinitions.EV_REL, bits);
return bits;
}
private final byte[] getEventTypeBits() throws IOException {
byte[] bits = new byte[NativeDefinitions.EV_MAX/8 + 1];
nGetBits(fd, 0, bits);
return bits;
}
private final static native void nGetBits(long fd, int ev_type, byte[] evtype_bits) throws IOException;
public final synchronized void pollKeyStates() throws IOException {
nGetKeyStates(fd, key_states);
}
private final static native void nGetKeyStates(long fd, byte[] states) throws IOException;
public final boolean isKeySet(int bit) {
return isBitSet(key_states, bit);
}
public final static boolean isBitSet(byte[] bits, int bit) {
return (bits[bit/8] & (1<<(bit%8))) != 0;
}
public final String getName() {
return name;
}
private final String getDeviceName() throws IOException {
return nGetName(fd);
}
private final static native String nGetName(long fd) throws IOException;
public synchronized final void close() throws IOException {
if (closed)
return;
closed = true;
LinuxEnvironmentPlugin.execute(new LinuxDeviceTask() {
protected final Object execute() throws IOException {
nClose(fd);
return null;
}
});
}
private final static native void nClose(long fd) throws IOException;
private final void checkClosed() throws IOException {
if (closed)
throw new IOException("Device is closed");
}
@SuppressWarnings("deprecation")
protected void finalize() throws IOException {
close();
}
}

View file

@ -0,0 +1,110 @@
/**
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
import java.io.IOException;
/**
* @author elias
*/
abstract class LinuxForceFeedbackEffect implements Rumbler {
private final LinuxEventDevice device;
private final int ff_id;
private final WriteTask write_task = new WriteTask();
private final UploadTask upload_task = new UploadTask();
public LinuxForceFeedbackEffect(LinuxEventDevice device) throws IOException {
this.device = device;
this.ff_id = upload_task.doUpload(-1, 0);
}
protected abstract int upload(int id, float intensity) throws IOException;
protected final LinuxEventDevice getDevice() {
return device;
}
public synchronized final void rumble(float intensity) {
try {
if (intensity > 0) {
upload_task.doUpload(ff_id, intensity);
write_task.write(1);
} else {
write_task.write(0);
}
} catch (IOException e) {
LinuxEnvironmentPlugin.log("Failed to rumble: " + e);
}
}
/*
* Erase doesn't seem to be implemented on Logitech joysticks,
* so we'll rely on the kernel cleaning up on device close
*/
/*
public final void erase() throws IOException {
device.eraseEffect(ff_id);
}
*/
public final String getAxisName() {
return null;
}
public final Component.Identifier getAxisIdentifier() {
return null;
}
private final class UploadTask extends LinuxDeviceTask {
private int id;
private float intensity;
public final int doUpload(int id, float intensity) throws IOException {
this.id = id;
this.intensity = intensity;
LinuxEnvironmentPlugin.execute(this);
return this.id;
}
protected final Object execute() throws IOException {
this.id = upload(id, intensity);
return null;
}
}
private final class WriteTask extends LinuxDeviceTask {
private int value;
public final void write(int value) throws IOException {
this.value = value;
LinuxEnvironmentPlugin.execute(this);
}
protected final Object execute() throws IOException {
device.writeEvent(NativeDefinitions.EV_FF, ff_id, value);
return null;
}
}
}

View file

@ -0,0 +1,52 @@
/**
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
/**
* @author elias
*/
final class LinuxInputID {
private final int bustype;
private final int vendor;
private final int product;
private final int version;
public LinuxInputID(int bustype, int vendor, int product, int version) {
this.bustype = bustype;
this.vendor = vendor;
this.product = product;
this.version = version;
}
public final Controller.PortType getPortType() {
return LinuxNativeTypesMap.getPortType(bustype);
}
public final String toString() {
return "LinuxInputID: bustype = 0x" + Integer.toHexString(bustype) + " | vendor = 0x" + Integer.toHexString(vendor) +
" | product = 0x" + Integer.toHexString(product) + " | version = 0x" + Integer.toHexString(version);
}
}

View file

@ -0,0 +1,70 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.io.IOException;
/** Represents a Linux controller
* @author elias
* @version 1.0
*/
final class LinuxJoystickAbstractController extends AbstractController {
private final LinuxJoystickDevice device;
protected LinuxJoystickAbstractController(LinuxJoystickDevice device, Component[] components, Controller[] children, Rumbler[] rumblers) {
super(device.getName(), components, children, rumblers);
this.device = device;
}
protected final void setDeviceEventQueueSize(int size) throws IOException {
device.setBufferSize(size);
}
public final void pollDevice() throws IOException {
device.poll();
}
protected final boolean getNextDeviceEvent(Event event) throws IOException {
return device.getNextEvent(event);
}
public Type getType() {
return Controller.Type.STICK;
}
}

View file

@ -0,0 +1,76 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.io.IOException;
/** Represents a linux Axis
* @author elias
* @version 1.0
*/
class LinuxJoystickAxis extends AbstractComponent {
private float value;
private boolean analog;
public LinuxJoystickAxis(Component.Identifier.Axis axis_id) {
this(axis_id, true);
}
public LinuxJoystickAxis(Component.Identifier.Axis axis_id, boolean analog) {
super(axis_id.getName(), axis_id);
this.analog = analog;
}
public final boolean isRelative() {
return false;
}
public final boolean isAnalog() {
return analog;
}
final void setValue(float value) {
this.value = value;
resetHasPolled();
}
protected final float poll() throws IOException {
return value;
}
}

View file

@ -0,0 +1,65 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.io.IOException;
/** Represents a linux button from the joystick interface
* @author elias
* @version 1.0
*/
final class LinuxJoystickButton extends AbstractComponent {
private float value;
public LinuxJoystickButton(Component.Identifier button_id) {
super(button_id.getName(), button_id);
}
public final boolean isRelative() {
return false;
}
final void setValue(float value) {
this.value = value;
}
protected final float poll() throws IOException {
return value;
}
}

View file

@ -0,0 +1,238 @@
/*
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
import java.io.IOException;
import java.util.Map;
import java.util.HashMap;
/**
* @author elias
*/
final class LinuxJoystickDevice implements LinuxDevice {
public final static int JS_EVENT_BUTTON = 0x01; /* button pressed/released */
public final static int JS_EVENT_AXIS = 0x02; /* joystick moved */
public final static int JS_EVENT_INIT = 0x80; /* initial state of device */
public final static int AXIS_MAX_VALUE = 32767;
private final long fd;
private final String name;
private final LinuxJoystickEvent joystick_event = new LinuxJoystickEvent();
private final Event event = new Event();
private final LinuxJoystickButton[] buttons;
private final LinuxJoystickAxis[] axes;
private final Map<Integer, LinuxJoystickPOV> povXs = new HashMap<>();
private final Map<Integer, LinuxJoystickPOV> povYs = new HashMap<>();
private final byte[] axisMap;
private final char[] buttonMap;
private EventQueue event_queue;
/* Closed state variable that protects the validity of the file descriptor.
* Access to the closed state must be synchronized
*/
private boolean closed;
public LinuxJoystickDevice(String filename) throws IOException {
this.fd = nOpen(filename);
try {
this.name = getDeviceName();
setBufferSize(AbstractController.EVENT_QUEUE_DEPTH);
buttons = new LinuxJoystickButton[getNumDeviceButtons()];
axes = new LinuxJoystickAxis[getNumDeviceAxes()];
axisMap = getDeviceAxisMap();
buttonMap = getDeviceButtonMap();
} catch (IOException e) {
close();
throw e;
}
}
private final static native long nOpen(String filename) throws IOException;
public final synchronized void setBufferSize(int size) {
event_queue = new EventQueue(size);
}
private final void processEvent(LinuxJoystickEvent joystick_event) {
int index = joystick_event.getNumber();
// Filter synthetic init event flag
int type = joystick_event.getType() & ~JS_EVENT_INIT;
switch (type) {
case JS_EVENT_BUTTON:
if (index < getNumButtons()) {
LinuxJoystickButton button = buttons[index];
if (button != null) {
float value = joystick_event.getValue();
button.setValue(value);
event.set(button, value, joystick_event.getNanos());
break;
}
}
return;
case JS_EVENT_AXIS:
if (index < getNumAxes()) {
LinuxJoystickAxis axis = axes[index];
if (axis != null) {
float value = (float)joystick_event.getValue()/AXIS_MAX_VALUE;
axis.setValue(value);
if(povXs.containsKey(index)) {
LinuxJoystickPOV pov = povXs.get(index);
pov.updateValue();
event.set(pov, pov.getPollData(), joystick_event.getNanos());
} else if(povYs.containsKey(index)) {
LinuxJoystickPOV pov = povYs.get(index);
pov.updateValue();
event.set(pov, pov.getPollData(), joystick_event.getNanos());
} else {
event.set(axis, value, joystick_event.getNanos());
}
break;
}
}
return;
default:
// Unknown component type
return;
}
if (!event_queue.isFull()) {
event_queue.add(event);
}
}
public final void registerAxis(int index, LinuxJoystickAxis axis) {
axes[index] = axis;
}
public final void registerButton(int index, LinuxJoystickButton button) {
buttons[index] = button;
}
public final void registerPOV(LinuxJoystickPOV pov) {
// The x and y on a joystick device are not the same as on an event device
LinuxJoystickAxis xAxis = pov.getYAxis();
LinuxJoystickAxis yAxis = pov.getXAxis();
int xIndex;
int yIndex;
for(xIndex=0;xIndex<axes.length;xIndex++) {
if(axes[xIndex]==xAxis) {
break;
}
}
for(yIndex=0;yIndex<axes.length;yIndex++) {
if(axes[yIndex]==yAxis) {
break;
}
}
povXs.put(xIndex,pov);
povYs.put(yIndex,pov);
}
public final synchronized boolean getNextEvent(Event event) throws IOException {
return event_queue.getNextEvent(event);
}
public final synchronized void poll() throws IOException {
checkClosed();
while (getNextDeviceEvent(joystick_event)) {
processEvent(joystick_event);
}
}
private final boolean getNextDeviceEvent(LinuxJoystickEvent joystick_event) throws IOException {
return nGetNextEvent(fd, joystick_event);
}
private final static native boolean nGetNextEvent(long fd, LinuxJoystickEvent joystick_event) throws IOException;
public final int getNumAxes() {
return axes.length;
}
public final int getNumButtons() {
return buttons.length;
}
public final byte[] getAxisMap() {
return axisMap;
}
public final char[] getButtonMap() {
return buttonMap;
}
private final int getNumDeviceButtons() throws IOException {
return nGetNumButtons(fd);
}
private final static native int nGetNumButtons(long fd) throws IOException;
private final int getNumDeviceAxes() throws IOException {
return nGetNumAxes(fd);
}
private final static native int nGetNumAxes(long fd) throws IOException;
private final byte[] getDeviceAxisMap() throws IOException {
return nGetAxisMap(fd);
}
private final static native byte[] nGetAxisMap(long fd) throws IOException;
private final char[] getDeviceButtonMap() throws IOException {
return nGetButtonMap(fd);
}
private final static native char[] nGetButtonMap(long fd) throws IOException;
private final int getVersion() throws IOException {
return nGetVersion(fd);
}
private final static native int nGetVersion(long fd) throws IOException;
public final String getName() {
return name;
}
private final String getDeviceName() throws IOException {
return nGetName(fd);
}
private final static native String nGetName(long fd) throws IOException;
public final synchronized void close() throws IOException {
if (!closed) {
closed = true;
nClose(fd);
}
}
private final static native void nClose(long fd) throws IOException;
private final void checkClosed() throws IOException {
if (closed)
throw new IOException("Device is closed");
}
@SuppressWarnings("deprecation")
protected void finalize() throws IOException {
close();
}
}

View file

@ -0,0 +1,59 @@
/**
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
/**
* @author elias
*/
final class LinuxJoystickEvent {
private long nanos;
private int value;
private int type;
private int number;
public final void set(long millis, int value, int type, int number) {
this.nanos = millis*1000000;
this.value = value;
this.type = type;
this.number = number;
}
public final int getValue() {
return value;
}
public final int getType() {
return type;
}
public final int getNumber() {
return number;
}
public final long getNanos() {
return nanos;
}
}

View file

@ -0,0 +1,54 @@
package net.java.games.input;
import java.io.IOException;
public class LinuxJoystickPOV extends LinuxJoystickAxis {
private LinuxJoystickAxis hatX;
private LinuxJoystickAxis hatY;
LinuxJoystickPOV(Component.Identifier.Axis id, LinuxJoystickAxis hatX, LinuxJoystickAxis hatY) {
super(id, false);
this.hatX = hatX;
this.hatY = hatY;
}
protected LinuxJoystickAxis getXAxis() {
return hatX;
}
protected LinuxJoystickAxis getYAxis() {
return hatY;
}
protected void updateValue() {
float last_x = hatX.getPollData();
float last_y = hatY.getPollData();
resetHasPolled();
if (last_x == -1 && last_y == -1)
setValue(Component.POV.UP_LEFT);
else if (last_x == -1 && last_y == 0)
setValue(Component.POV.LEFT);
else if (last_x == -1 && last_y == 1)
setValue(Component.POV.DOWN_LEFT);
else if (last_x == 0 && last_y == -1)
setValue(Component.POV.UP);
else if (last_x == 0 && last_y == 0)
setValue(Component.POV.OFF);
else if (last_x == 0 && last_y == 1)
setValue(Component.POV.DOWN);
else if (last_x == 1 && last_y == -1)
setValue(Component.POV.UP_RIGHT);
else if (last_x == 1 && last_y == 0)
setValue(Component.POV.RIGHT);
else if (last_x == 1 && last_y == 1)
setValue(Component.POV.DOWN_RIGHT);
else {
LinuxEnvironmentPlugin.log("Unknown values x = " + last_x + " | y = " + last_y);
setValue(Component.POV.OFF);
}
}
}

View file

@ -0,0 +1,68 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.io.IOException;
/** Represents an OSX Keyboard
* @author elias
* @version 1.0
*/
final class LinuxKeyboard extends Keyboard {
private final PortType port;
private final LinuxEventDevice device;
protected LinuxKeyboard(LinuxEventDevice device, Component[] components, Controller[] children, Rumbler[] rumblers) throws IOException {
super(device.getName(), components, children, rumblers);
this.device = device;
this.port = device.getPortType();
}
public final PortType getPortType() {
return port;
}
protected final boolean getNextDeviceEvent(Event event) throws IOException {
return LinuxControllers.getNextDeviceEvent(event, device);
}
public final void pollDevice() throws IOException {
device.pollKeyStates();
}
}

View file

@ -0,0 +1,68 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.io.IOException;
/** Represents an OSX Mouse
* @author elias
* @version 1.0
*/
final class LinuxMouse extends Mouse {
private final PortType port;
private final LinuxEventDevice device;
protected LinuxMouse(LinuxEventDevice device, Component[] components, Controller[] children, Rumbler[] rumblers) throws IOException {
super(device.getName(), components, children, rumblers);
this.device = device;
this.port = device.getPortType();
}
public final PortType getPortType() {
return port;
}
public final void pollDevice() throws IOException {
device.pollKeyStates();
}
protected final boolean getNextDeviceEvent(Event event) throws IOException {
return LinuxControllers.getNextDeviceEvent(event, device);
}
}

View file

@ -0,0 +1,848 @@
/**
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
import java.util.logging.Logger;
/**
* Mapping utility class between native type ints and string names or
* Key.Identifiers
* @author Jeremy Booth (jeremy@newdawnsoftware.com)
*/
class LinuxNativeTypesMap {
private static LinuxNativeTypesMap INSTANCE = new LinuxNativeTypesMap();
private static Logger log = Logger.getLogger(LinuxNativeTypesMap.class.getName());
private final Component.Identifier relAxesIDs[];
private final Component.Identifier absAxesIDs[];
private final Component.Identifier buttonIDs[];
/** create an empty, uninitialsed map
*/
private LinuxNativeTypesMap() {
buttonIDs = new Component.Identifier[NativeDefinitions.KEY_MAX];
relAxesIDs = new Component.Identifier[NativeDefinitions.REL_MAX];
absAxesIDs = new Component.Identifier[NativeDefinitions.ABS_MAX];
reInit();
}
/** Do the work.
*/
private void reInit() {
buttonIDs[NativeDefinitions.KEY_ESC] = Component.Identifier.Key.ESCAPE;
buttonIDs[NativeDefinitions.KEY_1] = Component.Identifier.Key._1;
buttonIDs[NativeDefinitions.KEY_2] = Component.Identifier.Key._2;
buttonIDs[NativeDefinitions.KEY_3] = Component.Identifier.Key._3;
buttonIDs[NativeDefinitions.KEY_4] = Component.Identifier.Key._4;
buttonIDs[NativeDefinitions.KEY_5] = Component.Identifier.Key._5;
buttonIDs[NativeDefinitions.KEY_6] = Component.Identifier.Key._6;
buttonIDs[NativeDefinitions.KEY_7] = Component.Identifier.Key._7;
buttonIDs[NativeDefinitions.KEY_8] = Component.Identifier.Key._8;
buttonIDs[NativeDefinitions.KEY_9] = Component.Identifier.Key._9;
buttonIDs[NativeDefinitions.KEY_0] = Component.Identifier.Key._0;
buttonIDs[NativeDefinitions.KEY_MINUS] = Component.Identifier.Key.MINUS;
buttonIDs[NativeDefinitions.KEY_EQUAL] = Component.Identifier.Key.EQUALS;
buttonIDs[NativeDefinitions.KEY_BACKSPACE] = Component.Identifier.Key.BACK;
buttonIDs[NativeDefinitions.KEY_TAB] = Component.Identifier.Key.TAB;
buttonIDs[NativeDefinitions.KEY_Q] = Component.Identifier.Key.Q;
buttonIDs[NativeDefinitions.KEY_W] = Component.Identifier.Key.W;
buttonIDs[NativeDefinitions.KEY_E] = Component.Identifier.Key.E;
buttonIDs[NativeDefinitions.KEY_R] = Component.Identifier.Key.R;
buttonIDs[NativeDefinitions.KEY_T] = Component.Identifier.Key.T;
buttonIDs[NativeDefinitions.KEY_Y] = Component.Identifier.Key.Y;
buttonIDs[NativeDefinitions.KEY_U] = Component.Identifier.Key.U;
buttonIDs[NativeDefinitions.KEY_I] = Component.Identifier.Key.I;
buttonIDs[NativeDefinitions.KEY_O] = Component.Identifier.Key.O;
buttonIDs[NativeDefinitions.KEY_P] = Component.Identifier.Key.P;
buttonIDs[NativeDefinitions.KEY_LEFTBRACE] = Component.Identifier.Key.LBRACKET;
buttonIDs[NativeDefinitions.KEY_RIGHTBRACE] = Component.Identifier.Key.RBRACKET;
buttonIDs[NativeDefinitions.KEY_ENTER] = Component.Identifier.Key.RETURN;
buttonIDs[NativeDefinitions.KEY_LEFTCTRL] = Component.Identifier.Key.LCONTROL;
buttonIDs[NativeDefinitions.KEY_A] = Component.Identifier.Key.A;
buttonIDs[NativeDefinitions.KEY_S] = Component.Identifier.Key.S;
buttonIDs[NativeDefinitions.KEY_D] = Component.Identifier.Key.D;
buttonIDs[NativeDefinitions.KEY_F] = Component.Identifier.Key.F;
buttonIDs[NativeDefinitions.KEY_G] = Component.Identifier.Key.G;
buttonIDs[NativeDefinitions.KEY_H] = Component.Identifier.Key.H;
buttonIDs[NativeDefinitions.KEY_J] = Component.Identifier.Key.J;
buttonIDs[NativeDefinitions.KEY_K] = Component.Identifier.Key.K;
buttonIDs[NativeDefinitions.KEY_L] = Component.Identifier.Key.L;
buttonIDs[NativeDefinitions.KEY_SEMICOLON] = Component.Identifier.Key.SEMICOLON;
buttonIDs[NativeDefinitions.KEY_APOSTROPHE] = Component.Identifier.Key.APOSTROPHE;
buttonIDs[NativeDefinitions.KEY_GRAVE] = Component.Identifier.Key.GRAVE;
buttonIDs[NativeDefinitions.KEY_LEFTSHIFT] = Component.Identifier.Key.LSHIFT;
buttonIDs[NativeDefinitions.KEY_BACKSLASH] = Component.Identifier.Key.BACKSLASH;
buttonIDs[NativeDefinitions.KEY_Z] = Component.Identifier.Key.Z;
buttonIDs[NativeDefinitions.KEY_X] = Component.Identifier.Key.X;
buttonIDs[NativeDefinitions.KEY_C] = Component.Identifier.Key.C;
buttonIDs[NativeDefinitions.KEY_V] = Component.Identifier.Key.V;
buttonIDs[NativeDefinitions.KEY_B] = Component.Identifier.Key.B;
buttonIDs[NativeDefinitions.KEY_N] = Component.Identifier.Key.N;
buttonIDs[NativeDefinitions.KEY_M] = Component.Identifier.Key.M;
buttonIDs[NativeDefinitions.KEY_COMMA] = Component.Identifier.Key.COMMA;
buttonIDs[NativeDefinitions.KEY_DOT] = Component.Identifier.Key.PERIOD;
buttonIDs[NativeDefinitions.KEY_SLASH] = Component.Identifier.Key.SLASH;
buttonIDs[NativeDefinitions.KEY_RIGHTSHIFT] = Component.Identifier.Key.RSHIFT;
buttonIDs[NativeDefinitions.KEY_KPASTERISK] = Component.Identifier.Key.MULTIPLY;
buttonIDs[NativeDefinitions.KEY_LEFTALT] = Component.Identifier.Key.LALT;
buttonIDs[NativeDefinitions.KEY_SPACE] = Component.Identifier.Key.SPACE;
buttonIDs[NativeDefinitions.KEY_CAPSLOCK] = Component.Identifier.Key.CAPITAL;
buttonIDs[NativeDefinitions.KEY_F1] = Component.Identifier.Key.F1;
buttonIDs[NativeDefinitions.KEY_F2] = Component.Identifier.Key.F2;
buttonIDs[NativeDefinitions.KEY_F3] = Component.Identifier.Key.F3;
buttonIDs[NativeDefinitions.KEY_F4] = Component.Identifier.Key.F4;
buttonIDs[NativeDefinitions.KEY_F5] = Component.Identifier.Key.F5;
buttonIDs[NativeDefinitions.KEY_F6] = Component.Identifier.Key.F6;
buttonIDs[NativeDefinitions.KEY_F7] = Component.Identifier.Key.F7;
buttonIDs[NativeDefinitions.KEY_F8] = Component.Identifier.Key.F8;
buttonIDs[NativeDefinitions.KEY_F9] = Component.Identifier.Key.F9;
buttonIDs[NativeDefinitions.KEY_F10] = Component.Identifier.Key.F10;
buttonIDs[NativeDefinitions.KEY_NUMLOCK] = Component.Identifier.Key.NUMLOCK;
buttonIDs[NativeDefinitions.KEY_SCROLLLOCK] = Component.Identifier.Key.SCROLL;
buttonIDs[NativeDefinitions.KEY_KP7] = Component.Identifier.Key.NUMPAD7;
buttonIDs[NativeDefinitions.KEY_KP8] = Component.Identifier.Key.NUMPAD8;
buttonIDs[NativeDefinitions.KEY_KP9] = Component.Identifier.Key.NUMPAD9;
buttonIDs[NativeDefinitions.KEY_KPMINUS] = Component.Identifier.Key.SUBTRACT;
buttonIDs[NativeDefinitions.KEY_KP4] = Component.Identifier.Key.NUMPAD4;
buttonIDs[NativeDefinitions.KEY_KP5] = Component.Identifier.Key.NUMPAD5;
buttonIDs[NativeDefinitions.KEY_KP6] = Component.Identifier.Key.NUMPAD6;
buttonIDs[NativeDefinitions.KEY_KPPLUS] = Component.Identifier.Key.ADD;
buttonIDs[NativeDefinitions.KEY_KP1] = Component.Identifier.Key.NUMPAD1;
buttonIDs[NativeDefinitions.KEY_KP2] = Component.Identifier.Key.NUMPAD2;
buttonIDs[NativeDefinitions.KEY_KP3] = Component.Identifier.Key.NUMPAD3;
buttonIDs[NativeDefinitions.KEY_KP0] = Component.Identifier.Key.NUMPAD0;
buttonIDs[NativeDefinitions.KEY_KPDOT] = Component.Identifier.Key.DECIMAL;
// buttonIDs[NativeDefinitions.KEY_103RD] = null;
buttonIDs[NativeDefinitions.KEY_F13] = Component.Identifier.Key.F13;
buttonIDs[NativeDefinitions.KEY_102ND] = null;
buttonIDs[NativeDefinitions.KEY_F11] = Component.Identifier.Key.F11;
buttonIDs[NativeDefinitions.KEY_F12] = Component.Identifier.Key.F12;
buttonIDs[NativeDefinitions.KEY_F14] = Component.Identifier.Key.F14;
buttonIDs[NativeDefinitions.KEY_F15] = Component.Identifier.Key.F15;
buttonIDs[NativeDefinitions.KEY_F16] = null;
buttonIDs[NativeDefinitions.KEY_F17] = null;
buttonIDs[NativeDefinitions.KEY_F18] = null;
buttonIDs[NativeDefinitions.KEY_F19] = null;
buttonIDs[NativeDefinitions.KEY_F20] = null;
buttonIDs[NativeDefinitions.KEY_KPENTER] = Component.Identifier.Key.NUMPADENTER;
buttonIDs[NativeDefinitions.KEY_RIGHTCTRL] = Component.Identifier.Key.RCONTROL;
buttonIDs[NativeDefinitions.KEY_KPSLASH] = Component.Identifier.Key.DIVIDE;
buttonIDs[NativeDefinitions.KEY_SYSRQ] = Component.Identifier.Key.SYSRQ;
buttonIDs[NativeDefinitions.KEY_RIGHTALT] = Component.Identifier.Key.RALT;
buttonIDs[NativeDefinitions.KEY_LINEFEED] = null;
buttonIDs[NativeDefinitions.KEY_HOME] = Component.Identifier.Key.HOME;
buttonIDs[NativeDefinitions.KEY_UP] = Component.Identifier.Key.UP;
buttonIDs[NativeDefinitions.KEY_PAGEUP] = Component.Identifier.Key.PAGEUP;
buttonIDs[NativeDefinitions.KEY_LEFT] = Component.Identifier.Key.LEFT;
buttonIDs[NativeDefinitions.KEY_RIGHT] = Component.Identifier.Key.RIGHT;
buttonIDs[NativeDefinitions.KEY_END] = Component.Identifier.Key.END;
buttonIDs[NativeDefinitions.KEY_DOWN] = Component.Identifier.Key.DOWN;
buttonIDs[NativeDefinitions.KEY_PAGEDOWN] = Component.Identifier.Key.PAGEDOWN;
buttonIDs[NativeDefinitions.KEY_INSERT] = Component.Identifier.Key.INSERT;
buttonIDs[NativeDefinitions.KEY_DELETE] = Component.Identifier.Key.DELETE;
buttonIDs[NativeDefinitions.KEY_PAUSE] = Component.Identifier.Key.PAUSE;
/* buttonIDs[NativeDefinitions.KEY_MACRO] = "Macro";
buttonIDs[NativeDefinitions.KEY_MUTE] = "Mute";
buttonIDs[NativeDefinitions.KEY_VOLUMEDOWN] = "Volume Down";
buttonIDs[NativeDefinitions.KEY_VOLUMEUP] = "Volume Up";
buttonIDs[NativeDefinitions.KEY_POWER] = "Power";*/
buttonIDs[NativeDefinitions.KEY_KPEQUAL] = Component.Identifier.Key.NUMPADEQUAL;
//buttonIDs[NativeDefinitions.KEY_KPPLUSMINUS] = "KeyPad +/-";
/* buttonIDs[NativeDefinitions.KEY_F21] = "F21";
buttonIDs[NativeDefinitions.KEY_F22] = "F22";
buttonIDs[NativeDefinitions.KEY_F23] = "F23";
buttonIDs[NativeDefinitions.KEY_F24] = "F24";
buttonIDs[NativeDefinitions.KEY_KPCOMMA] = "KeyPad comma";
buttonIDs[NativeDefinitions.KEY_LEFTMETA] = "LH Meta";
buttonIDs[NativeDefinitions.KEY_RIGHTMETA] = "RH Meta";
buttonIDs[NativeDefinitions.KEY_COMPOSE] = "Compose";
buttonIDs[NativeDefinitions.KEY_STOP] = "Stop";
buttonIDs[NativeDefinitions.KEY_AGAIN] = "Again";
buttonIDs[NativeDefinitions.KEY_PROPS] = "Properties";
buttonIDs[NativeDefinitions.KEY_UNDO] = "Undo";
buttonIDs[NativeDefinitions.KEY_FRONT] = "Front";
buttonIDs[NativeDefinitions.KEY_COPY] = "Copy";
buttonIDs[NativeDefinitions.KEY_OPEN] = "Open";
buttonIDs[NativeDefinitions.KEY_PASTE] = "Paste";
buttonIDs[NativeDefinitions.KEY_FIND] = "Find";
buttonIDs[NativeDefinitions.KEY_CUT] = "Cut";
buttonIDs[NativeDefinitions.KEY_HELP] = "Help";
buttonIDs[NativeDefinitions.KEY_MENU] = "Menu";
buttonIDs[NativeDefinitions.KEY_CALC] = "Calculator";
buttonIDs[NativeDefinitions.KEY_SETUP] = "Setup";*/
buttonIDs[NativeDefinitions.KEY_SLEEP] = Component.Identifier.Key.SLEEP;
/*buttonIDs[NativeDefinitions.KEY_WAKEUP] = "Wakeup";
buttonIDs[NativeDefinitions.KEY_FILE] = "File";
buttonIDs[NativeDefinitions.KEY_SENDFILE] = "Send File";
buttonIDs[NativeDefinitions.KEY_DELETEFILE] = "Delete File";
buttonIDs[NativeDefinitions.KEY_XFER] = "Transfer";
buttonIDs[NativeDefinitions.KEY_PROG1] = "Program 1";
buttonIDs[NativeDefinitions.KEY_PROG2] = "Program 2";
buttonIDs[NativeDefinitions.KEY_WWW] = "Web Browser";
buttonIDs[NativeDefinitions.KEY_MSDOS] = "DOS mode";
buttonIDs[NativeDefinitions.KEY_COFFEE] = "Coffee";
buttonIDs[NativeDefinitions.KEY_DIRECTION] = "Direction";
buttonIDs[NativeDefinitions.KEY_CYCLEWINDOWS] = "Window cycle";
buttonIDs[NativeDefinitions.KEY_MAIL] = "Mail";
buttonIDs[NativeDefinitions.KEY_BOOKMARKS] = "Book Marks";
buttonIDs[NativeDefinitions.KEY_COMPUTER] = "Computer";
buttonIDs[NativeDefinitions.KEY_BACK] = "Back";
buttonIDs[NativeDefinitions.KEY_FORWARD] = "Forward";
buttonIDs[NativeDefinitions.KEY_CLOSECD] = "Close CD";
buttonIDs[NativeDefinitions.KEY_EJECTCD] = "Eject CD";
buttonIDs[NativeDefinitions.KEY_EJECTCLOSECD] = "Eject / Close CD";
buttonIDs[NativeDefinitions.KEY_NEXTSONG] = "Next Song";
buttonIDs[NativeDefinitions.KEY_PLAYPAUSE] = "Play and Pause";
buttonIDs[NativeDefinitions.KEY_PREVIOUSSONG] = "Previous Song";
buttonIDs[NativeDefinitions.KEY_STOPCD] = "Stop CD";
buttonIDs[NativeDefinitions.KEY_RECORD] = "Record";
buttonIDs[NativeDefinitions.KEY_REWIND] = "Rewind";
buttonIDs[NativeDefinitions.KEY_PHONE] = "Phone";
buttonIDs[NativeDefinitions.KEY_ISO] = "ISO";
buttonIDs[NativeDefinitions.KEY_CONFIG] = "Config";
buttonIDs[NativeDefinitions.KEY_HOMEPAGE] = "Home";
buttonIDs[NativeDefinitions.KEY_REFRESH] = "Refresh";
buttonIDs[NativeDefinitions.KEY_EXIT] = "Exit";
buttonIDs[NativeDefinitions.KEY_MOVE] = "Move";
buttonIDs[NativeDefinitions.KEY_EDIT] = "Edit";
buttonIDs[NativeDefinitions.KEY_SCROLLUP] = "Scroll Up";
buttonIDs[NativeDefinitions.KEY_SCROLLDOWN] = "Scroll Down";
buttonIDs[NativeDefinitions.KEY_KPLEFTPAREN] = "KeyPad LH parenthesis";
buttonIDs[NativeDefinitions.KEY_KPRIGHTPAREN] = "KeyPad RH parenthesis";
buttonIDs[NativeDefinitions.KEY_INTL1] = "Intl 1";
buttonIDs[NativeDefinitions.KEY_INTL2] = "Intl 2";
buttonIDs[NativeDefinitions.KEY_INTL3] = "Intl 3";
buttonIDs[NativeDefinitions.KEY_INTL4] = "Intl 4";
buttonIDs[NativeDefinitions.KEY_INTL5] = "Intl 5";
buttonIDs[NativeDefinitions.KEY_INTL6] = "Intl 6";
buttonIDs[NativeDefinitions.KEY_INTL7] = "Intl 7";
buttonIDs[NativeDefinitions.KEY_INTL8] = "Intl 8";
buttonIDs[NativeDefinitions.KEY_INTL9] = "Intl 9";
buttonIDs[NativeDefinitions.KEY_LANG1] = "Language 1";
buttonIDs[NativeDefinitions.KEY_LANG2] = "Language 2";
buttonIDs[NativeDefinitions.KEY_LANG3] = "Language 3";
buttonIDs[NativeDefinitions.KEY_LANG4] = "Language 4";
buttonIDs[NativeDefinitions.KEY_LANG5] = "Language 5";
buttonIDs[NativeDefinitions.KEY_LANG6] = "Language 6";
buttonIDs[NativeDefinitions.KEY_LANG7] = "Language 7";
buttonIDs[NativeDefinitions.KEY_LANG8] = "Language 8";
buttonIDs[NativeDefinitions.KEY_LANG9] = "Language 9";
buttonIDs[NativeDefinitions.KEY_PLAYCD] = "Play CD";
buttonIDs[NativeDefinitions.KEY_PAUSECD] = "Pause CD";
buttonIDs[NativeDefinitions.KEY_PROG3] = "Program 3";
buttonIDs[NativeDefinitions.KEY_PROG4] = "Program 4";
buttonIDs[NativeDefinitions.KEY_SUSPEND] = "Suspend";
buttonIDs[NativeDefinitions.KEY_CLOSE] = "Close";*/
buttonIDs[NativeDefinitions.KEY_UNKNOWN] = Component.Identifier.Key.UNLABELED;
/*buttonIDs[NativeDefinitions.KEY_BRIGHTNESSDOWN] = "Brightness Down";
buttonIDs[NativeDefinitions.KEY_BRIGHTNESSUP] = "Brightness Up";*/
//Misc keys
buttonIDs[NativeDefinitions.BTN_0] = Component.Identifier.Button._0;
buttonIDs[NativeDefinitions.BTN_1] = Component.Identifier.Button._1;
buttonIDs[NativeDefinitions.BTN_2] = Component.Identifier.Button._2;
buttonIDs[NativeDefinitions.BTN_3] = Component.Identifier.Button._3;
buttonIDs[NativeDefinitions.BTN_4] = Component.Identifier.Button._4;
buttonIDs[NativeDefinitions.BTN_5] = Component.Identifier.Button._5;
buttonIDs[NativeDefinitions.BTN_6] = Component.Identifier.Button._6;
buttonIDs[NativeDefinitions.BTN_7] = Component.Identifier.Button._7;
buttonIDs[NativeDefinitions.BTN_8] = Component.Identifier.Button._8;
buttonIDs[NativeDefinitions.BTN_9] = Component.Identifier.Button._9;
// Mouse
buttonIDs[NativeDefinitions.BTN_LEFT] = Component.Identifier.Button.LEFT;
buttonIDs[NativeDefinitions.BTN_RIGHT] = Component.Identifier.Button.RIGHT;
buttonIDs[NativeDefinitions.BTN_MIDDLE] = Component.Identifier.Button.MIDDLE;
buttonIDs[NativeDefinitions.BTN_SIDE] = Component.Identifier.Button.SIDE;
buttonIDs[NativeDefinitions.BTN_EXTRA] = Component.Identifier.Button.EXTRA;
buttonIDs[NativeDefinitions.BTN_FORWARD] = Component.Identifier.Button.FORWARD;
buttonIDs[NativeDefinitions.BTN_BACK] = Component.Identifier.Button.BACK;
// Joystick
buttonIDs[NativeDefinitions.BTN_TRIGGER] = Component.Identifier.Button.TRIGGER;
buttonIDs[NativeDefinitions.BTN_THUMB] = Component.Identifier.Button.THUMB;
buttonIDs[NativeDefinitions.BTN_THUMB2] = Component.Identifier.Button.THUMB2;
buttonIDs[NativeDefinitions.BTN_TOP] = Component.Identifier.Button.TOP;
buttonIDs[NativeDefinitions.BTN_TOP2] = Component.Identifier.Button.TOP2;
buttonIDs[NativeDefinitions.BTN_PINKIE] = Component.Identifier.Button.PINKIE;
buttonIDs[NativeDefinitions.BTN_BASE] = Component.Identifier.Button.BASE;
buttonIDs[NativeDefinitions.BTN_BASE2] = Component.Identifier.Button.BASE2;
buttonIDs[NativeDefinitions.BTN_BASE3] = Component.Identifier.Button.BASE3;
buttonIDs[NativeDefinitions.BTN_BASE4] = Component.Identifier.Button.BASE4;
buttonIDs[NativeDefinitions.BTN_BASE5] = Component.Identifier.Button.BASE5;
buttonIDs[NativeDefinitions.BTN_BASE6] = Component.Identifier.Button.BASE6;
buttonIDs[NativeDefinitions.BTN_DEAD] = Component.Identifier.Button.DEAD;
// Gamepad
buttonIDs[NativeDefinitions.BTN_A] = Component.Identifier.Button.A;
buttonIDs[NativeDefinitions.BTN_B] = Component.Identifier.Button.B;
buttonIDs[NativeDefinitions.BTN_C] = Component.Identifier.Button.C;
buttonIDs[NativeDefinitions.BTN_X] = Component.Identifier.Button.X;
buttonIDs[NativeDefinitions.BTN_Y] = Component.Identifier.Button.Y;
buttonIDs[NativeDefinitions.BTN_Z] = Component.Identifier.Button.Z;
buttonIDs[NativeDefinitions.BTN_TL] = Component.Identifier.Button.LEFT_THUMB;
buttonIDs[NativeDefinitions.BTN_TR] = Component.Identifier.Button.RIGHT_THUMB;
buttonIDs[NativeDefinitions.BTN_TL2] = Component.Identifier.Button.LEFT_THUMB2;
buttonIDs[NativeDefinitions.BTN_TR2] = Component.Identifier.Button.RIGHT_THUMB2;
buttonIDs[NativeDefinitions.BTN_SELECT] = Component.Identifier.Button.SELECT;
buttonIDs[NativeDefinitions.BTN_START] = Component.Identifier.Button.START;
buttonIDs[NativeDefinitions.BTN_MODE] = Component.Identifier.Button.MODE;
buttonIDs[NativeDefinitions.BTN_THUMBL] = Component.Identifier.Button.LEFT_THUMB3;
buttonIDs[NativeDefinitions.BTN_THUMBR] = Component.Identifier.Button.RIGHT_THUMB3;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY1] = Component.Identifier.Button.EXTRA_1;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY2] = Component.Identifier.Button.EXTRA_2;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY3] = Component.Identifier.Button.EXTRA_3;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY4] = Component.Identifier.Button.EXTRA_4;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY5] = Component.Identifier.Button.EXTRA_5;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY6] = Component.Identifier.Button.EXTRA_6;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY7] = Component.Identifier.Button.EXTRA_7;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY8] = Component.Identifier.Button.EXTRA_8;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY9] = Component.Identifier.Button.EXTRA_9;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY10] = Component.Identifier.Button.EXTRA_10;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY11] = Component.Identifier.Button.EXTRA_11;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY12] = Component.Identifier.Button.EXTRA_12;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY13] = Component.Identifier.Button.EXTRA_13;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY14] = Component.Identifier.Button.EXTRA_14;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY15] = Component.Identifier.Button.EXTRA_15;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY16] = Component.Identifier.Button.EXTRA_16;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY17] = Component.Identifier.Button.EXTRA_17;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY18] = Component.Identifier.Button.EXTRA_18;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY19] = Component.Identifier.Button.EXTRA_19;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY20] = Component.Identifier.Button.EXTRA_20;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY21] = Component.Identifier.Button.EXTRA_21;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY22] = Component.Identifier.Button.EXTRA_22;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY23] = Component.Identifier.Button.EXTRA_23;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY24] = Component.Identifier.Button.EXTRA_24;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY25] = Component.Identifier.Button.EXTRA_25;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY26] = Component.Identifier.Button.EXTRA_26;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY27] = Component.Identifier.Button.EXTRA_27;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY28] = Component.Identifier.Button.EXTRA_28;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY29] = Component.Identifier.Button.EXTRA_29;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY30] = Component.Identifier.Button.EXTRA_30;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY31] = Component.Identifier.Button.EXTRA_31;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY32] = Component.Identifier.Button.EXTRA_32;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY33] = Component.Identifier.Button.EXTRA_33;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY34] = Component.Identifier.Button.EXTRA_34;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY35] = Component.Identifier.Button.EXTRA_35;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY36] = Component.Identifier.Button.EXTRA_36;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY37] = Component.Identifier.Button.EXTRA_37;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY38] = Component.Identifier.Button.EXTRA_38;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY39] = Component.Identifier.Button.EXTRA_39;
buttonIDs[NativeDefinitions.BTN_TRIGGER_HAPPY40] = Component.Identifier.Button.EXTRA_40;
// Digitiser
buttonIDs[NativeDefinitions.BTN_TOOL_PEN] = Component.Identifier.Button.TOOL_PEN;
buttonIDs[NativeDefinitions.BTN_TOOL_RUBBER] = Component.Identifier.Button.TOOL_RUBBER;
buttonIDs[NativeDefinitions.BTN_TOOL_BRUSH] = Component.Identifier.Button.TOOL_BRUSH;
buttonIDs[NativeDefinitions.BTN_TOOL_PENCIL] = Component.Identifier.Button.TOOL_PENCIL;
buttonIDs[NativeDefinitions.BTN_TOOL_AIRBRUSH] = Component.Identifier.Button.TOOL_AIRBRUSH;
buttonIDs[NativeDefinitions.BTN_TOOL_FINGER] = Component.Identifier.Button.TOOL_FINGER;
buttonIDs[NativeDefinitions.BTN_TOOL_MOUSE] = Component.Identifier.Button.TOOL_MOUSE;
buttonIDs[NativeDefinitions.BTN_TOOL_LENS] = Component.Identifier.Button.TOOL_LENS;
buttonIDs[NativeDefinitions.BTN_TOUCH] = Component.Identifier.Button.TOUCH;
buttonIDs[NativeDefinitions.BTN_STYLUS] = Component.Identifier.Button.STYLUS;
buttonIDs[NativeDefinitions.BTN_STYLUS2] = Component.Identifier.Button.STYLUS2;
relAxesIDs[NativeDefinitions.REL_X] = Component.Identifier.Axis.X;
relAxesIDs[NativeDefinitions.REL_Y] = Component.Identifier.Axis.Y;
relAxesIDs[NativeDefinitions.REL_Z] = Component.Identifier.Axis.Z;
relAxesIDs[NativeDefinitions.REL_WHEEL] = Component.Identifier.Axis.Z;
// There are guesses as I have no idea what they would be used for
relAxesIDs[NativeDefinitions.REL_HWHEEL] = Component.Identifier.Axis.SLIDER;
relAxesIDs[NativeDefinitions.REL_DIAL] = Component.Identifier.Axis.SLIDER;
relAxesIDs[NativeDefinitions.REL_MISC] = Component.Identifier.Axis.SLIDER;
absAxesIDs[NativeDefinitions.ABS_X] = Component.Identifier.Axis.X;
absAxesIDs[NativeDefinitions.ABS_Y] = Component.Identifier.Axis.Y;
absAxesIDs[NativeDefinitions.ABS_Z] = Component.Identifier.Axis.Z;
absAxesIDs[NativeDefinitions.ABS_RX] = Component.Identifier.Axis.RX;
absAxesIDs[NativeDefinitions.ABS_RY] = Component.Identifier.Axis.RY;
absAxesIDs[NativeDefinitions.ABS_RZ] = Component.Identifier.Axis.RZ;
absAxesIDs[NativeDefinitions.ABS_THROTTLE] = Component.Identifier.Axis.SLIDER;
absAxesIDs[NativeDefinitions.ABS_RUDDER] = Component.Identifier.Axis.RZ;
absAxesIDs[NativeDefinitions.ABS_WHEEL] = Component.Identifier.Axis.Y;
absAxesIDs[NativeDefinitions.ABS_GAS] = Component.Identifier.Axis.SLIDER;
absAxesIDs[NativeDefinitions.ABS_BRAKE] = Component.Identifier.Axis.SLIDER;
// Hats are done this way as they are mapped from two axis down to one
absAxesIDs[NativeDefinitions.ABS_HAT0X] = Component.Identifier.Axis.POV;
absAxesIDs[NativeDefinitions.ABS_HAT0Y] = Component.Identifier.Axis.POV;
absAxesIDs[NativeDefinitions.ABS_HAT1X] = Component.Identifier.Axis.POV;
absAxesIDs[NativeDefinitions.ABS_HAT1Y] = Component.Identifier.Axis.POV;
absAxesIDs[NativeDefinitions.ABS_HAT2X] = Component.Identifier.Axis.POV;
absAxesIDs[NativeDefinitions.ABS_HAT2Y] = Component.Identifier.Axis.POV;
absAxesIDs[NativeDefinitions.ABS_HAT3X] = Component.Identifier.Axis.POV;
absAxesIDs[NativeDefinitions.ABS_HAT3Y] = Component.Identifier.Axis.POV;
// erm, yeah
absAxesIDs[NativeDefinitions.ABS_PRESSURE] = null;
absAxesIDs[NativeDefinitions.ABS_DISTANCE] = null;
absAxesIDs[NativeDefinitions.ABS_TILT_X] = null;
absAxesIDs[NativeDefinitions.ABS_TILT_Y] = null;
absAxesIDs[NativeDefinitions.ABS_MISC] = null;
}
public final static Controller.Type guessButtonTrait(int button_code) {
switch (button_code) {
case NativeDefinitions.BTN_TRIGGER :
case NativeDefinitions.BTN_THUMB :
case NativeDefinitions.BTN_THUMB2 :
case NativeDefinitions.BTN_TOP :
case NativeDefinitions.BTN_TOP2 :
case NativeDefinitions.BTN_PINKIE :
case NativeDefinitions.BTN_BASE :
case NativeDefinitions.BTN_BASE2 :
case NativeDefinitions.BTN_BASE3 :
case NativeDefinitions.BTN_BASE4 :
case NativeDefinitions.BTN_BASE5 :
case NativeDefinitions.BTN_BASE6 :
case NativeDefinitions.BTN_DEAD :
return Controller.Type.STICK;
case NativeDefinitions.BTN_A :
case NativeDefinitions.BTN_B :
case NativeDefinitions.BTN_C :
case NativeDefinitions.BTN_X :
case NativeDefinitions.BTN_Y :
case NativeDefinitions.BTN_Z :
case NativeDefinitions.BTN_TL :
case NativeDefinitions.BTN_TR :
case NativeDefinitions.BTN_TL2 :
case NativeDefinitions.BTN_TR2 :
case NativeDefinitions.BTN_SELECT :
case NativeDefinitions.BTN_START :
case NativeDefinitions.BTN_MODE :
case NativeDefinitions.BTN_THUMBL :
case NativeDefinitions.BTN_THUMBR :
return Controller.Type.GAMEPAD;
case NativeDefinitions.BTN_0 :
case NativeDefinitions.BTN_1 :
case NativeDefinitions.BTN_2 :
case NativeDefinitions.BTN_3 :
case NativeDefinitions.BTN_4 :
case NativeDefinitions.BTN_5 :
case NativeDefinitions.BTN_6 :
case NativeDefinitions.BTN_7 :
case NativeDefinitions.BTN_8 :
case NativeDefinitions.BTN_9 :
return Controller.Type.UNKNOWN;
case NativeDefinitions.BTN_LEFT :
case NativeDefinitions.BTN_RIGHT :
case NativeDefinitions.BTN_MIDDLE :
case NativeDefinitions.BTN_SIDE :
case NativeDefinitions.BTN_EXTRA :
return Controller.Type.MOUSE;
// case NativeDefinitions.KEY_RESERVED:
case NativeDefinitions.KEY_ESC:
case NativeDefinitions.KEY_1:
case NativeDefinitions.KEY_2:
case NativeDefinitions.KEY_3:
case NativeDefinitions.KEY_4:
case NativeDefinitions.KEY_5:
case NativeDefinitions.KEY_6:
case NativeDefinitions.KEY_7:
case NativeDefinitions.KEY_8:
case NativeDefinitions.KEY_9:
case NativeDefinitions.KEY_0:
case NativeDefinitions.KEY_MINUS:
case NativeDefinitions.KEY_EQUAL:
case NativeDefinitions.KEY_BACKSPACE:
case NativeDefinitions.KEY_TAB:
case NativeDefinitions.KEY_Q:
case NativeDefinitions.KEY_W:
case NativeDefinitions.KEY_E:
case NativeDefinitions.KEY_R:
case NativeDefinitions.KEY_T:
case NativeDefinitions.KEY_Y:
case NativeDefinitions.KEY_U:
case NativeDefinitions.KEY_I:
case NativeDefinitions.KEY_O:
case NativeDefinitions.KEY_P:
case NativeDefinitions.KEY_LEFTBRACE:
case NativeDefinitions.KEY_RIGHTBRACE:
case NativeDefinitions.KEY_ENTER:
case NativeDefinitions.KEY_LEFTCTRL:
case NativeDefinitions.KEY_A:
case NativeDefinitions.KEY_S:
case NativeDefinitions.KEY_D:
case NativeDefinitions.KEY_F:
case NativeDefinitions.KEY_G:
case NativeDefinitions.KEY_H:
case NativeDefinitions.KEY_J:
case NativeDefinitions.KEY_K:
case NativeDefinitions.KEY_L:
case NativeDefinitions.KEY_SEMICOLON:
case NativeDefinitions.KEY_APOSTROPHE:
case NativeDefinitions.KEY_GRAVE:
case NativeDefinitions.KEY_LEFTSHIFT:
case NativeDefinitions.KEY_BACKSLASH:
case NativeDefinitions.KEY_Z:
case NativeDefinitions.KEY_X:
case NativeDefinitions.KEY_C:
case NativeDefinitions.KEY_V:
case NativeDefinitions.KEY_B:
case NativeDefinitions.KEY_N:
case NativeDefinitions.KEY_M:
case NativeDefinitions.KEY_COMMA:
case NativeDefinitions.KEY_DOT:
case NativeDefinitions.KEY_SLASH:
case NativeDefinitions.KEY_RIGHTSHIFT:
case NativeDefinitions.KEY_KPASTERISK:
case NativeDefinitions.KEY_LEFTALT:
case NativeDefinitions.KEY_SPACE:
case NativeDefinitions.KEY_CAPSLOCK:
case NativeDefinitions.KEY_F1:
case NativeDefinitions.KEY_F2:
case NativeDefinitions.KEY_F3:
case NativeDefinitions.KEY_F4:
case NativeDefinitions.KEY_F5:
case NativeDefinitions.KEY_F6:
case NativeDefinitions.KEY_F7:
case NativeDefinitions.KEY_F8:
case NativeDefinitions.KEY_F9:
case NativeDefinitions.KEY_F10:
case NativeDefinitions.KEY_NUMLOCK:
case NativeDefinitions.KEY_SCROLLLOCK:
case NativeDefinitions.KEY_KP7:
case NativeDefinitions.KEY_KP8:
case NativeDefinitions.KEY_KP9:
case NativeDefinitions.KEY_KPMINUS:
case NativeDefinitions.KEY_KP4:
case NativeDefinitions.KEY_KP5:
case NativeDefinitions.KEY_KP6:
case NativeDefinitions.KEY_KPPLUS:
case NativeDefinitions.KEY_KP1:
case NativeDefinitions.KEY_KP2:
case NativeDefinitions.KEY_KP3:
case NativeDefinitions.KEY_KP0:
case NativeDefinitions.KEY_KPDOT:
case NativeDefinitions.KEY_ZENKAKUHANKAKU:
case NativeDefinitions.KEY_102ND:
case NativeDefinitions.KEY_F11:
case NativeDefinitions.KEY_F12:
case NativeDefinitions.KEY_RO:
case NativeDefinitions.KEY_KATAKANA:
case NativeDefinitions.KEY_HIRAGANA:
case NativeDefinitions.KEY_HENKAN:
case NativeDefinitions.KEY_KATAKANAHIRAGANA:
case NativeDefinitions.KEY_MUHENKAN:
case NativeDefinitions.KEY_KPJPCOMMA:
case NativeDefinitions.KEY_KPENTER:
case NativeDefinitions.KEY_RIGHTCTRL:
case NativeDefinitions.KEY_KPSLASH:
case NativeDefinitions.KEY_SYSRQ:
case NativeDefinitions.KEY_RIGHTALT:
case NativeDefinitions.KEY_LINEFEED:
case NativeDefinitions.KEY_HOME:
case NativeDefinitions.KEY_UP:
case NativeDefinitions.KEY_PAGEUP:
case NativeDefinitions.KEY_LEFT:
case NativeDefinitions.KEY_RIGHT:
case NativeDefinitions.KEY_END:
case NativeDefinitions.KEY_DOWN:
case NativeDefinitions.KEY_PAGEDOWN:
case NativeDefinitions.KEY_INSERT:
case NativeDefinitions.KEY_DELETE:
case NativeDefinitions.KEY_MACRO:
case NativeDefinitions.KEY_MUTE:
case NativeDefinitions.KEY_VOLUMEDOWN:
case NativeDefinitions.KEY_VOLUMEUP:
case NativeDefinitions.KEY_POWER:
case NativeDefinitions.KEY_KPEQUAL:
case NativeDefinitions.KEY_KPPLUSMINUS:
case NativeDefinitions.KEY_PAUSE:
case NativeDefinitions.KEY_KPCOMMA:
case NativeDefinitions.KEY_HANGUEL:
case NativeDefinitions.KEY_HANJA:
case NativeDefinitions.KEY_YEN:
case NativeDefinitions.KEY_LEFTMETA:
case NativeDefinitions.KEY_RIGHTMETA:
case NativeDefinitions.KEY_COMPOSE:
case NativeDefinitions.KEY_STOP:
case NativeDefinitions.KEY_AGAIN:
case NativeDefinitions.KEY_PROPS:
case NativeDefinitions.KEY_UNDO:
case NativeDefinitions.KEY_FRONT:
case NativeDefinitions.KEY_COPY:
case NativeDefinitions.KEY_OPEN:
case NativeDefinitions.KEY_PASTE:
case NativeDefinitions.KEY_FIND:
case NativeDefinitions.KEY_CUT:
case NativeDefinitions.KEY_HELP:
case NativeDefinitions.KEY_MENU:
case NativeDefinitions.KEY_CALC:
case NativeDefinitions.KEY_SETUP:
case NativeDefinitions.KEY_SLEEP:
case NativeDefinitions.KEY_WAKEUP:
case NativeDefinitions.KEY_FILE:
case NativeDefinitions.KEY_SENDFILE:
case NativeDefinitions.KEY_DELETEFILE:
case NativeDefinitions.KEY_XFER:
case NativeDefinitions.KEY_PROG1:
case NativeDefinitions.KEY_PROG2:
case NativeDefinitions.KEY_WWW:
case NativeDefinitions.KEY_MSDOS:
case NativeDefinitions.KEY_COFFEE:
case NativeDefinitions.KEY_DIRECTION:
case NativeDefinitions.KEY_CYCLEWINDOWS:
case NativeDefinitions.KEY_MAIL:
case NativeDefinitions.KEY_BOOKMARKS:
case NativeDefinitions.KEY_COMPUTER:
case NativeDefinitions.KEY_BACK:
case NativeDefinitions.KEY_FORWARD:
case NativeDefinitions.KEY_CLOSECD:
case NativeDefinitions.KEY_EJECTCD:
case NativeDefinitions.KEY_EJECTCLOSECD:
case NativeDefinitions.KEY_NEXTSONG:
case NativeDefinitions.KEY_PLAYPAUSE:
case NativeDefinitions.KEY_PREVIOUSSONG:
case NativeDefinitions.KEY_STOPCD:
case NativeDefinitions.KEY_RECORD:
case NativeDefinitions.KEY_REWIND:
case NativeDefinitions.KEY_PHONE:
case NativeDefinitions.KEY_ISO:
case NativeDefinitions.KEY_CONFIG:
case NativeDefinitions.KEY_HOMEPAGE:
case NativeDefinitions.KEY_REFRESH:
case NativeDefinitions.KEY_EXIT:
case NativeDefinitions.KEY_MOVE:
case NativeDefinitions.KEY_EDIT:
case NativeDefinitions.KEY_SCROLLUP:
case NativeDefinitions.KEY_SCROLLDOWN:
case NativeDefinitions.KEY_KPLEFTPAREN:
case NativeDefinitions.KEY_KPRIGHTPAREN:
case NativeDefinitions.KEY_F13:
case NativeDefinitions.KEY_F14:
case NativeDefinitions.KEY_F15:
case NativeDefinitions.KEY_F16:
case NativeDefinitions.KEY_F17:
case NativeDefinitions.KEY_F18:
case NativeDefinitions.KEY_F19:
case NativeDefinitions.KEY_F20:
case NativeDefinitions.KEY_F21:
case NativeDefinitions.KEY_F22:
case NativeDefinitions.KEY_F23:
case NativeDefinitions.KEY_F24:
case NativeDefinitions.KEY_PLAYCD:
case NativeDefinitions.KEY_PAUSECD:
case NativeDefinitions.KEY_PROG3:
case NativeDefinitions.KEY_PROG4:
case NativeDefinitions.KEY_SUSPEND:
case NativeDefinitions.KEY_CLOSE:
case NativeDefinitions.KEY_PLAY:
case NativeDefinitions.KEY_FASTFORWARD:
case NativeDefinitions.KEY_BASSBOOST:
case NativeDefinitions.KEY_PRINT:
case NativeDefinitions.KEY_HP:
case NativeDefinitions.KEY_CAMERA:
case NativeDefinitions.KEY_SOUND:
case NativeDefinitions.KEY_QUESTION:
case NativeDefinitions.KEY_EMAIL:
case NativeDefinitions.KEY_CHAT:
case NativeDefinitions.KEY_SEARCH:
case NativeDefinitions.KEY_CONNECT:
case NativeDefinitions.KEY_FINANCE:
case NativeDefinitions.KEY_SPORT:
case NativeDefinitions.KEY_SHOP:
case NativeDefinitions.KEY_ALTERASE:
case NativeDefinitions.KEY_CANCEL:
case NativeDefinitions.KEY_BRIGHTNESSDOWN:
case NativeDefinitions.KEY_BRIGHTNESSUP:
case NativeDefinitions.KEY_MEDIA:
case NativeDefinitions.KEY_SWITCHVIDEOMODE:
case NativeDefinitions.KEY_KBDILLUMTOGGLE:
case NativeDefinitions.KEY_KBDILLUMDOWN:
case NativeDefinitions.KEY_KBDILLUMUP:
// case NativeDefinitions.KEY_UNKNOWN:
case NativeDefinitions.KEY_OK:
case NativeDefinitions.KEY_SELECT:
case NativeDefinitions.KEY_GOTO:
case NativeDefinitions.KEY_CLEAR:
case NativeDefinitions.KEY_POWER2:
case NativeDefinitions.KEY_OPTION:
case NativeDefinitions.KEY_INFO:
case NativeDefinitions.KEY_TIME:
case NativeDefinitions.KEY_VENDOR:
case NativeDefinitions.KEY_ARCHIVE:
case NativeDefinitions.KEY_PROGRAM:
case NativeDefinitions.KEY_CHANNEL:
case NativeDefinitions.KEY_FAVORITES:
case NativeDefinitions.KEY_EPG:
case NativeDefinitions.KEY_PVR:
case NativeDefinitions.KEY_MHP:
case NativeDefinitions.KEY_LANGUAGE:
case NativeDefinitions.KEY_TITLE:
case NativeDefinitions.KEY_SUBTITLE:
case NativeDefinitions.KEY_ANGLE:
case NativeDefinitions.KEY_ZOOM:
case NativeDefinitions.KEY_MODE:
case NativeDefinitions.KEY_KEYBOARD:
case NativeDefinitions.KEY_SCREEN:
case NativeDefinitions.KEY_PC:
case NativeDefinitions.KEY_TV:
case NativeDefinitions.KEY_TV2:
case NativeDefinitions.KEY_VCR:
case NativeDefinitions.KEY_VCR2:
case NativeDefinitions.KEY_SAT:
case NativeDefinitions.KEY_SAT2:
case NativeDefinitions.KEY_CD:
case NativeDefinitions.KEY_TAPE:
case NativeDefinitions.KEY_RADIO:
case NativeDefinitions.KEY_TUNER:
case NativeDefinitions.KEY_PLAYER:
case NativeDefinitions.KEY_TEXT:
case NativeDefinitions.KEY_DVD:
case NativeDefinitions.KEY_AUX:
case NativeDefinitions.KEY_MP3:
case NativeDefinitions.KEY_AUDIO:
case NativeDefinitions.KEY_VIDEO:
case NativeDefinitions.KEY_DIRECTORY:
case NativeDefinitions.KEY_LIST:
case NativeDefinitions.KEY_MEMO:
case NativeDefinitions.KEY_CALENDAR:
case NativeDefinitions.KEY_RED:
case NativeDefinitions.KEY_GREEN:
case NativeDefinitions.KEY_YELLOW:
case NativeDefinitions.KEY_BLUE:
case NativeDefinitions.KEY_CHANNELUP:
case NativeDefinitions.KEY_CHANNELDOWN:
case NativeDefinitions.KEY_FIRST:
case NativeDefinitions.KEY_LAST:
case NativeDefinitions.KEY_AB:
case NativeDefinitions.KEY_NEXT:
case NativeDefinitions.KEY_RESTART:
case NativeDefinitions.KEY_SLOW:
case NativeDefinitions.KEY_SHUFFLE:
case NativeDefinitions.KEY_BREAK:
case NativeDefinitions.KEY_PREVIOUS:
case NativeDefinitions.KEY_DIGITS:
case NativeDefinitions.KEY_TEEN:
case NativeDefinitions.KEY_TWEN:
case NativeDefinitions.KEY_DEL_EOL:
case NativeDefinitions.KEY_DEL_EOS:
case NativeDefinitions.KEY_INS_LINE:
case NativeDefinitions.KEY_DEL_LINE:
case NativeDefinitions.KEY_FN:
case NativeDefinitions.KEY_FN_ESC:
case NativeDefinitions.KEY_FN_F1:
case NativeDefinitions.KEY_FN_F2:
case NativeDefinitions.KEY_FN_F3:
case NativeDefinitions.KEY_FN_F4:
case NativeDefinitions.KEY_FN_F5:
case NativeDefinitions.KEY_FN_F6:
case NativeDefinitions.KEY_FN_F7:
case NativeDefinitions.KEY_FN_F8:
case NativeDefinitions.KEY_FN_F9:
case NativeDefinitions.KEY_FN_F10:
case NativeDefinitions.KEY_FN_F11:
case NativeDefinitions.KEY_FN_F12:
case NativeDefinitions.KEY_FN_1:
case NativeDefinitions.KEY_FN_2:
case NativeDefinitions.KEY_FN_D:
case NativeDefinitions.KEY_FN_E:
case NativeDefinitions.KEY_FN_F:
case NativeDefinitions.KEY_FN_S:
case NativeDefinitions.KEY_FN_B:
return Controller.Type.KEYBOARD;
default:
return Controller.Type.UNKNOWN;
}
}
/** Return port type from a native port type int id
* @param nativeid The native port type
* @return The jinput port type
*/
public static Controller.PortType getPortType(int nativeid) {
// Have to do this one this way as there is no BUS_MAX
switch (nativeid) {
case NativeDefinitions.BUS_GAMEPORT :
return Controller.PortType.GAME;
case NativeDefinitions.BUS_I8042 :
return Controller.PortType.I8042;
case NativeDefinitions.BUS_PARPORT :
return Controller.PortType.PARALLEL;
case NativeDefinitions.BUS_RS232 :
return Controller.PortType.SERIAL;
case NativeDefinitions.BUS_USB :
return Controller.PortType.USB;
default:
return Controller.PortType.UNKNOWN;
}
}
/** Gets the identifier for a relative axis
* @param nativeID The axis type ID
* @return The jinput id
*/
public static Component.Identifier getRelAxisID(int nativeID) {
Component.Identifier retval = null;
try {
retval = INSTANCE.relAxesIDs[nativeID];
} catch (ArrayIndexOutOfBoundsException e) {
log.warning("INSTANCE.relAxesIDis only " + INSTANCE.relAxesIDs.length + " long, so " + nativeID + " not contained");
//ignore, pretend it was null
}
if(retval == null) {
retval = Component.Identifier.Axis.SLIDER_VELOCITY;
}
return retval;
}
/** Gets the identifier for a absolute axis
* @param nativeID The native axis type id
* @return The jinput id
*/
public static Component.Identifier getAbsAxisID(int nativeID) {
Component.Identifier retval = null;
try {
retval = INSTANCE.absAxesIDs[nativeID];
} catch (ArrayIndexOutOfBoundsException e) {
log.warning("INSTANCE.absAxesIDs is only " + INSTANCE.absAxesIDs.length + " long, so " + nativeID + " not contained");
//ignore, pretend it was null
}
if(retval == null) {
retval = Component.Identifier.Axis.SLIDER;
}
return retval;
}
/** Gets the identifier for a button
* @param nativeID The native button type id
* @return The jinput id
*/
public static Component.Identifier getButtonID(int nativeID) {
Component.Identifier retval = null;
try {
retval = INSTANCE.buttonIDs[nativeID];
} catch (ArrayIndexOutOfBoundsException e) {
log.warning("INSTANCE.buttonIDs is only " + INSTANCE.buttonIDs.length + " long, so " + nativeID + " not contained");
//ignore, pretend it was null
}
if(retval == null) {
retval = Component.Identifier.Button.UNKNOWN;
}
return retval;
}
}

View file

@ -0,0 +1,95 @@
/*
* %W% %E%
*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
/*****************************************************************************
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materails provided with the distribution.
*
* Neither the name Sun Microsystems, Inc. or the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMEN, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND
* ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS
* A RESULT OF USING, MODIFYING OR DESTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES. HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OUR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for us in
* the design, construction, operation or maintenance of any nuclear facility
*
*****************************************************************************/
package net.java.games.input;
import java.io.IOException;
/** Represents a linux button
* @author elias
* @version 1.0
*/
final class LinuxPOV extends LinuxComponent {
private final LinuxEventComponent component_x;
private final LinuxEventComponent component_y;
private float last_x;
private float last_y;
public LinuxPOV(LinuxEventComponent component_x, LinuxEventComponent component_y) {
super(component_x);
this.component_x = component_x;
this.component_y = component_y;
}
protected final float poll() throws IOException {
last_x = LinuxControllers.poll(component_x);
last_y = LinuxControllers.poll(component_y);
return convertValue(0f, null);
}
public float convertValue(float value, LinuxAxisDescriptor descriptor) {
if (descriptor == component_x.getDescriptor())
last_x = value;
if (descriptor == component_y.getDescriptor())
last_y = value;
if (last_x == -1 && last_y == -1)
return Component.POV.UP_LEFT;
else if (last_x == -1 && last_y == 0)
return Component.POV.LEFT;
else if (last_x == -1 && last_y == 1)
return Component.POV.DOWN_LEFT;
else if (last_x == 0 && last_y == -1)
return Component.POV.UP;
else if (last_x == 0 && last_y == 0)
return Component.POV.OFF;
else if (last_x == 0 && last_y == 1)
return Component.POV.DOWN;
else if (last_x == 1 && last_y == -1)
return Component.POV.UP_RIGHT;
else if (last_x == 1 && last_y == 0)
return Component.POV.RIGHT;
else if (last_x == 1 && last_y == 1)
return Component.POV.DOWN_RIGHT;
else {
LinuxEnvironmentPlugin.log("Unknown values x = " + last_x + " | y = " + last_y);
return Component.POV.OFF;
}
}
}

View file

@ -0,0 +1,54 @@
/*
* Copyright (C) 2003 Jeremy Booth (jeremy@newdawnsoftware.com)
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer. Redistributions in binary
* form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided
* with the distribution.
* The name of the author may not be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*/
package net.java.games.input;
import java.io.IOException;
/**
* @author elias
*/
final class LinuxRumbleFF extends LinuxForceFeedbackEffect {
public LinuxRumbleFF(LinuxEventDevice device) throws IOException {
super(device);
}
protected final int upload(int id, float intensity) throws IOException {
int weak_magnitude;
int strong_magnitude;
if (intensity > 0.666666f) {
strong_magnitude = (int)(0x8000*intensity);
weak_magnitude = (int)(0xc000*intensity);
} else if (intensity > 0.3333333f) {
strong_magnitude = (int)(0x8000*intensity);
weak_magnitude = 0;
} else {
strong_magnitude = 0;
weak_magnitude = (int)(0xc000*intensity);
}
return getDevice().uploadRumbleEffect(id, 0, 0, 0, -1, 0, strong_magnitude, weak_magnitude);
}
}

View file

@ -0,0 +1,634 @@
package net.java.games.input;
/**
* This file is generated from /usr/src/linux-headers-3.2.0-38-generic/include/linux/input.h please do not edit
*/
class NativeDefinitions {
public static final int EV_VERSION = 0x010001;
public static final int EV_SYN = 0x00;
public static final int EV_KEY = 0x01;
public static final int EV_REL = 0x02;
public static final int EV_ABS = 0x03;
public static final int EV_MSC = 0x04;
public static final int EV_SW = 0x05;
public static final int EV_LED = 0x11;
public static final int EV_SND = 0x12;
public static final int EV_REP = 0x14;
public static final int EV_FF = 0x15;
public static final int EV_PWR = 0x16;
public static final int EV_FF_STATUS = 0x17;
public static final int EV_MAX = 0x1f;
public static final int EV_CNT = (EV_MAX+1);
public static final int KEY_RESERVED = 0;
public static final int KEY_ESC = 1;
public static final int KEY_1 = 2;
public static final int KEY_2 = 3;
public static final int KEY_3 = 4;
public static final int KEY_4 = 5;
public static final int KEY_5 = 6;
public static final int KEY_6 = 7;
public static final int KEY_7 = 8;
public static final int KEY_8 = 9;
public static final int KEY_9 = 10;
public static final int KEY_0 = 11;
public static final int KEY_MINUS = 12;
public static final int KEY_EQUAL = 13;
public static final int KEY_BACKSPACE = 14;
public static final int KEY_TAB = 15;
public static final int KEY_Q = 16;
public static final int KEY_W = 17;
public static final int KEY_E = 18;
public static final int KEY_R = 19;
public static final int KEY_T = 20;
public static final int KEY_Y = 21;
public static final int KEY_U = 22;
public static final int KEY_I = 23;
public static final int KEY_O = 24;
public static final int KEY_P = 25;
public static final int KEY_LEFTBRACE = 26;
public static final int KEY_RIGHTBRACE = 27;
public static final int KEY_ENTER = 28;
public static final int KEY_LEFTCTRL = 29;
public static final int KEY_A = 30;
public static final int KEY_S = 31;
public static final int KEY_D = 32;
public static final int KEY_F = 33;
public static final int KEY_G = 34;
public static final int KEY_H = 35;
public static final int KEY_J = 36;
public static final int KEY_K = 37;
public static final int KEY_L = 38;
public static final int KEY_SEMICOLON = 39;
public static final int KEY_APOSTROPHE = 40;
public static final int KEY_GRAVE = 41;
public static final int KEY_LEFTSHIFT = 42;
public static final int KEY_BACKSLASH = 43;
public static final int KEY_Z = 44;
public static final int KEY_X = 45;
public static final int KEY_C = 46;
public static final int KEY_V = 47;
public static final int KEY_B = 48;
public static final int KEY_N = 49;
public static final int KEY_M = 50;
public static final int KEY_COMMA = 51;
public static final int KEY_DOT = 52;
public static final int KEY_SLASH = 53;
public static final int KEY_RIGHTSHIFT = 54;
public static final int KEY_KPASTERISK = 55;
public static final int KEY_LEFTALT = 56;
public static final int KEY_SPACE = 57;
public static final int KEY_CAPSLOCK = 58;
public static final int KEY_F1 = 59;
public static final int KEY_F2 = 60;
public static final int KEY_F3 = 61;
public static final int KEY_F4 = 62;
public static final int KEY_F5 = 63;
public static final int KEY_F6 = 64;
public static final int KEY_F7 = 65;
public static final int KEY_F8 = 66;
public static final int KEY_F9 = 67;
public static final int KEY_F10 = 68;
public static final int KEY_NUMLOCK = 69;
public static final int KEY_SCROLLLOCK = 70;
public static final int KEY_KP7 = 71;
public static final int KEY_KP8 = 72;
public static final int KEY_KP9 = 73;
public static final int KEY_KPMINUS = 74;
public static final int KEY_KP4 = 75;
public static final int KEY_KP5 = 76;
public static final int KEY_KP6 = 77;
public static final int KEY_KPPLUS = 78;
public static final int KEY_KP1 = 79;
public static final int KEY_KP2 = 80;
public static final int KEY_KP3 = 81;
public static final int KEY_KP0 = 82;
public static final int KEY_KPDOT = 83;
public static final int KEY_ZENKAKUHANKAKU = 85;
public static final int KEY_102ND = 86;
public static final int KEY_F11 = 87;
public static final int KEY_F12 = 88;
public static final int KEY_RO = 89;
public static final int KEY_KATAKANA = 90;
public static final int KEY_HIRAGANA = 91;
public static final int KEY_HENKAN = 92;
public static final int KEY_KATAKANAHIRAGANA = 93;
public static final int KEY_MUHENKAN = 94;
public static final int KEY_KPJPCOMMA = 95;
public static final int KEY_KPENTER = 96;
public static final int KEY_RIGHTCTRL = 97;
public static final int KEY_KPSLASH = 98;
public static final int KEY_SYSRQ = 99;
public static final int KEY_RIGHTALT = 100;
public static final int KEY_LINEFEED = 101;
public static final int KEY_HOME = 102;
public static final int KEY_UP = 103;
public static final int KEY_PAGEUP = 104;
public static final int KEY_LEFT = 105;
public static final int KEY_RIGHT = 106;
public static final int KEY_END = 107;
public static final int KEY_DOWN = 108;
public static final int KEY_PAGEDOWN = 109;
public static final int KEY_INSERT = 110;
public static final int KEY_DELETE = 111;
public static final int KEY_MACRO = 112;
public static final int KEY_MUTE = 113;
public static final int KEY_VOLUMEDOWN = 114;
public static final int KEY_VOLUMEUP = 115;
public static final int KEY_POWER = 116;
public static final int KEY_KPEQUAL = 117;
public static final int KEY_KPPLUSMINUS = 118;
public static final int KEY_PAUSE = 119;
public static final int KEY_SCALE = 120;
public static final int KEY_KPCOMMA = 121;
public static final int KEY_HANGEUL = 122;
public static final int KEY_HANGUEL = KEY_HANGEUL;
public static final int KEY_HANJA = 123;
public static final int KEY_YEN = 124;
public static final int KEY_LEFTMETA = 125;
public static final int KEY_RIGHTMETA = 126;
public static final int KEY_COMPOSE = 127;
public static final int KEY_STOP = 128;
public static final int KEY_AGAIN = 129;
public static final int KEY_PROPS = 130;
public static final int KEY_UNDO = 131;
public static final int KEY_FRONT = 132;
public static final int KEY_COPY = 133;
public static final int KEY_OPEN = 134;
public static final int KEY_PASTE = 135;
public static final int KEY_FIND = 136;
public static final int KEY_CUT = 137;
public static final int KEY_HELP = 138;
public static final int KEY_MENU = 139;
public static final int KEY_CALC = 140;
public static final int KEY_SETUP = 141;
public static final int KEY_SLEEP = 142;
public static final int KEY_WAKEUP = 143;
public static final int KEY_FILE = 144;
public static final int KEY_SENDFILE = 145;
public static final int KEY_DELETEFILE = 146;
public static final int KEY_XFER = 147;
public static final int KEY_PROG1 = 148;
public static final int KEY_PROG2 = 149;
public static final int KEY_WWW = 150;
public static final int KEY_MSDOS = 151;
public static final int KEY_COFFEE = 152;
public static final int KEY_SCREENLOCK = KEY_COFFEE;
public static final int KEY_DIRECTION = 153;
public static final int KEY_CYCLEWINDOWS = 154;
public static final int KEY_MAIL = 155;
public static final int KEY_BOOKMARKS = 156;
public static final int KEY_COMPUTER = 157;
public static final int KEY_BACK = 158;
public static final int KEY_FORWARD = 159;
public static final int KEY_CLOSECD = 160;
public static final int KEY_EJECTCD = 161;
public static final int KEY_EJECTCLOSECD = 162;
public static final int KEY_NEXTSONG = 163;
public static final int KEY_PLAYPAUSE = 164;
public static final int KEY_PREVIOUSSONG = 165;
public static final int KEY_STOPCD = 166;
public static final int KEY_RECORD = 167;
public static final int KEY_REWIND = 168;
public static final int KEY_PHONE = 169;
public static final int KEY_ISO = 170;
public static final int KEY_CONFIG = 171;
public static final int KEY_HOMEPAGE = 172;
public static final int KEY_REFRESH = 173;
public static final int KEY_EXIT = 174;
public static final int KEY_MOVE = 175;
public static final int KEY_EDIT = 176;
public static final int KEY_SCROLLUP = 177;
public static final int KEY_SCROLLDOWN = 178;
public static final int KEY_KPLEFTPAREN = 179;
public static final int KEY_KPRIGHTPAREN = 180;
public static final int KEY_NEW = 181;
public static final int KEY_REDO = 182;
public static final int KEY_F13 = 183;
public static final int KEY_F14 = 184;
public static final int KEY_F15 = 185;
public static final int KEY_F16 = 186;
public static final int KEY_F17 = 187;
public static final int KEY_F18 = 188;
public static final int KEY_F19 = 189;
public static final int KEY_F20 = 190;
public static final int KEY_F21 = 191;
public static final int KEY_F22 = 192;
public static final int KEY_F23 = 193;
public static final int KEY_F24 = 194;
public static final int KEY_PLAYCD = 200;
public static final int KEY_PAUSECD = 201;
public static final int KEY_PROG3 = 202;
public static final int KEY_PROG4 = 203;
public static final int KEY_DASHBOARD = 204;
public static final int KEY_SUSPEND = 205;
public static final int KEY_CLOSE = 206;
public static final int KEY_PLAY = 207;
public static final int KEY_FASTFORWARD = 208;
public static final int KEY_BASSBOOST = 209;
public static final int KEY_PRINT = 210;
public static final int KEY_HP = 211;
public static final int KEY_CAMERA = 212;
public static final int KEY_SOUND = 213;
public static final int KEY_QUESTION = 214;
public static final int KEY_EMAIL = 215;
public static final int KEY_CHAT = 216;
public static final int KEY_SEARCH = 217;
public static final int KEY_CONNECT = 218;
public static final int KEY_FINANCE = 219;
public static final int KEY_SPORT = 220;
public static final int KEY_SHOP = 221;
public static final int KEY_ALTERASE = 222;
public static final int KEY_CANCEL = 223;
public static final int KEY_BRIGHTNESSDOWN = 224;
public static final int KEY_BRIGHTNESSUP = 225;
public static final int KEY_MEDIA = 226;
public static final int KEY_SWITCHVIDEOMODE = 227;
public static final int KEY_KBDILLUMTOGGLE = 228;
public static final int KEY_KBDILLUMDOWN = 229;
public static final int KEY_KBDILLUMUP = 230;
public static final int KEY_SEND = 231;
public static final int KEY_REPLY = 232;
public static final int KEY_FORWARDMAIL = 233;
public static final int KEY_SAVE = 234;
public static final int KEY_DOCUMENTS = 235;
public static final int KEY_BATTERY = 236;
public static final int KEY_BLUETOOTH = 237;
public static final int KEY_WLAN = 238;
public static final int KEY_UWB = 239;
public static final int KEY_UNKNOWN = 240;
public static final int KEY_VIDEO_NEXT = 241;
public static final int KEY_VIDEO_PREV = 242;
public static final int KEY_BRIGHTNESS_CYCLE = 243;
public static final int KEY_BRIGHTNESS_ZERO = 244;
public static final int KEY_DISPLAY_OFF = 245;
public static final int KEY_WIMAX = 246;
public static final int KEY_RFKILL = 247;
public static final int KEY_MICMUTE = 248;
public static final int BTN_MISC = 0x100;
public static final int BTN_0 = 0x100;
public static final int BTN_1 = 0x101;
public static final int BTN_2 = 0x102;
public static final int BTN_3 = 0x103;
public static final int BTN_4 = 0x104;
public static final int BTN_5 = 0x105;
public static final int BTN_6 = 0x106;
public static final int BTN_7 = 0x107;
public static final int BTN_8 = 0x108;
public static final int BTN_9 = 0x109;
public static final int BTN_MOUSE = 0x110;
public static final int BTN_LEFT = 0x110;
public static final int BTN_RIGHT = 0x111;
public static final int BTN_MIDDLE = 0x112;
public static final int BTN_SIDE = 0x113;
public static final int BTN_EXTRA = 0x114;
public static final int BTN_FORWARD = 0x115;
public static final int BTN_BACK = 0x116;
public static final int BTN_TASK = 0x117;
public static final int BTN_JOYSTICK = 0x120;
public static final int BTN_TRIGGER = 0x120;
public static final int BTN_THUMB = 0x121;
public static final int BTN_THUMB2 = 0x122;
public static final int BTN_TOP = 0x123;
public static final int BTN_TOP2 = 0x124;
public static final int BTN_PINKIE = 0x125;
public static final int BTN_BASE = 0x126;
public static final int BTN_BASE2 = 0x127;
public static final int BTN_BASE3 = 0x128;
public static final int BTN_BASE4 = 0x129;
public static final int BTN_BASE5 = 0x12a;
public static final int BTN_BASE6 = 0x12b;
public static final int BTN_DEAD = 0x12f;
public static final int BTN_GAMEPAD = 0x130;
public static final int BTN_A = 0x130;
public static final int BTN_B = 0x131;
public static final int BTN_C = 0x132;
public static final int BTN_X = 0x133;
public static final int BTN_Y = 0x134;
public static final int BTN_Z = 0x135;
public static final int BTN_TL = 0x136;
public static final int BTN_TR = 0x137;
public static final int BTN_TL2 = 0x138;
public static final int BTN_TR2 = 0x139;
public static final int BTN_SELECT = 0x13a;
public static final int BTN_START = 0x13b;
public static final int BTN_MODE = 0x13c;
public static final int BTN_THUMBL = 0x13d;
public static final int BTN_THUMBR = 0x13e;
public static final int BTN_DIGI = 0x140;
public static final int BTN_TOOL_PEN = 0x140;
public static final int BTN_TOOL_RUBBER = 0x141;
public static final int BTN_TOOL_BRUSH = 0x142;
public static final int BTN_TOOL_PENCIL = 0x143;
public static final int BTN_TOOL_AIRBRUSH = 0x144;
public static final int BTN_TOOL_FINGER = 0x145;
public static final int BTN_TOOL_MOUSE = 0x146;
public static final int BTN_TOOL_LENS = 0x147;
public static final int BTN_TOOL_QUINTTAP = 0x148;
public static final int BTN_TOUCH = 0x14a;
public static final int BTN_STYLUS = 0x14b;
public static final int BTN_STYLUS2 = 0x14c;
public static final int BTN_TOOL_DOUBLETAP = 0x14d;
public static final int BTN_TOOL_TRIPLETAP = 0x14e;
public static final int BTN_TOOL_QUADTAP = 0x14f;
public static final int BTN_WHEEL = 0x150;
public static final int BTN_GEAR_DOWN = 0x150;
public static final int BTN_GEAR_UP = 0x151;
public static final int KEY_OK = 0x160;
public static final int KEY_SELECT = 0x161;
public static final int KEY_GOTO = 0x162;
public static final int KEY_CLEAR = 0x163;
public static final int KEY_POWER2 = 0x164;
public static final int KEY_OPTION = 0x165;
public static final int KEY_INFO = 0x166;
public static final int KEY_TIME = 0x167;
public static final int KEY_VENDOR = 0x168;
public static final int KEY_ARCHIVE = 0x169;
public static final int KEY_PROGRAM = 0x16a;
public static final int KEY_CHANNEL = 0x16b;
public static final int KEY_FAVORITES = 0x16c;
public static final int KEY_EPG = 0x16d;
public static final int KEY_PVR = 0x16e;
public static final int KEY_MHP = 0x16f;
public static final int KEY_LANGUAGE = 0x170;
public static final int KEY_TITLE = 0x171;
public static final int KEY_SUBTITLE = 0x172;
public static final int KEY_ANGLE = 0x173;
public static final int KEY_ZOOM = 0x174;
public static final int KEY_MODE = 0x175;
public static final int KEY_KEYBOARD = 0x176;
public static final int KEY_SCREEN = 0x177;
public static final int KEY_PC = 0x178;
public static final int KEY_TV = 0x179;
public static final int KEY_TV2 = 0x17a;
public static final int KEY_VCR = 0x17b;
public static final int KEY_VCR2 = 0x17c;
public static final int KEY_SAT = 0x17d;
public static final int KEY_SAT2 = 0x17e;
public static final int KEY_CD = 0x17f;
public static final int KEY_TAPE = 0x180;
public static final int KEY_RADIO = 0x181;
public static final int KEY_TUNER = 0x182;
public static final int KEY_PLAYER = 0x183;
public static final int KEY_TEXT = 0x184;
public static final int KEY_DVD = 0x185;
public static final int KEY_AUX = 0x186;
public static final int KEY_MP3 = 0x187;
public static final int KEY_AUDIO = 0x188;
public static final int KEY_VIDEO = 0x189;
public static final int KEY_DIRECTORY = 0x18a;
public static final int KEY_LIST = 0x18b;
public static final int KEY_MEMO = 0x18c;
public static final int KEY_CALENDAR = 0x18d;
public static final int KEY_RED = 0x18e;
public static final int KEY_GREEN = 0x18f;
public static final int KEY_YELLOW = 0x190;
public static final int KEY_BLUE = 0x191;
public static final int KEY_CHANNELUP = 0x192;
public static final int KEY_CHANNELDOWN = 0x193;
public static final int KEY_FIRST = 0x194;
public static final int KEY_LAST = 0x195;
public static final int KEY_AB = 0x196;
public static final int KEY_NEXT = 0x197;
public static final int KEY_RESTART = 0x198;
public static final int KEY_SLOW = 0x199;
public static final int KEY_SHUFFLE = 0x19a;
public static final int KEY_BREAK = 0x19b;
public static final int KEY_PREVIOUS = 0x19c;
public static final int KEY_DIGITS = 0x19d;
public static final int KEY_TEEN = 0x19e;
public static final int KEY_TWEN = 0x19f;
public static final int KEY_VIDEOPHONE = 0x1a0;
public static final int KEY_GAMES = 0x1a1;
public static final int KEY_ZOOMIN = 0x1a2;
public static final int KEY_ZOOMOUT = 0x1a3;
public static final int KEY_ZOOMRESET = 0x1a4;
public static final int KEY_WORDPROCESSOR = 0x1a5;
public static final int KEY_EDITOR = 0x1a6;
public static final int KEY_SPREADSHEET = 0x1a7;
public static final int KEY_GRAPHICSEDITOR = 0x1a8;
public static final int KEY_PRESENTATION = 0x1a9;
public static final int KEY_DATABASE = 0x1aa;
public static final int KEY_NEWS = 0x1ab;
public static final int KEY_VOICEMAIL = 0x1ac;
public static final int KEY_ADDRESSBOOK = 0x1ad;
public static final int KEY_MESSENGER = 0x1ae;
public static final int KEY_DISPLAYTOGGLE = 0x1af;
public static final int KEY_SPELLCHECK = 0x1b0;
public static final int KEY_LOGOFF = 0x1b1;
public static final int KEY_DOLLAR = 0x1b2;
public static final int KEY_EURO = 0x1b3;
public static final int KEY_FRAMEBACK = 0x1b4;
public static final int KEY_FRAMEFORWARD = 0x1b5;
public static final int KEY_CONTEXT_MENU = 0x1b6;
public static final int KEY_MEDIA_REPEAT = 0x1b7;
public static final int KEY_10CHANNELSUP = 0x1b8;
public static final int KEY_10CHANNELSDOWN = 0x1b9;
public static final int KEY_IMAGES = 0x1ba;
public static final int KEY_DEL_EOL = 0x1c0;
public static final int KEY_DEL_EOS = 0x1c1;
public static final int KEY_INS_LINE = 0x1c2;
public static final int KEY_DEL_LINE = 0x1c3;
public static final int KEY_FN = 0x1d0;
public static final int KEY_FN_ESC = 0x1d1;
public static final int KEY_FN_F1 = 0x1d2;
public static final int KEY_FN_F2 = 0x1d3;
public static final int KEY_FN_F3 = 0x1d4;
public static final int KEY_FN_F4 = 0x1d5;
public static final int KEY_FN_F5 = 0x1d6;
public static final int KEY_FN_F6 = 0x1d7;
public static final int KEY_FN_F7 = 0x1d8;
public static final int KEY_FN_F8 = 0x1d9;
public static final int KEY_FN_F9 = 0x1da;
public static final int KEY_FN_F10 = 0x1db;
public static final int KEY_FN_F11 = 0x1dc;
public static final int KEY_FN_F12 = 0x1dd;
public static final int KEY_FN_1 = 0x1de;
public static final int KEY_FN_2 = 0x1df;
public static final int KEY_FN_D = 0x1e0;
public static final int KEY_FN_E = 0x1e1;
public static final int KEY_FN_F = 0x1e2;
public static final int KEY_FN_S = 0x1e3;
public static final int KEY_FN_B = 0x1e4;
public static final int KEY_BRL_DOT1 = 0x1f1;
public static final int KEY_BRL_DOT2 = 0x1f2;
public static final int KEY_BRL_DOT3 = 0x1f3;
public static final int KEY_BRL_DOT4 = 0x1f4;
public static final int KEY_BRL_DOT5 = 0x1f5;
public static final int KEY_BRL_DOT6 = 0x1f6;
public static final int KEY_BRL_DOT7 = 0x1f7;
public static final int KEY_BRL_DOT8 = 0x1f8;
public static final int KEY_BRL_DOT9 = 0x1f9;
public static final int KEY_BRL_DOT10 = 0x1fa;
public static final int KEY_NUMERIC_0 = 0x200;
public static final int KEY_NUMERIC_1 = 0x201;
public static final int KEY_NUMERIC_2 = 0x202;
public static final int KEY_NUMERIC_3 = 0x203;
public static final int KEY_NUMERIC_4 = 0x204;
public static final int KEY_NUMERIC_5 = 0x205;
public static final int KEY_NUMERIC_6 = 0x206;
public static final int KEY_NUMERIC_7 = 0x207;
public static final int KEY_NUMERIC_8 = 0x208;
public static final int KEY_NUMERIC_9 = 0x209;
public static final int KEY_NUMERIC_STAR = 0x20a;
public static final int KEY_NUMERIC_POUND = 0x20b;
public static final int KEY_CAMERA_FOCUS = 0x210;
public static final int KEY_WPS_BUTTON = 0x211;
public static final int KEY_TOUCHPAD_TOGGLE = 0x212;
public static final int KEY_TOUCHPAD_ON = 0x213;
public static final int KEY_TOUCHPAD_OFF = 0x214;
public static final int KEY_CAMERA_ZOOMIN = 0x215;
public static final int KEY_CAMERA_ZOOMOUT = 0x216;
public static final int KEY_CAMERA_UP = 0x217;
public static final int KEY_CAMERA_DOWN = 0x218;
public static final int KEY_CAMERA_LEFT = 0x219;
public static final int KEY_CAMERA_RIGHT = 0x21a;
public static final int BTN_TRIGGER_HAPPY = 0x2c0;
public static final int BTN_TRIGGER_HAPPY1 = 0x2c0;
public static final int BTN_TRIGGER_HAPPY2 = 0x2c1;
public static final int BTN_TRIGGER_HAPPY3 = 0x2c2;
public static final int BTN_TRIGGER_HAPPY4 = 0x2c3;
public static final int BTN_TRIGGER_HAPPY5 = 0x2c4;
public static final int BTN_TRIGGER_HAPPY6 = 0x2c5;
public static final int BTN_TRIGGER_HAPPY7 = 0x2c6;
public static final int BTN_TRIGGER_HAPPY8 = 0x2c7;
public static final int BTN_TRIGGER_HAPPY9 = 0x2c8;
public static final int BTN_TRIGGER_HAPPY10 = 0x2c9;
public static final int BTN_TRIGGER_HAPPY11 = 0x2ca;
public static final int BTN_TRIGGER_HAPPY12 = 0x2cb;
public static final int BTN_TRIGGER_HAPPY13 = 0x2cc;
public static final int BTN_TRIGGER_HAPPY14 = 0x2cd;
public static final int BTN_TRIGGER_HAPPY15 = 0x2ce;
public static final int BTN_TRIGGER_HAPPY16 = 0x2cf;
public static final int BTN_TRIGGER_HAPPY17 = 0x2d0;
public static final int BTN_TRIGGER_HAPPY18 = 0x2d1;
public static final int BTN_TRIGGER_HAPPY19 = 0x2d2;
public static final int BTN_TRIGGER_HAPPY20 = 0x2d3;
public static final int BTN_TRIGGER_HAPPY21 = 0x2d4;
public static final int BTN_TRIGGER_HAPPY22 = 0x2d5;
public static final int BTN_TRIGGER_HAPPY23 = 0x2d6;
public static final int BTN_TRIGGER_HAPPY24 = 0x2d7;
public static final int BTN_TRIGGER_HAPPY25 = 0x2d8;
public static final int BTN_TRIGGER_HAPPY26 = 0x2d9;
public static final int BTN_TRIGGER_HAPPY27 = 0x2da;
public static final int BTN_TRIGGER_HAPPY28 = 0x2db;
public static final int BTN_TRIGGER_HAPPY29 = 0x2dc;
public static final int BTN_TRIGGER_HAPPY30 = 0x2dd;
public static final int BTN_TRIGGER_HAPPY31 = 0x2de;
public static final int BTN_TRIGGER_HAPPY32 = 0x2df;
public static final int BTN_TRIGGER_HAPPY33 = 0x2e0;
public static final int BTN_TRIGGER_HAPPY34 = 0x2e1;
public static final int BTN_TRIGGER_HAPPY35 = 0x2e2;
public static final int BTN_TRIGGER_HAPPY36 = 0x2e3;
public static final int BTN_TRIGGER_HAPPY37 = 0x2e4;
public static final int BTN_TRIGGER_HAPPY38 = 0x2e5;
public static final int BTN_TRIGGER_HAPPY39 = 0x2e6;
public static final int BTN_TRIGGER_HAPPY40 = 0x2e7;
public static final int KEY_MIN_INTERESTING = KEY_MUTE;
public static final int KEY_MAX = 0x2ff;
public static final int KEY_CNT = (KEY_MAX+1);
public static final int REL_X = 0x00;
public static final int REL_Y = 0x01;
public static final int REL_Z = 0x02;
public static final int REL_RX = 0x03;
public static final int REL_RY = 0x04;
public static final int REL_RZ = 0x05;
public static final int REL_HWHEEL = 0x06;
public static final int REL_DIAL = 0x07;
public static final int REL_WHEEL = 0x08;
public static final int REL_MISC = 0x09;
public static final int REL_MAX = 0x0f;
public static final int REL_CNT = (REL_MAX+1);
public static final int ABS_X = 0x00;
public static final int ABS_Y = 0x01;
public static final int ABS_Z = 0x02;
public static final int ABS_RX = 0x03;
public static final int ABS_RY = 0x04;
public static final int ABS_RZ = 0x05;
public static final int ABS_THROTTLE = 0x06;
public static final int ABS_RUDDER = 0x07;
public static final int ABS_WHEEL = 0x08;
public static final int ABS_GAS = 0x09;
public static final int ABS_BRAKE = 0x0a;
public static final int ABS_HAT0X = 0x10;
public static final int ABS_HAT0Y = 0x11;
public static final int ABS_HAT1X = 0x12;
public static final int ABS_HAT1Y = 0x13;
public static final int ABS_HAT2X = 0x14;
public static final int ABS_HAT2Y = 0x15;
public static final int ABS_HAT3X = 0x16;
public static final int ABS_HAT3Y = 0x17;
public static final int ABS_PRESSURE = 0x18;
public static final int ABS_DISTANCE = 0x19;
public static final int ABS_TILT_X = 0x1a;
public static final int ABS_TILT_Y = 0x1b;
public static final int ABS_TOOL_WIDTH = 0x1c;
public static final int ABS_VOLUME = 0x20;
public static final int ABS_MISC = 0x28;
public static final int ABS_MT_SLOT = 0x2f;
public static final int ABS_MT_TOUCH_MAJOR = 0x30;
public static final int ABS_MT_TOUCH_MINOR = 0x31;
public static final int ABS_MT_WIDTH_MAJOR = 0x32;
public static final int ABS_MT_WIDTH_MINOR = 0x33;
public static final int ABS_MT_ORIENTATION = 0x34;
public static final int ABS_MT_POSITION_X = 0x35;
public static final int ABS_MT_POSITION_Y = 0x36;
public static final int ABS_MT_TOOL_TYPE = 0x37;
public static final int ABS_MT_BLOB_ID = 0x38;
public static final int ABS_MT_TRACKING_ID = 0x39;
public static final int ABS_MT_PRESSURE = 0x3a;
public static final int ABS_MT_DISTANCE = 0x3b;
public static final int ABS_MT_FIRST = ABS_MT_TOUCH_MAJOR;
public static final int ABS_MT_LAST = ABS_MT_DISTANCE;
public static final int ABS_MAX = 0x3f;
public static final int ABS_CNT = (ABS_MAX+1);
public static final int BUS_PCI = 0x01;
public static final int BUS_ISAPNP = 0x02;
public static final int BUS_USB = 0x03;
public static final int BUS_HIL = 0x04;
public static final int BUS_BLUETOOTH = 0x05;
public static final int BUS_VIRTUAL = 0x06;
public static final int BUS_ISA = 0x10;
public static final int BUS_I8042 = 0x11;
public static final int BUS_XTKBD = 0x12;
public static final int BUS_RS232 = 0x13;
public static final int BUS_GAMEPORT = 0x14;
public static final int BUS_PARPORT = 0x15;
public static final int BUS_AMIGA = 0x16;
public static final int BUS_ADB = 0x17;
public static final int BUS_I2C = 0x18;
public static final int BUS_HOST = 0x19;
public static final int BUS_GSC = 0x1A;
public static final int BUS_ATARI = 0x1B;
public static final int BUS_SPI = 0x1C;
public static final int FF_STATUS_STOPPED = 0x00;
public static final int FF_STATUS_PLAYING = 0x01;
public static final int FF_STATUS_MAX = 0x01;
public static final int FF_RUMBLE = 0x50;
public static final int FF_PERIODIC = 0x51;
public static final int FF_CONSTANT = 0x52;
public static final int FF_SPRING = 0x53;
public static final int FF_FRICTION = 0x54;
public static final int FF_DAMPER = 0x55;
public static final int FF_INERTIA = 0x56;
public static final int FF_RAMP = 0x57;
public static final int FF_EFFECT_MIN = FF_RUMBLE;
public static final int FF_EFFECT_MAX = FF_RAMP;
public static final int FF_SQUARE = 0x58;
public static final int FF_TRIANGLE = 0x59;
public static final int FF_SINE = 0x5a;
public static final int FF_SAW_UP = 0x5b;
public static final int FF_SAW_DOWN = 0x5c;
public static final int FF_CUSTOM = 0x5d;
public static final int FF_WAVEFORM_MIN = FF_SQUARE;
public static final int FF_WAVEFORM_MAX = FF_CUSTOM;
public static final int FF_GAIN = 0x60;
public static final int FF_AUTOCENTER = 0x61;
public static final int FF_MAX = 0x7f;
public static final int FF_CNT = (FF_MAX+1);
public static final int USAGE_MOUSE = 0x00;
public static final int USAGE_JOYSTICK = 0x01;
public static final int USAGE_GAMEPAD = 0x02;
public static final int USAGE_KEYBOARD = 0x03;
public static final int USAGE_MAX = 0x0f;
}

Some files were not shown because too many files have changed in this diff Show more