Day.png);">
Apprendre


Vous êtes
nouveau sur
Oniromancie?

Visite guidée
du site


Découvrir
RPG Maker

RM 95
RM 2000/2003
RM XP
RM VX/VX Ace
RM MV/MZ

Apprendre
RPG Maker

Tutoriels
Guides
Making-of

Dans le
Forum

Section Entraide

Tutos: Checklist de la composition (...) / Sorties: Dread Mac Farlane - episode 8 / Sorties: Dread Mac Farlane - episode 7 / Jeux: Ce qui vit Dessous / News: Quoi de neuf sur Oniromancie (...) / Chat

Bienvenue
visiteur !




publicité RPG Maker!

Statistiques

Liste des
membres


Contact

Mentions légales

394 connectés actuellement

29388249 visiteurs
depuis l'ouverture

5 visiteurs
aujourd'hui



Barre de séparation

Partenaires

Indiexpo

Akademiya RPG Maker

Blog Alioune Fall

Fairy Tail Constellations

RPG Maker VX

Lunae - le bazar d'Emz0

Guelnika & E-magination

RPG Fusion

Tous nos partenaires

Devenir
partenaire



forums

Index du forum > Entraide > [RMXP] Assigner une commande directement à une touche en combat


Malus777 - posté le 06/02/2014 à 12:22:17 (6 messages postés)

❤ 0

Maker sous XP

Domaine concerné: Script
Logiciel utilisé: RMXP
Bonjour, je travail actuellement sur un projet sous RMXP,
j'utilise le script "Enu Sideview Battle System Version 2.1xp" mais je pense que ce que je cherche à faire ne créera pas de conflit avec le script.

Je souhaiterais assigner la commande "Défense" en combat à une touche (par exemple "A") comme ça, lorsque c'est au tour du héros le joueur appui sur la touche "A" et l'action "défense" se lance.
Pour épurer ainsi l'affichage:
image

Merci d'avance pour vos réponses!

EDIT:
Je suis désolé si je n'ai pas respecter les règles du forum, je poste très peu (5 messages en plus de deux ans ^^') du coup je ne suis pas encore familier avec toutes les fonctions et règles. Jusqu'a maintenant je me suis contenter de lire les réponses au questions déjà posé sur le forum pour me renseigner et n'ai pu m'empecher de remarquer que certaines réponses au forum d'entraide son parfois un peu agressives, d’où m'a réaction peut être disproportionné. Cependant je ne tiens pas à transformer ce Topic en croisade au risque de jamais avoir de réponse à m'on problème et de pollué ce chouette forum. Donc, encore une fois je m'excuse platement ;-)

Ce problème étant régler voici le lien de la démo du script que j'utilise; https://dl.dropbox.com/u/27014140/Downloads/Enu%20SBS%20Tanketai%20XP.rar
Sachant que je n'utilise aucuns add-on proposé dans la démo mais uniquement le systeme ATB et le systeme Sideview.J'ai un peu chercher et je pense que si une solution existe elle ne passera pas par ce script c'est pourquoi je n'avais pas mis le lien.

J'ai installé cette après midi le script "input ultimate 2.3" mais je n'ai pas pu trouver d'action permetant d'assigner l'action "défendre" à une touche.

Portion de code : Tout sélectionner

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
 
     
    class Object
      remove_const(:Input)
      def singleton_attach_methods(o) class << self; self end.attach_methods(o) end
      def self.attach_methods(o)
        @attached_methods ||= []
        for m in o.public_methods-(instance_methods-@attached_methods)
          define_method(m, &o.method(m))
          @attached_methods << m unless @attached_methods.include?(m)
        end
      end
    end
     
    class String; alias getbyte [] end if RUBY_VERSION == '1.8.1'
     
    module Input
      class Key
        include Comparable
        attr_reader :o, :i, :s, :hash, :to_sym
        alias to_i i
        alias to_s s
        def initialize(i,o)
          @o, self.i, self.s = o, i, "#{self.class.name.split('::')[-1]}_#{i}"
        end
        def o=(o) @o, @hash = o, @i.hash^o.hash  end
        def i=(i) @i, @hash = i, i.hash^@o.hash  end
        def s=(s) @s, @to_sym = s, s.to_sym      end
        def <=>(o)       @i <=> o.to_i           end
        def succ()       self.class.new(@i+1,@o) end
        def count()      @o.get_count(@i)        end
        def push?()      @o.get_push(@i)         end
        def toggle?()    @o.get_toggle(@i)       end
        def press?()     @o.get_press(@i)        end
        def trigger?()   @o.get_trigger(@i)      end
        def release?()   @o.get_release(@i)      end
        def repeat?()    @o.get_repeat(@i)       end
        def ntrigger?(n) @o.get_ntrigger(n,@i)   end
        def analog?()    @o.get_analog(@i)       end
      end
      class Gamepad_Key < Key
        def initialize(i,o=Gamepad) super        end
      end
      class Keyboard_Key < Key
        def initialize(i,o=Keyboard) super       end
        def name()       @o.get_key_name(@i)     end
        def push!()      @o.push!(@i)            end
        def release!()   @o.release!(@i)         end
        def toggle!()    @o.toggle!(@i)          end
      end
      class Mouse_Key < Key
        def initialize(i,o=Mouse) super          end
        def click?()     ntrigger?(1)            end
        def dclick?()    ntrigger?(2)            end
        def tclick?()    ntrigger?(3)            end
      end
      class Player_Key < Key
        def [](i)        @players_keys[i]        end
        def initialize(i,o=Players[0])
          super
          @players_keys = Players.map {|p| k = dup; k.o = p; k}
        end
      end
     
      class Device
        GetDoubleClickTime = Win32API.new('user32', 'GetDoubleClickTime', '', 'i')
        attr_accessor :enabled, :ntrigger_max, :ntrigger_time
        def initialize(max)
          @enabled, @count, @release, @keys = true, Array.new(max,0), [], []
          @ntrigger_count, @ntrigger_last, @ntrigger_max = @count.dup, @count.dup, 0
          self.ntrigger_time = 0
        end
        def update
          return unless @enabled
          update_keys
          update_ntrigger if @ntrigger_max != 0
        end
        def update_keys
          @release.clear
          for i in @keys
            if    get_push(i)   ; @count[i] += 1
            elsif @count[i] != 0; @count[i]  = 0; @release << i
            end
          end
        end
        def update_ntrigger
          f = Graphics.frame_count
          for i in @keys
            if @count[i] == 1
              @ntrigger_count[i] %= @ntrigger_max
              @ntrigger_count[i] += 1
              @ntrigger_last[i] = f + @ntrigger_time
            elsif @ntrigger_last[i] == f
              @ntrigger_count[i] = 0
            end
          end
        end
        def capture_key(*exclude)
          exclude = keyarrayize(*exclude) unless exclude.empty?
          (@count.size-1).downto(0) {|i| return key(i) if !exclude.include?(i) and get_push(i)}
          nil
        end
        def get_count(i)      @count[i]                                                            end
        def get_push(i)       false                                                                end
        def get_toggle(i)     false                                                                end
        def get_press(i)      @count[i] != 0                                                       end
        def get_trigger(i)    @count[i] == 1                                                       end
        def get_release(i)    @release.include?(i)                                                 end
        def get_repeat(i)     (j=@count[i])>0 and REPEAT.any? {|w,f| break(f>0 && j%f==0) if j>=w} end
        def get_ntrigger(n,i) get_trigger(i) and @ntrigger_count[i] == n                           end
        def get_analog(i)     get_push(i) ? 1.0 : 0.0                                              end
        def count(k)          get_count(k2i(k))                                                           end
        def push?(*a)         a.any?{|i| enum?(i) ? i.all?{|j| push?(*j)}       : get_push(k2i(i))}       end
        def toggle?(*a)       a.any?{|i| enum?(i) ? i.all?{|j| toggle?(*j)}     : get_toggle(k2i(i))}     end
        def press?(*a)        a.any?{|i| enum?(i) ? i.all?{|j| press?(*j)}      : get_press(k2i(i))}      end
        def trigger?(*a)      a.any?{|i| enum?(i) ? i.all?{|j| trigger?(*j)}    : get_trigger(k2i(i))}    end
        def release?(*a)      a.any?{|i| enum?(i) ? i.all?{|j| release?(*j)}    : get_release(k2i(i))}    end
        def repeat?(*a)       a.any?{|i| enum?(i) ? i.all?{|j| repeat?(*j)}     : get_repeat(k2i(i))}     end
        def ntrigger?(n,*a)   a.any?{|i| enum?(i) ? i.all?{|j| ntrigger?(n,*j)} : get_ntrigger(n,k2i(i))} end
        def analog?(*a)
          a.each do |i|
            d = if enum?(i)
              sum = size = 0
              i.each {|j| sum, size = sum+analog?(*j), size+1}
              sum == 0 ? 0 : sum / size
            else get_analog(k2i(i))
            end
            return d if d != 0
          end
          0.0
        end
        def ntrigger_time=(i) @ntrigger_time = (i==0 ? GetDoubleClickTime.call *
                              Graphics.frame_rate / 1000 : i)  end
        def key(o)            self.class.key(o)                end
        def k2i(o)            self.class.k2i(o)                end
      private
        def enum?(o)          o.is_a?(Array) or o.is_a?(Range) end
        def keyarrayize(*a)
          a.flatten!
          a.map! {|o| o.is_a?(Range) ? o.to_a : o}.flatten!
          a.compact!
          a.map! {|k| k2i(k)}.uniq!
          a
        end
        def self.key(o) o.is_a?(Key) || o.is_a?(Integer) ? const_get(:Keys)[o.to_i] : const_get(o) end
        def self.k2i(o) o.is_a?(Key) ? o.i : o.is_a?(Integer) ? o : const_get(o).i                 end
      end
     
      class Player < Device
        attr_reader :id, :gamepad, :gamepad_id
        def initialize(id)
          super(KEYS_MAX)
          @id, @gamepad_id, @gamepad, @map = id, id, No_Gamepad.new, @count.map{[]}
        end
        def setup(h)
          @keys.clear
          @count.fill(0)
          @map.fill([])
          for i,a in h
            a=@map[i=k2i(i)] = a[0].map {|j| Gamepad.key(j).dup} + a[1].map {|j| Keyboard.key(j)}
            @keys << i unless a.empty?
          end
          self.gamepad_id += 0
        end
        def gamepad_id=(i)
          vibration, @gamepad.enabled = @gamepad.vibration, false
          @gamepad = (@gamepad_id = i) >= 0 && Gamepads[i] || No_Gamepad.new
          @gamepad.vibration = vibration
          Players.each {|p| p.gamepad.enabled = true}
          @map.each {|a| a.each {|k| k.o = @gamepad if k.is_a?(Gamepad_Key)}}
        end
        def get_push(i)   @map[i].any? {|k| k.push?}                              end
        def get_toggle(i) @map[i].any? {|k| k.toggle?}                            end
        def get_analog(i) @map[i].each {|k| d=k.analog?; return d if d != 0}; 0.0 end
        def dirXY
          return 0.0, 0.0 unless @enabled
          return RIGHT.analog?-LEFT.analog?, UP.analog?-DOWN.analog?
        end
        def dir360
          x, y = *dirXY
          return 0.0, 0.0 if x == 0 and y == 0
          return Math.atan2(y,x)*180/Math::PI, (w=Math.hypot(x,y))>1 ? 1.0 : w
        end
        def dir8
          d = 5
          d -= 3 if DOWN.press?
          d -= 1 if LEFT.press?
          d += 1 if RIGHT.press?
          d += 3 if UP.press?
          d == 5 ? 0 : d
        end
        def dir4
          case d = dir8
          when 1; DOWN.trigger? == (@last_dir==2) ? 2 : 4
          when 3; DOWN.trigger? == (@last_dir==2) ? 2 : 6
          when 7; UP.trigger?   == (@last_dir==8) ? 8 : 4
          when 9; UP.trigger?   == (@last_dir==8) ? 8 : 6
          else    @last_dir = d
          end
        end
      end
     
      class Gamepad < Device
        ::Gamepad = self
        AXIS_PUSH, AXIS_DEADZONE, TRIGGER_PUSH = 16384, 6666, 0
        Keys = Array.new(48) {|i| Gamepad_Key.new(i)}
        Button1 , Button2 , Button3 , Button4 , Button5 , Button6 , Button7 ,
        Button8 , Button9 , Button10, Button11, Button12, Button13, Button14,
        Button15, Button16, Button17, Button18, Button19, Button20, Button21,
        Button22, Button23, Button24, Button25, Button26, Button27, Button28,
        Button29, Button30, Button31, Button32, Axis1_0 , Axis1_1 , Axis2_0 ,
        Axis2_1 , Axis3_0 , Axis3_1 , Axis4_0 , Axis4_1 , Axis5_0 , Axis5_1 ,
        Axis6_0 , Axis6_1 , PovUp   , PovRight, PovDown , PovLeft = *Keys
        XKeys = Array.new(48) {|i| Gamepad_Key.new(i)}
        A, B, X, Y, LB, RB, LT, RT, BACK, START, LS, RS,
        n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n, n,
        AxisLX_0, AxisLX_1, AxisLY_1, AxisLY_0, AxisRX_0, AxisRX_1, AxisRY_1, AxisRY_0,
        n, n, n, n, DPadUp, DPadRight, DPadDown, DPadLeft = *XKeys
        constants.each {|s| k = const_get(s);  k.s = s.to_s if k.is_a?(Key)}
       
        attr_accessor :vibration
        attr_reader   :unplugged
        def initialize(id=nil)
          super(48)
          @id, @unplugged, @map, @vibration = id, false, @count.map{[]}, true
        end
        def get_push(i)
          return false unless @enabled and !@unplugged
          j, k = *@map[i]
          case j
          when :button ; button(k)
          when :pov    ; k.include?(pov)
          when :axis_0 ; axis_raw(k) < -AXIS_PUSH
          when :axis_1 ; axis_raw(k) > AXIS_PUSH-1
          when :trigger; trig_raw(k) > TRIGGER_PUSH
          else           false
          end
        end
        def get_analog(i)
          return 0.0 unless @enabled and !@unplugged
          j, k = *@map[i]
          case j
          when :button, :pov; super
          when :axis_0 ; (k=axis_pct(k)) < 0 ? -k : 0.0
          when :axis_1 ; (k=axis_pct(k)) > 0 ?  k : 0.0
          when :trigger; trig_pct(k)
          else           0.0
          end
        end
        def vibrate!(id, speed, fade_in, duration, fade_out) end
      private
        def axis_pct(i)
          (i=axis_raw(i)).abs <= AXIS_DEADZONE ? 0.0 :
          (i<0 ? i+AXIS_DEADZONE : i-AXIS_DEADZONE+1) / (32768.0-AXIS_DEADZONE)
        end
        def trig_pct(i) trig_raw(i) / 255.0 end
        def axis_raw(i) 0                   end
        def trig_raw(i) 0                   end
        def pov()       0                   end
        def button(i)   false               end
         
        singleton_attach_methods(@o = new)
       
        class No_Gamepad < Gamepad
          ::No_Gamepad = Input::No_Gamepad = self
          def get_push(i)   false end
          def get_analog(i) 0.0   end
        end
       
        class Multimedia_Gamepad < Gamepad
          ::Multimedia_Gamepad = Input::Multimedia_Gamepad = self
          JoyGetDevCaps = Win32API.new('winmm', 'joyGetDevCaps', 'ipi', 'i')
          JoyGetPosEx   = Win32API.new('winmm', 'joyGetPosEx'  , 'ip' , 'i')
          def initialize(id)
            super
            JoyGetDevCaps.call(id, devcaps="\0"*404, 404)
            @caps = Array.new(7) {|i| i<2 or devcaps.getbyte(96)[i-2]==1}
            @buffer = [52,255,0,0,0,0,0,0,0,0,0,0,0].pack('L13')
            @state = @buffer.unpack('L13')
            for k,v in {            Button1 =>[:button, 0], Button2 =>[:button, 1],
            Button3 =>[:button, 2], Button4 =>[:button, 3], Button5 =>[:button, 4],
            Button6 =>[:button, 5], Button7 =>[:button, 6], Button8 =>[:button, 7],
            Button9 =>[:button, 8], Button10=>[:button, 9], Button11=>[:button,10],
            Button12=>[:button,11], Button13=>[:button,12], Button14=>[:button,13],
            Button15=>[:button,14], Button16=>[:button,15], Button17=>[:button,16],
            Button18=>[:button,17], Button19=>[:button,18], Button20=>[:button,19],
            Button21=>[:button,20], Button22=>[:button,21], Button23=>[:button,22],
            Button24=>[:button,23], Button25=>[:button,24], Button26=>[:button,25],
            Button27=>[:button,26], Button28=>[:button,27], Button29=>[:button,28],
            Button30=>[:button,29], Button31=>[:button,30], Button32=>[:button,31],
            Axis1_0 =>[:axis_0, 0], Axis1_1 =>[:axis_1, 0], Axis2_0 =>[:axis_0, 1],
            Axis2_1 =>[:axis_1, 1], Axis3_0 =>[:axis_0, 2], Axis3_1 =>[:axis_1, 2],
            Axis4_0 =>[:axis_0, 3], Axis4_1 =>[:axis_1, 3], Axis5_0 =>[:axis_0, 4],
            Axis5_1 =>[:axis_1, 4], Axis6_0 =>[:axis_0, 5], Axis6_1 =>[:axis_1, 5],
            PovUp   =>[:pov,[31500,    0, 4500]], PovRight=>[:pov,[ 4500, 9000,13500]],
            PovDown =>[:pov,[13500,18000,22500]], PovLeft =>[:pov,[22500,27000,31500]]}
              @map[k.i] = v
            end
            update
          end
          def update
            return unless @enabled and !@unplugged = JoyGetPosEx.call(@id, @buffer) != 0
            @state.replace(@buffer.unpack('L13'))
            super
          end
        private
          def button(i)   @state[8][i] == 1                end
          def pov()       @caps[6] ? @state[10] : 0        end
          def axis_raw(i) @caps[i] ? @state[2+i]-32768 : 0 end
        end
       
        class XBox360_Gamepad < Gamepad
          ::XBox360_Gamepad = Input::XBox360_Gamepad = self
          Keys = XKeys
          XInputGetState = (Win32API.new(DLL='xinput1_3'  , 'XInputGetState', 'ip', 'i') rescue
                            Win32API.new(DLL='xinput1_2'  , 'XInputGetState', 'ip', 'i') rescue
                            Win32API.new(DLL='xinput1_1'  , 'XInputGetState', 'ip', 'i') rescue
                            Win32API.new(DLL='xinput9_1_0', 'XInputGetState', 'ip', 'i') rescue
                            DLL=nil)
          XInputSetState =  Win32API.new(DLL              , 'XInputSetState', 'ip', 'i') if DLL
          def initialize(id)
            super
            @buffer = "\0"*16
            @state = @buffer.unpack('LSC2s4')
            @vibration_state = Array.new(2) {[0,0,0,0,0,false]}
            for k,v in {
            A        =>[:button,12], B       =>[:button,13], X       =>[:button,14],
            Y        =>[:button,15], LB      =>[:button, 8], RB      =>[:button, 9],
            LT       =>[:trigger,0], RT      =>[:trigger,1], BACK    =>[:button, 5],
            START    =>[:button, 4], LS      =>[:button, 6], RS      =>[:button, 7],
            AxisLX_0 =>[:axis_0, 0], AxisLX_1=>[:axis_1, 0], AxisLY_1=>[:axis_1, 1],
            AxisLY_0 =>[:axis_0, 1], AxisRX_0=>[:axis_0, 2], AxisRX_1=>[:axis_1, 2],
            AxisRY_1 =>[:axis_1, 3], AxisRY_0=>[:axis_0, 3], DPadUp  =>[:button, 0],
            DPadRight=>[:button, 3], DPadDown=>[:button, 1], DPadLeft=>[:button, 2]}
              @map[k.i] = v
            end
            update
          end
          def update
            return unless @enabled and !@unplugged = XInputGetState.call(@id, @buffer) != 0
            @state.replace(@buffer.unpack('LSC2s4'))
            super
            update_vibration if @vibration
          end
          def update_vibration
            vibrate = false
            @vibration_state.each do |v|
              next unless v[5]
              last_v0 = v[0]
              if    v[2]>0; v[0] = (v[0]*(v[2]-=1)+v[1]) / (v[2]+1.0)
              elsif v[3]>0; v[0], v[3] = v[1], v[3]-1
              elsif v[4]>0; v[0] = v[0]*(v[4]-=1) / (v[4]+1.0)
              else          v[0], v[5] = 0, false
              end
              vibrate = true if last_v0 != v[0]
            end
            set_vibration if vibrate
          end
          def vibration=(b) vibrate!(2,0,0,0,0); super end
          def vibrate!(id, speed, fade_in, duration, fade_out)
            case id
            when 0, 1; @vibration_state[id][1,5] = [speed, fade_in, duration, fade_out, true]
            when 2   ; 2.times {|i| vibrate!(i, speed, fade_in, duration, fade_out)}
            end
          end
        private
          def button(i)   @state[1][i] == 1 end
          def axis_raw(i) @state[4+i]       end
          def trig_raw(i) @state[2+i]       end
          def set_vibration
            return unless @enabled and @vibration and !@unplugged
            XInputSetState.call(@id, [@vibration_state[0][0]*0xFFFF,
                                      @vibration_state[1][0]*0xFFFF].pack('S2'))
          end
        end
       
      end
     
      class Keyboard < Device
        ::Keyboard = self
        GetKeyboardState    = Win32API.new('user32'  , 'GetKeyboardState'   , 'p'       , 'i')
        getKeyNameText      = Win32API.new('user32'  , 'GetKeyNameTextW'    , 'ipi'     , 'i')
        mapVirtualKey       = Win32API.new('user32'  , 'MapVirtualKey'      , 'ii'      , 'i')
        SendInput           = Win32API.new('user32'  , 'SendInput'          , 'ipi'     , 'i')
        ToUnicode           = Win32API.new('user32'  , 'ToUnicode'          , 'iippii'  , 'i')
        WideCharToMultiByte = Win32API.new('kernel32', 'WideCharToMultiByte', 'iipipipp', 'i')
     
        Keys = Array.new(256) {|i| Keyboard_Key.new(i)}
        None, MouseL, MouseR, Cancel, MouseM, MouseX1, MouseX2, n, Back, Tab,
        LineFeed, n, Clear, Enter, n, n, Shift, Control, Alt, Pause, CapsLock,
        KanaMode, n, JunjaMode, FinalMode, KanjiMode, n, Escape, IMEConvert,
        IMENonConvert, IMEAccept, IMEModeChange, Space, PageUp, PageDown, End, Home,
        Left, Up, Right, Down, Select, Print, Execute, PrintScreen, Insert, Delete,
        Help, D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, n, n, n, n, n, n, n, A, B, C,
        D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, LWin,
        RWin, Apps, n, Sleep, NumPad0, NumPad1, NumPad2, NumPad3, NumPad4, NumPad5,
        NumPad6, NumPad7, NumPad8, NumPad9, Multiply, Add, Separator, Subtract,
        Decimal, Divide, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13,
        F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, n, n, n, n, n, n, n,
        n, NumLock, Scroll, n, n, n, n, n, n, n, n, n, n, n, n, n, n, LShift,
        RShift, LControl, RControl, LAlt, RAlt, BrowserBack, BrowserForward,
        BrowserRefresh, BrowserStop, BrowserSearch, BrowserFavorites, BrowserHome,
        VolumeMute, VolumeDown, VolumeUp, MediaNextTrack, MediaPreviousTrack,
        MediaStop, MediaPlayPause, LaunchMail, SelectMedia, LaunchApplication1,
        LaunchApplication2, n, n, OemSemicolon, OemPlus, OemComma, OemMinus,
        OemPeriod, OemQuestion, OemTilde, n, n, n, n, n, n, n, n, n, n, n, n, n, n,
        n, n, n, n, n, n, n, n, n, n, n, n, OemOpenBrackets, OemPipe,
        OemCloseBrackets, OemQuotes, Oem8, n, n, OemBackslash, n, n, ProcessKey,
        n, Packet, n, n, n, n, n, n, n, n, n, n, n, n, n, n, Attn, Crsel, Exsel,
        EraseEof, Play, Zoom, NoName, Pa1, OemClear, Unknown = *Keys
        constants.each {|s| k = const_get(s);  k.s = s.to_s if k.is_a?(Key)}
       
        SCAN_CODE = Array.new(256) {|i| mapVirtualKey.call(i, 0)}
        (BrowserBack..LaunchApplication2).each {|k| SCAN_CODE[k.i] = 0}
        for k,code in  {Pause  =>0x0045, PageUp     =>0x0149, PageDown=>0x0151,
        End   =>0x014F, Home   =>0x0147, Left       =>0x014B, Up      =>0x0148,
        Right =>0x014D, Down   =>0x0150, PrintScreen=>0x0137, Insert  =>0x0152,
        Delete=>0x0153, LWin   =>0x015B, RWin       =>0x015C, Apps    =>0x015D,
        Divide=>0x0135, NumLock=>0x0145, RControl   =>0x011D, RAlt    =>0x0138}
          SCAN_CODE[k.i] = code
        end
       
        KEYS_NAME = Array.new(256) do |i|
          if getKeyNameText.call(SCAN_CODE[i]<<16, utf16="\0"*256, 256) > 0
            WideCharToMultiByte.call(65001, 0, utf16, -1, utf8="\0"*256, 256, 0, 0)
            utf8.delete("\0")
          else Keys[i].to_s
          end
        end
       
        TEXT_KEYS = [Space.i] + (D0.i..D9.i).to_a + (A.i..Z.i).to_a +
                    (NumPad0.i..Divide.i).to_a + (146..150).to_a +
                    (OemSemicolon.i..OemTilde.i).to_a + (OemOpenBrackets.i..245).to_a
       
        TEXT_ENTRY_KEYS = TEXT_KEYS + [Back.i,Left.i,Up.i,Right.i,Down.i,Delete.i]
       
        DEAD_KEYS = {
            '`' => {'a'=>'à', 'e'=>'è', 'i'=>'ì', 'o'=>'ò', 'u'=>'ù',
          ' '=>'`', 'A'=>'À', 'E'=>'È', 'I'=>'Ì', 'O'=>'Ò', 'U'=>'Ù'},
         
            '´' => {'a'=>'á', 'e'=>'é', 'i'=>'í', 'o'=>'ó', 'u'=>'ú', 'y'=>'ý',
          ' '=>'´', 'A'=>'Á', 'E'=>'É', 'I'=>'Í', 'O'=>'Ó', 'U'=>'Ú', 'Y'=>'Ý'},
         
            '^' => {'a'=>'â', 'e'=>'ê', 'i'=>'î', 'o'=>'ô', 'u'=>'û',
          ' '=>'^', 'A'=>'Â', 'E'=>'Ê', 'I'=>'Î', 'O'=>'Ô', 'U'=>'Û'},
         
            '¨' => {'a'=>'ä', 'e'=>'ë', 'i'=>'ï', 'o'=>'ö', 'u'=>'ü', 'y'=>'ÿ',
          ' '=>'¨', 'A'=>'Ä', 'E'=>'Ë', 'I'=>'Ï', 'O'=>'Ö', 'U'=>'Ü', 'y'=>'Ÿ'},
         
            '~' => {'a'=>'ã', 'o'=>'õ', 'n'=>'ñ',
          ' '=>'~', 'A'=>'Ã', 'O'=>'Õ', 'N'=>'Ñ'},
        }
       
        def initialize()         super(256); @buffer = "\0"*256                        end
        def get_push(i)          @enabled and @buffer.getbyte(i)[7] == 1               end
        def get_toggle(i)        @enabled and @buffer.getbyte(i)[0] == 1               end
        def get_key_name(i)      i.between?(0, 255) ? KEYS_NAME[i].dup : ''            end
        def key_name(k)          get_key_name(k2i(k))                                  end
        def push!(*a)            set_state(a, true)                                    end
        def release!(*a)         set_state(a, false)                                   end
        def toggle!(*a)          set_state(a, true); set_state(a, false)               end
        def text_entry()         start_text_entry unless @text_entry; @text_entry.dup  end
        def start_text_entry()   (@text_entry = ''; setup(@keys)) unless @text_entry   end
        def stop_text_entry()    (@text_entry = nil; setup(@user_keys)) if @text_entry end
        def swap_mouse_button(b) MouseL.i, MouseR.i = b ? 2 : 1, b ? 1 : 2             end
        def setup(*a)
          @count.fill(0)
          @keys = keyarrayize(@text_entry ? [@user_keys=a, TEXT_ENTRY_KEYS] : a)
        end
        def update
          return unless @enabled
          GetKeyboardState.call(@buffer)
          super
          update_text_entry if @text_entry
        end
        def update_text_entry
          @text_entry = ''
          for i in TEXT_KEYS
            next if !get_repeat(i) or ToUnicode.call(i, 0, @buffer, utf16="\0"*16, 8, 0)==0
            j = ToUnicode.call(i, 0, @buffer, utf16, 8, 0)
            WideCharToMultiByte.call(65001, 0, utf16, 1, utf8="\0"*4, 4, 0, 0)
            utf8.delete!("\0")
            if @dead_key
              a = DEAD_KEYS[@dead_key]
              @text_entry, @dead_key = (a && a[utf8]) || (@dead_key + utf8)
            else j == -1 ? @dead_key=utf8 : @text_entry=utf8
            end
            return
          end
        end
      private
        def set_state(keys, state)
          keys, inputs = keyarrayize(keys), ''
          keys.each {|i| inputs << [1,i,0,state ? 0 : 2,0,0].pack('LSSLLLx8')}
          SendInput.call(keys.size, inputs, 28)
        end
       
        singleton_attach_methods(@o = new)
        Keys.each {|k| k.o = @o}
        def self.o() @o end
      end
     
      class Mouse < Device
        ::Mouse = self
        ClipCursor      = Win32API.new('user32', 'ClipCursor'     , 'p'      , 'i')
        createCursor    = Win32API.new('user32', 'CreateCursor'   , 'iiiiipp', 'i')
        findWindow      = Win32API.new('user32', 'FindWindow'     , 'pp'     , 'i')
        GetClientRect   = Win32API.new('user32', 'GetClientRect'  , 'ip'     , 'i')
        GetCursorPos    = Win32API.new('user32', 'GetCursorPos'   , 'p'      , 'i')
        GetWindowRect   = Win32API.new('user32', 'GetWindowRect'  , 'ip'     , 'i')
        MapWindowPoints = Win32API.new('user32', 'MapWindowPoints', 'iipi'   , 'i')
        PeekMessage     = Win32API.new('user32', 'PeekMessage'    , 'piiii'  , 'i')
        SetClassLong    = Win32API.new('user32', 'SetClassLong'   , 'iii'    , 'i')
        SetCursorPos    = Win32API.new('user32', 'SetCursorPos'   , 'ii'     , 'i')
       
        Keys = Array.new(7) {|i| Mouse_Key.new(i)}
        Left, Middle, Right, X1, X2, WheelUp, WheelDown = *Keys
        constants.each {|s| k = const_get(s);  k.s = s.to_s if k.is_a?(Key)}
       
        HWND = findWindow.call('RGSS Player', 0)
        BlankCursor = createCursor.call(0, 0, 0, 1, 1, "\xFF", "\x00")
        Cache = (defined? RPG::Cache) ? RPG::Cache : ::Cache
       
        alias click_max   ntrigger_max
        alias click_max=  ntrigger_max=
        alias click_time  ntrigger_time
        alias click_time= ntrigger_time=
        attr_accessor :drag_enabled, :drag_auto_clear, :drag_start_size
        attr_reader   :cursor, :drag
        def initialize
          super(7)
          @map = @count.map{[]}
          for k,v in {Left    => [:button, Keyboard::MouseL],
                      Middle  => [:button, Keyboard::MouseM],
                      Right   => [:button, Keyboard::MouseR],
                      X1      => [:button, Keyboard::MouseX1],
                      X2      => [:button, Keyboard::MouseX2],
                      WheelUp => [:wheel, 1], WheelDown => [:wheel, -1]}
            @map[k.i] = v
          end
          @enabled, @ntrigger_max, @buffer, @keys = false, 3, "\0"*28, (0...7).to_a
          @drag_enabled, @drag_auto_clear, @drag_start_size = false, false, 10
          clip
          initialize_sprites
        end
        def initialize_sprites
          return if @cursor and !@cursor.disposed?
          @cursor, @drag = Sprite.new, Sprite.new
          @cursor.z = @drag.z = 0x7FFFFFFF
          @cursor.visible, @drag.visible = @enabled, @enabled && @drag_enabled
          @cursor.bitmap = @default_icon = Bitmap.new(8,8)
          @cursor.bitmap.fill_rect(0, 0, 3, 7, c=Color.new(0,0,0))
          @cursor.bitmap.fill_rect(0, 0, 7, 3, c)
          @cursor.bitmap.fill_rect(5, 5, 3, 3, c)
          @cursor.bitmap.fill_rect(1, 1, 1, 5, c.set(255,255,255))
          @cursor.bitmap.fill_rect(1, 1, 5, 1, c)
          @cursor.bitmap.fill_rect(6, 6, 1, 1, c)
          @drag.bitmap = Bitmap.new(1,1)
          @drag.bitmap.set_pixel(0, 0, c.set(0,0,255,128))
          drag_clear
        end
        def enabled=(enabled)
          initialize_sprites
          drag_clear unless @enabled = enabled
          SetClassLong.call(HWND, -12, @enabled ? BlankCursor : 0)
          @cursor.visible, @drag.visible = @enabled, @enabled && @drag_enabled
        end
        def drag_enabled=(drag_enabled)
          initialize_sprites
          drag_clear unless @drag_enabled = drag_enabled
          @drag.visible = @enabled && @drag_enabled
        end
        def update
          return unless @enabled
          super
          initialize_sprites
          update_cursor
          update_drag
          update_clip
          update_wheel
        end
        def update_cursor
          GetCursorPos.call(@buffer)
          MapWindowPoints.call(0, HWND, @buffer, 1)
          @cursor.update
          @cursor.x, @cursor.y = *@buffer.unpack('ll')
        end
        def update_drag
          return unless @drag_enabled
          @drag.update
          if Left.trigger?
            drag_clear
            @drag_start_point = [@cursor.x, @cursor.y]
          elsif @drag_start_point and Left.press?
            x, y = *@drag_start_point
            w, h = @cursor.x-x, @cursor.y-y
            if w == 0 then w = 1 elsif w < 0 then x -= w *= -1 end
            if h == 0 then h = 1 elsif h < 0 then y -= h *= -1 end
            if dragging? or w > @drag_start_size or h > @drag_start_size
              @drag.x, @drag.y, @drag.zoom_x, @drag.zoom_y = x, y, w, h
            end
          elsif @drag_auto_clear and Left.release?
            drag_clear
          end
        end
        def update_clip
          ClipCursor.call(@buffer) if case @clip
          when String; MapWindowPoints.call(HWND, 0, @buffer.replace(@clip), 2)
          when      1; GetWindowRect.call(HWND, @buffer)
          when      2; GetClientRect.call(HWND, @buffer)
                       MapWindowPoints.call(HWND, 0, @buffer, 2)
          end
        end
        def update_wheel
          @wheel_state = PeekMessage.call(@buffer,HWND,0x020A,0x020A,0)>0 ?
                         @buffer.getbyte(11)==0 ? 1 : -1 : 0
        end
        def on?(x=nil, y=nil, w=nil, h=nil)
          if !@enabled; false
          elsif h; @cursor.x.between?(x, x+w) and @cursor.y.between?(y, y+h)
          elsif w; Math.hypot(x-@cursor.x, y-@cursor.y) <= w
          elsif y; @cursor.x == x and @cursor.y == y
          elsif x; on?(x.x, x.y, x.width, x.height)
          else     GetClientRect.call(HWND, @buffer); on?(*@buffer.unpack('l4'))
          end
        end
        def drag_on?(x, y=nil, w=nil, h=nil)
          if !@enabled or !@drag_enabled; false
          elsif h
            x < @drag.x+drag_width  and @drag.x < x+w and
            y < @drag.y+drag_height and @drag.y < y+h
          elsif w
            sw, sh = drag_width/2, drag_height/2
            x, y = (x-@drag.x-sw).abs, (y-@drag.y-sh).abs
            x<=sw+w and y<=sh+w and (x<=sw or y<=sh or Math.hypot(x-sw,y-sh)<=w)
          elsif y
            x.between?(@drag.x, @drag.x+drag_width) and
            y.between?(@drag.y, @drag.y+drag_height)
          else drag_on?(x.x, x.y, x.width, x.height)
          end
        end
        def icon(s=nil, ox=0, oy=0) @cursor.bitmap, @cursor.ox, @cursor.oy =
                                    s ? Cache.picture(s) : @default_icon, ox, oy end
        def clip(x=0, y=nil, w=0, h=0)
          ClipCursor.call(0)
          if x.is_a?(Rect); clip(x.x, x.y, x.width, x.height)
          else @clip = y ? [x, y, w+x, h+y].pack('l4x12') : x
          end
        end
        def click?(k=Left)  get_ntrigger(1, k2i(k))                           end
        def dclick?(k=Left) get_ntrigger(2, k2i(k))                           end
        def tclick?(k=Left) get_ntrigger(3, k2i(k))                           end
        def swap_button(b)  Keyboard.swap_mouse_button(b)                     end
        def x()             @cursor.x                                         end
        def x=(x)           set_pos(x, y)                                     end
        def y()             @cursor.y                                         end
        def y=(y)           set_pos(x, y)                                     end
        def dragging?()     @drag.zoom_x != 0                                 end
        def drag_x()        @drag.x                                           end
        def drag_y()        @drag.y                                           end
        def drag_width()    @drag.zoom_x.to_i                                 end
        def drag_height()   @drag.zoom_y.to_i                                 end
        def drag_rect()     Rect.new(drag_x, drag_y, drag_width, drag_height) end
        def drag_clear
          @drag_start_point = nil
          @drag.x = @drag.y = @drag.zoom_x = @drag.zoom_y = 0
        end
        def get_push(i)
          return false unless @enabled
          j, k = *@map[i]
          case j
          when :button; k.push?
          when :wheel ; k == @wheel_state
          else          false
          end
        end
        def get_toggle(i)
          return false unless @enabled
          j, k = *@map[i]
          case j
          when :button; k.toggle?
          else          false
          end
        end
      private
        def set_pos(x, y)
          @cursor.x, @cursor.y = x, y
          MapWindowPoints.call(HWND, 0, s=[x,y].pack('ll'), 1)
          SetCursorPos.call(*s.unpack('ll'))
        end
       
        singleton_attach_methods(@o = new)
        Keys.each {|k| k.o = @o}
        def self.o() @o end
      end
     
      class Text_Entry_Box < Sprite
        ::Text_Entry_Box = self
        SPECIAL_CHARS_CASE = {
          'à'=>'À', 'è'=>'È', 'ì'=>'Ì', 'ò'=>'Ò', 'ù'=>'Ù',
          'á'=>'Á', 'é'=>'É', 'í'=>'Í', 'ó'=>'Ó', 'ú'=>'Ú', 'ý'=>'Ý',
          'â'=>'Â', 'ê'=>'Ê', 'î'=>'Î', 'ô'=>'Ô', 'û'=>'Û',
          'ä'=>'Ä', 'ë'=>'Ë', 'ï'=>'Ï', 'ö'=>'Ö', 'ü'=>'Ü', 'ÿ'=>'Ÿ',
          'ã'=>'Ã',                     'õ'=>'Õ',                     'ñ'=>'Ñ',
        }
        def self.initialize
          @@boxes, @@last_icon = [], nil
          @@icon = [Bitmap.new(9,20), 4, 0] # [bmp, ox, oy]
          @@icon[0].fill_rect(0,  0, 9,  3, c=Color.new(0,0,0))
          @@icon[0].fill_rect(0, 17, 9,  3, c)
          @@icon[0].fill_rect(3,  3, 3, 14, c)
          @@icon[0].fill_rect(1,  1, 3,  1, c.set(255,255,255))
          @@icon[0].fill_rect(5,  1, 3,  1, c)
          @@icon[0].fill_rect(1, 18, 3,  1, c)
          @@icon[0].fill_rect(5, 18, 3,  1, c)
          @@icon[0].fill_rect(4,  2, 1, 16, c)
        end
        initialize
        attr_accessor :enabled, :mouse, :focus, :back_color, :select_color,
                      :text, :allow_c, :select, :case, :size_max, :width_max
        def initialize(width, height, viewport=nil)
          super(viewport)
          @back_color, @select_color = Color.new(0,0,0,0), Color.new(0,0,255,128)
          @text, @text_width, @allow_c = '', [], ''
          @enabled = @mouse = @select = true
          @case = @size_max = @width_max = @pos = @sel = @off = 0
          @text_chars = [] if RUBY_VERSION == '1.8.1'
          width = 640 if width > 640 and RUBY_VERSION == '1.9.2'
          self.bitmap = Bitmap.new(width, height)
          self.class.initialize if @@icon[0].disposed?
          @@boxes.delete_if {|s| s.disposed?}
          @focus = @@boxes.empty?
          @@boxes << self
        end
        def width()  bitmap.width                                      end
        def height() bitmap.height                                     end
        def font()   bitmap.font                                       end
        def font=(f) bitmap.font = f                                   end
        def hover?() Mouse.on?(x-ox, y-oy, width, height)              end
        def focus!() @@boxes.each {|s| s.focus = false}; @focus = true end
        def dispose
          super
          @@boxes.delete_if {|s| s.disposed?}
          Keyboard.stop_text_entry
          bitmap.dispose
        end
        def update
          super
          return unless @enabled
          update_mouse if @mouse
          return unless @focus
          if update_text_entry
            refresh
          elsif @mouse and (Mouse::WheelDown.press? or Mouse::WheelUp.press?)
            @off = Mouse::WheelDown.press? ? [@off-16, 0].max :
                   [@off+16, text_width(0, size)+1-width].min
            draw_text_box
          elsif Graphics.frame_count % 20 == 0
            draw_cursor(Graphics.frame_count % 40 == 0)
          end
        end
        def refresh
          tag = "#{font.name}#{font.size}#{font.bold}#{font.italic}"
          self.text, @last_font = @text, tag if @last_font != tag
          min = [text_width(0,@pos)+16-width, text_width(0,size)+1-width].min
          max = [text_width(0,@pos)-16, 0].max
          @off = [min, [@off, max].min].max
          @sel = 0 unless @select
          draw_text_box
        end
      private
        def update_mouse
          if hover = hover? and !@@last_icon
            @@last_icon = [Mouse.cursor.bitmap, Mouse.cursor.ox, Mouse.cursor.oy]
            Mouse.cursor.bitmap, Mouse.cursor.ox, Mouse.cursor.oy = *@@icon
          elsif @last_hover != hover and !@last_hover = hover and @@last_icon
            Mouse.cursor.bitmap, Mouse.cursor.ox, Mouse.cursor.oy = *@@last_icon
            @@last_icon = nil
          end
          if @mouse_select
            @sel, @mouse_select = @sel+@pos, Mouse::Left.press?
            @sel -= @pos = get_pos(Mouse.x-x+ox+@off, true)
          elsif Mouse::Left.trigger? and hover
            @pos, @sel, @mouse_select = get_pos(Mouse.x-x+ox+@off, true), 0, true
            Mouse.drag_clear
            focus!
          end
        end
        def update_text_entry
          if @mouse_select
            return false if @last_pos == @pos and @last_sel == @sel
            @last_pos, @last_sel = @pos, @sel
          elsif @sel != 0 and (Keyboard::Back.trigger? or Keyboard::Delete.trigger?)
            @pos -= @sel *= -1 if @sel < 0
            self[@pos, @sel], @sel = '', 0
          elsif @pos != 0 and Keyboard::Back.repeat?
            self[@pos -= 1, 1] = ''
          elsif @pos != size and Keyboard::Delete.repeat?
            self[@pos, 1] = ''
          elsif @pos != 0 and Keyboard::Up.trigger?
            @sel, @pos = @select && Keyboard::Shift.push? ? @sel+@pos : 0, 0
          elsif @pos != size and Keyboard::Down.trigger?
            @sel, @pos = @select && Keyboard::Shift.push? ? @sel+@pos-size : 0, size
          elsif @pos != 0 and Keyboard::Left.repeat?
            @pos, @sel = @pos-1, @select && Keyboard::Shift.push? ? @sel+1 : 0
          elsif @pos != size and Keyboard::Right.repeat?
            @pos, @sel = @pos+1, @select && Keyboard::Shift.push? ? @sel-1 : 0
          elsif !Keyboard.text_entry.empty?
            need_refresh, allowed_chars = false,
              @case==1 ? downcase(@allow_c) : @case==2 ? upcase(@allow_c) : @allow_c
            for c in Keyboard.text_entry.split(//)
              break if @size_max != 0 and @size_max <= size
              c = @case==1 ? downcase(c) : @case==2 ? upcase(c) : c
              next unless allowed_chars.empty? or allowed_chars.include?(c)
              _text, _pos, _sel = @text.dup, @pos, @sel if @width_max != 0
              @pos -= @sel *= -1 if @sel < 0
              self[@pos, @sel], @pos, @sel = c, @pos+1, 0
              if @width_max != 0 and text_width(0, size) > @width_max
                self.text, @pos, @sel = _text, _pos, _sel
                break
              end
              need_refresh = true
            end
            return need_refresh
          else return false
          end
          return true
        end
        def draw_text_box
          bitmap.fill_rect(bitmap.rect, @back_color)
          draw_selection if @sel != 0
          draw_text_entry
          draw_cursor(true)
        end
        def draw_selection
          pos, sel = @sel < 0 ? @pos+@sel : @pos, @sel.abs
          x, w, h = text_width(0,pos)-@off, text_width(pos,sel), font.size+2
          bitmap.fill_rect(x, (height-h)/2, w, h, @select_color)
        end
        def draw_cursor(blink)
          color = blink ? font.color : @back_color
          x, h = text_width(0, @pos)-@off, font.size+2
          bitmap.fill_rect(x, (height-h)/2, 1, h, color)
        end
        def draw_text_entry()
          bitmap.draw_text(-@off, 0, 0xFFFF, height, @text)
        end
        def downcase(str)
          str = str.downcase
          SPECIAL_CHARS_CASE.each {|d,u| str.gsub!(u, d)}
          str
        end
        def upcase(str)
          str = str.upcase
          SPECIAL_CHARS_CASE.each {|d,u| str.gsub!(d, u)}
          str
        end
        def text_width(i, j)
          @text_width[i] ||= bitmap.text_size(self[0, i]).width
          @text_width[i+j] ||= bitmap.text_size(self[0, i+j]).width
          @text_width[i+j] - @text_width[i]
        end
        def get_pos(x, round=false)
          return 0 if x <= 0
          return size if x >= text_width(0, size)
          size.times do |i|
            if (w = text_width(0,i+1)) > x
              return i unless round
              w -= text_width(i,1) / 2
              return w > x ? i : i+1
            end
          end
        end
        if RUBY_VERSION == '1.9.2'
          alias normal_draw_text_entry draw_text_entry
          def draw_text_entry
            if text_width(0, size) > 640
              a, b = get_pos(@off), get_pos(@off+width)
              b += 1 if b != size and text_width(a, b+1-a) <= 640
              a += 1 if text_width(a, b-a) > 640
              x = text_width(0,a)-@off
              bitmap.draw_text(x, 0, 0xFFFF, height, self[a, b-a])
            else normal_draw_text_entry
            end
          end
          def [](i, j) @text[i, j] end
          def []=(i, j, str)
            @text[i, j] = str
            @text_width[i, @text_width.size-i] = Array.new(size-i)
          end
        public
          def size()   @text.size  end
          def text=(str)
            str = @case==1 ? downcase(str) : @case==2 ? upcase(str) : str
            @text_width = Array.new(str.size)
            @text = str
          end
        else
          def [](i, j) @text_chars[i, j].join('') end
          def []=(i, j, str)
            @text_chars[i, j] = str.empty? ? nil : str
            @text_width[i, @text_width.size-i] = Array.new(size-i)
            @text.replace(@text_chars.join(''))
          end
        public
          def size()   @text_chars.size           end
          def text=(str)
            str = @case==1 ? downcase(str) : @case==2 ? upcase(str) : str
            @text_chars.replace(str.split(//))
            @text_width = Array.new(@text_chars.size)
            @text = str
          end
        end
      end
     
      def self.[](i) Players[i] end
      def self.update
        Keyboard.update
        Mouse.update
        Gamepads.each {|g| g.update}
        Players.each {|p| p.update}
      end
      def self.refresh
        Gamepads.clear
        x360_pads = XBox360_Gamepad::DLL ? Array.new(4) {|i| XBox360_Gamepad.new(i)} : []
        x360_pads.sort! {|a,b| (a.unplugged ? 1 : 0) <=> (b.unplugged ? 1 : 0)}
        devcaps = "\0"*404
        16.times do |i|
          Multimedia_Gamepad::JoyGetDevCaps.call(i, devcaps, 404)
          mid = devcaps.unpack('S')[0]
          if mid == 1118 and !x360_pads.empty?
            Gamepads << x360_pads.shift
          elsif mid != 0
            Gamepads << Multimedia_Gamepad.new(i)
          end
        end
        Gamepads.sort! {|a,b| (a.unplugged ? 1 : 0) <=> (b.unplugged ? 1 : 0)}
        Gamepads.each {|g| g.enabled = false}
        Players.each {|p| p.gamepad_id += 0}
      end
     
      # Le rythme de la fonction repeat? quand on maintient une touche appuyée.
      # La fonction repeat? est utilisée dans les menus pour bouger le curseur par exemple.
      f = Graphics.frame_rate
      REPEAT = [ # (se lit de bas en haut)
        #[f*4, 1],           # Après 4 secondes retourne toujours true.
        #[f*2, f*0.05],    # Après 2 secondes retourne true toutes les 0.05 secondes.
        [f*0.4, f*0.1], # Après 0.4 secondes retourne true toutes les 0.1 secondes.
        [2, 0],       # ...puis retourne false (à partir de la 2ème frame).
        [1, 1]      # Retourne true quand on vient d'appuyer (la 1ère frame)...
      ]
      PLAYERS_MAX = 1 # Le nombre de joueurs pour les jeux multijoueurs.
      KEYS_MAX = 30 # Nombre de touches, on peut mettre un très grand nombre si on
                    # veut mais le limiter au minimum sert à optimiser la mémoire.
     
      Gamepads, Players = [], Array.new(PLAYERS_MAX) {|i| Player.new(i)}
      singleton_attach_methods(Players[0])
      class Player
        Keys = Array.new(KEYS_MAX) {|i| Player_Key.new(i)}
        # Les différentes touches du jeu (id entre 0 et KEYS_MAX-1).
        DOWN  = Keys[2]
        LEFT  = Keys[4]
        RIGHT = Keys[6]
        UP    = Keys[8]
        A     = Keys[11]
        B     = Keys[12]
        C     = Keys[13]
        X     = Keys[14]
        Y     = Keys[15]
        Z     = Keys[16]
        L     = Keys[17]
        R     = Keys[18]
        SHIFT = Keys[21]
        CTRL  = Keys[22]
        ALT   = Keys[23]
        F5    = Keys[25]
        F6    = Keys[26]
        F7    = Keys[27]
        F8    = Keys[28]
        F9    = Keys[29]
       
        constants.each {|s| Input.const_set(s,k=const_get(s)); k.s = s.to_s if k.is_a?(Key)}
      end
     
      # La config par défaut des touches.
      # En cas de jeu multijoueur il en faut une différente pour chaque joueur.
      # Liste des touches du clavier ligne 862.
      # Liste des touches XBox360 ligne 689, pour manette random ligne 681.
      # Mais inutile de mettre les deux, par exemple :A et :Button1 sont la même
      # touche, si moi j'utilise celles d'XBox c'est juste parce que ça me semble
      # plus logique de régler les touches par rapport à une config connue.
      # Le mieux étant de faire un menu où le joueur peut configurer lui même tout ça.
      # Le format est très simple, à gauche les touches virtuelles du jeu, à droite
      # un tableau des touches correspondantes séparé en deux, 1ère colonne les
      # touches de la manette, 2ème colonne les touches du clavier.
      # Pour les jeux multijoueurs la config des manettes se fait pareillement pour
      # tous, la différenciation des manettes se fait en interne.
      # Config du joueur 1 :
      Players[0].setup(
        :DOWN  => [ [:AxisLY_0, :DPadDown] , [:Down]                 ],
        :LEFT  => [ [:AxisLX_0, :DPadLeft] , [:Left]                 ],
        :RIGHT => [ [:AxisLX_1, :DPadRight], [:Right]                ],
        :UP    => [ [:AxisLY_1, :DPadUp]   , [:Up]                   ],
        :A     => [ [:X]                   , [:Z, :Shift]            ],
        :B     => [ [:Y]                   , [:X, :NumPad0, :Escape] ],
        :C     => [ [:A]                   , [:C, :Enter, :Space]    ],
        :X     => [ [:B]                   , [:A]                    ],
        :Y     => [ [:LT]                  , [:S]                    ],
        :Z     => [ [:RT]                  , [:D]                    ],
        :L     => [ [:LB]                  , [:Q, :PageUp]           ],
        :R     => [ [:RB]                  , [:W, :PageDown]         ],
        :SHIFT => [ []                     , [:Shift]                ],
        :CTRL  => [ []                     , [:Control]              ],
        :ALT   => [ []                     , [:Alt]                  ],
        :F5    => [ []                     , [:F5]                   ],
        :F6    => [ []                     , [:F6]                   ],
        :F7    => [ []                     , [:F7]                   ],
        :F8    => [ []                     , [:F8]                   ],
        :F9    => [ []                     , [:F9]                   ])
     
      refresh
      update
      Keyboard.release!(0...256) if Keyboard.push?(*0...256)
    end
 
 



EDIT : Merci beaucoup daheji, j'ai suivis ta piste et ai finalement trouver une solution:
à la ligne 381 du Script Sideview 2
j'ai ajouté ceci

Portion de code : Tout sélectionner

1
2
3
4
5
6
7
 if Input.trigger?(Input::Y)
      $game_system.se_play($data_system.decision_se)
        @active_battler.current_action.kind = 0
        @active_battler.current_action.basic = 1
        phase3_next_actor
        return
        end



Et ça marche parfaitement, j'ai plus qu'a supprimer la commande initial pour qu'elle n’apparaisse plus dans les choix!

Merci encore !! :D

Malus


erudit0 - posté le 06/02/2014 à 16:03:53 (128 messages postés)

❤ 0

EVA Unit #5555

Tu veux bien POSTER le script?


Malus777 - posté le 06/02/2014 à 16:43:10 (6 messages postés)

❤ 0

Maker sous XP

Bonjour erudit0.
Tout d'abord sache que les majuscules en écriture sont considérées comme un cris, du coup quand tu écris "POSTER" tu t'exprime de manière agressive ce qui est impoli.
Et le script ne concerne que l'aspect graphique du système de combat et la jauge ATB, il n'est donc inutile de le poster pour ma demande (en plus il est beaucoup trop long)
Mais merci de ta réponse.

Malus


Joke - posté le 07/02/2014 à 12:35:56 (5089 messages postés)

❤ 0

Bilouteux fou

Bonjour Malus777.
Tout d'abord sache que le bouton "up !" sert à signaler que tu as modifié ton dernier message au lieu d'en poster un deuxième (ce qui n'est pas autorisé), sinon, lorsque tu es en attente d'une réponse et que ton topic est malheureusement enterré. Il n'est pas utile d'upper un topic qui est déjà en tête de liste, et par conséquent tu agis de manière insistante, ce qui est impoli.
Mais encore, la manière avec laquelle tu formule ta petite leçon d'expression relève en apparence d'un caractère plutôt insolent et prétentieux, mais ce n'est certainement qu'une maladresse.
Sache alors que les "majuscules" utilisées ici s'appellent des lettres capitales en écriture, elles ne sont pas forcément considérées comme un cri, mais plutôt comme un haussement de la voix, et plus généralement, elles servent à mettre une phrase ou partie EN ÉVIDENCE au même titre que le gras et le soulignement.
Vas-tu trouver ton journal agressif et impoli si par malheur tu te retrouvais à lire des titres et phrases d'accroche en lettres capitales ?
En toute amitié.

biloumaster.fr, mon joli site ouèb tout bô tout frai !


verehn - posté le 07/02/2014 à 13:21:57 (9056 messages postés) - honor -

❤ 0

Vhehrhehn

Les "up" sont en fait dus à Erudito, membre banni qui fait sa petite guéguerre contre le staff en repostant les messages supprimés de ses mutliples comptes. Entre deux complexes de "je suis djézus derrière mon pc" :hihi

En ce qui concerne la manière dont Malus a pris le "haussement de ton" d'Erudito, c'est assez relatif, ça reste plutôt maîtrisé, je ne sais pas si on peut qualifier ça d'insolence. Merci pour ta tentative de médiation dans tous les cas ;)

Eldrao ~ PakuPaku ~ Winged Light ~ Ruin ~ Ma galerie ~ LTDAD ~ Don de graphismes plateforme 2D


Joke - posté le 07/02/2014 à 14:02:24 (5089 messages postés)

❤ 0

Bilouteux fou

verehn a dit:

Merci pour ta tentative de médiation dans tous les cas ;)

J'avais juste envie d'incendier Malus en toute courtoisie :wouah

biloumaster.fr, mon joli site ouèb tout bô tout frai !


daheji - posté le 07/02/2014 à 18:20:32 (278 messages postés)

❤ 0

Poste un lien vers le script quand même. :3 Parce que ce SBS ne change pas que l'aspect graphique ou permet d'utiliser la jauge ATB, c'est un système de combat différent de celui de base. En gros, il le remplace. Il a son propre menu et tout (même s'il est similaire à celui par défaut). D:

Je suis allé vérifier moi-même dans le script que j'ai téléchargé il y a longtemps. X] Le menu de combat se trouve dans Sideview 2 > A partir de la ligne 45. D: Après je ne peux pas en dire plus parce que j'y connais quasiment rien en script.

Site officiel de Version Fille ! | Topic de Version Fille | Mon Twitter

Index du forum > Entraide > [RMXP] Assigner une commande directement à une touche en combat

repondre up

Suite à de nombreux abus, le post en invités a été désactivé. Veuillez vous inscrire si vous souhaitez participer à la conversation.

Haut de page

Merci de ne pas reproduire le contenu de ce site sans autorisation.
Contacter l'équipe - Mentions légales

Plan du site

Communauté: Accueil | Forum | Chat | Commentaires | News | Flash-news | Screen de la semaine | Sorties | Tests | Gaming-Live | Interviews | Galerie | OST | Blogs | Recherche
Apprendre: Visite guidée | RPG Maker 95 | RPG Maker 2003 | RPG Maker XP | RPG Maker VX | RPG Maker MV | Tutoriels | Guides | Making-of
Télécharger: Programmes | Scripts/Plugins | Ressources graphiques / sonores | Packs de ressources | Midis | Eléments séparés | Sprites
Jeux: Au hasard | Notre sélection | Sélection des membres | Tous les jeux | Jeux complets | Le cimetière | RPG Maker 95 | RPG Maker 2000 | RPG Maker 2003 | RPG Maker XP | RPG Maker VX | RPG Maker VX Ace | RPG Maker MV | Autres | Proposer
Ressources RPG Maker 2000/2003: Chipsets | Charsets | Panoramas | Backdrops | Facesets | Battle anims | Battle charsets | Monstres | Systems | Templates
Ressources RPG Maker XP: Tilesets | Autotiles | Characters | Battlers | Window skins | Icônes | Transitions | Fogs | Templates
Ressources RPG Maker VX: Tilesets | Charsets | Facesets | Systèmes
Ressources RPG Maker MV: Tilesets | Characters | Faces | Systèmes | Title | Battlebacks | Animations | SV/Ennemis
Archives: Palmarès | L'Annuaire | Livre d'or | Le Wiki | Divers