USB HID Buttons and Axis, (Gamepad / Joystick) for PDS. Work in progress - Page 4


+ Reply to Thread
Page 4 of 4 FirstFirst ... 234
Results 46 to 53 of 53
  1. #46
    Kapitan
    Guest Kapitan's Avatar

    0 Not allowed!

    Default Re: I just decided to post this here.

    @Joseph
    It works Joseph !, will post the stuff later, or in the morning, there is nothing wrong with the mouse bas mods..no changes need to be added, as said, it worked with the mouse, so should work, and does, with the rest... it was a 'Physical' collection declaration...
    will sort it out and update the files...
    I have attached the working code, if you want to experiment, there are only buttons, 32, but comms are fine. buffer size is 4 bytes, for the buttons. so at least you can test the controls.
    Joe.
    Attached Files Attached Files

Attention

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #47
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,466
    Thumbs Up
    Received: 71
    Given: 29
    Total Downloaded
    6.08 GB

    0 Not allowed!

    Default Re: I just decided to post this here.

    Joe,

    You do not have the .bas file please?

    Regards

    Joseph

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #48
    Kapitan
    Guest Kapitan's Avatar

    0 Not allowed!

    Default USB HID Joystick / Game Controller

    Sorry Joseph, here 'tis. will sort the rest hopefully today.

    Code:
    '
    ' Demonstrate a HID (Human Interface Device) interface Game Controller  - Modded by Joe Hanley - [email protected]
    '
    ' 
    
        Device = 18F4550                                ' Choose a device with on-board full speed USB
        Xtal = 48                                        ' Set the oscillator speed to 48MHz (using a 20MHz crystal)
        All_Digital = TRUE
    
        'USB_Descriptor = "JoeJSDesc3.inc"
       USB_Descriptor = "MousDescjoe.inc"
        Dim PP0 As Byte System                            ' USBPOLL status return
        Dim BUFFER[4]   As Byte
        'Dim Buffer As Byte
        Dim LOOP_COUNT    As    Byte
        Dim POSITION    As    Byte
        Dim INDEX As Byte'Word
        
        Symbol CARRY_FLAG = STATUS.0                    ' High if microcontroller does not have control over the DP buffer
        Symbol TRNIF = UIR.3                            ' Low if USB Busy
         TRISD=0
    '------------------------------------------------------------------------
    ' The main program loop starts here 
       
        DelayMS 200                                            ' Wait for things to stabilise
        Clear                                                ' Clear all RAM before we start   
    'Buffer = 240
    BUFFER[0]  =1
    BUFFER[1]  =128
    BUFFER[2]  =1
    BUFFER[3]  =255
    'BUFFER[4]  =100
    'BUFFER[5]  =100
    'BUFFER[6]  =100
    'BUFFER[7]  =100
    'BUFFER[8]  =100
    'BUFFER[9]  =100
    'BUFFER[10] =100
    'BUFFER[11]    =100
        Repeat                                                ' \
            USBPoll                                            '   Wait for the USB interface to become attached
        Until PP0 = %00000110                                ' /
        
        While 1 = 1
    
    'DelayMS 2
    '        For POSITION = 0 To 3                            ' Move through each position
    '            For LOOP_COUNT = 0 To 31                    ' 32 steps in each direction
    '                Select POSITION
    '                    Case 0                                ' Move UP ?
    '                        BUFFER#1 = 0
    '                        BUFFER#2 = -2
    '                    Case 1                                ' Move RIGHT ?
    '                        BUFFER#1 = 2
    '                        BUFFER#2 = 0
    '                    Case 2                                ' Move DOWN ?
    '                        BUFFER#1 = 0
    '                        BUFFER#2 = 2
    '                    Case 3                                ' Move LEFT ?
    '                        BUFFER#1 = -2
    '                        BUFFER#2 = 0
    '                End Select
    'DelayMS 2
                
                    Repeat
                        USBOut 1, BUFFER, 4                 ' Send the buffer to endpoint 1
                    Until CARRY_FLAG = 0                    ' Keep trying if the microcontroller does not have control over the buffer
                    Repeat : Until TRNIF = 1                ' Wait for completion before continuing
    Inc INDEX
    If INDEX > 127 Then
    High PORTD.0
    Else
    Low PORTD.0
    EndIf
    
    '            Next
    '        Next
        Wend
        
      End

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #49
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,466
    Thumbs Up
    Received: 71
    Given: 29
    Total Downloaded
    6.08 GB

    0 Not allowed!

    Default Re: USB HID Joystick / Game Controller

    Hi Joe,

    Thank you very much for the code.
    I posted this here so hopefully the other thread will not get too big. Your code works great, I can have comunication with USB, LED is flashing and can see the different positions of the axis.

    I am trying to understand the descriptor file to make things working now. You mentioned a 10 bit resolution. -127 to 127 is 8 bit, correct or am I missing something?

    Regards

    Joseph

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #50
    Kapitan
    Guest Kapitan's Avatar

    0 Not allowed!

    Default Re: USB HID Joystick / Game Controller

    Quote Originally Posted by joesaliba View Post
    Hi Joe,

    Thank you very much for the code.
    I posted this here so hopefully the other thread will not get too big. Your code works great, I can have comunication with USB, LED is flashing and can see the different positions of the axis.

    I am trying to understand the descriptor file to make things working now. You mentioned a 10 bit resolution. -127 to 127 is 8 bit, correct or am I missing something?

    Regards

    Joseph
    Hiya Joseph, no, you are not missing anything lol, apart from my lack of understanding at the moment haha.. I can pad the output - or actually, input, for 10 bits, but am still having a few issues with the padding... so should be, and indeed, is, perfectly possible to use full 10 bit, providing one uses the full travel of the pot or sensor.

    The basic thing is that the descriptor sends (as far as I understand it) byte chunks, or multiples of, so, if one uses 10 bits, then you need to pad the other 6 bits.. or, combine inputs to multiple bytes overlapping which I am trying to avoid, because it is not needed....
    I am afraid, at the moment, it is one step at a time , get it working, get it communicating, then adapt, overcome etc etc....
    we are getting there.... again, sorry for delay, but maybe tomorrow, my brain is fried lol... it is all possible...
    Joe

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #51
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,466
    Thumbs Up
    Received: 71
    Given: 29
    Total Downloaded
    6.08 GB

    0 Not allowed!

    Default Re: USB HID Joystick / Game Controller

    Hi,

    I did a small test to see if the bar in the joystick actually move. I added: -

    Inc BUFFER[0]

    If BUFFER[0] = 128 Then BUFFER[0] = -127

    in the main loop, and yes, it actually goes from one side to the other.

    What cannot understand is, if BUFFER is a Byte, how it can accept the -127? As I know it, a Byte in PDS range from 0 to 255, correct?

    Regards

    Joseph

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #52
    Kapitan
    Guest Kapitan's Avatar

    0 Not allowed!

    Default Re: USB HID Joystick / Game Controller

    Yes, it is interesting, if you look at the mouse demo, Les uses negative values in a byte, I presume therfore it is a two's compliment, but can find no reference to it in the PDS manual... it certainly works though.. If you replace the -ve value with its 2's compliment it also works, but using the - sign is easier. Didnt know PDS did that !

    Also, note the correct order for the buffer, !!.. corrected. also note that even theough the slider and dial are placed at axis 7 an 8 on the control panel of game controllers, the buffer order is reversed for these two, its just how it is changing the order in the descriptor makes no difference.
    So, our first 6 bytes (buffer 0 to 5) are the axis AFTER the X/Y pointer (Main Joystick axis) and X/Y are bytes 7 and 8. (buffer 6 and 7)
    I am still at a loss to get the hat to work in 8 directions, only 4 so far, but will keep reading / experimenting, it IS possible..


    BUFFER[0] =-110 ; Z AXIS ALL Axis are -127 to 127, 0 is middle.
    BUFFER[1] =-80 ; rX AXIS
    BUFFER[2] =-40 ; rY AXIS
    BUFFER[3] =0 ; rZ AXIS
    BUFFER[4] =80 ; Dial
    BUFFER[5] =40 ;Slider
    BUFFER[6] =127 ; X AXIS
    BUFFER[7] =127 ; Y AXIS
    BUFFER[8] =255 ; Buttons 1 to 8
    BUFFER[9] =101 ; Buttons 9 to 16
    BUFFER[10] =1 ; Buttons 17 to 24
    BUFFER[11] =10 ; Buttons 25 to 32
    BUFFER[12] =1 ; HAT (Lower NIBBLE ONLY !!!!)
    Joe.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #53
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,466
    Thumbs Up
    Received: 71
    Given: 29
    Total Downloaded
    6.08 GB

    0 Not allowed!

    Default Re: USB HID Joystick / Game Controller

    Joe,

    I am in hurry right now. Send me the new descriptor and bas file for the hat and I will try something.

    Regards


    Joseph

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. PDS USB HID Wizard 2.0.2
      By hadv215 in forum hadv215's Feedback Forum
      Replies: 2
      Last Post: 6th January 2014, 22:02
    2. Replies: 0
      Last Post: 5th January 2011, 17:08
    3. USB Joystick, some progress, some links..
      By Kapitan in forum The Lounge
      Replies: 0
      Last Post: 21st December 2010, 11:11
    4. [SOLVED !] Joystick HID USB for PC from PIC ? anyone aany info
      By Kapitan in forum The Lounge
      Replies: 7
      Last Post: 7th November 2010, 16:37
    5. [SOLVED !] Data Entry...Work in Progress
      By ~ Sy ~ in forum The Lounge
      Replies: 13
      Last Post: 24th October 2009, 18:19

    Members who have read this thread since 7th December 2019, 06:51 : 0

    Actions :  (Set Date)  (Clear Date)

    You do not have permission to view the list of names.

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts