• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Go で書き直した Ikemen


Commit MetaInfo

Révisiond11337cb87de5510c73e5c5fd8e68749cf87a38a (tree)
l'heure2018-12-16 19:53:53
Auteurneatunsou <sisiy4excite@gmai...>
Commiterneatunsou

Message de Log

ゲームパッドに暫定対応

Change Summary

Modification

--- a/script/options.lua
+++ b/script/options.lua
@@ -87,32 +87,32 @@ function options.f_keyDefault()
8787 config.KeyConfig[2].Buttons[11] = 'RSHIFT'
8888 config.KeyConfig[2].Buttons[12] = 'LEFTBRACKET'
8989 config.KeyConfig[2].Buttons[13] = 'RIGHTBRACKET'
90- config._comment.KeyConfig[1].Buttons[1] = '-7'
91- config._comment.KeyConfig[1].Buttons[2] = '-8'
92- config._comment.KeyConfig[1].Buttons[3] = '-5'
93- config._comment.KeyConfig[1].Buttons[4] = '-6'
94- config._comment.KeyConfig[1].Buttons[5] = '0'
95- config._comment.KeyConfig[1].Buttons[6] = '1'
96- config._comment.KeyConfig[1].Buttons[7] = '4'
97- config._comment.KeyConfig[1].Buttons[8] = '2'
98- config._comment.KeyConfig[1].Buttons[9] = '3'
99- config._comment.KeyConfig[1].Buttons[10] = '5'
100- config._comment.KeyConfig[1].Buttons[11] = '7'
101- config._comment.KeyConfig[1].Buttons[12] = '6'
102- config._comment.KeyConfig[1].Buttons[13] = '8'
103- config._comment.KeyConfig[2].Buttons[1] = '-7'
104- config._comment.KeyConfig[2].Buttons[2] = '-8'
105- config._comment.KeyConfig[2].Buttons[3] = '-5'
106- config._comment.KeyConfig[2].Buttons[4] = '-6'
107- config._comment.KeyConfig[2].Buttons[5] = '0'
108- config._comment.KeyConfig[2].Buttons[6] = '1'
109- config._comment.KeyConfig[2].Buttons[7] = '4'
110- config._comment.KeyConfig[2].Buttons[8] = '2'
111- config._comment.KeyConfig[2].Buttons[9] = '3'
112- config._comment.KeyConfig[2].Buttons[10] = '5'
113- config._comment.KeyConfig[2].Buttons[11] = '7'
114- config._comment.KeyConfig[2].Buttons[12] = '6'
115- config._comment.KeyConfig[2].Buttons[13] = '8'
90+ config.JoystickConfig[1].Buttons[1] = '-7'
91+ config.JoystickConfig[1].Buttons[2] = '-8'
92+ config.JoystickConfig[1].Buttons[3] = '-5'
93+ config.JoystickConfig[1].Buttons[4] = '-6'
94+ config.JoystickConfig[1].Buttons[5] = '0'
95+ config.JoystickConfig[1].Buttons[6] = '1'
96+ config.JoystickConfig[1].Buttons[7] = '4'
97+ config.JoystickConfig[1].Buttons[8] = '2'
98+ config.JoystickConfig[1].Buttons[9] = '3'
99+ config.JoystickConfig[1].Buttons[10] = '5'
100+ config.JoystickConfig[1].Buttons[11] = '7'
101+ config.JoystickConfig[1].Buttons[12] = '6'
102+ config.JoystickConfig[1].Buttons[13] = '8'
103+ config.JoystickConfig[2].Buttons[1] = '-7'
104+ config.JoystickConfig[2].Buttons[2] = '-8'
105+ config.JoystickConfig[2].Buttons[3] = '-5'
106+ config.JoystickConfig[2].Buttons[4] = '-6'
107+ config.JoystickConfig[2].Buttons[5] = '0'
108+ config.JoystickConfig[2].Buttons[6] = '1'
109+ config.JoystickConfig[2].Buttons[7] = '4'
110+ config.JoystickConfig[2].Buttons[8] = '2'
111+ config.JoystickConfig[2].Buttons[9] = '3'
112+ config.JoystickConfig[2].Buttons[10] = '5'
113+ config.JoystickConfig[2].Buttons[11] = '7'
114+ config.JoystickConfig[2].Buttons[12] = '6'
115+ config.JoystickConfig[2].Buttons[13] = '8'
116116 end
117117
118118 function options.f_menuCommon1(cursorPosY, moveTxt, item, t)
@@ -1049,7 +1049,7 @@ function options.f_keyCfg(playerNo, controller)
10491049 if controller == -1 then
10501050 t_keyCfg[i].vardisplay = config.KeyConfig[playerNo].Buttons[i]
10511051 else
1052- t_keyCfg[i].vardisplay = config._comment.KeyConfig[playerNo].Buttons[i]
1052+ t_keyCfg[i].vardisplay = config.JoystickConfig[playerNo].Buttons[i]
10531053 end
10541054 end
10551055 while true do
@@ -1072,7 +1072,7 @@ function options.f_keyCfg(playerNo, controller)
10721072 if controller == -1 then
10731073 config.KeyConfig[playerNo].Buttons[item] = key
10741074 else
1075- config._comment.KeyConfig[playerNo].Buttons[item] = key
1075+ config.JoystickConfig[playerNo].Buttons[item] = key
10761076 end
10771077 else
10781078 sndPlay(motif.files.snd_data, motif.option_info.cancel_snd[1], motif.option_info.cancel_snd[2])
--- a/src/input.go
+++ b/src/input.go
@@ -2,11 +2,12 @@ package main
22
33 import (
44 "encoding/binary"
5- "github.com/go-gl/glfw/v3.2/glfw"
65 "net"
76 "os"
87 "strings"
98 "time"
9+
10+ "github.com/go-gl/glfw/v3.2/glfw"
1011 )
1112
1213 type CommandKey byte
@@ -51,6 +52,8 @@ const (
5152 CK_y
5253 CK_z
5354 CK_s
55+ CK_v
56+ CK_w
5457 CK_na
5558 CK_nb
5659 CK_nc
@@ -58,7 +61,9 @@ const (
5861 CK_ny
5962 CK_nz
6063 CK_ns
61- CK_Last = CK_ns
64+ CK_nv
65+ CK_nw
66+ CK_Last = CK_nw
6267 )
6368
6469 type NetState int
@@ -311,6 +316,246 @@ func StringToKey(s string) glfw.Key {
311316 return glfw.KeyUnknown
312317 }
313318
319+func KeyToString(k glfw.Key) string {
320+ switch k {
321+ case glfw.KeyEnter:
322+ return "RETURN"
323+ case glfw.KeyEscape:
324+ return "ESCAPE"
325+ case glfw.KeyBackspace:
326+ return "BACKSPACE"
327+ case glfw.KeyTab:
328+ return "TAB"
329+ case glfw.KeySpace:
330+ return "SPACE"
331+ case glfw.KeyApostrophe:
332+ return "QUOTE"
333+ case glfw.KeyComma:
334+ return "COMMA"
335+ case glfw.KeyMinus:
336+ return "MINUS"
337+ case glfw.KeyPeriod:
338+ return "PERIOD"
339+ case glfw.KeySlash:
340+ return "SLASH"
341+ case glfw.Key0:
342+ return "0"
343+ case glfw.Key1:
344+ return "1"
345+ case glfw.Key2:
346+ return "2"
347+ case glfw.Key3:
348+ return "3"
349+ case glfw.Key4:
350+ return "4"
351+ case glfw.Key5:
352+ return "5"
353+ case glfw.Key6:
354+ return "6"
355+ case glfw.Key7:
356+ return "7"
357+ case glfw.Key8:
358+ return "8"
359+ case glfw.Key9:
360+ return "9"
361+ case glfw.KeySemicolon:
362+ return "SEMICOLON"
363+ case glfw.KeyEqual:
364+ return "EQUALS"
365+ case glfw.KeyLeftBracket:
366+ return "LEFTBRACKET"
367+ case glfw.KeyBackslash:
368+ return "BACKSLASH"
369+ case glfw.KeyRightBracket:
370+ return "RIGHTBRACKET"
371+ case glfw.KeyGraveAccent:
372+ return "BACKQUOTE"
373+ case glfw.KeyA:
374+ return "a"
375+ case glfw.KeyB:
376+ return "b"
377+ case glfw.KeyC:
378+ return "c"
379+ case glfw.KeyD:
380+ return "d"
381+ case glfw.KeyE:
382+ return "e"
383+ case glfw.KeyF:
384+ return "f"
385+ case glfw.KeyG:
386+ return "g"
387+ case glfw.KeyH:
388+ return "h"
389+ case glfw.KeyI:
390+ return "i"
391+ case glfw.KeyJ:
392+ return "j"
393+ case glfw.KeyK:
394+ return "k"
395+ case glfw.KeyL:
396+ return "l"
397+ case glfw.KeyM:
398+ return "m"
399+ case glfw.KeyN:
400+ return "n"
401+ case glfw.KeyO:
402+ return "o"
403+ case glfw.KeyP:
404+ return "p"
405+ case glfw.KeyQ:
406+ return "q"
407+ case glfw.KeyR:
408+ return "r"
409+ case glfw.KeyS:
410+ return "s"
411+ case glfw.KeyT:
412+ return "t"
413+ case glfw.KeyU:
414+ return "u"
415+ case glfw.KeyV:
416+ return "v"
417+ case glfw.KeyW:
418+ return "w"
419+ case glfw.KeyX:
420+ return "x"
421+ case glfw.KeyY:
422+ return "y"
423+ case glfw.KeyZ:
424+ return "z"
425+ case glfw.KeyCapsLock:
426+ return "CAPSLOCK"
427+ case glfw.KeyF1:
428+ return "F1"
429+ case glfw.KeyF2:
430+ return "F2"
431+ case glfw.KeyF3:
432+ return "F3"
433+ case glfw.KeyF4:
434+ return "F4"
435+ case glfw.KeyF5:
436+ return "F5"
437+ case glfw.KeyF6:
438+ return "F6"
439+ case glfw.KeyF7:
440+ return "F7"
441+ case glfw.KeyF8:
442+ return "F8"
443+ case glfw.KeyF9:
444+ return "F9"
445+ case glfw.KeyF10:
446+ return "F10"
447+ case glfw.KeyF11:
448+ return "F11"
449+ case glfw.KeyF12:
450+ return "F12"
451+ case glfw.KeyPrintScreen:
452+ return "PRINTSCREEN"
453+ case glfw.KeyScrollLock:
454+ return "SCROLLLOCK"
455+ case glfw.KeyPause:
456+ return "PAUSE"
457+ case glfw.KeyInsert:
458+ return "INSERT"
459+ case glfw.KeyHome:
460+ return "HOME"
461+ case glfw.KeyPageUp:
462+ return "PAGEUP"
463+ case glfw.KeyDelete:
464+ return "DELETE"
465+ case glfw.KeyEnd:
466+ return "END"
467+ case glfw.KeyPageDown:
468+ return "PAGEDOWN"
469+ case glfw.KeyRight:
470+ return "RIGHT"
471+ case glfw.KeyLeft:
472+ return "LEFT"
473+ case glfw.KeyDown:
474+ return "DOWN"
475+ case glfw.KeyUp:
476+ return "UP"
477+ case glfw.KeyNumLock:
478+ return "NUMLOCKCLEAR"
479+ case glfw.KeyKPDivide:
480+ return "KP_DIVIDE"
481+ case glfw.KeyKPMultiply:
482+ return "KP_MULTIPLY"
483+ case glfw.KeyKPSubtract:
484+ return "KP_MINUS"
485+ case glfw.KeyKPAdd:
486+ return "KP_PLUS"
487+ case glfw.KeyKPEnter:
488+ return "KP_ENTER"
489+ case glfw.KeyKP1:
490+ return "KP_1"
491+ case glfw.KeyKP2:
492+ return "KP_2"
493+ case glfw.KeyKP3:
494+ return "KP_3"
495+ case glfw.KeyKP4:
496+ return "KP_4"
497+ case glfw.KeyKP5:
498+ return "KP_5"
499+ case glfw.KeyKP6:
500+ return "KP_6"
501+ case glfw.KeyKP7:
502+ return "KP_7"
503+ case glfw.KeyKP8:
504+ return "KP_8"
505+ case glfw.KeyKP9:
506+ return "KP_9"
507+ case glfw.KeyKP0:
508+ return "KP_0"
509+ case glfw.KeyKPDecimal:
510+ return "KP_PERIOD"
511+ case glfw.KeyKPEqual:
512+ return "KP_EQUALS"
513+ case glfw.KeyF13:
514+ return "F13"
515+ case glfw.KeyF14:
516+ return "F14"
517+ case glfw.KeyF15:
518+ return "F15"
519+ case glfw.KeyF16:
520+ return "F16"
521+ case glfw.KeyF17:
522+ return "F17"
523+ case glfw.KeyF18:
524+ return "F18"
525+ case glfw.KeyF19:
526+ return "F19"
527+ case glfw.KeyF20:
528+ return "F20"
529+ case glfw.KeyF21:
530+ return "F21"
531+ case glfw.KeyF22:
532+ return "F22"
533+ case glfw.KeyF23:
534+ return "F23"
535+ case glfw.KeyF24:
536+ return "F24"
537+ case glfw.KeyMenu:
538+ return "MENU"
539+ case glfw.KeyLeftControl:
540+ return "LCTRL"
541+ case glfw.KeyLeftShift:
542+ return "LSHIFT"
543+ case glfw.KeyLeftAlt:
544+ return "LALT"
545+ case glfw.KeyLeftSuper:
546+ return "LGUI"
547+ case glfw.KeyRightControl:
548+ return "RCTRL"
549+ case glfw.KeyRightShift:
550+ return "RSHIFT"
551+ case glfw.KeyRightAlt:
552+ return "RALT"
553+ case glfw.KeyRightSuper:
554+ return "RGUI"
555+ }
556+ return ""
557+}
558+
314559 type ShortcutScript struct {
315560 Activate bool
316561 Script string
@@ -344,8 +589,11 @@ func keyCallback(_ *glfw.Window, key glfw.Key, _ int,
344589 switch action {
345590 case glfw.Release:
346591 sys.keySatate[key] = false
592+ sys.keyInput = glfw.KeyUnknown
593+ sys.keyString = ""
347594 case glfw.Press:
348595 sys.keySatate[key] = true
596+ sys.keyInput = key
349597 sys.esc = sys.esc ||
350598 key == glfw.KeyEscape && mk&(glfw.ModControl|glfw.ModAlt) == 0
351599 for k, v := range sys.shortcutScripts {
@@ -353,6 +601,9 @@ func keyCallback(_ *glfw.Window, key glfw.Key, _ int,
353601 }
354602 }
355603 }
604+func charCallback(_ *glfw.Window, char rune, mk glfw.ModifierKey) {
605+ sys.keyString = string(char)
606+}
356607
357608 var joystick = [...]glfw.Joystick{glfw.Joystick1, glfw.Joystick2,
358609 glfw.Joystick3, glfw.Joystick4, glfw.Joystick5, glfw.Joystick6,
@@ -367,27 +618,30 @@ func JoystickState(joy, button int) bool {
367618 if joy >= len(joystick) {
368619 return false
369620 }
621+ btns := glfw.GetJoystickButtons(joystick[joy])
370622 if button < 0 {
371623 button = -button - 1
372624 axes := glfw.GetJoystickAxes(joystick[joy])
373625 if len(axes)*2 <= button {
374626 return false
375627 }
628+ if (button == 8 || button == 10) && len(axes) == 6 && len(btns) == 14 { //XboxコントローラーのLRトリガー判定(glfwがバージョンアップすればもっとちゃんと判別できるようになるはず)
629+ return axes[button/2] > 0
630+ }
376631 switch button & 1 {
377632 case 0:
378- return axes[button/2] < -0.1
633+ return axes[button/2] < -0.2
379634 case 1:
380- return axes[button/2] > 0.1
635+ return axes[button/2] > 0.2
381636 }
382637 }
383- btns := glfw.GetJoystickButtons(joystick[joy])
384638 if len(btns) <= button {
385639 return false
386640 }
387641 return btns[button] != 0
388642 }
389643
390-type KeyConfig struct{ Joy, u, d, l, r, a, b, c, x, y, z, s int }
644+type KeyConfig struct{ Joy, u, d, l, r, a, b, c, x, y, z, s, v, w int }
391645
392646 func (kc KeyConfig) U() bool { return JoystickState(kc.Joy, kc.u) }
393647 func (kc KeyConfig) D() bool { return JoystickState(kc.Joy, kc.d) }
@@ -400,6 +654,8 @@ func (kc KeyConfig) X() bool { return JoystickState(kc.Joy, kc.x) }
400654 func (kc KeyConfig) Y() bool { return JoystickState(kc.Joy, kc.y) }
401655 func (kc KeyConfig) Z() bool { return JoystickState(kc.Joy, kc.z) }
402656 func (kc KeyConfig) S() bool { return JoystickState(kc.Joy, kc.s) }
657+func (kc KeyConfig) V() bool { return JoystickState(kc.Joy, kc.v) }
658+func (kc KeyConfig) W() bool { return JoystickState(kc.Joy, kc.w) }
403659
404660 type InputBits int32
405661
@@ -415,7 +671,9 @@ const (
415671 IB_Y
416672 IB_Z
417673 IB_S
418- IB_anybutton = IB_A | IB_B | IB_C | IB_X | IB_Y | IB_Z
674+ IB_V
675+ IB_W
676+ IB_anybutton = IB_A | IB_B | IB_C | IB_X | IB_Y | IB_Z | IB_V | IB_W
419677 )
420678
421679 func (ib *InputBits) SetInput(in int) {
@@ -425,7 +683,8 @@ func (ib *InputBits) SetInput(in int) {
425683 Btoi(sys.keyConfig[in].R())<<3 | Btoi(sys.keyConfig[in].A())<<4 |
426684 Btoi(sys.keyConfig[in].B())<<5 | Btoi(sys.keyConfig[in].C())<<6 |
427685 Btoi(sys.keyConfig[in].X())<<7 | Btoi(sys.keyConfig[in].Y())<<8 |
428- Btoi(sys.keyConfig[in].Z())<<9 | Btoi(sys.keyConfig[in].S())<<10)
686+ Btoi(sys.keyConfig[in].Z())<<9 | Btoi(sys.keyConfig[in].S())<<10 |
687+ Btoi(sys.keyConfig[in].V())<<11 | Btoi(sys.keyConfig[in].W())<<12)
429688 }
430689 }
431690 func (ib InputBits) GetInput(cb *CommandBuffer, facing int32) {
@@ -436,23 +695,23 @@ func (ib InputBits) GetInput(cb *CommandBuffer, facing int32) {
436695 b, f = ib&IB_L != 0, ib&IB_R != 0
437696 }
438697 cb.Input(b, ib&IB_D != 0, f, ib&IB_U != 0, ib&IB_A != 0, ib&IB_B != 0,
439- ib&IB_C != 0, ib&IB_X != 0, ib&IB_Y != 0, ib&IB_Z != 0, ib&IB_S != 0)
698+ ib&IB_C != 0, ib&IB_X != 0, ib&IB_Y != 0, ib&IB_Z != 0, ib&IB_S != 0, ib&IB_V != 0, ib&IB_W != 0)
440699 }
441700
442701 type CommandKeyRemap struct {
443- a, b, c, x, y, z, s, na, nb, nc, nx, ny, nz, ns CommandKey
702+ a, b, c, x, y, z, s, v, w, na, nb, nc, nx, ny, nz, ns, nv, nw CommandKey
444703 }
445704
446705 func NewCommandKeyRemap() *CommandKeyRemap {
447- return &CommandKeyRemap{CK_a, CK_b, CK_c, CK_x, CK_y, CK_z, CK_s,
448- CK_na, CK_nb, CK_nc, CK_nx, CK_ny, CK_nz, CK_ns}
706+ return &CommandKeyRemap{CK_a, CK_b, CK_c, CK_x, CK_y, CK_z, CK_s, CK_v, CK_w,
707+ CK_na, CK_nb, CK_nc, CK_nx, CK_ny, CK_nz, CK_ns, CK_nv, CK_nw}
449708 }
450709
451710 type CommandBuffer struct {
452- Bb, Db, Fb, Ub int32
453- ab, bb, cb, xb, yb, zb, sb int32
454- B, D, F, U int8
455- a, b, c, x, y, z, s int8
711+ Bb, Db, Fb, Ub int32
712+ ab, bb, cb, xb, yb, zb, sb, vb, wb int32
713+ B, D, F, U int8
714+ a, b, c, x, y, z, s, v, w int8
456715 }
457716
458717 func NewCommandBuffer() (c *CommandBuffer) {
@@ -462,9 +721,9 @@ func NewCommandBuffer() (c *CommandBuffer) {
462721 }
463722 func (__ *CommandBuffer) Reset() {
464723 *__ = CommandBuffer{B: -1, D: -1, F: -1, U: -1,
465- a: -1, b: -1, c: -1, x: -1, y: -1, z: -1, s: -1}
724+ a: -1, b: -1, c: -1, x: -1, y: -1, z: -1, s: -1, v: -1, w: -1}
466725 }
467-func (__ *CommandBuffer) Input(B, D, F, U, a, b, c, x, y, z, s bool) {
726+func (__ *CommandBuffer) Input(B, D, F, U, a, b, c, x, y, z, s, v, w bool) {
468727 if (B && !F) != (__.B > 0) {
469728 __.Bb = 0
470729 __.B *= -1
@@ -520,6 +779,16 @@ func (__ *CommandBuffer) Input(B, D, F, U, a, b, c, x, y, z, s bool) {
520779 __.s *= -1
521780 }
522781 __.sb += int32(__.s)
782+ if v != (__.v > 0) {
783+ __.vb = 0
784+ __.v *= -1
785+ }
786+ __.vb += int32(__.v)
787+ if w != (__.w > 0) {
788+ __.wb = 0
789+ __.w *= -1
790+ }
791+ __.wb += int32(__.w)
523792 }
524793 func (__ *CommandBuffer) InputBits(ib InputBits, f int32) {
525794 var B, F bool
@@ -529,7 +798,7 @@ func (__ *CommandBuffer) InputBits(ib InputBits, f int32) {
529798 B, F = ib&IB_L != 0, ib&IB_R != 0
530799 }
531800 __.Input(B, ib&IB_D != 0, F, ib&IB_U != 0, ib&IB_A != 0, ib&IB_B != 0,
532- ib&IB_C != 0, ib&IB_X != 0, ib&IB_Y != 0, ib&IB_Z != 0, ib&IB_S != 0)
801+ ib&IB_C != 0, ib&IB_X != 0, ib&IB_Y != 0, ib&IB_Z != 0, ib&IB_S != 0, ib&IB_V != 0, ib&IB_W != 0)
533802 }
534803 func (__ *CommandBuffer) State(ck CommandKey) int32 {
535804 switch ck {
@@ -579,6 +848,10 @@ func (__ *CommandBuffer) State(ck CommandKey) int32 {
579848 return __.zb
580849 case CK_s:
581850 return __.sb
851+ case CK_v:
852+ return __.vb
853+ case CK_w:
854+ return __.wb
582855 case CK_nB:
583856 return -Min(-Max(__.Db, __.Ub), __.Bb)
584857 case CK_nD:
@@ -625,6 +898,10 @@ func (__ *CommandBuffer) State(ck CommandKey) int32 {
625898 return -__.zb
626899 case CK_ns:
627900 return -__.sb
901+ case CK_nv:
902+ return -__.vb
903+ case CK_nw:
904+ return -__.wb
628905 }
629906 return 0
630907 }
@@ -705,7 +982,7 @@ func (__ *CommandBuffer) LastDirectionTime() int32 {
705982 }
706983 func (__ *CommandBuffer) LastChangeTime() int32 {
707984 return Min(__.LastDirectionTime(), Abs(__.ab), Abs(__.bb), Abs(__.cb),
708- Abs(__.xb), Abs(__.yb), Abs(__.zb), Abs(__.sb))
985+ Abs(__.xb), Abs(__.yb), Abs(__.zb), Abs(__.sb), Abs(__.vb), Abs(__.wb))
709986 }
710987
711988 type NetBuffer struct {
@@ -1052,13 +1329,14 @@ func (fi *FileInput) Update() bool {
10521329 }
10531330
10541331 type AiInput struct {
1055- dir, dt, at, bt, ct, xt, yt, zt, st int32
1332+ dir, dt, at, bt, ct, xt, yt, zt, st, vt, wt int32
10561333 }
10571334
10581335 func (__ *AiInput) Update() {
10591336 if sys.intro != 0 {
10601337 __.dt, __.at, __.bt, __.ct = 0, 0, 0, 0
10611338 __.xt, __.yt, __.zt, __.st = 0, 0, 0, 0
1339+ __.vt, __.wt = 0, 0
10621340 return
10631341 }
10641342 var osu, hanasu int32 = 15, 60
@@ -1083,6 +1361,8 @@ func (__ *AiInput) Update() {
10831361 dec(&__.xt)
10841362 dec(&__.yt)
10851363 dec(&__.zt)
1364+ dec(&__.vt)
1365+ dec(&__.wt)
10861366 osu = 3600
10871367 dec(&__.st)
10881368 }
@@ -1119,6 +1399,12 @@ func (__ *AiInput) Z() bool {
11191399 func (__ *AiInput) S() bool {
11201400 return __.st != 0
11211401 }
1402+func (__ *AiInput) V() bool {
1403+ return __.vt != 0
1404+}
1405+func (__ *AiInput) W() bool {
1406+ return __.wt != 0
1407+}
11221408
11231409 type cmdElem struct {
11241410 key []CommandKey
@@ -1305,7 +1591,7 @@ func ReadCommand(name, cmdstr string, kr *CommandKeyRemap) (*Command, error) {
13051591 tilde = false
13061592 case 'x':
13071593 if tilde {
1308- ce.key = append(ce.key, kr.x)
1594+ ce.key = append(ce.key, kr.nx)
13091595 } else {
13101596 ce.key = append(ce.key, kr.x)
13111597 }
@@ -1331,6 +1617,20 @@ func ReadCommand(name, cmdstr string, kr *CommandKeyRemap) (*Command, error) {
13311617 ce.key = append(ce.key, kr.s)
13321618 }
13331619 tilde = false
1620+ case 'v':
1621+ if tilde {
1622+ ce.key = append(ce.key, kr.nv)
1623+ } else {
1624+ ce.key = append(ce.key, kr.v)
1625+ }
1626+ tilde = false
1627+ case 'w':
1628+ if tilde {
1629+ ce.key = append(ce.key, kr.nw)
1630+ } else {
1631+ ce.key = append(ce.key, kr.w)
1632+ }
1633+ tilde = false
13341634 case '$':
13351635 switch nextChar() {
13361636 case 'B':
@@ -1616,7 +1916,7 @@ func (cl *CommandList) Input(i int, facing int32) bool {
16161916 _else = true
16171917 }
16181918 if _else {
1619- var l, r, u, d, a, b, c, x, y, z, s bool
1919+ var l, r, u, d, a, b, c, x, y, z, s, v, w bool
16201920 if i < 0 {
16211921 i = ^i
16221922 if i < len(sys.aiInput) {
@@ -1631,12 +1931,14 @@ func (cl *CommandList) Input(i int, facing int32) bool {
16311931 y = sys.aiInput[i].Y()
16321932 z = sys.aiInput[i].Z()
16331933 s = sys.aiInput[i].S()
1934+ v = sys.aiInput[i].V()
1935+ w = sys.aiInput[i].W()
16341936 }
16351937 } else if i < len(sys.inputRemap) {
16361938 in := sys.inputRemap[i]
16371939 if in < len(sys.keyConfig) {
16381940 joy := sys.keyConfig[in].Joy
1639- if joy >= -1 {
1941+ if joy == -1 {
16401942 l = sys.keyConfig[in].L()
16411943 r = sys.keyConfig[in].R()
16421944 u = sys.keyConfig[in].U()
@@ -1648,6 +1950,52 @@ func (cl *CommandList) Input(i int, facing int32) bool {
16481950 y = sys.keyConfig[in].Y()
16491951 z = sys.keyConfig[in].Z()
16501952 s = sys.keyConfig[in].S()
1953+ v = sys.keyConfig[in].V()
1954+ w = sys.keyConfig[in].W()
1955+ }
1956+ }
1957+ if in < len(sys.JoystickConfig) {
1958+ joyS := sys.JoystickConfig[in].Joy
1959+ if joyS >= 0 {
1960+ if l == false {
1961+ l = sys.JoystickConfig[in].L()
1962+ }
1963+ if r == false {
1964+ r = sys.JoystickConfig[in].R()
1965+ }
1966+ if u == false {
1967+ u = sys.JoystickConfig[in].U()
1968+ }
1969+ if d == false {
1970+ d = sys.JoystickConfig[in].D()
1971+ }
1972+ if a == false {
1973+ a = sys.JoystickConfig[in].A()
1974+ }
1975+ if b == false {
1976+ b = sys.JoystickConfig[in].B()
1977+ }
1978+ if c == false {
1979+ c = sys.JoystickConfig[in].C()
1980+ }
1981+ if x == false {
1982+ x = sys.JoystickConfig[in].X()
1983+ }
1984+ if y == false {
1985+ y = sys.JoystickConfig[in].Y()
1986+ }
1987+ if z == false {
1988+ z = sys.JoystickConfig[in].Z()
1989+ }
1990+ if s == false {
1991+ s = sys.JoystickConfig[in].S()
1992+ }
1993+ if v == false {
1994+ v = sys.JoystickConfig[in].V()
1995+ }
1996+ if w == false {
1997+ w = sys.JoystickConfig[in].W()
1998+ }
16511999 }
16522000 }
16532001 }
@@ -1657,7 +2005,7 @@ func (cl *CommandList) Input(i int, facing int32) bool {
16572005 } else {
16582006 B, F = l, r
16592007 }
1660- cl.Buffer.Input(B, d, F, u, a, b, c, x, y, z, s)
2008+ cl.Buffer.Input(B, d, F, u, a, b, c, x, y, z, s, v, w)
16612009 }
16622010 return step
16632011 }
--- a/src/main.go
+++ b/src/main.go
@@ -7,6 +7,7 @@ import (
77 "os"
88 "regexp"
99 "runtime"
10+ "strconv"
1011 "strings"
1112 "syscall"
1213
@@ -103,16 +104,13 @@ func main() {
103104 "Joystick":-1,
104105 "Buttons":["t","g","f","h","j","k","l","u","i","o","RSHIFT","LEFTBRACKET","RIGHTBRACKET"]
105106 }],
106- "_comment":{
107- "_comment":"ジョイスティック (0番) の場合の KeyConfig",
108- "KeyConfig":[{
109- "Joystick":0,
110- "Buttons":["-7","-8","-5","-6","0","1","4","2","3","5","7","6","8"]
111- },{
112- "Joystick":1,
113- "Buttons":["-7","-8","-5","-6","0","1","4","2","3","5","7","6","8"]
114- }]
115- },
107+ "JoystickConfig":[{
108+ "Joystick":0,
109+ "Buttons":["-7","-8","-5","-6","0","1","4","2","3","5","7","6","8"]
110+ },{
111+ "Joystick":1,
112+ "Buttons":["-7","-8","-5","-6","0","1","4","2","3","5","7","6","8"]
113+ }],
116114 "Motif":"data/system.def",
117115 "CommonAir":"data/common.air",
118116 "CommonCmd":"data/common.cmd",
@@ -159,6 +157,10 @@ func main() {
159157 Joystick int
160158 Buttons []interface{}
161159 }
160+ JoystickConfig []struct {
161+ Joystick int
162+ Buttons []interface{}
163+ }
162164 NumTag int
163165 TeamLifeShare bool
164166 AIRandomColor bool
@@ -192,17 +194,15 @@ func main() {
192194 stoki := func(key string) int {
193195 return int(StringToKey(key))
194196 }
197+ Atoi := func(key string) int {
198+ var i int
199+ i, _ = strconv.Atoi(key)
200+ return i
201+ }
195202 for a := 0; a < tmp.NumTag; a++ {
196203 for _, kc := range tmp.KeyConfig {
197204 b := kc.Buttons
198- if kc.Joystick >= 0 {
199- sys.keyConfig = append(sys.keyConfig, KeyConfig{kc.Joystick,
200- int(b[0].(float64)), int(b[1].(float64)),
201- int(b[2].(float64)), int(b[3].(float64)),
202- int(b[4].(float64)), int(b[5].(float64)), int(b[6].(float64)),
203- int(b[7].(float64)), int(b[8].(float64)), int(b[9].(float64)),
204- int(b[10].(float64)), int(b[11].(float64)), int(b[12].(float64))})
205- } else {
205+ if kc.Joystick < 0 {
206206 sys.keyConfig = append(sys.keyConfig, KeyConfig{kc.Joystick,
207207 stoki(b[0].(string)), stoki(b[1].(string)),
208208 stoki(b[2].(string)), stoki(b[3].(string)),
@@ -211,6 +211,17 @@ func main() {
211211 stoki(b[10].(string)), stoki(b[11].(string)), stoki(b[12].(string))})
212212 }
213213 }
214+ for _, jc := range tmp.JoystickConfig {
215+ b := jc.Buttons
216+ if jc.Joystick >= 0 {
217+ sys.JoystickConfig = append(sys.JoystickConfig, KeyConfig{jc.Joystick,
218+ Atoi(b[0].(string)), Atoi(b[1].(string)),
219+ Atoi(b[2].(string)), Atoi(b[3].(string)),
220+ Atoi(b[4].(string)), Atoi(b[5].(string)), Atoi(b[6].(string)),
221+ Atoi(b[7].(string)), Atoi(b[8].(string)), Atoi(b[9].(string)),
222+ Atoi(b[10].(string)), Atoi(b[11].(string)), Atoi(b[12].(string))})
223+ }
224+ }
214225 }
215226 sys.teamLifeShare = tmp.TeamLifeShare
216227 sys.fullscreen = tmp.Fullscreen
--- a/src/script.go
+++ b/src/script.go
@@ -2,11 +2,11 @@ package main
22
33 import (
44 "fmt"
5+ "math/rand"
56 "runtime"
7+ "strconv"
68 "strings"
79
8- "math/rand"
9-
1010 "github.com/go-gl/glfw/v3.2/glfw"
1111 "github.com/yuin/gopher-lua"
1212 )
@@ -1085,6 +1085,32 @@ func systemScriptInit(l *lua.LState) {
10851085 if sys.keyInput != glfw.KeyUnknown {
10861086 s = KeyToString(sys.keyInput)
10871087 }
1088+
1089+ for j := 0; j < 2; j++ {
1090+ if glfw.JoystickPresent(joystick[j]) {
1091+ axes := glfw.GetJoystickAxes(joystick[j])
1092+ btns := glfw.GetJoystickButtons(joystick[j])
1093+ for i := range axes {
1094+ if i > 3 && len(axes) == 6 && len(btns) == 14 { //Xboxコントローラー判定(glfwがバージョンアップすればもっとちゃんと判別できるようになるはず)
1095+ if axes[i] > 0 {
1096+ s = strconv.Itoa(-i*2 - 1)
1097+ }
1098+ } else {
1099+ if axes[i] < -0.2 {
1100+ s = strconv.Itoa(-i*2 - 1)
1101+ } else if axes[i] > 0.2 {
1102+ s = strconv.Itoa(-i*2 - 2)
1103+ }
1104+ }
1105+ }
1106+ for i := range btns {
1107+ if btns[i] > 0 {
1108+ s = strconv.Itoa(i)
1109+ }
1110+ }
1111+ }
1112+ }
1113+
10881114 l.Push(lua.LString(s))
10891115 return 1
10901116 })
--- a/src/system.go
+++ b/src/system.go
@@ -98,6 +98,7 @@ type System struct {
9898 fileInput *FileInput
9999 aiInput [MaxSimul * 2]AiInput
100100 keyConfig []KeyConfig
101+ JoystickConfig []KeyConfig
101102 com [MaxSimul * 2]int32
102103 autolevel bool
103104 home int
@@ -445,6 +446,11 @@ func (s *System) anyHardButton() bool {
445446 return true
446447 }
447448 }
449+ for _, kc := range s.JoystickConfig {
450+ if kc.A() || kc.B() || kc.C() || kc.X() || kc.Y() || kc.Z() {
451+ return true
452+ }
453+ }
448454 return false
449455 }
450456 func (s *System) anyButton() bool {