~fireclawthefox/panda3dcodecollection/trunk

« back to all changes in this revision

Viewing changes to character/extended Char controller/demo.py

  • Committer: Fireclaw the Fox
  • Date: 2017-02-08 14:26:21 UTC
  • Revision ID: fireclawthefox@gmail.com-20170208142621-ljorcvore5ivwutx
Added gamepad support

- Panda3D's integrated gamepad support (preview, needs panda3d binaries build from input-overhaul branch)
- Added pyglet gamepad sample
- enhanced graphics for the extended Char controller demo

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
loadPrcFileData("","""
56
56
model-path $MAIN_DIR/testmodel
57
57
cursor-hidden 1
 
58
on-screen-debug-enabled #f
58
59
""")
59
60
 
60
61
class Main(ShowBase):
67
68
        self.accept("r", self.resetPlayer)
68
69
        self.accept("p", self.togglePause)
69
70
        self.accept("f2", self.toggleCamera)
 
71
        #def printsomething():
 
72
        #    print "something"
 
73
        #self.accept("gamepad1-action_a", printsomething)
70
74
        self.disableMouse()
71
75
 
72
76
        self.useBullet = USEBULLET
197
201
        # DEBUGGING
198
202
        #
199
203
        # NOTE: To add output to the OSD, see debugOSDUpdater below
 
204
        #       also make sure to set on-screen-debug-enabled to #t in
 
205
        #       the loadPrcFileData call given in the upper part of
 
206
        #       this file
200
207
        from direct.showbase.OnScreenDebug import OnScreenDebug
201
208
        self.osd = OnScreenDebug()
202
209
        self.osd.enabled = True
277
284
        # be updated every frame
278
285
        #self.osd.add("Rotation", str(self.platforms[4].getH()))
279
286
        #self.osd.add("Speed", str(self.p.update_speed))
 
287
 
 
288
 
 
289
        #
 
290
        # GAMEPAD DEBUGGING
 
291
        #
 
292
        #gamepads = self.p.gamepad.gamepads
 
293
 
 
294
 
 
295
        #from panda3d.core import ButtonHandle
 
296
        #self.osd.add("0 - GAMEPAD:", gamepads[0].name)
 
297
        #self.osd.add("TEST STATE:", str(ButtonHandle("action_a")))
 
298
        #self.osd.add("HANDLE INDEX:", str(ButtonHandle("action_a").get_index()) + " " + str(gamepads[1].get_button_map(6).get_index()))
 
299
        #self.osd.add("STATE BY HANDLE:", str(gamepads[0].findButton(ButtonHandle("action_b")).state))
 
300
        #self.osd.add("MAP at 6:", str(gamepads[1].get_button_map(6)))
 
301
        #self.osd.add("MY MAP:", str(self.p.gamepad.deviceMap["sprint"]))
 
302
        #self.osd.add("BUTTON STATE 6:", str(gamepads[0].get_button(6).state))
 
303
 
280
304
        self.osd.render()
281
305
        return task.cont
282
306