stylet 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.travis.yml +4 -0
  4. data/.yardopts +2 -0
  5. data/Gemfile +16 -0
  6. data/README.org +19 -0
  7. data/Rakefile +17 -0
  8. data/bin/setup +63 -0
  9. data/bin/stylet +8 -0
  10. data/examples/.ruby-version +1 -0
  11. data/examples/00100_lib_hello_world.rb +8 -0
  12. data/examples/00110_lib_sge_check.rb +6 -0
  13. data/examples/00120_lib_/343/202/254/343/203/263/343/203/236/345/200/244/343/201/256/345/244/211/346/233/264.rb +22 -0
  14. data/examples/00130_lib_window_title.rb +8 -0
  15. data/examples/00140_lib_callbacks.rb +8 -0
  16. data/examples/00150_lib_vector.rb +5 -0
  17. data/examples/00160_lib_run.rb +4 -0
  18. data/examples/00170_lib_frame.rb +4 -0
  19. data/examples/00180_lib_config/347/242/272/350/252/215.rb +7 -0
  20. data/examples/00190_lib_/343/201/231/343/201/271/343/201/246/345/220/214/343/201/230/343/202/252/343/203/226/343/202/270/343/202/247/343/202/257/343/203/210.rb +10 -0
  21. data/examples/00200_lib_/343/203/254/343/202/267/343/203/274/343/203/220/343/203/274/343/202/222/347/234/201/347/225/245/343/201/231/343/202/213/346/226/271/346/263/225/343/201/256/343/203/206/343/202/271/343/203/210.rb +28 -0
  22. data/examples/00210_lib_delegators.rb +7 -0
  23. data/examples/00220_lib_template_method.rb +13 -0
  24. data/examples/00230_lib_/350/203/214/346/231/257/347/224/273/345/203/217/350/241/250/347/244/272.rb +9 -0
  25. data/examples/00240_lib_/350/203/214/346/231/257/347/224/273/345/203/217/343/202/222/346/232/227/343/201/2171_/351/273/222/343/201/256/344/270/212/343/201/253/350/203/214/346/231/257.rb +18 -0
  26. data/examples/00250_lib_/350/203/214/346/231/257/347/224/273/345/203/217/343/202/222/346/232/227/343/201/2172_/350/203/214/346/231/257/343/201/256/344/270/212/343/201/253/351/273/222.rb +17 -0
  27. data/examples/00260_lib_/350/203/214/346/231/257/347/224/273/345/203/217/343/202/222/346/232/227/343/201/2173_/350/203/214/346/231/257/343/201/256/344/270/212/343/201/253/351/273/222_/347/224/273/351/235/242/343/202/265/343/202/244/343/202/272/343/203/225/343/202/243/343/203/203/343/203/210_/351/207/215/343/201/204.rb +27 -0
  28. data/examples/00270_lib_/350/203/214/346/231/257/347/224/273/345/203/217/343/202/222/346/232/227/343/201/2173_/350/203/214/346/231/257/343/201/256/344/270/212/343/201/253/351/273/222_/347/224/273/351/235/242/343/202/265/343/202/244/343/202/272/343/203/225/343/202/243/343/203/203/343/203/210_/351/253/230/351/200/237/345/214/226.rb +44 -0
  29. data/examples/00280_lib_/347/211/271/345/256/232/343/201/256/343/202/250/343/203/252/343/202/242/343/201/240/343/201/221/345/276/220/343/200/205/343/201/253/346/266/210/343/201/231.rb +26 -0
  30. data/examples/00290_lib_/350/203/214/346/231/257/350/211/262/345/244/211/346/233/264.rb +5 -0
  31. data/examples/00300_lib_/343/202/255/343/203/243/343/203/251/343/202/257/343/202/277/347/224/273/345/203/217/343/202/222/350/241/250/347/244/272/343/201/231/343/202/213/344/276/213.rb +17 -0
  32. data/examples/00310_lib_/343/202/255/343/203/243/343/203/251/343/202/257/343/202/277/347/224/273/345/203/217/343/201/256/343/202/242/343/203/213/343/203/241/343/203/274/343/202/267/343/203/247/343/203/263.rb +18 -0
  33. data/examples/00320_lib_/343/202/255/343/203/243/343/203/251/343/202/257/343/202/277/346/213/241/345/244/247/347/270/256/345/260/217/345/233/236/350/273/242.rb +21 -0
  34. data/examples/00330_joystick.rb +5 -0
  35. data/examples/00340_joystick_PS3/343/202/242/343/203/212/343/203/255/343/202/260/343/203/254/343/203/220/343/203/274/343/201/256/345/213/225/343/201/215/343/201/214/345/206/205/351/203/250/343/201/247/343/201/257/345/233/233/350/247/222.rb +30 -0
  36. data/examples/00350_joystick_PS3/343/202/242/343/203/212/343/203/255/343/202/260/343/203/254/343/203/220/343/203/274/343/201/256/350/252/277/346/225/264/346/270/210/343/201/277/343/203/231/343/202/257/343/203/210/343/203/253.rb +12 -0
  37. data/examples/00360_lib_mouse.rb +5 -0
  38. data/examples/00370_lib_input.rb +29 -0
  39. data/examples/00380_lib_vputs_align.rb +8 -0
  40. data/examples/00390_/343/203/225/343/202/251/343/203/263/343/203/210/344/270/200/350/246/247.rb +15 -0
  41. data/examples/00400_lib_draw_circle.rb +8 -0
  42. data/examples/00410_SDL/343/201/256draw_rect/343/201/2571/343/203/224/343/202/257/343/202/273/343/203/253/344/275/231/345/210/206/343/201/253/346/217/217/347/224/273/343/201/225/343/202/214/343/202/213/343/201/256/343/201/247/346/263/250/346/204/217.rb +7 -0
  43. data/examples/00420_circle_on_circle.rb +10 -0
  44. data/examples/00430_rotate.rb +16 -0
  45. data/examples/00440_draw_triangle.rb +7 -0
  46. data/examples/00450_parabora_triangle.rb +37 -0
  47. data/examples/00460_ice_hockey.rb +88 -0
  48. data/examples/00470_collision_block_vs_block.rb +120 -0
  49. data/examples/00480_simple_circle_controll.rb +37 -0
  50. data/examples/00490_/347/255/211/351/200/237/347/247/273/345/213/225_uniform_velocity_rain.rb +51 -0
  51. data/examples/00500_/345/212/240/351/200/237/346/224/276/347/211/251/347/267/232_parabora_volcano.rb +94 -0
  52. data/examples/00510_3d.rb +53 -0
  53. data/examples/00520_/343/203/210/343/203/253/343/203/215/343/201/256/343/203/241/343/203/213/343/203/245/343/203/274/351/242/250/343/201/256/345/213/225/343/201/215.rb +77 -0
  54. data/examples/00530_curve_2/346/254/241/343/203/231/343/202/270/343/202/247/346/233/262/347/267/232/343/201/250/347/233/264/347/267/232/343/201/250/343/201/256/344/272/244/347/202/271.rb +43 -0
  55. data/examples/00540_curve_3/346/254/241/343/203/231/343/202/270/343/202/247/346/233/262/347/267/232.rb +40 -0
  56. data/examples/00550_curve_N/346/254/241/343/203/231/343/202/270/343/202/247/346/233/262/347/267/232.rb +92 -0
  57. data/examples/00560_curve_/343/202/271/343/203/227/343/203/251/343/202/244/343/203/263/346/233/262/347/267/232.rb +113 -0
  58. data/examples/00570_/345/206/206/351/201/213/345/213/225_circle_jet_coaster.rb +52 -0
  59. data/examples/00580_/345/206/206/343/202/222/346/212/274/343/201/231/343/201/262/343/201/243/343/201/261/343/202/213_collision_circle_vs_circle_push_or_pull.rb +56 -0
  60. data/examples/00590_/350/212/213/350/231/253/343/202/264/343/203/240/347/264/220/343/203/207/343/203/242_collision_demo_circle_worm.rb +104 -0
  61. data/examples/00600_/346/214/257/343/202/212/345/255/220_swing.rb +145 -0
  62. data/examples/00610_/345/206/205/347/251/215/343/201/250/345/244/226/347/251/215_inner_product.rb +36 -0
  63. data/examples/00620_/346/263/225/347/267/232/343/203/231/343/202/257/343/203/210/343/203/253.rb +23 -0
  64. data/examples/00630_/345/206/206/343/201/250/345/206/206/343/201/256/345/217/215/345/260/204_collision_reflect_circle_vs_circle.rb +222 -0
  65. data/examples/00640_/347/202/271/343/201/250/347/267/232/345/210/206/343/201/256/344/272/244/345/267/256/345/210/244/345/256/232_collision_ray_circle_vs_line.rb +261 -0
  66. data/examples/00650_/345/206/206/343/201/250/347/202/271/343/201/256/345/217/215/345/260/204_collision_circle_vs_dot.rb +36 -0
  67. data/examples/00660_/345/206/206/343/201/250/345/206/206/343/201/250/347/267/232/345/210/206/343/201/256/345/217/215/345/260/204/343/203/207/343/203/242_collision_demo.rb +305 -0
  68. data/examples/00670_/343/203/251/343/202/244/343/203/225/343/202/262/343/203/274/343/203/240.rb +86 -0
  69. data/examples/00680_2/347/202/271/343/202/222/351/200/232/343/202/213/347/233/264/347/267/232/343/201/256/346/226/271/347/250/213/345/274/217.rb +81 -0
  70. data/examples/00690_/343/203/222/343/203/253/343/203/231/343/203/253/343/203/210/346/233/262/347/267/232.rb +77 -0
  71. data/examples/00700_/343/202/263/343/203/203/343/203/233/346/233/262/347/267/232.rb +79 -0
  72. data/examples/00710_/343/202/267/343/202/260/343/203/242/343/202/244/343/203/211/346/233/262/347/267/232.rb +40 -0
  73. data/examples/00720_/343/202/267/343/203/200/346/244/215/347/211/251.rb +44 -0
  74. data/examples/00730_/343/202/257/343/203/252/343/203/225/343/202/251/343/203/274/343/203/211/343/202/242/343/203/210/343/203/251/343/202/257/343/202/277_/345/237/272/346/234/254.rb +29 -0
  75. data/examples/00740_/343/202/257/343/203/252/343/203/225/343/202/251/343/203/274/343/203/211/343/202/242/343/203/210/343/203/251/343/202/257/343/202/277_/346/224/271/350/211/257_/350/211/262/344/273/230/343/201/215.rb +68 -0
  76. data/examples/00750_/343/202/257/343/203/252/343/203/225/343/202/251/343/203/274/343/203/211/343/202/242/343/203/210/343/203/251/343/202/257/343/202/277_/343/203/211/343/203/274/343/203/212/343/203/204/345/236/213.rb +44 -0
  77. data/examples/00760_/347/201/253/350/212/261.rb +42 -0
  78. data/examples/00770_atan/343/201/247atan2/343/202/222/346/233/270/343/201/217.rb +26 -0
  79. data/examples/00780_/346/250/231/346/272/226/343/203/251/343/202/244/343/203/226/343/203/251/343/203/252/343/201/256atan2_sin_cos/343/202/222/344/275/277/343/201/206.rb +15 -0
  80. data/examples/00790_/350/247/222/345/272/246/343/201/250/343/203/251/343/202/270/343/202/242/343/203/263/343/201/256/347/233/270/344/272/222/345/244/211/346/217/233.rb +22 -0
  81. data/examples/00800_/347/220/203/343/201/214/347/233/264/347/267/232/347/232/204/343/201/253/345/213/225/343/201/204/343/201/246/343/201/204/343/202/213/343/201/240/343/201/221/343/201/247/345/233/236/350/273/242/343/201/227/343/201/246/343/201/204/343/202/213/343/202/210/343/201/206/343/201/253/350/246/213/343/201/210/343/202/213.rb +27 -0
  82. data/examples/00810_/343/202/267/343/203/237/343/203/245/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263_/350/273/212.rb +75 -0
  83. data/examples/00820_/343/202/267/343/203/237/343/203/245/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263_/346/210/246/350/273/212.rb +90 -0
  84. data/examples/00830_/350/247/222/345/272/246/345/267/256.rb +36 -0
  85. data/examples/00840_/346/224/276/347/211/251/347/267/232/343/201/247/347/213/231/346/222/203_/346/231/202/351/226/223/345/233/272/345/256/232.rb +61 -0
  86. data/examples/00850_/346/224/276/347/211/251/347/267/232/343/201/247/347/213/231/346/222/203_/350/247/222/345/272/246/345/233/272/345/256/232.rb +84 -0
  87. data/examples/00860_/346/224/276/347/211/251/347/267/232/343/201/247/347/213/231/346/222/203_/351/200/237/345/272/246/345/233/272/345/256/232.rb +66 -0
  88. data/examples/00870_/350/247/222/345/272/246/350/243/234/346/255/243_/345/212/240/351/200/237/343/203/237/343/202/265/343/202/244/343/203/253.rb +60 -0
  89. data/examples/00880_/345/210/235/351/200/237/343/201/214/351/200/237/343/201/204/343/203/237/343/202/265/343/202/244/343/203/253.rb +51 -0
  90. data/examples/00890_/346/255/243/350/246/217/344/271/261/346/225/260/343/201/250/346/250/231/346/272/226/345/201/217/345/267/256/343/201/256/345/217/257/350/246/226/345/214/226.rb +72 -0
  91. data/examples/00900_/345/220/221/345/277/203/345/212/233/343/201/247/345/233/236/350/273/242/343/200/220/350/247/222/345/272/2460/345/272/246/343/201/213/343/202/211/343/200/221.rb +23 -0
  92. data/examples/00910_/345/220/221/345/277/203/345/212/233/343/201/247/345/233/236/350/273/242/343/200/220/344/273/273/346/204/217/343/201/256/350/247/222/345/272/246/343/201/213/343/202/211/343/200/221.rb +33 -0
  93. data/examples/00920_/343/203/236/343/203/252/343/202/252/343/203/226/343/203/251/343/202/266/343/203/274/343/202/272/351/242/250/343/201/253/347/224/273/351/235/242/344/270/241/347/253/257/343/201/214/347/271/213/343/201/243/343/201/246/343/201/204/343/202/213/344/276/213.rb +29 -0
  94. data/examples/00930_/345/212/271/346/236/234/351/237/263.rb +17 -0
  95. data/examples/00940_/343/203/236/343/203/203/343/203/227/343/203/201/343/203/203/343/203/227/343/201/256/343/203/236/343/203/203/343/203/227/351/205/215/347/275/256.rb +71 -0
  96. data/examples/00950_/343/203/236/343/203/203/343/203/227/343/203/201/343/203/203/343/203/227/343/201/256/350/241/250/347/244/272/344/276/213.rb +28 -0
  97. data/examples/00960_/343/203/236/343/203/203/343/203/227/343/203/201/343/203/203/343/203/227/343/201/250/345/215/230/344/270/200/347/224/273/345/203/217/343/201/256/351/201/225/343/201/204/343/202/222/345/220/270/345/217/216/343/201/231/343/202/213/344/276/213.rb +47 -0
  98. data/examples/00970_observer_/343/201/235/343/201/2561_/347/233/264/346/216/245.rb +28 -0
  99. data/examples/00980_observer_/343/201/235/343/201/2562_/346/231/256/351/200/232/343/201/253Singleton/347/211/210.rb +30 -0
  100. data/examples/00990_observer_/343/201/235/343/201/2563_SimpleDelegator/347/211/210.rb +28 -0
  101. data/examples/01000_observer_/343/201/235/343/201/2564_/351/200/206/343/201/253/343/203/253/343/203/274/343/203/227/344/270/273/345/260/216.rb +28 -0
  102. data/examples/01010_observer_/343/201/235/343/201/2565_/343/201/204/343/202/215/343/202/223/343/201/252/346/211/200/343/201/213/343/202/211/345/221/274/343/202/223/343/201/247/343/201/204/343/202/213/343/201/221/343/201/251Singleton/343/201/252/343/201/256/343/201/247/345/256/211/345/205/250.rb +37 -0
  103. data/examples/01020_observer_/343/201/235/343/201/2566_/343/201/204/343/202/215/343/202/223/343/201/252/346/211/200/343/201/213/343/202/211/345/221/274/343/201/266/345/240/264/345/220/210callbacks/343/202/222/344/275/277/343/202/217/343/201/252/343/201/204/343/202/210/343/201/206/343/201/253.rb +30 -0
  104. data/examples/01030_observer_/343/201/235/343/201/2567_/343/202/250/343/203/225/343/202/247/343/202/257/343/203/210/343/202/277/343/202/271/343/202/257/343/202/222/345/233/236/343/201/231/344/276/213.rb +57 -0
  105. data/examples/01040_/343/203/236/343/202/246/343/202/271/343/201/256/344/275/215/347/275/256/343/201/253/343/203/224/343/202/257/343/202/273/343/203/253/343/202/222/346/211/223/343/201/244.rb +18 -0
  106. data/examples/01050_/343/203/224/343/202/257/343/202/273/343/203/253/345/205/250/344/275/223/343/202/222/346/233/270/343/201/215/350/276/274/343/202/200.rb +27 -0
  107. data/examples/01060_effect_/347/224/273/345/203/217/343/201/256/343/202/263/343/203/263/343/203/234/343/203/252/343/203/245/343/203/274/343/203/210/346/263/225/343/201/253/343/202/210/343/202/213/343/202/250/343/203/225/343/202/247/343/202/257/343/203/210/345/207/246/347/220/206.rb +116 -0
  108. data/examples/01070_effect_FF7/343/201/256/346/210/246/351/227/230/343/201/253/345/205/245/343/202/213/343/201/250/343/201/215/343/201/256/343/202/250/343/203/225/343/202/247/343/202/257/343/203/210.rb +33 -0
  109. data/examples/01080_effect_/350/203/214/346/231/257/343/202/222/347/267/251/343/201/217/346/266/210/343/201/227/343/201/246/343/201/204/343/201/217/343/201/250/343/202/271/343/203/240/343/203/274/343/202/272/343/201/253/343/201/252/343/202/213.rb +16 -0
  110. data/examples/01090_/347/224/273/345/203/217/343/201/256/343/202/257/343/203/255/343/202/271/343/203/225/343/202/247/343/203/274/343/203/211.rb +37 -0
  111. data/examples/01100_/343/202/271/343/202/257/343/203/252/343/203/274/343/203/263/346/203/205/345/240/261.rb +8 -0
  112. data/examples/01110_lib_contrib_menu.rb +19 -0
  113. data/examples/01120_/351/233/233/345/236/213_2P/345/257/276/346/210/246/351/242/250STG.rb +109 -0
  114. data/examples/01130_/351/233/233/345/236/213_/346/210/246/350/273/212/345/257/276/346/210/246.rb +396 -0
  115. data/examples/01140_/351/233/233/345/236/213_2P/345/257/276/346/210/246.rb +60 -0
  116. data/examples/01150_/351/233/233/345/236/213_/343/202/271/343/203/274/343/203/221/343/203/274/343/203/236/343/203/252/343/202/252/351/242/250/343/202/242/343/202/257/343/202/267/343/203/247/343/203/263.rb +1251 -0
  117. data/examples/01160_2D/343/202/242/343/203/225/343/202/243/343/203/263/345/244/211/346/217/233.rb +40 -0
  118. data/examples/01170_stackprof.rb +10 -0
  119. data/examples/01180_sdl_/343/202/242/343/203/253/343/203/225/343/202/241/343/203/226/343/203/254/343/203/263/343/203/207/343/202/243/343/203/263/343/202/260/343/201/247/351/207/215/343/201/255/345/220/210/343/201/233/345/241/227/343/202/212/346/275/260/343/201/227.rb +11 -0
  120. data/examples/01190_/343/203/221/343/203/274/343/203/206/343/202/243/343/202/257/343/203/253/345/220/214/345/243/253/343/201/247/344/270/255/345/244/256/343/201/253/345/220/221/343/201/213/343/201/206.rb +79 -0
  121. data/examples/01200_lib_OpenGL.rb +55 -0
  122. data/examples/bezier.rb +202 -0
  123. data/examples/cursor.rb +50 -0
  124. data/examples/helper.rb +38 -0
  125. data/examples/lifegame_patterns.rb +102 -0
  126. data/examples/movable_point.rb +64 -0
  127. data/examples/mtx33.rb +294 -0
  128. data/examples/setup.rb +5 -0
  129. data/examples/stage_infos.rb +1 -0
  130. data/examples/start.sh +2 -0
  131. data/examples/test_all.rb +5 -0
  132. data/examples/testgl.rb +228 -0
  133. data/examples/trash/__0060_shooting2.rb +37 -0
  134. data/examples/trash/__0090_collision_circle1.rb +50 -0
  135. data/examples/trash/__0125_circle_collision.rb +103 -0
  136. data/examples/trash/__0130_circle_collision2.rb +60 -0
  137. data/examples/trash/__0270_circle_cycle_shift.rb +29 -0
  138. data/examples/trash/__bullet_algos.rb +224 -0
  139. data/examples/trash/gunship.rb +39 -0
  140. data/examples//343/203/227/343/203/255/343/202/270/343/202/247/343/202/257/343/202/277/343/203/274/343/201/253/350/241/250/347/244/272/343/201/231/343/202/213/343/201/250/343/201/215.sh +2 -0
  141. data/lib/stylet.rb +1 -0
  142. data/lib/stylet/application_memory_record.rb +33 -0
  143. data/lib/stylet/audio.rb +455 -0
  144. data/lib/stylet/axis_support.rb +62 -0
  145. data/lib/stylet/base.rb +76 -0
  146. data/lib/stylet/callbacks.rb +62 -0
  147. data/lib/stylet/cli.rb +54 -0
  148. data/lib/stylet/collision_support.rb +56 -0
  149. data/lib/stylet/config.rb +39 -0
  150. data/lib/stylet/contrib/menu.rb +508 -0
  151. data/lib/stylet/contrib/shared_pad.rb +32 -0
  152. data/lib/stylet/contrib/sprity.rb +149 -0
  153. data/lib/stylet/core.rb +118 -0
  154. data/lib/stylet/cpu_stat.rb +58 -0
  155. data/lib/stylet/delegators.rb +54 -0
  156. data/lib/stylet/draw.rb +256 -0
  157. data/lib/stylet/draw_support/arrow.rb +56 -0
  158. data/lib/stylet/draw_support/circle.rb +63 -0
  159. data/lib/stylet/draw_support/polygon.rb +22 -0
  160. data/lib/stylet/font.rb +172 -0
  161. data/lib/stylet/fps_adjust.rb +23 -0
  162. data/lib/stylet/fps_stat.rb +41 -0
  163. data/lib/stylet/input.rb +8 -0
  164. data/lib/stylet/input/base.rb +105 -0
  165. data/lib/stylet/input/hardware_bindings.rb +65 -0
  166. data/lib/stylet/input/key_one.rb +162 -0
  167. data/lib/stylet/input/support.rb +72 -0
  168. data/lib/stylet/joystick.rb +31 -0
  169. data/lib/stylet/joystick_adapter.rb +130 -0
  170. data/lib/stylet/joystick_adapters/buffalo_snes_adapter.rb +47 -0
  171. data/lib/stylet/joystick_adapters/elecom_usb_pad_adapter.rb +30 -0
  172. data/lib/stylet/joystick_adapters/hori_rap_v3_sa_adapter.rb +46 -0
  173. data/lib/stylet/joystick_adapters/ps3_standard_adapter.rb +40 -0
  174. data/lib/stylet/joystick_adapters/unknown_adapter.rb +13 -0
  175. data/lib/stylet/keyboard.rb +15 -0
  176. data/lib/stylet/logger.rb +12 -0
  177. data/lib/stylet/mouse.rb +58 -0
  178. data/lib/stylet/palette.rb +17 -0
  179. data/lib/stylet/rect.rb +113 -0
  180. data/lib/stylet/shortcut.rb +8 -0
  181. data/lib/stylet/state.rb +87 -0
  182. data/lib/stylet/stylet.rb +44 -0
  183. data/lib/stylet/system_pause.rb +24 -0
  184. data/lib/stylet/version.rb +3 -0
  185. data/log/.gitkeep +0 -0
  186. data/stylet.gemspec +31 -0
  187. data/test/test_helper.rb +6 -0
  188. data/test/test_input_base.rb +12 -0
  189. data/test/test_input_key_one.rb +43 -0
  190. data/test/test_input_support.rb +47 -0
  191. data/test/test_sample.rb +13 -0
  192. data/test/test_state.rb +26 -0
  193. data/tips.org +16 -0
  194. metadata +391 -0
@@ -0,0 +1,65 @@
1
+ # ボタンのアサイン
2
+
3
+ module Stylet
4
+ module Input
5
+ module StandardKeybordBind
6
+ def key_bit_update_all(*args)
7
+ super if defined? super
8
+ @axis.up << SDL::Key.press?(SDL::Key::UP)
9
+ @axis.down << SDL::Key.press?(SDL::Key::DOWN)
10
+ @axis.left << SDL::Key.press?(SDL::Key::LEFT)
11
+ @axis.right << SDL::Key.press?(SDL::Key::RIGHT)
12
+ @button.btA << SDL::Key.press?(SDL::Key::Z)
13
+ @button.btB << SDL::Key.press?(SDL::Key::X)
14
+ @button.btC << SDL::Key.press?(SDL::Key::C)
15
+ @button.btD << SDL::Key.press?(SDL::Key::V)
16
+ end
17
+ end
18
+
19
+ module MouseButtonBind
20
+ def key_bit_update_all(*args)
21
+ super if defined? super
22
+ @button.btA << @mouse.button.a
23
+ @button.btB << @mouse.button.b
24
+ @button.btC << @mouse.button.c
25
+ end
26
+ end
27
+
28
+ module HjklKeyboardBind
29
+ def key_bit_update_all(*args)
30
+ super if defined? super
31
+ @axis.up << SDL::Key.press?(SDL::Key::K)
32
+ @axis.down << SDL::Key.press?(SDL::Key::J)
33
+ @axis.left << SDL::Key.press?(SDL::Key::H)
34
+ @axis.right << SDL::Key.press?(SDL::Key::L)
35
+ @button.btA << SDL::Key.press?(SDL::Key::U)
36
+ @button.btB << SDL::Key.press?(SDL::Key::I)
37
+ @button.btC << SDL::Key.press?(SDL::Key::O)
38
+ @button.btD << SDL::Key.press?(SDL::Key::P)
39
+ end
40
+ end
41
+
42
+ module JoystickBindMethod
43
+ def bit_update_by_joy(joy)
44
+ return unless joy
45
+ @axis.up << joy.lever_on?(:up)
46
+ @axis.down << joy.lever_on?(:down)
47
+ @axis.left << joy.lever_on?(:left)
48
+ @axis.right << joy.lever_on?(:right)
49
+ @button.btA << joy.button_on?(:btA)
50
+ @button.btB << joy.button_on?(:btB)
51
+ @button.btC << joy.button_on?(:btC)
52
+ @button.btD << joy.button_on?(:btD)
53
+ if @ext_button
54
+ @ext_button.btR1 << joy.button_on?(:btR1)
55
+ @ext_button.btR2 << joy.button_on?(:btR2)
56
+ @ext_button.btL1 << joy.button_on?(:btL1)
57
+ @ext_button.btL2 << joy.button_on?(:btL2)
58
+ @ext_button.btSelect << joy.button_on?(:btSelect)
59
+ @ext_button.btStart << joy.button_on?(:btStart)
60
+ @ext_button.btPS << joy.button_on?(:btPS)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,162 @@
1
+ #
2
+ # ボタン1つの押し下げ管理
3
+ #
4
+ module Stylet
5
+ module Input
6
+ #
7
+ # ボタン一つの情報を管理するクラス
8
+ #
9
+ # state をセットして update することでカウンタが更新される
10
+ #
11
+ class KeyOne
12
+ class << self
13
+ # キーリピート2としたときの挙動
14
+ # 3フレーム目に押された場合
15
+ #
16
+ # 1 2 3 4 5 6 7 (Frames)
17
+ # counter 0 0 1 2 3 4 5
18
+ # repeat 0 0 1 0 0 2 3
19
+ # ^ ^ の数(1と2の間がの数)が key_repeat_first_delay 値
20
+ #
21
+ def repeat(counter, key_repeat_first_delay)
22
+ case
23
+ when counter == 1
24
+ 1
25
+ when counter > key_repeat_first_delay + 1
26
+ counter - key_repeat_first_delay
27
+ else
28
+ 0
29
+ end
30
+ end
31
+ end
32
+
33
+ attr_accessor :name, :match_chars, :store_char, :index
34
+ attr_accessor :state
35
+ attr_reader :counter, :free_counter
36
+
37
+ def initialize(name:, match_chars: nil, store_char: nil, index: nil)
38
+ @name = name
39
+ @match_chars = match_chars
40
+ @store_char = store_char
41
+ @index = index
42
+
43
+ @counter = 0
44
+ @free_counter = 0
45
+ @state = false
46
+ end
47
+
48
+ # 直近フラグを設定。falseにはできない。
49
+ #
50
+ # フラグが有効になる条件が複数ある場合に使うと便利
51
+ #
52
+ # 有効になるもの
53
+ # obj << "A" # 同じマーク
54
+ # obj << 1
55
+ # obj << true
56
+ #
57
+ def <<(value)
58
+ case value
59
+ when String
60
+ if @match_chars
61
+ value = @match_chars.chars.any? {|m| value.include?(m) }
62
+ else
63
+ value = nil
64
+ end
65
+ when Integer
66
+ value = (value & _bit_value).nonzero?
67
+ end
68
+ @state |= value
69
+ end
70
+
71
+ # 更新する前のon/off状態を取得(廃止予定)
72
+ def state_to_s
73
+ @state ? @store_char : ""
74
+ end
75
+
76
+ # @state の状態を @counter に反映する
77
+ # 引数が指定されていればそれを直近の状態に設定して更新する
78
+ def counter_update(state = nil)
79
+ if state
80
+ self << state
81
+ end
82
+ if @state
83
+ @counter += 1
84
+ @free_counter = 0
85
+ else
86
+ @counter = 0
87
+ @free_counter += 1
88
+ end
89
+ @state = false
90
+ end
91
+
92
+ def repeat(key_repeat_first_delay = 12)
93
+ self.class.repeat(@counter, key_repeat_first_delay)
94
+ end
95
+
96
+ # 押してない?
97
+ def free?
98
+ @counter == 0
99
+ end
100
+
101
+ # 押している?
102
+ def press?
103
+ @counter >= 1
104
+ end
105
+
106
+ # 押した瞬間?
107
+ def trigger?
108
+ @counter == 1
109
+ end
110
+
111
+ # 離した瞬間?
112
+ def free_trigger?
113
+ @free_counter == 1
114
+ end
115
+
116
+ # 押していないとき 0.0 で押している間は 1.0 を返す
117
+ def repeat_0or1
118
+ if repeat >= 1
119
+ 1.0
120
+ else
121
+ 0.0
122
+ end
123
+ end
124
+
125
+ def inspect
126
+ "#{self}#{@counter}"
127
+ end
128
+
129
+ def to_s2
130
+ if press?
131
+ @store_char
132
+ end
133
+ end
134
+
135
+ def press_bit_value
136
+ if press?
137
+ _bit_value
138
+ else
139
+ 0
140
+ end
141
+ end
142
+
143
+ begin
144
+ private
145
+ def _bit_value
146
+ 1 << @index
147
+ end
148
+ end
149
+ end
150
+ end
151
+ end
152
+
153
+ if $0 == __FILE__
154
+ key_one = Stylet::Input::KeyOne.new("A")
155
+ key_one.update("A")
156
+ p key_one.state_to_s
157
+ p key_one.press?
158
+ p key_one.trigger?
159
+ p key_one.free?
160
+ p key_one.free_trigger?
161
+ p key_one.to_s
162
+ end
@@ -0,0 +1,72 @@
1
+ #
2
+ # ボタン同士の優先順位を得るユーティリティ
3
+ #
4
+ module Stylet
5
+ module Input
6
+ # FIXME: KeyOneの特異メソッドとした方が自然かもしれない。ただ KeyOne という名前がよくない
7
+ module Support
8
+ extend self
9
+
10
+ # 2つのキーの優先順位を得る
11
+ #
12
+ # a = KeyOne.new
13
+ # b = KeyOne.new
14
+ #
15
+ # 1フレーム目。aだけ押されたのでaが返る
16
+ # a.update(true)
17
+ # b.update(false)
18
+ # Input::Support.preference_key(a, b) #=> a
19
+ #
20
+ # 2フレーム目。aは押しっぱなしだが、bの方が若いのでbが返る
21
+ # a.update(true)
22
+ # b.update(true)
23
+ # Input::Support.preference_key(a, b) #=> b
24
+ #
25
+ # 3つ以上のキーで比較する場合の麗
26
+ # list.sort_by{|e|(e.counter.zero? ? Float::INFINITY : e.counter)}.first
27
+ #
28
+ def preference_key(lhv, rhv, if_collision: lhv)
29
+ case
30
+ when rhv.press? && lhv.press?
31
+ case
32
+ when rhv.counter < lhv.counter
33
+ rhv
34
+ when lhv.counter < rhv.counter
35
+ lhv
36
+ else
37
+ if_collision
38
+ end
39
+ when rhv.press?
40
+ rhv
41
+ when lhv.press?
42
+ lhv
43
+ else
44
+ nil
45
+ end
46
+ end
47
+
48
+ # 3つ以上のキーの優先順位を得る
49
+ def preference_keys(list)
50
+ if v = list.sort_by {|e| (e.counter.zero? ? Float::INFINITY : e.counter) }.first
51
+ if v.press?
52
+ v
53
+ end
54
+ end
55
+ end
56
+
57
+ # 2つのキーのどちらかの溜めが完了しているか?(次の状態から使えるか?)
58
+ #
59
+ # 1 2 3 4 5 6 Frames
60
+ # lhv 0 0 0 0 0 0
61
+ # rhv 1 0 0 2 3 4
62
+ #
63
+ # 3フレーム目で key_power_effective?(lhv, rhv, 2) #=> true になる
64
+ #
65
+ def key_power_effective?(lhv, rhv, power_delay)
66
+ if key = preference_key(lhv, rhv)
67
+ key.repeat(power_delay - 1) > 1
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,31 @@
1
+ require_relative "joystick_adapter"
2
+
3
+ module Stylet
4
+ module Joystick
5
+ attr_reader :joys
6
+
7
+ def run_initializers
8
+ super
9
+ init_on(:joystick) do
10
+ if SDL.inited_system(SDL::INIT_JOYSTICK).zero?
11
+ SDL.initSubSystem(SDL::INIT_JOYSTICK)
12
+ logger.debug "SDL::Joystick.num: #{SDL::Joystick.num}" if logger
13
+ @joys = SDL::Joystick.num.times.collect do |i|
14
+ JoystickAdapter.create(SDL::Joystick.open(i))
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ def polling
21
+ super
22
+ SDL::Joystick.update_all
23
+ end
24
+
25
+ def before_update
26
+ super
27
+ return if Stylet.production
28
+ @joys.each {|joy| vputs(joy.inspect) }
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,130 @@
1
+ require 'active_support/core_ext/module/delegation'
2
+ require "active_support/core_ext/class/attribute_accessors"
3
+ require "active_support/core_ext/string/inflections"
4
+
5
+ module Stylet
6
+ class JoystickAdapter
7
+ cattr_accessor :adapter_assigns do
8
+ {
9
+ "PLAYSTATION(R)3 Controller" => :ps3_standard, # 純正
10
+ "PS(R) Gamepad" => :ps3_standard, # 純正風ぱちもん
11
+ "USB Gamepad" => :elecom_usb_pad, # ELECOM ゲームパッド JC-U2410TBK http://www.amazon.co.jp/dp/B000FO600A
12
+ "REAL ARCADE Pro.V3" => :hori_rap_v3_sa, # リアルアーケードPro.V3 SA(PS3用) http://www.amazon.co.jp/dp/B002YT9PSI
13
+ "USB,2-axis 8-button gamepad" => :buffalo_snes, # iBUFFALO USBゲームパッド 8ボタン スーパーファミコン風 http://www.amazon.co.jp/dp/B002B9XB0E
14
+ }
15
+ end
16
+
17
+ def self.create(object)
18
+ name = SDL::Joystick.index_name(object.index).strip
19
+ key = adapter_assigns[name] || :ps3_standard
20
+ adapter = "#{key}_adapter"
21
+ require_relative "joystick_adapters/#{adapter}"
22
+ Stylet.logger.info [object.index, name, adapter].inspect if Stylet.logger
23
+ "stylet/joystick_adapters/#{adapter}".classify.constantize.new(object)
24
+ end
25
+
26
+ attr_reader :object
27
+
28
+ delegate :axis, :button, :to => :object
29
+
30
+ def initialize(object)
31
+ @object = object
32
+ end
33
+
34
+ # 抽象シリーズ
35
+ begin
36
+ def lever_on?(dir)
37
+ if i = lever_button_assigns[dir]
38
+ button(i)
39
+ end
40
+ end
41
+
42
+ def button_on?(key)
43
+ if i = button_assigns[key]
44
+ button(i)
45
+ end
46
+ end
47
+
48
+ def available_analog_levers
49
+ {}
50
+ end
51
+
52
+ def adjusted_axes
53
+ [:up, :down, :right, :left].collect { |dir|
54
+ if lever_on?(dir)
55
+ dir.to_s.slice(/^(.)/).upcase
56
+ end
57
+ }.compact
58
+ end
59
+
60
+ def adjusted_buttons
61
+ button_assigns.keys.collect {|key|
62
+ if button_on?(key)
63
+ key.to_s.sub("bt", "").upcase
64
+ end
65
+ }.compact
66
+ end
67
+ end
68
+
69
+ # ハードウェアの値をそのまま返すシリーズ
70
+ begin
71
+ def name
72
+ SDL::Joystick.index_name(@object.index)
73
+ end
74
+
75
+ def raw_active_button_numbers
76
+ @object.num_buttons.times.collect {|i|
77
+ if @object.button(i)
78
+ i
79
+ end
80
+ }.compact
81
+ end
82
+
83
+ def raw_analog_lever_status
84
+ @object.num_axes.times.collect {|i| @object.axis(i) }
85
+ end
86
+ end
87
+
88
+ def inspect
89
+ "#{@object.index}: #{unit_str}"
90
+ end
91
+
92
+ def unit_str
93
+ [
94
+ adjusted_axes.join,
95
+ adjusted_buttons.join,
96
+ raw_active_button_numbers,
97
+ # available_analog_levers.values,
98
+ raw_analog_lever_status,
99
+ ].collect(&:to_s).join
100
+ end
101
+
102
+ ANALOG_LEVER_MAX = 32767
103
+ ANALOG_LEVER_MAGNITUDE_MAX = Math.sqrt(ANALOG_LEVER_MAX**2 + ANALOG_LEVER_MAX**2)
104
+
105
+ # 調整済みアナログレバー
106
+ def adjusted_analog_levers
107
+ available_analog_levers.inject({}) do |hash, (key, xy)|
108
+ v = vec2[*xy]
109
+ m = v.magnitude
110
+ if false
111
+ # 取得した値をそのまま使うと斜めのベクトルが強くなりすぎる
112
+ # たんなる方向を示したいときはこれで問題ない
113
+ r = m.to_f / ANALOG_LEVER_MAGNITUDE_MAX
114
+ else
115
+ # 斜めのベクトルが強くなりすぎないように制限を加えた例
116
+ if m >= ANALOG_LEVER_MAX
117
+ m = ANALOG_LEVER_MAX
118
+ end
119
+ r = m.to_f / ANALOG_LEVER_MAX
120
+ end
121
+ hash.merge(key => v.normalize * r)
122
+ end
123
+ end
124
+ end
125
+ end
126
+
127
+ if $0 == __FILE__
128
+ require_relative "../stylet"
129
+ Stylet.run
130
+ end