2bam

GameInput info dump (only device info)

Feb 27th, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. package {
  2. import flash.display.Sprite;
  3. import flash.events.Event;
  4. import flash.events.GameInputEvent;
  5. import flash.text.TextField;
  6. import flash.text.TextFormat;
  7. import flash.ui.GameInput;
  8. import flash.ui.GameInputControl;
  9. import flash.ui.GameInputDevice;
  10. import flash.desktop.NativeApplication;
  11. import mx.core.FlexVersion;
  12. import mx.core.mx_internal;
  13. /**
  14. * ...
  15. * @author 2bam.com
  16. */
  17. public class Main extends Sprite {
  18.  
  19. private var _tf:TextField;
  20. private var _gi:GameInput;
  21. private var _myCount:int = 0;
  22.  
  23. private function onUnusable(ev:GameInputEvent):void {
  24. trace("DEVICE UNUSABLE ", ev.device, ev.device?ev.device.id:"", ev.device?ev.device.name:"");
  25. }
  26.  
  27. private function onAdd(ev:GameInputEvent):void {
  28. _myCount++;
  29. }
  30.  
  31. private function onRem(ev:GameInputEvent):void {
  32. _myCount--;
  33. }
  34.  
  35. private function onFrame(ev:Event):void {
  36. var s:String;
  37. s = "GameInput "+(GameInput.isSupported?"":"NOT")+" supported\n";
  38. s += "GameInput.numDevices = "+GameInput.numDevices+"\n";
  39. s += "_myCount = "+_myCount+"\n";
  40. for(var i:int = 0; i<GameInput.numDevices; i++) {
  41. var dev:GameInputDevice = GameInput.getDeviceAt(i);
  42. s += "======="+i+"=======\n";
  43. s += "\tname: "+dev.name+"\n";
  44. s += "\t id: "+dev.id+"\n";
  45. s += "\t#ctl: "+dev.numControls+"\n";
  46. dev.enabled = true;
  47.  
  48. }
  49.  
  50. _tf.text = s;
  51. }
  52.  
  53.  
  54. public function Main() {
  55. trace("AIR:" + NativeApplication.nativeApplication.runtimeVersion + " patch " + NativeApplication.nativeApplication.runtimePatchLevel);
  56. trace("FLEX: " + FlexVersion.compatibilityVersionString + " " + FlexVersion.CURRENT_VERSION.toString(16));
  57.  
  58. _tf = new TextField;
  59. _tf.multiline = true;
  60. _tf.wordWrap = true;
  61. _tf.defaultTextFormat = new TextFormat("Courier New", 16);
  62. //_tf.defaultTextFormat = new TextFormat("Courier New", 11);
  63. _tf.width = stage.stageWidth;
  64. _tf.height = stage.stageHeight;
  65. addChild(_tf);
  66. stage.addEventListener(Event.ENTER_FRAME, onFrame);
  67.  
  68. _gi = new GameInput;
  69. _gi.addEventListener(GameInputEvent.DEVICE_ADDED, onAdd,false,0,true);
  70. _gi.addEventListener(GameInputEvent.DEVICE_REMOVED, onRem,false,0,true);
  71. _gi.addEventListener(GameInputEvent.DEVICE_UNUSABLE, onUnusable,false,0,true);
  72. }
  73.  
  74. }
  75.  
  76. }
Add Comment
Please, Sign In to add comment