Author: titmuss
Date: Mon Oct 13 13:08:31 2008
New Revision: 3112

URL: http://svn.slimdevices.com?rev=3112&root=Jive&view=rev
Log:
 [EMAIL PROTECTED] (orig r3107):  awy | 2008-10-12 13:28:39 +0100
 Fix up test in previous change (thanks Felix).
 [EMAIL PROTECTED] (orig r3108):  awy | 2008-10-12 13:29:44 +0100
 Auto-pause on output-underrun, and stop on underrun.
 [EMAIL PROTECTED] (orig r3109):  tom | 2008-10-13 14:46:21 +0100
 lua shortcut key handling and keyboard text input for squeezeplay.
 Also backspace and esc work as back when not in textinput modes.  In textinput 
modes backspace deletes, and escape leaves the textinput altogether.
 [EMAIL PROTECTED] (orig r3111):  titmuss | 2008-10-13 21:05:36 +0100
 Bug: N/A
 Description:
 Use default alsa device for playback.
 
 

Modified:
    7.4/trunk/   (props changed)
    
7.4/trunk/squeezeplay/src/squeezeplay/share/applets/ScreenSavers/ScreenSaversApplet.lua
    
7.4/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
    7.4/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/Volume.lua
    7.4/trunk/squeezeplay/src/squeezeplay/share/jive/JiveMain.lua
    7.4/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua
    7.4/trunk/squeezeplay/src/squeezeplay/share/jive/slim/Player.lua
    7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Framework.lua
    7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Textinput.lua
    7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua
    7.4/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_alsa.c
    7.4/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c
    7.4/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h
    7.4/trunk/squeezeplay/src/squeezeplay/src/ui/jive_event.c
    7.4/trunk/squeezeplay/src/squeezeplay/src/ui/jive_framework.c
    7.4/trunk/squeezeplay/src/squeezeplay/src/ui/lua_jiveui.c

Propchange: 7.4/trunk/
------------------------------------------------------------------------------
--- svk:merge (original)
+++ svk:merge Mon Oct 13 13:08:31 2008
@@ -2,7 +2,7 @@
 bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.1/branches/discovery-refactor:2596
 bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.1/trunk:2920
 bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.2/trunk:2921
-bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.3/trunk:3098
+bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.3/trunk:3111
 bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/7.0:2013
 bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/SN:1083
 bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/scrolling:1378

Modified: 
7.4/trunk/squeezeplay/src/squeezeplay/share/applets/ScreenSavers/ScreenSaversApplet.lua
URL: 
http://svn.slimdevices.com/7.4/trunk/squeezeplay/src/squeezeplay/share/applets/ScreenSavers/ScreenSaversApplet.lua?rev=3112&root=Jive&r1=3111&r2=3112&view=diff
==============================================================================
--- 
7.4/trunk/squeezeplay/src/squeezeplay/share/applets/ScreenSavers/ScreenSaversApplet.lua
 (original)
+++ 
7.4/trunk/squeezeplay/src/squeezeplay/share/applets/ScreenSavers/ScreenSaversApplet.lua
 Mon Oct 13 13:08:31 2008
@@ -64,7 +64,7 @@
 
        -- listener to restart screensaver timer
        Framework:addListener(
-               EVENT_KEY_PRESS | EVENT_KEY_HOLD | EVENT_SCROLL | 
EVENT_MOUSE_ALL | EVENT_MOTION,
+               EVENT_CHAR_PRESS | EVENT_KEY_PRESS | EVENT_KEY_HOLD | 
EVENT_SCROLL | EVENT_MOUSE_ALL | EVENT_MOTION,
                function(event)
                        -- restart timer if it is running
                        self.timer:setInterval(self.timeout)
@@ -215,7 +215,7 @@
                           end)
 
        -- key or scroll events quit the screensaver
-       window:addListener(EVENT_KEY_PRESS | EVENT_KEY_HOLD | EVENT_SCROLL | 
EVENT_MOUSE_ALL,
+       window:addListener(EVENT_CHAR_PRESS | EVENT_KEY_PRESS | EVENT_KEY_HOLD 
| EVENT_SCROLL | EVENT_MOUSE_ALL,
                function(event)
 
                        -- close all screensaver windows

Modified: 
7.4/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
URL: 
http://svn.slimdevices.com/7.4/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua?rev=3112&root=Jive&r1=3111&r2=3112&view=diff
==============================================================================
--- 
7.4/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
 (original)
+++ 
7.4/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
 Mon Oct 13 13:08:31 2008
@@ -1249,7 +1249,14 @@
                return self.volume:event(event)
        end,
 
+       ["volup"] = function(self, event)
+               return self.volume:event(event)
+       end,
+
        ["voldown-down"] = function(self, event)
+               return self.volume:event(event)
+       end,
+       ["voldown"] = function(self, event)
                return self.volume:event(event)
        end,
 --[[   

Modified: 
7.4/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/Volume.lua
URL: 
http://svn.slimdevices.com/7.4/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/Volume.lua?rev=3112&root=Jive&r1=3111&r2=3112&view=diff
==============================================================================
--- 7.4/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/Volume.lua 
(original)
+++ 7.4/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/Volume.lua 
Mon Oct 13 13:08:31 2008
@@ -216,6 +216,18 @@
                        return EVENT_CONSUME
                end
 
+               --handle keyboard volume change
+               if (keycode == KEY_VOLUME_UP) then
+                       self.delta = 1
+                       _updateVolume(self)
+                       self.delta = 0
+               end
+               if (keycode == KEY_VOLUME_DOWN) then
+                       self.delta = -1
+                       _updateVolume(self)
+                       self.delta = 0
+               end
+                                       
                return EVENT_CONSUME
 
        else

Modified: 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/JiveMain.lua
URL: 
http://svn.slimdevices.com/7.4/trunk/squeezeplay/src/squeezeplay/share/jive/JiveMain.lua?rev=3112&root=Jive&r1=3111&r2=3112&view=diff
==============================================================================
--- 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/JiveMain.lua (original)
+++ 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/JiveMain.lua Mon Oct 13 
13:08:31 2008
@@ -56,6 +56,7 @@
 local Framework     = require("jive.ui.Framework")
 local Task          = require("jive.ui.Task")
 local Timer         = require("jive.ui.Timer")
+local Event         = require("jive.ui.Event")
 
 local debug         = require("jive.utils.debug")
 local log           = require("jive.utils.log").logger("jive.main")
@@ -64,14 +65,26 @@
 
 local EVENT_KEY_ALL        = jive.ui.EVENT_KEY_ALL
 local EVENT_KEY_PRESS      = jive.ui.EVENT_KEY_PRESS
+local EVENT_CHAR_PRESS      = jive.ui.EVENT_CHAR_PRESS
 local EVENT_KEY_HOLD       = jive.ui.EVENT_KEY_HOLD
 local EVENT_SCROLL         = jive.ui.EVENT_SCROLL
 local EVENT_WINDOW_RESIZE  = jive.ui.EVENT_WINDOW_RESIZE
 local EVENT_UNUSED         = jive.ui.EVENT_UNUSED
 
 local KEY_HOME             = jive.ui.KEY_HOME
-local KEY_BACK             = jive.ui.KEY_BACK
-
+local KEY_FWD           = jive.ui.KEY_FWD
+local KEY_REW           = jive.ui.KEY_REW
+local KEY_GO            = jive.ui.KEY_GO
+local KEY_BACK          = jive.ui.KEY_BACK
+local KEY_UP            = jive.ui.KEY_UP
+local KEY_DOWN          = jive.ui.KEY_DOWN
+local KEY_LEFT          = jive.ui.KEY_LEFT
+local KEY_RIGHT         = jive.ui.KEY_RIGHT
+local KEY_PLAY          = jive.ui.KEY_PLAY
+local KEY_PAUSE         = jive.ui.KEY_PAUSE
+local KEY_VOLUME_UP     = jive.ui.KEY_VOLUME_UP
+local KEY_VOLUME_DOWN   = jive.ui.KEY_VOLUME_DOWN
+local KEY_ADD           = jive.ui.KEY_ADD
 
 -- Classes
 local JiveMain = oo.class({}, HomeMenu)
@@ -84,12 +97,45 @@
 -- should not need to have an id passed when creating it
 local _idTranslations = {}
        
+local keyboardShortcuts = {    
+       ["i"]  = KEY_UP,
+       ["k"]  = KEY_DOWN,
+       ["j"]  = KEY_LEFT,
+       ["l"]  = KEY_RIGHT,
+       ["h"]  = KEY_HOME,
+       ["p"]  = KEY_PLAY,
+       ["x"]  = KEY_PLAY,
+       ["c"]  = KEY_PAUSE,
+       [" "]  = KEY_PAUSE,
+       ["a"]  = KEY_ADD,
+       ["z"]  = KEY_REW,
+       ["<"]  = KEY_REW,
+       ["b"]  = KEY_FWD,
+       [">"]  = KEY_FWD,
+       ["+"]  = KEY_VOLUME_UP,
+       ["="]  = KEY_VOLUME_UP,
+       ["-"]  = KEY_VOLUME_DOWN,
+       ["\b"]  = KEY_BACK, -- BACKSPACE
+       ["\27"]  = KEY_BACK -- ESC
+}
 
 -- bring us to the home menu
 local function _homeHandler(event)
        local type = event:getType()
 
-       if (( type == EVENT_KEY_PRESS and event:getKeycode() == KEY_HOME) or
+       if ( type == EVENT_CHAR_PRESS ) then
+               local keyboardEntry = string.char(event:getUnicode())
+               
+               log:debug("Keyboard entry: ", keyboardEntry)
+               
+               local keyCode = keyboardShortcuts[keyboardEntry]
+               if (keyCode) then
+                       Framework:pushEvent(Event:new(EVENT_KEY_PRESS, keyCode))
+               end
+               
+               return EVENT_CONSUME
+
+       elseif (( type == EVENT_KEY_PRESS and event:getKeycode() == KEY_HOME) or
            ( type == EVENT_KEY_HOLD and event:getKeycode() == KEY_BACK)) then
 
                -- disconnect from player on press and hold left
@@ -147,7 +193,7 @@
 
        -- home key handler, one for KEY_PRESS/HOME, one for KEY_HOLD/BACK
        Framework:addListener(
-               EVENT_KEY_PRESS | EVENT_KEY_HOLD,
+               EVENT_CHAR_PRESS| EVENT_KEY_PRESS | EVENT_KEY_HOLD,
                function(event)
                        _homeHandler(event)
                end,

Modified: 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua
URL: 
http://svn.slimdevices.com/7.4/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua?rev=3112&root=Jive&r1=3111&r2=3112&view=diff
==============================================================================
--- 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua 
(original)
+++ 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua Mon Oct 
13 13:08:31 2008
@@ -152,6 +152,7 @@
                        self.sentDecoderUnderrunEvent then
 
                        log:info("status AUDIO UNDERRUN")
+                       Decode:stop() -- XXX need to let last buffer play out 
before stop
                        self:sendStatus(status, "STMu")
 
                        self.sentAudioUnderrunEvent = true
@@ -160,6 +161,7 @@
                        self.stream then
 
                        log:info("status OUTPUT UNDERRUN")
+                       Decode:pause(0) -- auto-pause to prevent glitches
                        self:sendStatus(status, "STMo")
 
                        self.sentOutputUnderrunEvent = true

Modified: 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/slim/Player.lua
URL: 
http://svn.slimdevices.com/7.4/trunk/squeezeplay/src/squeezeplay/share/jive/slim/Player.lua?rev=3112&root=Jive&r1=3111&r2=3112&view=diff
==============================================================================
--- 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/slim/Player.lua (original)
+++ 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/slim/Player.lua Mon Oct 13 
13:08:31 2008
@@ -58,6 +58,7 @@
 local log            = require("jive.utils.log").logger("player")
 
 local EVENT_KEY_ALL    = jive.ui.EVENT_KEY_ALL
+local EVENT_CHAR_PRESS = jive.ui.EVENT_CHAR_PRESS
 local EVENT_SCROLL     = jive.ui.EVENT_SCROLL
 local EVENT_CONSUME    = jive.ui.EVENT_CONSUME
 
@@ -778,7 +779,7 @@
              })
 
        self.currentSong.window:addWidget(group)
-       self.currentSong.window:addListener(EVENT_KEY_ALL | EVENT_SCROLL,
+       self.currentSong.window:addListener(EVENT_CHAR_PRESS | EVENT_KEY_ALL | 
EVENT_SCROLL,
                function(event)
                        local prev = self.currentSong.window:getLowerWindow()
                        if prev then

Modified: 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Framework.lua
URL: 
http://svn.slimdevices.com/7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Framework.lua?rev=3112&root=Jive&r1=3111&r2=3112&view=diff
==============================================================================
--- 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Framework.lua (original)
+++ 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Framework.lua Mon Oct 
13 13:08:31 2008
@@ -172,6 +172,7 @@
 
        module.EVENT_SCROLL = jive.ui.EVENT_SCROLL
        module.EVENT_ACTION = jive.ui.EVENT_ACTION
+       module.EVENT_CHAR_PRESS = jive.ui.EVENT_CHAR_PRESS
        module.EVENT_KEY_DOWN = jive.ui.EVENT_KEY_DOWN
        module.EVENT_KEY_UP = jive.ui.EVENT_KEY_UP
        module.EVENT_KEY_PRESS = jive.ui.EVENT_KEY_PRESS

Modified: 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Textinput.lua
URL: 
http://svn.slimdevices.com/7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Textinput.lua?rev=3112&root=Jive&r1=3111&r2=3112&view=diff
==============================================================================
--- 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Textinput.lua (original)
+++ 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Textinput.lua Mon Oct 
13 13:08:31 2008
@@ -18,6 +18,7 @@
 local EVENT_UNUSED      = jive.ui.EVENT_UNUSED
 
 local EVENT_KEY_PRESS   = jive.ui.EVENT_KEY_PRESS
+local EVENT_CHAR_PRESS   = jive.ui.EVENT_CHAR_PRESS
 local EVENT_SCROLL      = jive.ui.EVENT_SCROLL
 local EVENT_WINDOW_RESIZE = jive.ui.EVENT_WINDOW_RESIZE
 local EVENT_CONSUME     = jive.ui.EVENT_CONSUME
@@ -227,6 +228,41 @@
                _scroll(self, self.scroll:event(event, idx, idx, 1, #v))
                return EVENT_CONSUME
 
+       elseif type == EVENT_CHAR_PRESS then
+               
+               --assuming ascii level values for now
+               local keyboardEntry = string.char(event:getUnicode())
+               if (keyboardEntry == "\b") then --backspace
+                       if not _delete(self) then
+                               self:playSound("BUMP")
+                               self:getWindow():bumpRight()
+                       end
+                       return EVENT_CONSUME    
+               elseif (keyboardEntry == "\27") then --escape
+                       self.cursor = 1
+                       self:playSound("WINDOWHIDE")
+                       self:hide()
+                       return EVENT_CONSUME
+               elseif (not string.find(self:_getChars(), keyboardEntry)) then
+                       --also check for possibility of uppercase match
+                       if (string.find(keyboardEntry, "%l")) then
+                               keyboardEntry = string.upper(keyboardEntry)
+                       end
+                       if (not string.find(self:_getChars(), keyboardEntry)) 
then
+                               self:playSound("BUMP")
+                               self:getWindow():bumpRight()
+                               return EVENT_CONSUME
+                       end
+               end
+               
+               local before = string.sub(tostring(self.value), 1, self.cursor 
- 1)
+               local after = string.sub(tostring(self.value), self.cursor + 1)
+               self:setValue(before .. keyboardEntry .. after)
+               
+               _moveCursor(self, 1)
+               
+               return EVENT_CONSUME
+               
        elseif type == EVENT_WINDOW_RESIZE then
                _moveCursor(self, 0)
 
@@ -350,7 +386,7 @@
                _globalStrings:str("ALLOWEDCHARS_WITHCAPS")
        obj.scroll = ScrollAccel()
 
-       obj:addListener(EVENT_KEY_PRESS | EVENT_SCROLL | EVENT_WINDOW_RESIZE,
+       obj:addListener(EVENT_CHAR_PRESS| EVENT_KEY_PRESS | EVENT_SCROLL | 
EVENT_WINDOW_RESIZE,
                        function(event)
                                return _eventHandler(obj, event)
                        end)

Modified: 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua
URL: 
http://svn.slimdevices.com/7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua?rev=3112&root=Jive&r1=3111&r2=3112&view=diff
==============================================================================
--- 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua (original)
+++ 7.4/trunk/squeezeplay/src/squeezeplay/share/jive/ui/Window.lua Mon Oct 13 
13:08:31 2008
@@ -61,6 +61,7 @@
 local EVENT_ACTION            = jive.ui.EVENT_ACTION
 local EVENT_SCROLL            = jive.ui.EVENT_SCROLL
 local EVENT_KEY_PRESS         = jive.ui.EVENT_KEY_PRESS
+local EVENT_TEXT_PRESS         = jive.ui.EVENT_TEXT_PRESS
 local EVENT_WINDOW_PUSH       = jive.ui.EVENT_WINDOW_PUSH
 local EVENT_WINDOW_POP        = jive.ui.EVENT_WINDOW_POP
 local EVENT_WINDOW_ACTIVE     = jive.ui.EVENT_WINDOW_ACTIVE
@@ -317,7 +318,7 @@
 
        if self.brieflyHandler == nil then
                self.brieflyHandler =
-                       self:addListener(EVENT_KEY_PRESS | EVENT_SCROLL,
+                       self:addListener(EVENT_TEXT_PRESS | EVENT_KEY_PRESS | 
EVENT_SCROLL,
                                         function(event)
                                                 self:hide(popTransition, 
"NONE")
                                                 return EVENT_CONSUME

Modified: 7.4/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_alsa.c
URL: 
http://svn.slimdevices.com/7.4/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_alsa.c?rev=3112&root=Jive&r1=3111&r2=3112&view=diff
==============================================================================
--- 7.4/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_alsa.c 
(original)
+++ 7.4/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_alsa.c Mon 
Oct 13 13:08:31 2008
@@ -24,7 +24,7 @@
 
 
 /* alsa */
-static char *device = "plughw:0,0";
+static char *device = "default";
 
 static snd_output_t *output;
 static snd_pcm_t *handle;

Modified: 7.4/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c
URL: 
http://svn.slimdevices.com/7.4/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c?rev=3112&root=Jive&r1=3111&r2=3112&view=diff
==============================================================================
--- 7.4/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c (original)
+++ 7.4/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c Mon Oct 13 
13:08:31 2008
@@ -83,7 +83,7 @@
        size_t n;
        
        if (!streambuf_streaming) {
-               return TRUE;
+               return FALSE;
        }
 
        fifo_lock(&streambuf_fifo);

Modified: 7.4/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h
URL: 
http://svn.slimdevices.com/7.4/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h?rev=3112&root=Jive&r1=3111&r2=3112&view=diff
==============================================================================
--- 7.4/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h (original)
+++ 7.4/trunk/squeezeplay/src/squeezeplay/src/ui/jive.h Mon Oct 13 13:08:31 2008
@@ -98,9 +98,12 @@
        JIVE_EVENT_SWITCH               = 0x00400000,
        JIVE_EVENT_MOTION               = 0x00800000,
 
+       JIVE_EVENT_CHAR_PRESS   = 0x02000000,
+       
+       JIVE_EVENT_CHAR_ALL     = ( JIVE_EVENT_CHAR_PRESS),
        JIVE_EVENT_KEY_ALL              = ( JIVE_EVENT_KEY_DOWN | 
JIVE_EVENT_KEY_UP | JIVE_EVENT_KEY_PRESS | JIVE_EVENT_KEY_HOLD ),
        JIVE_EVENT_MOUSE_ALL            = ( JIVE_EVENT_MOUSE_DOWN | 
JIVE_EVENT_MOUSE_PRESS | JIVE_EVENT_MOUSE_HOLD | JIVE_EVENT_MOUSE_MOVE | 
JIVE_EVENT_MOUSE_DRAG ),
-       JIVE_EVENT_ALL_INPUT            = ( JIVE_EVENT_KEY_ALL | 
JIVE_EVENT_MOUSE_ALL | JIVE_EVENT_SCROLL),
+       JIVE_EVENT_ALL_INPUT            = ( JIVE_EVENT_KEY_ALL | 
JIVE_EVENT_MOUSE_ALL | JIVE_EVENT_SCROLL | JIVE_EVENT_CHAR_ALL),
 
        JIVE_EVENT_VISIBLE_ALL          = ( JIVE_EVENT_SHOW | JIVE_EVENT_HIDE ),
        JIVE_EVENT_ALL                  = 0x7FFFFFFF,
@@ -193,6 +196,10 @@
        JiveKey code;
 };
 
+struct jive_char_event {
+       Uint16 unicode;
+};
+
 struct jive_mouse_event {
        Uint16 x;
        Uint16 y;
@@ -216,6 +223,7 @@
        union {
                struct jive_scroll_event scroll;
                struct jive_key_event key;
+               struct jive_char_event text;
                struct jive_mouse_event mouse;
                struct jive_motion_event motion;
                struct jive_sw_event sw;
@@ -386,6 +394,7 @@
 int jiveL_event_get_ticks(lua_State *L);
 int jiveL_event_get_scroll(lua_State *L);
 int jiveL_event_get_keycode(lua_State *L);
+int jiveL_event_get_unicode(lua_State *L);
 int jiveL_event_get_mouse(lua_State *L);
 int jiveL_event_get_motion(lua_State *L);
 int jiveL_event_get_switch(lua_State *L);

Modified: 7.4/trunk/squeezeplay/src/squeezeplay/src/ui/jive_event.c
URL: 
http://svn.slimdevices.com/7.4/trunk/squeezeplay/src/squeezeplay/src/ui/jive_event.c?rev=3112&root=Jive&r1=3111&r2=3112&view=diff
==============================================================================
--- 7.4/trunk/squeezeplay/src/squeezeplay/src/ui/jive_event.c (original)
+++ 7.4/trunk/squeezeplay/src/squeezeplay/src/ui/jive_event.c Mon Oct 13 
13:08:31 2008
@@ -136,6 +136,23 @@
        return 0;
 }
 
+int jiveL_event_get_unicode(lua_State *L) {
+       JiveEvent* event = (JiveEvent*)lua_touserdata(L, 1);
+       if (event == NULL) {
+               luaL_error(L, "invalid Event");
+       }
+
+       switch (event->type) {
+       case JIVE_EVENT_CHAR_PRESS:
+               lua_pushinteger(L, event->u.text.unicode);
+               return 1;
+
+       default:
+               luaL_error(L, "Not a char event");
+       }
+       return 0;
+}
+
 
 int jiveL_event_get_mouse(lua_State *L) {
        JiveEvent* event = (JiveEvent*)lua_touserdata(L, 1);

Modified: 7.4/trunk/squeezeplay/src/squeezeplay/src/ui/jive_framework.c
URL: 
http://svn.slimdevices.com/7.4/trunk/squeezeplay/src/squeezeplay/src/ui/jive_framework.c?rev=3112&root=Jive&r1=3111&r2=3112&view=diff
==============================================================================
--- 7.4/trunk/squeezeplay/src/squeezeplay/src/ui/jive_framework.c (original)
+++ 7.4/trunk/squeezeplay/src/squeezeplay/src/ui/jive_framework.c Mon Oct 13 
13:08:31 2008
@@ -72,29 +72,13 @@
        { SDLK_RIGHT,           JIVE_KEY_GO },
        { SDLK_RETURN,          JIVE_KEY_GO },
        { SDLK_LEFT,            JIVE_KEY_BACK },
-       { SDLK_i,               JIVE_KEY_UP },
-       { SDLK_k,               JIVE_KEY_DOWN },
-       { SDLK_j,               JIVE_KEY_LEFT },
-       { SDLK_l,               JIVE_KEY_RIGHT },
        { SDLK_HOME,            JIVE_KEY_HOME },
-       { SDLK_p,               JIVE_KEY_PLAY },
-       { SDLK_x,               JIVE_KEY_PLAY },
        { SDLK_AudioPlay,       JIVE_KEY_PLAY },
-       { SDLK_c,               JIVE_KEY_PAUSE },
-       { SDLK_SPACE,           JIVE_KEY_PAUSE },
        { SDLK_AudioPause,      JIVE_KEY_PAUSE },
-       { SDLK_a,               JIVE_KEY_ADD },
        { SDLK_KP_PLUS,         JIVE_KEY_ADD },
-       { SDLK_z,               JIVE_KEY_REW },
-       { SDLK_LESS,            JIVE_KEY_REW },
        { SDLK_AudioPrev,       JIVE_KEY_REW },
-       { SDLK_b,               JIVE_KEY_FWD },
-       { SDLK_GREATER,         JIVE_KEY_FWD },
        { SDLK_AudioNext,       JIVE_KEY_FWD },
-       { SDLK_PLUS,            JIVE_KEY_VOLUME_UP },
-       { SDLK_EQUALS,          JIVE_KEY_VOLUME_UP },
        { SDLK_AudioRaiseVolume,JIVE_KEY_VOLUME_UP },
-       { SDLK_MINUS,           JIVE_KEY_VOLUME_DOWN },
        { SDLK_AudioLowerVolume,JIVE_KEY_VOLUME_DOWN },
        { SDLK_UNKNOWN,         JIVE_KEY_NONE },
 };
@@ -167,7 +151,6 @@
 
        /* open window */
        SDL_WM_SetCaption("SqueezePlay Beta", "SqueezePlay Beta");
-
 
        srf = jive_surface_set_video_mode(screen_w, screen_h, bpp, false);
        if (!srf) {
@@ -184,6 +167,7 @@
 
 //     SDL_ShowCursor (SDL_DISABLE);
        SDL_EnableKeyRepeat (100, 100);
+       SDL_EnableUNICODE(1);
 
        tolua_pushusertype(L, srf, "Surface");
        lua_setfield(L, -2, "surface");
@@ -1095,10 +1079,26 @@
                        }
                        entry++;
                }
+
                if (entry->keysym == SDLK_UNKNOWN) {
+                       // handle regular character keys ('a', 't', etc..)
+                       SDLMod mod = event->key.keysym.mod;
+                       if (event->type == SDL_KEYDOWN && 
(event->key.keysym.unicode != 0) && (mod == KMOD_NONE || mod == KMOD_LSHIFT || 
mod == KMOD_RSHIFT)) {
+                               JiveEvent textEvent;
+
+                               memset(&textEvent, 0, sizeof(JiveEvent));
+                               textEvent.type = JIVE_EVENT_CHAR_PRESS;
+                               textEvent.ticks = SDL_GetTicks();
+                               if (event->key.keysym.sym == SDLK_BACKSPACE) {
+                                       //special case for Backspace, where 
value set is not ascii value, instead pass backspace ascii value
+                                       textEvent.u.text.unicode = 8;
+                               } else {
+                                       textEvent.u.text.unicode = 
event->key.keysym.unicode;
+                               }
+                               jive_queue_event(&textEvent);
+                       }
                        return 0;
                }
-
 
                if (event->type == SDL_KEYDOWN) {
                        if (key_mask & entry->keycode) {
@@ -1380,6 +1380,7 @@
        { "getTicks", jiveL_event_get_ticks },
        { "getScroll", jiveL_event_get_scroll },
        { "getKeycode", jiveL_event_get_keycode },
+       { "getUnicode", jiveL_event_get_unicode },
        { "getMouse", jiveL_event_get_mouse },
        { "getMotion", jiveL_event_get_motion },
        { "getSwitch", jiveL_event_get_switch },

Modified: 7.4/trunk/squeezeplay/src/squeezeplay/src/ui/lua_jiveui.c
URL: 
http://svn.slimdevices.com/7.4/trunk/squeezeplay/src/squeezeplay/src/ui/lua_jiveui.c?rev=3112&root=Jive&r1=3111&r2=3112&view=diff
==============================================================================
--- 7.4/trunk/squeezeplay/src/squeezeplay/src/ui/lua_jiveui.c (original)
+++ 7.4/trunk/squeezeplay/src/squeezeplay/src/ui/lua_jiveui.c Mon Oct 13 
13:08:31 2008
@@ -2184,6 +2184,7 @@
    tolua_constant(tolua_S,"EVENT_KEY_UP",JIVE_EVENT_KEY_UP);
    tolua_constant(tolua_S,"EVENT_KEY_PRESS",JIVE_EVENT_KEY_PRESS);
    tolua_constant(tolua_S,"EVENT_KEY_HOLD",JIVE_EVENT_KEY_HOLD);
+   tolua_constant(tolua_S,"EVENT_CHAR_PRESS",JIVE_EVENT_CHAR_PRESS);
    tolua_constant(tolua_S,"EVENT_MOUSE_DOWN",JIVE_EVENT_MOUSE_DOWN);
    tolua_constant(tolua_S,"EVENT_MOUSE_UP",JIVE_EVENT_MOUSE_UP);
    tolua_constant(tolua_S,"EVENT_MOUSE_PRESS",JIVE_EVENT_MOUSE_PRESS);

_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins

Reply via email to