zoukankan      html  css  js  c++  java
  • MaxScript调用DirectInput获取按键状态

    代码
    DotNet.loadAssembly "Microsoft.VisualBasic.dll"
    DotNet.loadAssembly
    "Microsoft.DirectX.DirectInput.dll"

    SystemGuid
    = DotNetClass "Microsoft.DirectX.DirectInput.SystemGuid"
    KeyboardDevice
    = DotNetObject "Microsoft.DirectX.DirectInput.Device" SystemGuid.Keyboard

    CooperativeLevelFlags
    = DotNetClass "Microsoft.DirectX.DirectInput.CooperativeLevelFlags"

    Operators
    = DotNetClass "Microsoft.VisualBasic.CompilerServices.Operators"

    theCooperativeLevelFlags
    = Operators.OrObject CooperativeLevelFlags.Background CooperativeLevelFlags.NonExclusive

    MaxHWND
    = DotNetObject "System.IntPtr" (Windows.getMAXHWND() as integer)

    KeyboardDevice.SetCooperativeLevel MaxHWND theCooperativeLevelFlags
    KeyboardDevice.Acquire()

    KeyboardState
    = KeyboardDevice.GetCurrentKeyboardState()


    DxKey
    = DotNetClass "Microsoft.DirectX.DirectInput.Key"

    KeyboardState.item dxkey.x
    dxkey.a


    --KeyboardDevice.Dispose()


    rollout test
    ""
    (
    timer clock
    "testClock" interval:300 --tick once a second
    label test
    ""
    on clock tick
    do
    (
    enableAccelerators = false
    KeyboardState = KeyboardDevice.GetCurrentKeyboardState()
    test.text
    = (KeyboardState.item dxkey.a) as string
    )
    )
    createdialog test
    Windows.getMAXHWND()是Max2008新增的函数,故需要Max2008版本,max9可用的过段时间再写,因为这是一个朋友需要的东西,所以,我不急.....
  • 相关阅读:
    Pyhon的json库常用方法
    常用的Python操作
    Leetcode: 1301.Number of Paths with Max Score
    redis 源码阅读杂记
    二分查找性能试验
    leetcode: 600. Non-negative Integers without Consecutive Ones
    Leetcode: 902. Numbers At Most N Given Digit Set
    leetcode:956. Tallest Billboard
    innodb 插入性能简单测试
    redis 源码阅读之 redis.c
  • 原文地址:https://www.cnblogs.com/sitt/p/1868082.html
Copyright © 2011-2022 走看看