Created
July 4, 2014 04:40
-
-
Save nanmo/9ca9fbcc366ffbcd2aaa to your computer and use it in GitHub Desktop.
UnityでKeyCodeから入力元デバイスを判定する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Unity - Scripting API: KeyCode http://docs.unity3d.com/ScriptReference/KeyCode.html | |
//Axis系はkeycodeから取得できない | |
//ちなみにintからKeyCodeにキャストは可能 | |
void detectInputDevice( KeyCode kc) { | |
int keycode = (int)kc; | |
if ( keycode == 0 ) { | |
//None | |
} | |
else if ( keycode >= 8 && keycode <= 319 ) { | |
//Keyboard (8=Backspace, 319=Menu) | |
//厳密には歯抜けになっているはず | |
} | |
else if ( keycode >= 323 && keycode <= 329 ) { | |
//Mouse Button 0-6 | |
} | |
else if ( keycode >= 330 && keycode <= 429 ) { | |
//Joystick Button | |
//ex:joystick 330-349, joystick1 350-369, joystick2 370-389, joystick3 390-409, joystick4 410-429 | |
} | |
else { | |
//Unknown | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment