bsnes v0.041 released

Archived bsnes development news, feature requests and bug reports. Forum is now located at http://board.byuu.org/
Locked
tetsuo55
Regular
Posts: 307
Joined: Sat Mar 04, 2006 3:17 pm

Post by tetsuo55 »

byuu wrote:2b. Mice [up to 16]: up to three axes (Z, aka scroll wheel, is pretty useless though for the SNES), and up to 8 buttons (though the core APIs for both RawInput and Xlib only provide the first five button states.)


So you can only really use 5 of the 8?
If so one cannot map all snes controller buttons to the mouse :(

Mapping up, down, left, right to the mouse sensor would be annoying anyway i think(never really tried it.)
byuu

Post by byuu »

Yeah, mouse mode only works on some games, like Super Mario All-Stars: SMB1.

Assign left to left-click, right to right-click, jump to up-arrow, shoot fireball to down-arrow, and start to middle-click. I made it to 8-1 like that :)
Verdauga Greeneyes
Regular
Posts: 347
Joined: Tue Mar 07, 2006 10:32 am
Location: The Netherlands

Post by Verdauga Greeneyes »

Does horizontal scroll stuff count as two buttons?
byuu

Post by byuu »

Source fixes for WinXP users:

Forgot to fix the window flashing ...

window.cpp:13:

Code: Select all

  window->move(std::numeric_limits<signed>::max(), std::numeric_limits<signed>::max()); // :D


Seems to be quickly mapping print screen. It was giving me 0x2a and 0x37 messages. Apparently on XP 0x2a is also sent by the arrow keys, so I picked the wrong code to look for.

rawinput.cpp:57:

Code: Select all

      map(0x0037, 2, keyboard<>::print_screen)


-mconsole was throwing a bunch of errors. Need:

ui_qt/Makefile:33:

Code: Select all

  link += $(call mklib,gdi32)


I don't understand why lib file inclusion has to be in a certain order, but whatever.

Random musings:

Pause key returns 0x1d:4, 0x45:0. Num lock gives just 0x45:0. So detecting num lock by itself isn't worth the trouble. EDIT: meh. Cheap fix. Won't detect both held down at the same time, but who really uses num lock and pause as action buttons, anyway?

Code: Select all

      map(0x001d, 4, keyboard<>::pause)
      map(0x0045, 0, keyboard<>::num_lock)
      if(state[keyboard<>::pause]) state[keyboard<>::num_lock] = false;


Spacebar is tough to map because it triggers the mouse context menu. Hmm ...

Seems to be acting weird on the last item when mapping F10 then F11/F12 in a group ... wtf? EDIT: oh yeah, F10 is an alternate to trigger the context menu, heh.

Does horizontal scroll stuff count as two buttons?


Depends on the mouse driver, I guess. If it maps them to buttons four and five, you're good. If it maps them to six and seven, then you can't use them.

Xorg / Linux maps buttons 4 and 5 to the scroll wheel up and down, instead of using a separate Z-delta. So horizontal scroll and side buttons won't work at all there.

You can actually catch more, but you have to have a native X11 window to catch events from, which I can't have due to ruby encapsulation from the UI.
henke37
Lurker
Posts: 152
Joined: Tue Apr 10, 2007 4:30 pm
Location: Sweden
Contact:

Post by henke37 »

byuu wrote:
I don't understand why lib file inclusion has to be in a certain order, but whatever.


I do, it is because the symbols in the lib files are only imported if they are on the list, and they are only on the list if another file has requested them.
Importing a lib before it's symbols are on the list results in those symbols not being imported. This obviously doesn't work when the symbols are needed by a later file.
byuu

Post by byuu »

Well, had to go to Microcenter because my roommate's monitor was screwing up. I noticed they had a wired Xbox 360 controller for $40. So ... fuck it. Picked it up so I could write an Xinput driver. Luckily it works on Win7 64-bit. Some people were saying it didn't work in 64-bit Windows.

Found a bug in the current WIP thanks to that, too. The joypadNumber() test is still using joypad<>::limit instead of joypad<>::length for range testing.

So the only problem with the joypad now is that LT and RT map as a single Z-axis, exactly as I expected. Meaning you can use one or the other, but not both at the same time. They're so much more natural than LB and RB for SNES L+R, and it'll help ruby out by having more flexibility, so whatever. Expect Xinput support soon enough.

Just need to find a less 'taken' name than ruby, get some OS X drivers written, make the video system a bit more flexible, and ruby could probably catch on as a truly viable SDL alternative. If not for the sole reason that the drivers are so much simpler to write: if you need something it lacks, it's feasible to add it.

I wonder how SDL went about its' marketing to get where it is today ...
tetsuo55
Regular
Posts: 307
Joined: Sat Mar 04, 2006 3:17 pm

Post by tetsuo55 »

byuu wrote:I noticed they had a wired Xbox 360 controller for $40. So ... fuck it. Picked it up so I could write an Xinput driver.


byuu wrote:Expect Xinput support soon enough.


So now you can bring it back and get a refund :P
byuu

Post by byuu »

Hahah, yeah. But seriously, I return so much crap to Microcenter (most recently those two hard drives, and the first E8400 before due to overheating) that they'll probably ban me if I try it again.
Dullaron
Lurker
Posts: 199
Joined: Mon Mar 10, 2008 11:36 pm

Post by Dullaron »

LOL
Window Vista Home Premium 32-bit / Intel Core 2 Quad Q6600 2.40Ghz / 3.00 GB RAM / Nvidia GeForce 8500 GT
FirebrandX
Trooper
Posts: 376
Joined: Tue Apr 19, 2005 11:08 pm
Location: DFW area, TX USA
Contact:

Post by FirebrandX »

Dullaron wrote:LOL


Seriously, that's it? LOL?


DEEP!!!

(just messin with ya :lol: )
odditude
Official tech support dood
Posts: 2106
Joined: Wed Jan 25, 2006 7:57 am

Post by odditude »

byuu wrote:E8400

mine just arrived via ups yesterday... can't wait to finish that build ;)
[/off-topic]
Why yes, my shift key *IS* broken.
FitzRoy
Veteran
Posts: 861
Joined: Wed Aug 04, 2004 5:43 pm
Location: Sloop

Post by FitzRoy »

Okay, so for the latest WIP (first WIP I've used since official), my digital pad refuses to be recognized. When I turn the analog mode on to activate the thumbsticks, all d-pad directions get recognized as a hat. If I then turn it off again, it will recognize certain directions of the d-pad as a "lo" "axis" and ignore others. Very strange behavior here, I should be able to use this thing in digital mode and can't. It always worked before.

Dual Shock 2, Vista 64
byuu

Post by byuu »

New WIP.

Rewrote a large portion of the RawInput driver, cleaning it up substantially. Each API is now its own separate class, and pInputRaw (the ruby private implementation class) pulls data from each separate driver.

For keyboards, I've added the fixes for print screen and pause/num_lock.

For joypads, I added XInput controller detection through RawInput's RIDI_DEVICENAME, instead of that crazy ass COM + wbem shit from MSDN. I also added a proper XInput driver, so now the left and right axes can be mapped independently, and you can use both at the same time. All in all, quite expensive and a lot of work, but it's the little bits of polish that really make an application shine.

Do note that MinGW still doesn't ship with libxinput.a -- it's only been out for four years now, after all. You'll need to take XInput.lib from the DX9 SDK x86\lib folder, copy it to MinGW\lib, and rename it to libxinput.a. I'm surprised that works, but it does. I tried to use LoadLibrary("xinput1_3.dll") + GetProcAddress("XInputGetState"), but the app kept crashing in bsnes when optimizations were enabled. gdb showed it to crash in msvcrt!memcpy() from inside dinput8.dll. No idea what the hell was going on there.

Non-XInput controllers will fall back on using DirectInput, of course.

Fixed the joypad indexing, so multiple joypads should work again. Got the window centering hopefully right on WinXP so that windows opening for the first time won't 'flicker' anymore. Added the mklib(gdi32) entry, so you can compile with -mconsole again.

Re-did the mouse capture stuff. 'Assign Mouse Button' + 'Assign Mouse Axis' are now buttons instead of menu buttons.

For button assignment, you are given a window with a large disabled button named '(capture box)'. The instructions say to put whatever mouse you want over this button and click the mouse button that you want to assign. It'll assign upon release. Right now, assignment won't work for 1-2 seconds to prevent instant assignment when you click. I'll make a button mask in the future to avoid that delay. Also, it only verifies you clicked a mouse button while the capture window was active. I'll need to look into Qt's methods for mapping cursor clicks to control regions onscreen. Good news is it's now much easier to assign extended buttons like up+down ... you don't have to know what button #s they are anymore.

For axis assignment, mapping based on mouse motion is too dangerous. So you get a window with two buttons: 'X-axis' and 'Y-axis'. I can add Z-axis if anyone wants (for the scroll wheel), but it seems kind of useless. The instructions say to click the axis button you want, with the mouse you want the axis assigned to.

Now I know the instructions will probably just confuse people with only one mouse (~99% of users), so if everyone really thinks it'd be better to leave multi-mouse users in the dark about how the capture system works, I can take out the verbose notes.

Hoping your controller will work now, FitzRoy. Otherwise I have no idea what's wrong. Be sure you manually set the driver to RawInput, too. Will most likely require a config file with "version = 42", otherwise reset to defaults, for the next release.
belegdol
Hazed
Posts: 68
Joined: Tue Dec 07, 2004 10:24 am

Post by belegdol »

I can confirm that all axes, hats and buttons work with my joypad now. Thanks byuu!
Dullaron
Lurker
Posts: 199
Joined: Mon Mar 10, 2008 11:36 pm

Post by Dullaron »

Window Vista Home Premium 32-bit / Intel Core 2 Quad Q6600 2.40Ghz / 3.00 GB RAM / Nvidia GeForce 8500 GT
FitzRoy
Veteran
Posts: 861
Joined: Wed Aug 04, 2004 5:43 pm
Location: Sloop

Post by FitzRoy »

Still won't recognize my d-pad as anything unless I activate analog mode. Buttons work fine.

In .041, they get recognized as this in both digital and analog mode:

"joypad00.up"
"joypad00.down"
"joypad00.left"
"joypad00.right"

In .041, dedicated axes wouldn't get recognized at all. All analog mode would do is cause the left thumbstick to mirror the above d-pad assignments.

I've got a super smartjoy around here somewhere, that's a completely digital controller. If that breaks, you're in big trouble.

EDIT: confirmed, all digital only joypads cannot map to the directional pad in Vista 64.
byuu

Post by byuu »

FitzRoy wrote:EDIT: confirmed, all digital only joypads cannot map to the directional pad in Vista 64.


With the exception of my three, which all work perfectly.

Does it work if you set the driver to DirectInput? You'll have to send me your controllers or something, because I don't have any idea why it wouldn't work.
FitzRoy
Veteran
Posts: 861
Joined: Wed Aug 04, 2004 5:43 pm
Location: Sloop

Post by FitzRoy »

byuu wrote:Does it work if you set the driver to DirectInput?


No, I've tried that and deleting the config numerous times.

I'm also not using manufacturer drivers for either. They are automatically recognized and work fine in the control panel.
byuu

Post by byuu »

So then it's unlikely to be bugs in the input drivers, but tripping of some issue in the UI mapping code.

I'll post a WIP with console mode enabled in the evening, see if we can determine what test is failing.

EDIT: in your control panel, are the unresponsive inputs acting as POV hats or as 'axes' that just go from extremes, eg starts centered, pressing any direction pushes them all the way to the edges?

To prevent the calibration from popping up right off the bat, I was using:

Code: Select all

        if(state < -24576 || state > +24576) return;  //ensure axis is not at its lowest or highest value
        if(state >  -8192 && state <  +8192) return;  //ensure axis is not near its center


Which would stop digital inputs mapped over analog inputs from triggering the calibration window.

Also, seems stock Vista ships with DX10, but not the most recent DX9c files. Users will need xinput1_3.dll to run the new builds. As I said before, GetProcAddress is screwing up somehow between MinGW optimizations and my code. But since it's only ~26kb, I'll probably just host it directly, plus put a direct link to the DX9 redist package. Sucks, but pretty much any modern game would require 9.0c anyway.
FitzRoy
Veteran
Posts: 861
Joined: Wed Aug 04, 2004 5:43 pm
Location: Sloop

Post by FitzRoy »

byuu wrote:as 'axes' that just go from extremes, eg starts centered, pressing any direction pushes them all the way to the edges?


This one. The only thing that uses the POV hat area is my dual shock 2 d-pad in analog mode. Digital d-pad always uses the x/y axis box with 8 extremities.

Btw, are you on SP1 like me?
byuu

Post by byuu »

Okay then, if everyone possible could test this quickly, I can post a new release tonight. Especially the input mapping, and especially there for gamepads / controllers.

Code: Select all

http://byuu.org/files/bsnes_test.zip


No source, Windows only binary.

If you get an error about xinput1_3.dll, install the DirectX 9.0c redistributable.

Changes from last WIP:

- I was able to reproduce FitzRoy's issue, and fix it. Really, really crappy gamepads that send large phantom movements when the user isn't even touching the axes may trigger the calibration window early; not much I can do about that. None of my controllers do this at least.

- I updated the mouse button capture window. It now uses a framed label (kind of like a groupbox but with text in the center), and you have to release a mouse button inside the box for it to map.

- Screensaver / monitor power saving disabled on both Windows and Linux.

- More improvements to window centering.

Btw, are you on SP1 like me?


No, I'm using Windows 7 beta 1.
I.S.T.
Zealot
Posts: 1325
Joined: Tue Nov 27, 2007 7:03 am

Post by I.S.T. »

Everything works properly here.
Tallgeese
Justice is Blind
Posts: 620
Joined: Wed Jul 28, 2004 3:33 pm
Location: Test
Contact:

Post by Tallgeese »

Is W7 that much better than Vista?
FitzRoy
Veteran
Posts: 861
Joined: Wed Aug 04, 2004 5:43 pm
Location: Sloop

Post by FitzRoy »

I was able to reproduce FitzRoy's issue, and fix it.


Yep, you got it.

Two things:

-A reminder about the "last folder ..." "same folder ..." change to the paths section.
-Are you capable of putting in any text you want per selection in the title bar of the configuration window? You could integrate the subtitles into that, and the current section would be known from a minimized state.
byuu

Post by byuu »

Is W7 that much better than Vista?


Yes, definitely.

Win+left/right/up/down; Win+1-8; the new taskbar dock thing; refinements to Explorer (still not as nice as good old Win XP's); eats less memory and runs faster; etc.

Still like Xfce more, myself.

-A reminder about the "last folder ..." "same folder ..." change to the paths section.


Could you elaborate on that?

-Are you capable of putting in any text you want per selection in the title bar of the configuration window?


Yeah, but then you can already tell what you're on from the left-hand listbox. It was really only there to give a stylish element ala SNESGT and friends. bsnes has always been really plain, so I like having some sort of aesthetic besides just plain minimalist controls.
Locked