Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import gremlin
- from gremlin.user_plugin import *
- active_mode = ModeVariable(
- "Mode",
- "Mode in which buttons will be asserted"
- )
- btn_1_in = PhysicalInputVariable(
- "Button Up In",
- "Button which is mapped to the up direction of the hat.",
- [gremlin.common.InputType.JoystickButton]
- )
- btn_2_in = PhysicalInputVariable(
- "Button Right In",
- "Button which is mapped to the right direction of the hat.",
- [gremlin.common.InputType.JoystickButton]
- )
- btn_3_in = PhysicalInputVariable(
- "Button Down In",
- "Button which is mapped to the down direction of the hat.",
- [gremlin.common.InputType.JoystickButton]
- )
- btn_4_in = PhysicalInputVariable(
- "Button Left In",
- "Button which is mapped to the left direction of the hat.",
- [gremlin.common.InputType.JoystickButton]
- )
- btn_5_in = PhysicalInputVariable(
- "Button Depress In",
- "Button which is mapped to the depress direction of the hat.",
- [gremlin.common.InputType.JoystickButton]
- )
- btn_1_out = VirtualInputVariable(
- "Button Up Out",
- "Button which will be mapped to the up direction of the hat.",
- [gremlin.common.InputType.JoystickButton]
- )
- btn_2_out = VirtualInputVariable(
- "Button Right Out",
- "Button which will be mapped to the right direction of the hat.",
- [gremlin.common.InputType.JoystickButton]
- )
- btn_3_out = VirtualInputVariable(
- "Button Down Out",
- "Button which will be mapped to the down direction of the hat.",
- [gremlin.common.InputType.JoystickButton]
- )
- btn_4_out = VirtualInputVariable(
- "Button Left Out",
- "Button which will be mapped to the left direction of the hat.",
- [gremlin.common.InputType.JoystickButton]
- )
- btn_5_out = VirtualInputVariable(
- "Button Depress Out",
- "Button which will be mapped to the left direction of the hat.",
- [gremlin.common.InputType.JoystickButton]
- )
- joystick_decorator = btn_1_in.create_decorator(active_mode.value)
- button_pressed = False
- @joystick_decorator.button(btn_1_in.input_id)
- def button_1(event, joy, vjoy):
- global button_pressed
- if event.is_pressed and not button_pressed:
- vjoy[btn_1_out.value["device_id"]].button(btn_1_out.value["input_id"]).is_pressed = True
- button_pressed = True
- elif vjoy[btn_1_out.value["device_id"]].button(btn_1_out.value["input_id"]).is_pressed:
- vjoy[btn_1_out.value["device_id"]].button(btn_1_out.value["input_id"]).is_pressed = False
- button_pressed = False
- button_2(joy[btn_2_in.value["device_id"]].button(btn_2_in.value["input_id"]), joy, vjoy)
- if not button_pressed:
- button_4(joy[btn_4_in.value["device_id"]].button(btn_4_in.value["input_id"]), joy, vjoy)
- @joystick_decorator.button(btn_2_in.input_id)
- def button_2(event, joy, vjoy):
- global button_pressed
- if event.is_pressed and not button_pressed:
- vjoy[btn_2_out.value["device_id"]].button(btn_2_out.value["input_id"]).is_pressed = True
- button_pressed = True
- elif vjoy[btn_2_out.value["device_id"]].button(btn_2_out.value["input_id"]).is_pressed:
- vjoy[btn_2_out.value["device_id"]].button(btn_2_out.value["input_id"]).is_pressed = False
- button_pressed = False
- button_1(joy[btn_1_in.value["device_id"]].button(btn_1_in.value["input_id"]), joy, vjoy)
- if not button_pressed:
- button_3(joy[btn_3_in.value["device_id"]].button(btn_3_in.value["input_id"]), joy, vjoy)
- @joystick_decorator.button(btn_3_in.input_id)
- def button_3(event, joy, vjoy):
- global button_pressed
- if event.is_pressed and not button_pressed:
- vjoy[btn_3_out.value["device_id"]].button(btn_3_out.value["input_id"]).is_pressed = True
- button_pressed = True
- elif vjoy[btn_3_out.value["device_id"]].button(btn_3_out.value["input_id"]).is_pressed:
- vjoy[btn_3_out.value["device_id"]].button(btn_3_out.value["input_id"]).is_pressed = False
- button_pressed = False
- button_2(joy[btn_2_in.value["device_id"]].button(btn_2_in.value["input_id"]), joy, vjoy)
- if not button_pressed:
- button_4(joy[btn_4_in.value["device_id"]].button(btn_4_in.value["input_id"]), joy, vjoy)
- @joystick_decorator.button(btn_4_in.input_id)
- def button_4(event, joy, vjoy):
- global button_pressed
- if event.is_pressed and not button_pressed:
- vjoy[btn_4_out.value["device_id"]].button(btn_4_out.value["input_id"]).is_pressed = True
- button_pressed = True
- elif vjoy[btn_4_out.value["device_id"]].button(btn_4_out.value["input_id"]).is_pressed:
- vjoy[btn_4_out.value["device_id"]].button(btn_4_out.value["input_id"]).is_pressed = False
- button_pressed = False
- button_1(joy[btn_1_in.value["device_id"]].button(btn_1_in.value["input_id"]), joy, vjoy)
- if not button_pressed:
- button_3(joy[btn_3_in.value["device_id"]].button(btn_3_in.value["input_id"]), joy, vjoy)
- @joystick_decorator.button(btn_5_in.input_id)
- def button_5(event, joy, vjoy):
- if event.is_pressed and not button_pressed:
- vjoy[btn_5_out.value["device_id"]].button(btn_5_out.value["input_id"]).is_pressed = True
- else:
- vjoy[btn_5_out.value["device_id"]].button(btn_5_out.value["input_id"]).is_pressed = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement