Reading serial data from a USB Gamepad

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
qp
Reply | Threaded
Open this post in threaded view
|

Reading serial data from a USB Gamepad

qp
Hi,

I want to read USB data from a Gamepad in Erlang to play a game.

Programs like JoyToKey and Enjoyable convert Gamepad inputs to keyboard input, but they only send 1 character so using io:read would require an additional "return" press to send the input.

Where do I start looking to learn how to read gamepads? I've heard that Erlang ports can be used to interact with the world outside the Erlang shell but I have no idea where to look. I found erlang-serial on Github but had trouble installing it https://github.com/tonyg/erlang-serial/issues/14

Thank you!

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Reading serial data from a USB Gamepad

József Bérces (LA/ETH)

You can give a try to this one:

http://github.com/tomszilagyi/gen_serial

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of qp
Sent: Sunday, March 12, 2017 17:57
To: Erlang/OTP discussions <[hidden email]>
Subject: [erlang-questions] Reading serial data from a USB Gamepad

 

Hi,

I want to read USB data from a Gamepad in Erlang to play a game.

Programs like JoyToKey and Enjoyable convert Gamepad inputs to keyboard input, but they only send 1 character so using io:read would require an additional "return" press to send the input.

Where do I start looking to learn how to read gamepads? I've heard that Erlang ports can be used to interact with the world outside the Erlang shell but I have no idea where to look. I found erlang-serial on Github but had trouble installing it https://github.com/tonyg/erlang-serial/issues/14

Thank you!


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
qp
Reply | Threaded
Open this post in threaded view
|

Re: Reading serial data from a USB Gamepad

qp
I get make errors with that one

/usr/local/bin/erlang/lib/gen_serial:../make.sh
Recompile: src/gen_serial_test
Recompile: src/gen_serial
gcc -Wall -O2 -g -ggdb -c -o ../erlang_serial.o ../erlang_serial.c
gcc -Wall -O2 -g -ggdb -c -o posix_main.o posix_main.c
posix_main.c:84:30: error: use of undeclared identifier 'B460800'
        case 460800: tio.c_cflag |= B460800; break;
                                    ^
posix_main.c:85:30: error: use of undeclared identifier 'B500000'
        case 500000: tio.c_cflag |= B500000; break;
                                    ^
posix_main.c:86:30: error: use of undeclared identifier 'B576000'
        case 576000: tio.c_cflag |= B576000; break;
                                    ^
posix_main.c:87:30: error: use of undeclared identifier 'B921600'
        case 921600: tio.c_cflag |= B921600; break;
                                    ^
posix_main.c:88:31: error: use of undeclared identifier 'B1000000'
        case 1000000: tio.c_cflag |= B1000000; break;
                                     ^
posix_main.c:89:31: error: use of undeclared identifier 'B1152000'
        case 1152000: tio.c_cflag |= B1152000; break;
                                     ^
posix_main.c:90:31: error: use of undeclared identifier 'B1500000'
        case 1500000: tio.c_cflag |= B1500000; break;
                                     ^
posix_main.c:91:31: error: use of undeclared identifier 'B2000000'
        case 2000000: tio.c_cflag |= B2000000; break;
                                     ^
posix_main.c:92:31: error: use of undeclared identifier 'B2500000'
        case 2500000: tio.c_cflag |= B2500000; break;
                                     ^
posix_main.c:93:31: error: use of undeclared identifier 'B3000000'
        case 3000000: tio.c_cflag |= B3000000; break;
                                     ^
posix_main.c:94:31: error: use of undeclared identifier 'B3500000'
        case 3500000: tio.c_cflag |= B3500000; break;
                                     ^
posix_main.c:95:31: error: use of undeclared identifier 'B4000000'
        case 4000000: tio.c_cflag |= B4000000; break;
                                     ^
12 errors generated.
make: *** [posix_main.o] Error 1
/usr/local/bin/erlang/lib/gen_serial:.

---


On Sun, Mar 12, 2017 at 1:23 PM, József Bérces <[hidden email]> wrote:

You can give a try to this one:

http://github.com/tomszilagyi/gen_serial

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of qp
Sent: Sunday, March 12, 2017 17:57
To: Erlang/OTP discussions <[hidden email]>
Subject: [erlang-questions] Reading serial data from a USB Gamepad

 

Hi,

I want to read USB data from a Gamepad in Erlang to play a game.

Programs like JoyToKey and Enjoyable convert Gamepad inputs to keyboard input, but they only send 1 character so using io:read would require an additional "return" press to send the input.

Where do I start looking to learn how to read gamepads? I've heard that Erlang ports can be used to interact with the world outside the Erlang shell but I have no idea where to look. I found erlang-serial on Github but had trouble installing it https://github.com/tonyg/erlang-serial/issues/14

Thank you!



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Reading serial data from a USB Gamepad

greim
Hi,

for me
Erlang-Serial from Tony Garnock-Jones worked well:

https://github.com/tonyg/erlang-serial

tested with some serial hardware, like a embedded lcd terminal and
minicom on Linux amd64 and Raspberry Pi

Markus


Am 12.03.2017 um 19:00 schrieb qp:

> I get make errors with that one
>
> /usr/local/bin/erlang/lib/gen_serial:../make.sh
> Recompile: src/gen_serial_test
> Recompile: src/gen_serial
> gcc -Wall -O2 -g -ggdb -c -o ../erlang_serial.o ../erlang_serial.c
> gcc -Wall -O2 -g -ggdb -c -o posix_main.o posix_main.c
> posix_main.c:84:30: error: use of undeclared identifier 'B460800'
>         case 460800: tio.c_cflag |= B460800; break;
>                                     ^
> posix_main.c:85:30: error: use of undeclared identifier 'B500000'
>         case 500000: tio.c_cflag |= B500000; break;
>                                     ^
> posix_main.c:86:30: error: use of undeclared identifier 'B576000'
>         case 576000: tio.c_cflag |= B576000; break;
>                                     ^
> posix_main.c:87:30: error: use of undeclared identifier 'B921600'
>         case 921600: tio.c_cflag |= B921600; break;
>                                     ^
> posix_main.c:88:31: error: use of undeclared identifier 'B1000000'
>         case 1000000: tio.c_cflag |= B1000000; break;
>                                      ^
> posix_main.c:89:31: error: use of undeclared identifier 'B1152000'
>         case 1152000: tio.c_cflag |= B1152000; break;
>                                      ^
> posix_main.c:90:31: error: use of undeclared identifier 'B1500000'
>         case 1500000: tio.c_cflag |= B1500000; break;
>                                      ^
> posix_main.c:91:31: error: use of undeclared identifier 'B2000000'
>         case 2000000: tio.c_cflag |= B2000000; break;
>                                      ^
> posix_main.c:92:31: error: use of undeclared identifier 'B2500000'
>         case 2500000: tio.c_cflag |= B2500000; break;
>                                      ^
> posix_main.c:93:31: error: use of undeclared identifier 'B3000000'
>         case 3000000: tio.c_cflag |= B3000000; break;
>                                      ^
> posix_main.c:94:31: error: use of undeclared identifier 'B3500000'
>         case 3500000: tio.c_cflag |= B3500000; break;
>                                      ^
> posix_main.c:95:31: error: use of undeclared identifier 'B4000000'
>         case 4000000: tio.c_cflag |= B4000000; break;
>                                      ^
> 12 errors generated.
> make: *** [posix_main.o] Error 1
> /usr/local/bin/erlang/lib/gen_serial:.
>
> ---
>
>
> On Sun, Mar 12, 2017 at 1:23 PM, József Bérces
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     You can give a try to this one:____
>
>     http://github.com/tomszilagyi/gen_serial
>     <http://github.com/tomszilagyi/gen_serial>____
>
>     __ __
>
>     *From:*[hidden email]
>     <mailto:[hidden email]>
>     [mailto:[hidden email]
>     <mailto:[hidden email]>] *On Behalf Of *qp
>     *Sent:* Sunday, March 12, 2017 17:57
>     *To:* Erlang/OTP discussions <[hidden email]
>     <mailto:[hidden email]>>
>     *Subject:* [erlang-questions] Reading serial data from a USB Gamepad____
>
>     __ __
>
>     Hi,____
>
>     I want to read USB data from a Gamepad in Erlang to play a game.____
>
>     Programs like JoyToKey and Enjoyable convert Gamepad inputs to
>     keyboard input, but they only send 1 character so using io:read
>     would require an additional "return" press to send the input.____
>
>     Where do I start looking to learn how to read gamepads? I've heard
>     that Erlang ports can be used to interact with the world outside the
>     Erlang shell but I have no idea where to look. I found erlang-serial
>     on Github but had trouble installing it
>     https://github.com/tonyg/erlang-serial/issues/14
>     <https://github.com/tonyg/erlang-serial/issues/14>____
>
>     Thank you!____
>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions
>

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Reading serial data from a USB Gamepad

Tony Rogvall-2
In reply to this post by qp
https://github.com/tonyrog/uart

/Tony

> On 12 mar 2017, at 17:57, qp <[hidden email]> wrote:
>
> Hi,
>
> I want to read USB data from a Gamepad in Erlang to play a game.
>
> Programs like JoyToKey and Enjoyable convert Gamepad inputs to keyboard input, but they only send 1 character so using io:read would require an additional "return" press to send the input.
>
> Where do I start looking to learn how to read gamepads? I've heard that Erlang ports can be used to interact with the world outside the Erlang shell but I have no idea where to look. I found erlang-serial on Github but had trouble installing it https://github.com/tonyg/erlang-serial/issues/14
>
> Thank you!
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

signature.asc (817 bytes) Download Attachment
qp
Reply | Threaded
Open this post in threaded view
|

Re: Reading serial data from a USB Gamepad

qp
This looks promising, thank you

On Sun, Mar 12, 2017 at 4:36 PM, Tony Rogvall <[hidden email]> wrote:
https://github.com/tonyrog/uart

/Tony

> On 12 mar 2017, at 17:57, qp <[hidden email]> wrote:
>
> Hi,
>
> I want to read USB data from a Gamepad in Erlang to play a game.
>
> Programs like JoyToKey and Enjoyable convert Gamepad inputs to keyboard input, but they only send 1 character so using io:read would require an additional "return" press to send the input.
>
> Where do I start looking to learn how to read gamepads? I've heard that Erlang ports can be used to interact with the world outside the Erlang shell but I have no idea where to look. I found erlang-serial on Github but had trouble installing it https://github.com/tonyg/erlang-serial/issues/14
>
> Thank you!
> _______________________________________________
> erlang-questions mailing list
> [hidden email]
> http://erlang.org/mailman/listinfo/erlang-questions



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions