common.bmx 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. SuperStrict
  2. Import "glue.c"
  3. Extern
  4. Function _nxlinkStdio:Int()="int nxlinkStdio()!"
  5. Function bmx_nx_socketInitializeDefault:Int()
  6. Function socketGetDefaultInitConfig:Byte Ptr()
  7. Function socketInitialize(config:Byte Ptr)
  8. Function socketGetLastBsdResult:Int()
  9. Function socketGetLastSfdnsresResult:Int()
  10. Function socketExit()
  11. Function bmx_nx_romfsInit:Int()
  12. Function gfxInitDefault()
  13. Function gfxFlushBuffers()
  14. Function gfxSwapBuffers()
  15. Function gfxWaitForVsync()
  16. Function gfxExit()
  17. Function gfxGetFramebuffer:Int Ptr(width:Int Var, height:Int Var)
  18. Function consoleInit(handle:Byte Ptr)
  19. Function appletMainLoop:Int()
  20. Function hidScanInput()
  21. Function hidTouchCount:Int()
  22. Function hidTouchRead(pos:NxTouchPosition Var, pointId:Int)
  23. Function hidKeysDown:ULong(index:Int)
  24. End Extern
  25. Struct NxTouchPosition
  26. Field px:Int
  27. Field py:Int
  28. Field dx:Int
  29. Field dy:Int
  30. Field angle:Int
  31. End Struct
  32. Struct NxJoystickPosition
  33. Field dx:Int
  34. Field dy:Int
  35. End Struct
  36. Struct NxMousePosition
  37. Field x:Int
  38. Field y:Int
  39. Field velocityX:Int
  40. Field velocityY:Int
  41. Field scrollVelocityX:Int
  42. Field scrollVelocityY:Int
  43. End Struct
  44. Const CONTROLLER_PLAYER_1:Int = 0
  45. Const CONTROLLER_PLAYER_2:Int = 1
  46. Const CONTROLLER_PLAYER_3:Int = 2
  47. Const CONTROLLER_PLAYER_4:Int = 3
  48. Const CONTROLLER_PLAYER_5:Int = 4
  49. Const CONTROLLER_PLAYER_6:Int = 5
  50. Const CONTROLLER_PLAYER_7:Int = 6
  51. Const CONTROLLER_PLAYER_8:Int = 7
  52. Const CONTROLLER_HANDHELD:Int = 8
  53. Const CONTROLLER_UNKNOWN:Int = 9
  54. Const CONTROLLER_P1_AUTO:Int = 10
  55. Const KEY_A:Int = 1 Shl 0 ' A
  56. Const KEY_B:Int = 1 Shl 1 ' B
  57. Const KEY_X:Int = 1 Shl 2 ' X
  58. Const KEY_Y:Int = 1 Shl 3 ' Y
  59. Const KEY_LSTICK:Int = 1 Shl 4 ' Left Stick Button
  60. Const KEY_RSTICK:Int = 1 Shl 5 ' Right Stick Button
  61. Const KEY_L:Int = 1 Shl 6 ' L
  62. Const KEY_R:Int = 1 Shl 7 ' R
  63. Const KEY_ZL:Int = 1 Shl 8 ' ZL
  64. Const KEY_ZR:Int = 1 Shl 9 ' ZR
  65. Const KEY_PLUS:Int = 1 Shl 10 ' Plus
  66. Const KEY_MINUS:Int = 1 Shl 11 ' Minus
  67. Const KEY_DLEFT:Int = 1 Shl 12 ' D-Pad Left
  68. Const KEY_DUP:Int = 1 Shl 13 ' D-Pad Up
  69. Const KEY_DRIGHT:Int = 1 Shl 14 ' D-Pad Right
  70. Const KEY_DDOWN:Int = 1 Shl 15 ' D-Pad Down
  71. Const KEY_LSTICK_LEFT:Int = 1 Shl 16 ' Left Stick Left
  72. Const KEY_LSTICK_UP:Int = 1 Shl 17 ' Left Stick Up
  73. Const KEY_LSTICK_RIGHT:Int = 1 Shl 18 ' Left Stick Right
  74. Const KEY_LSTICK_DOWN:Int = 1 Shl 19 ' Left Stick Down
  75. Const KEY_RSTICK_LEFT:Int = 1 Shl 20 ' Right Stick Left
  76. Const KEY_RSTICK_UP:Int = 1 Shl 21 ' Right Stick Up
  77. Const KEY_RSTICK_RIGHT:Int = 1 Shl 22 ' Right Stick Right
  78. Const KEY_RSTICK_DOWN:Int = 1 Shl 23 ' Right Stick Down
  79. Const KEY_SL:Int = 1 Shl 24 ' SL
  80. Const KEY_SR:Int = 1 Shl 25 ' SR
  81. ' Pseudo-key for at least one finger on the touch screen
  82. Const KEY_TOUCH:Int = 1 Shl 26
  83. ' Buttons by orientation (for single Joy-Con), also works with Joy-Con pairs, Pro Controller
  84. Const KEY_JOYCON_RIGHT:Int = 1 Shl 0
  85. Const KEY_JOYCON_DOWN:Int = 1 Shl 1
  86. Const KEY_JOYCON_UP:Int = 1 Shl 2
  87. Const KEY_JOYCON_LEFT:Int = 1 Shl 3
  88. ' Generic catch-all directions, also works for single Joy-Con
  89. Const KEY_UP:Int = KEY_DUP | KEY_LSTICK_UP | KEY_RSTICK_UP ' D-Pad Up or Sticks Up
  90. Const KEY_DOWN:Int = KEY_DDOWN | KEY_LSTICK_DOWN | KEY_RSTICK_DOWN ' D-Pad Down or Sticks Down
  91. Const KEY_LEFT:Int = KEY_DLEFT | KEY_LSTICK_LEFT | KEY_RSTICK_LEFT ' D-Pad Left or Sticks Left
  92. Const KEY_RIGHT:Int = KEY_DRIGHT | KEY_LSTICK_RIGHT | KEY_RSTICK_RIGHT ' D-Pad Right or Sticks Right
  93. Const TYPE_PROCONTROLLER:Int = 1 Shl 0
  94. Const TYPE_HANDHELD:Int = 1 Shl 1
  95. Const TYPE_JOYCON_PAIR:Int = 1 Shl 2
  96. Const TYPE_JOYCON_LEFT:Int = 1 Shl 3
  97. Const TYPE_JOYCON_RIGHT:Int = 1 Shl 4
  98. Const KBD_NONE:Int = $00
  99. Const KBD_ERR_OVF:Int = $01
  100. Const KBD_A:Int = $04
  101. Const KBD_B:Int = $05
  102. Const KBD_C:Int = $06
  103. Const KBD_D:Int = $07
  104. Const KBD_E:Int = $08
  105. Const KBD_F:Int = $09
  106. Const KBD_G:Int = $0a
  107. Const KBD_H:Int = $0b
  108. Const KBD_I:Int = $0c
  109. Const KBD_J:Int = $0d
  110. Const KBD_K:Int = $0e
  111. Const KBD_L:Int = $0f
  112. Const KBD_M:Int = $10
  113. Const KBD_N:Int = $11
  114. Const KBD_O:Int = $12
  115. Const KBD_P:Int = $13
  116. Const KBD_Q:Int = $14
  117. Const KBD_R:Int = $15
  118. Const KBD_S:Int = $16
  119. Const KBD_T:Int = $17
  120. Const KBD_U:Int = $18
  121. Const KBD_V:Int = $19
  122. Const KBD_W:Int = $1a
  123. Const KBD_X:Int = $1b
  124. Const KBD_Y:Int = $1c
  125. Const KBD_Z:Int = $1d
  126. Const KBD_1:Int = $1e
  127. Const KBD_2:Int = $1f
  128. Const KBD_3:Int = $20
  129. Const KBD_4:Int = $21
  130. Const KBD_5:Int = $22
  131. Const KBD_6:Int = $23
  132. Const KBD_7:Int = $24
  133. Const KBD_8:Int = $25
  134. Const KBD_9:Int = $26
  135. Const KBD_0:Int = $27
  136. Const KBD_ENTER:Int = $28
  137. Const KBD_ESC:Int = $29
  138. Const KBD_BACKSPACE:Int = $2a
  139. Const KBD_TAB:Int = $2b
  140. Const KBD_SPACE:Int = $2c
  141. Const KBD_MINUS:Int = $2d
  142. Const KBD_EQUAL:Int = $2e
  143. Const KBD_LEFTBRACE:Int = $2f
  144. Const KBD_RIGHTBRACE:Int = $30
  145. Const KBD_BACKSLASH:Int = $31
  146. Const KBD_HASHTILDE:Int = $32
  147. Const KBD_SEMICOLON:Int = $33
  148. Const KBD_APOSTROPHE:Int = $34
  149. Const KBD_GRAVE:Int = $35
  150. Const KBD_COMMA:Int = $36
  151. Const KBD_DOT:Int = $37
  152. Const KBD_SLASH:Int = $38
  153. Const KBD_CAPSLOCK:Int = $39
  154. Const KBD_F1:Int = $3a
  155. Const KBD_F2:Int = $3b
  156. Const KBD_F3:Int = $3c
  157. Const KBD_F4:Int = $3d
  158. Const KBD_F5:Int = $3e
  159. Const KBD_F6:Int = $3f
  160. Const KBD_F7:Int = $40
  161. Const KBD_F8:Int = $41
  162. Const KBD_F9:Int = $42
  163. Const KBD_F10:Int = $43
  164. Const KBD_F11:Int = $44
  165. Const KBD_F12:Int = $45
  166. Const KBD_SYSRQ:Int = $46
  167. Const KBD_SCROLLLOCK:Int = $47
  168. Const KBD_PAUSE:Int = $48
  169. Const KBD_INSERT:Int = $49
  170. Const KBD_HOME:Int = $4a
  171. Const KBD_PAGEUP:Int = $4b
  172. Const KBD_DELETE:Int = $4c
  173. Const KBD_END:Int = $4d
  174. Const KBD_PAGEDOWN:Int = $4e
  175. Const KBD_RIGHT:Int = $4f
  176. Const KBD_LEFT:Int = $50
  177. Const KBD_DOWN:Int = $51
  178. Const KBD_UP:Int = $52
  179. Const KBD_NUMLOCK:Int = $53
  180. Const KBD_KPSLASH:Int = $54
  181. Const KBD_KPASTERISK:Int = $55
  182. Const KBD_KPMINUS:Int = $56
  183. Const KBD_KPPLUS:Int = $57
  184. Const KBD_KPENTER:Int = $58
  185. Const KBD_KP1:Int = $59
  186. Const KBD_KP2:Int = $5a
  187. Const KBD_KP3:Int = $5b
  188. Const KBD_KP4:Int = $5c
  189. Const KBD_KP5:Int = $5d
  190. Const KBD_KP6:Int = $5e
  191. Const KBD_KP7:Int = $5f
  192. Const KBD_KP8:Int = $60
  193. Const KBD_KP9:Int = $61
  194. Const KBD_KP0:Int = $62
  195. Const KBD_KPDOT:Int = $63
  196. Const KBD_102ND:Int = $64
  197. Const KBD_COMPOSE:Int = $65
  198. Const KBD_POWER:Int = $66
  199. Const KBD_KPEQUAL:Int = $67
  200. Const KBD_F13:Int = $68
  201. Const KBD_F14:Int = $69
  202. Const KBD_F15:Int = $6a
  203. Const KBD_F16:Int = $6b
  204. Const KBD_F17:Int = $6c
  205. Const KBD_F18:Int = $6d
  206. Const KBD_F19:Int = $6e
  207. Const KBD_F20:Int = $6f
  208. Const KBD_F21:Int = $70
  209. Const KBD_F22:Int = $71
  210. Const KBD_F23:Int = $72
  211. Const KBD_F24:Int = $73
  212. Const KBD_OPEN:Int = $74
  213. Const KBD_HELP:Int = $75
  214. Const KBD_PROPS:Int = $76
  215. Const KBD_FRONT:Int = $77
  216. Const KBD_STOP:Int = $78
  217. Const KBD_AGAIN:Int = $79
  218. Const KBD_UNDO:Int = $7a
  219. Const KBD_CUT:Int = $7b
  220. Const KBD_COPY:Int = $7c
  221. Const KBD_PASTE:Int = $7d
  222. Const KBD_FIND:Int = $7e
  223. Const KBD_MUTE:Int = $7f
  224. Const KBD_VOLUMEUP:Int = $80
  225. Const KBD_VOLUMEDOWN:Int = $81
  226. Const KBD_CAPSLOCK_ACTIVE:Int = $82
  227. Const KBD_NUMLOCK_ACTIVE:Int = $83
  228. Const KBD_SCROLLLOCK_ACTIVE:Int = $84
  229. Const KBD_KPCOMMA:Int = $85
  230. Const KBD_KPLEFTPAREN:Int = $b6
  231. Const KBD_KPRIGHTPAREN:Int = $b7
  232. Const KBD_LEFTCTRL:Int = $e0
  233. Const KBD_LEFTSHIFT:Int = $e1
  234. Const KBD_LEFTALT:Int = $e2
  235. Const KBD_LEFTMETA:Int = $e3
  236. Const KBD_RIGHTCTRL:Int = $e4
  237. Const KBD_RIGHTSHIFT:Int = $e5
  238. Const KBD_RIGHTALT:Int = $e6
  239. Const KBD_RIGHTMETA:Int = $e7
  240. Const KBD_MEDIA_PLAYPAUSE:Int = $e8
  241. Const KBD_MEDIA_STOPCD:Int = $e9
  242. Const KBD_MEDIA_PREVIOUSSONG:Int = $ea
  243. Const KBD_MEDIA_NEXTSONG:Int = $eb
  244. Const KBD_MEDIA_EJECTCD:Int = $ec
  245. Const KBD_MEDIA_VOLUMEUP:Int = $ed
  246. Const KBD_MEDIA_VOLUMEDOWN:Int = $ee
  247. Const KBD_MEDIA_MUTE:Int = $ef
  248. Const KBD_MEDIA_WWW:Int = $f0
  249. Const KBD_MEDIA_BACK:Int = $f1
  250. Const KBD_MEDIA_FORWARD:Int = $f2
  251. Const KBD_MEDIA_STOP:Int = $f3
  252. Const KBD_MEDIA_FIND:Int = $f4
  253. Const KBD_MEDIA_SCROLLUP:Int = $f5
  254. Const KBD_MEDIA_SCROLLDOWN:Int = $f6
  255. Const KBD_MEDIA_EDIT:Int = $f7
  256. Const KBD_MEDIA_SLEEP:Int = $f8
  257. Const KBD_MEDIA_COFFEE:Int = $f9
  258. Const KBD_MEDIA_REFRESH:Int = $fa
  259. Const KBD_MEDIA_CALC:Int = $fb